summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml50
-rw-r--r--README.md1
-rw-r--r--SConstruct7
-rw-r--r--compat.py68
-rw-r--r--core/SCsub1
-rw-r--r--core/bind/core_bind.cpp539
-rw-r--r--core/bind/core_bind.h114
-rw-r--r--core/color.h2
-rw-r--r--core/command_queue_mt.h2
-rw-r--r--core/core_builders.py70
-rw-r--r--core/core_string_names.h2
-rw-r--r--core/cowdata.h51
-rw-r--r--core/debugger/debugger_marshalls.cpp2
-rw-r--r--core/debugger/debugger_marshalls.h4
-rw-r--r--core/debugger/remote_debugger.cpp33
-rw-r--r--core/debugger/script_debugger.h2
-rw-r--r--core/error_list.h2
-rw-r--r--core/error_macros.h2
-rw-r--r--core/global_constants.cpp2
-rw-r--r--core/hash_map.h2
-rw-r--r--core/hashfuncs.h3
-rw-r--r--core/image.cpp2
-rw-r--r--core/image.h2
-rw-r--r--core/input/SCsub20
-rw-r--r--core/input/default_controller_mappings.h (renamed from main/default_controller_mappings.h)0
-rw-r--r--core/input/gamecontrollerdb.txt (renamed from main/gamecontrollerdb.txt)0
-rw-r--r--core/input/gamecontrollerdb_204.txt (renamed from main/gamecontrollerdb_204.txt)0
-rw-r--r--core/input/gamecontrollerdb_205.txt (renamed from main/gamecontrollerdb_205.txt)0
-rw-r--r--core/input/godotcontrollerdb.txt (renamed from main/godotcontrollerdb.txt)0
-rw-r--r--core/input/input_builders.py73
-rw-r--r--core/input/input_event.cpp (renamed from core/os/input_event.cpp)34
-rw-r--r--core/input/input_event.h (renamed from core/os/input_event.h)30
-rw-r--r--core/input/input_filter.cpp (renamed from main/input_default.cpp)412
-rw-r--r--core/input/input_filter.h (renamed from main/input_default.h)223
-rw-r--r--core/input/input_map.cpp (renamed from core/input_map.cpp)0
-rw-r--r--core/input/input_map.h (renamed from core/input_map.h)2
-rw-r--r--core/int_types.h7
-rw-r--r--core/io/image_loader.h2
-rw-r--r--core/io/logger.h2
-rw-r--r--core/io/marshalls.h2
-rw-r--r--core/io/multiplayer_api.h6
-rw-r--r--core/io/networked_multiplayer_peer.h2
-rw-r--r--core/io/resource_loader.h2
-rw-r--r--core/io/resource_saver.h2
-rw-r--r--core/io/stream_peer_tcp.h2
-rw-r--r--core/io/xml_parser.h2
-rw-r--r--core/list.h6
-rw-r--r--core/map.h2
-rw-r--r--core/math/a_star.h6
-rw-r--r--core/math/audio_frame.h6
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/disjoint_set.h2
-rw-r--r--core/math/geometry.h2
-rw-r--r--core/math/octree.h2
-rw-r--r--core/math/quat.h2
-rw-r--r--core/math/triangulate.h2
-rw-r--r--core/message_queue.cpp4
-rw-r--r--core/method_bind.h2
-rw-r--r--core/method_ptrcall.h3
-rw-r--r--core/node_path.h2
-rw-r--r--core/oa_hash_map.h2
-rw-r--r--core/object.cpp20
-rw-r--r--core/object.h3
-rw-r--r--core/os/copymem.h2
-rw-r--r--core/os/dir_access.h2
-rw-r--r--core/os/file_access.h2
-rw-r--r--core/os/input.cpp157
-rw-r--r--core/os/input.h146
-rw-r--r--core/os/keyboard.h2
-rw-r--r--core/os/main_loop.cpp38
-rw-r--r--core/os/main_loop.h31
-rw-r--r--core/os/memory.h2
-rw-r--r--core/os/midi_driver.cpp4
-rw-r--r--core/os/midi_driver.h2
-rw-r--r--core/os/mutex.h2
-rw-r--r--core/os/os.cpp229
-rw-r--r--core/os/os.h249
-rw-r--r--core/os/rw_lock.h6
-rw-r--r--core/os/semaphore.h2
-rw-r--r--core/os/thread.h2
-rw-r--r--core/os/thread_dummy.h2
-rw-r--r--core/os/thread_safe.h2
-rw-r--r--core/pool_allocator.h2
-rw-r--r--core/print_string.h2
-rw-r--r--core/project_settings.h6
-rw-r--r--core/register_core_types.cpp8
-rw-r--r--core/register_core_types.h2
-rw-r--r--core/resource.h2
-rw-r--r--core/rid.h2
-rw-r--r--core/ring_buffer.h6
-rw-r--r--core/safe_refcount.h2
-rw-r--r--core/script_language.h3
-rw-r--r--core/set.h2
-rw-r--r--core/simple_type.h2
-rw-r--r--core/string_buffer.h2
-rw-r--r--core/type_info.h9
-rw-r--r--core/ucaps.h3
-rw-r--r--core/variant.h3
-rw-r--r--core/variant_parser.cpp2
-rw-r--r--core/vector.h2
-rw-r--r--core/version.h6
-rw-r--r--doc/Makefile7
-rw-r--r--doc/classes/EditorFeatureProfile.xml21
-rw-r--r--doc/classes/Object.xml11
-rw-r--r--drivers/alsa/audio_driver_alsa.h10
-rw-r--r--drivers/dummy/rasterizer_dummy.h122
-rw-r--r--drivers/gl_context/SCsub2
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp228
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.h2
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp6
-rw-r--r--drivers/gles2/rasterizer_gles2.h2
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp306
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h32
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp548
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h118
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp346
-rw-r--r--drivers/gles2/shader_compiler_gles2.h10
-rw-r--r--drivers/gles2/shader_gles2.h2
-rw-r--r--drivers/gles2/shaders/blend_shape.glsl2
-rw-r--r--drivers/unix/os_unix.cpp2
-rw-r--r--drivers/vulkan/SCsub2
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp6
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h8
-rw-r--r--drivers/vulkan/vulkan_context.cpp25
-rw-r--r--drivers/vulkan/vulkan_context.h18
-rw-r--r--editor/SCsub9
-rw-r--r--editor/animation_bezier_editor.cpp42
-rw-r--r--editor/animation_track_editor.cpp257
-rw-r--r--editor/animation_track_editor.h3
-rw-r--r--editor/animation_track_editor_plugins.cpp114
-rw-r--r--editor/code_editor.cpp98
-rw-r--r--editor/collada/SCsub5
-rw-r--r--editor/connections_dialog.cpp50
-rw-r--r--editor/create_dialog.cpp42
-rw-r--r--editor/debugger/editor_debugger_node.cpp19
-rw-r--r--editor/debugger/editor_debugger_tree.cpp11
-rw-r--r--editor/debugger/editor_network_profiler.cpp26
-rw-r--r--editor/debugger/editor_profiler.cpp16
-rw-r--r--editor/debugger/editor_visual_profiler.cpp18
-rw-r--r--editor/debugger/script_editor_debugger.cpp89
-rw-r--r--editor/dependency_editor.cpp24
-rw-r--r--editor/doc/SCsub5
-rw-r--r--editor/doc/doc_dump.cpp308
-rw-r--r--editor/doc/doc_dump.h41
-rw-r--r--editor/doc_data.cpp (renamed from editor/doc/doc_data.cpp)0
-rw-r--r--editor/doc_data.h (renamed from editor/doc/doc_data.h)0
-rw-r--r--editor/editor_about.cpp29
-rw-r--r--editor/editor_about.h2
-rw-r--r--editor/editor_asset_installer.cpp24
-rw-r--r--editor/editor_audio_buses.cpp88
-rw-r--r--editor/editor_autoload_settings.cpp12
-rw-r--r--editor/editor_builders.py17
-rw-r--r--editor/editor_dir_dialog.cpp15
-rw-r--r--editor/editor_feature_profile.cpp20
-rw-r--r--editor/editor_file_dialog.cpp209
-rw-r--r--editor/editor_file_dialog.h20
-rw-r--r--editor/editor_fonts.cpp2
-rw-r--r--editor/editor_help.cpp76
-rw-r--r--editor/editor_help.h4
-rw-r--r--editor/editor_help_search.cpp48
-rw-r--r--editor/editor_inspector.cpp121
-rw-r--r--editor/editor_layouts_dialog.cpp16
-rw-r--r--editor/editor_log.cpp18
-rw-r--r--editor/editor_node.cpp557
-rw-r--r--editor/editor_node.h18
-rw-r--r--editor/editor_path.cpp2
-rw-r--r--editor/editor_plugin.cpp102
-rw-r--r--editor/editor_plugin.h12
-rw-r--r--editor/editor_plugin_settings.cpp4
-rw-r--r--editor/editor_properties.cpp106
-rw-r--r--editor/editor_properties_array_dict.cpp18
-rw-r--r--editor/editor_resource_preview.cpp4
-rw-r--r--editor/editor_run.cpp19
-rw-r--r--editor/editor_sectioned_inspector.cpp4
-rw-r--r--editor/editor_settings.cpp4
-rw-r--r--editor/editor_spin_slider.cpp76
-rw-r--r--editor/editor_spin_slider.h1
-rw-r--r--editor/editor_sub_scene.cpp10
-rw-r--r--editor/editor_themes.cpp22
-rw-r--r--editor/export_template_manager.cpp37
-rw-r--r--editor/file_type_cache.cpp104
-rw-r--r--editor/file_type_cache.h57
-rw-r--r--editor/filesystem_dock.cpp160
-rw-r--r--editor/find_in_files.cpp29
-rw-r--r--editor/find_in_files.h5
-rw-r--r--editor/groups_editor.cpp68
-rw-r--r--editor/groups_editor.h4
-rw-r--r--editor/icons/AnimatedSprite2D.svg (renamed from editor/icons/AnimatedSprite.svg)0
-rw-r--r--editor/icons/Area3D.svg (renamed from editor/icons/Area.svg)0
-rw-r--r--editor/icons/BoneAttachment3D.svg (renamed from editor/icons/BoneAttachment.svg)0
-rw-r--r--editor/icons/BoxShape3D.svg (renamed from editor/icons/BoxShape.svg)0
-rw-r--r--editor/icons/CPUParticles3D.svg (renamed from editor/icons/CPUParticles.svg)0
-rw-r--r--editor/icons/Camera3D.svg (renamed from editor/icons/Camera.svg)0
-rw-r--r--editor/icons/CapsuleShape3D.svg (renamed from editor/icons/CapsuleShape.svg)0
-rw-r--r--editor/icons/ClippedCamera3D.svg (renamed from editor/icons/ClippedCamera.svg)0
-rw-r--r--editor/icons/CollisionPolygon3D.svg (renamed from editor/icons/CollisionPolygon.svg)0
-rw-r--r--editor/icons/CollisionShape3D.svg (renamed from editor/icons/CollisionShape.svg)0
-rw-r--r--editor/icons/ConcavePolygonShape3D.svg (renamed from editor/icons/ConcavePolygonShape.svg)0
-rw-r--r--editor/icons/ConeTwistJoint3D.svg (renamed from editor/icons/ConeTwistJoint.svg)0
-rw-r--r--editor/icons/ConvexPolygonShape3D.svg (renamed from editor/icons/ConvexPolygonShape.svg)0
-rw-r--r--editor/icons/CylinderShape3D.svg (renamed from editor/icons/CylinderShape.svg)0
-rw-r--r--editor/icons/DirectionalLight3D.svg (renamed from editor/icons/DirectionalLight.svg)0
-rw-r--r--editor/icons/GPUParticles2D.svg (renamed from editor/icons/Particles2D.svg)0
-rw-r--r--editor/icons/GPUParticles3D.svg (renamed from editor/icons/Particles.svg)0
-rw-r--r--editor/icons/Generic6DOFJoint3D.svg (renamed from editor/icons/Generic6DOFJoint.svg)0
-rw-r--r--editor/icons/Gizmo3DSamplePlayer.svg (renamed from editor/icons/GizmoSpatialSamplePlayer.svg)0
-rw-r--r--editor/icons/HeightMapShape3D.svg (renamed from editor/icons/HeightMapShape.svg)0
-rw-r--r--editor/icons/HingeJoint3D.svg (renamed from editor/icons/HingeJoint.svg)0
-rw-r--r--editor/icons/ImmediateGeometry3D.svg (renamed from editor/icons/ImmediateGeometry.svg)0
-rw-r--r--editor/icons/KinematicBody3D.svg (renamed from editor/icons/KinematicBody.svg)0
-rw-r--r--editor/icons/Listener3D.svg (renamed from editor/icons/Listener.svg)0
-rw-r--r--editor/icons/MeshInstance3D.svg (renamed from editor/icons/MeshInstance.svg)0
-rw-r--r--editor/icons/MultiMeshInstance3D.svg (renamed from editor/icons/MultiMeshInstance.svg)0
-rw-r--r--editor/icons/Navigation3D.svg (renamed from editor/icons/Navigation.svg)0
-rw-r--r--editor/icons/NavigationAgent3D.svg (renamed from editor/icons/NavigationAgent.svg)0
-rw-r--r--editor/icons/NavigationObstacle3D.svg (renamed from editor/icons/NavigationObstacle.svg)0
-rw-r--r--editor/icons/NavigationRegion3D.svg (renamed from editor/icons/NavigationRegion.svg)0
-rw-r--r--editor/icons/Node3D.svg (renamed from editor/icons/Spatial.svg)0
-rw-r--r--editor/icons/OmniLight3D.svg (renamed from editor/icons/OmniLight.svg)0
-rw-r--r--editor/icons/Path3D.svg (renamed from editor/icons/Path.svg)0
-rw-r--r--editor/icons/PathFollow3D.svg (renamed from editor/icons/PathFollow.svg)0
-rw-r--r--editor/icons/PhysicalBone3D.svg (renamed from editor/icons/PhysicalBone.svg)0
-rw-r--r--editor/icons/PinJoint3D.svg (renamed from editor/icons/PinJoint.svg)0
-rw-r--r--editor/icons/ProximityGroup3D.svg (renamed from editor/icons/ProximityGroup.svg)0
-rw-r--r--editor/icons/RayCast3D.svg (renamed from editor/icons/RayCast.svg)0
-rw-r--r--editor/icons/RayShape3D.svg (renamed from editor/icons/RayShape.svg)0
-rw-r--r--editor/icons/RemoteTransform3D.svg (renamed from editor/icons/RemoteTransform.svg)0
-rw-r--r--editor/icons/RigidBody3D.svg (renamed from editor/icons/RigidBody.svg)0
-rw-r--r--editor/icons/Skeleton3D.svg (renamed from editor/icons/Skeleton.svg)0
-rw-r--r--editor/icons/SkeletonIK3D.svg (renamed from editor/icons/SkeletonIK.svg)0
-rw-r--r--editor/icons/SliderJoint3D.svg (renamed from editor/icons/SliderJoint.svg)0
-rw-r--r--editor/icons/SoftBody3D.svg (renamed from editor/icons/SoftBody.svg)0
-rw-r--r--editor/icons/SpatialMaterial.svg1
-rw-r--r--editor/icons/SphereShape3D.svg (renamed from editor/icons/SphereShape.svg)0
-rw-r--r--editor/icons/SpotLight3D.svg (renamed from editor/icons/SpotLight.svg)0
-rw-r--r--editor/icons/SpringArm3D.svg (renamed from editor/icons/SpringArm.svg)0
-rw-r--r--editor/icons/Sprite2D.svg (renamed from editor/icons/Sprite.svg)0
-rw-r--r--editor/icons/StaticBody3D.svg (renamed from editor/icons/StaticBody.svg)0
-rw-r--r--editor/icons/VehicleBody3D.svg (renamed from editor/icons/VehicleBody.svg)0
-rw-r--r--editor/icons/VehicleWheel3D.svg (renamed from editor/icons/VehicleWheel.svg)0
-rw-r--r--editor/icons/VisibilityEnabler3D.svg (renamed from editor/icons/VisibilityEnabler.svg)0
-rw-r--r--editor/icons/VisibilityNotifier3D.svg (renamed from editor/icons/VisibilityNotifier.svg)0
-rw-r--r--editor/icons/World3D.svg (renamed from editor/icons/World.svg)0
-rw-r--r--editor/icons/WorldMarginShape.svg1
-rw-r--r--editor/icons/WorldMarginShape3D.svg (renamed from editor/icons/PlaneShape.svg)0
-rw-r--r--editor/icons/editor_icons_builders.py3
-rw-r--r--editor/import/collada.cpp (renamed from editor/collada/collada.cpp)0
-rw-r--r--editor/import/collada.h (renamed from editor/collada/collada.h)0
-rw-r--r--editor/import/editor_import_collada.cpp88
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp50
-rw-r--r--editor/import/editor_scene_importer_gltf.h24
-rw-r--r--editor/import/resource_importer_obj.cpp8
-rw-r--r--editor/import/resource_importer_scene.cpp130
-rw-r--r--editor/import/resource_importer_scene.h4
-rw-r--r--editor/import/resource_importer_texture.cpp2
-rw-r--r--editor/import/resource_importer_texture.h8
-rw-r--r--editor/import_dock.cpp8
-rw-r--r--editor/inspector_dock.cpp50
-rw-r--r--editor/node_3d_editor_gizmos.cpp (renamed from editor/spatial_editor_gizmos.cpp)982
-rw-r--r--editor/node_3d_editor_gizmos.h434
-rw-r--r--editor/node_dock.cpp4
-rw-r--r--editor/pane_drag.cpp4
-rw-r--r--editor/plugin_config_dialog.cpp9
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp14
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp36
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp52
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp38
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp140
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp96
-rw-r--r--editor/plugins/animation_state_machine_editor.h1
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp108
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp28
-rw-r--r--editor/plugins/camera_3d_editor_plugin.cpp (renamed from editor/plugins/camera_editor_plugin.cpp)46
-rw-r--r--editor/plugins/camera_3d_editor_plugin.h (renamed from editor/plugins/camera_editor_plugin.h)20
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp346
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h4
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.cpp (renamed from editor/plugins/collision_polygon_editor_plugin.cpp)66
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.h (renamed from editor/plugins/collision_polygon_editor_plugin.h)28
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp11
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.cpp (renamed from editor/plugins/cpu_particles_editor_plugin.cpp)48
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.h (renamed from editor/plugins/cpu_particles_editor_plugin.h)28
-rw-r--r--editor/plugins/curve_editor_plugin.cpp26
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp1
-rw-r--r--editor/plugins/editor_preview_plugins.cpp194
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp12
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.cpp (renamed from editor/plugins/particles_2d_editor_plugin.cpp)54
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.h (renamed from editor/plugins/particles_2d_editor_plugin.h)14
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp (renamed from editor/plugins/particles_editor_plugin.cpp)80
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.h (renamed from editor/plugins/particles_editor_plugin.h)34
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp2
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp4
-rw-r--r--editor/plugins/material_editor_plugin.cpp68
-rw-r--r--editor/plugins/material_editor_plugin.h18
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp22
-rw-r--r--editor/plugins/mesh_editor_plugin.h18
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.cpp (renamed from editor/plugins/mesh_instance_editor_plugin.cpp)132
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.h (renamed from editor/plugins/mesh_instance_editor_plugin.h)28
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp34
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp38
-rw-r--r--editor/plugins/multimesh_editor_plugin.h8
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp (renamed from editor/plugins/spatial_editor_plugin.cpp)1236
-rw-r--r--editor/plugins/node_3d_editor_plugin.h (renamed from editor/plugins/spatial_editor_plugin.h)188
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp18
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp (renamed from editor/plugins/path_editor_plugin.cpp)134
-rw-r--r--editor/plugins/path_3d_editor_plugin.h (renamed from editor/plugins/path_editor_plugin.h)42
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.cpp (renamed from editor/plugins/physical_bone_plugin.cpp)39
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.h (renamed from editor/plugins/physical_bone_plugin.h)28
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp59
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp14
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp10
-rw-r--r--editor/plugins/script_editor_plugin.cpp83
-rw-r--r--editor/plugins/script_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp98
-rw-r--r--editor/plugins/script_text_editor.h2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp86
-rw-r--r--editor/plugins/shader_editor_plugin.h2
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp (renamed from editor/plugins/skeleton_editor_plugin.cpp)68
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h (renamed from editor/plugins/skeleton_editor_plugin.h)44
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.cpp (renamed from editor/plugins/skeleton_ik_editor_plugin.cpp)33
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.h (renamed from editor/plugins/skeleton_ik_editor_plugin.h)20
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.cpp (renamed from editor/plugins/sprite_editor_plugin.cpp)74
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.h (renamed from editor/plugins/sprite_editor_plugin.h)26
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp55
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h2
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp2
-rw-r--r--editor/plugins/text_editor.cpp72
-rw-r--r--editor/plugins/text_editor.h2
-rw-r--r--editor/plugins/texture_editor_plugin.cpp4
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp32
-rw-r--r--editor/plugins/texture_region_editor_plugin.h6
-rw-r--r--editor/plugins/theme_editor_plugin.cpp22
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp40
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp98
-rw-r--r--editor/plugins/tile_set_editor_plugin.h4
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp34
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp146
-rw-r--r--editor/progress_dialog.cpp17
-rw-r--r--editor/progress_dialog.h4
-rw-r--r--editor/project_export.cpp99
-rw-r--r--editor/project_export.h1
-rw-r--r--editor/project_manager.cpp209
-rw-r--r--editor/project_manager.h1
-rw-r--r--editor/project_settings_editor.cpp149
-rw-r--r--editor/project_settings_editor.h6
-rw-r--r--editor/property_editor.cpp100
-rw-r--r--editor/property_editor.h4
-rw-r--r--editor/property_selector.cpp60
-rw-r--r--editor/quick_open.cpp16
-rw-r--r--editor/quick_open.h2
-rw-r--r--editor/rename_dialog.cpp70
-rw-r--r--editor/rename_dialog.h1
-rw-r--r--editor/reparent_dialog.cpp6
-rw-r--r--editor/scene_tree_dock.cpp184
-rw-r--r--editor/scene_tree_editor.cpp89
-rw-r--r--editor/script_create_dialog.cpp86
-rw-r--r--editor/script_create_dialog.h2
-rw-r--r--editor/settings_config_dialog.cpp58
-rw-r--r--editor/spatial_editor_gizmos.h434
-rw-r--r--gles_builders.py2
-rw-r--r--main/SCsub9
-rw-r--r--main/main.cpp403
-rw-r--r--main/main_builders.py69
-rw-r--r--main/performance.cpp38
-rw-r--r--main/tests/test_gui.cpp8
-rw-r--r--main/tests/test_main.cpp15
-rw-r--r--main/tests/test_main.h3
-rw-r--r--main/tests/test_math.cpp2
-rw-r--r--main/tests/test_oa_hash_map.cpp3
-rw-r--r--main/tests/test_oa_hash_map.h1
-rw-r--r--main/tests/test_ordered_hash_map.cpp2
-rw-r--r--main/tests/test_ordered_hash_map.h4
-rw-r--r--main/tests/test_physics_2d.cpp89
-rw-r--r--main/tests/test_physics_3d.cpp (renamed from main/tests/test_physics.cpp)151
-rw-r--r--main/tests/test_physics_3d.h (renamed from main/tests/test_physics.h)4
-rw-r--r--main/tests/test_render.cpp27
-rw-r--r--main/tests/test_shader_lang.cpp2
-rw-r--r--methods.py21
-rw-r--r--modules/arkit/arkit_interface.mm4
-rw-r--r--modules/assimp/SCsub2
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp82
-rw-r--r--modules/assimp/editor_scene_importer_assimp.h18
-rw-r--r--modules/assimp/import_state.h22
-rw-r--r--modules/assimp/register_types.h5
-rw-r--r--modules/basis_universal/register_types.cpp25
-rw-r--r--modules/basis_universal/register_types.h5
-rw-r--r--modules/basis_universal/texture_basisu.cpp10
-rw-r--r--modules/bmp/register_types.h5
-rw-r--r--modules/bullet/area_bullet.cpp48
-rw-r--r--modules/bullet/area_bullet.h14
-rw-r--r--modules/bullet/bullet_physics_server.cpp384
-rw-r--r--modules/bullet/bullet_physics_server.h18
-rw-r--r--modules/bullet/collision_object_bullet.cpp2
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp28
-rw-r--r--modules/bullet/cone_twist_joint_bullet.h6
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp98
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.h12
-rw-r--r--modules/bullet/godot_result_callbacks.cpp4
-rw-r--r--modules/bullet/godot_result_callbacks.h14
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp54
-rw-r--r--modules/bullet/hinge_joint_bullet.h10
-rw-r--r--modules/bullet/joint_bullet.h4
-rw-r--r--modules/bullet/pin_joint_bullet.cpp16
-rw-r--r--modules/bullet/pin_joint_bullet.h6
-rw-r--r--modules/bullet/register_types.cpp8
-rw-r--r--modules/bullet/rid_bullet.h8
-rw-r--r--modules/bullet/rigid_body_bullet.cpp126
-rw-r--r--modules/bullet/rigid_body_bullet.h26
-rw-r--r--modules/bullet/shape_bullet.cpp38
-rw-r--r--modules/bullet/shape_bullet.h22
-rw-r--r--modules/bullet/slider_joint_bullet.cpp94
-rw-r--r--modules/bullet/slider_joint_bullet.h6
-rw-r--r--modules/bullet/soft_body_bullet.cpp18
-rw-r--r--modules/bullet/soft_body_bullet.h4
-rw-r--r--modules/bullet/space_bullet.cpp86
-rw-r--r--modules/bullet/space_bullet.h22
-rw-r--r--modules/csg/csg_gizmos.cpp144
-rw-r--r--modules/csg/csg_gizmos.h20
-rw-r--r--modules/csg/csg_shape.cpp532
-rw-r--r--modules/csg/csg_shape.h70
-rw-r--r--modules/csg/icons/CSGBox3D.svg (renamed from modules/csg/icons/CSGBox.svg)0
-rw-r--r--modules/csg/icons/CSGCapsule3D.svg (renamed from modules/csg/icons/CSGCapsule.svg)0
-rw-r--r--modules/csg/icons/CSGCombiner3D.svg (renamed from modules/csg/icons/CSGCombiner.svg)0
-rw-r--r--modules/csg/icons/CSGCylinder3D.svg (renamed from modules/csg/icons/CSGCylinder.svg)0
-rw-r--r--modules/csg/icons/CSGMesh3D.svg (renamed from modules/csg/icons/CSGMesh.svg)0
-rw-r--r--modules/csg/icons/CSGPolygon3D.svg (renamed from modules/csg/icons/CSGPolygon.svg)0
-rw-r--r--modules/csg/icons/CSGSphere3D.svg (renamed from modules/csg/icons/CSGSphere.svg)0
-rw-r--r--modules/csg/icons/CSGTorus3D.svg (renamed from modules/csg/icons/CSGTorus.svg)0
-rw-r--r--modules/csg/register_types.cpp27
-rw-r--r--modules/csg/register_types.h5
-rw-r--r--modules/cvtt/register_types.h9
-rw-r--r--modules/dds/register_types.h5
-rw-r--r--modules/enet/register_types.h5
-rw-r--r--modules/etc/register_types.h5
-rw-r--r--modules/freetype/SCsub4
-rw-r--r--modules/freetype/register_types.h5
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp20
-rw-r--r--modules/gdnative/arvr/register_types.h5
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp34
-rw-r--r--modules/gdnative/nativescript/SCsub2
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp4
-rw-r--r--modules/gdnative/nativescript/register_types.h5
-rw-r--r--modules/gdnative/net/register_types.h5
-rw-r--r--modules/gdnative/pluginscript/register_types.h5
-rw-r--r--modules/gdnative/register_types.h5
-rw-r--r--modules/gdnative/videodecoder/register_types.h5
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp2
-rw-r--r--modules/gdnavigation/gd_navigation_server.h4
-rw-r--r--modules/gdnavigation/nav_region.h2
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.cpp14
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.h6
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp58
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.h2
-rw-r--r--modules/gdnavigation/register_types.cpp6
-rw-r--r--modules/gdnavigation/register_types.h5
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp10
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp4
-rw-r--r--modules/gdscript/language_server/lsp.hpp2
-rw-r--r--modules/gdscript/register_types.h5
-rw-r--r--modules/glslang/register_types.cpp2
-rw-r--r--modules/glslang/register_types.h6
-rw-r--r--modules/gridmap/grid_map.cpp154
-rw-r--r--modules/gridmap/grid_map.h14
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp165
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h10
-rw-r--r--modules/gridmap/register_types.h5
-rw-r--r--modules/hdr/register_types.h5
-rw-r--r--modules/jpg/register_types.h5
-rw-r--r--modules/jsonrpc/register_types.h5
-rwxr-xr-xmodules/mbedtls/register_types.h5
-rw-r--r--modules/mobile_vr/mobile_vr_interface.cpp9
-rw-r--r--modules/mobile_vr/register_types.h5
-rw-r--r--modules/mono/build_scripts/make_android_mono_config.py3
-rw-r--r--modules/mono/build_scripts/mono_configure.py4
-rw-r--r--modules/mono/build_scripts/mono_reg_utils.py9
-rw-r--r--modules/mono/config.py2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs2
-rw-r--r--modules/mono/editor/bindings_generator.h2
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.h2
-rw-r--r--modules/ogg/register_types.h5
-rw-r--r--modules/opensimplex/noise_texture.cpp10
-rw-r--r--modules/opensimplex/register_types.h5
-rw-r--r--modules/opus/register_types.h5
-rw-r--r--modules/pvr/register_types.h5
-rw-r--r--modules/regex/register_types.h5
-rw-r--r--modules/squish/register_types.h5
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp11
-rw-r--r--modules/stb_vorbis/register_types.h5
-rw-r--r--modules/svg/register_types.h5
-rw-r--r--modules/tga/register_types.h5
-rw-r--r--modules/theora/register_types.h5
-rw-r--r--modules/tinyexr/register_types.h5
-rw-r--r--modules/upnp/register_types.h5
-rw-r--r--modules/vhacd/register_types.h5
-rw-r--r--modules/visual_script/register_types.h5
-rw-r--r--modules/visual_script/visual_script_editor.cpp205
-rw-r--r--modules/visual_script/visual_script_editor.h4
-rw-r--r--modules/visual_script/visual_script_nodes.cpp10
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp80
-rw-r--r--modules/visual_script/visual_script_property_selector.h1
-rw-r--r--modules/vorbis/register_types.h5
-rw-r--r--modules/webm/libvpx/SCsub6
-rw-r--r--modules/webm/register_types.h5
-rw-r--r--modules/webp/register_types.h5
-rw-r--r--modules/webrtc/register_types.h5
-rw-r--r--modules/websocket/register_types.h5
-rw-r--r--modules/xatlas_unwrap/register_types.h5
-rw-r--r--platform/SCsub4
-rw-r--r--platform/android/api/api.h5
-rw-r--r--platform/android/export/export.h5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java4
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java4
-rw-r--r--platform/android/java_godot_lib_jni.cpp4
-rw-r--r--platform/android/os_android.cpp18
-rw-r--r--platform/android/os_android.h7
-rw-r--r--platform/haiku/haiku_direct_window.cpp2
-rw-r--r--platform/haiku/haiku_direct_window.h2
-rw-r--r--platform/haiku/os_haiku.cpp20
-rw-r--r--platform/haiku/os_haiku.h6
-rw-r--r--platform/iphone/export/export.h5
-rw-r--r--platform/iphone/os_iphone.cpp22
-rw-r--r--platform/iphone/os_iphone.h10
-rw-r--r--platform/iphone/vulkan_context_iphone.h2
-rw-r--r--platform/iphone/vulkan_context_iphone.mm2
-rw-r--r--platform/javascript/api/api.h5
-rw-r--r--platform/javascript/os_javascript.cpp18
-rw-r--r--platform/javascript/os_javascript.h4
-rw-r--r--platform/linuxbsd/SCsub23
-rw-r--r--platform/linuxbsd/context_gl_x11.cpp (renamed from platform/x11/context_gl_x11.cpp)0
-rw-r--r--platform/linuxbsd/context_gl_x11.h (renamed from platform/x11/context_gl_x11.h)0
-rw-r--r--platform/linuxbsd/crash_handler_linuxbsd.cpp (renamed from platform/x11/crash_handler_x11.cpp)4
-rw-r--r--platform/linuxbsd/crash_handler_linuxbsd.h (renamed from platform/x11/crash_handler_x11.h)2
-rw-r--r--platform/linuxbsd/detect.py (renamed from platform/x11/detect.py)8
-rw-r--r--platform/linuxbsd/detect_prime_x11.cpp (renamed from platform/x11/detect_prime.cpp)4
-rw-r--r--platform/linuxbsd/detect_prime_x11.h (renamed from platform/x11/detect_prime.h)2
-rw-r--r--platform/linuxbsd/display_server_x11.cpp (renamed from platform/x11/os_x11.cpp)4138
-rw-r--r--platform/linuxbsd/display_server_x11.h352
-rw-r--r--platform/linuxbsd/export/export.cpp (renamed from platform/x11/export/export.cpp)6
-rw-r--r--platform/linuxbsd/export/export.h (renamed from platform/x11/export/export.h)7
-rw-r--r--platform/linuxbsd/godot_linuxbsd.cpp (renamed from platform/x11/godot_x11.cpp)6
-rw-r--r--platform/linuxbsd/joypad_linux.cpp (renamed from platform/x11/joypad_linux.cpp)27
-rw-r--r--platform/linuxbsd/joypad_linux.h (renamed from platform/x11/joypad_linux.h)10
-rw-r--r--platform/linuxbsd/key_mapping_x11.cpp (renamed from platform/x11/key_mapping_x11.cpp)0
-rw-r--r--platform/linuxbsd/key_mapping_x11.h (renamed from platform/x11/key_mapping_x11.h)0
-rw-r--r--platform/linuxbsd/logo.png (renamed from platform/x11/logo.png)bin1679 -> 1679 bytes
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp381
-rw-r--r--platform/linuxbsd/os_linuxbsd.h106
-rw-r--r--platform/linuxbsd/pck_embed.ld (renamed from platform/x11/pck_embed.ld)0
-rw-r--r--platform/linuxbsd/pck_embed.legacy.ld (renamed from platform/x11/pck_embed.legacy.ld)0
-rw-r--r--platform/linuxbsd/platform_config.h (renamed from platform/x11/platform_config.h)0
-rw-r--r--platform/linuxbsd/platform_linuxbsd_builders.py (renamed from platform/x11/platform_x11_builders.py)2
-rw-r--r--platform/linuxbsd/vulkan_context_x11.cpp (renamed from platform/x11/vulkan_context_x11.cpp)6
-rw-r--r--platform/linuxbsd/vulkan_context_x11.h (renamed from platform/x11/vulkan_context_x11.h)2
-rw-r--r--platform/osx/SCsub1
-rw-r--r--platform/osx/display_server_osx.h308
-rw-r--r--platform/osx/display_server_osx.mm3595
-rw-r--r--platform/osx/export/export.h5
-rw-r--r--platform/osx/joypad_osx.cpp28
-rw-r--r--platform/osx/joypad_osx.h6
-rw-r--r--platform/osx/os_osx.h244
-rw-r--r--platform/osx/os_osx.mm2880
-rw-r--r--platform/osx/vulkan_context_osx.h2
-rw-r--r--platform/osx/vulkan_context_osx.mm6
-rw-r--r--platform/server/detect.py2
-rw-r--r--platform/server/os_server.cpp10
-rw-r--r--platform/server/os_server.h10
-rw-r--r--platform/uwp/export/export.h5
-rw-r--r--platform/uwp/joypad_uwp.h2
-rw-r--r--platform/uwp/os_uwp.cpp14
-rw-r--r--platform/uwp/os_uwp.h9
-rw-r--r--platform/windows/SCsub1
-rw-r--r--platform/windows/display_server_windows.cpp2998
-rw-r--r--platform/windows/display_server_windows.h419
-rw-r--r--platform/windows/joypad_windows.cpp26
-rw-r--r--platform/windows/joypad_windows.h6
-rw-r--r--platform/windows/os_windows.cpp2608
-rw-r--r--platform/windows/os_windows.h297
-rw-r--r--platform/windows/vulkan_context_win.cpp4
-rw-r--r--platform/windows/vulkan_context_win.h2
-rw-r--r--platform/x11/SCsub21
-rw-r--r--platform/x11/os_x11.h339
-rw-r--r--platform_methods.py5
-rw-r--r--scene/2d/animated_sprite_2d.cpp (renamed from scene/2d/animated_sprite.cpp)142
-rw-r--r--scene/2d/animated_sprite_2d.h (renamed from scene/2d/animated_sprite.h)12
-rw-r--r--scene/2d/area_2d.cpp40
-rw-r--r--scene/2d/audio_stream_player_2d.cpp8
-rw-r--r--scene/2d/back_buffer_copy.cpp6
-rw-r--r--scene/2d/camera_2d.cpp2
-rw-r--r--scene/2d/camera_2d.h2
-rw-r--r--scene/2d/canvas_modulate.cpp10
-rw-r--r--scene/2d/collision_object_2d.cpp56
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/collision_shape_2d.cpp2
-rw-r--r--scene/2d/cpu_particles_2d.cpp52
-rw-r--r--scene/2d/gpu_particles_2d.cpp (renamed from scene/2d/particles_2d.cpp)220
-rw-r--r--scene/2d/gpu_particles_2d.h (renamed from scene/2d/particles_2d.h)12
-rw-r--r--scene/2d/joints_2d.cpp34
-rw-r--r--scene/2d/light_2d.cpp56
-rw-r--r--scene/2d/light_occluder_2d.cpp32
-rw-r--r--scene/2d/line_2d.cpp2
-rw-r--r--scene/2d/navigation_2d.cpp20
-rw-r--r--scene/2d/navigation_2d.h2
-rw-r--r--scene/2d/navigation_agent_2d.cpp30
-rw-r--r--scene/2d/navigation_obstacle_2d.cpp20
-rw-r--r--scene/2d/navigation_region_2d.cpp (renamed from scene/2d/navigation_polygon.cpp)24
-rw-r--r--scene/2d/navigation_region_2d.h (renamed from scene/2d/navigation_polygon.h)8
-rw-r--r--scene/2d/node_2d.cpp18
-rw-r--r--scene/2d/node_2d.h2
-rw-r--r--scene/2d/parallax_layer.cpp2
-rw-r--r--scene/2d/path_texture.cpp90
-rw-r--r--scene/2d/path_texture.h64
-rw-r--r--scene/2d/physics_body_2d.cpp134
-rw-r--r--scene/2d/physics_body_2d.h10
-rw-r--r--scene/2d/polygon_2d.cpp8
-rw-r--r--scene/2d/ray_cast_2d.cpp6
-rw-r--r--scene/2d/skeleton_2d.cpp10
-rw-r--r--scene/2d/sprite_2d.cpp (renamed from scene/2d/sprite.cpp)180
-rw-r--r--scene/2d/sprite_2d.h (renamed from scene/2d/sprite.h)14
-rw-r--r--scene/2d/tile_map.cpp96
-rw-r--r--scene/2d/touch_screen_button.cpp19
-rw-r--r--scene/2d/visibility_notifier_2d.cpp14
-rw-r--r--scene/2d/y_sort.cpp4
-rw-r--r--scene/3d/SCsub7
-rw-r--r--scene/3d/area_3d.cpp (renamed from scene/3d/area.cpp)280
-rw-r--r--scene/3d/area_3d.h (renamed from scene/3d/area.h)18
-rw-r--r--scene/3d/arvr_nodes.cpp16
-rw-r--r--scene/3d/arvr_nodes.h20
-rw-r--r--scene/3d/audio_stream_player_3d.cpp30
-rw-r--r--scene/3d/audio_stream_player_3d.h12
-rw-r--r--scene/3d/baked_lightmap.cpp30
-rw-r--r--scene/3d/bone_attachment_3d.cpp (renamed from scene/3d/bone_attachment.cpp)30
-rw-r--r--scene/3d/bone_attachment_3d.h (renamed from scene/3d/bone_attachment.h)10
-rw-r--r--scene/3d/camera_3d.cpp (renamed from scene/3d/camera.cpp)338
-rw-r--r--scene/3d/camera_3d.h (renamed from scene/3d/camera.h)56
-rw-r--r--scene/3d/collision_object_3d.cpp (renamed from scene/3d/collision_object.cpp)156
-rw-r--r--scene/3d/collision_object_3d.h (renamed from scene/3d/collision_object.h)26
-rw-r--r--scene/3d/collision_polygon_3d.cpp (renamed from scene/3d/collision_polygon.cpp)58
-rw-r--r--scene/3d/collision_polygon_3d.h (renamed from scene/3d/collision_polygon.h)20
-rw-r--r--scene/3d/collision_shape_3d.cpp (renamed from scene/3d/collision_shape.cpp)96
-rw-r--r--scene/3d/collision_shape_3d.h (renamed from scene/3d/collision_shape.h)24
-rw-r--r--scene/3d/cpu_particles_3d.cpp (renamed from scene/3d/cpu_particles.cpp)316
-rw-r--r--scene/3d/cpu_particles_3d.h (renamed from scene/3d/cpu_particles.h)20
-rw-r--r--scene/3d/gi_probe.cpp54
-rw-r--r--scene/3d/gi_probe.h8
-rw-r--r--scene/3d/gpu_particles_3d.cpp (renamed from scene/3d/particles.cpp)228
-rw-r--r--scene/3d/gpu_particles_3d.h (renamed from scene/3d/particles.h)14
-rw-r--r--scene/3d/immediate_geometry_3d.cpp (renamed from scene/3d/immediate_geometry.cpp)78
-rw-r--r--scene/3d/immediate_geometry_3d.h (renamed from scene/3d/immediate_geometry.h)18
-rw-r--r--scene/3d/interpolated_camera.cpp155
-rw-r--r--scene/3d/interpolated_camera.h63
-rw-r--r--scene/3d/light_3d.cpp (renamed from scene/3d/light.cpp)196
-rw-r--r--scene/3d/light_3d.h (renamed from scene/3d/light.h)88
-rw-r--r--scene/3d/listener_3d.cpp (renamed from scene/3d/listener.cpp)44
-rw-r--r--scene/3d/listener_3d.h (renamed from scene/3d/listener.h)18
-rw-r--r--scene/3d/mesh_instance_3d.cpp (renamed from scene/3d/mesh_instance.cpp)130
-rw-r--r--scene/3d/mesh_instance_3d.h (renamed from scene/3d/mesh_instance.h)14
-rw-r--r--scene/3d/multimesh_instance_3d.cpp (renamed from scene/3d/multimesh_instance.cpp)22
-rw-r--r--scene/3d/multimesh_instance_3d.h (renamed from scene/3d/multimesh_instance.h)16
-rw-r--r--scene/3d/navigation_3d.cpp (renamed from scene/3d/navigation.cpp)80
-rw-r--r--scene/3d/navigation_3d.h (renamed from scene/3d/navigation.h)18
-rw-r--r--scene/3d/navigation_agent_3d.cpp (renamed from scene/3d/navigation_agent.cpp)170
-rw-r--r--scene/3d/navigation_agent_3d.h (renamed from scene/3d/navigation_agent.h)22
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp (renamed from scene/3d/navigation_obstacle.cpp)72
-rw-r--r--scene/3d/navigation_obstacle_3d.h (renamed from scene/3d/navigation_obstacle.h)18
-rw-r--r--scene/3d/navigation_region_3d.cpp (renamed from scene/3d/navigation_region.cpp)82
-rw-r--r--scene/3d/navigation_region_3d.h (renamed from scene/3d/navigation_region.h)16
-rw-r--r--scene/3d/node_3d.cpp (renamed from scene/3d/spatial.cpp)272
-rw-r--r--scene/3d/node_3d.h (renamed from scene/3d/spatial.h)42
-rw-r--r--scene/3d/path_3d.cpp (renamed from scene/3d/path.cpp)100
-rw-r--r--scene/3d/path_3d.h (renamed from scene/3d/path.h)20
-rw-r--r--scene/3d/physics_body_3d.cpp (renamed from scene/3d/physics_body.cpp)1004
-rw-r--r--scene/3d/physics_body_3d.h (renamed from scene/3d/physics_body.h)98
-rw-r--r--scene/3d/physics_joint.h343
-rw-r--r--scene/3d/physics_joint_3d.cpp (renamed from scene/3d/physics_joint.cpp)338
-rw-r--r--scene/3d/physics_joint_3d.h343
-rw-r--r--scene/3d/position_3d.h6
-rw-r--r--scene/3d/proximity_group_3d.cpp (renamed from scene/3d/proximity_group.cpp)52
-rw-r--r--scene/3d/proximity_group_3d.h (renamed from scene/3d/proximity_group.h)14
-rw-r--r--scene/3d/ray_cast_3d.cpp (renamed from scene/3d/ray_cast.cpp)152
-rw-r--r--scene/3d/ray_cast_3d.h (renamed from scene/3d/ray_cast.h)14
-rw-r--r--scene/3d/reflection_probe.cpp34
-rw-r--r--scene/3d/reflection_probe.h8
-rw-r--r--scene/3d/remote_transform_3d.cpp (renamed from scene/3d/remote_transform.cpp)68
-rw-r--r--scene/3d/remote_transform_3d.h (renamed from scene/3d/remote_transform.h)10
-rw-r--r--scene/3d/skeleton_3d.cpp (renamed from scene/3d/skeleton.cpp)198
-rw-r--r--scene/3d/skeleton_3d.h (renamed from scene/3d/skeleton.h)37
-rw-r--r--scene/3d/skeleton_ik_3d.cpp (renamed from scene/animation/skeleton_ik.cpp)127
-rw-r--r--scene/3d/skeleton_ik_3d.h (renamed from scene/animation/skeleton_ik.h)26
-rw-r--r--scene/3d/soft_body_3d.cpp (renamed from scene/3d/soft_body.cpp)382
-rw-r--r--scene/3d/soft_body_3d.h (renamed from scene/3d/soft_body.h)26
-rw-r--r--scene/3d/spring_arm_3d.cpp (renamed from scene/3d/spring_arm.cpp)72
-rw-r--r--scene/3d/spring_arm_3d.h (renamed from scene/3d/spring_arm.h)16
-rw-r--r--scene/3d/sprite_3d.cpp40
-rw-r--r--scene/3d/sprite_3d.h8
-rw-r--r--scene/3d/vehicle_body_3d.cpp (renamed from scene/3d/vehicle_body.cpp)228
-rw-r--r--scene/3d/vehicle_body_3d.h (renamed from scene/3d/vehicle_body.h)48
-rw-r--r--scene/3d/velocity_tracker_3d.cpp (renamed from scene/3d/spatial_velocity_tracker.cpp)28
-rw-r--r--scene/3d/velocity_tracker_3d.h (renamed from scene/3d/spatial_velocity_tracker.h)10
-rw-r--r--scene/3d/visibility_notifier_3d.cpp (renamed from scene/3d/visibility_notifier.cpp)68
-rw-r--r--scene/3d/visibility_notifier_3d.h (renamed from scene/3d/visibility_notifier.h)26
-rw-r--r--scene/3d/visual_instance_3d.cpp (renamed from scene/3d/visual_instance.cpp)174
-rw-r--r--scene/3d/visual_instance_3d.h (renamed from scene/3d/visual_instance.h)38
-rw-r--r--scene/3d/voxelizer.h2
-rw-r--r--scene/3d/world_environment.cpp6
-rw-r--r--scene/3d/world_environment.h2
-rw-r--r--scene/animation/animation_cache.cpp6
-rw-r--r--scene/animation/animation_cache.h6
-rw-r--r--scene/animation/animation_player.cpp12
-rw-r--r--scene/animation/animation_player.h8
-rw-r--r--scene/animation/animation_tree.cpp6
-rw-r--r--scene/animation/animation_tree.h8
-rw-r--r--scene/animation/root_motion_view.cpp28
-rw-r--r--scene/animation/root_motion_view.h6
-rw-r--r--scene/debugger/scene_debugger.cpp2
-rw-r--r--scene/gui/base_button.cpp5
-rw-r--r--scene/gui/box_container.cpp6
-rw-r--r--scene/gui/button.cpp88
-rw-r--r--scene/gui/check_box.cpp22
-rw-r--r--scene/gui/check_button.cpp18
-rw-r--r--scene/gui/color_picker.cpp97
-rw-r--r--scene/gui/control.cpp871
-rw-r--r--scene/gui/control.h100
-rw-r--r--scene/gui/dialogs.cpp439
-rw-r--r--scene/gui/dialogs.h83
-rw-r--r--scene/gui/file_dialog.cpp147
-rw-r--r--scene/gui/file_dialog.h23
-rw-r--r--scene/gui/gradient_edit.cpp6
-rw-r--r--scene/gui/graph_edit.cpp54
-rw-r--r--scene/gui/graph_node.cpp56
-rw-r--r--scene/gui/grid_container.cpp8
-rw-r--r--scene/gui/item_list.cpp34
-rw-r--r--scene/gui/label.cpp38
-rw-r--r--scene/gui/line_edit.cpp164
-rw-r--r--scene/gui/link_button.cpp20
-rw-r--r--scene/gui/margin_container.cpp16
-rw-r--r--scene/gui/menu_button.cpp34
-rw-r--r--scene/gui/nine_patch_rect.cpp4
-rw-r--r--scene/gui/option_button.cpp39
-rw-r--r--scene/gui/panel.cpp16
-rw-r--r--scene/gui/panel.h14
-rw-r--r--scene/gui/panel_container.cpp20
-rw-r--r--scene/gui/popup.cpp280
-rw-r--r--scene/gui/popup.h39
-rw-r--r--scene/gui/popup_menu.cpp567
-rw-r--r--scene/gui/popup_menu.h13
-rw-r--r--scene/gui/progress_bar.cpp14
-rw-r--r--scene/gui/rich_text_label.cpp103
-rw-r--r--scene/gui/scroll_bar.cpp54
-rw-r--r--scene/gui/scroll_container.cpp14
-rw-r--r--scene/gui/separator.cpp6
-rw-r--r--scene/gui/shortcut.h2
-rw-r--r--scene/gui/slider.cpp16
-rw-r--r--scene/gui/spin_box.cpp13
-rw-r--r--scene/gui/split_container.cpp26
-rw-r--r--scene/gui/tab_container.cpp98
-rw-r--r--scene/gui/tabs.cpp104
-rw-r--r--scene/gui/text_edit.cpp238
-rw-r--r--scene/gui/texture_progress.cpp2
-rw-r--r--scene/gui/texture_rect.cpp2
-rw-r--r--scene/gui/tree.cpp192
-rw-r--r--scene/gui/tree.h8
-rw-r--r--scene/gui/viewport_container.cpp18
-rw-r--r--scene/main/canvas_item.cpp (renamed from scene/2d/canvas_item.cpp)185
-rw-r--r--scene/main/canvas_item.h (renamed from scene/2d/canvas_item.h)8
-rw-r--r--scene/main/canvas_layer.cpp32
-rw-r--r--scene/main/node.cpp4
-rw-r--r--scene/main/node.h17
-rw-r--r--scene/main/scene_tree.cpp399
-rw-r--r--scene/main/scene_tree.h60
-rw-r--r--[-rwxr-xr-x]scene/main/timer.cpp0
-rw-r--r--[-rwxr-xr-x]scene/main/timer.h0
-rw-r--r--scene/main/viewport.cpp1874
-rw-r--r--scene/main/viewport.h265
-rw-r--r--scene/main/window.cpp1406
-rw-r--r--scene/main/window.h266
-rw-r--r--scene/register_scene_types.cpp341
-rw-r--r--scene/resources/audio_stream_sample.cpp6
-rw-r--r--scene/resources/box_shape_3d.cpp (renamed from scene/resources/box_shape.cpp)30
-rw-r--r--scene/resources/box_shape_3d.h (renamed from scene/resources/box_shape.h)10
-rw-r--r--scene/resources/canvas.cpp46
-rw-r--r--scene/resources/canvas.h48
-rw-r--r--scene/resources/capsule_shape_2d.cpp10
-rw-r--r--scene/resources/capsule_shape_3d.cpp (renamed from scene/resources/capsule_shape.cpp)38
-rw-r--r--scene/resources/capsule_shape_3d.h (renamed from scene/resources/capsule_shape.h)10
-rw-r--r--scene/resources/circle_shape_2d.cpp10
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp12
-rw-r--r--scene/resources/concave_polygon_shape_3d.cpp (renamed from scene/resources/concave_polygon_shape.cpp)32
-rw-r--r--scene/resources/concave_polygon_shape_3d.h (renamed from scene/resources/concave_polygon_shape.h)14
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp10
-rw-r--r--scene/resources/convex_polygon_shape_3d.cpp (renamed from scene/resources/convex_polygon_shape.cpp)30
-rw-r--r--scene/resources/convex_polygon_shape_3d.h (renamed from scene/resources/convex_polygon_shape.h)10
-rw-r--r--scene/resources/cylinder_shape_3d.cpp (renamed from scene/resources/cylinder_shape.cpp)38
-rw-r--r--scene/resources/cylinder_shape_3d.h (renamed from scene/resources/cylinder_shape.h)14
-rw-r--r--scene/resources/default_theme/default_theme.cpp21
-rw-r--r--scene/resources/dynamic_font.cpp2
-rw-r--r--scene/resources/environment.cpp166
-rw-r--r--scene/resources/environment.h2
-rw-r--r--scene/resources/font.cpp2
-rw-r--r--scene/resources/height_map_shape_3d.cpp (renamed from scene/resources/height_map_shape.cpp)46
-rw-r--r--scene/resources/height_map_shape_3d.h (renamed from scene/resources/height_map_shape.h)10
-rw-r--r--scene/resources/line_shape_2d.cpp12
-rw-r--r--scene/resources/material.cpp120
-rw-r--r--scene/resources/material.h8
-rw-r--r--scene/resources/mesh.cpp92
-rw-r--r--scene/resources/mesh.h52
-rw-r--r--scene/resources/mesh_data_tool.cpp28
-rw-r--r--scene/resources/mesh_library.h6
-rw-r--r--scene/resources/multimesh.cpp36
-rw-r--r--scene/resources/multimesh.h6
-rw-r--r--scene/resources/packed_scene.cpp6
-rw-r--r--scene/resources/particles_material.cpp116
-rw-r--r--scene/resources/physics_material.h2
-rw-r--r--scene/resources/primitive_meshes.cpp102
-rw-r--r--scene/resources/ray_shape_3d.cpp (renamed from scene/resources/ray_shape.cpp)38
-rw-r--r--scene/resources/ray_shape_3d.h (renamed from scene/resources/ray_shape.h)10
-rw-r--r--scene/resources/rectangle_shape_2d.cpp10
-rw-r--r--scene/resources/segment_shape_2d.cpp18
-rw-r--r--scene/resources/shader.cpp18
-rw-r--r--scene/resources/shader.h2
-rw-r--r--scene/resources/shape_2d.cpp14
-rw-r--r--scene/resources/shape_3d.cpp (renamed from scene/resources/shape.cpp)32
-rw-r--r--scene/resources/shape_3d.h (renamed from scene/resources/shape.h)18
-rw-r--r--scene/resources/sky.cpp10
-rw-r--r--scene/resources/sky_material.cpp74
-rw-r--r--scene/resources/sky_material.h2
-rw-r--r--scene/resources/space_2d.cpp66
-rw-r--r--scene/resources/space_2d.h56
-rw-r--r--scene/resources/sphere_shape_3d.cpp (renamed from scene/resources/sphere_shape.cpp)30
-rw-r--r--scene/resources/sphere_shape_3d.h (renamed from scene/resources/sphere_shape.h)14
-rw-r--r--scene/resources/style_box.cpp9
-rw-r--r--scene/resources/style_box.h2
-rw-r--r--scene/resources/surface_tool.cpp108
-rw-r--r--scene/resources/texture.cpp206
-rw-r--r--scene/resources/texture.h52
-rw-r--r--scene/resources/tile_set.cpp2
-rw-r--r--scene/resources/tile_set.h2
-rw-r--r--scene/resources/visual_shader.cpp70
-rw-r--r--scene/resources/world_2d.cpp30
-rw-r--r--scene/resources/world_2d.h4
-rw-r--r--scene/resources/world_3d.cpp (renamed from scene/resources/world.cpp)154
-rw-r--r--scene/resources/world_3d.h (renamed from scene/resources/world.h)45
-rw-r--r--scene/resources/world_margin_shape_3d.cpp (renamed from scene/resources/world_margin_shape.cpp)28
-rw-r--r--scene/resources/world_margin_shape_3d.h (renamed from scene/resources/world_margin_shape.h)14
-rw-r--r--scene/scene_string_names.cpp6
-rw-r--r--scene/scene_string_names.h7
-rw-r--r--servers/SCsub4
-rw-r--r--servers/arvr/arvr_interface.h2
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp2
-rw-r--r--servers/arvr_server.cpp2
-rw-r--r--servers/audio/reverb_sw.cpp538
-rw-r--r--servers/audio/reverb_sw.h88
-rw-r--r--servers/audio/voice_rb_sw.h141
-rw-r--r--servers/audio_server.cpp43
-rw-r--r--servers/audio_server.h14
-rw-r--r--servers/camera/camera_feed.cpp28
-rw-r--r--servers/camera/camera_feed.h4
-rw-r--r--servers/camera_server.cpp2
-rw-r--r--servers/display_server.cpp597
-rw-r--r--servers/display_server.h385
-rw-r--r--servers/navigation_server_2d.cpp (renamed from servers/navigation_2d_server.cpp)166
-rw-r--r--servers/navigation_server_2d.h (renamed from servers/navigation_2d_server.h)18
-rw-r--r--servers/navigation_server_3d.cpp (renamed from servers/navigation_server.cpp)104
-rw-r--r--servers/navigation_server_3d.h (renamed from servers/navigation_server.h)28
-rw-r--r--servers/physics/physics_server_sw.cpp1589
-rw-r--r--servers/physics_2d/area_2d_sw.cpp48
-rw-r--r--servers/physics_2d/area_2d_sw.h14
-rw-r--r--servers/physics_2d/area_pair_2d_sw.cpp8
-rw-r--r--servers/physics_2d/body_2d_sw.cpp154
-rw-r--r--servers/physics_2d/body_2d_sw.h42
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp12
-rw-r--r--servers/physics_2d/collision_object_2d_sw.cpp14
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h2
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp12
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp16
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp24
-rw-r--r--servers/physics_2d/joints_2d_sw.h16
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp (renamed from servers/physics_2d/physics_2d_server_sw.cpp)279
-rw-r--r--servers/physics_2d/physics_server_2d_sw.h (renamed from servers/physics_2d/physics_2d_server_sw.h)24
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.cpp (renamed from servers/physics_2d/physics_2d_server_wrap_mt.cpp)34
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.h (renamed from servers/physics_2d/physics_2d_server_wrap_mt.h)26
-rw-r--r--servers/physics_2d/shape_2d_sw.h20
-rw-r--r--servers/physics_2d/space_2d_sw.cpp122
-rw-r--r--servers/physics_2d/space_2d_sw.h20
-rw-r--r--servers/physics_2d/step_2d_sw.cpp6
-rw-r--r--servers/physics_3d/SCsub (renamed from servers/physics/SCsub)0
-rw-r--r--servers/physics_3d/area_3d_sw.cpp (renamed from servers/physics/area_sw.cpp)82
-rw-r--r--servers/physics_3d/area_3d_sw.h (renamed from servers/physics/area_sw.h)64
-rw-r--r--servers/physics_3d/area_pair_3d_sw.cpp (renamed from servers/physics/area_pair_sw.cpp)34
-rw-r--r--servers/physics_3d/area_pair_3d_sw.h (renamed from servers/physics/area_pair_sw.h)28
-rw-r--r--servers/physics_3d/body_3d_sw.cpp (renamed from servers/physics/body_sw.cpp)194
-rw-r--r--servers/physics_3d/body_3d_sw.h (renamed from servers/physics/body_sw.h)92
-rw-r--r--servers/physics_3d/body_pair_3d_sw.cpp (renamed from servers/physics/body_pair_sw.cpp)44
-rw-r--r--servers/physics_3d/body_pair_3d_sw.h (renamed from servers/physics/body_pair_sw.h)22
-rw-r--r--servers/physics_3d/broad_phase_3d_basic.cpp (renamed from servers/physics/broad_phase_basic.cpp)36
-rw-r--r--servers/physics_3d/broad_phase_3d_basic.h (renamed from servers/physics/broad_phase_basic.h)22
-rw-r--r--servers/physics_3d/broad_phase_3d_sw.cpp (renamed from servers/physics/broad_phase_sw.cpp)8
-rw-r--r--servers/physics_3d/broad_phase_3d_sw.h (renamed from servers/physics/broad_phase_sw.h)24
-rw-r--r--servers/physics_3d/broad_phase_octree.cpp (renamed from servers/physics/broad_phase_octree.cpp)22
-rw-r--r--servers/physics_3d/broad_phase_octree.h (renamed from servers/physics/broad_phase_octree.h)22
-rw-r--r--servers/physics_3d/collision_object_3d_sw.cpp (renamed from servers/physics/collision_object_sw.cpp)44
-rw-r--r--servers/physics_3d/collision_object_3d_sw.h (renamed from servers/physics/collision_object_sw.h)40
-rw-r--r--servers/physics_3d/collision_solver_3d_sat.cpp (renamed from servers/physics/collision_solver_sat.cpp)150
-rw-r--r--servers/physics_3d/collision_solver_3d_sat.h (renamed from servers/physics/collision_solver_sat.h)6
-rw-r--r--servers/physics_3d/collision_solver_3d_sw.cpp (renamed from servers/physics/collision_solver_sw.cpp)56
-rw-r--r--servers/physics_3d/collision_solver_3d_sw.h (renamed from servers/physics/collision_solver_sw.h)22
-rw-r--r--servers/physics_3d/constraint_3d_sw.h (renamed from servers/physics/constraint_sw.h)26
-rw-r--r--servers/physics_3d/gjk_epa.cpp (renamed from servers/physics/gjk_epa.cpp)18
-rw-r--r--servers/physics_3d/gjk_epa.h (renamed from servers/physics/gjk_epa.h)8
-rw-r--r--servers/physics_3d/joints/SCsub (renamed from servers/physics/joints/SCsub)0
-rw-r--r--servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp (renamed from servers/physics/joints/cone_twist_joint_sw.cpp)42
-rw-r--r--servers/physics_3d/joints/cone_twist_joint_3d_sw.h (renamed from servers/physics/joints/cone_twist_joint_sw.h)24
-rw-r--r--servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp (renamed from servers/physics/joints/generic_6dof_joint_sw.cpp)178
-rw-r--r--servers/physics_3d/joints/generic_6dof_joint_3d_sw.h (renamed from servers/physics/joints/generic_6dof_joint_sw.h)66
-rw-r--r--servers/physics_3d/joints/hinge_joint_3d_sw.cpp (renamed from servers/physics/joints/hinge_joint_sw.cpp)82
-rw-r--r--servers/physics_3d/joints/hinge_joint_3d_sw.h (renamed from servers/physics/joints/hinge_joint_sw.h)32
-rw-r--r--servers/physics_3d/joints/jacobian_entry_3d_sw.h (renamed from servers/physics/joints/jacobian_entry_sw.h)22
-rw-r--r--servers/physics_3d/joints/pin_joint_3d_sw.cpp (renamed from servers/physics/joints/pin_joint_sw.cpp)32
-rw-r--r--servers/physics_3d/joints/pin_joint_3d_sw.h (renamed from servers/physics/joints/pin_joint_sw.h)26
-rw-r--r--servers/physics_3d/joints/slider_joint_3d_sw.cpp (renamed from servers/physics/joints/slider_joint_sw.cpp)132
-rw-r--r--servers/physics_3d/joints/slider_joint_3d_sw.h (renamed from servers/physics/joints/slider_joint_sw.h)30
-rw-r--r--servers/physics_3d/joints_3d_sw.h (renamed from servers/physics/joints_sw.h)14
-rw-r--r--servers/physics_3d/physics_server_3d_sw.cpp1589
-rw-r--r--servers/physics_3d/physics_server_3d_sw.h (renamed from servers/physics/physics_server_sw.h)50
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp (renamed from servers/physics/shape_sw.cpp)246
-rw-r--r--servers/physics_3d/shape_3d_sw.h (renamed from servers/physics/shape_sw.h)102
-rw-r--r--servers/physics_3d/space_3d_sw.cpp (renamed from servers/physics/space_sw.cpp)312
-rw-r--r--servers/physics_3d/space_3d_sw.h (renamed from servers/physics/space_sw.h)102
-rw-r--r--servers/physics_3d/step_3d_sw.cpp (renamed from servers/physics/step_sw.cpp)80
-rw-r--r--servers/physics_3d/step_3d_sw.h (renamed from servers/physics/step_sw.h)18
-rw-r--r--servers/physics_server_2d.cpp (renamed from servers/physics_2d_server.cpp)488
-rw-r--r--servers/physics_server_2d.h (renamed from servers/physics_2d_server.h)120
-rw-r--r--servers/physics_server_3d.cpp (renamed from servers/physics_server.cpp)454
-rw-r--r--servers/physics_server_3d.h (renamed from servers/physics_server.h)114
-rw-r--r--servers/register_server_types.cpp83
-rw-r--r--servers/rendering/SCsub (renamed from servers/visual/SCsub)0
-rw-r--r--servers/rendering/rasterizer.cpp (renamed from servers/visual/rasterizer.cpp)0
-rw-r--r--servers/rendering/rasterizer.h (renamed from servers/visual/rasterizer.h)134
-rw-r--r--servers/rendering/rasterizer_rd/SCsub (renamed from servers/visual/rasterizer_rd/SCsub)0
-rw-r--r--servers/rendering/rasterizer_rd/light_cluster_builder.cpp (renamed from servers/visual/rasterizer_rd/light_cluster_builder.cpp)0
-rw-r--r--servers/rendering/rasterizer_rd/light_cluster_builder.h (renamed from servers/visual/rasterizer_rd/light_cluster_builder.h)2
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp (renamed from servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp)90
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h (renamed from servers/visual/rasterizer_rd/rasterizer_canvas_rd.h)30
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp (renamed from servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp)20
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_effects_rd.h (renamed from servers/visual/rasterizer_rd/rasterizer_effects_rd.h)36
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_rd.cpp (renamed from servers/visual/rasterizer_rd/rasterizer_rd.cpp)2
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_rd.h (renamed from servers/visual/rasterizer_rd/rasterizer_rd.h)10
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp (renamed from servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp)179
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h (renamed from servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h)14
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp (renamed from servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp)225
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_rd.h (renamed from servers/visual/rasterizer_rd/rasterizer_scene_rd.h)95
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp (renamed from servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp)248
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_storage_rd.h (renamed from servers/visual/rasterizer_rd/rasterizer_storage_rd.h)112
-rw-r--r--servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp (renamed from servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp)0
-rw-r--r--servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h (renamed from servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h)2
-rw-r--r--servers/rendering/rasterizer_rd/shader_compiler_rd.cpp (renamed from servers/visual/rasterizer_rd/shader_compiler_rd.cpp)240
-rw-r--r--servers/rendering/rasterizer_rd/shader_compiler_rd.h (renamed from servers/visual/rasterizer_rd/shader_compiler_rd.h)8
-rw-r--r--servers/rendering/rasterizer_rd/shader_rd.cpp (renamed from servers/visual/rasterizer_rd/shader_rd.cpp)3
-rw-r--r--servers/rendering/rasterizer_rd/shader_rd.h (renamed from servers/visual/rasterizer_rd/shader_rd.h)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/SCsub (renamed from servers/visual/rasterizer_rd/shaders/SCsub)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/blur.glsl (renamed from servers/visual/rasterizer_rd/shaders/blur.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/blur_inc.glsl (renamed from servers/visual/rasterizer_rd/shaders/blur_inc.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl (renamed from servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/canvas.glsl (renamed from servers/visual/rasterizer_rd/shaders/canvas.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl (renamed from servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/canvas_uniforms_inc.glsl (renamed from servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/copy.glsl (renamed from servers/visual/rasterizer_rd/shaders/copy.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl (renamed from servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl (renamed from servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl)51
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl (renamed from servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe.glsl (renamed from servers/visual/rasterizer_rd/shaders/giprobe.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl (renamed from servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl (renamed from servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl (renamed from servers/visual/rasterizer_rd/shaders/giprobe_write.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl (renamed from servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl (renamed from servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl (renamed from servers/visual/rasterizer_rd/shaders/scene_high_end.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl (renamed from servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/sky.glsl (renamed from servers/visual/rasterizer_rd/shaders/sky.glsl)56
-rw-r--r--servers/rendering/rasterizer_rd/shaders/ssao.glsl (renamed from servers/visual/rasterizer_rd/shaders/ssao.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl (renamed from servers/visual/rasterizer_rd/shaders/ssao_blur.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl (renamed from servers/visual/rasterizer_rd/shaders/ssao_minify.glsl)0
-rw-r--r--servers/rendering/rasterizer_rd/shaders/tonemap.glsl (renamed from servers/visual/rasterizer_rd/shaders/tonemap.glsl)0
-rw-r--r--servers/rendering/rendering_device.cpp (renamed from servers/visual/rendering_device.cpp)0
-rw-r--r--servers/rendering/rendering_device.h (renamed from servers/visual/rendering_device.h)7
-rw-r--r--servers/rendering/rendering_server_canvas.cpp (renamed from servers/visual/visual_server_canvas.cpp)230
-rw-r--r--servers/rendering/rendering_server_canvas.h (renamed from servers/visual/visual_server_canvas.h)52
-rw-r--r--servers/rendering/rendering_server_globals.cpp (renamed from platform/iphone/platform_refcount.h)26
-rw-r--r--servers/rendering/rendering_server_globals.h (renamed from servers/visual/visual_server_globals.h)24
-rw-r--r--servers/rendering/rendering_server_raster.cpp (renamed from servers/visual/visual_server_raster.cpp)158
-rw-r--r--servers/rendering/rendering_server_raster.h (renamed from servers/visual/visual_server_raster.h)39
-rw-r--r--servers/rendering/rendering_server_scene.cpp (renamed from servers/visual/visual_server_scene.cpp)654
-rw-r--r--servers/rendering/rendering_server_scene.h (renamed from servers/visual/visual_server_scene.h)24
-rw-r--r--servers/rendering/rendering_server_viewport.cpp (renamed from servers/visual/visual_server_viewport.cpp)327
-rw-r--r--servers/rendering/rendering_server_viewport.h (renamed from servers/visual/visual_server_viewport.h)55
-rw-r--r--servers/rendering/rendering_server_wrap_mt.cpp (renamed from servers/visual/visual_server_wrap_mt.cpp)67
-rw-r--r--servers/rendering/rendering_server_wrap_mt.h (renamed from servers/visual/visual_server_wrap_mt.h)67
-rw-r--r--servers/rendering/shader_language.cpp (renamed from servers/visual/shader_language.cpp)18
-rw-r--r--servers/rendering/shader_language.h (renamed from servers/visual/shader_language.h)0
-rw-r--r--servers/rendering/shader_types.cpp328
-rw-r--r--servers/rendering/shader_types.h (renamed from servers/visual/shader_types.h)8
-rw-r--r--servers/rendering_server.cpp (renamed from servers/visual_server.cpp)928
-rw-r--r--servers/rendering_server.h (renamed from servers/visual_server.h)117
-rw-r--r--servers/visual/shader_types.cpp327
-rw-r--r--servers/visual/visual_server_globals.cpp40
-rw-r--r--servers/visual/visual_server_light_baker.cpp34
-rw-r--r--servers/visual/visual_server_light_baker.h52
-rw-r--r--thirdparty/README.md4
-rw-r--r--thirdparty/misc/cubemap_coeffs.h (renamed from servers/visual/rasterizer_rd/cubemap_coeffs.h)0
1012 files changed, 38700 insertions, 36533 deletions
diff --git a/.travis.yml b/.travis.yml
index eeeedef063..8b58e12563 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,7 +31,7 @@ matrix:
- name: Linux editor (debug, GCC 9, with Mono)
stage: build
- env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
+ env: PLATFORM=linuxbsd TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
os: linux
compiler: gcc-9
addons:
@@ -47,7 +47,7 @@ matrix:
- name: Linux export template (release, Clang 7)
stage: build
- env: PLATFORM=x11 TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes"
+ env: PLATFORM=linuxbsd TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes"
os: linux
compiler: clang
addons:
@@ -67,17 +67,17 @@ matrix:
# packages:
# - openjdk-8-jdk
-# - name: macOS editor (debug, Clang)
-# stage: build
-# env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes"
-# os: osx
-# osx_image: xcode11.3
-# compiler: clang
-# addons:
-# homebrew:
-# packages:
-# - scons
-# update: true
+ - name: macOS editor (debug, Clang)
+ stage: build
+ env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes"
+ os: osx
+ osx_image: xcode11.3
+ compiler: clang
+ addons:
+ homebrew:
+ packages:
+ - scons
+ update: true
# TODO: iOS MoltenVK support
@@ -109,7 +109,7 @@ matrix:
- name: Linux export template (release_debug, GCC 7, without 3D support)
stage: build
- env: PLATFORM=x11 TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-7 EXTRA_ARGS="disable_3d=yes"
+ env: PLATFORM=linuxbsd TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-7 EXTRA_ARGS="disable_3d=yes"
os: linux
compiler: gcc
addons:
@@ -117,15 +117,15 @@ matrix:
packages:
- *linux_deps
- - name: Javascript export template (release, emscripten latest)
- stage: build
- env: PLATFORM=javascript TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-emcc-latest EXTRA_ARGS="use_closure_compiler=yes"
- os: linux
- compiler: clang
- addons:
- apt:
- packages:
- - *linux_deps
+# - name: Javascript export template (release, emscripten latest)
+# stage: build
+# env: PLATFORM=javascript TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-emcc-latest EXTRA_ARGS="use_closure_compiler=yes"
+# os: linux
+# compiler: clang
+# addons:
+# apt:
+# packages:
+# - *linux_deps
before_install:
- eval "${MATRIX_EVAL}"
@@ -165,7 +165,7 @@ script:
scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS &&
if [ "$TEST_PROJECT" = "yes" ]; then
git clone --depth 1 "https://github.com/godotengine/godot-tests.git";
- sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.x11.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg;
- godot-tests/tests/project_export/test_project.sh "bin/godot_server.x11.opt.tools.64";
+ sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.linuxbsd.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg;
+ godot-tests/tests/project_export/test_project.sh "bin/godot_server.linuxbsd.opt.tools.64";
fi
fi
diff --git a/README.md b/README.md
index 1202dabc8c..f9855beaf6 100644
--- a/README.md
+++ b/README.md
@@ -71,3 +71,4 @@ for more info.
[![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot)
[![Translate on Weblate](https://hosted.weblate.org/widgets/godot-engine/-/godot/svg-badge.svg)](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget)
[![Total alerts on LGTM](https://img.shields.io/lgtm/alerts/g/godotengine/godot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/godotengine/godot/alerts)
+[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/godotengine/godot)](https://www.tickgit.com/browse?repo=github.com/godotengine/godot)
diff --git a/SConstruct b/SConstruct
index 4ebc33f593..ed4b3c6242 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,6 +1,7 @@
#!/usr/bin/env python
-EnsureSConsVersion(0, 98, 1)
+EnsureSConsVersion(3, 0, 0)
+EnsurePythonVersion(3, 5)
# System
import glob
@@ -13,7 +14,7 @@ import methods
import gles_builders
from platform_methods import run_in_subprocess
-# scan possible build platforms
+# Scan possible build platforms
platform_list = [] # list of platforms
platform_opts = {} # options for each platform
@@ -235,7 +236,7 @@ elif env_base['p'] != "":
else:
# Missing `platform` argument, try to detect platform automatically
if sys.platform.startswith('linux'):
- selected_platform = 'x11'
+ selected_platform = 'linuxbsd'
elif sys.platform == 'darwin':
selected_platform = 'osx'
elif sys.platform == 'win32':
diff --git a/compat.py b/compat.py
deleted file mode 100644
index de99eef9c2..0000000000
--- a/compat.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import sys
-
-if sys.version_info < (3,):
- def isbasestring(s):
- return isinstance(s, basestring)
- def open_utf8(filename, mode):
- return open(filename, mode)
- def byte_to_str(x):
- return str(ord(x))
- import cStringIO
- def StringIO():
- return cStringIO.StringIO()
- def encode_utf8(x):
- return x
- def decode_utf8(x):
- return x
- def iteritems(d):
- return d.iteritems()
- def itervalues(d):
- return d.itervalues()
- def escape_string(s):
- if isinstance(s, unicode):
- s = s.encode('ascii')
- result = ''
- for c in s:
- if not (32 <= ord(c) < 127) or c in ('\\', '"'):
- result += '\\%03o' % ord(c)
- else:
- result += c
- return result
-
-else:
- def isbasestring(s):
- return isinstance(s, (str, bytes))
- def open_utf8(filename, mode):
- return open(filename, mode, encoding="utf-8")
- def byte_to_str(x):
- return str(x)
- import io
- def StringIO():
- return io.StringIO()
- import codecs
- def encode_utf8(x):
- return codecs.utf_8_encode(x)[0]
- def decode_utf8(x):
- return codecs.utf_8_decode(x)[0]
- def iteritems(d):
- return iter(d.items())
- def itervalues(d):
- return iter(d.values())
- def charcode_to_c_escapes(c):
- rev_result = []
- while c >= 256:
- c, low = (c // 256, c % 256)
- rev_result.append('\\%03o' % low)
- rev_result.append('\\%03o' % c)
- return ''.join(reversed(rev_result))
- def escape_string(s):
- result = ''
- if isinstance(s, str):
- s = s.encode('utf-8')
- for c in s:
- if not(32 <= c < 127) or c in (ord('\\'), ord('"')):
- result += charcode_to_c_escapes(c)
- else:
- result += chr(c)
- return result
-
diff --git a/core/SCsub b/core/SCsub
index b4974196bd..ca003ce931 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -166,6 +166,7 @@ SConscript('math/SCsub')
SConscript('crypto/SCsub')
SConscript('io/SCsub')
SConscript('debugger/SCsub')
+SConscript('input/SCsub')
SConscript('bind/SCsub')
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 62d83b2e04..0236523200 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -194,82 +194,6 @@ _ResourceSaver::_ResourceSaver() {
singleton = this;
}
-/////////////////OS
-
-void _OS::global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta) {
-
- OS::get_singleton()->global_menu_add_item(p_menu, p_label, p_signal, p_meta);
-}
-
-void _OS::global_menu_add_separator(const String &p_menu) {
-
- OS::get_singleton()->global_menu_add_separator(p_menu);
-}
-
-void _OS::global_menu_remove_item(const String &p_menu, int p_idx) {
-
- OS::get_singleton()->global_menu_remove_item(p_menu, p_idx);
-}
-
-void _OS::global_menu_clear(const String &p_menu) {
-
- OS::get_singleton()->global_menu_clear(p_menu);
-}
-
-Point2 _OS::get_mouse_position() const {
-
- return OS::get_singleton()->get_mouse_position();
-}
-
-void _OS::set_window_title(const String &p_title) {
-
- OS::get_singleton()->set_window_title(p_title);
-}
-
-int _OS::get_mouse_button_state() const {
-
- return OS::get_singleton()->get_mouse_button_state();
-}
-
-String _OS::get_unique_id() const {
- return OS::get_singleton()->get_unique_id();
-}
-
-bool _OS::has_touchscreen_ui_hint() const {
-
- return OS::get_singleton()->has_touchscreen_ui_hint();
-}
-
-void _OS::set_clipboard(const String &p_text) {
-
- OS::get_singleton()->set_clipboard(p_text);
-}
-
-String _OS::get_clipboard() const {
-
- return OS::get_singleton()->get_clipboard();
-}
-
-int _OS::get_video_driver_count() const {
- return OS::get_singleton()->get_video_driver_count();
-}
-
-String _OS::get_video_driver_name(VideoDriver p_driver) const {
- return OS::get_singleton()->get_video_driver_name((int)p_driver);
-}
-
-_OS::VideoDriver _OS::get_current_video_driver() const {
- return (VideoDriver)OS::get_singleton()->get_current_video_driver();
-}
-
-int _OS::get_audio_driver_count() const {
- return OS::get_singleton()->get_audio_driver_count();
-}
-
-String _OS::get_audio_driver_name(int p_driver) const {
- return OS::get_singleton()->get_audio_driver_name(p_driver);
-}
-
PackedStringArray _OS::get_connected_midi_inputs() {
return OS::get_singleton()->get_connected_midi_inputs();
}
@@ -282,198 +206,11 @@ void _OS::close_midi_inputs() {
OS::get_singleton()->close_midi_inputs();
}
-void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
-
- OS::VideoMode vm;
- vm.width = p_size.width;
- vm.height = p_size.height;
- vm.fullscreen = p_fullscreen;
- vm.resizable = p_resizeable;
- OS::get_singleton()->set_video_mode(vm, p_screen);
-}
-
-Size2 _OS::get_video_mode(int p_screen) const {
-
- OS::VideoMode vm;
- vm = OS::get_singleton()->get_video_mode(p_screen);
- return Size2(vm.width, vm.height);
-}
-
-bool _OS::is_video_mode_fullscreen(int p_screen) const {
-
- OS::VideoMode vm;
- vm = OS::get_singleton()->get_video_mode(p_screen);
- return vm.fullscreen;
-}
-
-int _OS::get_screen_count() const {
- return OS::get_singleton()->get_screen_count();
-}
-
-int _OS::get_current_screen() const {
- return OS::get_singleton()->get_current_screen();
-}
-
-void _OS::set_current_screen(int p_screen) {
- OS::get_singleton()->set_current_screen(p_screen);
-}
-
-Point2 _OS::get_screen_position(int p_screen) const {
- return OS::get_singleton()->get_screen_position(p_screen);
-}
-
-Size2 _OS::get_screen_size(int p_screen) const {
- return OS::get_singleton()->get_screen_size(p_screen);
-}
-
-int _OS::get_screen_dpi(int p_screen) const {
-
- return OS::get_singleton()->get_screen_dpi(p_screen);
-}
-
-Point2 _OS::get_window_position() const {
- return OS::get_singleton()->get_window_position();
-}
-
-void _OS::set_window_position(const Point2 &p_position) {
- OS::get_singleton()->set_window_position(p_position);
-}
-
-Size2 _OS::get_max_window_size() const {
- return OS::get_singleton()->get_max_window_size();
-}
-
-Size2 _OS::get_min_window_size() const {
- return OS::get_singleton()->get_min_window_size();
-}
-
-Size2 _OS::get_window_size() const {
- return OS::get_singleton()->get_window_size();
-}
-
-Size2 _OS::get_real_window_size() const {
- return OS::get_singleton()->get_real_window_size();
-}
-
-void _OS::set_max_window_size(const Size2 &p_size) {
- OS::get_singleton()->set_max_window_size(p_size);
-}
-
-void _OS::set_min_window_size(const Size2 &p_size) {
- OS::get_singleton()->set_min_window_size(p_size);
-}
-
-void _OS::set_window_size(const Size2 &p_size) {
- OS::get_singleton()->set_window_size(p_size);
-}
-
-Rect2 _OS::get_window_safe_area() const {
- return OS::get_singleton()->get_window_safe_area();
-}
-
-void _OS::set_window_fullscreen(bool p_enabled) {
- OS::get_singleton()->set_window_fullscreen(p_enabled);
-}
-
-bool _OS::is_window_fullscreen() const {
- return OS::get_singleton()->is_window_fullscreen();
-}
-
-void _OS::set_window_resizable(bool p_enabled) {
- OS::get_singleton()->set_window_resizable(p_enabled);
-}
-
-bool _OS::is_window_resizable() const {
- return OS::get_singleton()->is_window_resizable();
-}
-
-void _OS::set_window_minimized(bool p_enabled) {
- OS::get_singleton()->set_window_minimized(p_enabled);
-}
-
-bool _OS::is_window_minimized() const {
- return OS::get_singleton()->is_window_minimized();
-}
-
-void _OS::set_window_maximized(bool p_enabled) {
- OS::get_singleton()->set_window_maximized(p_enabled);
-}
-
-bool _OS::is_window_maximized() const {
- return OS::get_singleton()->is_window_maximized();
-}
-
-void _OS::set_window_always_on_top(bool p_enabled) {
- OS::get_singleton()->set_window_always_on_top(p_enabled);
-}
-
-bool _OS::is_window_always_on_top() const {
- return OS::get_singleton()->is_window_always_on_top();
-}
-
-bool _OS::is_window_focused() const {
- return OS::get_singleton()->is_window_focused();
-}
-
-void _OS::set_borderless_window(bool p_borderless) {
- OS::get_singleton()->set_borderless_window(p_borderless);
-}
-
-bool _OS::get_window_per_pixel_transparency_enabled() const {
- return OS::get_singleton()->get_window_per_pixel_transparency_enabled();
-}
-
-void _OS::set_window_per_pixel_transparency_enabled(bool p_enabled) {
- OS::get_singleton()->set_window_per_pixel_transparency_enabled(p_enabled);
-}
-
-bool _OS::get_borderless_window() const {
- return OS::get_singleton()->get_borderless_window();
-}
-
-void _OS::set_ime_active(const bool p_active) {
-
- OS::get_singleton()->set_ime_active(p_active);
-}
-
-void _OS::set_ime_position(const Point2 &p_pos) {
-
- OS::get_singleton()->set_ime_position(p_pos);
-}
-
-Point2 _OS::get_ime_selection() const {
- return OS::get_singleton()->get_ime_selection();
-}
-
-String _OS::get_ime_text() const {
- return OS::get_singleton()->get_ime_text();
-}
-
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
FileAccess::set_backup_save(p_enable);
}
-bool _OS::is_video_mode_resizable(int p_screen) const {
-
- OS::VideoMode vm;
- vm = OS::get_singleton()->get_video_mode(p_screen);
- return vm.resizable;
-}
-
-Array _OS::get_fullscreen_mode_list(int p_screen) const {
-
- List<OS::VideoMode> vmlist;
- OS::get_singleton()->get_fullscreen_mode_list(&vmlist, p_screen);
- Array vmarr;
- for (List<OS::VideoMode>::Element *E = vmlist.front(); E; E = E->next()) {
-
- vmarr.push_back(Size2(E->get().width, E->get().height));
- }
-
- return vmarr;
-}
-
void _OS::set_low_processor_usage_mode(bool p_enabled) {
OS::get_singleton()->set_low_processor_usage_mode(p_enabled);
@@ -562,52 +299,16 @@ String _OS::get_locale() const {
return OS::get_singleton()->get_locale();
}
-String _OS::get_latin_keyboard_variant() const {
- switch (OS::get_singleton()->get_latin_keyboard_variant()) {
- case OS::LATIN_KEYBOARD_QWERTY: return "QWERTY";
- case OS::LATIN_KEYBOARD_QWERTZ: return "QWERTZ";
- case OS::LATIN_KEYBOARD_AZERTY: return "AZERTY";
- case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY";
- case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK";
- case OS::LATIN_KEYBOARD_NEO: return "NEO";
- case OS::LATIN_KEYBOARD_COLEMAK: return "COLEMAK";
- default: return "ERROR";
- }
-}
-
String _OS::get_model_name() const {
return OS::get_singleton()->get_model_name();
}
-bool _OS::is_ok_left_and_cancel_right() const {
-
- return OS::get_singleton()->get_swap_ok_cancel();
-}
-
Error _OS::set_thread_name(const String &p_name) {
return Thread::set_name(p_name);
};
-void _OS::set_use_vsync(bool p_enable) {
- OS::get_singleton()->set_use_vsync(p_enable);
-}
-
-bool _OS::is_vsync_enabled() const {
-
- return OS::get_singleton()->is_vsync_enabled();
-}
-
-void _OS::set_vsync_via_compositor(bool p_enable) {
- OS::get_singleton()->set_vsync_via_compositor(p_enable);
-}
-
-bool _OS::is_vsync_via_compositor_enabled() const {
-
- return OS::get_singleton()->is_vsync_via_compositor_enabled();
-}
-
bool _OS::has_feature(const String &p_feature) const {
return OS::get_singleton()->has_feature(p_feature);
@@ -667,16 +368,6 @@ uint64_t _OS::get_static_memory_peak_usage() const {
return OS::get_singleton()->get_static_memory_peak_usage();
}
-void _OS::set_native_icon(const String &p_filename) {
-
- OS::get_singleton()->set_native_icon(p_filename);
-}
-
-void _OS::set_icon(const Ref<Image> &p_icon) {
-
- OS::get_singleton()->set_icon(p_icon);
-}
-
int _OS::get_exit_code() const {
return OS::get_singleton()->get_exit_code();
@@ -924,11 +615,6 @@ bool _OS::can_use_threads() const {
return OS::get_singleton()->can_use_threads();
}
-bool _OS::can_draw() const {
-
- return OS::get_singleton()->can_draw();
-}
-
bool _OS::is_userfs_persistent() const {
return OS::get_singleton()->is_userfs_persistent();
@@ -1025,22 +711,6 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) {
}
};
-bool _OS::has_virtual_keyboard() const {
- return OS::get_singleton()->has_virtual_keyboard();
-}
-
-void _OS::show_virtual_keyboard(const String &p_existing_text) {
- OS::get_singleton()->show_virtual_keyboard(p_existing_text, Rect2());
-}
-
-void _OS::hide_virtual_keyboard() {
- OS::get_singleton()->hide_virtual_keyboard();
-}
-
-int _OS::get_virtual_keyboard_height() {
- return OS::get_singleton()->get_virtual_keyboard_height();
-}
-
void _OS::print_all_resources(const String &p_to_file) {
OS::get_singleton()->print_all_resources(p_to_file);
@@ -1061,45 +731,6 @@ String _OS::get_user_data_dir() const {
return OS::get_singleton()->get_user_data_dir();
};
-Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
-
- return OS::get_singleton()->native_video_play(p_path, p_volume, p_audio_track, p_subtitle_track);
-};
-
-bool _OS::native_video_is_playing() {
-
- return OS::get_singleton()->native_video_is_playing();
-};
-
-void _OS::native_video_pause() {
-
- OS::get_singleton()->native_video_pause();
-};
-
-void _OS::native_video_unpause() {
- OS::get_singleton()->native_video_unpause();
-};
-
-void _OS::native_video_stop() {
-
- OS::get_singleton()->native_video_stop();
-};
-
-void _OS::request_attention() {
-
- OS::get_singleton()->request_attention();
-}
-
-void _OS::center_window() {
-
- OS::get_singleton()->center_window();
-}
-
-void _OS::move_window_to_foreground() {
-
- OS::get_singleton()->move_window_to_foreground();
-}
-
bool _OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
@@ -1109,26 +740,6 @@ bool _OS::is_debug_build() const {
#endif
}
-void _OS::set_screen_orientation(ScreenOrientation p_orientation) {
-
- OS::get_singleton()->set_screen_orientation(OS::ScreenOrientation(p_orientation));
-}
-
-_OS::ScreenOrientation _OS::get_screen_orientation() const {
-
- return ScreenOrientation(OS::get_singleton()->get_screen_orientation());
-}
-
-void _OS::set_keep_screen_on(bool p_enabled) {
-
- OS::get_singleton()->set_keep_screen_on(p_enabled);
-}
-
-bool _OS::is_keep_screen_on() const {
-
- return OS::get_singleton()->is_keep_screen_on();
-}
-
String _OS::get_system_dir(SystemDir p_dir) const {
return OS::get_singleton()->get_system_dir(OS::SystemDir(p_dir));
@@ -1149,11 +760,6 @@ int _OS::find_keycode_from_string(const String &p_code) const {
return find_keycode(p_code);
}
-void _OS::alert(const String &p_alert, const String &p_title) {
-
- OS::get_singleton()->alert(p_alert, p_title);
-}
-
bool _OS::request_permission(const String &p_name) {
return OS::get_singleton()->request_permission(p_name);
@@ -1169,90 +775,17 @@ Vector<String> _OS::get_granted_permissions() const {
return OS::get_singleton()->get_granted_permissions();
}
+String _OS::get_unique_id() const {
+ return OS::get_singleton()->get_unique_id();
+}
_OS *_OS::singleton = NULL;
void _OS::_bind_methods() {
- //ClassDB::bind_method(D_METHOD("get_mouse_position"),&_OS::get_mouse_position);
- //ClassDB::bind_method(D_METHOD("is_mouse_grab_enabled"),&_OS::is_mouse_grab_enabled);
-
- ClassDB::bind_method(D_METHOD("set_clipboard", "clipboard"), &_OS::set_clipboard);
- ClassDB::bind_method(D_METHOD("get_clipboard"), &_OS::get_clipboard);
-
- //will not delete for now, just unexpose
- //ClassDB::bind_method(D_METHOD("set_video_mode","size","fullscreen","resizable","screen"),&_OS::set_video_mode,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("get_video_mode_size","screen"),&_OS::get_video_mode,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("is_video_mode_fullscreen","screen"),&_OS::is_video_mode_fullscreen,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
-
- ClassDB::bind_method(D_METHOD("global_menu_add_item", "menu", "label", "id", "meta"), &_OS::global_menu_add_item);
- ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu"), &_OS::global_menu_add_separator);
- ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu", "idx"), &_OS::global_menu_remove_item);
- ClassDB::bind_method(D_METHOD("global_menu_clear", "menu"), &_OS::global_menu_clear);
-
- ClassDB::bind_method(D_METHOD("get_video_driver_count"), &_OS::get_video_driver_count);
- ClassDB::bind_method(D_METHOD("get_video_driver_name", "driver"), &_OS::get_video_driver_name);
- ClassDB::bind_method(D_METHOD("get_current_video_driver"), &_OS::get_current_video_driver);
-
- ClassDB::bind_method(D_METHOD("get_audio_driver_count"), &_OS::get_audio_driver_count);
- ClassDB::bind_method(D_METHOD("get_audio_driver_name", "driver"), &_OS::get_audio_driver_name);
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs);
ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs);
- ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count);
- ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen);
- ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &_OS::set_current_screen);
- ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("get_window_position"), &_OS::get_window_position);
- ClassDB::bind_method(D_METHOD("set_window_position", "position"), &_OS::set_window_position);
- ClassDB::bind_method(D_METHOD("get_window_size"), &_OS::get_window_size);
- ClassDB::bind_method(D_METHOD("get_max_window_size"), &_OS::get_max_window_size);
- ClassDB::bind_method(D_METHOD("get_min_window_size"), &_OS::get_min_window_size);
- ClassDB::bind_method(D_METHOD("set_max_window_size", "size"), &_OS::set_max_window_size);
- ClassDB::bind_method(D_METHOD("set_min_window_size", "size"), &_OS::set_min_window_size);
- ClassDB::bind_method(D_METHOD("set_window_size", "size"), &_OS::set_window_size);
- ClassDB::bind_method(D_METHOD("get_window_safe_area"), &_OS::get_window_safe_area);
- ClassDB::bind_method(D_METHOD("set_window_fullscreen", "enabled"), &_OS::set_window_fullscreen);
- ClassDB::bind_method(D_METHOD("is_window_fullscreen"), &_OS::is_window_fullscreen);
- ClassDB::bind_method(D_METHOD("set_window_resizable", "enabled"), &_OS::set_window_resizable);
- ClassDB::bind_method(D_METHOD("is_window_resizable"), &_OS::is_window_resizable);
- ClassDB::bind_method(D_METHOD("set_window_minimized", "enabled"), &_OS::set_window_minimized);
- ClassDB::bind_method(D_METHOD("is_window_minimized"), &_OS::is_window_minimized);
- ClassDB::bind_method(D_METHOD("set_window_maximized", "enabled"), &_OS::set_window_maximized);
- ClassDB::bind_method(D_METHOD("is_window_maximized"), &_OS::is_window_maximized);
- ClassDB::bind_method(D_METHOD("set_window_always_on_top", "enabled"), &_OS::set_window_always_on_top);
- ClassDB::bind_method(D_METHOD("is_window_always_on_top"), &_OS::is_window_always_on_top);
- ClassDB::bind_method(D_METHOD("is_window_focused"), &_OS::is_window_focused);
- ClassDB::bind_method(D_METHOD("request_attention"), &_OS::request_attention);
- ClassDB::bind_method(D_METHOD("get_real_window_size"), &_OS::get_real_window_size);
- ClassDB::bind_method(D_METHOD("center_window"), &_OS::center_window);
- ClassDB::bind_method(D_METHOD("move_window_to_foreground"), &_OS::move_window_to_foreground);
-
- ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
- ClassDB::bind_method(D_METHOD("get_borderless_window"), &_OS::get_borderless_window);
-
- ClassDB::bind_method(D_METHOD("get_window_per_pixel_transparency_enabled"), &_OS::get_window_per_pixel_transparency_enabled);
- ClassDB::bind_method(D_METHOD("set_window_per_pixel_transparency_enabled", "enabled"), &_OS::set_window_per_pixel_transparency_enabled);
-
- ClassDB::bind_method(D_METHOD("set_ime_active", "active"), &_OS::set_ime_active);
- ClassDB::bind_method(D_METHOD("set_ime_position", "position"), &_OS::set_ime_position);
- ClassDB::bind_method(D_METHOD("get_ime_selection"), &_OS::get_ime_selection);
- ClassDB::bind_method(D_METHOD("get_ime_text"), &_OS::get_ime_text);
-
- ClassDB::bind_method(D_METHOD("set_screen_orientation", "orientation"), &_OS::set_screen_orientation);
- ClassDB::bind_method(D_METHOD("get_screen_orientation"), &_OS::get_screen_orientation);
-
- ClassDB::bind_method(D_METHOD("set_keep_screen_on", "enabled"), &_OS::set_keep_screen_on);
- ClassDB::bind_method(D_METHOD("is_keep_screen_on"), &_OS::is_keep_screen_on);
-
- ClassDB::bind_method(D_METHOD("has_touchscreen_ui_hint"), &_OS::has_touchscreen_ui_hint);
-
- ClassDB::bind_method(D_METHOD("set_window_title", "title"), &_OS::set_window_title);
-
ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode", "enable"), &_OS::set_low_processor_usage_mode);
ClassDB::bind_method(D_METHOD("is_in_low_processor_usage_mode"), &_OS::is_in_low_processor_usage_mode);
@@ -1283,9 +816,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
ClassDB::bind_method(D_METHOD("get_system_time_msecs"), &_OS::get_system_time_msecs);
- ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &_OS::set_native_icon);
- ClassDB::bind_method(D_METHOD("set_icon", "icon"), &_OS::set_icon);
-
ClassDB::bind_method(D_METHOD("get_exit_code"), &_OS::get_exit_code);
ClassDB::bind_method(D_METHOD("set_exit_code", "code"), &_OS::set_exit_code);
@@ -1295,10 +825,8 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ticks_usec"), &_OS::get_ticks_usec);
ClassDB::bind_method(D_METHOD("get_splash_tick_msec"), &_OS::get_splash_tick_msec);
ClassDB::bind_method(D_METHOD("get_locale"), &_OS::get_locale);
- ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &_OS::get_latin_keyboard_variant);
ClassDB::bind_method(D_METHOD("get_model_name"), &_OS::get_model_name);
- ClassDB::bind_method(D_METHOD("can_draw"), &_OS::can_draw);
ClassDB::bind_method(D_METHOD("is_userfs_persistent"), &_OS::is_userfs_persistent);
ClassDB::bind_method(D_METHOD("is_stdout_verbose"), &_OS::is_stdout_verbose);
@@ -1310,10 +838,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("dump_memory_to_file", "file"), &_OS::dump_memory_to_file);
ClassDB::bind_method(D_METHOD("dump_resources_to_file", "file"), &_OS::dump_resources_to_file);
- ClassDB::bind_method(D_METHOD("has_virtual_keyboard"), &_OS::has_virtual_keyboard);
- ClassDB::bind_method(D_METHOD("show_virtual_keyboard", "existing_text"), &_OS::show_virtual_keyboard, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("hide_virtual_keyboard"), &_OS::hide_virtual_keyboard);
- ClassDB::bind_method(D_METHOD("get_virtual_keyboard_height"), &_OS::get_virtual_keyboard_height);
ClassDB::bind_method(D_METHOD("print_resources_in_use", "short"), &_OS::print_resources_in_use, DEFVAL(false));
ClassDB::bind_method(D_METHOD("print_all_resources", "tofile"), &_OS::print_all_resources, DEFVAL(""));
@@ -1324,81 +848,32 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);
- ClassDB::bind_method(D_METHOD("is_ok_left_and_cancel_right"), &_OS::is_ok_left_and_cancel_right);
-
ClassDB::bind_method(D_METHOD("print_all_textures_by_size"), &_OS::print_all_textures_by_size);
ClassDB::bind_method(D_METHOD("print_resources_by_type", "types"), &_OS::print_resources_by_type);
- ClassDB::bind_method(D_METHOD("native_video_play", "path", "volume", "audio_track", "subtitle_track"), &_OS::native_video_play);
- ClassDB::bind_method(D_METHOD("native_video_is_playing"), &_OS::native_video_is_playing);
- ClassDB::bind_method(D_METHOD("native_video_stop"), &_OS::native_video_stop);
- ClassDB::bind_method(D_METHOD("native_video_pause"), &_OS::native_video_pause);
- ClassDB::bind_method(D_METHOD("native_video_unpause"), &_OS::native_video_unpause);
-
ClassDB::bind_method(D_METHOD("get_keycode_string", "code"), &_OS::get_keycode_string);
ClassDB::bind_method(D_METHOD("is_keycode_unicode", "code"), &_OS::is_keycode_unicode);
ClassDB::bind_method(D_METHOD("find_keycode_from_string", "string"), &_OS::find_keycode_from_string);
ClassDB::bind_method(D_METHOD("set_use_file_access_save_and_swap", "enabled"), &_OS::set_use_file_access_save_and_swap);
- ClassDB::bind_method(D_METHOD("alert", "text", "title"), &_OS::alert, DEFVAL("Alert!"));
-
ClassDB::bind_method(D_METHOD("set_thread_name", "name"), &_OS::set_thread_name);
- ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync);
- ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled);
-
- ClassDB::bind_method(D_METHOD("set_vsync_via_compositor", "enable"), &_OS::set_vsync_via_compositor);
- ClassDB::bind_method(D_METHOD("is_vsync_via_compositor_enabled"), &_OS::is_vsync_via_compositor_enabled);
-
ClassDB::bind_method(D_METHOD("has_feature", "tag_name"), &_OS::has_feature);
ClassDB::bind_method(D_METHOD("request_permission", "name"), &_OS::request_permission);
ClassDB::bind_method(D_METHOD("request_permissions"), &_OS::request_permissions);
ClassDB::bind_method(D_METHOD("get_granted_permissions"), &_OS::get_granted_permissions);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "clipboard"), "set_clipboard", "get_clipboard");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen"), "set_current_screen", "get_current_screen");
ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_enabled"), "set_use_vsync", "is_vsync_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_via_compositor"), "set_vsync_via_compositor", "is_vsync_via_compositor_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_screen_on"), "set_keep_screen_on", "is_keep_screen_on");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "min_window_size"), "set_min_window_size", "get_min_window_size");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "max_window_size"), "set_max_window_size", "get_max_window_size");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait,Reverse Landscape,Reverse Portrait,Sensor Landscape,Sensor Portrait,Sensor"), "set_screen_orientation", "get_screen_orientation");
- ADD_GROUP("Window", "window_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_borderless"), "set_borderless_window", "get_borderless_window");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_per_pixel_transparency_enabled"), "set_window_per_pixel_transparency_enabled", "get_window_per_pixel_transparency_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_fullscreen"), "set_window_fullscreen", "is_window_fullscreen");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_maximized"), "set_window_maximized", "is_window_maximized");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_minimized"), "set_window_minimized", "is_window_minimized");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_resizable"), "set_window_resizable", "is_window_resizable");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_position"), "set_window_position", "get_window_position");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_size"), "set_window_size", "get_window_size");
// Those default values need to be specified for the docs generator,
// to avoid using values from the documentation writer's own OS instance.
- ADD_PROPERTY_DEFAULT("clipboard", "");
- ADD_PROPERTY_DEFAULT("current_screen", 0);
ADD_PROPERTY_DEFAULT("exit_code", 0);
- ADD_PROPERTY_DEFAULT("vsync_enabled", true);
- ADD_PROPERTY_DEFAULT("vsync_via_compositor", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
- ADD_PROPERTY_DEFAULT("keep_screen_on", true);
- ADD_PROPERTY_DEFAULT("min_window_size", Vector2());
- ADD_PROPERTY_DEFAULT("max_window_size", Vector2());
- ADD_PROPERTY_DEFAULT("screen_orientation", 0);
- ADD_PROPERTY_DEFAULT("window_borderless", false);
- ADD_PROPERTY_DEFAULT("window_per_pixel_transparency_enabled", false);
- ADD_PROPERTY_DEFAULT("window_fullscreen", false);
- ADD_PROPERTY_DEFAULT("window_maximized", false);
- ADD_PROPERTY_DEFAULT("window_minimized", false);
- ADD_PROPERTY_DEFAULT("window_resizable", true);
- ADD_PROPERTY_DEFAULT("window_position", Vector2());
- ADD_PROPERTY_DEFAULT("window_size", Vector2());
BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES2);
BIND_ENUM_CONSTANT(VIDEO_DRIVER_VULKAN);
@@ -1424,14 +899,6 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(MONTH_NOVEMBER);
BIND_ENUM_CONSTANT(MONTH_DECEMBER);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_LANDSCAPE);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_PORTRAIT);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_PORTRAIT);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR_PORTRAIT);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR);
-
BIND_ENUM_CONSTANT(SYSTEM_DIR_DESKTOP);
BIND_ENUM_CONSTANT(SYSTEM_DIR_DCIM);
BIND_ENUM_CONSTANT(SYSTEM_DIR_DOCUMENTS);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 3a5bd28ce8..510d87844d 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -145,83 +145,10 @@ public:
MONTH_DECEMBER
};
- void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
- void global_menu_add_separator(const String &p_menu);
- void global_menu_remove_item(const String &p_menu, int p_idx);
- void global_menu_clear(const String &p_menu);
-
- Point2 get_mouse_position() const;
- void set_window_title(const String &p_title);
- int get_mouse_button_state() const;
-
- void set_clipboard(const String &p_text);
- String get_clipboard() const;
-
- void set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen = 0);
- Size2 get_video_mode(int p_screen = 0) const;
- bool is_video_mode_fullscreen(int p_screen = 0) const;
- bool is_video_mode_resizable(int p_screen = 0) const;
- Array get_fullscreen_mode_list(int p_screen = 0) const;
-
- virtual int get_video_driver_count() const;
- virtual String get_video_driver_name(VideoDriver p_driver) const;
- virtual VideoDriver get_current_video_driver() const;
-
- virtual int get_audio_driver_count() const;
- virtual String get_audio_driver_name(int p_driver) const;
-
virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
- virtual int get_screen_count() const;
- virtual int get_current_screen() const;
- virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = -1) const;
- virtual Size2 get_screen_size(int p_screen = -1) const;
- virtual int get_screen_dpi(int p_screen = -1) const;
- virtual Point2 get_window_position() const;
- virtual void set_window_position(const Point2 &p_position);
- virtual Size2 get_max_window_size() const;
- virtual Size2 get_min_window_size() const;
- virtual Size2 get_window_size() const;
- virtual Size2 get_real_window_size() const;
- virtual Rect2 get_window_safe_area() const;
- virtual void set_max_window_size(const Size2 &p_size);
- virtual void set_min_window_size(const Size2 &p_size);
- virtual void set_window_size(const Size2 &p_size);
- virtual void set_window_fullscreen(bool p_enabled);
- virtual bool is_window_fullscreen() const;
- virtual void set_window_resizable(bool p_enabled);
- virtual bool is_window_resizable() const;
- virtual void set_window_minimized(bool p_enabled);
- virtual bool is_window_minimized() const;
- virtual void set_window_maximized(bool p_enabled);
- virtual bool is_window_maximized() const;
- virtual void set_window_always_on_top(bool p_enabled);
- virtual bool is_window_always_on_top() const;
- virtual bool is_window_focused() const;
- virtual void request_attention();
- virtual void center_window();
- virtual void move_window_to_foreground();
-
- virtual void set_borderless_window(bool p_borderless);
- virtual bool get_borderless_window() const;
-
- virtual bool get_window_per_pixel_transparency_enabled() const;
- virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
-
- virtual void set_ime_active(const bool p_active);
- virtual void set_ime_position(const Point2 &p_pos);
- virtual Point2 get_ime_selection() const;
- virtual String get_ime_text() const;
-
- Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
- bool native_video_is_playing();
- void native_video_pause();
- void native_video_unpause();
- void native_video_stop();
-
void set_low_processor_usage_mode(bool p_enabled);
bool is_in_low_processor_usage_mode() const;
@@ -243,25 +170,17 @@ public:
Vector<String> get_cmdline_args();
String get_locale() const;
- String get_latin_keyboard_variant() const;
String get_model_name() const;
void dump_memory_to_file(const String &p_file);
void dump_resources_to_file(const String &p_file);
- bool has_virtual_keyboard() const;
- void show_virtual_keyboard(const String &p_existing_text = "");
- void hide_virtual_keyboard();
- int get_virtual_keyboard_height();
-
void print_resources_in_use(bool p_short = false);
void print_all_resources(const String &p_to_file);
void print_all_textures_by_size();
void print_resources_by_type(const Vector<String> &p_types);
- bool has_touchscreen_ui_hint() const;
-
bool is_debug_build() const;
String get_unique_id() const;
@@ -272,9 +191,6 @@ public:
void set_use_file_access_save_and_swap(bool p_enable);
- void set_native_icon(const String &p_filename);
- void set_icon(const Ref<Image> &p_icon);
-
int get_exit_code() const;
void set_exit_code(int p_code);
Dictionary get_date(bool utc) const;
@@ -298,8 +214,6 @@ public:
bool can_use_threads() const;
- bool can_draw() const;
-
bool is_userfs_persistent() const;
bool is_stdout_verbose() const;
@@ -317,39 +231,12 @@ public:
SYSTEM_DIR_RINGTONES,
};
- enum ScreenOrientation {
-
- SCREEN_ORIENTATION_LANDSCAPE,
- SCREEN_ORIENTATION_PORTRAIT,
- SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
- SCREEN_ORIENTATION_REVERSE_PORTRAIT,
- SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
- SCREEN_ORIENTATION_SENSOR_PORTRAIT,
- SCREEN_ORIENTATION_SENSOR,
- };
-
String get_system_dir(SystemDir p_dir) const;
String get_user_data_dir() const;
- void alert(const String &p_alert, const String &p_title = "ALERT!");
-
- void set_screen_orientation(ScreenOrientation p_orientation);
- ScreenOrientation get_screen_orientation() const;
-
- void set_keep_screen_on(bool p_enabled);
- bool is_keep_screen_on() const;
-
- bool is_ok_left_and_cancel_right() const;
-
Error set_thread_name(const String &p_name);
- void set_use_vsync(bool p_enable);
- bool is_vsync_enabled() const;
-
- void set_vsync_via_compositor(bool p_enable);
- bool is_vsync_via_compositor_enabled() const;
-
bool has_feature(const String &p_feature) const;
bool request_permission(const String &p_name);
@@ -365,7 +252,6 @@ VARIANT_ENUM_CAST(_OS::VideoDriver);
VARIANT_ENUM_CAST(_OS::Weekday);
VARIANT_ENUM_CAST(_OS::Month);
VARIANT_ENUM_CAST(_OS::SystemDir);
-VARIANT_ENUM_CAST(_OS::ScreenOrientation);
class _Geometry : public Object {
diff --git a/core/color.h b/core/color.h
index a7ab94ab08..16dc721072 100644
--- a/core/color.h
+++ b/core/color.h
@@ -239,4 +239,4 @@ bool Color::operator<(const Color &p_color) const {
return r < p_color.r;
}
-#endif
+#endif // COLOR_H
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 90231546ef..cc08ae7004 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -508,4 +508,4 @@ public:
#undef CMD_SYNC_TYPE
#undef DECL_CMD_SYNC
-#endif
+#endif // COMMAND_QUEUE_MT_H
diff --git a/core/core_builders.py b/core/core_builders.py
index 7720183595..a06b61cb9b 100644
--- a/core/core_builders.py
+++ b/core/core_builders.py
@@ -4,23 +4,41 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki
"""
from platform_methods import subprocess_main
-from compat import iteritems, itervalues, open_utf8, escape_string, byte_to_str
-def make_certs_header(target, source, env):
+def escape_string(s):
+ def charcode_to_c_escapes(c):
+ rev_result = []
+ while c >= 256:
+ c, low = (c // 256, c % 256)
+ rev_result.append('\\%03o' % low)
+ rev_result.append('\\%03o' % c)
+ return ''.join(reversed(rev_result))
+
+ result = ''
+ if isinstance(s, str):
+ s = s.encode('utf-8')
+ for c in s:
+ if not(32 <= c < 127) or c in (ord('\\'), ord('"')):
+ result += charcode_to_c_escapes(c)
+ else:
+ result += chr(c)
+ return result
+
+def make_certs_header(target, source, env):
src = source[0]
dst = target[0]
f = open(src, "rb")
- g = open_utf8(dst, "w")
+ g = open(dst, "w", encoding="utf-8")
buf = f.read()
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _CERTS_RAW_H\n")
- g.write("#define _CERTS_RAW_H\n")
+ g.write("#ifndef CERTS_COMPRESSED_GEN_H\n")
+ g.write("#define CERTS_COMPRESSED_GEN_H\n")
# System certs path. Editor will use them if defined. (for package maintainers)
path = env['system_certs_path']
@@ -32,9 +50,9 @@ def make_certs_header(target, source, env):
g.write("static const int _certs_uncompressed_size = " + str(decomp_size) + ";\n")
g.write("static const unsigned char _certs_compressed[] = {\n")
for i in range(len(buf)):
- g.write("\t" + byte_to_str(buf[i]) + ",\n")
+ g.write("\t" + str(buf[i]) + ",\n")
g.write("};\n")
- g.write("#endif")
+ g.write("#endif // CERTS_COMPRESSED_GEN_H")
g.close()
f.close()
@@ -46,12 +64,12 @@ def make_authors_header(target, source, env):
src = source[0]
dst = target[0]
- f = open_utf8(src, "r")
- g = open_utf8(dst, "w")
+ f = open(src, "r", encoding="utf-8")
+ g = open(dst, "w", encoding="utf-8")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_AUTHORS_H\n")
- g.write("#define _EDITOR_AUTHORS_H\n")
+ g.write("#ifndef AUTHORS_GEN_H\n")
+ g.write("#define AUTHORS_GEN_H\n")
reading = False
@@ -78,7 +96,7 @@ def make_authors_header(target, source, env):
if reading:
close_section()
- g.write("#endif\n")
+ g.write("#endif // AUTHORS_GEN_H\n")
g.close()
f.close()
@@ -92,12 +110,12 @@ def make_donors_header(target, source, env):
src = source[0]
dst = target[0]
- f = open_utf8(src, "r")
- g = open_utf8(dst, "w")
+ f = open(src, "r", encoding="utf-8")
+ g = open(dst, "w", encoding="utf-8")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_DONORS_H\n")
- g.write("#define _EDITOR_DONORS_H\n")
+ g.write("#ifndef DONORS_GEN_H\n")
+ g.write("#define DONORS_GEN_H\n")
reading = False
@@ -124,7 +142,7 @@ def make_donors_header(target, source, env):
if reading:
close_section()
- g.write("#endif\n")
+ g.write("#endif // DONORS_GEN_H\n")
g.close()
f.close()
@@ -163,7 +181,7 @@ def make_license_header(target, source, env):
projects = OrderedDict()
license_list = []
- with open_utf8(src_copyright, "r") as copyright_file:
+ with open(src_copyright, "r", encoding="utf-8") as copyright_file:
reader = LicenseReader(copyright_file)
part = {}
while reader.current:
@@ -183,21 +201,21 @@ def make_license_header(target, source, env):
reader.next_line()
data_list = []
- for project in itervalues(projects):
+ for project in iter(projects.values()):
for part in project:
part["file_index"] = len(data_list)
data_list += part["Files"]
part["copyright_index"] = len(data_list)
data_list += part["Copyright"]
- with open_utf8(dst, "w") as f:
+ with open(dst, "w", encoding="utf-8") as f:
f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- f.write("#ifndef _EDITOR_LICENSE_H\n")
- f.write("#define _EDITOR_LICENSE_H\n")
+ f.write("#ifndef LICENSE_GEN_H\n")
+ f.write("#define LICENSE_GEN_H\n")
f.write("const char *const GODOT_LICENSE_TEXT =")
- with open_utf8(src_license, "r") as license_file:
+ with open(src_license, "r", encoding="utf-8") as license_file:
for line in license_file:
escaped_string = escape_string(line.strip())
f.write("\n\t\t\"" + escaped_string + "\\n\"")
@@ -225,7 +243,7 @@ def make_license_header(target, source, env):
f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n")
part_index = 0
part_indexes = {}
- for project_name, project in iteritems(projects):
+ for project_name, project in iter(projects.items()):
part_indexes[project_name] = part_index
for part in project:
f.write("\t{ \"" + escape_string(part["License"][0]) + "\", "
@@ -239,7 +257,7 @@ def make_license_header(target, source, env):
f.write("const int COPYRIGHT_INFO_COUNT = " + str(len(projects)) + ";\n")
f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n")
- for project_name, project in iteritems(projects):
+ for project_name, project in iter(projects.items()):
f.write("\t{ \"" + escape_string(project_name) + "\", "
+ "&COPYRIGHT_PROJECT_PARTS[" + str(part_indexes[project_name]) + "], "
+ str(len(project)) + " },\n")
@@ -262,7 +280,7 @@ def make_license_header(target, source, env):
f.write("\t\"\",\n\n")
f.write("};\n\n")
- f.write("#endif\n")
+ f.write("#endif // LICENSE_GEN_H\n")
if __name__ == '__main__':
diff --git a/core/core_string_names.h b/core/core_string_names.h
index 42416d3f75..dce0244631 100644
--- a/core/core_string_names.h
+++ b/core/core_string_names.h
@@ -97,4 +97,4 @@ public:
StringName notification;
};
-#endif // SCENE_STRING_NAMES_H
+#endif // CORE_STRING_NAMES_H
diff --git a/core/cowdata.h b/core/cowdata.h
index fba3f64899..8b01b63aaa 100644
--- a/core/cowdata.h
+++ b/core/cowdata.h
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef COWDATA_H_
-#define COWDATA_H_
-
-#include <string.h>
+#ifndef COWDATA_H
+#define COWDATA_H
#include "core/error_macros.h"
#include "core/os/memory.h"
#include "core/safe_refcount.h"
+#include <string.h>
+
template <class T>
class Vector;
class String;
@@ -253,7 +253,9 @@ Error CowData<T>::resize(int p_size) {
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
- if (p_size == size())
+ int current_size = size();
+
+ if (p_size == current_size)
return OK;
if (p_size == 0) {
@@ -266,24 +268,27 @@ Error CowData<T>::resize(int p_size) {
// possibly changing size, copy on write
_copy_on_write();
+ size_t current_alloc_size = _get_alloc_size(current_size);
size_t alloc_size;
ERR_FAIL_COND_V(!_get_alloc_size_checked(p_size, &alloc_size), ERR_OUT_OF_MEMORY);
- if (p_size > size()) {
+ if (p_size > current_size) {
- if (size() == 0) {
- // alloc from scratch
- uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true);
- ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY);
- *(ptr - 1) = 0; //size, currently none
- *(ptr - 2) = 1; //refcount
+ if (alloc_size != current_alloc_size) {
+ if (current_size == 0) {
+ // alloc from scratch
+ uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true);
+ ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY);
+ *(ptr - 1) = 0; //size, currently none
+ *(ptr - 2) = 1; //refcount
- _ptr = (T *)ptr;
+ _ptr = (T *)ptr;
- } else {
- void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true);
- ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
- _ptr = (T *)(_ptrnew);
+ } else {
+ void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true);
+ ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
+ _ptr = (T *)(_ptrnew);
+ }
}
// construct the newly created elements
@@ -298,7 +303,7 @@ Error CowData<T>::resize(int p_size) {
*_get_size() = p_size;
- } else if (p_size < size()) {
+ } else if (p_size < current_size) {
if (!__has_trivial_destructor(T)) {
// deinitialize no longer needed elements
@@ -308,10 +313,12 @@ Error CowData<T>::resize(int p_size) {
}
}
- void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true);
- ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
+ if (alloc_size != current_alloc_size) {
+ void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true);
+ ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
- _ptr = (T *)(_ptrnew);
+ _ptr = (T *)(_ptrnew);
+ }
*_get_size() = p_size;
}
@@ -371,4 +378,4 @@ CowData<T>::~CowData() {
_unref(_ptr);
}
-#endif /* COW_H_ */
+#endif // COWDATA_H
diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp
index eb3a19506a..427c005b60 100644
--- a/core/debugger/debugger_marshalls.cpp
+++ b/core/debugger/debugger_marshalls.cpp
@@ -317,7 +317,7 @@ bool DebuggerMarshalls::VisualProfilerFrame::deserialize(const Array &p_arr) {
CHECK_SIZE(p_arr, size, "VisualProfilerFrame");
int idx = 2;
areas.resize(size / 3);
- VS::FrameProfileArea *w = areas.ptrw();
+ RS::FrameProfileArea *w = areas.ptrw();
for (int i = 0; i < size / 3; i++) {
w[i].name = p_arr[idx];
w[i].cpu_msec = p_arr[idx + 1];
diff --git a/core/debugger/debugger_marshalls.h b/core/debugger/debugger_marshalls.h
index 4c15adc555..04229c0afc 100644
--- a/core/debugger/debugger_marshalls.h
+++ b/core/debugger/debugger_marshalls.h
@@ -32,7 +32,7 @@
#define DEBUGGER_MARSHARLLS_H
#include "core/script_language.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
struct DebuggerMarshalls {
@@ -165,7 +165,7 @@ struct DebuggerMarshalls {
// Visual Profiler
struct VisualProfilerFrame {
uint64_t frame_number;
- Vector<VS::FrameProfileArea> areas;
+ Vector<RS::FrameProfileArea> areas;
Array serialize();
bool deserialize(const Array &p_arr);
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp
index 5f7ffb115c..66b890be23 100644
--- a/core/debugger/remote_debugger.cpp
+++ b/core/debugger/remote_debugger.cpp
@@ -33,11 +33,12 @@
#include "core/debugger/debugger_marshalls.h"
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "core/script_language.h"
#include "scene/main/node.h"
+#include "servers/display_server.h"
template <typename T>
void RemoteDebugger::_bind_profiler(const String &p_name, T *p_prof) {
@@ -353,18 +354,18 @@ struct RemoteDebugger::VisualProfiler {
Map<StringName, ServerInfo> server_data;
void toggle(bool p_enable, const Array &p_opts) {
- VS::get_singleton()->set_frame_profiling_enabled(p_enable);
+ RS::get_singleton()->set_frame_profiling_enabled(p_enable);
}
void add(const Array &p_data) {}
void tick(float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time) {
- Vector<VS::FrameProfileArea> profile_areas = VS::get_singleton()->get_frame_profile();
+ Vector<RS::FrameProfileArea> profile_areas = RS::get_singleton()->get_frame_profile();
DebuggerMarshalls::VisualProfilerFrame frame;
if (!profile_areas.size())
return;
- frame.frame_number = VS::get_singleton()->get_frame_profile_frame();
+ frame.frame_number = RS::get_singleton()->get_frame_profile_frame();
frame.areas.append_array(profile_areas);
EngineDebugger::get_singleton()->send_message("visual:profile_frame", frame.serialize());
}
@@ -403,10 +404,10 @@ void RemoteDebugger::_send_resource_usage() {
DebuggerMarshalls::ResourceUsage usage;
- List<VS::TextureInfo> tinfo;
- VS::get_singleton()->texture_debug_usage(&tinfo);
+ List<RS::TextureInfo> tinfo;
+ RS::get_singleton()->texture_debug_usage(&tinfo);
- for (List<VS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) {
+ for (List<RS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) {
DebuggerMarshalls::ResourceInfo info;
info.path = E->get().path;
@@ -658,9 +659,9 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
servers_profiler->skip_profile_frame = true; // Avoid frame time spike in debug.
- Input::MouseMode mouse_mode = Input::get_singleton()->get_mouse_mode();
- if (mouse_mode != Input::MOUSE_MODE_VISIBLE)
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ InputFilter::MouseMode mouse_mode = InputFilter::get_singleton()->get_mouse_mode();
+ if (mouse_mode != InputFilter::MOUSE_MODE_VISIBLE)
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
uint64_t loop_begin_usec = 0;
uint64_t loop_time_sec = 0;
@@ -694,7 +695,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
} else if (command == "continue") {
script_debugger->set_depth(-1);
script_debugger->set_lines_left(-1);
- OS::get_singleton()->move_window_to_foreground();
+ DisplayServer::get_singleton()->window_move_to_foreground();
break;
} else if (command == "break") {
@@ -770,16 +771,16 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
// This is for the camera override to stay live even when the game is paused from the editor
loop_time_sec = (OS::get_singleton()->get_ticks_usec() - loop_begin_usec) / 1000000.0f;
- VisualServer::get_singleton()->sync();
- if (VisualServer::get_singleton()->has_changed()) {
- VisualServer::get_singleton()->draw(true, loop_time_sec * Engine::get_singleton()->get_time_scale());
+ RenderingServer::get_singleton()->sync();
+ if (RenderingServer::get_singleton()->has_changed()) {
+ RenderingServer::get_singleton()->draw(true, loop_time_sec * Engine::get_singleton()->get_time_scale());
}
}
send_message("debug_exit", Array());
- if (mouse_mode != Input::MOUSE_MODE_VISIBLE)
- Input::get_singleton()->set_mouse_mode(mouse_mode);
+ if (mouse_mode != InputFilter::MOUSE_MODE_VISIBLE)
+ InputFilter::get_singleton()->set_mouse_mode(mouse_mode);
}
void RemoteDebugger::poll_events(bool p_is_idle) {
diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h
index 2273073bf4..a60b57c637 100644
--- a/core/debugger/script_debugger.h
+++ b/core/debugger/script_debugger.h
@@ -77,4 +77,4 @@ public:
ScriptDebugger() {}
};
-#endif
+#endif // SCRIPT_DEBUGGER_H
diff --git a/core/error_list.h b/core/error_list.h
index b464a93341..a0218cf045 100644
--- a/core/error_list.h
+++ b/core/error_list.h
@@ -90,4 +90,4 @@ enum Error {
ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
};
-#endif
+#endif // ERROR_LIST_H
diff --git a/core/error_macros.h b/core/error_macros.h
index 8818dcbe77..18c46c9e7d 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -623,4 +623,4 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
} else \
((void)0)
-#endif
+#endif // ERROR_MACROS_H
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 0945240c1f..8706a38453 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -30,8 +30,8 @@
#include "global_constants.h"
+#include "core/input/input_event.h"
#include "core/object.h"
-#include "core/os/input_event.h"
#include "core/os/keyboard.h"
#include "core/variant.h"
diff --git a/core/hash_map.h b/core/hash_map.h
index c9d3a690e7..e40b00a67a 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -599,4 +599,4 @@ public:
}
};
-#endif
+#endif // HASH_MAP_H
diff --git a/core/hashfuncs.h b/core/hashfuncs.h
index d6cf04e560..219b8b2658 100644
--- a/core/hashfuncs.h
+++ b/core/hashfuncs.h
@@ -38,6 +38,7 @@
#include "core/string_name.h"
#include "core/typedefs.h"
#include "core/ustring.h"
+
/**
* Hashing functions
*/
@@ -171,4 +172,4 @@ struct HashMapComparatorDefault {
}
};
-#endif
+#endif // HASHFUNCS_H
diff --git a/core/image.cpp b/core/image.cpp
index 2c39c9b882..d691c4f442 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1680,7 +1680,7 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
int pixel_ofs = y * w + x;
Color c = _get_color_at_ofs(ptr, pixel_ofs);
- float roughness;
+ float roughness = 0;
switch (p_roughness_channel) {
case ROUGHNESS_CHANNEL_R: {
diff --git a/core/image.h b/core/image.h
index 4dc4bf1328..9453f41334 100644
--- a/core/image.h
+++ b/core/image.h
@@ -396,4 +396,4 @@ VARIANT_ENUM_CAST(Image::UsedChannels)
VARIANT_ENUM_CAST(Image::AlphaMode)
VARIANT_ENUM_CAST(Image::RoughnessChannel)
-#endif
+#endif // IMAGE_H
diff --git a/core/input/SCsub b/core/input/SCsub
new file mode 100644
index 0000000000..f1660932e5
--- /dev/null
+++ b/core/input/SCsub
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+Import('env')
+
+from platform_methods import run_in_subprocess
+import input_builders
+
+
+# Order matters here. Higher index controller database files write on top of lower index database files.
+controller_databases = ["#core/input/gamecontrollerdb_204.txt", "#core/input/gamecontrollerdb_205.txt", "#core/input/gamecontrollerdb.txt", "#core/input/godotcontrollerdb.txt"]
+
+env.Depends("#core/input/default_controller_mappings.gen.cpp", controller_databases)
+env.CommandNoCache("#core/input/default_controller_mappings.gen.cpp", controller_databases, run_in_subprocess(input_builders.make_default_controller_mappings))
+
+env.add_source_files(env.core_sources, "*.cpp")
+
+# Don't warn about duplicate entry here, we need it registered manually for first build,
+# even if later builds will pick it up twice due to above *.cpp globbing.
+env.add_source_files(env.core_sources, "#core/input/default_controller_mappings.gen.cpp", warn_duplicates=False)
+
diff --git a/main/default_controller_mappings.h b/core/input/default_controller_mappings.h
index 9e2a69acec..9e2a69acec 100644
--- a/main/default_controller_mappings.h
+++ b/core/input/default_controller_mappings.h
diff --git a/main/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt
index 90d309c1c8..90d309c1c8 100644
--- a/main/gamecontrollerdb.txt
+++ b/core/input/gamecontrollerdb.txt
diff --git a/main/gamecontrollerdb_204.txt b/core/input/gamecontrollerdb_204.txt
index 7fbe925b25..7fbe925b25 100644
--- a/main/gamecontrollerdb_204.txt
+++ b/core/input/gamecontrollerdb_204.txt
diff --git a/main/gamecontrollerdb_205.txt b/core/input/gamecontrollerdb_205.txt
index 55c45eb148..55c45eb148 100644
--- a/main/gamecontrollerdb_205.txt
+++ b/core/input/gamecontrollerdb_205.txt
diff --git a/main/godotcontrollerdb.txt b/core/input/godotcontrollerdb.txt
index 472b01947b..472b01947b 100644
--- a/main/godotcontrollerdb.txt
+++ b/core/input/godotcontrollerdb.txt
diff --git a/core/input/input_builders.py b/core/input/input_builders.py
new file mode 100644
index 0000000000..ca142c0c80
--- /dev/null
+++ b/core/input/input_builders.py
@@ -0,0 +1,73 @@
+"""Functions used to generate source files during build time
+
+All such functions are invoked in a subprocess on Windows to prevent build flakiness.
+"""
+
+from platform_methods import subprocess_main
+from collections import OrderedDict
+
+
+def make_default_controller_mappings(target, source, env):
+ dst = target[0]
+ g = open(dst, "w")
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#include \"core/typedefs.h\"\n")
+ g.write("#include \"core/input/default_controller_mappings.h\"\n")
+
+ # ensure mappings have a consistent order
+ platform_mappings = OrderedDict()
+ for src_path in source:
+ with open(src_path, "r") as f:
+ # read mapping file and skip header
+ mapping_file_lines = f.readlines()[2:]
+
+ current_platform = None
+ for line in mapping_file_lines:
+ if not line:
+ continue
+ line = line.strip()
+ if len(line) == 0:
+ continue
+ if line[0] == "#":
+ current_platform = line[1:].strip()
+ if current_platform not in platform_mappings:
+ platform_mappings[current_platform] = {}
+ elif current_platform:
+ line_parts = line.split(",")
+ guid = line_parts[0]
+ if guid in platform_mappings[current_platform]:
+ g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
+ valid_mapping = True
+ for input_map in line_parts[2:]:
+ if "+" in input_map or "-" in input_map or "~" in input_map:
+ g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
+ valid_mapping = False
+ break
+ if valid_mapping:
+ platform_mappings[current_platform][guid] = line
+
+ platform_variables = {
+ "Linux": "#if X11_ENABLED",
+ "Windows": "#ifdef WINDOWS_ENABLED",
+ "Mac OS X": "#ifdef OSX_ENABLED",
+ "Android": "#if defined(__ANDROID__)",
+ "iOS": "#ifdef IPHONE_ENABLED",
+ "Javascript": "#ifdef JAVASCRIPT_ENABLED",
+ "UWP": "#ifdef UWP_ENABLED",
+ }
+
+ g.write("const char* DefaultControllerMappings::mappings[] = {\n")
+ for platform, mappings in platform_mappings.items():
+ variable = platform_variables[platform]
+ g.write("{}\n".format(variable))
+ for mapping in mappings.values():
+ g.write("\t\"{}\",\n".format(mapping))
+ g.write("#endif\n")
+
+ g.write("\tNULL\n};\n")
+ g.close()
+
+
+if __name__ == '__main__':
+ subprocess_main(globals())
diff --git a/core/os/input_event.cpp b/core/input/input_event.cpp
index 204a36bf56..088d185b8d 100644
--- a/core/os/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -30,7 +30,7 @@
#include "input_event.h"
-#include "core/input_map.h"
+#include "core/input/input_map.h"
#include "core/os/keyboard.h"
const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1;
@@ -136,6 +136,25 @@ InputEvent::InputEvent() {
device = 0;
}
+////////////////
+
+void InputEventFromWindow::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_window_id", "id"), &InputEventFromWindow::set_window_id);
+ ClassDB::bind_method(D_METHOD("get_window_id"), &InputEventFromWindow::get_window_id);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "window_id"), "set_window_id", "get_window_id");
+}
+
+void InputEventFromWindow::set_window_id(int64_t p_id) {
+ window_id = p_id;
+}
+int64_t InputEventFromWindow::get_window_id() const {
+ return window_id;
+}
+
+InputEventFromWindow::InputEventFromWindow() {
+ window_id = 0;
+}
//////////////////
@@ -499,7 +518,7 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
mb.instance();
mb->set_device(get_device());
-
+ mb->set_window_id(get_window_id());
mb->set_modifiers_from_event(this);
mb->set_position(l);
@@ -650,6 +669,7 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
mm.instance();
mm->set_device(get_device());
+ mm->set_window_id(get_window_id());
mm->set_modifiers_from_event(this);
@@ -697,6 +717,10 @@ bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
if (motion.is_null())
return false;
+ if (get_window_id() != motion->get_window_id()) {
+ return false;
+ }
+
if (is_pressed() != motion->is_pressed()) {
return false;
}
@@ -948,6 +972,7 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co
Ref<InputEventScreenTouch> st;
st.instance();
st->set_device(get_device());
+ st->set_window_id(get_window_id());
st->set_index(index);
st->set_position(p_xform.xform(pos + p_local_ofs));
st->set_pressed(pressed);
@@ -1028,6 +1053,7 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
sd.instance();
sd->set_device(get_device());
+ sd->set_window_id(get_window_id());
sd->set_index(index);
sd->set_position(p_xform.xform(pos + p_local_ofs));
@@ -1186,6 +1212,8 @@ Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform,
ev.instance();
ev->set_device(get_device());
+ ev->set_window_id(get_window_id());
+
ev->set_modifiers_from_event(this);
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
@@ -1228,6 +1256,8 @@ Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, con
ev.instance();
ev->set_device(get_device());
+ ev->set_window_id(get_window_id());
+
ev->set_modifiers_from_event(this);
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
diff --git a/core/os/input_event.h b/core/input/input_event.h
index c105fcd1c1..2fdcdd0319 100644
--- a/core/os/input_event.h
+++ b/core/input/input_event.h
@@ -205,8 +205,24 @@ public:
InputEvent();
};
-class InputEventWithModifiers : public InputEvent {
- GDCLASS(InputEventWithModifiers, InputEvent);
+class InputEventFromWindow : public InputEvent {
+
+ GDCLASS(InputEventFromWindow, InputEvent);
+
+ int64_t window_id;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_window_id(int64_t p_id);
+ int64_t get_window_id() const;
+
+ InputEventFromWindow();
+};
+
+class InputEventWithModifiers : public InputEventFromWindow {
+ GDCLASS(InputEventWithModifiers, InputEventFromWindow);
bool shift;
bool alt;
@@ -440,8 +456,8 @@ public:
InputEventJoypadButton();
};
-class InputEventScreenTouch : public InputEvent {
- GDCLASS(InputEventScreenTouch, InputEvent);
+class InputEventScreenTouch : public InputEventFromWindow {
+ GDCLASS(InputEventScreenTouch, InputEventFromWindow);
int index;
Vector2 pos;
bool pressed;
@@ -465,9 +481,9 @@ public:
InputEventScreenTouch();
};
-class InputEventScreenDrag : public InputEvent {
+class InputEventScreenDrag : public InputEventFromWindow {
- GDCLASS(InputEventScreenDrag, InputEvent);
+ GDCLASS(InputEventScreenDrag, InputEventFromWindow);
int index;
Vector2 pos;
Vector2 relative;
@@ -622,4 +638,4 @@ public:
InputEventMIDI();
};
-#endif
+#endif // INPUT_EVENT_H
diff --git a/main/input_default.cpp b/core/input/input_filter.cpp
index aa9e772a38..088f7effd6 100644
--- a/main/input_default.cpp
+++ b/core/input/input_filter.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* input_default.cpp */
+/* input_filter.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,134 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "input_default.h"
+#include "input_filter.h"
-#include "core/input_map.h"
+#include "core/input/default_controller_mappings.h"
+#include "core/input/input_map.h"
#include "core/os/os.h"
-#include "main/default_controller_mappings.h"
-#include "scene/resources/texture.h"
-#include "servers/visual_server.h"
+#include "core/project_settings.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_settings.h"
+#endif
+
+InputFilter *InputFilter::singleton = NULL;
+
+void (*InputFilter::set_mouse_mode_func)(InputFilter::MouseMode) = nullptr;
+InputFilter::MouseMode (*InputFilter::get_mouse_mode_func)() = nullptr;
+void (*InputFilter::warp_mouse_func)(const Vector2 &p_to_pos) = nullptr;
+InputFilter::CursorShape (*InputFilter::get_current_cursor_shape_func)() = nullptr;
+void (*InputFilter::set_custom_mouse_cursor_func)(const RES &, InputFilter::CursorShape, const Vector2 &) = nullptr;
+
+InputFilter *InputFilter::get_singleton() {
+
+ return singleton;
+}
+
+void InputFilter::set_mouse_mode(MouseMode p_mode) {
+ ERR_FAIL_INDEX((int)p_mode, 4);
+ set_mouse_mode_func(p_mode);
+}
+
+InputFilter::MouseMode InputFilter::get_mouse_mode() const {
+
+ return get_mouse_mode_func();
+}
+
+void InputFilter::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &InputFilter::is_key_pressed);
+ ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &InputFilter::is_mouse_button_pressed);
+ ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &InputFilter::is_joy_button_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &InputFilter::is_action_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &InputFilter::is_action_just_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &InputFilter::is_action_just_released);
+ ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &InputFilter::get_action_strength);
+ ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &InputFilter::add_joy_mapping, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &InputFilter::remove_joy_mapping);
+ ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &InputFilter::joy_connection_changed);
+ ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &InputFilter::is_joy_known);
+ ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &InputFilter::get_joy_axis);
+ ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &InputFilter::get_joy_name);
+ ClassDB::bind_method(D_METHOD("get_joy_guid", "device"), &InputFilter::get_joy_guid);
+ ClassDB::bind_method(D_METHOD("get_connected_joypads"), &InputFilter::get_connected_joypads);
+ ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &InputFilter::get_joy_vibration_strength);
+ ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &InputFilter::get_joy_vibration_duration);
+ ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &InputFilter::get_joy_button_string);
+ ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &InputFilter::get_joy_button_index_from_string);
+ ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &InputFilter::get_joy_axis_string);
+ ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &InputFilter::get_joy_axis_index_from_string);
+ ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &InputFilter::start_joy_vibration, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &InputFilter::stop_joy_vibration);
+ ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &InputFilter::vibrate_handheld, DEFVAL(500));
+ ClassDB::bind_method(D_METHOD("get_gravity"), &InputFilter::get_gravity);
+ ClassDB::bind_method(D_METHOD("get_accelerometer"), &InputFilter::get_accelerometer);
+ ClassDB::bind_method(D_METHOD("get_magnetometer"), &InputFilter::get_magnetometer);
+ ClassDB::bind_method(D_METHOD("get_gyroscope"), &InputFilter::get_gyroscope);
+ ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &InputFilter::get_last_mouse_speed);
+ ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &InputFilter::get_mouse_button_mask);
+ ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &InputFilter::set_mouse_mode);
+ ClassDB::bind_method(D_METHOD("get_mouse_mode"), &InputFilter::get_mouse_mode);
+ ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &InputFilter::warp_mouse_position);
+ ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &InputFilter::action_press, DEFVAL(1.f));
+ ClassDB::bind_method(D_METHOD("action_release", "action"), &InputFilter::action_release);
+ ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &InputFilter::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
+ ClassDB::bind_method(D_METHOD("get_current_cursor_shape"), &InputFilter::get_current_cursor_shape);
+ ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &InputFilter::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
+ ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &InputFilter::parse_input_event);
+ ClassDB::bind_method(D_METHOD("set_use_accumulated_input", "enable"), &InputFilter::set_use_accumulated_input);
+
+ BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
+
+ BIND_ENUM_CONSTANT(CURSOR_ARROW);
+ BIND_ENUM_CONSTANT(CURSOR_IBEAM);
+ BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
+ BIND_ENUM_CONSTANT(CURSOR_CROSS);
+ BIND_ENUM_CONSTANT(CURSOR_WAIT);
+ BIND_ENUM_CONSTANT(CURSOR_BUSY);
+ BIND_ENUM_CONSTANT(CURSOR_DRAG);
+ BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
+ BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
+ BIND_ENUM_CONSTANT(CURSOR_VSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_HSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_MOVE);
+ BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HELP);
+
+ ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected")));
+}
+
+void InputFilter::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
+#ifdef TOOLS_ENABLED
+
+ const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
+
+ String pf = p_function;
+ if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
+
+ List<PropertyInfo> pinfo;
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
+
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ const PropertyInfo &pi = E->get();
+
+ if (!pi.name.begins_with("input/"))
+ continue;
-void InputDefault::SpeedTrack::update(const Vector2 &p_delta_p) {
+ String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
+ r_options->push_back(quote_style + name + quote_style);
+ }
+ }
+#endif
+}
+
+void InputFilter::SpeedTrack::update(const Vector2 &p_delta_p) {
uint64_t tick = OS::get_singleton()->get_ticks_usec();
uint32_t tdiff = tick - last_tick;
@@ -60,26 +179,26 @@ void InputDefault::SpeedTrack::update(const Vector2 &p_delta_p) {
}
}
-void InputDefault::SpeedTrack::reset() {
+void InputFilter::SpeedTrack::reset() {
last_tick = OS::get_singleton()->get_ticks_usec();
speed = Vector2();
accum_t = 0;
}
-InputDefault::SpeedTrack::SpeedTrack() {
+InputFilter::SpeedTrack::SpeedTrack() {
min_ref_frame = 0.1;
max_ref_frame = 0.3;
reset();
}
-bool InputDefault::is_key_pressed(int p_keycode) const {
+bool InputFilter::is_key_pressed(int p_keycode) const {
_THREAD_SAFE_METHOD_
return keys_pressed.has(p_keycode);
}
-bool InputDefault::is_mouse_button_pressed(int p_button) const {
+bool InputFilter::is_mouse_button_pressed(int p_button) const {
_THREAD_SAFE_METHOD_
return (mouse_button_mask & (1 << (p_button - 1))) != 0;
@@ -90,18 +209,18 @@ static int _combine_device(int p_value, int p_device) {
return p_value | (p_device << 20);
}
-bool InputDefault::is_joy_button_pressed(int p_device, int p_button) const {
+bool InputFilter::is_joy_button_pressed(int p_device, int p_button) const {
_THREAD_SAFE_METHOD_
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
}
-bool InputDefault::is_action_pressed(const StringName &p_action) const {
+bool InputFilter::is_action_pressed(const StringName &p_action) const {
return action_state.has(p_action) && action_state[p_action].pressed;
}
-bool InputDefault::is_action_just_pressed(const StringName &p_action) const {
+bool InputFilter::is_action_just_pressed(const StringName &p_action) const {
const Map<StringName, Action>::Element *E = action_state.find(p_action);
if (!E)
@@ -114,7 +233,7 @@ bool InputDefault::is_action_just_pressed(const StringName &p_action) const {
}
}
-bool InputDefault::is_action_just_released(const StringName &p_action) const {
+bool InputFilter::is_action_just_released(const StringName &p_action) const {
const Map<StringName, Action>::Element *E = action_state.find(p_action);
if (!E)
@@ -127,7 +246,7 @@ bool InputDefault::is_action_just_released(const StringName &p_action) const {
}
}
-float InputDefault::get_action_strength(const StringName &p_action) const {
+float InputFilter::get_action_strength(const StringName &p_action) const {
const Map<StringName, Action>::Element *E = action_state.find(p_action);
if (!E)
return 0.0f;
@@ -135,7 +254,7 @@ float InputDefault::get_action_strength(const StringName &p_action) const {
return E->get().strength;
}
-float InputDefault::get_joy_axis(int p_device, int p_axis) const {
+float InputFilter::get_joy_axis(int p_device, int p_axis) const {
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
@@ -146,13 +265,13 @@ float InputDefault::get_joy_axis(int p_device, int p_axis) const {
}
}
-String InputDefault::get_joy_name(int p_idx) {
+String InputFilter::get_joy_name(int p_idx) {
_THREAD_SAFE_METHOD_
return joy_names[p_idx].name;
};
-Vector2 InputDefault::get_joy_vibration_strength(int p_device) {
+Vector2 InputFilter::get_joy_vibration_strength(int p_device) {
if (joy_vibration.has(p_device)) {
return Vector2(joy_vibration[p_device].weak_magnitude, joy_vibration[p_device].strong_magnitude);
} else {
@@ -160,7 +279,7 @@ Vector2 InputDefault::get_joy_vibration_strength(int p_device) {
}
}
-uint64_t InputDefault::get_joy_vibration_timestamp(int p_device) {
+uint64_t InputFilter::get_joy_vibration_timestamp(int p_device) {
if (joy_vibration.has(p_device)) {
return joy_vibration[p_device].timestamp;
} else {
@@ -168,7 +287,7 @@ uint64_t InputDefault::get_joy_vibration_timestamp(int p_device) {
}
}
-float InputDefault::get_joy_vibration_duration(int p_device) {
+float InputFilter::get_joy_vibration_duration(int p_device) {
if (joy_vibration.has(p_device)) {
return joy_vibration[p_device].duration;
} else {
@@ -188,7 +307,7 @@ static String _hex_str(uint8_t p_byte) {
return ret;
};
-void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
+void InputFilter::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
_THREAD_SAFE_METHOD_
Joypad js;
@@ -230,36 +349,36 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_
emit_signal("joy_connection_changed", p_idx, p_connected);
};
-Vector3 InputDefault::get_gravity() const {
+Vector3 InputFilter::get_gravity() const {
_THREAD_SAFE_METHOD_
return gravity;
}
-Vector3 InputDefault::get_accelerometer() const {
+Vector3 InputFilter::get_accelerometer() const {
_THREAD_SAFE_METHOD_
return accelerometer;
}
-Vector3 InputDefault::get_magnetometer() const {
+Vector3 InputFilter::get_magnetometer() const {
_THREAD_SAFE_METHOD_
return magnetometer;
}
-Vector3 InputDefault::get_gyroscope() const {
+Vector3 InputFilter::get_gyroscope() const {
_THREAD_SAFE_METHOD_
return gyroscope;
}
-void InputDefault::parse_input_event(const Ref<InputEvent> &p_event) {
+void InputFilter::parse_input_event(const Ref<InputEvent> &p_event) {
_parse_input_event_impl(p_event, false);
}
-void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated) {
+void InputFilter::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated) {
// Notes on mouse-touch emulation:
// - Emulated mouse events are parsed, that is, re-routed to this method, so they make the same effects
@@ -293,12 +412,12 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
set_mouse_position(pos);
}
- if (main_loop && emulate_touch_from_mouse && !p_is_emulated && mb->get_button_index() == 1) {
+ if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mb->get_button_index() == 1) {
Ref<InputEventScreenTouch> touch_event;
touch_event.instance();
touch_event->set_pressed(mb->is_pressed());
touch_event->set_position(mb->get_position());
- main_loop->input_event(touch_event);
+ event_dispatch_function(touch_event);
}
}
@@ -311,7 +430,7 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
set_mouse_position(pos);
}
- if (main_loop && emulate_touch_from_mouse && !p_is_emulated && mm->get_button_mask() & 1) {
+ if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && mm->get_button_mask() & 1) {
Ref<InputEventScreenDrag> drag_event;
drag_event.instance();
@@ -319,7 +438,7 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
drag_event->set_relative(mm->get_relative());
drag_event->set_speed(mm->get_speed());
- main_loop->input_event(drag_event);
+ event_dispatch_function(drag_event);
}
}
@@ -417,8 +536,8 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
if (ge.is_valid()) {
- if (main_loop) {
- main_loop->input_event(ge);
+ if (event_dispatch_function) {
+ event_dispatch_function(ge);
}
}
@@ -438,18 +557,18 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
}
}
- if (main_loop)
- main_loop->input_event(p_event);
+ if (event_dispatch_function)
+ event_dispatch_function(p_event);
}
-void InputDefault::set_joy_axis(int p_device, int p_axis, float p_value) {
+void InputFilter::set_joy_axis(int p_device, int p_axis, float p_value) {
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
_joy_axis[c] = p_value;
}
-void InputDefault::start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration) {
+void InputFilter::start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration) {
_THREAD_SAFE_METHOD_
if (p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) {
return;
@@ -462,7 +581,7 @@ void InputDefault::start_joy_vibration(int p_device, float p_weak_magnitude, flo
joy_vibration[p_device] = vibration;
}
-void InputDefault::stop_joy_vibration(int p_device) {
+void InputFilter::stop_joy_vibration(int p_device) {
_THREAD_SAFE_METHOD_
VibrationInfo vibration;
vibration.weak_magnitude = 0;
@@ -472,68 +591,63 @@ void InputDefault::stop_joy_vibration(int p_device) {
joy_vibration[p_device] = vibration;
}
-void InputDefault::vibrate_handheld(int p_duration_ms) {
+void InputFilter::vibrate_handheld(int p_duration_ms) {
OS::get_singleton()->vibrate_handheld(p_duration_ms);
}
-void InputDefault::set_gravity(const Vector3 &p_gravity) {
+void InputFilter::set_gravity(const Vector3 &p_gravity) {
_THREAD_SAFE_METHOD_
gravity = p_gravity;
}
-void InputDefault::set_accelerometer(const Vector3 &p_accel) {
+void InputFilter::set_accelerometer(const Vector3 &p_accel) {
_THREAD_SAFE_METHOD_
accelerometer = p_accel;
}
-void InputDefault::set_magnetometer(const Vector3 &p_magnetometer) {
+void InputFilter::set_magnetometer(const Vector3 &p_magnetometer) {
_THREAD_SAFE_METHOD_
magnetometer = p_magnetometer;
}
-void InputDefault::set_gyroscope(const Vector3 &p_gyroscope) {
+void InputFilter::set_gyroscope(const Vector3 &p_gyroscope) {
_THREAD_SAFE_METHOD_
gyroscope = p_gyroscope;
}
-void InputDefault::set_main_loop(MainLoop *p_main_loop) {
- main_loop = p_main_loop;
-}
-
-void InputDefault::set_mouse_position(const Point2 &p_posf) {
+void InputFilter::set_mouse_position(const Point2 &p_posf) {
mouse_speed_track.update(p_posf - mouse_pos);
mouse_pos = p_posf;
}
-Point2 InputDefault::get_mouse_position() const {
+Point2 InputFilter::get_mouse_position() const {
return mouse_pos;
}
-Point2 InputDefault::get_last_mouse_speed() const {
+Point2 InputFilter::get_last_mouse_speed() const {
return mouse_speed_track.speed;
}
-int InputDefault::get_mouse_button_mask() const {
+int InputFilter::get_mouse_button_mask() const {
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
}
-void InputDefault::warp_mouse_position(const Vector2 &p_to) {
-
- OS::get_singleton()->warp_mouse_position(p_to);
+void InputFilter::warp_mouse_position(const Vector2 &p_to) {
+ warp_mouse_func(p_to);
}
-Point2i InputDefault::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
+Point2i InputFilter::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
// The relative distance reported for the next event after a warp is in the boundaries of the
// size of the rect on that axis, but it may be greater, in which case there's not problem as fmod()
@@ -553,16 +667,16 @@ Point2i InputDefault::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_moti
const Point2i pos_local = p_motion->get_global_position() - p_rect.position;
const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y));
if (pos_warped != pos_local) {
- OS::get_singleton()->warp_mouse_position(pos_warped + p_rect.position);
+ warp_mouse_position(pos_warped + p_rect.position);
}
return rel_warped;
}
-void InputDefault::iteration(float p_step) {
+void InputFilter::iteration(float p_step) {
}
-void InputDefault::action_press(const StringName &p_action, float p_strength) {
+void InputFilter::action_press(const StringName &p_action, float p_strength) {
Action action;
@@ -574,7 +688,7 @@ void InputDefault::action_press(const StringName &p_action, float p_strength) {
action_state[p_action] = action;
}
-void InputDefault::action_release(const StringName &p_action) {
+void InputFilter::action_release(const StringName &p_action) {
Action action;
@@ -586,19 +700,19 @@ void InputDefault::action_release(const StringName &p_action) {
action_state[p_action] = action;
}
-void InputDefault::set_emulate_touch_from_mouse(bool p_emulate) {
+void InputFilter::set_emulate_touch_from_mouse(bool p_emulate) {
emulate_touch_from_mouse = p_emulate;
}
-bool InputDefault::is_emulating_touch_from_mouse() const {
+bool InputFilter::is_emulating_touch_from_mouse() const {
return emulate_touch_from_mouse;
}
// Calling this whenever the game window is focused helps unstucking the "touch mouse"
// if the OS or its abstraction class hasn't properly reported that touch pointers raised
-void InputDefault::ensure_touch_mouse_raised() {
+void InputFilter::ensure_touch_mouse_raised() {
if (mouse_from_touch_index != -1) {
mouse_from_touch_index = -1;
@@ -617,22 +731,22 @@ void InputDefault::ensure_touch_mouse_raised() {
}
}
-void InputDefault::set_emulate_mouse_from_touch(bool p_emulate) {
+void InputFilter::set_emulate_mouse_from_touch(bool p_emulate) {
emulate_mouse_from_touch = p_emulate;
}
-bool InputDefault::is_emulating_mouse_from_touch() const {
+bool InputFilter::is_emulating_mouse_from_touch() const {
return emulate_mouse_from_touch;
}
-Input::CursorShape InputDefault::get_default_cursor_shape() const {
+InputFilter::CursorShape InputFilter::get_default_cursor_shape() const {
return default_shape;
}
-void InputDefault::set_default_cursor_shape(CursorShape p_shape) {
+void InputFilter::set_default_cursor_shape(CursorShape p_shape) {
if (default_shape == p_shape)
return;
@@ -647,19 +761,19 @@ void InputDefault::set_default_cursor_shape(CursorShape p_shape) {
parse_input_event(mm);
}
-Input::CursorShape InputDefault::get_current_cursor_shape() const {
+InputFilter::CursorShape InputFilter::get_current_cursor_shape() const {
- return (Input::CursorShape)OS::get_singleton()->get_cursor_shape();
+ return get_current_cursor_shape_func();
}
-void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+void InputFilter::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
if (Engine::get_singleton()->is_editor_hint())
return;
- OS::get_singleton()->set_custom_mouse_cursor(p_cursor, (OS::CursorShape)p_shape, p_hotspot);
+ set_custom_mouse_cursor_func(p_cursor, p_shape, p_hotspot);
}
-void InputDefault::accumulate_input_event(const Ref<InputEvent> &p_event) {
+void InputFilter::accumulate_input_event(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (!use_accumulated_input) {
@@ -672,7 +786,7 @@ void InputDefault::accumulate_input_event(const Ref<InputEvent> &p_event) {
accumulated_events.push_back(p_event);
}
-void InputDefault::flush_accumulated_events() {
+void InputFilter::flush_accumulated_events() {
while (accumulated_events.front()) {
parse_input_event(accumulated_events.front()->get());
@@ -680,12 +794,12 @@ void InputDefault::flush_accumulated_events() {
}
}
-void InputDefault::set_use_accumulated_input(bool p_enable) {
+void InputFilter::set_use_accumulated_input(bool p_enable) {
use_accumulated_input = p_enable;
}
-void InputDefault::release_pressed_events() {
+void InputFilter::release_pressed_events() {
flush_accumulated_events(); // this is needed to release actions strengths
@@ -693,61 +807,17 @@ void InputDefault::release_pressed_events() {
joy_buttons_pressed.clear();
_joy_axis.clear();
- for (Map<StringName, InputDefault::Action>::Element *E = action_state.front(); E; E = E->next()) {
+ for (Map<StringName, InputFilter::Action>::Element *E = action_state.front(); E; E = E->next()) {
if (E->get().pressed)
action_release(E->key());
}
}
-InputDefault::InputDefault() {
-
- use_accumulated_input = true;
- mouse_button_mask = 0;
- emulate_touch_from_mouse = false;
- emulate_mouse_from_touch = false;
- mouse_from_touch_index = -1;
- main_loop = NULL;
- default_shape = CURSOR_ARROW;
-
- hat_map_default[HAT_UP].type = TYPE_BUTTON;
- hat_map_default[HAT_UP].index = JOY_DPAD_UP;
- hat_map_default[HAT_UP].value = 0;
-
- hat_map_default[HAT_RIGHT].type = TYPE_BUTTON;
- hat_map_default[HAT_RIGHT].index = JOY_DPAD_RIGHT;
- hat_map_default[HAT_RIGHT].value = 0;
-
- hat_map_default[HAT_DOWN].type = TYPE_BUTTON;
- hat_map_default[HAT_DOWN].index = JOY_DPAD_DOWN;
- hat_map_default[HAT_DOWN].value = 0;
-
- hat_map_default[HAT_LEFT].type = TYPE_BUTTON;
- hat_map_default[HAT_LEFT].index = JOY_DPAD_LEFT;
- hat_map_default[HAT_LEFT].value = 0;
-
- fallback_mapping = -1;
-
- // Parse default mappings.
- {
- int i = 0;
- while (DefaultControllerMappings::mappings[i]) {
- parse_mapping(DefaultControllerMappings::mappings[i++]);
- }
- }
-
- // If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides.
- String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG");
- if (env_mapping != "") {
- Vector<String> entries = env_mapping.split("\n");
- for (int i = 0; i < entries.size(); i++) {
- if (entries[i] == "")
- continue;
- parse_mapping(entries[i]);
- }
- }
+void InputFilter::set_event_dispatch_function(EventDispatchFunc p_function) {
+ event_dispatch_function = p_function;
}
-void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
+void InputFilter::joy_button(int p_device, int p_button, bool p_pressed) {
_THREAD_SAFE_METHOD_;
Joypad &joy = joy_names[p_device];
@@ -786,7 +856,7 @@ void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
// no event?
}
-void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
+void InputFilter::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
_THREAD_SAFE_METHOD_;
@@ -901,7 +971,7 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
//printf("invalid mapping\n");
}
-void InputDefault::joy_hat(int p_device, int p_val) {
+void InputFilter::joy_hat(int p_device, int p_val) {
_THREAD_SAFE_METHOD_;
const Joypad &joy = joy_names[p_device];
@@ -933,7 +1003,7 @@ void InputDefault::joy_hat(int p_device, int p_val) {
joy_names[p_device].hat_current = p_val;
}
-void InputDefault::_button_event(int p_device, int p_index, bool p_pressed) {
+void InputFilter::_button_event(int p_device, int p_index, bool p_pressed) {
Ref<InputEventJoypadButton> ievent;
ievent.instance();
@@ -944,7 +1014,7 @@ void InputDefault::_button_event(int p_device, int p_index, bool p_pressed) {
parse_input_event(ievent);
}
-void InputDefault::_axis_event(int p_device, int p_axis, float p_value) {
+void InputFilter::_axis_event(int p_device, int p_axis, float p_value) {
Ref<InputEventJoypadMotion> ievent;
ievent.instance();
@@ -955,7 +1025,7 @@ void InputDefault::_axis_event(int p_device, int p_axis, float p_value) {
parse_input_event(ievent);
};
-InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) {
+InputFilter::JoyEvent InputFilter::_find_to_event(String p_to) {
// string names of the SDL buttons in the same order as input_event.h godot buttons
static const char *buttons[] = { "a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", NULL };
@@ -993,7 +1063,7 @@ InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) {
return ret;
};
-void InputDefault::parse_mapping(String p_mapping) {
+void InputFilter::parse_mapping(String p_mapping) {
_THREAD_SAFE_METHOD_;
JoyDeviceMapping mapping;
@@ -1058,7 +1128,7 @@ void InputDefault::parse_mapping(String p_mapping) {
//printf("added mapping with uuid %ls\n", mapping.uid.c_str());
};
-void InputDefault::add_joy_mapping(String p_mapping, bool p_update_existing) {
+void InputFilter::add_joy_mapping(String p_mapping, bool p_update_existing) {
parse_mapping(p_mapping);
if (p_update_existing) {
Vector<String> entry = p_mapping.split(",");
@@ -1071,7 +1141,7 @@ void InputDefault::add_joy_mapping(String p_mapping, bool p_update_existing) {
}
}
-void InputDefault::remove_joy_mapping(String p_guid) {
+void InputFilter::remove_joy_mapping(String p_guid) {
for (int i = map_db.size() - 1; i >= 0; i--) {
if (p_guid == map_db[i].uid) {
map_db.remove(i);
@@ -1084,7 +1154,7 @@ void InputDefault::remove_joy_mapping(String p_guid) {
}
}
-void InputDefault::set_fallback_mapping(String p_guid) {
+void InputFilter::set_fallback_mapping(String p_guid) {
for (int i = 0; i < map_db.size(); i++) {
if (map_db[i].uid == p_guid) {
@@ -1094,28 +1164,18 @@ void InputDefault::set_fallback_mapping(String p_guid) {
}
}
-//Defaults to simple implementation for platforms with a fixed gamepad layout, like consoles.
-bool InputDefault::is_joy_known(int p_device) {
-
- return OS::get_singleton()->is_joy_known(p_device);
-}
-
-String InputDefault::get_joy_guid(int p_device) const {
- return OS::get_singleton()->get_joy_guid(p_device);
-}
-
//platforms that use the remapping system can override and call to these ones
-bool InputDefault::is_joy_mapped(int p_device) {
+bool InputFilter::is_joy_known(int p_device) {
int mapping = joy_names[p_device].mapping;
return mapping != -1 ? (mapping != fallback_mapping) : false;
}
-String InputDefault::get_joy_guid_remapped(int p_device) const {
+String InputFilter::get_joy_guid(int p_device) const {
ERR_FAIL_COND_V(!joy_names.has(p_device), "");
return joy_names[p_device].uid;
}
-Array InputDefault::get_connected_joypads() {
+Array InputFilter::get_connected_joypads() {
Array ret;
Map<int, Joypad>::Element *elem = joy_names.front();
while (elem) {
@@ -1159,12 +1219,12 @@ static const char *_axes[JOY_AXIS_MAX] = {
""
};
-String InputDefault::get_joy_button_string(int p_button) {
+String InputFilter::get_joy_button_string(int p_button) {
ERR_FAIL_INDEX_V(p_button, JOY_BUTTON_MAX, "");
return _buttons[p_button];
}
-int InputDefault::get_joy_button_index_from_string(String p_button) {
+int InputFilter::get_joy_button_index_from_string(String p_button) {
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
if (p_button == _buttons[i]) {
return i;
@@ -1173,7 +1233,7 @@ int InputDefault::get_joy_button_index_from_string(String p_button) {
ERR_FAIL_V(-1);
}
-int InputDefault::get_unused_joy_id() {
+int InputFilter::get_unused_joy_id() {
for (int i = 0; i < JOYPADS_MAX; i++) {
if (!joy_names.has(i) || !joy_names[i].connected) {
return i;
@@ -1182,12 +1242,12 @@ int InputDefault::get_unused_joy_id() {
return -1;
}
-String InputDefault::get_joy_axis_string(int p_axis) {
+String InputFilter::get_joy_axis_string(int p_axis) {
ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, "");
return _axes[p_axis];
}
-int InputDefault::get_joy_axis_index_from_string(String p_axis) {
+int InputFilter::get_joy_axis_index_from_string(String p_axis) {
for (int i = 0; i < JOY_AXIS_MAX; i++) {
if (p_axis == _axes[i]) {
return i;
@@ -1195,3 +1255,55 @@ int InputDefault::get_joy_axis_index_from_string(String p_axis) {
}
ERR_FAIL_V(-1);
}
+
+InputFilter::InputFilter() {
+
+ singleton = this;
+ use_accumulated_input = true;
+ mouse_button_mask = 0;
+ mouse_window = 0;
+ emulate_touch_from_mouse = false;
+ emulate_mouse_from_touch = false;
+ mouse_from_touch_index = -1;
+ event_dispatch_function = nullptr;
+ default_shape = CURSOR_ARROW;
+
+ hat_map_default[HAT_UP].type = TYPE_BUTTON;
+ hat_map_default[HAT_UP].index = JOY_DPAD_UP;
+ hat_map_default[HAT_UP].value = 0;
+
+ hat_map_default[HAT_RIGHT].type = TYPE_BUTTON;
+ hat_map_default[HAT_RIGHT].index = JOY_DPAD_RIGHT;
+ hat_map_default[HAT_RIGHT].value = 0;
+
+ hat_map_default[HAT_DOWN].type = TYPE_BUTTON;
+ hat_map_default[HAT_DOWN].index = JOY_DPAD_DOWN;
+ hat_map_default[HAT_DOWN].value = 0;
+
+ hat_map_default[HAT_LEFT].type = TYPE_BUTTON;
+ hat_map_default[HAT_LEFT].index = JOY_DPAD_LEFT;
+ hat_map_default[HAT_LEFT].value = 0;
+
+ fallback_mapping = -1;
+
+ // Parse default mappings.
+ {
+ int i = 0;
+ while (DefaultControllerMappings::mappings[i]) {
+ parse_mapping(DefaultControllerMappings::mappings[i++]);
+ }
+ }
+
+ // If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides.
+ String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG");
+ if (env_mapping != "") {
+ Vector<String> entries = env_mapping.split("\n");
+ for (int i = 0; i < entries.size(); i++) {
+ if (entries[i] == "")
+ continue;
+ parse_mapping(entries[i]);
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////
diff --git a/main/input_default.h b/core/input/input_filter.h
index 0ec31d417b..908a005228 100644
--- a/main/input_default.h
+++ b/core/input/input_filter.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* input_default.h */
+/* input_filter.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,78 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef INPUT_DEFAULT_H
-#define INPUT_DEFAULT_H
+#ifndef INPUT_H
+#define INPUT_H
-#include "core/os/input.h"
+#include "core/input/input_event.h"
+#include "core/object.h"
+#include "core/os/thread_safe.h"
-class InputDefault : public Input {
+class InputFilter : public Object {
- GDCLASS(InputDefault, Input);
+ GDCLASS(InputFilter, Object);
_THREAD_SAFE_CLASS_
+ static InputFilter *singleton;
+
+public:
+ enum MouseMode {
+ MOUSE_MODE_VISIBLE,
+ MOUSE_MODE_HIDDEN,
+ MOUSE_MODE_CAPTURED,
+ MOUSE_MODE_CONFINED
+ };
+
+#undef CursorShape
+ enum CursorShape {
+ CURSOR_ARROW,
+ CURSOR_IBEAM,
+ CURSOR_POINTING_HAND,
+ CURSOR_CROSS,
+ CURSOR_WAIT,
+ CURSOR_BUSY,
+ CURSOR_DRAG,
+ CURSOR_CAN_DROP,
+ CURSOR_FORBIDDEN,
+ CURSOR_VSIZE,
+ CURSOR_HSIZE,
+ CURSOR_BDIAGSIZE,
+ CURSOR_FDIAGSIZE,
+ CURSOR_MOVE,
+ CURSOR_VSPLIT,
+ CURSOR_HSPLIT,
+ CURSOR_HELP,
+ CURSOR_MAX
+ };
+
+ enum HatMask {
+ HAT_MASK_CENTER = 0,
+ HAT_MASK_UP = 1,
+ HAT_MASK_RIGHT = 2,
+ HAT_MASK_DOWN = 4,
+ HAT_MASK_LEFT = 8,
+ };
+
+ enum HatDir {
+ HAT_UP,
+ HAT_RIGHT,
+ HAT_DOWN,
+ HAT_LEFT,
+ HAT_MAX,
+ };
+
+ enum {
+ JOYPADS_MAX = 16,
+ };
+
+ struct JoyAxis {
+ int min;
+ float value;
+ };
+
+ typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event);
+
+private:
int mouse_button_mask;
Set<int> keys_pressed;
@@ -49,7 +111,7 @@ class InputDefault : public Input {
Vector3 magnetometer;
Vector3 gyroscope;
Vector2 mouse_pos;
- MainLoop *main_loop;
+ int64_t mouse_window;
struct Action {
uint64_t physics_frame;
@@ -123,33 +185,6 @@ class InputDefault : public Input {
CursorShape default_shape;
-public:
- enum HatMask {
- HAT_MASK_CENTER = 0,
- HAT_MASK_UP = 1,
- HAT_MASK_RIGHT = 2,
- HAT_MASK_DOWN = 4,
- HAT_MASK_LEFT = 8,
- };
-
- enum HatDir {
- HAT_UP,
- HAT_RIGHT,
- HAT_DOWN,
- HAT_LEFT,
- HAT_MAX,
- };
-
- enum {
- JOYPADS_MAX = 16,
- };
-
- struct JoyAxis {
- int min;
- float value;
- };
-
-private:
enum JoyType {
TYPE_BUTTON,
TYPE_AXIS,
@@ -185,38 +220,57 @@ private:
List<Ref<InputEvent>> accumulated_events;
bool use_accumulated_input;
+ friend class DisplayServer;
+
+ static void (*set_mouse_mode_func)(MouseMode);
+ static MouseMode (*get_mouse_mode_func)();
+ static void (*warp_mouse_func)(const Vector2 &p_to_pos);
+
+ static CursorShape (*get_current_cursor_shape_func)();
+ static void (*set_custom_mouse_cursor_func)(const RES &, CursorShape, const Vector2 &);
+
+ EventDispatchFunc event_dispatch_function;
+
+protected:
+ static void _bind_methods();
public:
- virtual bool is_key_pressed(int p_keycode) const;
- virtual bool is_mouse_button_pressed(int p_button) const;
- virtual bool is_joy_button_pressed(int p_device, int p_button) const;
- virtual bool is_action_pressed(const StringName &p_action) const;
- virtual bool is_action_just_pressed(const StringName &p_action) const;
- virtual bool is_action_just_released(const StringName &p_action) const;
- virtual float get_action_strength(const StringName &p_action) const;
-
- virtual float get_joy_axis(int p_device, int p_axis) const;
+ void set_mouse_mode(MouseMode p_mode);
+ MouseMode get_mouse_mode() const;
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
+
+ static InputFilter *get_singleton();
+
+ bool is_key_pressed(int p_keycode) const;
+ bool is_mouse_button_pressed(int p_button) const;
+ bool is_joy_button_pressed(int p_device, int p_button) const;
+ bool is_action_pressed(const StringName &p_action) const;
+ bool is_action_just_pressed(const StringName &p_action) const;
+ bool is_action_just_released(const StringName &p_action) const;
+ float get_action_strength(const StringName &p_action) const;
+
+ float get_joy_axis(int p_device, int p_axis) const;
String get_joy_name(int p_idx);
- virtual Array get_connected_joypads();
- virtual Vector2 get_joy_vibration_strength(int p_device);
- virtual float get_joy_vibration_duration(int p_device);
- virtual uint64_t get_joy_vibration_timestamp(int p_device);
+ Array get_connected_joypads();
+ Vector2 get_joy_vibration_strength(int p_device);
+ float get_joy_vibration_duration(int p_device);
+ uint64_t get_joy_vibration_timestamp(int p_device);
void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = "");
void parse_joypad_mapping(String p_mapping, bool p_update_existing);
- virtual Vector3 get_gravity() const;
- virtual Vector3 get_accelerometer() const;
- virtual Vector3 get_magnetometer() const;
- virtual Vector3 get_gyroscope() const;
+ Vector3 get_gravity() const;
+ Vector3 get_accelerometer() const;
+ Vector3 get_magnetometer() const;
+ Vector3 get_gyroscope() const;
- virtual Point2 get_mouse_position() const;
- virtual Point2 get_last_mouse_speed() const;
- virtual int get_mouse_button_mask() const;
+ Point2 get_mouse_position() const;
+ Point2 get_last_mouse_speed() const;
+ int get_mouse_button_mask() const;
- virtual void warp_mouse_position(const Vector2 &p_to);
- virtual Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
+ void warp_mouse_position(const Vector2 &p_to);
+ Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect);
- virtual void parse_input_event(const Ref<InputEvent> &p_event);
+ void parse_input_event(const Ref<InputEvent> &p_event);
void set_gravity(const Vector3 &p_gravity);
void set_accelerometer(const Vector3 &p_accel);
@@ -224,11 +278,10 @@ public:
void set_gyroscope(const Vector3 &p_gyroscope);
void set_joy_axis(int p_device, int p_axis, float p_value);
- virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
- virtual void stop_joy_vibration(int p_device);
- virtual void vibrate_handheld(int p_duration_ms = 500);
+ void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
+ void stop_joy_vibration(int p_device);
+ void vibrate_handheld(int p_duration_ms = 500);
- void set_main_loop(MainLoop *p_main_loop);
void set_mouse_position(const Point2 &p_posf);
void action_press(const StringName &p_action, float p_strength = 1.f);
@@ -237,44 +290,48 @@ public:
void iteration(float p_step);
void set_emulate_touch_from_mouse(bool p_emulate);
- virtual bool is_emulating_touch_from_mouse() const;
+ bool is_emulating_touch_from_mouse() const;
void ensure_touch_mouse_raised();
void set_emulate_mouse_from_touch(bool p_emulate);
- virtual bool is_emulating_mouse_from_touch() const;
+ bool is_emulating_mouse_from_touch() const;
- virtual CursorShape get_default_cursor_shape() const;
- virtual void set_default_cursor_shape(CursorShape p_shape);
- virtual CursorShape get_current_cursor_shape() const;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
+ CursorShape get_default_cursor_shape() const;
+ void set_default_cursor_shape(CursorShape p_shape);
+ CursorShape get_current_cursor_shape() const;
+ void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = InputFilter::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
void parse_mapping(String p_mapping);
void joy_button(int p_device, int p_button, bool p_pressed);
void joy_axis(int p_device, int p_axis, const JoyAxis &p_value);
void joy_hat(int p_device, int p_val);
- virtual void add_joy_mapping(String p_mapping, bool p_update_existing = false);
- virtual void remove_joy_mapping(String p_guid);
- virtual bool is_joy_known(int p_device);
- virtual String get_joy_guid(int p_device) const;
+ void add_joy_mapping(String p_mapping, bool p_update_existing = false);
+ void remove_joy_mapping(String p_guid);
- virtual String get_joy_button_string(int p_button);
- virtual String get_joy_axis_string(int p_axis);
- virtual int get_joy_axis_index_from_string(String p_axis);
- virtual int get_joy_button_index_from_string(String p_button);
+ String get_joy_button_string(int p_button);
+ String get_joy_axis_string(int p_axis);
+ int get_joy_axis_index_from_string(String p_axis);
+ int get_joy_button_index_from_string(String p_button);
int get_unused_joy_id();
- bool is_joy_mapped(int p_device);
- String get_joy_guid_remapped(int p_device) const;
+ bool is_joy_known(int p_device);
+ String get_joy_guid(int p_device) const;
void set_fallback_mapping(String p_guid);
- virtual void accumulate_input_event(const Ref<InputEvent> &p_event);
- virtual void flush_accumulated_events();
- virtual void set_use_accumulated_input(bool p_enable);
+ void accumulate_input_event(const Ref<InputEvent> &p_event);
+ void flush_accumulated_events();
+ void set_use_accumulated_input(bool p_enable);
+
+ void release_pressed_events();
- virtual void release_pressed_events();
- InputDefault();
+ void set_event_dispatch_function(EventDispatchFunc p_function);
+
+ InputFilter();
};
-#endif // INPUT_DEFAULT_H
+VARIANT_ENUM_CAST(InputFilter::MouseMode);
+VARIANT_ENUM_CAST(InputFilter::CursorShape);
+
+#endif // INPUT_H
diff --git a/core/input_map.cpp b/core/input/input_map.cpp
index 8f18c082d6..8f18c082d6 100644
--- a/core/input_map.cpp
+++ b/core/input/input_map.cpp
diff --git a/core/input_map.h b/core/input/input_map.h
index 6039d915c9..de6f57b0bf 100644
--- a/core/input_map.h
+++ b/core/input/input_map.h
@@ -31,8 +31,8 @@
#ifndef INPUT_MAP_H
#define INPUT_MAP_H
+#include "core/input/input_event.h"
#include "core/object.h"
-#include "core/os/input_event.h"
class InputMap : public Object {
diff --git a/core/int_types.h b/core/int_types.h
index e7de053766..71caa2202d 100644
--- a/core/int_types.h
+++ b/core/int_types.h
@@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef INT_TYPES_H
+#define INT_TYPES_H
+
#ifdef _MSC_VER
typedef signed __int8 int8_t;
@@ -54,4 +57,6 @@ typedef unsigned long long uint64_t;
#include <stdint.h>
#endif
-#endif
+#endif // _MSC_VER
+
+#endif // INT_TYPES_H
diff --git a/core/io/image_loader.h b/core/io/image_loader.h
index 3ba028b99c..29352e9cd4 100644
--- a/core/io/image_loader.h
+++ b/core/io/image_loader.h
@@ -79,4 +79,4 @@ public:
virtual String get_resource_type(const String &p_path) const;
};
-#endif
+#endif // IMAGE_LOADER_H
diff --git a/core/io/logger.h b/core/io/logger.h
index ab2f9d8bc7..7028551185 100644
--- a/core/io/logger.h
+++ b/core/io/logger.h
@@ -107,4 +107,4 @@ public:
virtual ~CompositeLogger();
};
-#endif
+#endif // LOGGER_H
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index 484f0755de..7d95bc4f86 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -202,4 +202,4 @@ public:
Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = false);
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false);
-#endif
+#endif // MARSHALLS_H
diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h
index 52f918aefa..4eb4a53e99 100644
--- a/core/io/multiplayer_api.h
+++ b/core/io/multiplayer_api.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef MULTIPLAYER_PROTOCOL_H
-#define MULTIPLAYER_PROTOCOL_H
+#ifndef MULTIPLAYER_API_H
+#define MULTIPLAYER_API_H
#include "core/io/networked_multiplayer_peer.h"
#include "core/reference.h"
@@ -148,4 +148,4 @@ public:
VARIANT_ENUM_CAST(MultiplayerAPI::RPCMode);
-#endif // MULTIPLAYER_PROTOCOL_H
+#endif // MULTIPLAYER_API_H
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
index bffd544589..c1f1924051 100644
--- a/core/io/networked_multiplayer_peer.h
+++ b/core/io/networked_multiplayer_peer.h
@@ -80,4 +80,4 @@ public:
VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode)
VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::ConnectionStatus)
-#endif // NetworkedMultiplayerPeer_H
+#endif // NETWORKED_MULTIPLAYER_PEER_H
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 5ba9e26858..a97b72e7df 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -200,4 +200,4 @@ public:
static void finalize();
};
-#endif
+#endif // RESOURCE_LOADER_H
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index e749f54cfa..2ddebf0581 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -90,4 +90,4 @@ public:
static void remove_custom_savers();
};
-#endif
+#endif // RESOURCE_SAVER_H
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 327aa3cc3b..86df9ab8cf 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -93,4 +93,4 @@ public:
VARIANT_ENUM_CAST(StreamPeerTCP::Status);
-#endif
+#endif // STREAM_PEER_TCP_H
diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h
index 47e276da28..26c3e6802f 100644
--- a/core/io/xml_parser.h
+++ b/core/io/xml_parser.h
@@ -121,4 +121,4 @@ public:
~XMLParser();
};
-#endif
+#endif // XML_PARSER_H
diff --git a/core/list.h b/core/list.h
index 5a7c9e572c..d441c0230d 100644
--- a/core/list.h
+++ b/core/list.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GLOBALS_LIST_H
-#define GLOBALS_LIST_H
+#ifndef LIST_H
+#define LIST_H
#include "core/error_macros.h"
#include "core/os/memory.h"
@@ -708,4 +708,4 @@ public:
};
};
-#endif
+#endif // LIST_H
diff --git a/core/map.h b/core/map.h
index b97f735f1b..010c47b0fb 100644
--- a/core/map.h
+++ b/core/map.h
@@ -682,4 +682,4 @@ public:
}
};
-#endif
+#endif // MAP_H
diff --git a/core/math/a_star.h b/core/math/a_star.h
index cc6c4619e9..8c10ace33c 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef ASTAR_H
-#define ASTAR_H
+#ifndef A_STAR_H
+#define A_STAR_H
#include "core/oa_hash_map.h"
#include "core/reference.h"
@@ -210,4 +210,4 @@ public:
~AStar2D();
};
-#endif // ASTAR_H
+#endif // A_STAR_H
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
index 6477d029d5..e1dbb385e4 100644
--- a/core/math/audio_frame.h
+++ b/core/math/audio_frame.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef AUDIOFRAME_H
-#define AUDIOFRAME_H
+#ifndef AUDIO_FRAME_H
+#define AUDIO_FRAME_H
#include "core/math/vector2.h"
#include "core/typedefs.h"
@@ -140,4 +140,4 @@ struct AudioFrame {
_ALWAYS_INLINE_ AudioFrame() {}
};
-#endif
+#endif // AUDIO_FRAME_H
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 60f7d15974..c10193bc84 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -124,4 +124,4 @@ Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const {
return ret / w;
}
-#endif
+#endif // CAMERA_MATRIX_H
diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h
index fb89941ce4..32b9875e4c 100644
--- a/core/math/disjoint_set.h
+++ b/core/math/disjoint_set.h
@@ -152,4 +152,4 @@ void DisjointSet<T, C, AL>::get_members(Vector<T> &out_members, T representative
}
}
-#endif
+#endif // DISJOINT_SET_H
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 6453d16181..becbcdbf0f 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -1019,4 +1019,4 @@ private:
static Vector<Vector<Point2>> _polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type);
};
-#endif
+#endif // GEOMETRY_H
diff --git a/core/math/octree.h b/core/math/octree.h
index 5478bdaf77..b47c052b68 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -1375,4 +1375,4 @@ Octree<T, use_pairs, AL>::Octree(real_t p_unit_size) {
unpair_callback_userdata = NULL;
}
-#endif
+#endif // OCTREE_H
diff --git a/core/math/quat.h b/core/math/quat.h
index 11ae03dffb..b3135ad1ca 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -231,4 +231,4 @@ bool Quat::operator!=(const Quat &p_quat) const {
return x != p_quat.x || y != p_quat.y || z != p_quat.z || w != p_quat.w;
}
-#endif
+#endif // QUAT_H
diff --git a/core/math/triangulate.h b/core/math/triangulate.h
index f9bcb37141..c453b77ecf 100644
--- a/core/math/triangulate.h
+++ b/core/math/triangulate.h
@@ -58,4 +58,4 @@ private:
static bool snip(const Vector<Vector2> &p_contour, int u, int v, int w, int n, const Vector<int> &V, bool relaxed);
};
-#endif
+#endif // TRIANGULATE_H
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 37207483fe..26f5b23416 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -343,14 +343,14 @@ bool MessageQueue::is_flushing() const {
MessageQueue::MessageQueue() {
- ERR_FAIL_COND_MSG(singleton != NULL, "MessageQueue singleton already exist.");
+ ERR_FAIL_COND_MSG(singleton != NULL, "A MessageQueue singleton already exists.");
singleton = this;
flushing = false;
buffer_end = 0;
buffer_max_used = 0;
buffer_size = GLOBAL_DEF_RST("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB);
- ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/message_queue/max_size_kb", PropertyInfo(Variant::INT, "memory/limits/message_queue/max_size_kb", PROPERTY_HINT_RANGE, "0,2048,1,or_greater"));
+ ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/message_queue/max_size_kb", PropertyInfo(Variant::INT, "memory/limits/message_queue/max_size_kb", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater"));
buffer_size *= 1024;
buffer = memnew_arr(uint8_t, buffer_size);
}
diff --git a/core/method_bind.h b/core/method_bind.h
index 726ce512f8..a1ab4e58fc 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -405,4 +405,4 @@ class __UnexistingClass;
#include "method_bind.gen.inc"
-#endif
+#endif // METHOD_BIND_H
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index d09242e2f1..7ae0a788bd 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -118,6 +118,9 @@ MAKE_PTRARG(String);
MAKE_PTRARG(Vector2);
MAKE_PTRARG(Rect2);
MAKE_PTRARG_BY_REFERENCE(Vector3);
+MAKE_PTRARG(Vector2i);
+MAKE_PTRARG(Rect2i);
+MAKE_PTRARG_BY_REFERENCE(Vector3i);
MAKE_PTRARG(Transform2D);
MAKE_PTRARG_BY_REFERENCE(Plane);
MAKE_PTRARG(Quat);
diff --git a/core/node_path.h b/core/node_path.h
index 05b6d844ff..76de36cd9f 100644
--- a/core/node_path.h
+++ b/core/node_path.h
@@ -97,4 +97,4 @@ public:
~NodePath();
};
-#endif
+#endif // NODE_PATH_H
diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h
index 7ceba26be8..447b0db0eb 100644
--- a/core/oa_hash_map.h
+++ b/core/oa_hash_map.h
@@ -369,4 +369,4 @@ public:
}
};
-#endif
+#endif // OA_HASH_MAP_H
diff --git a/core/object.cpp b/core/object.cpp
index 140ee811fe..188c0ee5c2 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1324,6 +1324,25 @@ Array Object::_get_incoming_connections() const {
return ret;
}
+bool Object::has_signal(const StringName &p_name) const {
+ if (!script.is_null()) {
+ Ref<Script> scr = script;
+ if (scr.is_valid() && scr->has_script_signal(p_name)) {
+ return true;
+ }
+ }
+
+ if (ClassDB::has_signal(get_class_name(), p_name)) {
+ return true;
+ }
+
+ if (_has_user_signal(p_name)) {
+ return true;
+ }
+
+ return false;
+}
+
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
if (!script.is_null()) {
@@ -1696,6 +1715,7 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_method", "method"), &Object::has_method);
+ ClassDB::bind_method(D_METHOD("has_signal", "signal"), &Object::has_signal);
ClassDB::bind_method(D_METHOD("get_signal_list"), &Object::_get_signal_list);
ClassDB::bind_method(D_METHOD("get_signal_connection_list", "signal"), &Object::_get_signal_connection_list);
ClassDB::bind_method(D_METHOD("get_incoming_connections"), &Object::_get_incoming_connections);
diff --git a/core/object.h b/core/object.h
index 59d3f06cfe..0826686fb3 100644
--- a/core/object.h
+++ b/core/object.h
@@ -694,6 +694,7 @@ public:
void add_user_signal(const MethodInfo &p_signal);
Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST);
Error emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount);
+ bool has_signal(const StringName &p_name) const;
void get_signal_list(List<MethodInfo> *p_signals) const;
void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const;
void get_all_signal_connections(List<Connection> *p_connections) const;
@@ -816,4 +817,4 @@ public:
//needed by macros
#include "core/class_db.h"
-#endif
+#endif // OBJECT_H
diff --git a/core/os/copymem.h b/core/os/copymem.h
index 1d6631ddb8..04ea3caeff 100644
--- a/core/os/copymem.h
+++ b/core/os/copymem.h
@@ -47,4 +47,4 @@
#endif
-#endif
+#endif // COPYMEM_H
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index aac6c67f0a..059f7aad2f 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -149,4 +149,4 @@ struct DirAccessRef {
}
};
-#endif
+#endif // DIR_ACCESS_H
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 36a947c691..4a82637ecc 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -196,4 +196,4 @@ struct FileAccessRef {
}
};
-#endif
+#endif // FILE_ACCESS_H
diff --git a/core/os/input.cpp b/core/os/input.cpp
deleted file mode 100644
index 1768b851df..0000000000
--- a/core/os/input.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*************************************************************************/
-/* input.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "input.h"
-
-#include "core/input_map.h"
-#include "core/os/os.h"
-#include "core/project_settings.h"
-
-#ifdef TOOLS_ENABLED
-#include "editor/editor_settings.h"
-#endif
-
-Input *Input::singleton = NULL;
-
-Input *Input::get_singleton() {
-
- return singleton;
-}
-
-void Input::set_mouse_mode(MouseMode p_mode) {
- ERR_FAIL_INDEX((int)p_mode, 4);
- OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
-}
-
-Input::MouseMode Input::get_mouse_mode() const {
-
- return (MouseMode)OS::get_singleton()->get_mouse_mode();
-}
-
-void Input::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed);
- ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
- ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
- ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &Input::is_action_pressed);
- ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &Input::is_action_just_pressed);
- ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released);
- ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &Input::get_action_strength);
- ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping);
- ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed);
- ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known);
- ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis);
- ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name);
- ClassDB::bind_method(D_METHOD("get_joy_guid", "device"), &Input::get_joy_guid);
- ClassDB::bind_method(D_METHOD("get_connected_joypads"), &Input::get_connected_joypads);
- ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
- ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
- ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
- ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
- ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
- ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
- ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
- ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500));
- ClassDB::bind_method(D_METHOD("get_gravity"), &Input::get_gravity);
- ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer);
- ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer);
- ClassDB::bind_method(D_METHOD("get_gyroscope"), &Input::get_gyroscope);
- //ClassDB::bind_method(D_METHOD("get_mouse_position"),&Input::get_mouse_position); - this is not the function you want
- ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed);
- ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask);
- ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode);
- ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode);
- ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
- ClassDB::bind_method(D_METHOD("action_press", "action", "strength"), &Input::action_press, DEFVAL(1.f));
- ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
- ClassDB::bind_method(D_METHOD("set_default_cursor_shape", "shape"), &Input::set_default_cursor_shape, DEFVAL(CURSOR_ARROW));
- ClassDB::bind_method(D_METHOD("get_current_cursor_shape"), &Input::get_current_cursor_shape);
- ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
- ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
- ClassDB::bind_method(D_METHOD("set_use_accumulated_input", "enable"), &Input::set_use_accumulated_input);
-
- BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
- BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
- BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
- BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
-
- BIND_ENUM_CONSTANT(CURSOR_ARROW);
- BIND_ENUM_CONSTANT(CURSOR_IBEAM);
- BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
- BIND_ENUM_CONSTANT(CURSOR_CROSS);
- BIND_ENUM_CONSTANT(CURSOR_WAIT);
- BIND_ENUM_CONSTANT(CURSOR_BUSY);
- BIND_ENUM_CONSTANT(CURSOR_DRAG);
- BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
- BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
- BIND_ENUM_CONSTANT(CURSOR_VSIZE);
- BIND_ENUM_CONSTANT(CURSOR_HSIZE);
- BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
- BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
- BIND_ENUM_CONSTANT(CURSOR_MOVE);
- BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
- BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
- BIND_ENUM_CONSTANT(CURSOR_HELP);
-
- ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "device"), PropertyInfo(Variant::BOOL, "connected")));
-}
-
-void Input::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-#ifdef TOOLS_ENABLED
-
- const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
-
- String pf = p_function;
- if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
-
- List<PropertyInfo> pinfo;
- ProjectSettings::get_singleton()->get_property_list(&pinfo);
-
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
- if (!pi.name.begins_with("input/"))
- continue;
-
- String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- r_options->push_back(quote_style + name + quote_style);
- }
- }
-#endif
-}
-
-Input::Input() {
-
- singleton = this;
-}
-
-//////////////////////////////////////////////////////////
diff --git a/core/os/input.h b/core/os/input.h
deleted file mode 100644
index 55e0511080..0000000000
--- a/core/os/input.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*************************************************************************/
-/* input.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef INPUT_H
-#define INPUT_H
-
-#include "core/object.h"
-#include "core/os/main_loop.h"
-#include "core/os/thread_safe.h"
-
-class Input : public Object {
-
- GDCLASS(Input, Object);
-
- static Input *singleton;
-
-protected:
- static void _bind_methods();
-
-public:
- enum MouseMode {
- MOUSE_MODE_VISIBLE,
- MOUSE_MODE_HIDDEN,
- MOUSE_MODE_CAPTURED,
- MOUSE_MODE_CONFINED
- };
-
-#undef CursorShape
- enum CursorShape {
- CURSOR_ARROW,
- CURSOR_IBEAM,
- CURSOR_POINTING_HAND,
- CURSOR_CROSS,
- CURSOR_WAIT,
- CURSOR_BUSY,
- CURSOR_DRAG,
- CURSOR_CAN_DROP,
- CURSOR_FORBIDDEN,
- CURSOR_VSIZE,
- CURSOR_HSIZE,
- CURSOR_BDIAGSIZE,
- CURSOR_FDIAGSIZE,
- CURSOR_MOVE,
- CURSOR_VSPLIT,
- CURSOR_HSPLIT,
- CURSOR_HELP,
- CURSOR_MAX
- };
-
- void set_mouse_mode(MouseMode p_mode);
- MouseMode get_mouse_mode() const;
-
- static Input *get_singleton();
-
- virtual bool is_key_pressed(int p_keycode) const = 0;
- virtual bool is_mouse_button_pressed(int p_button) const = 0;
- virtual bool is_joy_button_pressed(int p_device, int p_button) const = 0;
- virtual bool is_action_pressed(const StringName &p_action) const = 0;
- virtual bool is_action_just_pressed(const StringName &p_action) const = 0;
- virtual bool is_action_just_released(const StringName &p_action) const = 0;
- virtual float get_action_strength(const StringName &p_action) const = 0;
-
- virtual float get_joy_axis(int p_device, int p_axis) const = 0;
- virtual String get_joy_name(int p_idx) = 0;
- virtual Array get_connected_joypads() = 0;
- virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) = 0;
- virtual void add_joy_mapping(String p_mapping, bool p_update_existing = false) = 0;
- virtual void remove_joy_mapping(String p_guid) = 0;
- virtual bool is_joy_known(int p_device) = 0;
- virtual String get_joy_guid(int p_device) const = 0;
- virtual Vector2 get_joy_vibration_strength(int p_device) = 0;
- virtual float get_joy_vibration_duration(int p_device) = 0;
- virtual uint64_t get_joy_vibration_timestamp(int p_device) = 0;
- virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0) = 0;
- virtual void stop_joy_vibration(int p_device) = 0;
- virtual void vibrate_handheld(int p_duration_ms = 500) = 0;
-
- virtual Point2 get_mouse_position() const = 0;
- virtual Point2 get_last_mouse_speed() const = 0;
- virtual int get_mouse_button_mask() const = 0;
-
- virtual void warp_mouse_position(const Vector2 &p_to) = 0;
- virtual Point2i warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) = 0;
-
- virtual Vector3 get_gravity() const = 0;
- virtual Vector3 get_accelerometer() const = 0;
- virtual Vector3 get_magnetometer() const = 0;
- virtual Vector3 get_gyroscope() const = 0;
-
- virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0;
- virtual void action_release(const StringName &p_action) = 0;
-
- void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
-
- virtual bool is_emulating_touch_from_mouse() const = 0;
- virtual bool is_emulating_mouse_from_touch() const = 0;
-
- virtual CursorShape get_default_cursor_shape() const = 0;
- virtual void set_default_cursor_shape(CursorShape p_shape) = 0;
- virtual CursorShape get_current_cursor_shape() const = 0;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) = 0;
-
- virtual String get_joy_button_string(int p_button) = 0;
- virtual String get_joy_axis_string(int p_axis) = 0;
- virtual int get_joy_button_index_from_string(String p_button) = 0;
- virtual int get_joy_axis_index_from_string(String p_axis) = 0;
-
- virtual void parse_input_event(const Ref<InputEvent> &p_event) = 0;
- virtual void accumulate_input_event(const Ref<InputEvent> &p_event) = 0;
- virtual void flush_accumulated_events() = 0;
- virtual void set_use_accumulated_input(bool p_enable) = 0;
-
- Input();
-};
-
-VARIANT_ENUM_CAST(Input::MouseMode);
-VARIANT_ENUM_CAST(Input::CursorShape);
-
-#endif // INPUT_H
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index bac32e01dd..5d11e6a378 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -325,4 +325,4 @@ int keycode_get_count();
int keycode_get_value_by_index(int p_index);
const char *keycode_get_name_by_index(int p_index);
-#endif
+#endif // KEYBOARD_H
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index ab43ce4af7..0d1a080682 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -34,30 +34,16 @@
void MainLoop::_bind_methods() {
- ClassDB::bind_method(D_METHOD("input_event", "event"), &MainLoop::input_event);
- ClassDB::bind_method(D_METHOD("input_text", "text"), &MainLoop::input_text);
ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
ClassDB::bind_method(D_METHOD("idle", "delta"), &MainLoop::idle);
ClassDB::bind_method(D_METHOD("finish"), &MainLoop::finish);
- BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
- BIND_VMETHOD(MethodInfo("_input_text", PropertyInfo(Variant::STRING, "text")));
BIND_VMETHOD(MethodInfo("_initialize"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::FLOAT, "delta")));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta")));
- BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "from_screen")));
BIND_VMETHOD(MethodInfo("_finalize"));
- BIND_VMETHOD(MethodInfo("_global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
-
- BIND_CONSTANT(NOTIFICATION_WM_MOUSE_ENTER);
- BIND_CONSTANT(NOTIFICATION_WM_MOUSE_EXIT);
- BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN);
- BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT);
- BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST);
- BIND_CONSTANT(NOTIFICATION_WM_GO_BACK_REQUEST);
- BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST);
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
@@ -80,18 +66,6 @@ MainLoop::MainLoop() {
MainLoop::~MainLoop() {
}
-void MainLoop::input_text(const String &p_text) {
-
- if (get_script_instance())
- get_script_instance()->call("_input_text", p_text);
-}
-
-void MainLoop::input_event(const Ref<InputEvent> &p_event) {
-
- if (get_script_instance())
- get_script_instance()->call("_input_event", p_event);
-}
-
void MainLoop::init() {
if (init_script.is_valid())
@@ -115,18 +89,6 @@ bool MainLoop::idle(float p_time) {
return false;
}
-void MainLoop::drop_files(const Vector<String> &p_files, int p_from_screen) {
-
- if (get_script_instance())
- get_script_instance()->call("_drop_files", p_files, p_from_screen);
-}
-
-void MainLoop::global_menu_action(const Variant &p_id, const Variant &p_meta) {
-
- if (get_script_instance())
- get_script_instance()->call("_global_menu_action", p_id, p_meta);
-}
-
void MainLoop::finish() {
if (get_script_instance()) {
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index b1120aee8a..8f6c8c91b1 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -31,7 +31,7 @@
#ifndef MAIN_LOOP_H
#define MAIN_LOOP_H
-#include "core/os/input_event.h"
+#include "core/input/input_event.h"
#include "core/reference.h"
#include "core/script_language.h"
@@ -48,37 +48,24 @@ protected:
public:
enum {
//make sure these are replicated in Node
- NOTIFICATION_WM_MOUSE_ENTER = 1002,
- NOTIFICATION_WM_MOUSE_EXIT = 1003,
- NOTIFICATION_WM_FOCUS_IN = 1004,
- NOTIFICATION_WM_FOCUS_OUT = 1005,
- NOTIFICATION_WM_QUIT_REQUEST = 1006,
- NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
- NOTIFICATION_WM_UNFOCUS_REQUEST = 1008,
- NOTIFICATION_OS_MEMORY_WARNING = 1009,
- NOTIFICATION_TRANSLATION_CHANGED = 1010,
- NOTIFICATION_WM_ABOUT = 1011,
- NOTIFICATION_CRASH = 1012,
- NOTIFICATION_OS_IME_UPDATE = 1013,
- NOTIFICATION_APP_RESUMED = 1014,
- NOTIFICATION_APP_PAUSED = 1015,
+ NOTIFICATION_OS_MEMORY_WARNING = 2009,
+ NOTIFICATION_TRANSLATION_CHANGED = 2010,
+ NOTIFICATION_WM_ABOUT = 2011,
+ NOTIFICATION_CRASH = 2012,
+ NOTIFICATION_OS_IME_UPDATE = 2013,
+ NOTIFICATION_APP_RESUMED = 2014,
+ NOTIFICATION_APP_PAUSED = 2015,
};
- virtual void input_event(const Ref<InputEvent> &p_event);
- virtual void input_text(const String &p_text);
-
virtual void init();
virtual bool iteration(float p_time);
virtual bool idle(float p_time);
virtual void finish();
- virtual void drop_files(const Vector<String> &p_files, int p_from_screen = 0);
- virtual void global_menu_action(const Variant &p_id, const Variant &p_meta);
-
void set_init_script(const Ref<Script> &p_init_script);
MainLoop();
virtual ~MainLoop();
};
-#endif
+#endif // MAIN_LOOP_H
diff --git a/core/os/memory.h b/core/os/memory.h
index 207149b57e..dcaedd92ba 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -206,4 +206,4 @@ struct _GlobalNilClass {
static _GlobalNil _nil;
};
-#endif
+#endif // MEMORY_H
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index 6ebec50ff0..c23ade3088 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -30,8 +30,8 @@
#include "midi_driver.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
-#include "main/input_default.h"
uint8_t MIDIDriver::last_received_message = 0x00;
MIDIDriver *MIDIDriver::singleton = NULL;
@@ -117,7 +117,7 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
break;
}
- InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
+ InputFilter *id = InputFilter::get_singleton();
id->parse_input_event(event);
}
diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h
index 4f53feb43e..b7377a8a40 100644
--- a/core/os/midi_driver.h
+++ b/core/os/midi_driver.h
@@ -58,4 +58,4 @@ public:
virtual ~MIDIDriver() {}
};
-#endif
+#endif // MIDI_DRIVER_H
diff --git a/core/os/mutex.h b/core/os/mutex.h
index b44b1994de..526549dd93 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -105,4 +105,4 @@ using BinaryMutex = MutexImpl<FakeMutex>; // Non-recursive, handle with care
#endif // !NO_THREADS
-#endif
+#endif // MUTEX_H
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 9a65d537ac..66ab3bbd8c 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -30,9 +30,9 @@
#include "os.h"
+#include "core/input/input_filter.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
-#include "core/os/input.h"
#include "core/os/midi_driver.h"
#include "core/project_settings.h"
#include "core/version_generated.gen.h"
@@ -139,14 +139,6 @@ void OS::printerr(const char *p_format, ...) {
va_end(argp);
};
-void OS::set_keep_screen_on(bool p_enabled) {
- _keep_screen_on = p_enabled;
-}
-
-bool OS::is_keep_screen_on() const {
- return _keep_screen_on;
-}
-
void OS::set_low_processor_usage_mode(bool p_enabled) {
low_processor_usage_mode = p_enabled;
@@ -167,15 +159,6 @@ int OS::get_low_processor_usage_mode_sleep_usec() const {
return low_processor_usage_mode_sleep_usec;
}
-void OS::set_clipboard(const String &p_text) {
-
- _local_clipboard = p_text;
-}
-String OS::get_clipboard() const {
-
- return _local_clipboard;
-}
-
String OS::get_executable_path() const {
return _execpath;
@@ -216,31 +199,6 @@ static void _OS_printres(Object *p_obj) {
print_line(str);
}
-bool OS::has_virtual_keyboard() const {
-
- return false;
-}
-
-void OS::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length) {
-}
-
-void OS::hide_virtual_keyboard() {
-}
-
-int OS::get_virtual_keyboard_height() const {
- return 0;
-}
-
-void OS::set_cursor_shape(CursorShape p_shape) {
-}
-
-OS::CursorShape OS::get_cursor_shape() const {
- return CURSOR_ARROW;
-}
-
-void OS::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
-}
-
void OS::print_all_resources(String p_to_file) {
ERR_FAIL_COND(p_to_file != "" && _OSPRF);
@@ -372,45 +330,6 @@ Error OS::shell_open(String p_uri) {
};
// implement these with the canvas?
-Error OS::dialog_show(String p_title, String p_description, Vector<String> p_buttons, Object *p_obj, String p_callback) {
-
- while (true) {
-
- print("%ls\n--------\n%ls\n", p_title.c_str(), p_description.c_str());
- for (int i = 0; i < p_buttons.size(); i++) {
- if (i > 0) print(", ");
- print("%i=%ls", i + 1, p_buttons[i].c_str());
- };
- print("\n");
- String res = get_stdin_string().strip_edges();
- if (!res.is_numeric())
- continue;
- int n = res.to_int();
- if (n < 0 || n >= p_buttons.size())
- continue;
- if (p_obj && p_callback != "")
- p_obj->call_deferred(p_callback, n);
- break;
- };
- return OK;
-};
-
-Error OS::dialog_input_text(String p_title, String p_description, String p_partial, Object *p_obj, String p_callback) {
-
- ERR_FAIL_COND_V(!p_obj, FAILED);
- ERR_FAIL_COND_V(p_callback == "", FAILED);
- print("%ls\n---------\n%ls\n[%ls]:\n", p_title.c_str(), p_description.c_str(), p_partial.c_str());
-
- String res = get_stdin_string().strip_edges();
- bool success = true;
- if (res == "") {
- res = p_partial;
- };
-
- p_obj->call_deferred(p_callback, success, res);
-
- return OK;
-};
uint64_t OS::get_static_memory_usage() const {
@@ -427,12 +346,6 @@ Error OS::set_cwd(const String &p_cwd) {
return ERR_CANT_OPEN;
}
-bool OS::has_touchscreen_ui_hint() const {
-
- //return false;
- return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse();
-}
-
uint64_t OS::get_free_static_memory() const {
return Memory::get_mem_available();
@@ -441,17 +354,7 @@ uint64_t OS::get_free_static_memory() const {
void OS::yield() {
}
-void OS::set_screen_orientation(ScreenOrientation p_orientation) {
-
- _orientation = p_orientation;
-}
-
-OS::ScreenOrientation OS::get_screen_orientation() const {
-
- return (OS::ScreenOrientation)_orientation;
-}
-
-void OS::_ensure_user_data_dir() {
+void OS::ensure_user_data_dir() {
String dd = get_user_data_dir();
DirAccess *da = DirAccess::open(dd);
@@ -467,12 +370,6 @@ void OS::_ensure_user_data_dir() {
memdelete(da);
}
-void OS::set_native_icon(const String &p_filename) {
-}
-
-void OS::set_icon(const Ref<Image> &p_icon) {
-}
-
String OS::get_model_name() const {
return "GenericDevice";
@@ -484,15 +381,6 @@ void OS::set_cmdline(const char *p_execpath, const List<String> &p_args) {
_cmdline = p_args;
};
-void OS::release_rendering_thread() {
-}
-
-void OS::make_rendering_thread() {
-}
-
-void OS::swap_buffers() {
-}
-
String OS::get_unique_id() const {
ERR_FAIL_V("");
@@ -503,31 +391,6 @@ int OS::get_processor_count() const {
return 1;
}
-Error OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
-
- return FAILED;
-};
-
-bool OS::native_video_is_playing() const {
-
- return false;
-};
-
-void OS::native_video_pause(){
-
-};
-
-void OS::native_video_unpause(){
-
-};
-
-void OS::native_video_stop(){
-
-};
-
-void OS::set_mouse_mode(MouseMode p_mode) {
-}
-
bool OS::can_use_threads() const {
#ifdef NO_THREADS
@@ -537,51 +400,6 @@ bool OS::can_use_threads() const {
#endif
}
-OS::MouseMode OS::get_mouse_mode() const {
-
- return MOUSE_MODE_VISIBLE;
-}
-
-OS::LatinKeyboardVariant OS::get_latin_keyboard_variant() const {
-
- return LATIN_KEYBOARD_QWERTY;
-}
-
-bool OS::is_joy_known(int p_device) {
- return true;
-}
-
-String OS::get_joy_guid(int p_device) const {
- return "Default Joypad";
-}
-
-void OS::set_context(int p_context) {
-}
-
-OS::SwitchVSyncCallbackInThread OS::switch_vsync_function = NULL;
-
-void OS::set_use_vsync(bool p_enable) {
- _use_vsync = p_enable;
- if (switch_vsync_function) { //if a function was set, use function
- switch_vsync_function(p_enable);
- } else { //otherwise just call here
- _set_use_vsync(p_enable);
- }
-}
-
-bool OS::is_vsync_enabled() const {
-
- return _use_vsync;
-}
-
-void OS::set_vsync_via_compositor(bool p_enable) {
- _vsync_via_compositor = p_enable;
-}
-
-bool OS::is_vsync_via_compositor_enabled() const {
- return _vsync_via_compositor;
-}
-
void OS::set_has_server_feature_callback(HasServerFeatureCallback p_callback) {
has_server_feature_callback = p_callback;
@@ -653,48 +471,6 @@ bool OS::has_feature(const String &p_feature) {
return false;
}
-void OS::center_window() {
-
- if (is_window_fullscreen()) return;
-
- Point2 sp = get_screen_position(get_current_screen());
- Size2 scr = get_screen_size(get_current_screen());
- Size2 wnd = get_real_window_size();
-
- int x = sp.width + (scr.width - wnd.width) / 2;
- int y = sp.height + (scr.height - wnd.height) / 2;
-
- set_window_position(Vector2(x, y));
-}
-
-int OS::get_video_driver_count() const {
-
- return 2;
-}
-
-const char *OS::get_video_driver_name(int p_driver) const {
-
- switch (p_driver) {
- case VIDEO_DRIVER_GLES2:
- return "GLES2";
- case VIDEO_DRIVER_VULKAN:
- default:
- return "Vulkan";
- }
-}
-
-int OS::get_audio_driver_count() const {
-
- return AudioDriverManager::get_driver_count();
-}
-
-const char *OS::get_audio_driver_name(int p_driver) const {
-
- AudioDriver *driver = AudioDriverManager::get_driver(p_driver);
- ERR_FAIL_COND_V_MSG(!driver, "", "Cannot get audio driver at index '" + itos(p_driver) + "'.");
- return AudioDriverManager::get_driver(p_driver)->get_name();
-}
-
void OS::set_restart_on_exit(bool p_restart, const List<String> &p_restart_arguments) {
restart_on_exit = p_restart;
restart_commandline = p_restart_arguments;
@@ -740,7 +516,6 @@ OS::OS() {
_verbose_stdout = false;
_no_window = false;
_exit_code = 0;
- _orientation = SCREEN_LANDSCAPE;
_render_thread_mode = RENDER_THREAD_SAFE;
diff --git a/core/os/os.h b/core/os/os.h
index 1d3619b1e6..a31b1c1f4b 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -82,31 +82,6 @@ public:
RENDER_THREAD_SAFE,
RENDER_SEPARATE_THREAD
};
- struct VideoMode {
-
- int width, height;
- bool fullscreen;
- bool resizable;
- bool borderless_window;
- bool maximized;
- bool always_on_top;
- bool use_vsync;
- bool vsync_via_compositor;
- bool layered;
- float get_aspect() const { return (float)width / (float)height; }
- VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_always_on_top = false, bool p_use_vsync = false, bool p_vsync_via_compositor = false) {
- width = p_width;
- height = p_height;
- fullscreen = p_fullscreen;
- resizable = p_resizable;
- borderless_window = p_borderless_window;
- maximized = p_maximized;
- always_on_top = p_always_on_top;
- use_vsync = p_use_vsync;
- vsync_via_compositor = p_vsync_via_compositor;
- layered = false;
- }
- };
protected:
friend class Main;
@@ -117,8 +92,8 @@ protected:
// functions used by main to initialize/deinitialize the OS
void add_logger(Logger *p_logger);
- virtual void initialize_core() = 0;
- virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0;
+ virtual void initialize() = 0;
+ virtual void initialize_joypads() = 0;
virtual void set_main_loop(MainLoop *p_main_loop) = 0;
virtual void delete_main_loop() = 0;
@@ -128,7 +103,6 @@ protected:
virtual void set_cmdline(const char *p_execpath, const List<String> &p_args);
- void _ensure_user_data_dir();
virtual bool _check_internal_feature_support(const String &p_feature) = 0;
public:
@@ -136,121 +110,20 @@ public:
static OS *get_singleton();
- virtual void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta){};
- virtual void global_menu_add_separator(const String &p_menu){};
- virtual void global_menu_remove_item(const String &p_menu, int p_idx){};
- virtual void global_menu_clear(const String &p_menu){};
-
void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type = Logger::ERR_ERROR);
void print(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
void printerr(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
- virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0;
virtual String get_stdin_string(bool p_block = true) = 0;
- enum MouseMode {
- MOUSE_MODE_VISIBLE,
- MOUSE_MODE_HIDDEN,
- MOUSE_MODE_CAPTURED,
- MOUSE_MODE_CONFINED
- };
-
- virtual void set_mouse_mode(MouseMode p_mode);
- virtual MouseMode get_mouse_mode() const;
-
- virtual void warp_mouse_position(const Point2 &p_to) {}
- virtual Point2 get_mouse_position() const = 0;
- virtual int get_mouse_button_state() const = 0;
- virtual void set_window_title(const String &p_title) = 0;
-
- virtual void set_clipboard(const String &p_text);
- virtual String get_clipboard() const;
-
- virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0) = 0;
- virtual VideoMode get_video_mode(int p_screen = 0) const = 0;
- virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const = 0;
-
- enum VideoDriver {
- VIDEO_DRIVER_VULKAN,
- VIDEO_DRIVER_GLES2,
- VIDEO_DRIVER_MAX,
- };
-
- virtual int get_video_driver_count() const;
- virtual const char *get_video_driver_name(int p_driver) const;
- virtual int get_current_video_driver() const = 0;
-
- virtual int get_audio_driver_count() const;
- virtual const char *get_audio_driver_name(int p_driver) const;
-
virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
- virtual int get_screen_count() const { return 1; }
- virtual int get_current_screen() const { return 0; }
- virtual void set_current_screen(int p_screen) {}
- virtual Point2 get_screen_position(int p_screen = -1) const { return Point2(); }
- virtual Size2 get_screen_size(int p_screen = -1) const { return get_window_size(); }
- virtual int get_screen_dpi(int p_screen = -1) const { return 72; }
- virtual Point2 get_window_position() const { return Vector2(); }
- virtual void set_window_position(const Point2 &p_position) {}
- virtual Size2 get_max_window_size() const { return Size2(); };
- virtual Size2 get_min_window_size() const { return Size2(); };
- virtual Size2 get_window_size() const = 0;
- virtual Size2 get_real_window_size() const { return get_window_size(); }
- virtual void set_min_window_size(const Size2 p_size) {}
- virtual void set_max_window_size(const Size2 p_size) {}
- virtual void set_window_size(const Size2 p_size) {}
- virtual void set_window_fullscreen(bool p_enabled) {}
- virtual bool is_window_fullscreen() const { return true; }
- virtual void set_window_resizable(bool p_enabled) {}
- virtual bool is_window_resizable() const { return false; }
- virtual void set_window_minimized(bool p_enabled) {}
- virtual bool is_window_minimized() const { return false; }
- virtual void set_window_maximized(bool p_enabled) {}
- virtual bool is_window_maximized() const { return true; }
- virtual void set_window_always_on_top(bool p_enabled) {}
- virtual bool is_window_always_on_top() const { return false; }
- virtual bool is_window_focused() const { return true; }
- virtual void set_console_visible(bool p_enabled) {}
- virtual bool is_console_visible() const { return false; }
- virtual void request_attention() {}
- virtual void center_window();
-
- // Returns window area free of hardware controls and other obstacles.
- // The application should use this to determine where to place UI elements.
- //
- // Keep in mind the area returned is in window coordinates rather than
- // viewport coordinates - you should perform the conversion on your own.
- //
- // The maximum size of the area is Rect2(0, 0, window_size.width, window_size.height).
- virtual Rect2 get_window_safe_area() const {
- Size2 window_size = get_window_size();
- return Rect2(0, 0, window_size.width, window_size.height);
- }
-
- virtual void set_borderless_window(bool p_borderless) {}
- virtual bool get_borderless_window() { return 0; }
-
- virtual bool get_window_per_pixel_transparency_enabled() const { return false; }
- virtual void set_window_per_pixel_transparency_enabled(bool p_enabled) {}
-
- virtual uint8_t *get_layered_buffer_data() { return NULL; }
- virtual Size2 get_layered_buffer_size() { return Size2(0, 0); }
- virtual void swap_layered_buffer() {}
-
- virtual void set_ime_active(const bool p_active) {}
- virtual void set_ime_position(const Point2 &p_pos) {}
- virtual Point2 get_ime_selection() const { return Point2(); }
- virtual String get_ime_text() const { return String(); }
-
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) { return ERR_UNAVAILABLE; }
virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; }
virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; }
- virtual void set_keep_screen_on(bool p_enabled);
- virtual bool is_keep_screen_on() const;
virtual void set_low_processor_usage_mode(bool p_enabled);
virtual bool is_in_low_processor_usage_mode() const;
virtual void set_low_processor_usage_mode_sleep_usec(int p_usec);
@@ -273,6 +146,11 @@ public:
virtual List<String> get_cmdline_args() const { return _cmdline; }
virtual String get_model_name() const;
+ bool is_layered_allowed() const { return _allow_layered; }
+ bool is_hidpi_allowed() const { return _allow_hidpi; }
+
+ void ensure_user_data_dir();
+
virtual MainLoop *get_main_loop() const = 0;
virtual void yield();
@@ -338,8 +216,6 @@ public:
uint32_t get_ticks_msec() const;
uint64_t get_splash_tick_msec() const;
- virtual bool can_draw() const = 0;
-
virtual bool is_userfs_persistent() const { return true; }
bool is_stdout_verbose() const;
@@ -348,39 +224,6 @@ public:
virtual bool is_disable_crash_handler() const { return false; }
virtual void initialize_debugging() {}
- enum CursorShape {
- CURSOR_ARROW,
- CURSOR_IBEAM,
- CURSOR_POINTING_HAND,
- CURSOR_CROSS,
- CURSOR_WAIT,
- CURSOR_BUSY,
- CURSOR_DRAG,
- CURSOR_CAN_DROP,
- CURSOR_FORBIDDEN,
- CURSOR_VSIZE,
- CURSOR_HSIZE,
- CURSOR_BDIAGSIZE,
- CURSOR_FDIAGSIZE,
- CURSOR_MOVE,
- CURSOR_VSPLIT,
- CURSOR_HSPLIT,
- CURSOR_HELP,
- CURSOR_MAX
- };
-
- virtual bool has_virtual_keyboard() const;
- virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1);
- virtual void hide_virtual_keyboard();
-
- // returns height of the currently shown virtual keyboard (0 if keyboard is hidden)
- virtual int get_virtual_keyboard_height() const;
-
- virtual void set_cursor_shape(CursorShape p_shape);
- virtual CursorShape get_cursor_shape() const;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
-
- virtual bool get_swap_ok_cancel() { return false; }
virtual void dump_memory_to_file(const char *p_file);
virtual void dump_resources_to_file(const char *p_file);
virtual void print_resources_in_use(bool p_short = false);
@@ -423,34 +266,8 @@ public:
virtual void set_no_window_mode(bool p_enable);
virtual bool is_no_window_mode_enabled() const;
- virtual bool has_touchscreen_ui_hint() const;
-
- enum ScreenOrientation {
-
- SCREEN_LANDSCAPE,
- SCREEN_PORTRAIT,
- SCREEN_REVERSE_LANDSCAPE,
- SCREEN_REVERSE_PORTRAIT,
- SCREEN_SENSOR_LANDSCAPE,
- SCREEN_SENSOR_PORTRAIT,
- SCREEN_SENSOR,
- };
-
- virtual void set_screen_orientation(ScreenOrientation p_orientation);
- ScreenOrientation get_screen_orientation() const;
-
- virtual void enable_for_stealing_focus(ProcessID pid) {}
- virtual void move_window_to_foreground() {}
-
virtual void debug_break();
- virtual void release_rendering_thread();
- virtual void make_rendering_thread();
- virtual void swap_buffers();
-
- virtual void set_native_icon(const String &p_filename);
- virtual void set_icon(const Ref<Image> &p_icon);
-
virtual int get_exit_code() const;
virtual void set_exit_code(int p_code);
@@ -458,62 +275,12 @@ public:
virtual String get_unique_id() const;
- virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
- virtual bool native_video_is_playing() const;
- virtual void native_video_pause();
- virtual void native_video_unpause();
- virtual void native_video_stop();
-
virtual bool can_use_threads() const;
- virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, Object *p_obj, String p_callback);
- virtual Error dialog_input_text(String p_title, String p_description, String p_partial, Object *p_obj, String p_callback);
-
- enum LatinKeyboardVariant {
- LATIN_KEYBOARD_QWERTY,
- LATIN_KEYBOARD_QWERTZ,
- LATIN_KEYBOARD_AZERTY,
- LATIN_KEYBOARD_QZERTY,
- LATIN_KEYBOARD_DVORAK,
- LATIN_KEYBOARD_NEO,
- LATIN_KEYBOARD_COLEMAK,
- };
-
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
-
- virtual bool is_joy_known(int p_device);
- virtual String get_joy_guid(int p_device) const;
-
- enum EngineContext {
- CONTEXT_EDITOR,
- CONTEXT_PROJECTMAN,
- CONTEXT_ENGINE,
- };
-
- virtual void set_context(int p_context);
-
- //amazing hack because OpenGL needs this to be set on a separate thread..
- //also core can't access servers, so a callback must be used
- typedef void (*SwitchVSyncCallbackInThread)(bool);
-
- static SwitchVSyncCallbackInThread switch_vsync_function;
- void set_use_vsync(bool p_enable);
- bool is_vsync_enabled() const;
-
- //real, actual overridable function to switch vsync, which needs to be called from graphics thread if needed
- virtual void _set_use_vsync(bool p_enable) {}
-
- void set_vsync_via_compositor(bool p_enable);
- bool is_vsync_via_compositor_enabled() const;
-
- virtual void force_process_input(){};
bool has_feature(const String &p_feature);
void set_has_server_feature_callback(HasServerFeatureCallback p_callback);
- bool is_layered_allowed() const { return _allow_layered; }
- bool is_hidpi_allowed() const { return _allow_hidpi; }
-
void set_restart_on_exit(bool p_restart, const List<String> &p_restart_arguments);
bool is_restart_on_exit_set() const;
List<String> get_restart_on_exit_arguments() const;
@@ -527,4 +294,4 @@ public:
virtual ~OS();
};
-#endif
+#endif // OS_H
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 21648b6cbc..64dfbef20c 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RWLOCK_H
-#define RWLOCK_H
+#ifndef RW_LOCK_H
+#define RW_LOCK_H
#include "core/error_list.h"
@@ -79,4 +79,4 @@ public:
}
};
-#endif // RWLOCK_H
+#endif // RW_LOCK_H
diff --git a/core/os/semaphore.h b/core/os/semaphore.h
index 6f194d4887..3d9d1ab984 100644
--- a/core/os/semaphore.h
+++ b/core/os/semaphore.h
@@ -80,4 +80,4 @@ public:
#endif
-#endif
+#endif // SEMAPHORE_H
diff --git a/core/os/thread.h b/core/os/thread.h
index 0803fd1190..76d296bcf7 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -77,4 +77,4 @@ public:
virtual ~Thread();
};
-#endif
+#endif // THREAD_H
diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h
index da8188f983..066ee498ac 100644
--- a/core/os/thread_dummy.h
+++ b/core/os/thread_dummy.h
@@ -61,4 +61,4 @@ public:
static void make_default();
};
-#endif
+#endif // THREAD_DUMMY_H
diff --git a/core/os/thread_safe.h b/core/os/thread_safe.h
index 0221edf491..670ee8b125 100644
--- a/core/os/thread_safe.h
+++ b/core/os/thread_safe.h
@@ -38,4 +38,4 @@
#define _THREAD_SAFE_LOCK_ _thread_safe_.lock();
#define _THREAD_SAFE_UNLOCK_ _thread_safe_.unlock();
-#endif
+#endif // THREAD_SAFE_H
diff --git a/core/pool_allocator.h b/core/pool_allocator.h
index e34f5b1104..8c1710ebe0 100644
--- a/core/pool_allocator.h
+++ b/core/pool_allocator.h
@@ -148,4 +148,4 @@ public:
virtual ~PoolAllocator();
};
-#endif
+#endif // POOL_ALLOCATOR_H
diff --git a/core/print_string.h b/core/print_string.h
index c2cf1c293b..d83cc35dd6 100644
--- a/core/print_string.h
+++ b/core/print_string.h
@@ -60,4 +60,4 @@ extern void print_line(String p_string);
extern void print_error(String p_string);
extern void print_verbose(String p_string);
-#endif
+#endif // PRINT_STRING_H
diff --git a/core/project_settings.h b/core/project_settings.h
index 8695df560e..7b3ca18c62 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GLOBAL_CONFIG_H
-#define GLOBAL_CONFIG_H
+#ifndef PROJECT_SETTINGS_H
+#define PROJECT_SETTINGS_H
#include "core/object.h"
#include "core/os/thread_safe.h"
@@ -166,4 +166,4 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restar
#define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true)
#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var)
-#endif
+#endif // PROJECT_SETTINGS_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index b0ba8ed194..7145d64629 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -38,7 +38,8 @@
#include "core/crypto/hashing_context.h"
#include "core/engine.h"
#include "core/func_ref.h"
-#include "core/input_map.h"
+#include "core/input/input_filter.h"
+#include "core/input/input_map.h"
#include "core/io/config_file.h"
#include "core/io/dtls_server.h"
#include "core/io/http_client.h"
@@ -62,7 +63,6 @@
#include "core/math/geometry.h"
#include "core/math/random_number_generator.h"
#include "core/math/triangle_mesh.h"
-#include "core/os/input.h"
#include "core/os/main_loop.h"
#include "core/packed_data_container.h"
#include "core/path_remap.h"
@@ -248,7 +248,7 @@ void register_core_singletons() {
ClassDB::register_class<_ClassDB>();
ClassDB::register_class<_Marshalls>();
ClassDB::register_class<TranslationServer>();
- ClassDB::register_virtual_class<Input>();
+ ClassDB::register_virtual_class<InputFilter>();
ClassDB::register_class<InputMap>();
ClassDB::register_class<_JSON>();
ClassDB::register_class<Expression>();
@@ -263,7 +263,7 @@ void register_core_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("ClassDB", _classdb));
Engine::get_singleton()->add_singleton(Engine::Singleton("Marshalls", _Marshalls::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Input", InputFilter::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("JSON", _JSON::get_singleton()));
}
diff --git a/core/register_core_types.h b/core/register_core_types.h
index 22c0025f0c..bdd335f33c 100644
--- a/core/register_core_types.h
+++ b/core/register_core_types.h
@@ -36,4 +36,4 @@ void register_core_settings();
void register_core_singletons();
void unregister_core_types();
-#endif
+#endif // REGISTER_CORE_TYPES_H
diff --git a/core/resource.h b/core/resource.h
index 4b79a39d9d..9f83848c04 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -167,4 +167,4 @@ public:
static int get_cached_resource_count();
};
-#endif
+#endif // RESOURCE_H
diff --git a/core/rid.h b/core/rid.h
index 0c4a96efed..3cc0ee3084 100644
--- a/core/rid.h
+++ b/core/rid.h
@@ -75,4 +75,4 @@ public:
}
};
-#endif
+#endif // RID_H
diff --git a/core/ring_buffer.h b/core/ring_buffer.h
index f5f43607fe..620a3a3846 100644
--- a/core/ring_buffer.h
+++ b/core/ring_buffer.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RINGBUFFER_H
-#define RINGBUFFER_H
+#ifndef RING_BUFFER_H
+#define RING_BUFFER_H
#include "core/vector.h"
@@ -221,4 +221,4 @@ public:
~RingBuffer<T>(){};
};
-#endif
+#endif // RING_BUFFER_H
diff --git a/core/safe_refcount.h b/core/safe_refcount.h
index 887282f556..953a877397 100644
--- a/core/safe_refcount.h
+++ b/core/safe_refcount.h
@@ -208,4 +208,4 @@ public:
}
};
-#endif
+#endif // SAFE_REFCOUNT_H
diff --git a/core/script_language.h b/core/script_language.h
index bb7d74dd83..6219a423d0 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -459,4 +459,5 @@ public:
PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner);
~PlaceHolderScriptInstance();
};
-#endif
+
+#endif // SCRIPT_LANGUAGE_H
diff --git a/core/set.h b/core/set.h
index aee3f4bc7a..5ddfb87b74 100644
--- a/core/set.h
+++ b/core/set.h
@@ -634,4 +634,4 @@ public:
}
};
-#endif
+#endif // SET_H
diff --git a/core/simple_type.h b/core/simple_type.h
index f637504db8..da031854c6 100644
--- a/core/simple_type.h
+++ b/core/simple_type.h
@@ -51,4 +51,4 @@ struct GetSimpleTypeT<T const> {
typedef T type_t;
};
-#endif
+#endif // SIMPLE_TYPE_H
diff --git a/core/string_buffer.h b/core/string_buffer.h
index d80a975c7f..a140f0abf7 100644
--- a/core/string_buffer.h
+++ b/core/string_buffer.h
@@ -163,4 +163,4 @@ int64_t StringBuffer<SHORT_BUFFER_SIZE>::as_int() {
return String::to_int(current_buffer_ptr());
}
-#endif
+#endif // STRING_BUFFER_H
diff --git a/core/type_info.h b/core/type_info.h
index 3b08ff3cae..816d0d9381 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GET_TYPE_INFO_H
-#define GET_TYPE_INFO_H
+#ifndef TYPE_INFO_H
+#define TYPE_INFO_H
#ifdef DEBUG_METHODS_ENABLED
@@ -144,6 +144,9 @@ MAKE_TYPE_INFO(String, Variant::STRING)
MAKE_TYPE_INFO(Vector2, Variant::VECTOR2)
MAKE_TYPE_INFO(Rect2, Variant::RECT2)
MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
+MAKE_TYPE_INFO(Vector2i, Variant::VECTOR2I)
+MAKE_TYPE_INFO(Rect2i, Variant::RECT2I)
+MAKE_TYPE_INFO(Vector3i, Variant::VECTOR3I)
MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
MAKE_TYPE_INFO(Plane, Variant::PLANE)
MAKE_TYPE_INFO(Quat, Variant::QUAT)
@@ -273,4 +276,4 @@ inline StringName __constant_get_enum_name(T param, const String &p_constant) {
#endif // DEBUG_METHODS_ENABLED
-#endif // GET_TYPE_INFO_H
+#endif // TYPE_INFO_H
diff --git a/core/ucaps.h b/core/ucaps.h
index 013f264d2f..ad71731617 100644
--- a/core/ucaps.h
+++ b/core/ucaps.h
@@ -1413,4 +1413,5 @@ static int _find_lower(int ch) {
return ch;
}
-#endif
+
+#endif // UCAPS_H
diff --git a/core/variant.h b/core/variant.h
index 614d39e84a..d38130e3a3 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -516,4 +516,5 @@ const Variant::ObjData &Variant::_get_obj() const {
}
String vformat(const String &p_text, const Variant &p1 = Variant(), const Variant &p2 = Variant(), const Variant &p3 = Variant(), const Variant &p4 = Variant(), const Variant &p5 = Variant());
-#endif
+
+#endif // VARIANT_H
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index d2ee0b71c9..0a578faf78 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -30,8 +30,8 @@
#include "variant_parser.h"
+#include "core/input/input_event.h"
#include "core/io/resource_loader.h"
-#include "core/os/input_event.h"
#include "core/os/keyboard.h"
#include "core/string_buffer.h"
diff --git a/core/vector.h b/core/vector.h
index 51a73e4ae4..7277179621 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -181,4 +181,4 @@ bool Vector<T>::push_back(T p_elem) {
return false;
}
-#endif
+#endif // VECTOR_H
diff --git a/core/version.h b/core/version.h
index 42c85c1b13..1198f62db4 100644
--- a/core/version.h
+++ b/core/version.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_VERSION_H
-#define GODOT_VERSION_H
+#ifndef VERSION_H
+#define VERSION_H
#include "core/version_generated.gen.h"
@@ -68,4 +68,4 @@
// Example: "Godot v3.1.4.stable.official.mono"
#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_FULL_BUILD
-#endif // GODOT_VERSION_H
+#endif // VERSION_H
diff --git a/doc/Makefile b/doc/Makefile
index 7f3f7ea939..9534da9bd5 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -13,13 +13,6 @@ doxygen:
mkdir -p $(OUTPUTDIR)/doxygen
doxygen Doxyfile
-markdown:
- rm -rf $(OUTPUTDIR)/markdown
- mkdir -p $(OUTPUTDIR)/markdown
- pushd $(OUTPUTDIR)/markdown
- python2 $(TOOLSDIR)/makemd.py $(CLASSES)
- popd
-
rst:
rm -rf $(OUTPUTDIR)/rst
mkdir -p $(OUTPUTDIR)/rst
diff --git a/doc/classes/EditorFeatureProfile.xml b/doc/classes/EditorFeatureProfile.xml
index 387962cf6a..75b906d6d2 100644
--- a/doc/classes/EditorFeatureProfile.xml
+++ b/doc/classes/EditorFeatureProfile.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorFeatureProfile" inherits="Reference" version="4.0">
<brief_description>
+ An editor feature profile which can be used to disable specific features.
</brief_description>
<description>
+ An editor feature profile can be used to disable specific features of the Godot editor. When disabled, the features won't appear in the editor, which makes the editor less cluttered. This is useful in education settings to reduce confusion or when working in a team. For example, artists and level designers could use a feature profile that disables the script editor to avoid accidentally making changes to files they aren't supposed to edit.
+ To manage editor feature profiles visually, use [b]Editor > Manage Feature Profiles...[/b] at the top of the editor window.
</description>
<tutorials>
</tutorials>
@@ -13,6 +16,7 @@
<argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature">
</argument>
<description>
+ Returns the specified [code]feature[/code]'s human-readable name.
</description>
</method>
<method name="is_class_disabled" qualifiers="const">
@@ -21,6 +25,7 @@
<argument index="0" name="class_name" type="StringName">
</argument>
<description>
+ Returns [code]true[/code] if the class specified by [code]class_name[/code] is disabled. When disabled, the class won't appear in the Create New Node dialog.
</description>
</method>
<method name="is_class_editor_disabled" qualifiers="const">
@@ -29,6 +34,7 @@
<argument index="0" name="class_name" type="StringName">
</argument>
<description>
+ Returns [code]true[/code] if editing for the class specified by [code]class_name[/code] is disabled. When disabled, the class will still appear in the Create New Node dialog but the inspector will be read-only when selecting a node that extends the class.
</description>
</method>
<method name="is_class_property_disabled" qualifiers="const">
@@ -39,6 +45,7 @@
<argument index="1" name="property" type="StringName">
</argument>
<description>
+ Returns [code]true[/code] if [code]property[/code] is disabled in the class specified by [code]class_name[/code]. When a property is disabled, it won't appear in the inspector when selecting a node that extends the class specified by [code]class_name[/code].
</description>
</method>
<method name="is_feature_disabled" qualifiers="const">
@@ -47,6 +54,7 @@
<argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature">
</argument>
<description>
+ Returns [code]true[/code] if the [code]feature[/code] is disabled. When a feature is disabled, it will disappear from the editor entirely.
</description>
</method>
<method name="load_from_file">
@@ -55,6 +63,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
+ Loads an editor feature profile from a file. The file must follow the JSON format obtained by using the feature profile manager's [b]Export[/b] button or the [method save_to_file] method.
</description>
</method>
<method name="save_to_file">
@@ -63,6 +72,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
+ Saves the editor feature profile to a file in JSON format. It can then be imported using the feature profile manager's [b]Import[/b] button or the [method load_from_file] button.
</description>
</method>
<method name="set_disable_class">
@@ -73,6 +83,7 @@
<argument index="1" name="disable" type="bool">
</argument>
<description>
+ If [code]disable[/code] is [code]true[/code], disables the class specified by [code]class_name[/code]. When disabled, the class won't appear in the Create New Node dialog.
</description>
</method>
<method name="set_disable_class_editor">
@@ -83,6 +94,7 @@
<argument index="1" name="disable" type="bool">
</argument>
<description>
+ If [code]disable[/code] is [code]true[/code], disables editing for the class specified by [code]class_name[/code]. When disabled, the class will still appear in the Create New Node dialog but the inspector will be read-only when selecting a node that extends the class.
</description>
</method>
<method name="set_disable_class_property">
@@ -95,6 +107,7 @@
<argument index="2" name="disable" type="bool">
</argument>
<description>
+ If [code]disable[/code] is [code]true[/code], disables editing for [code]property[/code] in the class specified by [code]class_name[/code]. When a property is disabled, it won't appear in the inspector when selecting a node that extends the class specified by [code]class_name[/code].
</description>
</method>
<method name="set_disable_feature">
@@ -105,23 +118,31 @@
<argument index="1" name="disable" type="bool">
</argument>
<description>
+ If [code]disable[/code] is [code]true[/code], disables the editor feature specified in [code]feature[/code]. When a feature is disabled, it will disappear from the editor entirely.
</description>
</method>
</methods>
<constants>
<constant name="FEATURE_3D" value="0" enum="Feature">
+ The 3D editor. If this feature is disabled, the 3D editor won't display but 3D nodes will still display in the Create New Node dialog.
</constant>
<constant name="FEATURE_SCRIPT" value="1" enum="Feature">
+ The Script tab, which contains the script editor and class reference browser. If this feature is disabled, the Script tab won't display.
</constant>
<constant name="FEATURE_ASSET_LIB" value="2" enum="Feature">
+ The AssetLib tab. If this feature is disabled, the AssetLib tab won't display.
</constant>
<constant name="FEATURE_SCENE_TREE" value="3" enum="Feature">
+ Scene tree editing. If this feature is disabled, the Scene tree dock will still be visible but will be read-only.
</constant>
<constant name="FEATURE_IMPORT_DOCK" value="4" enum="Feature">
+ The Import dock. If this feature is disabled, the Import dock won't be visible.
</constant>
<constant name="FEATURE_NODE_DOCK" value="5" enum="Feature">
+ The Node dock. If this feature is disabled, signals and groups won't be visible and modifiable from the editor.
</constant>
<constant name="FEATURE_FILESYSTEM_DOCK" value="6" enum="Feature">
+ The FileSystem dock. If this feature is disabled, the FileSystem dock won't be visible.
</constant>
<constant name="FEATURE_MAX" value="7" enum="Feature">
Represents the size of the [enum Feature] enum.
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index a3faccae1a..33f5fc0f35 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -311,13 +311,22 @@
Returns [code]true[/code] if the object contains the given [code]method[/code].
</description>
</method>
+ <method name="has_signal" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="signal" type="String">
+ </argument>
+ <description>
+ Returns [code]true[/code] if the given [code]signal[/code] exists.
+ </description>
+ </method>
<method name="has_user_signal" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="signal" type="StringName">
</argument>
<description>
- Returns [code]true[/code] if the given user-defined [code]signal[/code] exists.
+ Returns [code]true[/code] if the given user-defined [code]signal[/code] exists. Only signals added using [method add_user_signal] are taken into account.
</description>
</method>
<method name="is_blocking_signals" qualifiers="const">
diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h
index a8caf0fbae..50bd9e853d 100644
--- a/drivers/alsa/audio_driver_alsa.h
+++ b/drivers/alsa/audio_driver_alsa.h
@@ -28,12 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/audio_server.h"
-
#ifdef ALSA_ENABLED
+#ifndef AUDIO_DRIVER_ALSA_H
+#define AUDIO_DRIVER_ALSA_H
+
#include "core/os/mutex.h"
#include "core/os/thread.h"
+#include "servers/audio_server.h"
#include <alsa/asoundlib.h>
@@ -87,4 +89,6 @@ public:
~AudioDriverALSA();
};
-#endif
+#endif // AUDIO_DRIVER_ALSA_H
+
+#endif // ALSA_ENABLED
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h
index b446828128..a503492595 100644
--- a/drivers/dummy/rasterizer_dummy.h
+++ b/drivers/dummy/rasterizer_dummy.h
@@ -35,8 +35,8 @@
#include "core/rid_owner.h"
#include "core/self_list.h"
#include "scene/resources/mesh.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
class RasterizerSceneDummy : public RasterizerScene {
public:
@@ -55,7 +55,7 @@ public:
RID sky_create() { return RID(); }
void sky_set_radiance_size(RID p_sky, int p_radiance_size) {}
- void sky_set_mode(RID p_sky, VS::SkyMode p_samples) {}
+ void sky_set_mode(RID p_sky, RS::SkyMode p_samples) {}
void sky_set_texture(RID p_sky, RID p_panorama) {}
void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
void sky_set_material(RID p_sky, RID p_material) {}
@@ -64,28 +64,28 @@ public:
RID environment_create() { return RID(); }
- void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) {}
+ void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {}
void environment_set_sky(RID p_env, RID p_sky) {}
void environment_set_sky_custom_fov(RID p_env, float p_scale) {}
void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {}
void environment_set_bg_color(RID p_env, const Color &p_color) {}
void environment_set_bg_energy(RID p_env, float p_energy) {}
void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {}
- void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) {}
+ void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) {}
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {}
#endif
- void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {}
+ void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {}
void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {}
void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {}
- virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {}
- virtual void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) {}
+ virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {}
+ virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) {}
- void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {}
+ void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {}
void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {}
@@ -94,13 +94,13 @@ public:
void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {}
bool is_environment(RID p_env) const { return false; }
- VS::EnvironmentBG environment_get_background(RID p_env) const { return VS::ENV_BG_KEEP; }
+ RS::EnvironmentBG environment_get_background(RID p_env) const { return RS::ENV_BG_KEEP; }
int environment_get_canvas_max_layer(RID p_env) const { return 0; }
virtual RID camera_effects_create() { return RID(); }
- virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) {}
- virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) {}
+ virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {}
+ virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {}
virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {}
virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {}
@@ -133,10 +133,10 @@ public:
void set_scene_pass(uint64_t p_pass) {}
virtual void set_time(double p_time, double p_step) {}
- void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {}
+ void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {}
virtual RID render_buffers_create() { return RID(); }
- virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) {}
+ virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) {}
virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_curve) {}
virtual bool screen_space_roughness_limiter_is_active() const { return false; }
@@ -162,7 +162,7 @@ public:
struct DummySurface {
uint32_t format;
- VS::PrimitiveType primitive;
+ RS::PrimitiveType primitive;
Vector<uint8_t> array;
int vertex_count;
Vector<uint8_t> index_array;
@@ -175,14 +175,14 @@ public:
struct DummyMesh {
Vector<DummySurface> surfaces;
int blend_shape_count;
- VS::BlendShapeMode blend_shape_mode;
+ RS::BlendShapeMode blend_shape_mode;
};
mutable RID_PtrOwner<DummyTexture> texture_owner;
mutable RID_PtrOwner<DummyMesh> mesh_owner;
virtual RID texture_2d_create(const Ref<Image> &p_image) { return RID(); }
- virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) { return RID(); }
+ virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) { return RID(); }
virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return RID(); }
virtual RID texture_proxy_create(RID p_base) { return RID(); }
@@ -209,11 +209,11 @@ public:
virtual void texture_set_path(RID p_texture, const String &p_path) {}
virtual String texture_get_path(RID p_texture) const { return String(); }
- virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {}
- virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {}
- virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {}
+ virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {}
+ virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {}
+ virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {}
- virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) {}
+ virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) {}
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
virtual Size2 texture_size_with_proxy(RID p_proxy) { return Size2(); }
@@ -225,7 +225,7 @@ public:
return texture_owner.make_rid(texture);
}
- void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VisualServer::TextureType p_type = VS::TEXTURE_TYPE_2D, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) {
+ void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingServer::TextureType p_type = RS::TEXTURE_TYPE_2D, uint32_t p_flags = RS::TEXTURE_FLAGS_DEFAULT) {
DummyTexture *t = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!t);
t->width = p_width;
@@ -278,7 +278,7 @@ public:
return t->format;
}
- VisualServer::TextureType texture_get_type(RID p_texture) const { return VS::TEXTURE_TYPE_2D; }
+ RenderingServer::TextureType texture_get_type(RID p_texture) const { return RS::TEXTURE_TYPE_2D; }
uint32_t texture_get_texid(RID p_texture) const { return 0; }
uint32_t texture_get_width(RID p_texture) const { return 0; }
uint32_t texture_get_height(RID p_texture) const { return 0; }
@@ -299,13 +299,13 @@ public:
void texture_set_shrink_all_x2_on_set_data(bool p_enable) {}
- void texture_debug_usage(List<VS::TextureInfo> *r_info) {}
+ void texture_debug_usage(List<RS::TextureInfo> *r_info) {}
RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const { return RID(); }
- void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {}
- void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {}
- void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {}
+ void texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {}
+ void texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {}
+ void texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {}
void textures_keep_original(bool p_enable) {}
@@ -353,14 +353,14 @@ public:
DummyMesh *mesh = memnew(DummyMesh);
ERR_FAIL_COND_V(!mesh, RID());
mesh->blend_shape_count = 0;
- mesh->blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED;
+ mesh->blend_shape_mode = RS::BLEND_SHAPE_MODE_NORMALIZED;
return mesh_owner.make_rid(mesh);
}
- void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) {}
+ void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {}
#if 0
- void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
+ void mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!m);
@@ -390,14 +390,14 @@ public:
return m->blend_shape_count;
}
- void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) {
+ void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!m);
m->blend_shape_mode = p_mode;
}
- VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const {
+ RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!m, VS::BLEND_SHAPE_MODE_NORMALIZED);
+ ERR_FAIL_COND_V(!m, RS::BLEND_SHAPE_MODE_NORMALIZED);
return m->blend_shape_mode;
}
@@ -439,9 +439,9 @@ public:
return m->surfaces[p_surface].format;
}
- VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
+ RS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!m, VS::PRIMITIVE_POINTS);
+ ERR_FAIL_COND_V(!m, RS::PRIMITIVE_POINTS);
return m->surfaces[p_surface].primitive;
}
@@ -474,7 +474,7 @@ public:
}
#endif
- VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const { return VS::SurfaceData(); }
+ RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const { return RS::SurfaceData(); }
int mesh_get_surface_count(RID p_mesh) const {
DummyMesh *m = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!m, 0);
@@ -491,7 +491,7 @@ public:
virtual RID multimesh_create() { return RID(); }
- virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) {}
+ virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) {}
int multimesh_get_instance_count(RID p_multimesh) const { return 0; }
void multimesh_set_mesh(RID p_multimesh, RID p_mesh) {}
@@ -516,7 +516,7 @@ public:
/* IMMEDIATE API */
RID immediate_create() { return RID(); }
- void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
+ void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {}
void immediate_normal(RID p_immediate, const Vector3 &p_normal) {}
void immediate_tangent(RID p_immediate, const Plane &p_tangent) {}
@@ -543,14 +543,14 @@ public:
/* Light API */
- RID light_create(VS::LightType p_type) { return RID(); }
+ RID light_create(RS::LightType p_type) { return RID(); }
- RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); }
- RID omni_light_create() { return light_create(VS::LIGHT_OMNI); }
- RID spot_light_create() { return light_create(VS::LIGHT_SPOT); }
+ RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); }
+ RID omni_light_create() { return light_create(RS::LIGHT_OMNI); }
+ RID spot_light_create() { return light_create(RS::LIGHT_SPOT); }
void light_set_color(RID p_light, const Color &p_color) {}
- void light_set_param(RID p_light, VS::LightParam p_param, float p_value) {}
+ void light_set_param(RID p_light, RS::LightParam p_param, float p_value) {}
void light_set_shadow(RID p_light, bool p_enabled) {}
void light_set_shadow_color(RID p_light, const Color &p_color) {}
void light_set_projector(RID p_light, RID p_texture) {}
@@ -559,22 +559,22 @@ public:
void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {}
void light_set_use_gi(RID p_light, bool p_enabled) {}
- void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {}
+ void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {}
- void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {}
+ void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {}
void light_directional_set_blend_splits(RID p_light, bool p_enable) {}
bool light_directional_get_blend_splits(RID p_light) const { return false; }
- void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {}
- VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; }
+ void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) {}
+ RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; }
- VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; }
- VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; }
+ RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; }
+ RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; }
bool light_has_shadow(RID p_light) const { return false; }
- VS::LightType light_get_type(RID p_light) const { return VS::LIGHT_OMNI; }
+ RS::LightType light_get_type(RID p_light) const { return RS::LIGHT_OMNI; }
AABB light_get_aabb(RID p_light) const { return AABB(); }
- float light_get_param(RID p_light, VS::LightParam p_param) { return 0.0; }
+ float light_get_param(RID p_light, RS::LightParam p_param) { return 0.0; }
Color light_get_color(RID p_light) { return Color(); }
bool light_get_use_gi(RID p_light) { return false; }
uint64_t light_get_version(RID p_light) const { return 0; }
@@ -583,7 +583,7 @@ public:
RID reflection_probe_create() { return RID(); }
- void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) {}
+ void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {}
void reflection_probe_set_intensity(RID p_probe, float p_intensity) {}
void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {}
void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {}
@@ -598,7 +598,7 @@ public:
void reflection_probe_set_resolution(RID p_probe, int p_resolution) {}
AABB reflection_probe_get_aabb(RID p_probe) const { return AABB(); }
- VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return VisualServer::REFLECTION_PROBE_UPDATE_ONCE; }
+ RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; }
uint32_t reflection_probe_get_cull_mask(RID p_probe) const { return 0; }
Vector3 reflection_probe_get_extents(RID p_probe) const { return Vector3(); }
Vector3 reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); }
@@ -742,7 +742,7 @@ public:
void particles_set_fractional_delta(RID p_particles, bool p_enable) {}
void particles_restart(RID p_particles) {}
- void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {}
+ void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {}
void particles_set_draw_passes(RID p_particles, int p_count) {}
void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {}
@@ -776,12 +776,12 @@ public:
virtual void render_target_disable_clear_request(RID p_render_target) {}
virtual void render_target_do_clear_request(RID p_render_target) {}
- VS::InstanceType get_base_type(RID p_rid) const {
+ RS::InstanceType get_base_type(RID p_rid) const {
if (mesh_owner.owns(p_rid)) {
- return VS::INSTANCE_MESH;
+ return RS::INSTANCE_MESH;
}
- return VS::INSTANCE_NONE;
+ return RS::INSTANCE_NONE;
}
bool free(RID p_rid) {
@@ -803,9 +803,9 @@ public:
void render_info_begin_capture() {}
void render_info_end_capture() {}
- int get_captured_render_info(VS::RenderInfo p_info) { return 0; }
+ int get_captured_render_info(RS::RenderInfo p_info) { return 0; }
- int get_render_info(VS::RenderInfo p_info) { return 0; }
+ int get_render_info(RS::RenderInfo p_info) { return 0; }
String get_video_adapter_name() const { return String(); }
String get_video_adapter_vendor() const { return String(); }
@@ -825,7 +825,7 @@ public:
class RasterizerCanvasDummy : public RasterizerCanvas {
public:
- virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { return 0; }
+ virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { return 0; }
virtual void free_texture_binding(TextureBindingID p_binding) {}
virtual PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>()) { return 0; }
@@ -841,7 +841,7 @@ public:
virtual RID occluder_polygon_create() { return RID(); }
virtual void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) {}
- virtual void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) {}
+ virtual void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {}
void draw_window_margins(int *p_margins, RID *p_margin_textures) {}
diff --git a/drivers/gl_context/SCsub b/drivers/gl_context/SCsub
index b9f0ea2254..d6945ee2eb 100644
--- a/drivers/gl_context/SCsub
+++ b/drivers/gl_context/SCsub
@@ -2,7 +2,7 @@
Import('env')
-if (env["platform"] in ["haiku", "osx", "windows", "x11"]):
+if (env["platform"] in ["haiku", "osx", "windows", "linuxbsd"]):
# Thirdparty source files
thirdparty_dir = "#thirdparty/glad/"
thirdparty_sources = [
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index 24927c4bb8..734b4463ff 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -33,7 +33,7 @@
#include "core/os/os.h"
#include "core/project_settings.h"
#include "rasterizer_scene_gles2.h"
-#include "servers/visual/visual_server_raster.h"
+#include "servers/rendering/rendering_server_raster.h"
#ifndef GLES_OVER_GL
#define glClearDepth glClearDepthf
@@ -85,7 +85,7 @@ void RasterizerCanvasGLES2::_set_uniforms() {
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR, light->color * light->energy);
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS, light->light_shader_pos);
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_HEIGHT, light->height);
- state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == VS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
+ state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
if (state.using_shadow) {
RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer);
@@ -124,7 +124,7 @@ void RasterizerCanvasGLES2::canvas_begin() {
viewport_width = storage->frame.current_rt->width;
viewport_height = storage->frame.current_rt->height;
viewport_x = storage->frame.current_rt->x;
- viewport_y = OS::get_singleton()->get_window_size().height - viewport_height - storage->frame.current_rt->y;
+ viewport_y = DisplayServer::get_singleton()->window_get_size().height - viewport_height - storage->frame.current_rt->y;
glScissor(viewport_x, viewport_y, viewport_width, viewport_height);
glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
glEnable(GL_SCISSOR_TEST);
@@ -152,8 +152,8 @@ void RasterizerCanvasGLES2::canvas_begin() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
// set up default uniforms
@@ -168,7 +168,7 @@ void RasterizerCanvasGLES2::canvas_begin() {
canvas_transform.translate(-(storage->frame.current_rt->width / 2.0f), -(storage->frame.current_rt->height / 2.0f), 0.0f);
canvas_transform.scale(Vector3(2.0f / storage->frame.current_rt->width, csy * -2.0f / storage->frame.current_rt->height, 1.0f));
} else {
- Vector2 ssize = OS::get_singleton()->get_window_size();
+ Vector2 ssize = DisplayServer::get_singleton()->window_get_size();
canvas_transform.translate(-(ssize.width / 2.0f), -(ssize.height / 2.0f), 0.0f);
canvas_transform.scale(Vector3(2.0f / ssize.width, -2.0f / ssize.height, 1.0f));
}
@@ -188,14 +188,14 @@ void RasterizerCanvasGLES2::canvas_end() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
glDisableVertexAttribArray(i);
}
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
//reset viewport to full window size
- int viewport_width = OS::get_singleton()->get_window_size().width;
- int viewport_height = OS::get_singleton()->get_window_size().height;
+ int viewport_width = DisplayServer::get_singleton()->window_get_size().width;
+ int viewport_height = DisplayServer::get_singleton()->window_get_size().height;
glViewport(0, 0, viewport_width, viewport_height);
glScissor(0, 0, viewport_width, viewport_height);
}
@@ -224,7 +224,7 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
} else {
if (texture->redraw_if_visible) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
texture = texture->get_ptr();
@@ -266,7 +266,7 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
} else {
if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
normal_map = normal_map->get_ptr();
@@ -299,47 +299,47 @@ void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_coun
uint32_t buffer_ofs = 0;
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
buffer_ofs += sizeof(Vector2) * p_vertex_count;
if (p_singlecolor) {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
Color m = *p_colors;
- glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
+ glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
} else if (!p_colors) {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} else {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
- glEnableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(Color) * p_vertex_count;
}
if (p_uvs) {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(Vector2) * p_vertex_count;
} else {
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
}
if (p_weights && p_bones) {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(float) * 4 * p_vertex_count, p_weights);
- glEnableVertexAttribArray(VS::ARRAY_WEIGHTS);
- glVertexAttribPointer(VS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_WEIGHTS);
+ glVertexAttribPointer(RS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(float) * 4 * p_vertex_count;
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(int) * 4 * p_vertex_count, p_bones);
- glEnableVertexAttribArray(VS::ARRAY_BONES);
- glVertexAttribPointer(VS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, sizeof(int) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_BONES);
+ glVertexAttribPointer(RS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, sizeof(int) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(int) * 4 * p_vertex_count;
} else {
- glDisableVertexAttribArray(VS::ARRAY_WEIGHTS);
- glDisableVertexAttribArray(VS::ARRAY_BONES);
+ glDisableVertexAttribArray(RS::ARRAY_WEIGHTS);
+ glDisableVertexAttribArray(RS::ARRAY_BONES);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
@@ -375,30 +375,30 @@ void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count
uint32_t buffer_ofs = 0;
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
buffer_ofs += sizeof(Vector2) * p_vertex_count;
if (p_singlecolor) {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
Color m = *p_colors;
- glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
+ glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
} else if (!p_colors) {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} else {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
- glEnableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(Color) * p_vertex_count;
}
if (p_uvs) {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
} else {
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
}
glDrawArrays(p_primitive, 0, p_vertex_count);
@@ -417,31 +417,31 @@ void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int
uint32_t buffer_ofs = 0;
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices);
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
buffer_ofs += sizeof(Vector2) * p_vertex_count;
if (p_singlecolor) {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
Color m = *p_colors;
- glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
+ glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
} else if (!p_colors) {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} else {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors);
- glEnableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(Color) * p_vertex_count;
}
if (p_uvs) {
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs);
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
buffer_ofs += sizeof(Vector2) * p_vertex_count;
} else {
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
@@ -514,16 +514,16 @@ void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_v
#endif
glBufferSubData(GL_ARRAY_BUFFER, 0, p_points * stride * 4 * sizeof(float), buffer_data);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
if (p_colors) {
- glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float)));
- glEnableVertexAttribArray(VS::ARRAY_COLOR);
+ glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float)));
+ glEnableVertexAttribArray(RS::ARRAY_COLOR);
}
if (p_uvs) {
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float)));
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float)));
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
}
glDrawArrays(prim[p_points], 0, p_points);
@@ -564,8 +564,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
_bind_canvas_texture(RID(), RID());
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttrib4fv(VS::ARRAY_COLOR, line->color.components);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttrib4fv(RS::ARRAY_COLOR, line->color.components);
state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
@@ -616,8 +616,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
Item::CommandRect *r = static_cast<Item::CommandRect *>(command);
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttrib4fv(VS::ARRAY_COLOR, r->modulate.components);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttrib4fv(RS::ARRAY_COLOR, r->modulate.components);
bool can_tile = true;
if (r->texture.is_valid() && r->flags & CANVAS_RECT_TILE && !storage->config.support_npot_repeat_mipmap) {
@@ -696,7 +696,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
bool untile = false;
- if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & VS::TEXTURE_FLAG_REPEAT)) {
+ if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & RS::TEXTURE_FLAG_REPEAT)) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
untile = true;
@@ -753,7 +753,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
bool untile = false;
- if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & VS::TEXTURE_FLAG_REPEAT)) {
+ if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RS::TEXTURE_FLAG_REPEAT)) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
untile = true;
@@ -816,8 +816,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
state.canvas_shader.use_material((void *)p_material);
}
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
- glVertexAttrib4fv(VS::ARRAY_COLOR, np->color.components);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
+ glVertexAttrib4fv(RS::ARRAY_COLOR, np->color.components);
RasterizerStorageGLES2::Texture *tex = _bind_canvas_texture(np->texture, np->normal_map);
@@ -968,11 +968,11 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ninepatch_elements);
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL);
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), CAST_INT_TO_UCHAR_PTR((sizeof(float) * 2)));
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), CAST_INT_TO_UCHAR_PTR((sizeof(float) * 2)));
glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_BYTE, NULL);
@@ -1072,18 +1072,18 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id);
}
- for (int k = 0; k < VS::ARRAY_MAX - 1; k++) {
+ for (int k = 0; k < RS::ARRAY_MAX - 1; k++) {
if (s->attribs[k].enabled) {
glEnableVertexAttribArray(k);
glVertexAttribPointer(s->attribs[k].index, s->attribs[k].size, s->attribs[k].type, s->attribs[k].normalized, s->attribs[k].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[k].offset));
} else {
glDisableVertexAttribArray(k);
switch (k) {
- case VS::ARRAY_NORMAL: {
- glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
+ case RS::ARRAY_NORMAL: {
+ glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
} break;
- case VS::ARRAY_COLOR: {
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ case RS::ARRAY_COLOR: {
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} break;
default: {
@@ -1099,7 +1099,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
}
}
- for (int j = 1; j < VS::ARRAY_MAX - 1; j++) {
+ for (int j = 1; j < RS::ARRAY_MAX - 1; j++) {
glDisableVertexAttribArray(j);
}
}
@@ -1118,7 +1118,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
if (!mesh_data)
break;
- state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != VS::MULTIMESH_CUSTOM_DATA_NONE);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCING, true);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1162,18 +1162,18 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id);
}
- for (int k = 0; k < VS::ARRAY_MAX - 1; k++) {
+ for (int k = 0; k < RS::ARRAY_MAX - 1; k++) {
if (s->attribs[k].enabled) {
glEnableVertexAttribArray(k);
glVertexAttribPointer(s->attribs[k].index, s->attribs[k].size, s->attribs[k].type, s->attribs[k].normalized, s->attribs[k].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[k].offset));
} else {
glDisableVertexAttribArray(k);
switch (k) {
- case VS::ARRAY_NORMAL: {
- glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
+ case RS::ARRAY_NORMAL: {
+ glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
} break;
- case VS::ARRAY_COLOR: {
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ case RS::ARRAY_COLOR: {
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} break;
default: {
@@ -1189,7 +1189,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]);
- if (multi_mesh->transform_format == VS::MULTIMESH_TRANSFORM_3D) {
+ if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) {
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 2, &buffer[8]);
} else {
glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 2, 0.0, 0.0, 1.0, 0.0);
@@ -1197,7 +1197,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
}
if (multi_mesh->color_floats) {
- if (multi_mesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multi_mesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
uint8_t *color_data = (uint8_t *)(buffer + color_ofs);
glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 3, color_data[0] / 255.0, color_data[1] / 255.0, color_data[2] / 255.0, color_data[3] / 255.0);
} else {
@@ -1208,7 +1208,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
}
if (multi_mesh->custom_data_floats) {
- if (multi_mesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multi_mesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
uint8_t *custom_data = (uint8_t *)(buffer + custom_data_ofs);
glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 4, custom_data[0] / 255.0, custom_data[1] / 255.0, custom_data[2] / 255.0, custom_data[3] / 255.0);
} else {
@@ -1301,9 +1301,9 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
if (primitive->colors.size() == 1 && primitive->points.size() > 1) {
Color c = primitive->colors[0];
- glVertexAttrib4f(VS::ARRAY_COLOR, c.r, c.g, c.b, c.a);
+ glVertexAttrib4f(RS::ARRAY_COLOR, c.r, c.g, c.b, c.a);
} else if (primitive->colors.empty()) {
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
}
_draw_gui_primitive(primitive->points.size(), primitive->points.ptr(), primitive->colors.ptr(), primitive->uvs.ptr());
@@ -1518,7 +1518,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
if (material_ptr) {
shader_ptr = material_ptr->shader;
- if (shader_ptr && shader_ptr->mode != VS::SHADER_CANVAS_ITEM) {
+ if (shader_ptr && shader_ptr->mode != RS::SHADER_CANVAS_ITEM) {
shader_ptr = NULL; // not a canvas item shader, don't use.
}
}
@@ -1542,7 +1542,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
if (shader_ptr != shader_cache) {
if (shader_ptr->canvas_item.uses_time) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
state.canvas_shader.set_custom_shader(shader_ptr->custom_code_id);
@@ -1582,7 +1582,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (t->redraw_if_visible) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
t = t->get_ptr();
@@ -1682,7 +1682,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
Light *light = p_light;
bool light_used = false;
- VS::CanvasLightMode mode = VS::CANVAS_LIGHT_MODE_ADD;
+ RS::CanvasLightMode mode = RS::CANVAS_LIGHT_MODE_ADD;
state.uniforms.final_modulate = ci->final_modulate; // remove the canvas modulate
while (light) {
@@ -1697,17 +1697,17 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
switch (mode) {
- case VS::CANVAS_LIGHT_MODE_ADD: {
+ case RS::CANVAS_LIGHT_MODE_ADD: {
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
} break;
- case VS::CANVAS_LIGHT_MODE_SUB: {
+ case RS::CANVAS_LIGHT_MODE_SUB: {
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
} break;
- case VS::CANVAS_LIGHT_MODE_MIX:
- case VS::CANVAS_LIGHT_MODE_MASK: {
+ case RS::CANVAS_LIGHT_MODE_MIX:
+ case RS::CANVAS_LIGHT_MODE_MASK: {
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1726,12 +1726,12 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, has_shadow);
if (has_shadow) {
state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_USE_GRADIENT, light->shadow_gradient_length > 0);
- state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_NONE);
- state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF3, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF3);
- state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF5, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF5);
- state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF7, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF7);
- state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF9, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF9);
- state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF13, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF13);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_NONE);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF3, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF3);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF5, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF5);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF7, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF7);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF9, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF9);
+ state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF13, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF13);
}
state.canvas_shader.bind();
@@ -1846,7 +1846,7 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- VS::CanvasOccluderPolygonCullMode cull = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
+ RS::CanvasOccluderPolygonCullMode cull = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
for (int i = 0; i < 4; i++) {
@@ -1903,31 +1903,31 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::WORLD_MATRIX, instance->xform_cache);
- VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
+ RS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
- if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
+ if (transformed_cull_cache != RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
(p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
transformed_cull_cache =
- transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
- VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
- VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
+ transformed_cull_cache == RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
+ RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
+ RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
}
if (cull != transformed_cull_cache) {
cull = transformed_cull_cache;
switch (cull) {
- case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
+ case RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
glDisable(GL_CULL_FACE);
} break;
- case VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: {
+ case RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: {
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
} break;
- case VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: {
+ case RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: {
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -1937,8 +1937,8 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
}
glBindBuffer(GL_ARRAY_BUFFER, cc->vertex_id);
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cc->index_id);
glDrawElements(GL_TRIANGLES, cc->len * 3, GL_UNSIGNED_SHORT, 0);
@@ -1979,8 +1979,8 @@ void RasterizerCanvasGLES2::reset_canvas() {
void RasterizerCanvasGLES2::_bind_quad_buffer() {
glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices);
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL);
}
void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
@@ -1995,7 +1995,7 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float
if (storage->frame.current_rt) {
half_size = Vector2(storage->frame.current_rt->width, storage->frame.current_rt->height);
} else {
- half_size = OS::get_singleton()->get_window_size();
+ half_size = DisplayServer::get_singleton()->window_get_size();
}
half_size *= 0.5;
Vector2 offset((p_rect.position.x - half_size.x) / half_size.x, (p_rect.position.y - half_size.y) / half_size.y);
@@ -2022,14 +2022,14 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float
// and cleanup
glBindBuffer(GL_ARRAY_BUFFER, 0);
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
glDisableVertexAttribArray(i);
}
}
void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_image) {
- Vector2 window_size = OS::get_singleton()->get_window_size();
+ Vector2 window_size = DisplayServer::get_singleton()->window_get_size();
int window_h = window_size.height;
int window_w = window_size.width;
diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h
index f6ae6a60c0..4e4db98c25 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.h
+++ b/drivers/gles2/rasterizer_canvas_gles2.h
@@ -32,7 +32,7 @@
#define RASTERIZERCANVASGLES2_H
#include "rasterizer_storage_gles2.h"
-#include "servers/visual/rasterizer.h"
+#include "servers/rendering/rasterizer.h"
#include "shaders/canvas.glsl.gen.h"
#include "shaders/lens_distorted.glsl.gen.h"
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 02b956fd44..cc17af171e 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -263,7 +263,7 @@ void RasterizerGLES2::initialize() {
#endif // GLES_OVER_GL
#endif // CAN_DEBUG
- print_line("OpenGL ES 2.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name());
+ print_line("OpenGL ES 2.0 Renderer: " + RenderingServer::get_singleton()->get_video_adapter_name());
storage->initialize();
canvas->initialize();
scene->initialize();
@@ -318,7 +318,7 @@ void RasterizerGLES2::set_current_render_target(RID p_render_target) {
} else {
storage->frame.current_rt = NULL;
storage->frame.clear_request = false;
- glViewport(0, 0, OS::get_singleton()->get_window_size().width, OS::get_singleton()->get_window_size().height);
+ glViewport(0, 0, DisplayServer::get_singleton()->window_get_size().width, DisplayServer::get_singleton()->window_get_size().height);
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES2::system_fbo);
}
}
@@ -359,7 +359,7 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
canvas->canvas_begin();
RID texture = storage->texture_create();
- storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_use_filter ? VS::TEXTURE_FLAG_FILTER : 0);
+ storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), RS::TEXTURE_TYPE_2D, p_use_filter ? RS::TEXTURE_FLAG_FILTER : 0);
storage->texture_set_data(texture, p_image);
Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height());
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 9a5501f13d..027a634ae8 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -34,7 +34,7 @@
#include "rasterizer_canvas_gles2.h"
#include "rasterizer_scene_gles2.h"
#include "rasterizer_storage_gles2.h"
-#include "servers/visual/rasterizer.h"
+#include "servers/rendering/rasterizer.h"
class RasterizerGLES2 : public Rasterizer {
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index c433886545..4bb8d5a16d 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -37,7 +37,7 @@
#include "core/vmap.h"
#include "rasterizer_canvas_gles2.h"
#include "servers/camera/camera_feed.h"
-#include "servers/visual/visual_server_raster.h"
+#include "servers/rendering/rendering_server_raster.h"
#ifndef GLES_OVER_GL
#define glClearDepth glClearDepthf
@@ -456,10 +456,10 @@ int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance)
ERR_FAIL_COND_V(!light_instance, 0);
switch (light_instance->light_ptr->directional_shadow_mode) {
- case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
+ case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
break; //none
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS:
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS:
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS:
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS:
shadow_size /= 2;
break;
}
@@ -525,7 +525,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_needs_redraw(RID p_instance
const ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
- bool need_redraw = rpi->probe_ptr->resolution != rpi->current_resolution || rpi->dirty || rpi->probe_ptr->update_mode == VS::REFLECTION_PROBE_UPDATE_ALWAYS;
+ bool need_redraw = rpi->probe_ptr->resolution != rpi->current_resolution || rpi->dirty || rpi->probe_ptr->update_mode == RS::REFLECTION_PROBE_UPDATE_ALWAYS;
rpi->dirty = false;
return need_redraw;
}
@@ -610,7 +610,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
glDisable(GL_BLEND);
glDepthMask(GL_FALSE);
- for (int i = 0; i < VS::ARRAY_MAX - 1; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX - 1; i++) {
glDisableVertexAttribArray(i);
}
}
@@ -690,7 +690,7 @@ RID RasterizerSceneGLES2::environment_create() {
return environment_owner.make_rid(env);
}
-void RasterizerSceneGLES2::environment_set_background(RID p_env, VS::EnvironmentBG p_bg) {
+void RasterizerSceneGLES2::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -755,7 +755,7 @@ void RasterizerSceneGLES2::environment_set_camera_feed_id(RID p_env, int p_camer
env->camera_feed_id = p_camera_feed_id;
}
-void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) {
+void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -767,7 +767,7 @@ void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable
env->dof_blur_far_quality = p_quality;
}
-void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) {
+void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -779,7 +779,7 @@ void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enabl
env->dof_blur_near_quality = p_quality;
}
-void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
+void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -806,12 +806,12 @@ void RasterizerSceneGLES2::environment_set_ssr(RID p_env, bool p_enable, int p_m
ERR_FAIL_COND(!env);
}
-void RasterizerSceneGLES2::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VisualServer::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {
+void RasterizerSceneGLES2::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, RS::EnvironmentSSAOQuality p_quality, RenderingServer::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
}
-void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
+void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
}
@@ -866,9 +866,9 @@ bool RasterizerSceneGLES2::is_environment(RID p_env) {
return environment_owner.owns(p_env);
}
-VS::EnvironmentBG RasterizerSceneGLES2::environment_get_background(RID p_env) {
+RS::EnvironmentBG RasterizerSceneGLES2::environment_get_background(RID p_env) {
const Environment *env = environment_owner.getornull(p_env);
- ERR_FAIL_COND_V(!env, VS::ENV_BG_MAX);
+ ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX);
return env->bg_mode;
}
@@ -914,7 +914,7 @@ void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_insta
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
- if (light_instance->light_ptr->type != VS::LIGHT_DIRECTIONAL) {
+ if (light_instance->light_ptr->type != RS::LIGHT_DIRECTIONAL) {
p_pass = 0;
}
@@ -1022,7 +1022,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
//shader does not use discard and does not write a vertex position, use generic material
- if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
+ if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
mirror = false;
} else {
@@ -1048,7 +1048,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
e->use_accum = false;
e->light_index = RenderList::MAX_LIGHTS;
e->use_accum_ptr = &e->use_accum;
- e->instancing = (e->instance->base_type == VS::INSTANCE_MULTIMESH) ? 1 : 0;
+ e->instancing = (e->instance->base_type == RS::INSTANCE_MULTIMESH) ? 1 : 0;
e->front_facing = false;
if (e->geometry->last_pass != render_pass) {
@@ -1162,7 +1162,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
//directional sort key
e->light_type1 = 1;
- e->light_type2 = li->light_ptr->type == VisualServer::LIGHT_OMNI ? 0 : 1;
+ e->light_type2 = li->light_ptr->type == RenderingServer::LIGHT_OMNI ? 0 : 1;
e->light_index = li->light_index;
copy = true;
@@ -1181,7 +1181,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
// do not add anything here, as lights are duplicated elements..
if (p_material->shader->spatial.uses_time) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
}
@@ -1224,7 +1224,7 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
switch (instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getornull(instance->base);
ERR_CONTINUE(!mesh);
@@ -1241,7 +1241,7 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
RasterizerStorageGLES2::MultiMesh *multi_mesh = storage->multimesh_owner.getornull(instance->base);
ERR_CONTINUE(!multi_mesh);
@@ -1260,7 +1260,7 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
}
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
RasterizerStorageGLES2::Immediate *im = storage->immediate_owner.getornull(instance->base);
ERR_CONTINUE(!im);
@@ -1426,7 +1426,7 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
}
if (t->redraw_if_visible) { //must check before proxy because this is often used with proxies
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
t = t->get_ptr();
@@ -1459,7 +1459,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
switch (p_element->instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id);
@@ -1468,18 +1468,18 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id);
}
- for (int i = 0; i < VS::ARRAY_MAX - 1; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX - 1; i++) {
if (s->attribs[i].enabled) {
glEnableVertexAttribArray(i);
glVertexAttribPointer(s->attribs[i].index, s->attribs[i].size, s->attribs[i].type, s->attribs[i].normalized, s->attribs[i].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[i].offset));
} else {
glDisableVertexAttribArray(i);
switch (i) {
- case VS::ARRAY_NORMAL: {
- glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
+ case RS::ARRAY_NORMAL: {
+ glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
} break;
- case VS::ARRAY_COLOR: {
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ case RS::ARRAY_COLOR: {
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} break;
default: {
@@ -1502,7 +1502,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
Vector<float> &transform_buffer = storage->resources.skeleton_transform_cpu_buffer;
- if (!s->attribs[VS::ARRAY_BONES].enabled || !s->attribs[VS::ARRAY_WEIGHTS].enabled) {
+ if (!s->attribs[RS::ARRAY_BONES].enabled || !s->attribs[RS::ARRAY_WEIGHTS].enabled) {
break; // the whole instance has a skeleton, but this surface is not affected by it.
}
@@ -1511,10 +1511,10 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
transform_buffer.resize(s->array_len * 12);
}
- const size_t bones_offset = s->attribs[VS::ARRAY_BONES].offset;
- const size_t bones_stride = s->attribs[VS::ARRAY_BONES].stride;
- const size_t bone_weight_offset = s->attribs[VS::ARRAY_WEIGHTS].offset;
- const size_t bone_weight_stride = s->attribs[VS::ARRAY_WEIGHTS].stride;
+ const size_t bones_offset = s->attribs[RS::ARRAY_BONES].offset;
+ const size_t bones_stride = s->attribs[RS::ARRAY_BONES].stride;
+ const size_t bone_weight_offset = s->attribs[RS::ARRAY_WEIGHTS].offset;
+ const size_t bone_weight_stride = s->attribs[RS::ARRAY_WEIGHTS].stride;
{
float *write = transform_buffer.ptrw();
@@ -1530,7 +1530,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
size_t bones[4];
float bone_weight[4];
- if (s->attribs[VS::ARRAY_BONES].type == GL_UNSIGNED_BYTE) {
+ if (s->attribs[RS::ARRAY_BONES].type == GL_UNSIGNED_BYTE) {
// read as byte
const uint8_t *bones_ptr = vertex_data + bones_offset + (i * bones_stride);
bones[0] = bones_ptr[0];
@@ -1546,7 +1546,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
bones[3] = bones_ptr[3];
}
- if (s->attribs[VS::ARRAY_WEIGHTS].type == GL_FLOAT) {
+ if (s->attribs[RS::ARRAY_WEIGHTS].type == GL_FLOAT) {
// read as float
const float *weight_ptr = (const float *)(vertex_data + bone_weight_offset + (i * bone_weight_stride));
bone_weight[0] = weight_ptr[0];
@@ -1621,7 +1621,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id);
@@ -1630,18 +1630,18 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id);
}
- for (int i = 0; i < VS::ARRAY_MAX - 1; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX - 1; i++) {
if (s->attribs[i].enabled) {
glEnableVertexAttribArray(i);
glVertexAttribPointer(s->attribs[i].index, s->attribs[i].size, s->attribs[i].type, s->attribs[i].normalized, s->attribs[i].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[i].offset));
} else {
glDisableVertexAttribArray(i);
switch (i) {
- case VS::ARRAY_NORMAL: {
- glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
+ case RS::ARRAY_NORMAL: {
+ glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1);
} break;
- case VS::ARRAY_COLOR: {
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ case RS::ARRAY_COLOR: {
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
} break;
default: {
@@ -1662,7 +1662,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
} break;
default: {
@@ -1674,7 +1674,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
switch (p_element->instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
@@ -1688,22 +1688,22 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
storage->info.render.vertices_count += s->array_len;
}
/*
- if (p_element->instance->skeleton.is_valid() && s->attribs[VS::ARRAY_BONES].enabled && s->attribs[VS::ARRAY_WEIGHTS].enabled) {
+ if (p_element->instance->skeleton.is_valid() && s->attribs[RS::ARRAY_BONES].enabled && s->attribs[RS::ARRAY_WEIGHTS].enabled) {
//clean up after skeleton
glBindBuffer(GL_ARRAY_BUFFER, storage->resources.skeleton_transform_buffer);
- glDisableVertexAttribArray(VS::ARRAY_MAX + 0);
- glDisableVertexAttribArray(VS::ARRAY_MAX + 1);
- glDisableVertexAttribArray(VS::ARRAY_MAX + 2);
+ glDisableVertexAttribArray(RS::ARRAY_MAX + 0);
+ glDisableVertexAttribArray(RS::ARRAY_MAX + 1);
+ glDisableVertexAttribArray(RS::ARRAY_MAX + 2);
- glVertexAttrib4f(VS::ARRAY_MAX + 0, 1, 0, 0, 0);
- glVertexAttrib4f(VS::ARRAY_MAX + 1, 0, 1, 0, 0);
- glVertexAttrib4f(VS::ARRAY_MAX + 2, 0, 0, 1, 0);
+ glVertexAttrib4f(RS::ARRAY_MAX + 0, 1, 0, 0, 0);
+ glVertexAttrib4f(RS::ARRAY_MAX + 1, 0, 1, 0, 0);
+ glVertexAttrib4f(RS::ARRAY_MAX + 2, 0, 0, 1, 0);
}
*/
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
RasterizerStorageGLES2::MultiMesh *multi_mesh = static_cast<RasterizerStorageGLES2::MultiMesh *>(p_element->owner);
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
@@ -1734,7 +1734,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
}
if (multi_mesh->color_floats) {
- if (multi_mesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multi_mesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
uint8_t *color_data = (uint8_t *)(buffer + color_ofs);
glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 3, color_data[0] / 255.0, color_data[1] / 255.0, color_data[2] / 255.0, color_data[3] / 255.0);
} else {
@@ -1745,7 +1745,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
}
if (multi_mesh->custom_data_floats) {
- if (multi_mesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multi_mesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
uint8_t *custom_data = (uint8_t *)(buffer + custom_data_ofs);
glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 4, custom_data[0] / 255.0, custom_data[1] / 255.0, custom_data[2] / 255.0, custom_data[3] / 255.0);
} else {
@@ -1764,7 +1764,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
const RasterizerStorageGLES2::Immediate *im = static_cast<const RasterizerStorageGLES2::Immediate *>(p_element->geometry);
if (im->building) {
@@ -1792,7 +1792,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(c.texture);
if (t->redraw_if_visible) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
t = t->get_ptr();
@@ -1816,53 +1816,53 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
}
if (!c.normals.empty()) {
- glEnableVertexAttribArray(VS::ARRAY_NORMAL);
+ glEnableVertexAttribArray(RS::ARRAY_NORMAL);
glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.normals.ptr());
- glVertexAttribPointer(VS::ARRAY_NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs));
+ glVertexAttribPointer(RS::ARRAY_NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs));
buf_ofs += sizeof(Vector3) * vertices;
} else {
- glDisableVertexAttribArray(VS::ARRAY_NORMAL);
+ glDisableVertexAttribArray(RS::ARRAY_NORMAL);
}
if (!c.tangents.empty()) {
- glEnableVertexAttribArray(VS::ARRAY_TANGENT);
+ glEnableVertexAttribArray(RS::ARRAY_TANGENT);
glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Plane) * vertices, c.tangents.ptr());
- glVertexAttribPointer(VS::ARRAY_TANGENT, 4, GL_FLOAT, GL_FALSE, sizeof(Plane), CAST_INT_TO_UCHAR_PTR(buf_ofs));
+ glVertexAttribPointer(RS::ARRAY_TANGENT, 4, GL_FLOAT, GL_FALSE, sizeof(Plane), CAST_INT_TO_UCHAR_PTR(buf_ofs));
buf_ofs += sizeof(Plane) * vertices;
} else {
- glDisableVertexAttribArray(VS::ARRAY_TANGENT);
+ glDisableVertexAttribArray(RS::ARRAY_TANGENT);
}
if (!c.colors.empty()) {
- glEnableVertexAttribArray(VS::ARRAY_COLOR);
+ glEnableVertexAttribArray(RS::ARRAY_COLOR);
glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Color) * vertices, c.colors.ptr());
- glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buf_ofs));
+ glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buf_ofs));
buf_ofs += sizeof(Color) * vertices;
} else {
- glDisableVertexAttribArray(VS::ARRAY_COLOR);
+ glDisableVertexAttribArray(RS::ARRAY_COLOR);
}
if (!c.uvs.empty()) {
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uvs.ptr());
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs));
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs));
buf_ofs += sizeof(Vector2) * vertices;
} else {
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
}
if (!c.uv2s.empty()) {
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV2);
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV2);
glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uv2s.ptr());
- glVertexAttribPointer(VS::ARRAY_TEX_UV2, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs));
+ glVertexAttribPointer(RS::ARRAY_TEX_UV2, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs));
buf_ofs += sizeof(Vector2) * vertices;
} else {
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV2);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV2);
}
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.vertices.ptr());
- glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs));
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs));
glDrawArrays(gl_primitive[c.primitive], 0, c.vertices.size());
}
@@ -1901,18 +1901,18 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTING, true);
switch (p_light->light_ptr->type) {
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_DIRECTIONAL, true);
switch (p_light->light_ptr->directional_shadow_mode) {
- case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: {
//no need
} break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: {
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_USE_PSSM2, true);
} break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: {
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_USE_PSSM4, true);
} break;
}
@@ -1931,7 +1931,7 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
}
} break;
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_OMNI: {
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_OMNI, true);
if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) {
@@ -1946,7 +1946,7 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
state.scene_shader.set_conditional(SceneShaderGLES2::SHADOW_MODE_PCF_13, shadow_filter_mode == SHADOW_FILTER_PCF13);
}
} break;
- case VS::LIGHT_SPOT: {
+ case RS::LIGHT_SPOT: {
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_SPOT, true);
if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) {
@@ -1969,8 +1969,8 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
RasterizerStorageGLES2::Light *light_ptr = light->light_ptr;
//common parameters
- float energy = light_ptr->param[VS::LIGHT_PARAM_ENERGY];
- float specular = light_ptr->param[VS::LIGHT_PARAM_SPECULAR];
+ float energy = light_ptr->param[RS::LIGHT_PARAM_ENERGY];
+ float specular = light_ptr->param[RS::LIGHT_PARAM_SPECULAR];
float sign = (light_ptr->negative && !accum_pass) ? -1 : 1; //inverse color for base pass lights only
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SPECULAR, specular);
@@ -1982,7 +1982,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
//specific parameters
switch (light_ptr->type) {
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
//not using inverse for performance, view should be normalized anyway
Vector3 direction = p_view_transform.basis.xform_inv(light->transform.basis.xform(Vector3(0, 0, -1))).normalized();
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_DIRECTION, direction);
@@ -1995,15 +1995,15 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
Color split_offsets;
switch (light_ptr->directional_shadow_mode) {
- case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: {
shadow_count = 1;
} break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: {
shadow_count = 2;
} break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: {
shadow_count = 4;
} break;
}
@@ -2015,7 +2015,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
uint32_t width = light->directional_rect.size.x;
uint32_t height = light->directional_rect.size.y;
- if (light_ptr->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
+ if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
width /= 2;
height /= 2;
@@ -2029,7 +2029,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
y += height;
}
- } else if (light_ptr->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
+ } else if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
height /= 2;
@@ -2067,16 +2067,16 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SHADOW_MATRIX4, matrices[3]);
}
} break;
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_OMNI: {
Vector3 position = p_view_transform.xform_inv(light->transform.origin);
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position);
- float range = light_ptr->param[VS::LIGHT_PARAM_RANGE];
+ float range = light_ptr->param[RS::LIGHT_PARAM_RANGE];
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_RANGE, range);
- float attenuation = light_ptr->param[VS::LIGHT_PARAM_ATTENUATION];
+ float attenuation = light_ptr->param[RS::LIGHT_PARAM_ATTENUATION];
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation);
if (!state.render_no_shadows && light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(light->self)) {
@@ -2101,7 +2101,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
uint32_t width = shadow_size;
uint32_t height = shadow_size;
- if (light->light_ptr->omni_shadow_detail == VS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
+ if (light->light_ptr->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
height /= 2;
} else {
width /= 2;
@@ -2121,7 +2121,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
} break;
- case VS::LIGHT_SPOT: {
+ case RS::LIGHT_SPOT: {
Vector3 position = p_view_transform.xform_inv(light->transform.origin);
@@ -2129,10 +2129,10 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
Vector3 direction = p_view_transform.inverse().basis.xform(light->transform.basis.xform(Vector3(0, 0, -1))).normalized();
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_DIRECTION, direction);
- float attenuation = light_ptr->param[VS::LIGHT_PARAM_ATTENUATION];
- float range = light_ptr->param[VS::LIGHT_PARAM_RANGE];
- float spot_attenuation = light_ptr->param[VS::LIGHT_PARAM_SPOT_ATTENUATION];
- float angle = light_ptr->param[VS::LIGHT_PARAM_SPOT_ANGLE];
+ float attenuation = light_ptr->param[RS::LIGHT_PARAM_ATTENUATION];
+ float range = light_ptr->param[RS::LIGHT_PARAM_RANGE];
+ float spot_attenuation = light_ptr->param[RS::LIGHT_PARAM_SPOT_ATTENUATION];
+ float angle = light_ptr->param[RS::LIGHT_PARAM_SPOT_ANGLE];
angle = Math::cos(Math::deg2rad(angle));
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation);
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SPOT_ATTENUATION, spot_attenuation);
@@ -2490,7 +2490,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
rebind = true;
}
- bool instancing = e->instance->base_type == VS::INSTANCE_MULTIMESH;
+ bool instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH;
if (instancing != prev_instancing) {
@@ -2726,10 +2726,10 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, vertices, GL_DYNAMIC_DRAW);
// bind sky vertex array....
- glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0);
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, CAST_INT_TO_UCHAR_PTR(sizeof(Vector3)));
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, CAST_INT_TO_UCHAR_PTR(sizeof(Vector3)));
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_ASYM_PANO, asymmetrical);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_PANORAMA, !asymmetrical);
@@ -2752,8 +2752,8 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableVertexAttribArray(VS::ARRAY_VERTEX);
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glDisableVertexAttribArray(RS::ARRAY_VERTEX);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
glBindBuffer(GL_ARRAY_BUFFER, 0);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_ASYM_PANO, false);
@@ -2845,9 +2845,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_FAR_BLUR, true);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_LOW);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_HIGH);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_far_quality == RS::ENV_DOF_BLUR_QUALITY_LOW);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_far_quality == RS::ENV_DOF_BLUR_QUALITY_MEDIUM);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_far_quality == RS::ENV_DOF_BLUR_QUALITY_HIGH);
state.effect_blur_shader.bind();
int qsteps[3] = { 4, 10, 20 };
@@ -2911,9 +2911,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_BLUR, true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_FIRST_TAP, true);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_LOW);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM);
- state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_HIGH);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_near_quality == RS::ENV_DOF_BLUR_QUALITY_LOW);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_near_quality == RS::ENV_DOF_BLUR_QUALITY_MEDIUM);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_near_quality == RS::ENV_DOF_BLUR_QUALITY_HIGH);
state.effect_blur_shader.bind();
int qsteps[3] = { 4, 10, 20 };
@@ -3003,7 +3003,7 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
if (env->glow_enabled) {
- for (int i = 0; i < VS::MAX_GLOW_LEVELS; i++) {
+ for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) {
if (env->glow_levels & (1 << i)) {
if (i >= storage->frame.current_rt->mip_maps[1].sizes.size()) {
@@ -3156,9 +3156,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
}
- state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SCREEN, env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_SCREEN);
- state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SOFTLIGHT, env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_SOFTLIGHT);
- state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_REPLACE, env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_REPLACE);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SCREEN, env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_SCREEN);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SOFTLIGHT, env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT);
+ state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_REPLACE, env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_REPLACE);
}
//Adjustments
@@ -3261,7 +3261,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
viewport_x = storage->frame.current_rt->x;
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
- viewport_y = OS::get_singleton()->get_window_size().height - viewport_height - storage->frame.current_rt->y;
+ viewport_y = DisplayServer::get_singleton()->window_get_size().height - viewport_height - storage->frame.current_rt->y;
} else {
viewport_y = storage->frame.current_rt->y;
}
@@ -3288,7 +3288,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
LightInstance *light = light_instance_owner.getornull(light_rid);
- if (light->light_ptr->type == VS::LIGHT_DIRECTIONAL) {
+ if (light->light_ptr->type == RS::LIGHT_DIRECTIONAL) {
render_directional_lights++;
//as going in reverse, directional lights are always first anyway
}
@@ -3322,7 +3322,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
reflection_probe_count = 0;
}
- if (env && env->bg_mode == VS::ENV_BG_CANVAS) {
+ if (env && env->bg_mode == RS::ENV_BG_CANVAS) {
// If using canvas background, copy 2d to screen copy texture
// TODO: When GLES2 renders to current_rt->mip_maps[], this copy will no longer be needed
_copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->copy_screen_effect.fbo);
@@ -3358,22 +3358,22 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
clear_color = Color(0, 0, 0, 0);
storage->frame.clear_request = false;
- } else if (!env || env->bg_mode == VS::ENV_BG_CLEAR_COLOR || env->bg_mode == VS::ENV_BG_SKY) {
+ } else if (!env || env->bg_mode == RS::ENV_BG_CLEAR_COLOR || env->bg_mode == RS::ENV_BG_SKY) {
if (storage->frame.clear_request) {
clear_color = storage->frame.clear_request_color;
storage->frame.clear_request = false;
}
- } else if (env->bg_mode == VS::ENV_BG_CANVAS || env->bg_mode == VS::ENV_BG_COLOR || env->bg_mode == VS::ENV_BG_COLOR_SKY) {
+ } else if (env->bg_mode == RS::ENV_BG_CANVAS || env->bg_mode == RS::ENV_BG_COLOR || env->bg_mode == RS::ENV_BG_COLOR_SKY) {
clear_color = env->bg_color;
storage->frame.clear_request = false;
- } else if (env->bg_mode == VS::ENV_BG_CAMERA_FEED) {
+ } else if (env->bg_mode == RS::ENV_BG_CAMERA_FEED) {
feed = CameraServer::get_singleton()->get_feed_by_id(env->camera_feed_id);
storage->frame.clear_request = false;
} else {
storage->frame.clear_request = false;
}
- if (!env || env->bg_mode != VS::ENV_BG_KEEP) {
+ if (!env || env->bg_mode != RS::ENV_BG_KEEP) {
glClearColor(clear_color.r, clear_color.g, clear_color.b, clear_color.a);
glClear(GL_COLOR_BUFFER_BIT);
}
@@ -3385,7 +3385,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
glDisable(GL_SCISSOR_TEST);
}
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1);
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -3396,15 +3396,15 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
if (env) {
switch (env->bg_mode) {
- case VS::ENV_BG_COLOR_SKY:
- case VS::ENV_BG_SKY: {
+ case RS::ENV_BG_COLOR_SKY:
+ case RS::ENV_BG_SKY: {
sky = storage->sky_owner.getornull(env->sky);
if (sky) {
env_radiance_tex = sky->radiance;
}
} break;
- case VS::ENV_BG_CAMERA_FEED: {
+ case RS::ENV_BG_CAMERA_FEED: {
if (feed.is_valid() && (feed->get_base_width() > 0) && (feed->get_base_height() > 0)) {
// copy our camera feed to our background
@@ -3419,12 +3419,12 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
if (feed->get_datatype() == CameraFeed::FEED_RGB) {
RID camera_RGBA = feed->get_texture(CameraServer::FEED_RGBA_IMAGE);
- VS::get_singleton()->texture_bind(camera_RGBA, 0);
+ RS::get_singleton()->texture_bind(camera_RGBA, 0);
} else if (feed->get_datatype() == CameraFeed::FEED_YCBCR) {
RID camera_YCbCr = feed->get_texture(CameraServer::FEED_YCBCR_IMAGE);
- VS::get_singleton()->texture_bind(camera_YCbCr, 0);
+ RS::get_singleton()->texture_bind(camera_YCbCr, 0);
storage->shaders.copy.set_conditional(CopyShaderGLES2::YCBCR_TO_RGB, true);
@@ -3432,8 +3432,8 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
RID camera_Y = feed->get_texture(CameraServer::FEED_Y_IMAGE);
RID camera_CbCr = feed->get_texture(CameraServer::FEED_CBCR_IMAGE);
- VS::get_singleton()->texture_bind(camera_Y, 0);
- VS::get_singleton()->texture_bind(camera_CbCr, 1);
+ RS::get_singleton()->texture_bind(camera_Y, 0);
+ RS::get_singleton()->texture_bind(camera_CbCr, 1);
storage->shaders.copy.set_conditional(CopyShaderGLES2::SEP_CBCR_TEXTURE, true);
storage->shaders.copy.set_conditional(CopyShaderGLES2::YCBCR_TO_RGB, true);
@@ -3444,8 +3444,8 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
storage->bind_quad_array();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableVertexAttribArray(VS::ARRAY_VERTEX);
- glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glDisableVertexAttribArray(RS::ARRAY_VERTEX);
+ glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// turn off everything used
@@ -3464,7 +3464,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
clear_color = Color(0.0, 1.0, 0.0, 1.0);
}
} break;
- case VS::ENV_BG_CANVAS: {
+ case RS::ENV_BG_CANVAS: {
// use screen copy as background
_copy_texture_to_buffer(storage->frame.current_rt->copy_screen_effect.color, current_fb);
} break;
@@ -3484,7 +3484,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
_render_render_list(render_list.elements, render_list.element_count, cam_transform, p_cam_projection, p_shadow_atlas, env, env_radiance_tex, 0.0, 0.0, reverse_cull, false, false);
// then draw the sky after
- if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) {
+ if (env && env->bg_mode == RS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) {
if (sky && sky->panorama.is_valid()) {
_draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation);
@@ -3616,7 +3616,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
// TODO directional light
- if (light->type == VS::LIGHT_DIRECTIONAL) {
+ if (light->type == RS::LIGHT_DIRECTIONAL) {
// set pssm stuff
// TODO set this only when changed
@@ -3651,7 +3651,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
width = light_instance->directional_rect.size.width;
height = light_instance->directional_rect.size.height;
- if (light->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
+ if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
width /= 2;
height /= 2;
@@ -3665,7 +3665,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
y += height;
}
- } else if (light->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
+ } else if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
height /= 2;
@@ -3676,10 +3676,10 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
}
}
- float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, light->param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE]);
- zfar = light->param[VS::LIGHT_PARAM_RANGE];
- bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS] * bias_mult;
- normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult;
+ float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, light->param[RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE]);
+ zfar = light->param[RS::LIGHT_PARAM_RANGE];
+ bias = light->param[RS::LIGHT_PARAM_SHADOW_BIAS] * bias_mult;
+ normal_bias = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult;
fbo = directional_shadow.fbo;
} else {
@@ -3708,9 +3708,9 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
width = shadow_size;
height = shadow_size;
- if (light->type == VS::LIGHT_OMNI) {
+ if (light->type == RS::LIGHT_OMNI) {
// cubemap only
- if (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) {
+ if (light->omni_shadow_mode == RS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) {
int cubemap_index = shadow_cubemaps.size() - 1;
// find an appropriate cubemap to render to
@@ -3727,7 +3727,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
light_transform = light_instance->shadow_transform[0].transform;
custom_vp_size = shadow_cubemaps[cubemap_index].size;
- zfar = light->param[VS::LIGHT_PARAM_RANGE];
+ zfar = light->param[RS::LIGHT_PARAM_RANGE];
current_cubemap = cubemap_index;
} else {
@@ -3736,7 +3736,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
light_projection = light_instance->shadow_transform[0].camera;
light_transform = light_instance->shadow_transform[0].transform;
- if (light->omni_shadow_detail == VS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
+ if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
height /= 2;
y += p_pass * height;
@@ -3747,22 +3747,22 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
state.dual_parbolloid_direction = p_pass == 0 ? 1.0 : -1.0;
flip_facing = (p_pass == 1);
- zfar = light->param[VS::LIGHT_PARAM_RANGE];
- bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS];
+ zfar = light->param[RS::LIGHT_PARAM_RANGE];
+ bias = light->param[RS::LIGHT_PARAM_SHADOW_BIAS];
state.dual_parbolloid_zfar = zfar;
state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH_DUAL_PARABOLOID, true);
}
- } else if (light->type == VS::LIGHT_SPOT) {
+ } else if (light->type == RS::LIGHT_SPOT) {
light_projection = light_instance->shadow_transform[0].camera;
light_transform = light_instance->shadow_transform[0].transform;
flip_facing = false;
- zfar = light->param[VS::LIGHT_PARAM_RANGE];
- bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS];
- normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS];
+ zfar = light->param[RS::LIGHT_PARAM_RANGE];
+ bias = light->param[RS::LIGHT_PARAM_SHADOW_BIAS];
+ normal_bias = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS];
}
}
@@ -3812,7 +3812,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH_DUAL_PARABOLOID, false);
// convert cubemap to dual paraboloid if needed
- if (light->type == VS::LIGHT_OMNI && (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) && p_pass == 5) {
+ if (light->type == RS::LIGHT_OMNI && (light->omni_shadow_mode == RS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) && p_pass == 5) {
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
glBindFramebuffer(GL_FRAMEBUFFER, shadow_atlas->fbo);
@@ -3827,14 +3827,14 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::Z_FLIP, i == 1);
state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::Z_NEAR, light_projection.get_z_near());
state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::Z_FAR, light_projection.get_z_far());
- state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::BIAS, light->param[VS::LIGHT_PARAM_SHADOW_BIAS]);
+ state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::BIAS, light->param[RS::LIGHT_PARAM_SHADOW_BIAS]);
uint32_t local_width = width;
uint32_t local_height = height;
uint32_t local_x = x;
uint32_t local_y = y;
- if (light->omni_shadow_detail == VS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
+ if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
local_height /= 2;
local_y += i * local_height;
} else {
@@ -3922,7 +3922,7 @@ bool RasterizerSceneGLES2::free(RID p_rid) {
return true;
}
-void RasterizerSceneGLES2::set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {
+void RasterizerSceneGLES2::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {
}
void RasterizerSceneGLES2::initialize() {
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index 174cdd8e2e..6d0a5a45ca 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -236,7 +236,7 @@ public:
/* ENVIRONMENT API */
struct Environment {
- VS::EnvironmentBG bg_mode;
+ RS::EnvironmentBG bg_mode;
RID sky;
float sky_custom_fov;
@@ -259,7 +259,7 @@ public:
float glow_intensity;
float glow_strength;
float glow_bloom;
- VS::EnvironmentGlowBlendMode glow_blend_mode;
+ RS::EnvironmentGlowBlendMode glow_blend_mode;
float glow_hdr_bleed_threshold;
float glow_hdr_bleed_scale;
float glow_hdr_luminance_cap;
@@ -269,13 +269,13 @@ public:
float dof_blur_far_distance;
float dof_blur_far_transition;
float dof_blur_far_amount;
- VS::EnvironmentDOFBlurQuality dof_blur_far_quality;
+ RS::EnvironmentDOFBlurQuality dof_blur_far_quality;
bool dof_blur_near_enabled;
float dof_blur_near_distance;
float dof_blur_near_transition;
float dof_blur_near_amount;
- VS::EnvironmentDOFBlurQuality dof_blur_near_quality;
+ RS::EnvironmentDOFBlurQuality dof_blur_near_quality;
bool adjustments_enabled;
float adjustments_brightness;
@@ -300,7 +300,7 @@ public:
float fog_height_curve;
Environment() :
- bg_mode(VS::ENV_BG_CLEAR_COLOR),
+ bg_mode(RS::ENV_BG_CLEAR_COLOR),
sky_custom_fov(0.0),
bg_energy(1.0),
sky_ambient(0),
@@ -313,7 +313,7 @@ public:
glow_intensity(0.8),
glow_strength(1.0),
glow_bloom(0.0),
- glow_blend_mode(VS::ENV_GLOW_BLEND_MODE_SOFTLIGHT),
+ glow_blend_mode(RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT),
glow_hdr_bleed_threshold(1.0),
glow_hdr_bleed_scale(2.0),
glow_hdr_luminance_cap(12.0),
@@ -322,12 +322,12 @@ public:
dof_blur_far_distance(10),
dof_blur_far_transition(5),
dof_blur_far_amount(0.1),
- dof_blur_far_quality(VS::ENV_DOF_BLUR_QUALITY_MEDIUM),
+ dof_blur_far_quality(RS::ENV_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(VS::ENV_DOF_BLUR_QUALITY_MEDIUM),
+ dof_blur_near_quality(RS::ENV_DOF_BLUR_QUALITY_MEDIUM),
adjustments_enabled(false),
adjustments_brightness(1.0),
adjustments_contrast(1.0),
@@ -353,7 +353,7 @@ public:
virtual RID environment_create();
- virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg);
+ virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg);
virtual void environment_set_sky(RID p_env, RID p_sky);
virtual void environment_set_sky_custom_fov(RID p_env, float p_scale);
virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation);
@@ -363,15 +363,15 @@ public:
virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0);
virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id);
- virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality);
- virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality);
- virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale);
+ virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality);
+ virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality);
+ virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale);
virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture);
virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness);
- virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness);
+ virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness);
- virtual void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale);
+ virtual void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale);
virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp);
@@ -381,7 +381,7 @@ public:
virtual bool is_environment(RID p_env);
- virtual VS::EnvironmentBG environment_get_background(RID p_env);
+ virtual RS::EnvironmentBG environment_get_background(RID p_env);
virtual int environment_get_canvas_max_layer(RID p_env);
/* LIGHT INSTANCE */
@@ -650,7 +650,7 @@ public:
virtual bool free(RID p_rid);
virtual void set_scene_pass(uint64_t p_pass);
- virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw);
+ virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw);
void iteration();
void initialize();
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index f76c7da8e1..4337d2a833 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -34,7 +34,7 @@
#include "core/project_settings.h"
#include "rasterizer_canvas_gles2.h"
#include "rasterizer_scene_gles2.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/shader_language.h"
GLuint RasterizerStorageGLES2::system_fbo = 0;
@@ -127,11 +127,11 @@ PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glCompressedTexSubImage3DOES;
void RasterizerStorageGLES2::bind_quad_array() const {
glBindBuffer(GL_ARRAY_BUFFER, resources.quadie);
- glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0);
- glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8));
+ glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0);
+ glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8));
- glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ glEnableVertexAttribArray(RS::ARRAY_VERTEX);
+ glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
}
Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const {
@@ -549,15 +549,15 @@ RID RasterizerStorageGLES2::texture_create() {
return texture_owner.make_rid(texture);
}
-void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VisualServer::TextureType p_type, uint32_t p_flags) {
+void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingServer::TextureType p_type, uint32_t p_flags) {
GLenum format;
GLenum internal_format;
GLenum type;
bool compressed = false;
- if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) {
- p_flags &= ~VS::TEXTURE_FLAG_MIPMAPS; // no mipies for video
+ if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
+ p_flags &= ~RS::TEXTURE_FLAG_MIPMAPS; // no mipies for video
}
Texture *texture = texture_owner.getornull(p_texture);
@@ -570,15 +570,15 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
texture->type = p_type;
switch (p_type) {
- case VS::TEXTURE_TYPE_2D: {
+ case RS::TEXTURE_TYPE_2D: {
texture->target = GL_TEXTURE_2D;
texture->images.resize(1);
} break;
- case VS::TEXTURE_TYPE_CUBEMAP: {
+ case RS::TEXTURE_TYPE_CUBEMAP: {
texture->target = GL_TEXTURE_CUBE_MAP;
texture->images.resize(6);
} break;
- case VS::TEXTURE_TYPE_2D_ARRAY: {
+ case RS::TEXTURE_TYPE_2D_ARRAY: {
if (config.texture_array_supported) {
texture->target = GL_TEXTURE_2D_ARRAY;
texture->images.resize(p_depth_3d);
@@ -587,7 +587,7 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
return;
}
} break;
- case VS::TEXTURE_TYPE_3D: {
+ case RS::TEXTURE_TYPE_3D: {
if (config.texture_3d_supported) {
texture->target = GL_TEXTURE_3D;
texture->images.resize(p_depth_3d);
@@ -611,12 +611,12 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
bool is_po2 = p_width == po2_width && p_height == po2_height;
- if (!is_po2 && (p_flags & VS::TEXTURE_FLAG_REPEAT || p_flags & VS::TEXTURE_FLAG_MIPMAPS)) {
+ if (!is_po2 && (p_flags & RS::TEXTURE_FLAG_REPEAT || p_flags & RS::TEXTURE_FLAG_MIPMAPS)) {
- if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) {
+ if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
//not supported
ERR_PRINT("Streaming texture for non power of 2 or has mipmaps on this hardware: " + texture->path + "'. Mipmaps and repeat disabled.");
- texture->flags &= ~(VS::TEXTURE_FLAG_REPEAT | VS::TEXTURE_FLAG_MIPMAPS);
+ texture->flags &= ~(RS::TEXTURE_FLAG_REPEAT | RS::TEXTURE_FLAG_MIPMAPS);
} else {
texture->alloc_height = po2_height;
texture->alloc_width = po2_width;
@@ -640,7 +640,7 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
glBindTexture(texture->target, texture->tex_id);
#if defined(GLES_OVER_GL) || defined(ANDROID_ENABLED)
- if ((p_type == VS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == VS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) {
+ if ((p_type == RS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == RS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) {
int width = p_width;
int height = p_height;
@@ -648,7 +648,7 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
int mipmaps = 0;
- while (width > 0 || height > 0 || (p_type == VS::TEXTURE_TYPE_3D && depth > 0)) {
+ while (width > 0 || height > 0 || (p_type == RS::TEXTURE_TYPE_3D && depth > 0)) {
width = MAX(1, width);
height = MAX(1, height);
depth = MAX(1, depth);
@@ -658,13 +658,13 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
width /= 2;
height /= 2;
- if (p_type == VS::TEXTURE_TYPE_3D) {
+ if (p_type == RS::TEXTURE_TYPE_3D) {
depth /= 2;
}
mipmaps++;
- if (!(p_flags & VS::TEXTURE_FLAG_MIPMAPS))
+ if (!(p_flags & RS::TEXTURE_FLAG_MIPMAPS))
break;
}
#ifdef GLES_OVER_GL
@@ -674,7 +674,7 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
} else
#endif
- if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) {
+ if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
//prealloc if video
glTexImage2D(texture->target, 0, internal_format, texture->alloc_width, texture->alloc_height, 0, format, type, NULL);
}
@@ -686,7 +686,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
- if ((texture->type == VS::TEXTURE_TYPE_2D_ARRAY && !config.texture_array_supported) || (texture->type == VS::TEXTURE_TYPE_3D && !config.texture_3d_supported)) {
+ if ((texture->type == RS::TEXTURE_TYPE_2D_ARRAY && !config.texture_array_supported) || (texture->type == RS::TEXTURE_TYPE_3D && !config.texture_3d_supported)) {
return;
}
ERR_FAIL_COND(!texture->active);
@@ -699,7 +699,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
GLenum internal_format;
bool compressed = false;
- if (config.keep_original_textures && !(texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING)) {
+ if (config.keep_original_textures && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) {
texture->images.write[p_layer] = p_image;
}
@@ -717,7 +717,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
img->resize_to_po2(false);
}
- if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING)) {
+ if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) {
texture->alloc_height = MAX(1, texture->alloc_height / 2);
texture->alloc_width = MAX(1, texture->alloc_width / 2);
@@ -734,17 +734,17 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
GLenum blit_target = GL_TEXTURE_2D;
switch (texture->type) {
- case VS::TEXTURE_TYPE_2D: {
+ case RS::TEXTURE_TYPE_2D: {
blit_target = GL_TEXTURE_2D;
} break;
- case VS::TEXTURE_TYPE_CUBEMAP: {
+ case RS::TEXTURE_TYPE_CUBEMAP: {
ERR_FAIL_INDEX(p_layer, 6);
blit_target = _cube_side_enum[p_layer];
} break;
- case VS::TEXTURE_TYPE_2D_ARRAY: {
+ case RS::TEXTURE_TYPE_2D_ARRAY: {
blit_target = GL_TEXTURE_2D_ARRAY;
} break;
- case VS::TEXTURE_TYPE_3D: {
+ case RS::TEXTURE_TYPE_3D: {
blit_target = GL_TEXTURE_3D;
} break;
}
@@ -758,17 +758,17 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
texture->ignore_mipmaps = compressed && !img->has_mipmaps();
- if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps)
+ if ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps)
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
else {
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
+ if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
}
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
+ if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
@@ -777,9 +777,9 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
- if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
+ if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
- if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) {
+ if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
} else {
@@ -793,7 +793,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
- int mipmaps = ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1;
+ int mipmaps = ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1;
int w = img->get_width();
int h = img->get_height();
@@ -804,7 +804,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
int size, ofs;
img->get_mipmap_offset_and_size(i, ofs, size);
- if (texture->type == VS::TEXTURE_TYPE_2D || texture->type == VS::TEXTURE_TYPE_CUBEMAP) {
+ if (texture->type == RS::TEXTURE_TYPE_2D || texture->type == RS::TEXTURE_TYPE_CUBEMAP) {
if (compressed) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
@@ -816,7 +816,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
} else {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- if (texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) {
+ if (texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
glTexSubImage2D(blit_target, i, 0, 0, w, h, format, type, &read[ofs]);
} else {
glTexImage2D(blit_target, i, internal_format, w, h, 0, format, type, &read[ofs]);
@@ -854,7 +854,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
texture->stored_cube_sides |= (1 << p_layer);
- if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && mipmaps == 1 && !texture->ignore_mipmaps && (texture->type != VS::TEXTURE_TYPE_CUBEMAP || texture->stored_cube_sides == (1 << 6) - 1)) {
+ if ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && mipmaps == 1 && !texture->ignore_mipmaps && (texture->type != RS::TEXTURE_TYPE_CUBEMAP || texture->stored_cube_sides == (1 << 6) - 1)) {
//generate mipmaps if they were requested and the image does not contain them
glGenerateMipmap(texture->target);
}
@@ -875,7 +875,7 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
ERR_FAIL_COND_V(!texture->active, Ref<Image>());
ERR_FAIL_COND_V(texture->data_size == 0 && !texture->render_target, Ref<Image>());
- if (texture->type == VS::TEXTURE_TYPE_CUBEMAP && p_layer < 6 && p_layer >= 0 && !texture->images[p_layer].is_null()) {
+ if (texture->type == RS::TEXTURE_TYPE_CUBEMAP && p_layer < 6 && p_layer >= 0 && !texture->images[p_layer].is_null()) {
return texture->images[p_layer];
}
@@ -997,16 +997,16 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
- bool had_mipmaps = texture->flags & VS::TEXTURE_FLAG_MIPMAPS;
+ bool had_mipmaps = texture->flags & RS::TEXTURE_FLAG_MIPMAPS;
texture->flags = p_flags;
glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target, texture->tex_id);
- if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
+ if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
- if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) {
+ if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
} else {
@@ -1019,21 +1019,21 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
- if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) {
+ if ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) {
if (!had_mipmaps && texture->mipmaps == 1) {
glGenerateMipmap(texture->target);
}
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
} else {
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
+ if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
}
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
+ if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
@@ -1059,10 +1059,10 @@ Image::Format RasterizerStorageGLES2::texture_get_format(RID p_texture) const {
return texture->format;
}
-VisualServer::TextureType RasterizerStorageGLES2::texture_get_type(RID p_texture) const {
+RenderingServer::TextureType RasterizerStorageGLES2::texture_get_type(RID p_texture) const {
Texture *texture = texture_owner.getornull(p_texture);
- ERR_FAIL_COND_V(!texture, VS::TEXTURE_TYPE_2D);
+ ERR_FAIL_COND_V(!texture, RS::TEXTURE_TYPE_2D);
return texture->type;
}
@@ -1135,7 +1135,7 @@ String RasterizerStorageGLES2::texture_get_path(RID p_texture) const {
return texture->path;
}
-void RasterizerStorageGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info) {
+void RasterizerStorageGLES2::texture_debug_usage(List<RS::TextureInfo> *r_info) {
List<RID> textures;
texture_owner.get_owned_list(&textures);
@@ -1144,7 +1144,7 @@ void RasterizerStorageGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info)
Texture *t = texture_owner.getornull(E->get());
if (!t)
continue;
- VS::TextureInfo tinfo;
+ RS::TextureInfo tinfo;
tinfo.path = t->path;
tinfo.format = t->format;
tinfo.width = t->alloc_width;
@@ -1200,7 +1200,7 @@ void RasterizerStorageGLES2::texture_set_force_redraw_if_visible(RID p_texture,
texture->redraw_if_visible = p_enable;
}
-void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
+void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1208,7 +1208,7 @@ void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, Visua
texture->detect_3d_ud = p_userdata;
}
-void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
+void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1216,7 +1216,7 @@ void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, Vis
texture->detect_srgb_ud = p_userdata;
}
-void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
+void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1265,7 +1265,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
- for (int i = 0; i < VS::ARRAY_MAX - 1; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX - 1; i++) {
glDisableVertexAttribArray(i);
}
}
@@ -1397,7 +1397,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
RID RasterizerStorageGLES2::shader_create() {
Shader *shader = memnew(Shader);
- shader->mode = VS::SHADER_SPATIAL;
+ shader->mode = RS::SHADER_SPATIAL;
shader->shader = &scene->state.scene_shader;
RID rid = shader_owner.make_rid(shader);
_shader_make_dirty(shader);
@@ -1421,16 +1421,16 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
shader->code = p_code;
String mode_string = ShaderLanguage::get_shader_type(p_code);
- VS::ShaderMode mode;
+ RS::ShaderMode mode;
if (mode_string == "canvas_item")
- mode = VS::SHADER_CANVAS_ITEM;
+ mode = RS::SHADER_CANVAS_ITEM;
else if (mode_string == "particles")
- mode = VS::SHADER_PARTICLES;
+ mode = RS::SHADER_PARTICLES;
else if (mode_string == "sky")
- mode = VS::SHADER_SKY;
+ mode = RS::SHADER_SKY;
else
- mode = VS::SHADER_SPATIAL;
+ mode = RS::SHADER_SPATIAL;
if (shader->custom_code_id && mode != shader->mode) {
shader->shader->free_custom_shader(shader->custom_code_id);
@@ -1440,10 +1440,10 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
shader->mode = mode;
// TODO handle all shader types
- if (mode == VS::SHADER_CANVAS_ITEM) {
+ if (mode == RS::SHADER_CANVAS_ITEM) {
shader->shader = &canvas->state.canvas_shader;
- } else if (mode == VS::SHADER_SPATIAL) {
+ } else if (mode == RS::SHADER_SPATIAL) {
shader->shader = &scene->state.scene_shader;
} else {
return;
@@ -1481,7 +1481,7 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
switch (p_shader->mode) {
- case VS::SHADER_CANVAS_ITEM: {
+ case RS::SHADER_CANVAS_ITEM: {
p_shader->canvas_item.light_mode = Shader::CanvasItem::LIGHT_MODE_NORMAL;
p_shader->canvas_item.blend_mode = Shader::CanvasItem::BLEND_MODE_MIX;
@@ -1508,7 +1508,7 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
actions->uniforms = &p_shader->uniforms;
} break;
- case VS::SHADER_SPATIAL: {
+ case RS::SHADER_SPATIAL: {
p_shader->spatial.blend_mode = Shader::Spatial::BLEND_MODE_MIX;
p_shader->spatial.depth_draw_mode = Shader::Spatial::DEPTH_DRAW_OPAQUE;
p_shader->spatial.cull_mode = Shader::Spatial::CULL_MODE_BACK;
@@ -1949,8 +1949,8 @@ void RasterizerStorageGLES2::material_remove_instance_owner(RID p_material, Rast
}
void RasterizerStorageGLES2::material_set_render_priority(RID p_material, int priority) {
- ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
- ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
+ ERR_FAIL_COND(priority < RS::MATERIAL_RENDER_PRIORITY_MIN);
+ ERR_FAIL_COND(priority > RS::MATERIAL_RENDER_PRIORITY_MAX);
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1975,7 +1975,7 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
bool can_cast_shadow = false;
bool is_animated = false;
- if (p_material->shader && p_material->shader->mode == VS::SHADER_SPATIAL) {
+ if (p_material->shader && p_material->shader->mode == RS::SHADER_SPATIAL) {
if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX &&
(!p_material->shader->spatial.uses_alpha || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) {
@@ -2087,14 +2087,14 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
uint32_t p_format = format;
- static int src_size[VS::ARRAY_MAX];
- static int dst_size[VS::ARRAY_MAX];
- static int to_convert[VS::ARRAY_MAX];
+ static int src_size[RS::ARRAY_MAX];
+ static int dst_size[RS::ARRAY_MAX];
+ static int to_convert[RS::ARRAY_MAX];
int src_stride = 0;
int dst_stride = 0;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
to_convert[i] = 0;
if (!(p_format & (1 << i))) {
@@ -2105,11 +2105,11 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
- if (p_format & VS::ARRAY_COMPRESS_VERTEX) {
+ if (p_format & RS::ARRAY_COMPRESS_VERTEX) {
- if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
src_size[i] = 4;
dst_size[i] = 8;
to_convert[i] = 2;
@@ -2119,10 +2119,10 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
to_convert[i] = 3;
}
- format &= ~VS::ARRAY_COMPRESS_VERTEX;
+ format &= ~RS::ARRAY_COMPRESS_VERTEX;
} else {
- if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
src_size[i] = 8;
dst_size[i] = 8;
} else {
@@ -2132,9 +2132,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
- if (p_format & VS::ARRAY_COMPRESS_NORMAL) {
+ if (p_format & RS::ARRAY_COMPRESS_NORMAL) {
src_size[i] = 4;
dst_size[i] = 4;
} else {
@@ -2143,9 +2143,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
- if (p_format & VS::ARRAY_COMPRESS_TANGENT) {
+ if (p_format & RS::ARRAY_COMPRESS_TANGENT) {
src_size[i] = 4;
dst_size[i] = 4;
} else {
@@ -2154,9 +2154,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
- if (p_format & VS::ARRAY_COMPRESS_COLOR) {
+ if (p_format & RS::ARRAY_COMPRESS_COLOR) {
src_size[i] = 4;
dst_size[i] = 4;
} else {
@@ -2165,12 +2165,12 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
- if (p_format & VS::ARRAY_COMPRESS_TEX_UV) {
+ if (p_format & RS::ARRAY_COMPRESS_TEX_UV) {
src_size[i] = 4;
to_convert[i] = 2;
- format &= ~VS::ARRAY_COMPRESS_TEX_UV;
+ format &= ~RS::ARRAY_COMPRESS_TEX_UV;
} else {
src_size[i] = 8;
}
@@ -2178,12 +2178,12 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
dst_size[i] = 8;
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
- if (p_format & VS::ARRAY_COMPRESS_TEX_UV2) {
+ if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) {
src_size[i] = 4;
to_convert[i] = 2;
- format &= ~VS::ARRAY_COMPRESS_TEX_UV2;
+ format &= ~RS::ARRAY_COMPRESS_TEX_UV2;
} else {
src_size[i] = 8;
}
@@ -2191,9 +2191,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
dst_size[i] = 8;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
- if (p_format & VS::ARRAY_FLAG_USE_16_BIT_BONES) {
+ if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) {
src_size[i] = 8;
dst_size[i] = 8;
} else {
@@ -2202,9 +2202,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
- if (p_format & VS::ARRAY_COMPRESS_WEIGHTS) {
+ if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) {
src_size[i] = 8;
dst_size[i] = 8;
} else {
@@ -2213,7 +2213,7 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
src_size[i] = 0;
dst_size[i] = 0;
@@ -2234,7 +2234,7 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
int src_offset = 0;
int dst_offset = 0;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
if (src_size[i] == 0) {
continue; //no go
@@ -2272,27 +2272,27 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
return ret;
}
-void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
+void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
- ERR_FAIL_COND(!(p_format & VS::ARRAY_FORMAT_VERTEX));
+ ERR_FAIL_COND(!(p_format & RS::ARRAY_FORMAT_VERTEX));
//must have index and bones, both.
{
- uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS;
+ uint32_t bones_weight = RS::ARRAY_FORMAT_BONES | RS::ARRAY_FORMAT_WEIGHTS;
ERR_FAIL_COND_MSG((p_format & bones_weight) && (p_format & bones_weight) != bones_weight, "Array must have both bones and weights in format or none.");
}
//bool has_morph = p_blend_shapes.size();
- Surface::Attrib attribs[VS::ARRAY_MAX];
+ Surface::Attrib attribs[RS::ARRAY_MAX];
int stride = 0;
bool uses_half_float = false;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
attribs[i].index = i;
@@ -2308,15 +2308,15 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
- if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
attribs[i].size = 2;
} else {
- attribs[i].size = (p_format & VS::ARRAY_COMPRESS_VERTEX) ? 4 : 3;
+ attribs[i].size = (p_format & RS::ARRAY_COMPRESS_VERTEX) ? 4 : 3;
}
- if (p_format & VS::ARRAY_COMPRESS_VERTEX) {
+ if (p_format & RS::ARRAY_COMPRESS_VERTEX) {
attribs[i].type = _GL_HALF_FLOAT_OES;
stride += attribs[i].size * 2;
uses_half_float = true;
@@ -2328,11 +2328,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
attribs[i].normalized = GL_FALSE;
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
attribs[i].size = 3;
- if (p_format & VS::ARRAY_COMPRESS_NORMAL) {
+ if (p_format & RS::ARRAY_COMPRESS_NORMAL) {
attribs[i].type = GL_BYTE;
stride += 4; //pad extra byte
attribs[i].normalized = GL_TRUE;
@@ -2343,11 +2343,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
attribs[i].size = 4;
- if (p_format & VS::ARRAY_COMPRESS_TANGENT) {
+ if (p_format & RS::ARRAY_COMPRESS_TANGENT) {
attribs[i].type = GL_BYTE;
stride += 4;
attribs[i].normalized = GL_TRUE;
@@ -2358,11 +2358,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
attribs[i].size = 4;
- if (p_format & VS::ARRAY_COMPRESS_COLOR) {
+ if (p_format & RS::ARRAY_COMPRESS_COLOR) {
attribs[i].type = GL_UNSIGNED_BYTE;
stride += 4;
attribs[i].normalized = GL_TRUE;
@@ -2373,11 +2373,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
attribs[i].size = 2;
- if (p_format & VS::ARRAY_COMPRESS_TEX_UV) {
+ if (p_format & RS::ARRAY_COMPRESS_TEX_UV) {
attribs[i].type = _GL_HALF_FLOAT_OES;
stride += 4;
uses_half_float = true;
@@ -2389,11 +2389,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
attribs[i].normalized = GL_FALSE;
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
attribs[i].size = 2;
- if (p_format & VS::ARRAY_COMPRESS_TEX_UV2) {
+ if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) {
attribs[i].type = _GL_HALF_FLOAT_OES;
stride += 4;
uses_half_float = true;
@@ -2404,11 +2404,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
attribs[i].normalized = GL_FALSE;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
attribs[i].size = 4;
- if (p_format & VS::ARRAY_FLAG_USE_16_BIT_BONES) {
+ if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) {
attribs[i].type = GL_UNSIGNED_SHORT;
stride += 8;
} else {
@@ -2420,11 +2420,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
attribs[i].integer = true;
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
attribs[i].size = 4;
- if (p_format & VS::ARRAY_COMPRESS_WEIGHTS) {
+ if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) {
attribs[i].type = GL_UNSIGNED_SHORT;
stride += 8;
@@ -2436,7 +2436,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
attribs[i].size = 1;
@@ -2454,7 +2454,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
}
- for (int i = 0; i < VS::ARRAY_MAX - 1; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX - 1; i++) {
attribs[i].stride = stride;
}
@@ -2500,9 +2500,9 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
return; //do not go any further, above function used unpacked stuff will be used instead.
}
- if (p_format & VS::ARRAY_FORMAT_INDEX) {
+ if (p_format & RS::ARRAY_FORMAT_INDEX) {
- index_array_size = attribs[VS::ARRAY_INDEX].stride * p_index_count;
+ index_array_size = attribs[RS::ARRAY_INDEX].stride * p_index_count;
}
ERR_FAIL_COND(p_index_array.size() != index_array_size);
@@ -2545,7 +2545,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
surface->skeleton_bone_used.write[i] = !(surface->skeleton_bone_aabb[i].size.x < 0 || surface->skeleton_bone_aabb[i].size.y < 0 || surface->skeleton_bone_aabb[i].size.z < 0);
}
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
surface->attribs[i] = attribs[i];
}
@@ -2555,11 +2555,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
glGenBuffers(1, &surface->vertex_id);
glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id);
- glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), (p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), (p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- if (p_format & VS::ARRAY_FORMAT_INDEX) {
+ if (p_format & RS::ARRAY_FORMAT_INDEX) {
const uint8_t *ir = p_index_array.ptr();
glGenBuffers(1, &surface->index_id);
@@ -2616,16 +2616,16 @@ int RasterizerStorageGLES2::mesh_get_blend_shape_count(RID p_mesh) const {
return mesh->blend_shape_count;
}
-void RasterizerStorageGLES2::mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) {
+void RasterizerStorageGLES2::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
mesh->blend_shape_mode = p_mode;
}
-VS::BlendShapeMode RasterizerStorageGLES2::mesh_get_blend_shape_mode(RID p_mesh) const {
+RS::BlendShapeMode RasterizerStorageGLES2::mesh_get_blend_shape_mode(RID p_mesh) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, VS::BLEND_SHAPE_MODE_NORMALIZED);
+ ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
return mesh->blend_shape_mode;
}
@@ -2723,10 +2723,10 @@ uint32_t RasterizerStorageGLES2::mesh_surface_get_format(RID p_mesh, int p_surfa
return mesh->surfaces[p_surface]->format;
}
-VS::PrimitiveType RasterizerStorageGLES2::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
+RS::PrimitiveType RasterizerStorageGLES2::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_MAX);
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), VS::PRIMITIVE_MAX);
+ ERR_FAIL_COND_V(!mesh, RS::PRIMITIVE_MAX);
+ ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), RS::PRIMITIVE_MAX);
return mesh->surfaces[p_surface]->primitive;
}
@@ -2827,7 +2827,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
for (int i = 0; i < mesh->surfaces.size(); i++) {
AABB laabb;
- if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
+ if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
int bs = mesh->surfaces[i]->skeleton_bone_aabb.size();
const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
@@ -2939,7 +2939,7 @@ RID RasterizerStorageGLES2::multimesh_create() {
return multimesh_owner.make_rid(multimesh);
}
-void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data) {
+void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, RS::MultimeshColorFormat p_color_format, RS::MultimeshCustomDataFormat p_data) {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
@@ -2957,23 +2957,23 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances
multimesh->data.resize(0);
}
- if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) {
+ if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) {
multimesh->xform_floats = 8;
} else {
multimesh->xform_floats = 12;
}
- if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
multimesh->color_floats = 1;
- } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) {
+ } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) {
multimesh->color_floats = 4;
} else {
multimesh->color_floats = 0;
}
- if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
multimesh->custom_data_floats = 1;
- } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) {
+ } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) {
multimesh->custom_data_floats = 4;
} else {
multimesh->custom_data_floats = 0;
@@ -2987,7 +2987,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances
int color_from = 0;
int custom_data_from = 0;
- if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) {
+ if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) {
multimesh->data.write[i + 0] = 1.0;
multimesh->data.write[i + 1] = 0.0;
multimesh->data.write[i + 2] = 0.0;
@@ -3015,7 +3015,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances
custom_data_from = 12;
}
- if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
union {
uint32_t colu;
float colf;
@@ -3024,7 +3024,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances
cu.colu = 0xFFFFFFFF;
multimesh->data.write[i + color_from + 0] = cu.colf;
custom_data_from = color_from + 1;
- } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) {
+ } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) {
multimesh->data.write[i + color_from + 0] = 1.0;
multimesh->data.write[i + color_from + 1] = 1.0;
multimesh->data.write[i + color_from + 2] = 1.0;
@@ -3032,7 +3032,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances
custom_data_from = color_from + 4;
}
- if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
union {
uint32_t colu;
float colf;
@@ -3040,7 +3040,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances
cu.colu = 0;
multimesh->data.write[i + custom_data_from + 0] = cu.colf;
- } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) {
+ } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) {
multimesh->data.write[i + custom_data_from + 0] = 0.0;
multimesh->data.write[i + custom_data_from + 1] = 0.0;
multimesh->data.write[i + custom_data_from + 2] = 0.0;
@@ -3094,7 +3094,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_transform(RID p_multimesh, i
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->size);
- ERR_FAIL_COND(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D);
+ ERR_FAIL_COND(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D);
int stride = multimesh->color_floats + multimesh->custom_data_floats + multimesh->xform_floats;
@@ -3125,7 +3125,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_transform_2d(RID p_multimesh
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->size);
- ERR_FAIL_COND(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_3D);
+ ERR_FAIL_COND(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_3D);
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index];
@@ -3151,13 +3151,13 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->size);
- ERR_FAIL_COND(multimesh->color_format == VS::MULTIMESH_COLOR_NONE);
- ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_MAX);
+ ERR_FAIL_COND(multimesh->color_format == RS::MULTIMESH_COLOR_NONE);
+ ERR_FAIL_INDEX(multimesh->color_format, RS::MULTIMESH_COLOR_MAX);
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
- if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
uint8_t *data8 = (uint8_t *)dataptr;
data8[0] = CLAMP(p_color.r * 255.0, 0, 255);
@@ -3165,7 +3165,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p
data8[2] = CLAMP(p_color.b * 255.0, 0, 255);
data8[3] = CLAMP(p_color.a * 255.0, 0, 255);
- } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) {
+ } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) {
dataptr[0] = p_color.r;
dataptr[1] = p_color.g;
dataptr[2] = p_color.b;
@@ -3184,13 +3184,13 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh,
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->size);
- ERR_FAIL_COND(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE);
- ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX);
+ ERR_FAIL_COND(multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_NONE);
+ ERR_FAIL_INDEX(multimesh->custom_data_format, RS::MULTIMESH_CUSTOM_DATA_MAX);
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
- if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
uint8_t *data8 = (uint8_t *)dataptr;
data8[0] = CLAMP(p_custom_data.r * 255.0, 0, 255);
@@ -3198,7 +3198,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh,
data8[2] = CLAMP(p_custom_data.b * 255.0, 0, 255);
data8[3] = CLAMP(p_custom_data.a * 255.0, 0, 255);
- } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) {
+ } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) {
dataptr[0] = p_custom_data.r;
dataptr[1] = p_custom_data.g;
dataptr[2] = p_custom_data.b;
@@ -3224,7 +3224,7 @@ Transform RasterizerStorageGLES2::multimesh_instance_get_transform(RID p_multime
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform());
ERR_FAIL_INDEX_V(p_index, multimesh->size, Transform());
- ERR_FAIL_COND_V(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D, Transform());
+ ERR_FAIL_COND_V(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D, Transform());
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index];
@@ -3251,7 +3251,7 @@ Transform2D RasterizerStorageGLES2::multimesh_instance_get_transform_2d(RID p_mu
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform2D());
ERR_FAIL_INDEX_V(p_index, multimesh->size, Transform2D());
- ERR_FAIL_COND_V(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_3D, Transform2D());
+ ERR_FAIL_COND_V(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_3D, Transform2D());
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index];
@@ -3272,13 +3272,13 @@ Color RasterizerStorageGLES2::multimesh_instance_get_color(RID p_multimesh, int
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
- ERR_FAIL_COND_V(multimesh->color_format == VS::MULTIMESH_COLOR_NONE, Color());
- ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_MAX, Color());
+ ERR_FAIL_COND_V(multimesh->color_format == RS::MULTIMESH_COLOR_NONE, Color());
+ ERR_FAIL_INDEX_V(multimesh->color_format, RS::MULTIMESH_COLOR_MAX, Color());
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
- if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) {
+ if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
union {
uint32_t colu;
float colf;
@@ -3288,7 +3288,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_color(RID p_multimesh, int
return Color::hex(BSWAP32(cu.colu));
- } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) {
+ } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) {
Color c;
c.r = dataptr[0];
c.g = dataptr[1];
@@ -3305,13 +3305,13 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
- ERR_FAIL_COND_V(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE, Color());
- ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX, Color());
+ ERR_FAIL_COND_V(multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_NONE, Color());
+ ERR_FAIL_INDEX_V(multimesh->custom_data_format, RS::MULTIMESH_CUSTOM_DATA_MAX, Color());
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
- if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) {
+ if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
union {
uint32_t colu;
float colf;
@@ -3321,7 +3321,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh
return Color::hex(BSWAP32(cu.colu));
- } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) {
+ } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) {
Color c;
c.r = dataptr[0];
c.g = dataptr[1];
@@ -3400,7 +3400,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() {
AABB aabb;
- if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) {
+ if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) {
for (int i = 0; i < count; i += stride) {
@@ -3472,7 +3472,7 @@ RID RasterizerStorageGLES2::immediate_create() {
return immediate_owner.make_rid(im);
}
-void RasterizerStorageGLES2::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) {
+void RasterizerStorageGLES2::immediate_begin(RID p_immediate, RS::PrimitiveType p_primitive, RID p_texture) {
Immediate *im = immediate_owner.getornull(p_immediate);
ERR_FAIL_COND(!im);
ERR_FAIL_COND(im->building);
@@ -3499,17 +3499,17 @@ void RasterizerStorageGLES2::immediate_vertex(RID p_immediate, const Vector3 &p_
im->aabb.expand_to(p_vertex);
}
- if (im->mask & VS::ARRAY_FORMAT_NORMAL)
+ if (im->mask & RS::ARRAY_FORMAT_NORMAL)
c->normals.push_back(chunk_normal);
- if (im->mask & VS::ARRAY_FORMAT_TANGENT)
+ if (im->mask & RS::ARRAY_FORMAT_TANGENT)
c->tangents.push_back(chunk_tangent);
- if (im->mask & VS::ARRAY_FORMAT_COLOR)
+ if (im->mask & RS::ARRAY_FORMAT_COLOR)
c->colors.push_back(chunk_color);
- if (im->mask & VS::ARRAY_FORMAT_TEX_UV)
+ if (im->mask & RS::ARRAY_FORMAT_TEX_UV)
c->uvs.push_back(chunk_uv);
- if (im->mask & VS::ARRAY_FORMAT_TEX_UV2)
+ if (im->mask & RS::ARRAY_FORMAT_TEX_UV2)
c->uv2s.push_back(chunk_uv2);
- im->mask |= VS::ARRAY_FORMAT_VERTEX;
+ im->mask |= RS::ARRAY_FORMAT_VERTEX;
c->vertices.push_back(p_vertex);
}
@@ -3518,7 +3518,7 @@ void RasterizerStorageGLES2::immediate_normal(RID p_immediate, const Vector3 &p_
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
- im->mask |= VS::ARRAY_FORMAT_NORMAL;
+ im->mask |= RS::ARRAY_FORMAT_NORMAL;
chunk_normal = p_normal;
}
@@ -3527,7 +3527,7 @@ void RasterizerStorageGLES2::immediate_tangent(RID p_immediate, const Plane &p_t
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
- im->mask |= VS::ARRAY_FORMAT_TANGENT;
+ im->mask |= RS::ARRAY_FORMAT_TANGENT;
chunk_tangent = p_tangent;
}
@@ -3536,7 +3536,7 @@ void RasterizerStorageGLES2::immediate_color(RID p_immediate, const Color &p_col
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
- im->mask |= VS::ARRAY_FORMAT_COLOR;
+ im->mask |= RS::ARRAY_FORMAT_COLOR;
chunk_color = p_color;
}
@@ -3545,7 +3545,7 @@ void RasterizerStorageGLES2::immediate_uv(RID p_immediate, const Vector2 &tex_uv
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
- im->mask |= VS::ARRAY_FORMAT_TEX_UV;
+ im->mask |= RS::ARRAY_FORMAT_TEX_UV;
chunk_uv = tex_uv;
}
@@ -3554,7 +3554,7 @@ void RasterizerStorageGLES2::immediate_uv2(RID p_immediate, const Vector2 &tex_u
ERR_FAIL_COND(!im);
ERR_FAIL_COND(!im->building);
- im->mask |= VS::ARRAY_FORMAT_TEX_UV2;
+ im->mask |= RS::ARRAY_FORMAT_TEX_UV2;
chunk_uv2 = tex_uv;
}
@@ -3812,34 +3812,34 @@ void RasterizerStorageGLES2::update_dirty_skeletons() {
/* Light API */
-RID RasterizerStorageGLES2::light_create(VS::LightType p_type) {
+RID RasterizerStorageGLES2::light_create(RS::LightType p_type) {
Light *light = memnew(Light);
light->type = p_type;
- light->param[VS::LIGHT_PARAM_ENERGY] = 1.0;
- light->param[VS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
- light->param[VS::LIGHT_PARAM_SPECULAR] = 0.5;
- light->param[VS::LIGHT_PARAM_RANGE] = 1.0;
- light->param[VS::LIGHT_PARAM_SPOT_ANGLE] = 45;
- light->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45;
- light->param[VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
- light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
- light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
- light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
- light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1;
- light->param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1;
+ light->param[RS::LIGHT_PARAM_ENERGY] = 1.0;
+ light->param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
+ light->param[RS::LIGHT_PARAM_SPECULAR] = 0.5;
+ light->param[RS::LIGHT_PARAM_RANGE] = 1.0;
+ light->param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45;
+ light->param[RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45;
+ light->param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
+ light->param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
+ light->param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
+ light->param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
+ light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1;
+ light->param[RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1;
light->color = Color(1, 1, 1, 1);
light->shadow = false;
light->negative = false;
light->cull_mask = 0xFFFFFFFF;
- light->directional_shadow_mode = VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL;
- light->omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
- light->omni_shadow_detail = VS::LIGHT_OMNI_SHADOW_DETAIL_VERTICAL;
+ light->directional_shadow_mode = RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL;
+ light->omni_shadow_mode = RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
+ light->omni_shadow_detail = RS::LIGHT_OMNI_SHADOW_DETAIL_VERTICAL;
light->directional_blend_splits = false;
- light->directional_range_mode = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE;
+ light->directional_range_mode = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE;
light->reverse_cull = false;
light->use_gi = true;
light->version = 0;
@@ -3854,20 +3854,20 @@ void RasterizerStorageGLES2::light_set_color(RID p_light, const Color &p_color)
light->color = p_color;
}
-void RasterizerStorageGLES2::light_set_param(RID p_light, VS::LightParam p_param, float p_value) {
+void RasterizerStorageGLES2::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
- ERR_FAIL_INDEX(p_param, VS::LIGHT_PARAM_MAX);
+ ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
switch (p_param) {
- case VS::LIGHT_PARAM_RANGE:
- case VS::LIGHT_PARAM_SPOT_ANGLE:
- case VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
- case VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
- case VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
- case VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
- case VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
- case VS::LIGHT_PARAM_SHADOW_BIAS: {
+ case RS::LIGHT_PARAM_RANGE:
+ case RS::LIGHT_PARAM_SPOT_ANGLE:
+ case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
+ case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
+ case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
+ case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
+ case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
+ case RS::LIGHT_PARAM_SHADOW_BIAS: {
light->version++;
light->instance_change_notify(true, false);
} break;
@@ -3939,7 +3939,7 @@ void RasterizerStorageGLES2::light_set_use_gi(RID p_light, bool p_enabled) {
light->instance_change_notify(true, false);
}
-void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {
+void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3949,14 +3949,14 @@ void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOm
light->instance_change_notify(true, false);
}
-VS::LightOmniShadowMode RasterizerStorageGLES2::light_omni_get_shadow_mode(RID p_light) {
+RS::LightOmniShadowMode RasterizerStorageGLES2::light_omni_get_shadow_mode(RID p_light) {
Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI_SHADOW_CUBE);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
return light->omni_shadow_mode;
}
-void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) {
+void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3966,7 +3966,7 @@ void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, VS::Light
light->instance_change_notify(true, false);
}
-void RasterizerStorageGLES2::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {
+void RasterizerStorageGLES2::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3992,37 +3992,37 @@ bool RasterizerStorageGLES2::light_directional_get_blend_splits(RID p_light) con
return light->directional_blend_splits;
}
-VS::LightDirectionalShadowMode RasterizerStorageGLES2::light_directional_get_shadow_mode(RID p_light) {
+RS::LightDirectionalShadowMode RasterizerStorageGLES2::light_directional_get_shadow_mode(RID p_light) {
Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
return light->directional_shadow_mode;
}
-void RasterizerStorageGLES2::light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {
+void RasterizerStorageGLES2::light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
light->directional_range_mode = p_range_mode;
}
-VS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES2::light_directional_get_shadow_depth_range_mode(RID p_light) const {
+RS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES2::light_directional_get_shadow_depth_range_mode(RID p_light) const {
Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
return light->directional_range_mode;
}
-VS::LightType RasterizerStorageGLES2::light_get_type(RID p_light) const {
+RS::LightType RasterizerStorageGLES2::light_get_type(RID p_light) const {
Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->type;
}
-float RasterizerStorageGLES2::light_get_param(RID p_light, VS::LightParam p_param) {
+float RasterizerStorageGLES2::light_get_param(RID p_light, RS::LightParam p_param) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, 0.0);
- ERR_FAIL_INDEX_V(p_param, VS::LIGHT_PARAM_MAX, 0.0);
+ ERR_FAIL_INDEX_V(p_param, RS::LIGHT_PARAM_MAX, 0.0);
return light->param[p_param];
}
@@ -4061,18 +4061,18 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const {
switch (light->type) {
- case VS::LIGHT_SPOT: {
- float len = light->param[VS::LIGHT_PARAM_RANGE];
- float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len;
+ case RS::LIGHT_SPOT: {
+ float len = light->param[RS::LIGHT_PARAM_RANGE];
+ float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
};
- case VS::LIGHT_OMNI: {
- float r = light->param[VS::LIGHT_PARAM_RANGE];
+ case RS::LIGHT_OMNI: {
+ float r = light->param[RS::LIGHT_PARAM_RANGE];
return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
};
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
return AABB();
};
}
@@ -4097,13 +4097,13 @@ RID RasterizerStorageGLES2::reflection_probe_create() {
reflection_probe->box_projection = false;
reflection_probe->enable_shadows = false;
reflection_probe->cull_mask = (1 << 20) - 1;
- reflection_probe->update_mode = VS::REFLECTION_PROBE_UPDATE_ONCE;
+ reflection_probe->update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE;
reflection_probe->resolution = 128;
return reflection_probe_owner.make_rid(reflection_probe);
}
-void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) {
+void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4220,10 +4220,10 @@ AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
-VS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
+RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
- ERR_FAIL_COND_V(!reflection_probe, VS::REFLECTION_PROBE_UPDATE_ALWAYS);
+ ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
return reflection_probe->update_mode;
}
@@ -4518,7 +4518,7 @@ void RasterizerStorageGLES2::particles_set_fractional_delta(RID p_particles, boo
void RasterizerStorageGLES2::particles_set_process_material(RID p_particles, RID p_material) {
}
-void RasterizerStorageGLES2::particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {
+void RasterizerStorageGLES2::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {
}
void RasterizerStorageGLES2::particles_set_draw_passes(RID p_particles, int p_passes) {
@@ -4581,35 +4581,35 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene
Instantiable *inst = NULL;
switch (p_instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
inst = mesh_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
inst = multimesh_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
inst = immediate_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- /*case VS::INSTANCE_PARTICLES: {
+ /*case RS::INSTANCE_PARTICLES: {
inst = particles_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;*/
- case VS::INSTANCE_REFLECTION_PROBE: {
+ case RS::INSTANCE_REFLECTION_PROBE: {
inst = reflection_probe_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- case VS::INSTANCE_LIGHT: {
+ case RS::INSTANCE_LIGHT: {
inst = light_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- /*case VS::INSTANCE_GI_PROBE: {
+ /*case RS::INSTANCE_GI_PROBE: {
inst = gi_probe_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;*/
- case VS::INSTANCE_LIGHTMAP_CAPTURE: {
+ case RS::INSTANCE_LIGHTMAP_CAPTURE: {
inst = lightmap_capture_data_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
@@ -4626,35 +4626,35 @@ void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerSc
Instantiable *inst = NULL;
switch (p_instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
inst = mesh_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
inst = multimesh_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
inst = immediate_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- /*case VS::INSTANCE_PARTICLES: {
+ /*case RS::INSTANCE_PARTICLES: {
inst = particles_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;*/
- case VS::INSTANCE_REFLECTION_PROBE: {
+ case RS::INSTANCE_REFLECTION_PROBE: {
inst = reflection_probe_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- case VS::INSTANCE_LIGHT: {
+ case RS::INSTANCE_LIGHT: {
inst = light_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
- /*case VS::INSTANCE_GI_PROBE: {
+ /*case RS::INSTANCE_GI_PROBE: {
inst = gi_probe_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break; */
- case VS::INSTANCE_LIGHTMAP_CAPTURE: {
+ case RS::INSTANCE_LIGHTMAP_CAPTURE: {
inst = lightmap_capture_data_owner.getornull(p_base);
ERR_FAIL_COND(!inst);
} break;
@@ -4723,7 +4723,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, NULL);
- if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
+ if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -4805,7 +4805,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
/* For MSAA */
#ifndef JAVASCRIPT_ENABLED
- if (rt->msaa >= VS::VIEWPORT_MSAA_2X && rt->msaa <= VS::VIEWPORT_MSAA_16X && config.multisample_supported) {
+ if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_16X && config.multisample_supported) {
rt->multisample_active = true;
@@ -5134,7 +5134,7 @@ RID RasterizerStorageGLES2::render_target_create() {
Texture *t = memnew(Texture);
- t->type = VS::TEXTURE_TYPE_2D;
+ t->type = RS::TEXTURE_TYPE_2D;
t->flags = 0;
t->width = 0;
t->height = 0;
@@ -5235,7 +5235,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
// allocate a texture
t = memnew(Texture);
- t->type = VS::TEXTURE_TYPE_2D;
+ t->type = RS::TEXTURE_TYPE_2D;
t->flags = 0;
t->width = 0;
t->height = 0;
@@ -5278,7 +5278,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
// Switch our texture on our frame buffer
#if ANDROID_ENABLED
- if (rt->msaa >= VS::VIEWPORT_MSAA_EXT_2X && rt->msaa <= VS::VIEWPORT_MSAA_EXT_4X) {
+ if (rt->msaa >= RS::VIEWPORT_MSAA_EXT_2X && rt->msaa <= RS::VIEWPORT_MSAA_EXT_4X) {
// This code only applies to the Oculus Go and Oculus Quest. Due to the the tiled nature
// of the GPU we can do a single render pass by rendering directly into our texture chains
// texture and apply MSAA as we render.
@@ -5287,7 +5287,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
// the normal MSAA modes need to be used to enable our two pass approach
static const int msaa_value[] = { 2, 4 };
- int msaa = msaa_value[rt->msaa - VS::VIEWPORT_MSAA_EXT_2X];
+ int msaa = msaa_value[rt->msaa - RS::VIEWPORT_MSAA_EXT_2X];
if (rt->external.depth == 0) {
// create a multisample depth buffer, we're not reusing Godots because Godot's didn't get created..
@@ -5370,7 +5370,7 @@ void RasterizerStorageGLES2::render_target_set_as_unused(RID p_render_target) {
rt->used_in_frame = false;
}
-void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {
+void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) {
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
@@ -5544,22 +5544,22 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
}
}
-VS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
+RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
if (mesh_owner.owns(p_rid)) {
- return VS::INSTANCE_MESH;
+ return RS::INSTANCE_MESH;
} else if (light_owner.owns(p_rid)) {
- return VS::INSTANCE_LIGHT;
+ return RS::INSTANCE_LIGHT;
} else if (multimesh_owner.owns(p_rid)) {
- return VS::INSTANCE_MULTIMESH;
+ return RS::INSTANCE_MULTIMESH;
} else if (immediate_owner.owns(p_rid)) {
- return VS::INSTANCE_IMMEDIATE;
+ return RS::INSTANCE_IMMEDIATE;
} else if (reflection_probe_owner.owns(p_rid)) {
- return VS::INSTANCE_REFLECTION_PROBE;
+ return RS::INSTANCE_REFLECTION_PROBE;
} else if (lightmap_capture_data_owner.owns(p_rid)) {
- return VS::INSTANCE_LIGHTMAP_CAPTURE;
+ return RS::INSTANCE_LIGHTMAP_CAPTURE;
} else {
- return VS::INSTANCE_NONE;
+ return RS::INSTANCE_NONE;
}
}
@@ -5710,7 +5710,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
}
}
- multimesh_allocate(p_rid, 0, VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
+ multimesh_allocate(p_rid, 0, RS::MULTIMESH_TRANSFORM_3D, RS::MULTIMESH_COLOR_NONE);
update_dirty_multimeshes();
@@ -5817,25 +5817,25 @@ void RasterizerStorageGLES2::render_info_end_capture() {
info.snap.vertices_count = info.render.vertices_count - info.snap.vertices_count;
}
-int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) {
+int RasterizerStorageGLES2::get_captured_render_info(RS::RenderInfo p_info) {
switch (p_info) {
- case VS::INFO_OBJECTS_IN_FRAME: {
+ case RS::INFO_OBJECTS_IN_FRAME: {
return info.snap.object_count;
} break;
- case VS::INFO_VERTICES_IN_FRAME: {
+ case RS::INFO_VERTICES_IN_FRAME: {
return info.snap.vertices_count;
} break;
- case VS::INFO_MATERIAL_CHANGES_IN_FRAME: {
+ case RS::INFO_MATERIAL_CHANGES_IN_FRAME: {
return info.snap.material_switch_count;
} break;
- case VS::INFO_SHADER_CHANGES_IN_FRAME: {
+ case RS::INFO_SHADER_CHANGES_IN_FRAME: {
return info.snap.shader_rebind_count;
} break;
- case VS::INFO_SURFACE_CHANGES_IN_FRAME: {
+ case RS::INFO_SURFACE_CHANGES_IN_FRAME: {
return info.snap.surface_switch_count;
} break;
- case VS::INFO_DRAW_CALLS_IN_FRAME: {
+ case RS::INFO_DRAW_CALLS_IN_FRAME: {
return info.snap.draw_call_count;
} break;
default: {
@@ -5844,27 +5844,27 @@ int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) {
}
}
-int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) {
+int RasterizerStorageGLES2::get_render_info(RS::RenderInfo p_info) {
switch (p_info) {
- case VS::INFO_OBJECTS_IN_FRAME:
+ case RS::INFO_OBJECTS_IN_FRAME:
return info.render_final.object_count;
- case VS::INFO_VERTICES_IN_FRAME:
+ case RS::INFO_VERTICES_IN_FRAME:
return info.render_final.vertices_count;
- case VS::INFO_MATERIAL_CHANGES_IN_FRAME:
+ case RS::INFO_MATERIAL_CHANGES_IN_FRAME:
return info.render_final.material_switch_count;
- case VS::INFO_SHADER_CHANGES_IN_FRAME:
+ case RS::INFO_SHADER_CHANGES_IN_FRAME:
return info.render_final.shader_rebind_count;
- case VS::INFO_SURFACE_CHANGES_IN_FRAME:
+ case RS::INFO_SURFACE_CHANGES_IN_FRAME:
return info.render_final.surface_switch_count;
- case VS::INFO_DRAW_CALLS_IN_FRAME:
+ case RS::INFO_DRAW_CALLS_IN_FRAME:
return info.render_final.draw_call_count;
- case VS::INFO_USAGE_VIDEO_MEM_TOTAL:
+ case RS::INFO_USAGE_VIDEO_MEM_TOTAL:
return 0; //no idea
- case VS::INFO_VIDEO_MEM_USED:
+ case RS::INFO_VIDEO_MEM_USED:
return info.vertex_mem + info.texture_mem;
- case VS::INFO_TEXTURE_MEM_USED:
+ case RS::INFO_TEXTURE_MEM_USED:
return info.texture_mem;
- case VS::INFO_VERTEX_MEM_USED:
+ case RS::INFO_VERTEX_MEM_USED:
return info.vertex_mem;
default:
return 0; //no idea either
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index 86965730e0..f8b8b824bd 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -32,8 +32,8 @@
#define RASTERIZERSTORAGEGLES2_H
#include "core/self_list.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering/shader_language.h"
#include "shader_compiler_gles2.h"
#include "shader_gles2.h"
@@ -249,7 +249,7 @@ public:
int width, height, depth;
int alloc_width, alloc_height;
Image::Format format;
- VS::TextureType type;
+ RS::TextureType type;
GLenum target;
GLenum gl_format_cache;
@@ -279,13 +279,13 @@ public:
bool redraw_if_visible;
- VisualServer::TextureDetectCallback detect_3d;
+ RenderingServer::TextureDetectCallback detect_3d;
void *detect_3d_ud;
- VisualServer::TextureDetectCallback detect_srgb;
+ RenderingServer::TextureDetectCallback detect_srgb;
void *detect_srgb_ud;
- VisualServer::TextureDetectCallback detect_normal;
+ RenderingServer::TextureDetectCallback detect_normal;
void *detect_normal_ud;
Texture() :
@@ -296,7 +296,7 @@ public:
alloc_width(0),
alloc_height(0),
format(Image::FORMAT_L8),
- type(VS::TEXTURE_TYPE_2D),
+ type(RS::TEXTURE_TYPE_2D),
target(0),
data_size(0),
total_data_size(0),
@@ -345,14 +345,14 @@ public:
Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const;
virtual RID texture_create();
- virtual void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VS::TextureType p_type, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT);
+ virtual void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RS::TextureType p_type, uint32_t p_flags = RS::TEXTURE_FLAGS_DEFAULT);
virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0);
virtual void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer = 0);
virtual Ref<Image> texture_get_data(RID p_texture, int p_layer = 0) const;
virtual void texture_set_flags(RID p_texture, uint32_t p_flags);
virtual uint32_t texture_get_flags(RID p_texture) const;
virtual Image::Format texture_get_format(RID p_texture) const;
- virtual VS::TextureType texture_get_type(RID p_texture) const;
+ virtual RS::TextureType texture_get_type(RID p_texture) const;
virtual uint32_t texture_get_texid(RID p_texture) const;
virtual uint32_t texture_get_width(RID p_texture) const;
virtual uint32_t texture_get_height(RID p_texture) const;
@@ -365,7 +365,7 @@ public:
virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable);
- virtual void texture_debug_usage(List<VS::TextureInfo> *r_info);
+ virtual void texture_debug_usage(List<RS::TextureInfo> *r_info);
virtual RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const;
@@ -374,9 +374,9 @@ public:
virtual void texture_set_proxy(RID p_texture, RID p_proxy);
virtual Size2 texture_size_with_proxy(RID p_texture) const;
- virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
- virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
- virtual void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
+ virtual void texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata);
+ virtual void texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata);
+ virtual void texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable);
@@ -402,7 +402,7 @@ public:
RID self;
- VS::ShaderMode mode;
+ RS::ShaderMode mode;
ShaderGLES2 *shader;
String code;
SelfList<Material>::List materials;
@@ -617,7 +617,7 @@ public:
uint32_t offset;
};
- Attrib attribs[VS::ARRAY_MAX];
+ Attrib attribs[RS::ARRAY_MAX];
Mesh *mesh;
uint32_t format;
@@ -641,7 +641,7 @@ public:
int array_byte_size;
int index_array_byte_size;
- VS::PrimitiveType primitive;
+ RS::PrimitiveType primitive;
Vector<AABB> skeleton_bone_aabb;
Vector<bool> skeleton_bone_used;
@@ -660,7 +660,7 @@ public:
index_array_len(0),
array_byte_size(0),
index_array_byte_size(0),
- primitive(VS::PRIMITIVE_POINTS),
+ primitive(RS::PRIMITIVE_POINTS),
active(false),
total_data_size(0) {
}
@@ -675,7 +675,7 @@ public:
Vector<Surface *> surfaces;
int blend_shape_count;
- VS::BlendShapeMode blend_shape_mode;
+ RS::BlendShapeMode blend_shape_mode;
AABB custom_aabb;
@@ -694,7 +694,7 @@ public:
Mesh() :
blend_shape_count(0),
- blend_shape_mode(VS::BLEND_SHAPE_MODE_NORMALIZED) {
+ blend_shape_mode(RS::BLEND_SHAPE_MODE_NORMALIZED) {
}
};
@@ -702,13 +702,13 @@ public:
virtual RID mesh_create();
- virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
+ virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount);
virtual int mesh_get_blend_shape_count(RID p_mesh) const;
- virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode);
- virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
+ virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode);
+ virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data);
@@ -722,7 +722,7 @@ public:
virtual Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const;
virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const;
- virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
+ virtual RS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
virtual Vector<Vector<uint8_t>> mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
@@ -744,9 +744,9 @@ public:
RID mesh;
int size;
- VS::MultimeshTransformFormat transform_format;
- VS::MultimeshColorFormat color_format;
- VS::MultimeshCustomDataFormat custom_data_format;
+ RS::MultimeshTransformFormat transform_format;
+ RS::MultimeshColorFormat color_format;
+ RS::MultimeshCustomDataFormat custom_data_format;
Vector<float> data;
@@ -766,9 +766,9 @@ public:
MultiMesh() :
size(0),
- transform_format(VS::MULTIMESH_TRANSFORM_2D),
- color_format(VS::MULTIMESH_COLOR_NONE),
- custom_data_format(VS::MULTIMESH_CUSTOM_DATA_NONE),
+ transform_format(RS::MULTIMESH_TRANSFORM_2D),
+ color_format(RS::MULTIMESH_COLOR_NONE),
+ custom_data_format(RS::MULTIMESH_CUSTOM_DATA_NONE),
update_list(this),
mesh_list(this),
visible_instances(-1),
@@ -786,7 +786,7 @@ public:
virtual RID multimesh_create();
- virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data = VS::MULTIMESH_CUSTOM_DATA_NONE);
+ virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, RS::MultimeshColorFormat p_color_format, RS::MultimeshCustomDataFormat p_data = RS::MULTIMESH_CUSTOM_DATA_NONE);
virtual int multimesh_get_instance_count(RID p_multimesh) const;
virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
@@ -817,7 +817,7 @@ public:
struct Chunk {
RID texture;
- VS::PrimitiveType primitive;
+ RS::PrimitiveType primitive;
Vector<Vector3> vertices;
Vector<Vector3> normals;
Vector<Plane> tangents;
@@ -846,7 +846,7 @@ public:
mutable RID_PtrOwner<Immediate> immediate_owner;
virtual RID immediate_create();
- virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID());
+ virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_primitive, RID p_texture = RID());
virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex);
virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal);
virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent);
@@ -906,8 +906,8 @@ public:
/* Light API */
struct Light : Instantiable {
- VS::LightType type;
- float param[VS::LIGHT_PARAM_MAX];
+ RS::LightType type;
+ float param[RS::LIGHT_PARAM_MAX];
Color color;
Color shadow_color;
@@ -921,11 +921,11 @@ public:
uint32_t cull_mask;
- VS::LightOmniShadowMode omni_shadow_mode;
- VS::LightOmniShadowDetail omni_shadow_detail;
+ RS::LightOmniShadowMode omni_shadow_mode;
+ RS::LightOmniShadowDetail omni_shadow_detail;
- VS::LightDirectionalShadowMode directional_shadow_mode;
- VS::LightDirectionalShadowDepthRangeMode directional_range_mode;
+ RS::LightDirectionalShadowMode directional_shadow_mode;
+ RS::LightDirectionalShadowDepthRangeMode directional_range_mode;
bool directional_blend_splits;
@@ -934,10 +934,10 @@ public:
mutable RID_PtrOwner<Light> light_owner;
- virtual RID light_create(VS::LightType p_type);
+ virtual RID light_create(RS::LightType p_type);
virtual void light_set_color(RID p_light, const Color &p_color);
- virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value);
+ virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value);
virtual void light_set_shadow(RID p_light, bool p_enabled);
virtual void light_set_shadow_color(RID p_light, const Color &p_color);
virtual void light_set_projector(RID p_light, RID p_texture);
@@ -946,23 +946,23 @@ public:
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled);
virtual void light_set_use_gi(RID p_light, bool p_enabled);
- virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode);
- virtual void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail);
+ virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode);
+ virtual void light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail);
- virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode);
+ virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode);
virtual void light_directional_set_blend_splits(RID p_light, bool p_enable);
virtual bool light_directional_get_blend_splits(RID p_light) const;
- virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light);
- virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
+ virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light);
+ virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
- virtual void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode);
- virtual VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const;
+ virtual void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode);
+ virtual RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const;
virtual bool light_has_shadow(RID p_light) const;
- virtual VS::LightType light_get_type(RID p_light) const;
- virtual float light_get_param(RID p_light, VS::LightParam p_param);
+ virtual RS::LightType light_get_type(RID p_light) const;
+ virtual float light_get_param(RID p_light, RS::LightParam p_param);
virtual Color light_get_color(RID p_light);
virtual bool light_get_use_gi(RID p_light);
@@ -973,7 +973,7 @@ public:
struct ReflectionProbe : Instantiable {
- VS::ReflectionProbeUpdateMode update_mode;
+ RS::ReflectionProbeUpdateMode update_mode;
float intensity;
Color interior_ambient;
float interior_ambient_energy;
@@ -992,7 +992,7 @@ public:
virtual RID reflection_probe_create();
- virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode);
+ virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode);
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity);
virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient);
virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy);
@@ -1007,7 +1007,7 @@ public:
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution);
virtual AABB reflection_probe_get_aabb(RID p_probe) const;
- virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
+ virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const;
virtual int reflection_probe_get_resolution(RID p_probe) const;
@@ -1111,7 +1111,7 @@ public:
virtual void particles_set_fractional_delta(RID p_particles, bool p_enable);
virtual void particles_restart(RID p_particles);
- virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order);
+ virtual void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order);
virtual void particles_set_draw_passes(RID p_particles, int p_passes);
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh);
@@ -1203,7 +1203,7 @@ public:
bool flags[RENDER_TARGET_FLAG_MAX];
bool used_in_frame;
- VS::ViewportMSAA msaa;
+ RS::ViewportMSAA msaa;
RID texture;
@@ -1223,7 +1223,7 @@ public:
width(0),
height(0),
used_in_frame(false),
- msaa(VS::VIEWPORT_MSAA_DISABLED),
+ msaa(RS::VIEWPORT_MSAA_DISABLED),
used_dof_blur_near(false),
mip_maps_allocated(false) {
for (int i = 0; i < RENDER_TARGET_FLAG_MAX; ++i) {
@@ -1247,7 +1247,7 @@ public:
virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value);
virtual bool render_target_was_used(RID p_render_target);
virtual void render_target_set_as_unused(RID p_render_target);
- virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa);
+ virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa);
/* CANVAS SHADOW */
@@ -1279,7 +1279,7 @@ public:
virtual RID canvas_light_occluder_create();
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines);
- virtual VS::InstanceType get_base_type(RID p_rid) const;
+ virtual RS::InstanceType get_base_type(RID p_rid) const;
virtual bool free(RID p_rid);
@@ -1309,9 +1309,9 @@ public:
virtual void render_info_begin_capture();
virtual void render_info_end_capture();
- virtual int get_captured_render_info(VS::RenderInfo p_info);
+ virtual int get_captured_render_info(RS::RenderInfo p_info);
- virtual int get_render_info(VS::RenderInfo p_info);
+ virtual int get_render_info(RS::RenderInfo p_info);
virtual String get_video_adapter_name() const;
virtual String get_video_adapter_vendor() const;
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index 620fcdbdca..d626263431 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -934,7 +934,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
return code.as_string();
}
-Error ShaderCompilerGLES2::compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
+Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types());
@@ -975,210 +975,210 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
/** CANVAS ITEM SHADER **/
- actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
- actions[VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv";
- actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size";
-
- actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix";
- actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
- actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance";
- actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time";
- actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass";
- actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom";
-
- actions[VS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color";
- actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal";
- actions[VS::SHADER_CANVAS_ITEM].renames["NORMALMAP"] = "normal_map";
- actions[VS::SHADER_CANVAS_ITEM].renames["NORMALMAP_DEPTH"] = "normal_depth";
- actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture";
- actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size";
- actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture";
- actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv";
- actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture";
- actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size";
- actions[VS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord";
- actions[VS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord";
-
- actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec";
- actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height";
- actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color";
- actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv";
- actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light";
- actions[VS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color";
- actions[VS::SHADER_CANVAS_ITEM].renames["SHADOW_VEC"] = "shadow_vec";
-
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
- actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_VEC"] = "#define SHADOW_VEC_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
+ actions[RS::SHADER_CANVAS_ITEM].renames["UV"] = "uv";
+ actions[RS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size";
+
+ actions[RS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix";
+ actions[RS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
+ actions[RS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance";
+ actions[RS::SHADER_CANVAS_ITEM].renames["TIME"] = "time";
+ actions[RS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass";
+ actions[RS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom";
+
+ actions[RS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color";
+ actions[RS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal";
+ actions[RS::SHADER_CANVAS_ITEM].renames["NORMALMAP"] = "normal_map";
+ actions[RS::SHADER_CANVAS_ITEM].renames["NORMALMAP_DEPTH"] = "normal_depth";
+ actions[RS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture";
+ actions[RS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size";
+ actions[RS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture";
+ actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv";
+ actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture";
+ actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size";
+ actions[RS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord";
+ actions[RS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord";
+
+ actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec";
+ actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height";
+ actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color";
+ actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv";
+ actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light";
+ actions[RS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color";
+ actions[RS::SHADER_CANVAS_ITEM].renames["SHADOW_VEC"] = "shadow_vec";
+
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+ actions[RS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_VEC"] = "#define SHADOW_VEC_USED\n";
// Ported from GLES3
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["sinh"] = "#define SINH_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["cosh"] = "#define COSH_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["tanh"] = "#define TANH_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["asinh"] = "#define ASINH_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["acosh"] = "#define ACOSH_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["atanh"] = "#define ATANH_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["sinh"] = "#define SINH_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["cosh"] = "#define COSH_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["tanh"] = "#define TANH_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["asinh"] = "#define ASINH_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["acosh"] = "#define ACOSH_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["atanh"] = "#define ATANH_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n";
+ actions[RS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n";
/** SPATIAL SHADER **/
- actions[VS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
- actions[VS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
- actions[VS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
- actions[VS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
- actions[VS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix";
- actions[VS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
-
- actions[VS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
- actions[VS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
- actions[VS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
- actions[VS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
- actions[VS::SHADER_SPATIAL].renames["POSITION"] = "position";
- actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
- actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
- actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
- actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size";
+ actions[RS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
+ actions[RS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
+ actions[RS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
+ actions[RS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
+ actions[RS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix";
+ actions[RS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
+
+ actions[RS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
+ actions[RS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
+ actions[RS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
+ actions[RS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
+ actions[RS::SHADER_SPATIAL].renames["POSITION"] = "position";
+ actions[RS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
+ actions[RS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
+ actions[RS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
+ actions[RS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size";
// gl_InstanceID is not available in OpenGL ES 2.0
- actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0";
+ actions[RS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0";
//builtins
- actions[VS::SHADER_SPATIAL].renames["TIME"] = "time";
- actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
-
- actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
- actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
- actions[VS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
- actions[VS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
- actions[VS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
- actions[VS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
- actions[VS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
- actions[VS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
- actions[VS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
- actions[VS::SHADER_SPATIAL].renames["RIM"] = "rim";
- actions[VS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
- actions[VS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
- actions[VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
- actions[VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
- actions[VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
- actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
- actions[VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
- actions[VS::SHADER_SPATIAL].renames["AO"] = "ao";
- actions[VS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
- actions[VS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
- actions[VS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
- actions[VS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
- actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
- actions[VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
- actions[VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture";
+ actions[RS::SHADER_SPATIAL].renames["TIME"] = "time";
+ actions[RS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
+
+ actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
+ actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
+ actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
+ actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
+ actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
+ actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
+ actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
+ actions[RS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
+ actions[RS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
+ actions[RS::SHADER_SPATIAL].renames["RIM"] = "rim";
+ actions[RS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
+ actions[RS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
+ actions[RS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
+ actions[RS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
+ actions[RS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
+ actions[RS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
+ actions[RS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
+ actions[RS::SHADER_SPATIAL].renames["AO"] = "ao";
+ actions[RS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
+ actions[RS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
+ actions[RS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
+ actions[RS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
+ actions[RS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
+ actions[RS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
+ actions[RS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture";
// Defined in GLES3, but not available in GLES2
- //actions[VS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
- actions[VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
- actions[VS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
+ //actions[RS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
+ actions[RS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
+ actions[RS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
//for light
- actions[VS::SHADER_SPATIAL].renames["VIEW"] = "view";
- actions[VS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
- actions[VS::SHADER_SPATIAL].renames["LIGHT"] = "light";
- actions[VS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
- actions[VS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
- actions[VS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
-
- actions[VS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
- actions[VS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
- actions[VS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
- actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
- actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
- actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
- actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
- actions[VS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
- actions[VS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
- actions[VS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
- actions[VS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
- actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
-
- actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
- actions[VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
-
- actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
- actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+ actions[RS::SHADER_SPATIAL].renames["VIEW"] = "view";
+ actions[RS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
+ actions[RS::SHADER_SPATIAL].renames["LIGHT"] = "light";
+ actions[RS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
+ actions[RS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
+ actions[RS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
+
+ actions[RS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
+ actions[RS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
+ actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
+ actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
+ actions[RS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
+ actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
+
+ actions[RS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
+
+ actions[RS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
// Ported from GLES3
- actions[VS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n";
-
- actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n";
+
+ actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
// Defined in GLES3, could be implemented in GLES2 too if there's a need for it
- //actions[VS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
+ //actions[RS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
// Defined in GLES3, might not be possible in GLES2 as gl_FrontFacing is not available
- //actions[VS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
- //actions[VS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
+ //actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
+ //actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley");
if (!force_lambert) {
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
}
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx");
if (!force_blinn) {
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
} else {
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
}
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
// No defines for particle shaders in GLES2, there are no GPU particles
diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h
index dd10a27c0d..757dcdd4f2 100644
--- a/drivers/gles2/shader_compiler_gles2.h
+++ b/drivers/gles2/shader_compiler_gles2.h
@@ -33,9 +33,9 @@
#include "core/pair.h"
#include "core/string_builder.h"
-#include "servers/visual/shader_language.h"
-#include "servers/visual/shader_types.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/shader_language.h"
+#include "servers/rendering/shader_types.h"
+#include "servers/rendering_server.h"
class ShaderCompilerGLES2 {
public:
@@ -91,10 +91,10 @@ private:
Set<StringName> used_rmode_defines;
Set<StringName> internal_functions;
- DefaultIdentifierActions actions[VS::SHADER_MAX];
+ DefaultIdentifierActions actions[RS::SHADER_MAX];
public:
- Error compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
+ Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
ShaderCompilerGLES2();
};
diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h
index d5e8159479..54858becb6 100644
--- a/drivers/gles2/shader_gles2.h
+++ b/drivers/gles2/shader_gles2.h
@@ -44,7 +44,7 @@
#include "core/math/camera_matrix.h"
#include "core/pair.h"
#include "core/variant.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/shader_language.h"
#include <stdio.h>
diff --git a/drivers/gles2/shaders/blend_shape.glsl b/drivers/gles2/shaders/blend_shape.glsl
index a1e954e33d..0d0b3e24e4 100644
--- a/drivers/gles2/shaders/blend_shape.glsl
+++ b/drivers/gles2/shaders/blend_shape.glsl
@@ -2,7 +2,7 @@
[vertex]
/*
-from VisualServer:
+from RenderingServer:
ARRAY_VERTEX=0,
ARRAY_NORMAL=1,
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 458488f3e9..76a89b2bb4 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -41,7 +41,7 @@
#include "drivers/unix/net_socket_posix.h"
#include "drivers/unix/rw_lock_posix.h"
#include "drivers/unix/thread_posix.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#ifdef __APPLE__
#include <mach-o/dyld.h>
diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub
index 85a5ae8d26..de776b19b2 100644
--- a/drivers/vulkan/SCsub
+++ b/drivers/vulkan/SCsub
@@ -57,7 +57,7 @@ if env['builtin_vulkan']:
'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share',
'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg'
])
- elif env['platform'] == "x11":
+ elif env['platform'] == "linuxbsd":
env_thirdparty.AppendUnique(CPPDEFINES=[
'VK_USE_PLATFORM_XLIB_KHR',
'VULKAN_NON_CMAKE_BUILD',
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 76541c3cd5..8ebf5b0f04 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -5150,12 +5150,12 @@ bool RenderingDeviceVulkan::compute_pipeline_is_valid(RID p_pipeline) {
/**** SCREEN ****/
/****************/
-int RenderingDeviceVulkan::screen_get_width(int p_screen) const {
+int RenderingDeviceVulkan::screen_get_width(DisplayServer::WindowID p_screen) const {
_THREAD_SAFE_METHOD_
return context->window_get_width(p_screen);
}
-int RenderingDeviceVulkan::screen_get_height(int p_screen) const {
+int RenderingDeviceVulkan::screen_get_height(DisplayServer::WindowID p_screen) const {
_THREAD_SAFE_METHOD_
return context->window_get_height(p_screen);
@@ -5189,7 +5189,7 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuff
/**** DRAW LIST ****/
/*******************/
-RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(int p_screen, const Color &p_clear_color) {
+RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(DisplayServer::WindowID p_screen, const Color &p_clear_color) {
_THREAD_SAFE_METHOD_
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 4a224f0ceb..f7ae9c28ea 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -34,7 +34,7 @@
#include "core/oa_hash_map.h"
#include "core/os/thread_safe.h"
#include "core/rid_owner.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rendering_device.h"
#ifdef DEBUG_ENABLED
#define _DEBUG
@@ -1052,15 +1052,15 @@ public:
/**** SCREEN ****/
/****************/
- virtual int screen_get_width(int p_screen = 0) const;
- virtual int screen_get_height(int p_screen = 0) const;
+ virtual int screen_get_width(DisplayServer::WindowID p_screen = 0) const;
+ virtual int screen_get_height(DisplayServer::WindowID p_screen = 0) const;
virtual FramebufferFormatID screen_get_framebuffer_format() const;
/********************/
/**** DRAW LISTS ****/
/********************/
- virtual DrawListID draw_list_begin_for_screen(int p_screen = 0, const Color &p_clear_color = Color());
+ virtual DrawListID draw_list_begin_for_screen(DisplayServer::WindowID p_screen = 0, const Color &p_clear_color = Color());
virtual DrawListID draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2());
virtual Error draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, DrawListID *r_split_ids, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2());
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index c8ff342713..494c64ff55 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -696,7 +696,9 @@ Error VulkanContext::_create_semaphores() {
return OK;
}
-int VulkanContext::_window_create(VkSurfaceKHR p_surface, int p_width, int p_height) {
+Error VulkanContext::_window_create(DisplayServer::WindowID p_window_id, VkSurfaceKHR p_surface, int p_width, int p_height) {
+
+ ERR_FAIL_COND_V(windows.has(p_window_id), ERR_INVALID_PARAMETER);
if (!queues_initialized) {
// We use a single GPU, but we need a surface to initialize the
@@ -710,39 +712,37 @@ int VulkanContext::_window_create(VkSurfaceKHR p_surface, int p_width, int p_hei
window.width = p_width;
window.height = p_height;
Error err = _update_swap_chain(&window);
- ERR_FAIL_COND_V(err != OK, -1);
+ ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
- int id = last_window_id;
- windows[id] = window;
- last_window_id++;
- return id;
+ windows[p_window_id] = window;
+ return OK;
}
-void VulkanContext::window_resize(int p_window, int p_width, int p_height) {
+void VulkanContext::window_resize(DisplayServer::WindowID p_window, int p_width, int p_height) {
ERR_FAIL_COND(!windows.has(p_window));
windows[p_window].width = p_width;
windows[p_window].height = p_height;
_update_swap_chain(&windows[p_window]);
}
-int VulkanContext::window_get_width(int p_window) {
+int VulkanContext::window_get_width(DisplayServer::WindowID p_window) {
ERR_FAIL_COND_V(!windows.has(p_window), -1);
return windows[p_window].width;
}
-int VulkanContext::window_get_height(int p_window) {
+int VulkanContext::window_get_height(DisplayServer::WindowID p_window) {
ERR_FAIL_COND_V(!windows.has(p_window), -1);
return windows[p_window].height;
}
-VkRenderPass VulkanContext::window_get_render_pass(int p_window) {
+VkRenderPass VulkanContext::window_get_render_pass(DisplayServer::WindowID p_window) {
ERR_FAIL_COND_V(!windows.has(p_window), VK_NULL_HANDLE);
Window *w = &windows[p_window];
//vulkan use of currentbuffer
return w->render_pass;
}
-VkFramebuffer VulkanContext::window_get_framebuffer(int p_window) {
+VkFramebuffer VulkanContext::window_get_framebuffer(DisplayServer::WindowID p_window) {
ERR_FAIL_COND_V(!windows.has(p_window), VK_NULL_HANDLE);
ERR_FAIL_COND_V(!buffers_prepared, VK_NULL_HANDLE);
Window *w = &windows[p_window];
@@ -750,7 +750,7 @@ VkFramebuffer VulkanContext::window_get_framebuffer(int p_window) {
return w->swapchain_image_resources[w->current_buffer].framebuffer;
}
-void VulkanContext::window_destroy(int p_window_id) {
+void VulkanContext::window_destroy(DisplayServer::WindowID p_window_id) {
ERR_FAIL_COND(!windows.has(p_window_id));
_clean_up_swap_chain(&windows[p_window_id]);
vkDestroySurfaceKHR(inst, windows[p_window_id].surface, NULL);
@@ -1497,7 +1497,6 @@ VulkanContext::VulkanContext() {
buffers_prepared = false;
swapchainImageCount = 0;
- last_window_id = 0;
}
VulkanContext::~VulkanContext() {
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h
index 458cb6d793..2f10fbfdef 100644
--- a/drivers/vulkan/vulkan_context.h
+++ b/drivers/vulkan/vulkan_context.h
@@ -34,6 +34,7 @@
#include "core/error_list.h"
#include "core/map.h"
#include "core/ustring.h"
+#include "servers/display_server.h"
#include <vulkan/vulkan.h>
class VulkanContext {
@@ -106,8 +107,7 @@ class VulkanContext {
}
};
- Map<int, Window> windows;
- int last_window_id;
+ Map<DisplayServer::WindowID, Window> windows;
uint32_t swapchainImageCount;
//commands
@@ -173,7 +173,7 @@ protected:
virtual const char *_get_platform_surface_extension() const = 0;
// virtual VkResult _create_surface(VkSurfaceKHR *surface, VkInstance p_instance) = 0;
- virtual int _window_create(VkSurfaceKHR p_surface, int p_width, int p_height);
+ virtual Error _window_create(DisplayServer::WindowID p_window_id, VkSurfaceKHR p_surface, int p_width, int p_height);
VkInstance _get_instance() {
return inst;
@@ -187,12 +187,12 @@ public:
int get_swapchain_image_count() const;
uint32_t get_graphics_queue() const;
- void window_resize(int p_window_id, int p_width, int p_height);
- int window_get_width(int p_window = 0);
- int window_get_height(int p_window = 0);
- void window_destroy(int p_window_id);
- VkFramebuffer window_get_framebuffer(int p_window = 0);
- VkRenderPass window_get_render_pass(int p_window = 0);
+ void window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height);
+ int window_get_width(DisplayServer::WindowID p_window = 0);
+ int window_get_height(DisplayServer::WindowID p_window = 0);
+ void window_destroy(DisplayServer::WindowID p_window_id);
+ VkFramebuffer window_get_framebuffer(DisplayServer::WindowID p_window = 0);
+ VkRenderPass window_get_render_pass(DisplayServer::WindowID p_window = 0);
VkFormat get_screen_format() const;
VkPhysicalDeviceLimits get_device_limits() const;
diff --git a/editor/SCsub b/editor/SCsub
index e54383350e..61562d70d3 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -7,13 +7,12 @@ env.editor_sources = []
import os
import os.path
from platform_methods import run_in_subprocess
-from compat import open_utf8
import editor_builders
def _make_doc_data_class_path(to_path):
# NOTE: It is safe to generate this file here, since this is still executed serially
- g = open_utf8(os.path.join(to_path, "doc_data_class_path.gen.h"), "w")
+ g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8")
g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n")
g.write("struct _DocDataClassPath { const char* name; const char* path; };\n")
@@ -37,7 +36,7 @@ if env['tools']:
reg_exporters += '}\n'
# NOTE: It is safe to generate this file here, since this is still executed serially
- with open_utf8("register_exporters.gen.cpp", "w") as f:
+ with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f:
f.write(reg_exporters_inc)
f.write(reg_exporters)
@@ -56,7 +55,7 @@ if env['tools']:
except OSError:
pass
- _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc"))
+ _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor"))
docs = sorted(docs)
env.Depends("#editor/doc_data_compressed.gen.h", docs)
@@ -85,8 +84,6 @@ if env['tools']:
env.add_source_files(env.editor_sources, "*.cpp")
- SConscript('collada/SCsub')
- SConscript('doc/SCsub')
SConscript('debugger/SCsub')
SConscript('fileserver/SCsub')
SConscript('icons/SCsub')
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index 6dcc9dd8ae..f3e3025e81 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -215,20 +215,20 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V
void AnimationBezierTrackEdit::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- bezier_icon = get_icon("KeyBezierPoint", "EditorIcons");
- bezier_handle_icon = get_icon("KeyBezierHandle", "EditorIcons");
- selected_icon = get_icon("KeyBezierSelected", "EditorIcons");
+ bezier_icon = get_theme_icon("KeyBezierPoint", "EditorIcons");
+ bezier_handle_icon = get_theme_icon("KeyBezierHandle", "EditorIcons");
+ selected_icon = get_theme_icon("KeyBezierSelected", "EditorIcons");
if (handle_mode_option->get_item_count() == 0) {
- handle_mode_option->add_icon_item(get_icon("BezierHandlesFree", "EditorIcons"), TTR("Free"), HANDLE_MODE_FREE);
- handle_mode_option->add_icon_item(get_icon("BezierHandlesBalanced", "EditorIcons"), TTR("Balanced"), HANDLE_MODE_BALANCED);
- handle_mode_option->add_icon_item(get_icon("BezierHandlesMirror", "EditorIcons"), TTR("Mirror"), HANDLE_MODE_MIRROR);
+ handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesFree", "EditorIcons"), TTR("Free"), HANDLE_MODE_FREE);
+ handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesBalanced", "EditorIcons"), TTR("Balanced"), HANDLE_MODE_BALANCED);
+ handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesMirror", "EditorIcons"), TTR("Mirror"), HANDLE_MODE_MIRROR);
}
}
if (p_what == NOTIFICATION_RESIZED) {
int right_limit = get_size().width - timeline->get_buttons_width();
- int hsep = get_constant("hseparation", "ItemList");
- int vsep = get_constant("vseparation", "ItemList");
+ int hsep = get_theme_constant("hseparation", "ItemList");
+ int vsep = get_theme_constant("vseparation", "ItemList");
handle_mode_option->set_position(Vector2(right_limit + hsep, get_size().height - handle_mode_option->get_combined_minimum_size().height - vsep));
handle_mode_option->set_size(Vector2(timeline->get_buttons_width() - hsep * 2, handle_mode_option->get_combined_minimum_size().height));
@@ -240,15 +240,15 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
int limit = timeline->get_name_limit();
if (has_focus()) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
accent.a *= 0.7;
draw_rect(Rect2(Point2(), get_size()), accent, false);
}
- Ref<Font> font = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
- int hsep = get_constant("hseparation", "ItemList");
- int vsep = get_constant("vseparation", "ItemList");
+ Ref<Font> font = get_theme_font("font", "Label");
+ Color color = get_theme_color("font_color", "Label");
+ int hsep = get_theme_constant("hseparation", "ItemList");
+ int vsep = get_theme_constant("vseparation", "ItemList");
Color linecolor = color;
linecolor.a = 0.2;
@@ -258,7 +258,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor);
- Ref<Texture2D> close_icon = get_icon("Close", "EditorIcons");
+ Ref<Texture2D> close_icon = get_theme_icon("Close", "EditorIcons");
close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep);
close_icon_rect.size = close_icon->get_size();
@@ -340,7 +340,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
subtracks[i] = rect;
} else {
- Color ac = get_color("accent_color", "Editor");
+ Color ac = get_theme_color("accent_color", "Editor");
ac.a = 0.5;
draw_rect(rect, ac);
}
@@ -349,7 +349,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
vofs += font->get_height() + vsep;
}
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
{ //guides
float min_left_scale = font->get_height() + vsep;
@@ -391,7 +391,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
{ //draw OTHER curves
float scale = timeline->get_zoom_scale();
- Ref<Texture2D> point = get_icon("KeyValue", "EditorIcons");
+ Ref<Texture2D> point = get_theme_icon("KeyValue", "EditorIcons");
for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) {
_draw_track(E->key(), E->get());
@@ -410,7 +410,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
//draw edited curve
- const Color highlight = get_color("highlight_color", "Editor");
+ const Color highlight = get_theme_color("highlight_color", "Editor");
_draw_track(track, highlight);
}
@@ -540,7 +540,7 @@ void AnimationBezierTrackEdit::_play_position_draw() {
int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit();
if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
play_position->draw_line(Point2(px, 0), Point2(px, h), color);
}
}
@@ -657,9 +657,9 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT);
if (selection.size()) {
menu->add_separator();
- menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE);
+ menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE);
menu->add_separator();
- menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE);
+ menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE);
}
menu->set_as_minsize();
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index fb427afe24..4f06a753a7 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -31,13 +31,13 @@
#include "animation_track_editor.h"
#include "animation_track_editor_plugins.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "editor/animation_bezier_editor.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor_node.h"
#include "editor_scale.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "servers/audio/audio_stream.h"
class AnimationTrackKeyEdit : public Object {
@@ -1442,11 +1442,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() {
int AnimationTimelineEdit::get_buttons_width() const {
- Ref<Texture2D> interp_mode = get_icon("TrackContinuous", "EditorIcons");
- Ref<Texture2D> interp_type = get_icon("InterpRaw", "EditorIcons");
- Ref<Texture2D> loop_type = get_icon("InterpWrapClamp", "EditorIcons");
- Ref<Texture2D> remove_icon = get_icon("Remove", "EditorIcons");
- Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree");
+ Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons");
+ Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons");
+ Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons");
+ Ref<Texture2D> remove_icon = get_theme_icon("Remove", "EditorIcons");
+ Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree");
int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width();
total_w += (down_icon->get_width() + 4 * EDSCALE) * 4;
@@ -1456,7 +1456,7 @@ int AnimationTimelineEdit::get_buttons_width() const {
int AnimationTimelineEdit::get_name_limit() const {
- Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons");
+ Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons");
int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width());
@@ -1468,17 +1468,17 @@ int AnimationTimelineEdit::get_name_limit() const {
void AnimationTimelineEdit::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- add_track->set_icon(get_icon("Add", "EditorIcons"));
- loop->set_icon(get_icon("Loop", "EditorIcons"));
- time_icon->set_texture(get_icon("Time", "EditorIcons"));
+ add_track->set_icon(get_theme_icon("Add", "EditorIcons"));
+ loop->set_icon(get_theme_icon("Loop", "EditorIcons"));
+ time_icon->set_texture(get_theme_icon("Time", "EditorIcons"));
add_track->get_popup()->clear();
- add_track->get_popup()->add_icon_item(get_icon("KeyValue", "EditorIcons"), TTR("Property Track"));
- add_track->get_popup()->add_icon_item(get_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track"));
- add_track->get_popup()->add_icon_item(get_icon("KeyCall", "EditorIcons"), TTR("Call Method Track"));
- add_track->get_popup()->add_icon_item(get_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track"));
- add_track->get_popup()->add_icon_item(get_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track"));
- add_track->get_popup()->add_icon_item(get_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon("KeyValue", "EditorIcons"), TTR("Property Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon("KeyCall", "EditorIcons"), TTR("Call Method Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track"));
+ add_track->get_popup()->add_icon_item(get_theme_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track"));
}
if (p_what == NOTIFICATION_RESIZED) {
@@ -1493,8 +1493,8 @@ void AnimationTimelineEdit::_notification(int p_what) {
if (!animation.is_valid())
return;
- Ref<Font> font = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
+ Color color = get_theme_color("font_color", "Label");
int zoomw = key_range;
float scale = get_zoom_scale();
@@ -1504,7 +1504,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
if (l <= 0)
l = 0.001; //avoid crashor
- Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons");
+ Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons");
hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
draw_texture(hsize_icon, hsize_rect.position);
@@ -1554,7 +1554,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
int end_px = (l - get_value()) * scale;
int begin_px = -get_value() * scale;
- Color notimecol = get_color("dark_color_2", "Editor");
+ Color notimecol = get_theme_color("dark_color_2", "Editor");
Color timecolor = color;
timecolor.a = 0.2;
Color linecolor = color;
@@ -1685,9 +1685,9 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) {
Size2 AnimationTimelineEdit::get_minimum_size() const {
Size2 ms = add_track->get_minimum_size();
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
ms.height = MAX(ms.height, font->get_height());
- ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_icon("Hsize", "EditorIcons")->get_width() + 2;
+ ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon("Hsize", "EditorIcons")->get_width() + 2;
return ms;
}
@@ -1746,11 +1746,11 @@ void AnimationTimelineEdit::_play_position_draw() {
int px = (-get_value() + play_position_pos) * scale + get_name_limit();
if (px >= get_name_limit() && px < (play_position->get_size().width - get_buttons_width())) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE));
play_position->draw_texture(
- get_icon("TimelineIndicator", "EditorIcons"),
- Point2(px - get_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0),
+ get_theme_icon("TimelineIndicator", "EditorIcons"),
+ Point2(px - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0),
color);
}
}
@@ -1921,23 +1921,23 @@ void AnimationTrackEdit::_notification(int p_what) {
int limit = timeline->get_name_limit();
if (has_focus()) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
accent.a *= 0.7;
// Offside so the horizontal sides aren't cutoff.
draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false);
}
- Ref<Font> font = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
+ Color color = get_theme_color("font_color", "Label");
Ref<Texture2D> type_icons[6] = {
- get_icon("KeyValue", "EditorIcons"),
- get_icon("KeyXform", "EditorIcons"),
- get_icon("KeyCall", "EditorIcons"),
- get_icon("KeyBezier", "EditorIcons"),
- get_icon("KeyAudio", "EditorIcons"),
- get_icon("KeyAnimation", "EditorIcons")
+ get_theme_icon("KeyValue", "EditorIcons"),
+ get_theme_icon("KeyXform", "EditorIcons"),
+ get_theme_icon("KeyCall", "EditorIcons"),
+ get_theme_icon("KeyBezier", "EditorIcons"),
+ get_theme_icon("KeyAudio", "EditorIcons"),
+ get_theme_icon("KeyAnimation", "EditorIcons")
};
- int hsep = get_constant("hseparation", "ItemList");
+ int hsep = get_theme_constant("hseparation", "ItemList");
Color linecolor = color;
linecolor.a = 0.2;
@@ -1945,7 +1945,7 @@ void AnimationTrackEdit::_notification(int p_what) {
{
- Ref<Texture2D> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox");
+ Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon("checked", "CheckBox") : get_theme_icon("unchecked", "CheckBox");
int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but..
@@ -1966,7 +1966,7 @@ void AnimationTrackEdit::_notification(int p_what) {
String text;
Color text_color = color;
if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) {
- text_color = get_color("accent_color", "Editor");
+ text_color = get_theme_color("accent_color", "Editor");
}
if (in_group) {
@@ -2045,25 +2045,25 @@ void AnimationTrackEdit::_notification(int p_what) {
{
Ref<Texture2D> wrap_icon[2] = {
- get_icon("InterpWrapClamp", "EditorIcons"),
- get_icon("InterpWrapLoop", "EditorIcons"),
+ get_theme_icon("InterpWrapClamp", "EditorIcons"),
+ get_theme_icon("InterpWrapLoop", "EditorIcons"),
};
Ref<Texture2D> interp_icon[3] = {
- get_icon("InterpRaw", "EditorIcons"),
- get_icon("InterpLinear", "EditorIcons"),
- get_icon("InterpCubic", "EditorIcons")
+ get_theme_icon("InterpRaw", "EditorIcons"),
+ get_theme_icon("InterpLinear", "EditorIcons"),
+ get_theme_icon("InterpCubic", "EditorIcons")
};
Ref<Texture2D> cont_icon[4] = {
- get_icon("TrackContinuous", "EditorIcons"),
- get_icon("TrackDiscrete", "EditorIcons"),
- get_icon("TrackTrigger", "EditorIcons"),
- get_icon("TrackCapture", "EditorIcons")
+ get_theme_icon("TrackContinuous", "EditorIcons"),
+ get_theme_icon("TrackDiscrete", "EditorIcons"),
+ get_theme_icon("TrackTrigger", "EditorIcons"),
+ get_theme_icon("TrackCapture", "EditorIcons")
};
int ofs = get_size().width - timeline->get_buttons_width();
- Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree");
+ Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree");
draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE));
@@ -2100,7 +2100,7 @@ void AnimationTrackEdit::_notification(int p_what) {
update_mode_rect.size.x += down_icon->get_width();
bezier_edit_rect = Rect2();
} else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) {
- Ref<Texture2D> bezier_icon = get_icon("EditBezier", "EditorIcons");
+ Ref<Texture2D> bezier_icon = get_theme_icon("EditBezier", "EditorIcons");
update_mode_rect.size.x += down_icon->get_width();
bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2;
bezier_edit_rect.size = bezier_icon->get_size();
@@ -2185,7 +2185,7 @@ void AnimationTrackEdit::_notification(int p_what) {
{
//erase
- Ref<Texture2D> icon = get_icon("Remove", "EditorIcons");
+ Ref<Texture2D> icon = get_theme_icon("Remove", "EditorIcons");
remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2;
remove_rect.position.y = int(get_size().height - icon->get_height()) / 2;
@@ -2202,7 +2202,7 @@ void AnimationTrackEdit::_notification(int p_what) {
}
if (dropping_at != 0) {
- Color drop_color = get_color("accent_color", "Editor");
+ Color drop_color = get_theme_color("accent_color", "Editor");
if (dropping_at < 0) {
draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE));
} else {
@@ -2249,7 +2249,7 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x,
if (current != next)
return;
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
color.a = 0.5;
int from_x = MAX(p_x, p_clip_left);
@@ -2273,15 +2273,15 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
const Variant &v = animation->track_get_key_value(track, p_index);
Variant::Type valid_type = Variant::NIL;
if (!_is_value_key_valid(v, valid_type)) {
- icon_to_draw = get_icon("KeyInvalid", "EditorIcons");
+ icon_to_draw = get_theme_icon("KeyInvalid", "EditorIcons");
}
}
Vector2 ofs(p_x - icon_to_draw->get_width() / 2, int(get_size().height - icon_to_draw->get_height()) / 2);
if (animation->track_get_type(track) == Animation::TYPE_METHOD) {
- Ref<Font> font = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
+ Color color = get_theme_color("font_color", "Label");
color.a = 0.5;
Dictionary d = animation->track_get_key_value(track, p_index);
@@ -2387,19 +2387,19 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati
update();
Ref<Texture2D> type_icons[6] = {
- get_icon("KeyValue", "EditorIcons"),
- get_icon("KeyXform", "EditorIcons"),
- get_icon("KeyCall", "EditorIcons"),
- get_icon("KeyBezier", "EditorIcons"),
- get_icon("KeyAudio", "EditorIcons"),
- get_icon("KeyAnimation", "EditorIcons")
+ get_theme_icon("KeyValue", "EditorIcons"),
+ get_theme_icon("KeyXform", "EditorIcons"),
+ get_theme_icon("KeyCall", "EditorIcons"),
+ get_theme_icon("KeyBezier", "EditorIcons"),
+ get_theme_icon("KeyAudio", "EditorIcons"),
+ get_theme_icon("KeyAnimation", "EditorIcons")
};
ERR_FAIL_INDEX(track, animation->get_track_count());
node_path = animation->track_get_path(p_track);
type_icon = type_icons[animation->track_get_type(track)];
- selected_icon = get_icon("KeySelected", "EditorIcons");
+ selected_icon = get_theme_icon("KeySelected", "EditorIcons");
}
NodePath AnimationTrackEdit::get_path() const {
@@ -2408,9 +2408,9 @@ NodePath AnimationTrackEdit::get_path() const {
Size2 AnimationTrackEdit::get_minimum_size() const {
- Ref<Texture2D> texture = get_icon("Object", "EditorIcons");
- Ref<Font> font = get_font("font", "Label");
- int separation = get_constant("vseparation", "ItemList");
+ Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons");
+ Ref<Font> font = get_theme_font("font", "Label");
+ int separation = get_theme_constant("vseparation", "ItemList");
int max_h = MAX(texture->get_height(), font->get_height());
max_h = MAX(max_h, get_key_height());
@@ -2442,7 +2442,7 @@ void AnimationTrackEdit::_play_position_draw() {
int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit();
if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE));
}
}
@@ -2471,6 +2471,7 @@ void AnimationTrackEdit::_path_entered(const String &p_text) {
undo_redo->add_do_method(animation.ptr(), "track_set_path", track, p_text);
undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track));
undo_redo->commit_action();
+ path_popup->hide();
}
bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const {
@@ -2689,14 +2690,14 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
}
menu->clear();
- menu->add_icon_item(get_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS);
- menu->add_icon_item(get_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE);
- menu->add_icon_item(get_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER);
- menu->add_icon_item(get_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE);
+ menu->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS);
+ menu->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE);
+ menu->add_icon_item(get_theme_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER);
+ menu->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE);
menu->set_as_minsize();
- Vector2 popup_pos = get_global_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height);
- menu->set_global_position(popup_pos);
+ Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height);
+ menu->set_position(popup_pos);
menu->popup();
accept_event();
}
@@ -2708,13 +2709,13 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
}
menu->clear();
- menu->add_icon_item(get_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST);
- menu->add_icon_item(get_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR);
- menu->add_icon_item(get_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC);
+ menu->add_icon_item(get_theme_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST);
+ menu->add_icon_item(get_theme_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR);
+ menu->add_icon_item(get_theme_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC);
menu->set_as_minsize();
- Vector2 popup_pos = get_global_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height);
- menu->set_global_position(popup_pos);
+ Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height);
+ menu->set_position(popup_pos);
menu->popup();
accept_event();
}
@@ -2726,12 +2727,12 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
}
menu->clear();
- menu->add_icon_item(get_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP);
- menu->add_icon_item(get_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP);
+ menu->add_icon_item(get_theme_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP);
+ menu->add_icon_item(get_theme_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP);
menu->set_as_minsize();
- Vector2 popup_pos = get_global_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height);
- menu->set_global_position(popup_pos);
+ Vector2 popup_pos = get_screen_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height);
+ menu->set_position(popup_pos);
menu->popup();
accept_event();
}
@@ -2822,17 +2823,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
menu->clear();
- menu->add_icon_item(get_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT);
+ menu->add_icon_item(get_theme_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT);
if (editor->is_selection_active()) {
menu->add_separator();
- menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE);
+ menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE);
menu->add_separator();
- menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE);
+ menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE);
}
menu->set_as_minsize();
- Vector2 popup_pos = get_global_transform().xform(get_local_mouse_position());
- menu->set_global_position(popup_pos);
+ Vector2 popup_pos = get_screen_transform().xform(get_local_mouse_position());
+ menu->set_position(popup_pos);
menu->popup();
insert_at_pos = offset + timeline->get_value();
@@ -2843,17 +2844,20 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && clicking_on_name) {
if (!path) {
+ path_popup = memnew(Popup);
+ path_popup->set_wrap_controls(true);
+ add_child(path_popup);
path = memnew(LineEdit);
- add_child(path);
- path->set_as_toplevel(true);
+ path_popup->add_child(path);
+ path->set_anchors_and_margins_preset(PRESET_WIDE);
path->connect("text_entered", callable_mp(this, &AnimationTrackEdit::_path_entered));
}
path->set_text(animation->track_get_path(track));
- Vector2 theme_ofs = path->get_stylebox("normal", "LineEdit")->get_offset();
- path->set_position(get_global_position() + path_rect.position - theme_ofs);
- path->set_size(path_rect.size);
- path->show_modal();
+ Vector2 theme_ofs = path->get_theme_stylebox("normal", "LineEdit")->get_offset();
+ path_popup->set_position(get_screen_position() + path_rect.position - theme_ofs);
+ path_popup->set_size(path_rect.size);
+ path_popup->popup();
path->grab_focus();
path->set_cursor_position(path->get_text().length());
clicking_on_name = false;
@@ -3090,6 +3094,7 @@ AnimationTrackEdit::AnimationTrackEdit() {
timeline = NULL;
root = NULL;
path = NULL;
+ path_popup = NULL;
menu = NULL;
clicking_on_name = false;
dropping_at = 0;
@@ -3158,18 +3163,18 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object
void AnimationTrackEditGroup::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Font> font = get_font("font", "Label");
- int separation = get_constant("hseparation", "ItemList");
- Color color = get_color("font_color", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
+ int separation = get_theme_constant("hseparation", "ItemList");
+ Color color = get_theme_color("font_color", "Label");
if (root && root->has_node(node)) {
Node *n = root->get_node(node);
if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
- color = get_color("accent_color", "Editor");
+ color = get_theme_color("accent_color", "Editor");
}
}
- Color bgcol = get_color("dark_color_2", "Editor");
+ Color bgcol = get_theme_color("dark_color_2", "Editor");
bgcol.a *= 0.6;
draw_rect(Rect2(Point2(), get_size()), bgcol);
Color linecolor = color;
@@ -3187,7 +3192,7 @@ void AnimationTrackEditGroup::_notification(int p_what) {
int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit();
if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE));
}
}
@@ -3203,8 +3208,8 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co
Size2 AnimationTrackEditGroup::get_minimum_size() const {
- Ref<Font> font = get_font("font", "Label");
- int separation = get_constant("vseparation", "ItemList");
+ Ref<Font> font = get_theme_font("font", "Label");
+ int separation = get_theme_constant("vseparation", "ItemList");
return Vector2(0, MAX(font->get_height(), icon->get_height()) + separation);
}
@@ -3443,7 +3448,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
if (insert_frame != Engine::get_singleton()->get_frames_drawn()) {
//clear insert list for the frame if frame changed
- if (insert_confirm->is_visible_in_tree())
+ if (insert_confirm->is_visible())
return; //do nothing
insert_data.clear();
insert_query = false;
@@ -3496,7 +3501,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
insert_confirm_bezier->set_visible(all_bezier);
insert_confirm->get_ok()->set_text(TTR("Create"));
- insert_confirm->popup_centered_minsize();
+ insert_confirm->popup_centered();
insert_query = true;
} else {
call_deferred("_insert_delay");
@@ -3549,7 +3554,7 @@ void AnimationTrackEditor::_insert_delay() {
insert_queue = false;
}
-void AnimationTrackEditor::insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform) {
+void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) {
if (!keying)
return;
@@ -4095,7 +4100,7 @@ bool AnimationTrackEditor::is_selection_active() const {
}
bool AnimationTrackEditor::is_snap_enabled() const {
- return snap->is_pressed() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ return snap->is_pressed() ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
}
void AnimationTrackEditor::_update_tracks() {
@@ -4207,7 +4212,7 @@ void AnimationTrackEditor::_update_tracks() {
if (!group_sort.has(base_path)) {
AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup);
- Ref<Texture2D> icon = get_icon("Node", "EditorIcons");
+ Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons");
String name = base_path;
String tooltip;
if (root && root->has_node(base_path)) {
@@ -4225,7 +4230,7 @@ void AnimationTrackEditor::_update_tracks() {
g->set_timeline(timeline);
groups.push_back(g);
VBoxContainer *vb = memnew(VBoxContainer);
- vb->add_constant_override("separation", 0);
+ vb->add_theme_constant_override("separation", 0);
vb->add_child(g);
track_vbox->add_child(vb);
group_sort[base_path] = vb;
@@ -4368,12 +4373,12 @@ MenuButton *AnimationTrackEditor::get_edit_menu() {
void AnimationTrackEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- zoom_icon->set_texture(get_icon("Zoom", "EditorIcons"));
- snap->set_icon(get_icon("Snap", "EditorIcons"));
- view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons"));
- selected_filter->set_icon(get_icon("AnimationFilter", "EditorIcons"));
- imported_anim_warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
- main_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
+ zoom_icon->set_texture(get_theme_icon("Zoom", "EditorIcons"));
+ snap->set_icon(get_theme_icon("Snap", "EditorIcons"));
+ view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons"));
+ selected_filter->set_icon(get_theme_icon("AnimationFilter", "EditorIcons"));
+ imported_anim_warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons"));
+ main_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
}
if (p_what == NOTIFICATION_READY) {
@@ -4441,8 +4446,8 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
ERR_FAIL_COND(!node);
NodePath path_to = root->get_path_to(node);
- if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Spatial")) {
- EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to Spatial-based nodes."));
+ if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Node3D")) {
+ EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to 3D-based nodes."));
return;
}
@@ -4633,10 +4638,10 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a key."));
return;
}
- Spatial *base = Object::cast_to<Spatial>(root->get_node(animation->track_get_path(p_track)));
+ Node3D *base = Object::cast_to<Node3D>(root->get_node(animation->track_get_path(p_track)));
if (!base) {
- EditorNode::get_singleton()->show_warning(TTR("Track is not of type Spatial, can't insert key"));
+ EditorNode::get_singleton()->show_warning(TTR("Track is not of type Node3D, can't insert key"));
return;
}
@@ -5050,8 +5055,8 @@ float AnimationTrackEditor::get_moving_selection_offset() const {
void AnimationTrackEditor::_box_selection_draw() {
const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size());
- box_selection->draw_rect(selection_rect, get_color("box_selection_fill_color", "Editor"));
- box_selection->draw_rect(selection_rect, get_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE));
+ box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor"));
+ box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE));
}
void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {
@@ -5266,10 +5271,10 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}
String text;
- Ref<Texture2D> icon = get_icon("Node", "EditorIcons");
+ Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons");
if (node) {
- if (has_icon(node->get_class(), "EditorIcons")) {
- icon = get_icon(node->get_class(), "EditorIcons");
+ if (has_theme_icon(node->get_class(), "EditorIcons")) {
+ icon = get_theme_icon(node->get_class(), "EditorIcons");
}
text = node->get_name();
@@ -5309,7 +5314,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
it->set_metadata(0, md);
}
- track_copy_dialog->popup_centered_minsize(Size2(350, 500) * EDSCALE);
+ track_copy_dialog->popup_centered(Size2(350, 500) * EDSCALE);
} break;
case EDIT_COPY_TRACKS_CONFIRM: {
@@ -5578,7 +5583,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
} break;
case EDIT_CLEAN_UP_ANIMATION: {
- cleanup_dialog->popup_centered_minsize(Size2(300, 0) * EDSCALE);
+ cleanup_dialog->popup_centered(Size2(300, 0) * EDSCALE);
} break;
case EDIT_CLEAN_UP_ANIMATION_CONFIRM: {
@@ -5652,7 +5657,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
void AnimationTrackEditor::_view_group_toggle() {
_update_tracks();
- view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons"));
+ view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons"));
}
bool AnimationTrackEditor::is_grouping_tracks() {
@@ -5763,7 +5768,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
timeline_scroll->add_child(timeline_vbox);
timeline_vbox->set_v_size_flags(SIZE_EXPAND_FILL);
timeline_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
- timeline_vbox->add_constant_override("separation", 0);
+ timeline_vbox->add_theme_constant_override("separation", 0);
info_message = memnew(Label);
info_message->set_text(TTR("Select an AnimationPlayer node to create and edit animations."));
@@ -5814,7 +5819,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
track_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
scroll->set_enable_h_scroll(false);
scroll->set_enable_v_scroll(true);
- track_vbox->add_constant_override("separation", 0);
+ track_vbox->add_theme_constant_override("separation", 0);
HBoxContainer *bottom_hb = memnew(HBoxContainer);
add_child(bottom_hb);
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 8de56a153e..7c4cc6db53 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -140,6 +140,7 @@ class AnimationTrackEdit : public Control {
};
AnimationTimelineEdit *timeline;
UndoRedo *undo_redo;
+ Popup *path_popup;
LineEdit *path;
Node *root;
Control *play_position; //separate control used to draw so updates for only position changed are much faster
@@ -512,7 +513,7 @@ public:
void set_anim_pos(float p_pos);
void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false);
void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance);
- void insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform);
+ void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform);
void show_select_node_warning(bool p_show);
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index fc47a69a2c..4467366c3f 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -33,8 +33,8 @@
#include "editor/audio_stream_preview.h"
#include "editor_resource_preview.h"
#include "editor_scale.h"
-#include "scene/2d/animated_sprite.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/animated_sprite_2d.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/3d/sprite_3d.h"
#include "scene/animation/animation_player.h"
#include "servers/audio/audio_stream.h"
@@ -42,12 +42,12 @@
/// BOOL ///
int AnimationTrackEditBool::get_key_height() const {
- Ref<Texture2D> checked = get_icon("checked", "CheckBox");
+ Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox");
return checked->get_height();
}
Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) {
- Ref<Texture2D> checked = get_icon("checked", "CheckBox");
+ Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox");
return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height);
}
@@ -58,7 +58,7 @@ bool AnimationTrackEditBool::is_key_selectable_by_distance() const {
void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
bool checked = get_animation()->track_get_key_value(get_track(), p_index);
- Ref<Texture2D> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox");
+ Ref<Texture2D> icon = get_theme_icon(checked ? "checked" : "unchecked", "CheckBox");
Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2);
@@ -71,7 +71,7 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x,
draw_texture(icon, ofs);
if (p_selected) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
draw_rect_clipped(Rect2(ofs, icon->get_size()), color, false);
}
}
@@ -80,12 +80,12 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x,
int AnimationTrackEditColor::get_key_height() const {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return font->get_height() * 0.8;
}
Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
return Rect2(-fh / 2, 0, fh, get_size().height);
}
@@ -97,7 +97,7 @@ bool AnimationTrackEditColor::is_key_selectable_by_distance() const {
void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = (font->get_height() * 0.8);
int x_from = p_x + fh / 2 - 1;
@@ -146,7 +146,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x,
Color color = get_animation()->track_get_key_value(get_track(), p_index);
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
Rect2 rect(Vector2(p_x - fh / 2, int(get_size().height - fh) / 2), Size2(fh, fh));
@@ -158,7 +158,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x,
draw_rect_clipped(rect, color);
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect_clipped(rect, accent, false);
}
}
@@ -185,7 +185,7 @@ int AnimationTrackEditAudio::get_key_height() const {
return AnimationTrackEdit::get_key_height();
}
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
@@ -218,7 +218,7 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
return Rect2(0, 0, len * p_pixels_sec, get_size().height);
} else {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
return Rect2(0, 0, fh, get_size().height);
}
@@ -279,7 +279,7 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
if (to_x <= from_x)
return;
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
float fh = int(font->get_height() * 1.5);
Rect2 rect = Rect2(from_x, (get_size().height - fh) / 2, to_x - from_x, fh);
draw_rect(rect, Color(0.25, 0.25, 0.25));
@@ -303,22 +303,22 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
Vector<Color> color;
color.push_back(Color(0.75, 0.75, 0.75));
- VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color);
+ RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color);
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
} else {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
draw_rect(rect, color);
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
}
@@ -344,7 +344,7 @@ int AnimationTrackEditSpriteFrame::get_key_height() const {
return AnimationTrackEdit::get_key_height();
}
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 2);
}
Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_sec) {
@@ -357,7 +357,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
Size2 size;
- if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
+ if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
Ref<Texture2D> texture = object->call("get_texture");
if (!texture.is_valid()) {
@@ -379,7 +379,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
if (vframes > 1) {
size.y /= vframes;
}
- } else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
+ } else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
if (sf.is_null()) {
@@ -413,7 +413,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
size = size.floor();
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int height = int(font->get_height() * 2);
int width = height * size.width / size.height;
@@ -436,7 +436,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
Ref<Texture2D> texture;
Rect2 region;
- if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
+ if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
texture = object->call("get_texture");
if (!texture.is_valid()) {
@@ -473,7 +473,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.position.x += region.size.x * coords.x;
region.position.y += region.size.y * coords.y;
- } else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
+ } else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
if (sf.is_null()) {
@@ -507,7 +507,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.size = texture->get_size();
}
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int height = int(font->get_height() * 2);
int width = height * region.size.width / region.size.height;
@@ -520,7 +520,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
if (rect.position.x > p_clip_right)
return;
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
Color bg = accent;
bg.a = 0.15;
@@ -551,7 +551,7 @@ int AnimationTrackEditSubAnim::get_key_height() const {
return AnimationTrackEdit::get_key_height();
}
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
@@ -580,7 +580,7 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
return Rect2(0, 0, len * p_pixels_sec, get_size().height);
} else {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
return Rect2(0, 0, fh, get_size().height);
}
@@ -633,12 +633,12 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
if (to_x <= from_x)
return;
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 1.5;
Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh);
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
Color bg = color;
bg.r = 1 - color.r;
bg.g = 1 - color.g;
@@ -673,7 +673,7 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
}
if (lines.size() > 2) {
- VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv);
+ RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv);
}
int limit = to_x - from_x - 4;
@@ -682,19 +682,19 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
}
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
} else {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
draw_rect(rect, color);
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
}
@@ -709,13 +709,13 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) {
int AnimationTrackEditVolumeDB::get_key_height() const {
- Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
+ Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
return volume_texture->get_height() * 1.2;
}
void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) {
- Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
+ Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;
@@ -727,7 +727,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) {
void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) {
- Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
+ Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;
int db0 = y_from + (24 / 80.0) * tex_h;
@@ -762,12 +762,12 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec,
to_x = p_clip_right;
}
- Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
+ Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
color.a *= 0.7;
draw_line(Point2(from_x, y_from + h * tex_h), Point2(to_x, y_from + h_n * tex_h), color, 2);
@@ -790,7 +790,7 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) {
int AnimationTrackEditTypeAudio::get_key_height() const {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) {
@@ -854,7 +854,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
}
}
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
float fh = int(font->get_height() * 1.5);
float len = stream->get_length();
@@ -926,9 +926,9 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
Vector<Color> color;
color.push_back(Color(0.75, 0.75, 0.75));
- VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color);
+ RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color);
- Color cut_color = get_color("accent_color", "Editor");
+ Color cut_color = get_theme_color("accent_color", "Editor");
cut_color.a = 0.7;
if (start_ofs > 0 && pixel_begin > p_clip_left) {
draw_rect(Rect2(pixel_begin, rect.position.y, 1, rect.size.y), cut_color);
@@ -938,7 +938,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
}
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
}
@@ -1133,7 +1133,7 @@ int AnimationTrackEditTypeAnimation::get_key_height() const {
return AnimationTrackEdit::get_key_height();
}
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_sec) {
@@ -1162,7 +1162,7 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_
return Rect2(0, 0, len * p_pixels_sec, get_size().height);
} else {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
return Rect2(0, 0, fh, get_size().height);
}
@@ -1215,12 +1215,12 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
if (to_x <= from_x)
return;
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 1.5;
Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh);
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
Color bg = color;
bg.r = 1 - color.r;
bg.g = 1 - color.g;
@@ -1255,7 +1255,7 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
}
if (lines.size() > 2) {
- VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv);
+ RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv);
}
int limit = to_x - from_x - 4;
@@ -1264,19 +1264,19 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
}
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
} else {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh));
- Color color = get_color("font_color", "Label");
+ Color color = get_theme_color("font_color", "Label");
draw_rect(rect, color);
if (p_selected) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
draw_rect(rect, accent, false);
}
}
@@ -1300,14 +1300,14 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj
return audio;
}
- if (p_property == "frame" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite") || p_object->is_class("AnimatedSprite3D"))) {
+ if (p_property == "frame" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite2D") || p_object->is_class("AnimatedSprite3D"))) {
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_node(p_object);
return sprite;
}
- if (p_property == "frame_coords" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D"))) {
+ if (p_property == "frame_coords" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D"))) {
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_as_coords();
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index ddd702fc6c..26bc6dfaf2 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -30,7 +30,7 @@
#include "code_editor.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "core/string_builder.h"
#include "editor/editor_scale.h"
@@ -69,10 +69,10 @@ GotoLineDialog::GotoLineDialog() {
set_title(TTR("Go to Line"));
VBoxContainer *vbc = memnew(VBoxContainer);
- vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE);
add_child(vbc);
Label *l = memnew(Label);
@@ -91,25 +91,25 @@ void FindReplaceBar::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
- find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
- hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
- hide_button->set_hover_texture(get_icon("Close", "EditorIcons"));
- hide_button->set_pressed_texture(get_icon("Close", "EditorIcons"));
+ find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
+ find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
+ hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
+ hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons"));
+ hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons"));
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
set_process_unhandled_input(is_visible_in_tree());
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
- find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
- hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
- hide_button->set_hover_texture(get_icon("Close", "EditorIcons"));
- hide_button->set_pressed_texture(get_icon("Close", "EditorIcons"));
+ find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
+ find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
+ hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
+ hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons"));
+ hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons"));
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
- matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor"));
+ matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
}
}
@@ -277,7 +277,7 @@ void FindReplaceBar::_replace_all() {
}
text_edit->set_v_scroll(vsval);
- matches_label->add_color_override("font_color", rc > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor"));
+ matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
matches_label->set_text(vformat(TTR("%d replaced."), rc));
text_edit->call_deferred("connect", "text_changed", Callable(this, "_editor_text_changed"));
@@ -331,7 +331,7 @@ void FindReplaceBar::_update_matches_label() {
} else {
matches_label->show();
- matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor"));
+ matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count));
}
}
@@ -505,7 +505,7 @@ void FindReplaceBar::_search_text_changed(const String &p_text) {
void FindReplaceBar::_search_text_entered(const String &p_text) {
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
search_prev();
} else {
search_next();
@@ -517,7 +517,7 @@ void FindReplaceBar::_replace_text_entered(const String &p_text) {
if (selection_only->is_pressed() && text_edit->is_selection_active()) {
_replace_all();
_hide_bar();
- } else if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ } else if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
_replace();
search_prev();
} else {
@@ -712,7 +712,7 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
- Ref<DynamicFont> font = text_editor->get_font("font");
+ Ref<DynamicFont> font = text_editor->get_theme_font("font");
if (font.is_valid()) {
if (font->get_size() != (int)font_size) {
@@ -760,7 +760,7 @@ void CodeTextEditor::_zoom_changed() {
}
void CodeTextEditor::_reset_zoom() {
- Ref<DynamicFont> font = text_editor->get_font("font"); // Reset source font size to default.
+ Ref<DynamicFont> font = text_editor->get_theme_font("font"); // Reset source font size to default.
if (font.is_valid()) {
EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14);
@@ -828,41 +828,41 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp
Ref<Texture2D> tex;
switch (p_option.kind) {
case ScriptCodeCompletionOption::KIND_CLASS: {
- if (has_icon(p_option.display, "EditorIcons")) {
- tex = get_icon(p_option.display, "EditorIcons");
+ if (has_theme_icon(p_option.display, "EditorIcons")) {
+ tex = get_theme_icon(p_option.display, "EditorIcons");
} else {
- tex = get_icon("Object", "EditorIcons");
+ tex = get_theme_icon("Object", "EditorIcons");
}
} break;
case ScriptCodeCompletionOption::KIND_ENUM:
- tex = get_icon("Enum", "EditorIcons");
+ tex = get_theme_icon("Enum", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_FILE_PATH:
- tex = get_icon("File", "EditorIcons");
+ tex = get_theme_icon("File", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_NODE_PATH:
- tex = get_icon("NodePath", "EditorIcons");
+ tex = get_theme_icon("NodePath", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_VARIABLE:
- tex = get_icon("Variant", "EditorIcons");
+ tex = get_theme_icon("Variant", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_CONSTANT:
- tex = get_icon("MemberConstant", "EditorIcons");
+ tex = get_theme_icon("MemberConstant", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_MEMBER:
- tex = get_icon("MemberProperty", "EditorIcons");
+ tex = get_theme_icon("MemberProperty", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_SIGNAL:
- tex = get_icon("MemberSignal", "EditorIcons");
+ tex = get_theme_icon("MemberSignal", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_FUNCTION:
- tex = get_icon("MemberMethod", "EditorIcons");
+ tex = get_theme_icon("MemberMethod", "EditorIcons");
break;
case ScriptCodeCompletionOption::KIND_PLAIN_TEXT:
- tex = get_icon("CubeMesh", "EditorIcons");
+ tex = get_theme_icon("CubeMesh", "EditorIcons");
break;
default:
- tex = get_icon("String", "EditorIcons");
+ tex = get_theme_icon("String", "EditorIcons");
break;
}
return tex;
@@ -877,7 +877,7 @@ void CodeTextEditor::_font_resize_timeout() {
bool CodeTextEditor::_add_font_size(int p_delta) {
- Ref<DynamicFont> font = text_editor->get_font("font");
+ Ref<DynamicFont> font = text_editor->get_theme_font("font");
if (font.is_valid()) {
int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE);
@@ -1454,18 +1454,18 @@ void CodeTextEditor::goto_error() {
void CodeTextEditor::_update_font() {
- text_editor->add_font_override("font", get_font("source", "EditorFonts"));
+ text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
- error->add_font_override("font", get_font("status_source", "EditorFonts"));
- error->add_color_override("font_color", get_color("error_color", "Editor"));
+ error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts"));
+ error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
- Ref<Font> status_bar_font = get_font("status_source", "EditorFonts");
- error->add_font_override("font", status_bar_font);
+ Ref<Font> status_bar_font = get_theme_font("status_source", "EditorFonts");
+ error->add_theme_font_override("font", status_bar_font);
int count = status_bar->get_child_count();
for (int i = 0; i < count; i++) {
Control *n = Object::cast_to<Control>(status_bar->get_child(i));
if (n)
- n->add_font_override("font", status_bar_font);
+ n->add_theme_font_override("font", status_bar_font);
}
}
@@ -1516,7 +1516,7 @@ void CodeTextEditor::_set_show_warnings_panel(bool p_show) {
}
void CodeTextEditor::_toggle_scripts_pressed() {
- toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_icon("Back", "EditorIcons") : get_icon("Forward", "EditorIcons"));
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons"));
}
void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
@@ -1540,8 +1540,8 @@ void CodeTextEditor::_notification(int p_what) {
_update_font();
} break;
case NOTIFICATION_ENTER_TREE: {
- warning_button->set_icon(get_icon("NodeWarning", "EditorIcons"));
- add_constant_override("separation", 4 * EDSCALE);
+ warning_button->set_icon(get_theme_icon("NodeWarning", "EditorIcons"));
+ add_theme_constant_override("separation", 4 * EDSCALE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (toggle_scripts_button->is_visible()) {
@@ -1650,7 +1650,7 @@ void CodeTextEditor::show_toggle_scripts_button() {
}
void CodeTextEditor::update_toggle_scripts_button() {
- toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_icon("Back", "EditorIcons") : get_icon("Forward", "EditorIcons"));
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons"));
toggle_scripts_button->set_tooltip(TTR("Toggle Scripts Panel") + " (" + ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text() + ")");
}
@@ -1729,8 +1729,8 @@ CodeTextEditor::CodeTextEditor() {
warning_count_label->set_default_cursor_shape(CURSOR_POINTING_HAND);
warning_count_label->set_mouse_filter(MOUSE_FILTER_STOP);
warning_count_label->set_tooltip(TTR("Warnings"));
- warning_count_label->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor"));
- warning_count_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts"));
+ warning_count_label->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"));
+ warning_count_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
warning_count_label->connect("gui_input", callable_mp(this, &CodeTextEditor::_warning_label_gui_input));
is_warnings_panel_opened = false;
@@ -1740,7 +1740,7 @@ CodeTextEditor::CodeTextEditor() {
line_and_col_txt = memnew(Label);
status_bar->add_child(line_and_col_txt);
line_and_col_txt->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
- line_and_col_txt->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts"));
+ line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
line_and_col_txt->set_tooltip(TTR("Line and column numbers."));
line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP);
diff --git a/editor/collada/SCsub b/editor/collada/SCsub
deleted file mode 100644
index 2b1e889fb0..0000000000
--- a/editor/collada/SCsub
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-
-env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 60a15984ee..7f03fd30f0 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -115,7 +115,7 @@ void ConnectDialog::ok_pressed() {
if (dst_method->get_text() == "") {
error->set_text(TTR("Method in target node must be specified."));
- error->popup_centered_minsize();
+ error->popup_centered();
return;
}
Node *target = tree->get_selected();
@@ -125,7 +125,7 @@ void ConnectDialog::ok_pressed() {
if (target->get_script().is_null()) {
if (!target->has_method(dst_method->get_text())) {
error->set_text(TTR("Target method not found. Specify a valid method or attach a script to the target node."));
- error->popup_centered_minsize();
+ error->popup_centered();
return;
}
}
@@ -341,7 +341,7 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) {
void ConnectDialog::popup_dialog(const String &p_for_signal) {
from_signal->set_text(p_for_signal);
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor"));
if (!advanced->is_pressed())
error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root()));
@@ -351,14 +351,14 @@ void ConnectDialog::popup_dialog(const String &p_for_signal) {
void ConnectDialog::_advanced_pressed() {
if (advanced->is_pressed()) {
- set_custom_minimum_size(Size2(900, 500) * EDSCALE);
+ set_min_size(Size2(900, 500) * EDSCALE);
connect_to_label->set_text(TTR("Connect to Node:"));
tree->set_connect_to_script_mode(false);
vbc_right->show();
error_label->hide();
} else {
- set_custom_minimum_size(Size2(600, 500) * EDSCALE);
+ set_min_size(Size2(600, 500) * EDSCALE);
set_size(Size2());
connect_to_label->set_text(TTR("Connect to Script:"));
tree->set_connect_to_script_mode(true);
@@ -369,23 +369,23 @@ void ConnectDialog::_advanced_pressed() {
_update_ok_enabled();
- set_position((get_viewport_rect().size - get_custom_minimum_size()) / 2);
+ popup_centered();
}
ConnectDialog::ConnectDialog() {
- set_custom_minimum_size(Size2(600, 500) * EDSCALE);
+ set_min_size(Size2(600, 500) * EDSCALE);
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
HBoxContainer *main_hb = memnew(HBoxContainer);
vbc->add_child(main_hb);
- main_hb->set_v_size_flags(SIZE_EXPAND_FILL);
+ main_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
VBoxContainer *vbc_left = memnew(VBoxContainer);
main_hb->add_child(vbc_left);
- vbc_left->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
from_signal = memnew(LineEdit);
from_signal->set_editable(false);
@@ -407,13 +407,13 @@ ConnectDialog::ConnectDialog() {
vbc_right = memnew(VBoxContainer);
main_hb->add_child(vbc_right);
- vbc_right->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_right->set_h_size_flags(Control::SIZE_EXPAND_FILL);
vbc_right->hide();
HBoxContainer *add_bind_hb = memnew(HBoxContainer);
type_list = memnew(OptionButton);
- type_list->set_h_size_flags(SIZE_EXPAND_FILL);
+ type_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_bind_hb->add_child(type_list);
type_list->add_item("bool", Variant::BOOL);
type_list->add_item("int", Variant::INT);
@@ -451,7 +451,7 @@ ConnectDialog::ConnectDialog() {
vbc_left->add_margin_child(TTR("Receiver Method:"), dstm_hb);
dst_method = memnew(LineEdit);
- dst_method->set_h_size_flags(SIZE_EXPAND_FILL);
+ dst_method->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dst_method->connect("text_entered", callable_mp(this, &ConnectDialog::_text_entered));
dstm_hb->add_child(dst_method);
@@ -477,8 +477,6 @@ ConnectDialog::ConnectDialog() {
oneshot->set_tooltip(TTR("Disconnects the signal after its first emission."));
vbc_right->add_child(oneshot);
- set_as_toplevel(true);
-
cdbinds = memnew(ConnectDialogBinds);
error = memnew(AcceptDialog);
@@ -499,7 +497,7 @@ ConnectDialog::~ConnectDialog() {
Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
EditorHelpBit *help_bit = memnew(EditorHelpBit);
- help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
+ help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
String text = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]";
@@ -909,21 +907,21 @@ void ConnectionsDock::update_tree() {
else
name = scr->get_class();
- if (has_icon(scr->get_class(), "EditorIcons")) {
- icon = get_icon(scr->get_class(), "EditorIcons");
+ if (has_theme_icon(scr->get_class(), "EditorIcons")) {
+ icon = get_theme_icon(scr->get_class(), "EditorIcons");
}
}
} else {
ClassDB::get_signal_list(base, &node_signals2, true);
- if (has_icon(base, "EditorIcons")) {
- icon = get_icon(base, "EditorIcons");
+ if (has_theme_icon(base, "EditorIcons")) {
+ icon = get_theme_icon(base, "EditorIcons");
}
name = base;
}
if (!icon.is_valid()) {
- icon = get_icon("Object", "EditorIcons");
+ icon = get_theme_icon("Object", "EditorIcons");
}
TreeItem *pitem = NULL;
@@ -934,7 +932,7 @@ void ConnectionsDock::update_tree() {
pitem->set_icon(0, icon);
pitem->set_selectable(0, false);
pitem->set_editable(0, false);
- pitem->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ pitem->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
node_signals2.sort();
}
@@ -970,7 +968,7 @@ void ConnectionsDock::update_tree() {
sinfo["name"] = signal_name;
sinfo["args"] = argnames;
item->set_metadata(0, sinfo);
- item->set_icon(0, get_icon("Signal", "EditorIcons"));
+ item->set_icon(0, get_theme_icon("Signal", "EditorIcons"));
// Set tooltip with the signal's documentation.
{
@@ -1045,7 +1043,7 @@ void ConnectionsDock::update_tree() {
item2->set_text(0, path);
Connection cd = c;
item2->set_metadata(0, cd);
- item2->set_icon(0, get_icon("Slot", "EditorIcons"));
+ item2->set_icon(0, get_theme_icon("Slot", "EditorIcons"));
}
}
@@ -1072,7 +1070,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
tree->set_select_mode(Tree::SELECT_ROW);
tree->set_hide_root(true);
vbc->add_child(tree);
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tree->set_allow_rmb_select(true);
connect_button = memnew(Button);
@@ -1083,11 +1081,9 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
connect_button->connect("pressed", callable_mp(this, &ConnectionsDock::_connect_pressed));
connect_dialog = memnew(ConnectDialog);
- connect_dialog->set_as_toplevel(true);
add_child(connect_dialog);
disconnect_all_dialog = memnew(ConfirmationDialog);
- disconnect_all_dialog->set_as_toplevel(true);
add_child(disconnect_all_dialog);
disconnect_all_dialog->connect("confirmed", callable_mp(this, &ConnectionsDock::_disconnect_all));
disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from this signal?"));
@@ -1110,7 +1106,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
tree->connect("item_activated", callable_mp(this, &ConnectionsDock::_tree_item_activated));
tree->connect("item_rmb_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed));
- add_constant_override("separation", 3 * EDSCALE);
+ add_theme_constant_override("separation", 3 * EDSCALE);
}
ConnectionsDock::~ConnectionsDock() {
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index b220e82f6c..6210b580ba 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -193,7 +193,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
item->set_text(0, p_type + " (" + ScriptServer::get_global_class_path(p_type).get_file() + ")");
}
if (!can_instance) {
- item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ item->set_custom_color(0, search_options->get_theme_color("disabled_font_color", "Editor"));
item->set_selectable(0, false);
} else if (!(*to_select && (*to_select)->get_text(0) == search_box->get_text())) {
String search_term = search_box->get_text().to_lower();
@@ -310,8 +310,8 @@ void CreateDialog::_update_search() {
EditorData &ed = EditorNode::get_editor_data();
root->set_text(0, base_type);
- if (has_icon(base_type, "EditorIcons")) {
- root->set_icon(0, get_icon(base_type, "EditorIcons"));
+ if (search_options->has_theme_icon(base_type, "EditorIcons")) {
+ root->set_icon(0, search_options->get_theme_icon(base_type, "EditorIcons"));
}
TreeItem *to_select = search_box->get_text() == base_type ? root : NULL;
@@ -460,23 +460,22 @@ void CreateDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
- favorite->set_icon(get_icon("Favorites", "EditorIcons"));
+ favorite->set_icon(search_options->get_theme_icon("Favorites", "EditorIcons"));
} break;
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible_in_tree()) {
+ if (is_visible()) {
search_box->call_deferred("grab_focus"); // still not visible
search_box->select_all();
+ } else {
+ EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size()));
+ search_loaded_scripts.clear();
}
} break;
- case NOTIFICATION_POPUP_HIDE: {
- EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", get_rect());
- search_loaded_scripts.clear();
- } break;
}
}
@@ -562,7 +561,7 @@ void CreateDialog::_item_selected() {
}
void CreateDialog::_hide_requested() {
- _closed(); // From WindowDialog.
+ _cancel_pressed(); // From AcceptDialog.
}
void CreateDialog::_favorite_toggled() {
@@ -662,7 +661,7 @@ Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
ToolButton *tb = memnew(ToolButton);
tb->set_icon(ti->get_icon(0));
tb->set_text(ti->get_text(0));
- set_drag_preview(tb);
+ favorites->set_drag_preview(tb);
return d;
}
@@ -743,8 +742,6 @@ CreateDialog::CreateDialog() {
is_replace_mode = false;
- set_resizable(true);
-
HSplitContainer *hsc = memnew(HSplitContainer);
add_child(hsc);
@@ -754,7 +751,7 @@ CreateDialog::CreateDialog() {
VBoxContainer *fav_vb = memnew(VBoxContainer);
vsc->add_child(fav_vb);
fav_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
- fav_vb->set_v_size_flags(SIZE_EXPAND_FILL);
+ fav_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
favorites = memnew(Tree);
fav_vb->add_margin_child(TTR("Favorites:"), favorites, true);
@@ -763,13 +760,16 @@ CreateDialog::CreateDialog() {
favorites->set_allow_reselect(true);
favorites->connect("cell_selected", callable_mp(this, &CreateDialog::_favorite_selected));
favorites->connect("item_activated", callable_mp(this, &CreateDialog::_favorite_activated));
- favorites->set_drag_forwarding(this);
- favorites->add_constant_override("draw_guides", 1);
+#ifndef _MSC_VER
+#warning cant forward drag data to a non control, must be fixed
+#endif
+ //favorites->set_drag_forwarding(this);
+ favorites->add_theme_constant_override("draw_guides", 1);
VBoxContainer *rec_vb = memnew(VBoxContainer);
vsc->add_child(rec_vb);
rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
- rec_vb->set_v_size_flags(SIZE_EXPAND_FILL);
+ rec_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
recent = memnew(Tree);
rec_vb->add_margin_child(TTR("Recent:"), recent, true);
@@ -778,15 +778,15 @@ CreateDialog::CreateDialog() {
recent->set_allow_reselect(true);
recent->connect("cell_selected", callable_mp(this, &CreateDialog::_history_selected));
recent->connect("item_activated", callable_mp(this, &CreateDialog::_history_activated));
- recent->add_constant_override("draw_guides", 1);
+ recent->add_theme_constant_override("draw_guides", 1);
VBoxContainer *vbc = memnew(VBoxContainer);
hsc->add_child(vbc);
vbc->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
- vbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *search_hb = memnew(HBoxContainer);
search_box = memnew(LineEdit);
- search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_hb->add_child(search_box);
favorite = memnew(Button);
favorite->set_flat(true);
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index f4a8102b79..5c9b977247 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -53,8 +53,8 @@ EditorDebuggerNode::EditorDebuggerNode() {
if (!singleton)
singleton = this;
- add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
- add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
+ add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
+ add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
tabs = memnew(TabContainer);
tabs->set_tab_align(TabContainer::ALIGN_LEFT);
@@ -64,7 +64,7 @@ EditorDebuggerNode::EditorDebuggerNode() {
Ref<StyleBoxEmpty> empty;
empty.instance();
- tabs->add_style_override("panel", empty);
+ tabs->add_theme_style_override("panel", empty);
auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false);
_add_debugger();
@@ -110,7 +110,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
if (tabs->get_tab_count() > 1) {
node->clear_style();
tabs->set_tabs_visible(true);
- tabs->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
+ tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles"));
}
return node;
@@ -223,10 +223,10 @@ void EditorDebuggerNode::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (tabs->get_tab_count() > 1) {
- add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
- add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
+ add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
+ add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
- tabs->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
+ tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles"));
}
} break;
default:
@@ -262,9 +262,9 @@ void EditorDebuggerNode::_notification(int p_what) {
} else {
debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
if (error_count == 0) {
- debugger_button->set_icon(get_icon("Warning", "EditorIcons"));
+ debugger_button->set_icon(get_theme_icon("Warning", "EditorIcons"));
} else {
- debugger_button->set_icon(get_icon("Error", "EditorIcons"));
+ debugger_button->set_icon(get_theme_icon("Error", "EditorIcons"));
}
}
last_error_count = error_count;
@@ -371,7 +371,6 @@ void EditorDebuggerNode::set_script_debug_button(MenuButton *p_button) {
script_menu->set_text(TTR("Debug"));
script_menu->set_switch_on_hover(true);
PopupMenu *p = script_menu->get_popup();
- p->set_hide_on_window_lose_focus(true);
p->add_shortcut(ED_GET_SHORTCUT("debugger/step_into"), DEBUG_STEP);
p->add_shortcut(ED_GET_SHORTCUT("debugger/step_over"), DEBUG_NEXT);
p->add_separator();
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index 019a5d0fc3..427b929ccb 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -33,6 +33,7 @@
#include "editor/editor_node.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/packed_scene.h"
+#include "servers/display_server.h"
EditorDebuggerTree::EditorDebuggerTree() {
set_v_size_flags(SIZE_EXPAND_FILL);
@@ -106,9 +107,9 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) {
item->select(0);
item_menu->clear();
- item_menu->add_icon_item(get_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE);
- item_menu->add_icon_item(get_icon("CopyNodePath", "EditorIcons"), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH);
- item_menu->set_global_position(get_global_mouse_position());
+ item_menu->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE);
+ item_menu->add_icon_item(get_theme_icon("CopyNodePath", "EditorIcons"), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH);
+ item_menu->set_position(get_screen_transform().xform(get_local_mouse_position()));
item_menu->popup();
}
@@ -229,7 +230,7 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) {
case ITEM_MENU_SAVE_REMOTE_NODE: {
file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
List<String> extensions;
Ref<PackedScene> sd = memnew(PackedScene);
@@ -257,7 +258,7 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) {
text = text.substr(slash + 1);
}
}
- OS::get_singleton()->set_clipboard(text);
+ DisplayServer::get_singleton()->clipboard_set(text);
} break;
}
}
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index 21ef66d1aa..b8c795d9ca 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -41,14 +41,14 @@ void EditorNetworkProfiler::_bind_methods() {
void EditorNetworkProfiler::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- activate->set_icon(get_icon("Play", "EditorIcons"));
- clear_button->set_icon(get_icon("Clear", "EditorIcons"));
- incoming_bandwidth_text->set_right_icon(get_icon("ArrowDown", "EditorIcons"));
- outgoing_bandwidth_text->set_right_icon(get_icon("ArrowUp", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
+ clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
+ incoming_bandwidth_text->set_right_icon(get_theme_icon("ArrowDown", "EditorIcons"));
+ outgoing_bandwidth_text->set_right_icon(get_theme_icon("ArrowUp", "EditorIcons"));
// This needs to be done here to set the faded color when the profiler is first opened
- incoming_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5));
- outgoing_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5));
+ incoming_bandwidth_text->add_theme_color_override("font_color_uneditable", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5));
+ outgoing_bandwidth_text->add_theme_color_override("font_color_uneditable", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5));
}
}
@@ -77,10 +77,10 @@ void EditorNetworkProfiler::_update_frame() {
void EditorNetworkProfiler::_activate_pressed() {
if (activate->is_pressed()) {
- activate->set_icon(get_icon("Stop", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop"));
} else {
- activate->set_icon(get_icon("Play", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
activate->set_text(TTR("Start"));
}
emit_signal("enable_profiling", activate->is_pressed());
@@ -118,12 +118,12 @@ void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) {
outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing)));
// Make labels more prominent when the bandwidth is greater than 0 to attract user attention
- incoming_bandwidth_text->add_color_override(
+ incoming_bandwidth_text->add_theme_color_override(
"font_color_uneditable",
- get_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5));
- outgoing_bandwidth_text->add_color_override(
+ get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5));
+ outgoing_bandwidth_text->add_theme_color_override(
"font_color_uneditable",
- get_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5));
+ get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5));
}
bool EditorNetworkProfiler::is_profiling() {
@@ -133,7 +133,7 @@ bool EditorNetworkProfiler::is_profiling() {
EditorNetworkProfiler::EditorNetworkProfiler() {
HBoxContainer *hb = memnew(HBoxContainer);
- hb->add_constant_override("separation", 8 * EDSCALE);
+ hb->add_theme_constant_override("separation", 8 * EDSCALE);
add_child(hb);
activate = memnew(Button);
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index ca4979563d..1577e24ac0 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -132,11 +132,11 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca
Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const {
- Color bc = get_color("error_color", "Editor");
+ Color bc = get_theme_color("error_color", "Editor");
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
Color c;
c.set_hsv(rot, bc.get_s(), bc.get_v());
- return c.linear_interpolate(get_color("base_color", "Editor"), 0.07);
+ return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07);
}
void EditorProfiler::_item_edited() {
@@ -176,7 +176,7 @@ void EditorProfiler::_update_plot() {
}
uint8_t *wr = graph_image.ptrw();
- const Color background_color = get_color("dark_color_2", "Editor");
+ const Color background_color = get_theme_color("dark_color_2", "Editor");
// Clear the previous frame and set the background color.
for (int i = 0; i < desired_len; i += 4) {
@@ -420,10 +420,10 @@ void EditorProfiler::_update_frame() {
void EditorProfiler::_activate_pressed() {
if (activate->is_pressed()) {
- activate->set_icon(get_icon("Stop", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop"));
} else {
- activate->set_icon(get_icon("Play", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
activate->set_text(TTR("Start"));
}
emit_signal("enable_profiling", activate->is_pressed());
@@ -438,8 +438,8 @@ void EditorProfiler::_clear_pressed() {
void EditorProfiler::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- activate->set_icon(get_icon("Play", "EditorIcons"));
- clear_button->set_icon(get_icon("Clear", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
+ clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
}
}
@@ -712,7 +712,7 @@ EditorProfiler::EditorProfiler() {
hb->add_child(cursor_metric_edit);
cursor_metric_edit->connect("value_changed", callable_mp(this, &EditorProfiler::_cursor_metric_changed));
- hb->add_constant_override("separation", 8 * EDSCALE);
+ hb->add_theme_constant_override("separation", 8 * EDSCALE);
h_split = memnew(HSplitContainer);
add_child(h_split);
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index 48425062d1..d2edba5970 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -128,11 +128,11 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) {
Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const {
- Color bc = get_color("error_color", "Editor");
+ Color bc = get_theme_color("error_color", "Editor");
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
Color c;
c.set_hsv(rot, bc.get_s(), bc.get_v());
- return c.linear_interpolate(get_color("base_color", "Editor"), 0.07);
+ return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07);
}
void EditorVisualProfiler::_item_selected() {
@@ -327,7 +327,7 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
int cursor_metric = _get_cursor_index();
- Ref<Texture> track_icon = get_icon("TrackColor", "EditorIcons");
+ Ref<Texture> track_icon = get_theme_icon("TrackColor", "EditorIcons");
ERR_FAIL_INDEX(cursor_metric, frame_metrics.size());
@@ -418,11 +418,11 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
void EditorVisualProfiler::_activate_pressed() {
if (activate->is_pressed()) {
- activate->set_icon(get_icon("Stop", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop"));
_clear_pressed(); //always clear on start
} else {
- activate->set_icon(get_icon("Play", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
activate->set_text(TTR("Start"));
}
emit_signal("enable_profiling", activate->is_pressed());
@@ -437,8 +437,8 @@ void EditorVisualProfiler::_clear_pressed() {
void EditorVisualProfiler::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- activate->set_icon(get_icon("Play", "EditorIcons"));
- clear_button->set_icon(get_icon("Clear", "EditorIcons"));
+ activate->set_icon(get_theme_icon("Play", "EditorIcons"));
+ clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
}
}
@@ -446,7 +446,7 @@ void EditorVisualProfiler::_graph_tex_draw() {
if (last_metric < 0)
return;
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
if (seeking) {
int max_frames = frame_metrics.size();
@@ -777,7 +777,7 @@ EditorVisualProfiler::EditorVisualProfiler() {
hb->add_child(cursor_metric_edit);
cursor_metric_edit->connect("value_changed", callable_mp(this, &EditorVisualProfiler::_cursor_metric_changed));
- hb->add_constant_override("separation", 8 * EDSCALE);
+ hb->add_theme_constant_override("separation", 8 * EDSCALE);
h_split = memnew(HSplitContainer);
add_child(h_split);
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index dcb1611f71..bdb1ebd4d7 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -42,10 +42,10 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/property_editor.h"
#include "main/performance.h"
-#include "scene/3d/camera.h"
+#include "scene/3d/camera_3d.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/label.h"
@@ -58,6 +58,7 @@
#include "scene/gui/texture_button.h"
#include "scene/gui/tree.h"
#include "scene/resources/packed_scene.h"
+#include "servers/display_server.h"
using CameraOverride = EditorDebuggerNode::CameraOverride;
@@ -73,15 +74,15 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) {
void ScriptEditorDebugger::debug_copy() {
String msg = reason->get_text();
if (msg == "") return;
- OS::get_singleton()->set_clipboard(msg);
+ DisplayServer::get_singleton()->clipboard_set(msg);
}
void ScriptEditorDebugger::debug_skip_breakpoints() {
skip_breakpoints_value = !skip_breakpoints_value;
if (skip_breakpoints_value)
- skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOn", "EditorIcons"));
+ skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons"));
else
- skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons"));
+ skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons"));
Array msg;
msg.push_back(skip_breakpoints_value);
@@ -116,7 +117,7 @@ void ScriptEditorDebugger::debug_continue() {
// Allow focus stealing only if we actually run this client for security.
if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid))
- OS::get_singleton()->enable_for_stealing_focus(remote_pid);
+ DisplayServer::get_singleton()->enable_for_stealing_focus(remote_pid);
_clear_execution();
_put_msg("continue", Array());
@@ -129,15 +130,15 @@ void ScriptEditorDebugger::update_tabs() {
} else {
errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")");
if (error_count == 0) {
- tabs->set_tab_icon(errors_tab->get_index(), get_icon("Warning", "EditorIcons"));
+ tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Warning", "EditorIcons"));
} else {
- tabs->set_tab_icon(errors_tab->get_index(), get_icon("Error", "EditorIcons"));
+ tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Error", "EditorIcons"));
}
}
}
void ScriptEditorDebugger::clear_style() {
- tabs->add_style_override("panel", NULL);
+ tabs->add_theme_style_override("panel", NULL);
}
void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) {
@@ -253,7 +254,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
_update_buttons_state();
_set_reason_text(error, MESSAGE_ERROR);
emit_signal("breaked", true, can_continue);
- OS::get_singleton()->move_window_to_foreground();
+ DisplayServer::get_singleton()->window_move_to_foreground();
if (error != "") {
tabs->set_current_tab(0);
}
@@ -310,8 +311,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
it->set_text(3, String::humanize_size(bytes));
total += bytes;
- if (has_icon(type, "EditorIcons"))
- it->set_icon(0, get_icon(type, "EditorIcons"));
+ if (has_theme_icon(type, "EditorIcons"))
+ it->set_icon(0, get_theme_icon(type, "EditorIcons"));
}
vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total));
@@ -442,7 +443,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
TreeItem *error = error_tree->create_item(r);
error->set_collapsed(true);
- error->set_icon(0, get_icon(oe.warning ? "Warning" : "Error", "EditorIcons"));
+ error->set_icon(0, get_theme_icon(oe.warning ? "Warning" : "Error", "EditorIcons"));
error->set_text(0, time);
error->set_text_align(0, TreeItem::ALIGN_LEFT);
@@ -660,13 +661,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) {
switch (p_type) {
case MESSAGE_ERROR:
- reason->add_color_override("font_color", get_color("error_color", "Editor"));
+ reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
break;
case MESSAGE_WARNING:
- reason->add_color_override("font_color", get_color("warning_color", "Editor"));
+ reason->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
break;
default:
- reason->add_color_override("font_color", get_color("success_color", "Editor"));
+ reason->add_theme_color_override("font_color", get_theme_color("success_color", "Editor"));
}
reason->set_text(p_reason);
reason->set_tooltip(p_reason.word_wrap(80));
@@ -693,8 +694,8 @@ void ScriptEditorDebugger::_performance_draw() {
info_message->hide();
- Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit");
- Ref<Font> graph_font = get_font("font", "TextEdit");
+ Ref<StyleBox> graph_sb = get_theme_stylebox("normal", "TextEdit");
+ Ref<Font> graph_font = get_theme_font("font", "TextEdit");
int cols = Math::ceil(Math::sqrt((float)which.size()));
int rows = Math::ceil((float)which.size() / cols);
@@ -714,7 +715,7 @@ void ScriptEditorDebugger::_performance_draw() {
r.position += graph_sb->get_offset();
r.size -= graph_sb->get_minimum_size();
int pi = which[i];
- Color c = get_color("accent_color", "Editor");
+ Color c = get_theme_color("accent_color", "Editor");
float h = (float)which[i] / (float)(perf_items.size());
// Use a darker color on light backgrounds for better visibility
float value_multiplier = EditorSettings::get_singleton()->is_dark_theme() ? 1.4 : 0.55;
@@ -753,20 +754,20 @@ void ScriptEditorDebugger::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons"));
- copy->set_icon(get_icon("ActionCopy", "EditorIcons"));
+ skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons"));
+ copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons"));
- step->set_icon(get_icon("DebugStep", "EditorIcons"));
- next->set_icon(get_icon("DebugNext", "EditorIcons"));
- dobreak->set_icon(get_icon("Pause", "EditorIcons"));
- docontinue->set_icon(get_icon("DebugContinue", "EditorIcons"));
+ step->set_icon(get_theme_icon("DebugStep", "EditorIcons"));
+ next->set_icon(get_theme_icon("DebugNext", "EditorIcons"));
+ dobreak->set_icon(get_theme_icon("Pause", "EditorIcons"));
+ docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons"));
le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set));
le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected));
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
- vmem_refresh->set_icon(get_icon("Reload", "EditorIcons"));
+ vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons"));
- reason->add_color_override("font_color", get_color("error_color", "Editor"));
+ reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
} break;
case NOTIFICATION_PROCESS: {
@@ -790,12 +791,12 @@ void ScriptEditorDebugger::_notification(int p_what) {
} else if (camera_override >= CameraOverride::OVERRIDE_3D_1) {
int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1;
- SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(viewport_idx);
- Camera *const cam = viewport->get_camera();
+ Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(viewport_idx);
+ Camera3D *const cam = viewport->get_camera();
Array msg;
msg.push_back(cam->get_camera_transform());
- if (cam->get_projection() == Camera::PROJECTION_ORTHOGONAL) {
+ if (cam->get_projection() == Camera3D::PROJECTION_ORTHOGONAL) {
msg.push_back(false);
msg.push_back(cam->get_size());
} else {
@@ -829,16 +830,16 @@ void ScriptEditorDebugger::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (tabs->has_stylebox_override("panel")) {
- tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
+ if (tabs->has_theme_stylebox_override("panel")) {
+ tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles"));
}
- copy->set_icon(get_icon("ActionCopy", "EditorIcons"));
- step->set_icon(get_icon("DebugStep", "EditorIcons"));
- next->set_icon(get_icon("DebugNext", "EditorIcons"));
- dobreak->set_icon(get_icon("Pause", "EditorIcons"));
- docontinue->set_icon(get_icon("DebugContinue", "EditorIcons"));
- vmem_refresh->set_icon(get_icon("Reload", "EditorIcons"));
+ copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons"));
+ step->set_icon(get_theme_icon("DebugStep", "EditorIcons"));
+ next->set_icon(get_theme_icon("DebugNext", "EditorIcons"));
+ dobreak->set_icon(get_theme_icon("Pause", "EditorIcons"));
+ docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons"));
+ vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons"));
} break;
}
}
@@ -978,7 +979,7 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
void ScriptEditorDebugger::_export_csv() {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog->popup_centered_ratio();
}
@@ -1388,7 +1389,7 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
item_menu->set_size(Size2(1, 1));
if (error_tree->is_anything_selected()) {
- item_menu->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), 0);
+ item_menu->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), 0);
}
if (item_menu->get_item_count() > 0) {
@@ -1404,9 +1405,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
String type;
- if (ti->get_icon(0) == get_icon("Warning", "EditorIcons")) {
+ if (ti->get_icon(0) == get_theme_icon("Warning", "EditorIcons")) {
type = "W ";
- } else if (ti->get_icon(0) == get_icon("Error", "EditorIcons")) {
+ } else if (ti->get_icon(0) == get_theme_icon("Error", "EditorIcons")) {
type = "E ";
}
@@ -1420,7 +1421,7 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
ci = ci->get_next();
}
- OS::get_singleton()->set_clipboard(text);
+ DisplayServer::get_singleton()->clipboard_set(text);
}
void ScriptEditorDebugger::_tab_changed(int p_tab) {
@@ -1461,7 +1462,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
tabs = memnew(TabContainer);
tabs->set_tab_align(TabContainer::ALIGN_LEFT);
- tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
+ tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles"));
tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed));
add_child(tabs);
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 5a0accd45c..8ba706d4b3 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -174,7 +174,7 @@ void DependencyEditor::_update_list() {
TreeItem *root = tree->create_item();
- Ref<Texture2D> folder = get_icon("folder", "FileDialog");
+ Ref<Texture2D> folder = tree->get_theme_icon("folder", "FileDialog");
bool broken = false;
@@ -256,7 +256,7 @@ DependencyEditor::DependencyEditor() {
vb->add_child(hbc);
MarginContainer *mc = memnew(MarginContainer);
- mc->set_v_size_flags(SIZE_EXPAND_FILL);
+ mc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
mc->add_child(tree);
vb->add_child(mc);
@@ -264,7 +264,7 @@ DependencyEditor::DependencyEditor() {
set_title(TTR("Dependency Editor"));
search = memnew(EditorFileDialog);
search->connect("file_selected", callable_mp(this, &DependencyEditor::_searched));
- search->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ search->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
search->set_title(TTR("Search Replacement Resource:"));
add_child(search);
}
@@ -422,17 +422,17 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed
if (!tree_items.has(rd.dependency_folder)) {
TreeItem *folder_item = owners->create_item(owners->get_root());
folder_item->set_text(0, rd.dependency_folder);
- folder_item->set_icon(0, get_icon("Folder", "EditorIcons"));
+ folder_item->set_icon(0, owners->get_theme_icon("Folder", "EditorIcons"));
tree_items[rd.dependency_folder] = folder_item;
}
TreeItem *dependency_item = owners->create_item(tree_items[rd.dependency_folder]);
dependency_item->set_text(0, rd.dependency);
- dependency_item->set_icon(0, get_icon("Warning", "EditorIcons"));
+ dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons"));
tree_items[rd.dependency] = dependency_item;
} else {
TreeItem *dependency_item = owners->create_item(owners->get_root());
dependency_item->set_text(0, rd.dependency);
- dependency_item->set_icon(0, get_icon("Warning", "EditorIcons"));
+ dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons"));
tree_items[rd.dependency] = dependency_item;
}
}
@@ -580,7 +580,7 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
owners = memnew(Tree);
owners->set_hide_root(true);
vb->add_child(owners);
- owners->set_v_size_flags(SIZE_EXPAND_FILL);
+ owners->set_v_size_flags(Control::SIZE_EXPAND_FILL);
}
//////////////
@@ -636,9 +636,9 @@ DependencyErrorDialog::DependencyErrorDialog() {
files = memnew(Tree);
files->set_hide_root(true);
vb->add_margin_child(TTR("Load failed due to missing dependencies:"), files, true);
- files->set_v_size_flags(SIZE_EXPAND_FILL);
+ files->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- set_custom_minimum_size(Size2(500, 220) * EDSCALE);
+ set_min_size(Size2(500, 220) * EDSCALE);
get_ok()->set_text(TTR("Open Anyway"));
get_cancel()->set_text(TTR("Close"));
@@ -662,7 +662,7 @@ void OrphanResourcesDialog::ok_pressed() {
return;
delete_confirm->set_text(vformat(TTR("Permanently delete %d item(s)? (No undo!)"), paths.size()));
- delete_confirm->popup_centered_clamped(delete_confirm->get_minimum_size());
+ delete_confirm->popup_centered();
}
bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) {
@@ -678,7 +678,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa
if (p_parent) {
dir_item = files->create_item(p_parent);
dir_item->set_text(0, efsd->get_subdir(i)->get_name());
- dir_item->set_icon(0, get_icon("folder", "FileDialog"));
+ dir_item->set_icon(0, files->get_theme_icon("folder", "FileDialog"));
}
bool children = _fill_owners(efsd->get_subdir(i), refs, dir_item);
@@ -717,7 +717,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa
int ds = efsd->get_file_deps(i).size();
ti->set_text(1, itos(ds));
if (ds) {
- ti->add_button(1, get_icon("GuiVisibilityVisible", "EditorIcons"), -1, false, TTR("Show Dependencies"));
+ ti->add_button(1, files->get_theme_icon("GuiVisibilityVisible", "EditorIcons"), -1, false, TTR("Show Dependencies"));
}
ti->set_metadata(0, path);
has_children = true;
diff --git a/editor/doc/SCsub b/editor/doc/SCsub
deleted file mode 100644
index 2b1e889fb0..0000000000
--- a/editor/doc/SCsub
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-
-env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp
deleted file mode 100644
index b0a89ff4b8..0000000000
--- a/editor/doc/doc_dump.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/*************************************************************************/
-/* doc_dump.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "doc_dump.h"
-
-#include "core/os/file_access.h"
-#include "core/version.h"
-#include "scene/main/node.h"
-
-static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) {
-
- String tab;
- for (int i = 0; i < p_tablevel; i++)
- tab += "\t";
- f->store_string(tab + p_string + "\n");
-}
-
-struct _ConstantSort {
-
- String name;
- int value;
- bool operator<(const _ConstantSort &p_c) const {
-
- String left_a = name.find("_") == -1 ? name : name.substr(0, name.find("_"));
- String left_b = p_c.name.find("_") == -1 ? p_c.name : p_c.name.substr(0, p_c.name.find("_"));
- if (left_a == left_b)
- return value < p_c.value;
- else
- return left_a < left_b;
- }
-};
-
-static String _escape_string(const String &p_str) {
-
- String ret = p_str;
- ret = ret.replace("&", "&amp;");
- ret = ret.replace("<", "&gt;");
- ret = ret.replace(">", "&lt;");
- ret = ret.replace("'", "&apos;");
- ret = ret.replace("\"", "&quot;");
- for (char i = 1; i < 32; i++) {
-
- char chr[2] = { i, 0 };
- ret = ret.replace(chr, "&#" + String::num(i) + ";");
- }
- ret = ret.utf8();
- return ret;
-}
-void DocDump::dump(const String &p_file) {
-
- List<StringName> class_list;
- ClassDB::get_class_list(&class_list);
-
- class_list.sort_custom<StringName::AlphCompare>();
-
- FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE);
-
- _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
- _write_string(f, 0, String("<doc version=\"") + VERSION_BRANCH + "\" name=\"Engine Types\">");
-
- while (class_list.size()) {
-
- String name = class_list.front()->get();
-
- String header = "<class name=\"" + name + "\"";
- String inherits = ClassDB::get_parent_class(name);
- if (inherits != "")
- header += " inherits=\"" + inherits + "\"";
- _write_string(f, 0, header);
-
- _write_string(f, 1, "<brief_description>");
- _write_string(f, 1, "</brief_description>");
-
- _write_string(f, 1, "<description>");
- _write_string(f, 1, "</description>");
-
- _write_string(f, 1, "<methods>");
-
- List<MethodInfo> method_list;
- ClassDB::get_method_list(name, &method_list, true);
- method_list.sort();
-
- for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
- if (E->get().name == "" || E->get().name[0] == '_')
- continue; //hidden
-
- MethodBind *m = ClassDB::get_method(name, E->get().name);
-
- String qualifiers;
- if (E->get().flags & METHOD_FLAG_CONST)
- qualifiers += "qualifiers=\"const\"";
-
- _write_string(f, 2, "<method name=\"" + _escape_string(E->get().name) + "\" " + qualifiers + " >");
-
- for (int i = -1; i < E->get().arguments.size(); i++) {
-
- PropertyInfo arginfo;
-
- if (i == -1) {
-
- arginfo = E->get().return_val;
- String type_name = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type);
-
- if (arginfo.type == Variant::NIL)
- continue;
- _write_string(f, 3, "<return type=\"" + type_name + "\">");
- } else {
-
- arginfo = E->get().arguments[i];
-
- String type_name;
-
- if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE)
- type_name = arginfo.hint_string;
- else if (arginfo.type == Variant::NIL)
- type_name = "Variant";
- else
- type_name = Variant::get_type_name(arginfo.type);
-
- if (m && m->has_default_argument(i)) {
- Variant default_arg = m->get_default_argument(i);
- String default_arg_text = String(_escape_string(m->get_default_argument(i)));
-
- switch (default_arg.get_type()) {
-
- case Variant::NIL:
- default_arg_text = "NULL";
- break;
- // atomic types
- case Variant::BOOL:
- if (bool(default_arg))
- default_arg_text = "true";
- else
- default_arg_text = "false";
- break;
- case Variant::INT:
- case Variant::FLOAT:
- //keep it
- break;
- case Variant::STRING:
- case Variant::STRING_NAME:
- default_arg_text = "@\"" + default_arg_text + "\"";
- break;
- case Variant::NODE_PATH:
- default_arg_text = "\"" + default_arg_text + "\"";
- break;
- case Variant::TRANSFORM:
- if (default_arg.operator Transform() == Transform()) {
- default_arg_text = "";
- }
-
- default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
- break;
-
- case Variant::VECTOR2:
- case Variant::RECT2:
- case Variant::VECTOR3:
- case Variant::PLANE:
- case Variant::QUAT:
- case Variant::AABB:
- case Variant::BASIS:
- case Variant::COLOR:
- case Variant::PACKED_BYTE_ARRAY:
- case Variant::PACKED_INT32_ARRAY:
- case Variant::PACKED_FLOAT32_ARRAY:
- case Variant::PACKED_INT64_ARRAY:
- case Variant::PACKED_FLOAT64_ARRAY:
- case Variant::PACKED_STRING_ARRAY:
- case Variant::PACKED_VECTOR3_ARRAY:
- case Variant::PACKED_COLOR_ARRAY:
- default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
- break;
- case Variant::OBJECT:
- case Variant::DICTIONARY:
- case Variant::ARRAY:
- case Variant::_RID:
-
- default: {
- }
- }
-
- _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + _escape_string(arginfo.name) + "\" type=\"" + type_name + "\" default=\"" + _escape_string(default_arg_text) + "\">");
- } else
- _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + type_name + "\">");
- }
-
- String hint;
- switch (arginfo.hint) {
- case PROPERTY_HINT_DIR: hint = "A directory."; break;
- case PROPERTY_HINT_RANGE: hint = "Range - min: " + arginfo.hint_string.get_slice(",", 0) + " max: " + arginfo.hint_string.get_slice(",", 1) + " step: " + arginfo.hint_string.get_slice(",", 2); break;
- case PROPERTY_HINT_ENUM:
- hint = "Values: ";
- for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) {
- if (j > 0) hint += ", ";
- hint += arginfo.hint_string.get_slice(",", j) + "=" + itos(j);
- }
- break;
- case PROPERTY_HINT_LENGTH: hint = "Length: " + arginfo.hint_string; break;
- case PROPERTY_HINT_FLAGS:
- hint = "Values: ";
- for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) {
- if (j > 0) hint += ", ";
- hint += arginfo.hint_string.get_slice(",", j) + "=" + itos((uint64_t)1 << j);
- }
- break;
- case PROPERTY_HINT_FILE: hint = "A file:"; break;
- default: {
- }
- //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break;
- };
- if (hint != "")
- _write_string(f, 4, hint);
-
- _write_string(f, 3, (i == -1) ? "</return>" : "</argument>");
- }
-
- _write_string(f, 3, "<description>");
- _write_string(f, 3, "</description>");
-
- _write_string(f, 2, "</method>");
- }
-
- _write_string(f, 1, "</methods>");
-
- List<MethodInfo> signal_list;
- ClassDB::get_signal_list(name, &signal_list, true);
-
- if (signal_list.size()) {
-
- _write_string(f, 1, "<signals>");
- for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
-
- _write_string(f, 2, "<signal name=\"" + EV->get().name + "\">");
- for (int i = 0; i < EV->get().arguments.size(); i++) {
- PropertyInfo arginfo = EV->get().arguments[i];
- _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + Variant::get_type_name(arginfo.type) + "\">");
- _write_string(f, 3, "</argument>");
- }
- _write_string(f, 3, "<description>");
- _write_string(f, 3, "</description>");
-
- _write_string(f, 2, "</signal>");
- }
-
- _write_string(f, 1, "</signals>");
- }
-
- _write_string(f, 1, "<constants>");
-
- List<String> constant_list;
- ClassDB::get_integer_constant_list(name, &constant_list, true);
-
- /* constants are sorted in a special way */
-
- List<_ConstantSort> constant_sort;
-
- for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
- _ConstantSort cs;
- cs.name = E->get();
- cs.value = ClassDB::get_integer_constant(name, E->get());
- constant_sort.push_back(cs);
- }
-
- constant_sort.sort();
-
- for (List<_ConstantSort>::Element *E = constant_sort.front(); E; E = E->next()) {
-
- _write_string(f, 2, "<constant name=\"" + E->get().name + "\" value=\"" + itos(E->get().value) + "\">");
- _write_string(f, 2, "</constant>");
- }
-
- _write_string(f, 1, "</constants>");
- _write_string(f, 0, "</class>");
-
- class_list.erase(name);
- }
-
- _write_string(f, 0, "</doc>");
- f->close();
- memdelete(f);
-}
diff --git a/editor/doc/doc_dump.h b/editor/doc/doc_dump.h
deleted file mode 100644
index f8f1b6f805..0000000000
--- a/editor/doc/doc_dump.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*************************************************************************/
-/* doc_dump.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef DOC_DUMP_H
-#define DOC_DUMP_H
-
-#include "core/class_db.h"
-
-class DocDump {
-public:
- static void dump(const String &p_file);
-};
-
-#endif // DOC_DUMP_H
diff --git a/editor/doc/doc_data.cpp b/editor/doc_data.cpp
index 66134b4428..66134b4428 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc_data.cpp
diff --git a/editor/doc/doc_data.h b/editor/doc_data.h
index 073705f0b1..073705f0b1 100644
--- a/editor/doc/doc_data.h
+++ b/editor/doc_data.h
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index a223cee360..33ee95c2d8 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -37,20 +37,23 @@
#include "core/version.h"
#include "core/version_hash.gen.h"
+void EditorAbout::_theme_changed() {
+
+ Control *base = EditorNode::get_singleton()->get_gui_base();
+ Ref<Font> font = base->get_theme_font("source", "EditorFonts");
+ _tpl_text->add_theme_font_override("normal_font", font);
+ _tpl_text->add_theme_constant_override("line_separation", 6 * EDSCALE);
+ _license_text->add_theme_font_override("normal_font", font);
+ _license_text->add_theme_constant_override("line_separation", 6 * EDSCALE);
+ _logo->set_texture(base->get_theme_icon("Logo", "EditorIcons"));
+}
+
void EditorAbout::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE:
- case NOTIFICATION_THEME_CHANGED: {
-
- Control *base = EditorNode::get_singleton()->get_gui_base();
- Ref<Font> font = base->get_font("source", "EditorFonts");
- _tpl_text->add_font_override("normal_font", font);
- _tpl_text->add_constant_override("line_separation", 6 * EDSCALE);
- _license_text->add_font_override("normal_font", font);
- _license_text->add_constant_override("line_separation", 6 * EDSCALE);
- _logo->set_texture(base->get_icon("Logo", "EditorIcons"));
+ case NOTIFICATION_ENTER_TREE: {
+ _theme_changed();
} break;
}
}
@@ -95,7 +98,7 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
il->set_same_column_width(true);
il->set_auto_height(true);
il->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
- il->add_constant_override("hseparation", 16 * EDSCALE);
+ il->add_theme_constant_override("hseparation", 16 * EDSCALE);
while (*names_ptr) {
il->add_item(String::utf8(*names_ptr++), NULL, false);
}
@@ -115,13 +118,13 @@ EditorAbout::EditorAbout() {
set_title(TTR("Thanks from the Godot community!"));
set_hide_on_ok(true);
- set_resizable(true);
VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc->connect("theme_changed", callable_mp(this, &EditorAbout::_theme_changed));
HBoxContainer *hbc = memnew(HBoxContainer);
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->set_alignment(BoxContainer::ALIGN_CENTER);
- hbc->add_constant_override("separation", 30 * EDSCALE);
+ hbc->add_theme_constant_override("separation", 30 * EDSCALE);
add_child(vbc);
vbc->add_child(hbc);
diff --git a/editor/editor_about.h b/editor/editor_about.h
index 51438ee953..83e9e9f490 100644
--- a/editor/editor_about.h
+++ b/editor/editor_about.h
@@ -57,6 +57,8 @@ private:
RichTextLabel *_tpl_text;
TextureRect *_logo;
+ void _theme_changed();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index e26d44025f..d61fe8f08a 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -112,17 +112,17 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
Map<String, Ref<Texture2D>> extension_guess;
{
- extension_guess["png"] = get_icon("ImageTexture", "EditorIcons");
- extension_guess["jpg"] = get_icon("ImageTexture", "EditorIcons");
- extension_guess["atlastex"] = get_icon("AtlasTexture", "EditorIcons");
- extension_guess["scn"] = get_icon("PackedScene", "EditorIcons");
- extension_guess["tscn"] = get_icon("PackedScene", "EditorIcons");
- extension_guess["shader"] = get_icon("Shader", "EditorIcons");
- extension_guess["gd"] = get_icon("GDScript", "EditorIcons");
- extension_guess["vs"] = get_icon("VisualScript", "EditorIcons");
+ extension_guess["png"] = tree->get_theme_icon("ImageTexture", "EditorIcons");
+ extension_guess["jpg"] = tree->get_theme_icon("ImageTexture", "EditorIcons");
+ extension_guess["atlastex"] = tree->get_theme_icon("AtlasTexture", "EditorIcons");
+ extension_guess["scn"] = tree->get_theme_icon("PackedScene", "EditorIcons");
+ extension_guess["tscn"] = tree->get_theme_icon("PackedScene", "EditorIcons");
+ extension_guess["shader"] = tree->get_theme_icon("Shader", "EditorIcons");
+ extension_guess["gd"] = tree->get_theme_icon("GDScript", "EditorIcons");
+ extension_guess["vs"] = tree->get_theme_icon("VisualScript", "EditorIcons");
}
- Ref<Texture2D> generic_extension = get_icon("Object", "EditorIcons");
+ Ref<Texture2D> generic_extension = tree->get_theme_icon("Object", "EditorIcons");
unzClose(pkg);
@@ -131,7 +131,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
TreeItem *root = tree->create_item();
root->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
root->set_checked(0, true);
- root->set_icon(0, get_icon("folder", "FileDialog"));
+ root->set_icon(0, tree->get_theme_icon("folder", "FileDialog"));
root->set_text(0, "res://");
root->set_editable(0, true);
Map<String, TreeItem *> dir_map;
@@ -180,7 +180,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
if (isdir) {
dir_map[path] = ti;
ti->set_text(0, path.get_file() + "/");
- ti->set_icon(0, get_icon("folder", "FileDialog"));
+ ti->set_icon(0, tree->get_theme_icon("folder", "FileDialog"));
ti->set_metadata(0, String());
} else {
String file = path.get_file();
@@ -194,7 +194,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
String res_path = "res://" + path;
if (FileAccess::exists(res_path)) {
- ti->set_custom_color(0, get_color("error_color", "Editor"));
+ ti->set_custom_color(0, tree->get_theme_color("error_color", "Editor"));
ti->set_tooltip(0, vformat(TTR("%s (Already Exists)"), res_path));
ti->set_checked(0, false);
} else {
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index d77216697e..55bdd2070b 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -30,8 +30,8 @@
#include "editor_audio_buses.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_saver.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "editor_node.h"
#include "editor_scale.h"
@@ -69,27 +69,27 @@ void EditorAudioBus::_notification(int p_what) {
case NOTIFICATION_READY: {
for (int i = 0; i < CHANNELS_MAX; i++) {
- channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
- channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
- channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
- channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
+ channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons"));
+ channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons"));
+ channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons"));
+ channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons"));
channel[i].prev_active = true;
}
- disabled_vu = get_icon("BusVuFrozen", "EditorIcons");
+ disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons");
Color solo_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.89, 0.22) : Color(1.0, 0.92, 0.44);
Color mute_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.16, 0.16) : Color(1.0, 0.44, 0.44);
Color bypass_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(0.13, 0.8, 1.0) : Color(0.44, 0.87, 1.0);
- solo->set_icon(get_icon("AudioBusSolo", "EditorIcons"));
- solo->add_color_override("icon_color_pressed", solo_color);
- mute->set_icon(get_icon("AudioBusMute", "EditorIcons"));
- mute->add_color_override("icon_color_pressed", mute_color);
- bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons"));
- bypass->add_color_override("icon_color_pressed", bypass_color);
+ solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons"));
+ solo->add_theme_color_override("icon_color_pressed", solo_color);
+ mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons"));
+ mute->add_theme_color_override("icon_color_pressed", mute_color);
+ bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons"));
+ bypass->add_theme_color_override("icon_color_pressed", bypass_color);
- bus_options->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
+ bus_options->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
update_bus();
set_process(true);
@@ -97,15 +97,15 @@ void EditorAudioBus::_notification(int p_what) {
case NOTIFICATION_DRAW: {
if (is_master) {
- draw_style_box(get_stylebox("disabled", "Button"), Rect2(Vector2(), get_size()));
+ draw_style_box(get_theme_stylebox("disabled", "Button"), Rect2(Vector2(), get_size()));
} else if (has_focus()) {
- draw_style_box(get_stylebox("focus", "Button"), Rect2(Vector2(), get_size()));
+ draw_style_box(get_theme_stylebox("focus", "Button"), Rect2(Vector2(), get_size()));
} else {
- draw_style_box(get_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size()));
+ draw_style_box(get_theme_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size()));
}
if (get_index() != 0 && hovering_drop) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
accent.a *= 0.7;
draw_rect(Rect2(Point2(), get_size()), accent, false);
}
@@ -168,20 +168,20 @@ void EditorAudioBus::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
for (int i = 0; i < CHANNELS_MAX; i++) {
- channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
- channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
- channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
- channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
+ channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons"));
+ channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons"));
+ channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons"));
+ channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons"));
channel[i].prev_active = true;
}
- disabled_vu = get_icon("BusVuFrozen", "EditorIcons");
+ disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons");
- solo->set_icon(get_icon("AudioBusSolo", "EditorIcons"));
- mute->set_icon(get_icon("AudioBusMute", "EditorIcons"));
- bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons"));
+ solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons"));
+ mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons"));
+ bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons"));
- bus_options->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
+ bus_options->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
} break;
case NOTIFICATION_MOUSE_EXIT:
case NOTIFICATION_DRAG_END: {
@@ -325,7 +325,7 @@ void EditorAudioBus::_volume_changed(float p_normalized) {
const float p_db = this->_normalized_volume_to_scaled_db(p_normalized);
- if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
// Snap the value when holding Ctrl for easier editing.
// To do so, it needs to be converted back to normalized volume (as the slider uses that unit).
slider->set_value(_scaled_db_to_normalized_volume(Math::round(p_db)));
@@ -386,7 +386,7 @@ float EditorAudioBus::_scaled_db_to_normalized_volume(float db) {
void EditorAudioBus::_show_value(float slider_value) {
float db;
- if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
// Display the correct (snapped) value when holding Ctrl
db = Math::round(_normalized_volume_to_scaled_db(slider_value));
} else {
@@ -586,7 +586,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) {
Panel *p = memnew(Panel);
c->add_child(p);
p->set_modulate(Color(1, 1, 1, 0.7));
- p->add_style_override("panel", get_stylebox("focus", "Button"));
+ p->add_theme_style_override("panel", get_theme_stylebox("focus", "Button"));
p->set_size(get_size());
p->set_position(-p_point);
set_drag_preview(c);
@@ -819,10 +819,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
Ref<StyleBoxEmpty> sbempty = memnew(StyleBoxEmpty);
for (int i = 0; i < hbc->get_child_count(); i++) {
Control *child = Object::cast_to<Control>(hbc->get_child(i));
- child->add_style_override("normal", sbempty);
- child->add_style_override("hover", sbempty);
- child->add_style_override("focus", sbempty);
- child->add_style_override("pressed", sbempty);
+ child->add_theme_style_override("normal", sbempty);
+ child->add_theme_style_override("hover", sbempty);
+ child->add_theme_style_override("focus", sbempty);
+ child->add_theme_style_override("pressed", sbempty);
}
HSeparator *separator = memnew(HSeparator);
@@ -854,7 +854,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
audio_value_preview_box->set_as_toplevel(true);
Ref<StyleBoxFlat> panel_style = memnew(StyleBoxFlat);
panel_style->set_bg_color(Color(0.0f, 0.0f, 0.0f, 0.8f));
- audio_value_preview_box->add_style_override("panel", panel_style);
+ audio_value_preview_box->add_theme_style_override("panel", panel_style);
audio_value_preview_box->set_mouse_filter(MOUSE_FILTER_PASS);
audio_value_preview_box->hide();
@@ -953,10 +953,10 @@ void EditorAudioBusDrop::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
- draw_style_box(get_stylebox("normal", "Button"), Rect2(Vector2(), get_size()));
+ draw_style_box(get_theme_stylebox("normal", "Button"), Rect2(Vector2(), get_size()));
if (hovering_drop) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
accent.a *= 0.7;
draw_rect(Rect2(Point2(), get_size()), accent, false);
}
@@ -1035,7 +1035,7 @@ void EditorAudioBuses::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- bus_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
+ bus_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
@@ -1204,7 +1204,7 @@ void EditorAudioBuses::_select_layout() {
void EditorAudioBuses::_save_as_layout() {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_title(TTR("Save Audio Bus Layout As..."));
file_dialog->set_current_path(edited_path);
file_dialog->popup_centered_ratio();
@@ -1213,7 +1213,7 @@ void EditorAudioBuses::_save_as_layout() {
void EditorAudioBuses::_new_layout() {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_title(TTR("Location for New Layout..."));
file_dialog->set_current_path(edited_path);
file_dialog->popup_centered_ratio();
@@ -1222,7 +1222,7 @@ void EditorAudioBuses::_new_layout() {
void EditorAudioBuses::_load_layout() {
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_dialog->set_title(TTR("Open Audio Bus Layout"));
file_dialog->set_current_path(edited_path);
file_dialog->popup_centered_ratio();
@@ -1249,7 +1249,7 @@ void EditorAudioBuses::_load_default_layout() {
void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
- if (file_dialog->get_mode() == EditorFileDialog::MODE_OPEN_FILE) {
+ if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_OPEN_FILE) {
Ref<AudioBusLayout> state = ResourceLoader::load(p_string, "", true);
if (state.is_null()) {
EditorNode::get_singleton()->show_warning(TTR("Invalid file, not an audio bus layout."));
@@ -1263,7 +1263,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
EditorNode::get_singleton()->get_undo_redo()->clear_history();
call_deferred("_select_layout");
- } else if (file_dialog->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
+ } else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
if (new_layout) {
Ref<AudioBusLayout> empty_state;
@@ -1423,7 +1423,7 @@ void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_va
Size2 EditorAudioMeterNotches::get_minimum_size() const {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
float font_height = font->get_height();
float width = 0;
@@ -1460,7 +1460,7 @@ void EditorAudioMeterNotches::_notification(int p_what) {
void EditorAudioMeterNotches::_draw_audio_notches() {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
float font_height = font->get_height();
for (int i = 0; i < notches.size(); i++) {
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 83a1e2fca2..a6a383ba58 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -35,7 +35,7 @@
#include "editor_node.h"
#include "editor_scale.h"
#include "project_settings_editor.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#define PREVIEW_LIST_MAX_SIZE 10
@@ -452,10 +452,10 @@ void EditorAutoloadSettings::update_autoload() {
item->set_editable(2, true);
item->set_text(2, TTR("Enable"));
item->set_checked(2, info.is_singleton);
- item->add_button(3, get_icon("Load", "EditorIcons"), BUTTON_OPEN);
- item->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP);
- item->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN);
- item->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_DELETE);
+ item->add_button(3, get_theme_icon("Load", "EditorIcons"), BUTTON_OPEN);
+ item->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP);
+ item->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN);
+ item->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_DELETE);
item->set_selectable(3, false);
}
@@ -825,7 +825,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
autoload_add_path = memnew(EditorLineEditFileChooser);
autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL);
- autoload_add_path->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ autoload_add_path->get_file_dialog()->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
autoload_add_path->get_file_dialog()->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_file_callback));
autoload_add_path->get_line_edit()->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed));
diff --git a/editor/editor_builders.py b/editor/editor_builders.py
index e8c23acf9e..44c3e50dfc 100644
--- a/editor/editor_builders.py
+++ b/editor/editor_builders.py
@@ -6,24 +6,23 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki
import os
import os.path
from platform_methods import subprocess_main
-from compat import encode_utf8, byte_to_str, open_utf8
def make_doc_header(target, source, env):
dst = target[0]
- g = open_utf8(dst, "w")
+ g = open(dst, "w", encoding="utf-8")
buf = ""
docbegin = ""
docend = ""
for src in source:
if not src.endswith(".xml"):
continue
- with open_utf8(src, "r") as f:
+ with open(src, "r", encoding="utf-8") as f:
content = f.read()
buf += content
- buf = encode_utf8(docbegin + buf + docend)
+ buf = (docbegin + buf + docend).encode("utf-8")
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
@@ -35,7 +34,7 @@ def make_doc_header(target, source, env):
g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n")
g.write("static const unsigned char _doc_data_compressed[] = {\n")
for i in range(len(buf)):
- g.write("\t" + byte_to_str(buf[i]) + ",\n")
+ g.write("\t" + str(buf[i]) + ",\n")
g.write("};\n")
g.write("#endif")
@@ -47,7 +46,7 @@ def make_fonts_header(target, source, env):
dst = target[0]
- g = open_utf8(dst, "w")
+ g = open(dst, "w", encoding="utf-8")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_FONTS_H\n")
@@ -64,7 +63,7 @@ def make_fonts_header(target, source, env):
g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n")
g.write("static const unsigned char _font_" + name + "[] = {\n")
for j in range(len(buf)):
- g.write("\t" + byte_to_str(buf[j]) + ",\n")
+ g.write("\t" + str(buf[j]) + ",\n")
g.write("};\n")
@@ -77,7 +76,7 @@ def make_translations_header(target, source, env, category):
dst = target[0]
- g = open_utf8(dst, "w")
+ g = open(dst, "w", encoding="utf-8")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper()))
@@ -98,7 +97,7 @@ def make_translations_header(target, source, env, category):
g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name))
for j in range(len(buf)):
- g.write("\t" + byte_to_str(buf[j]) + ",\n")
+ g.write("\t" + str(buf[j]) + ",\n")
g.write("};\n")
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index 20fe349ef6..cb87656382 100644
--- a/editor/editor_dir_dialog.cpp
+++ b/editor/editor_dir_dialog.cpp
@@ -35,6 +35,7 @@
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
#include "editor_scale.h"
+#include "servers/display_server.h"
void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path) {
@@ -43,7 +44,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p
String path = p_dir->get_path();
p_item->set_metadata(0, p_dir->get_path());
- p_item->set_icon(0, get_icon("Folder", "EditorIcons"));
+ p_item->set_icon(0, tree->get_theme_icon("Folder", "EditorIcons"));
if (!p_item->get_parent()) {
p_item->set_text(0, "res://");
@@ -68,7 +69,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p
void EditorDirDialog::reload(const String &p_path) {
- if (!is_visible_in_tree()) {
+ if (!is_visible()) {
must_reload = true;
return;
}
@@ -102,7 +103,7 @@ void EditorDirDialog::_notification(int p_what) {
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (must_reload && is_visible_in_tree()) {
+ if (must_reload && is_visible()) {
reload();
}
}
@@ -141,11 +142,11 @@ void EditorDirDialog::_make_dir() {
TreeItem *ti = tree->get_selected();
if (!ti) {
mkdirerr->set_text(TTR("Please select a base directory first."));
- mkdirerr->popup_centered_minsize();
+ mkdirerr->popup_centered();
return;
}
- makedialog->popup_centered_minsize(Size2(250, 80));
+ makedialog->popup_centered(Size2(250, 80));
makedirname->grab_focus();
}
@@ -162,7 +163,7 @@ void EditorDirDialog::_make_dir_confirm() {
Error err = d->make_dir(makedirname->get_text());
if (err != OK) {
- mkdirerr->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ mkdirerr->popup_centered(Size2(250, 80) * EDSCALE);
} else {
opened_paths.insert(dir);
//reload(dir.plus_file(makedirname->get_text()));
@@ -188,7 +189,7 @@ EditorDirDialog::EditorDirDialog() {
tree->connect("item_activated", callable_mp(this, &EditorDirDialog::_item_activated));
- makedir = add_button(TTR("Create Folder"), OS::get_singleton()->get_swap_ok_cancel(), "makedir");
+ makedir = add_button(TTR("Create Folder"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "makedir");
makedir->connect("pressed", callable_mp(this, &EditorDirDialog::_make_dir));
makedialog = memnew(ConfirmationDialog);
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index 4b0bbdcec2..6e13ec7967 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -420,7 +420,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) {
} break;
case PROFILE_NEW: {
- new_profile_dialog->popup_centered_minsize();
+ new_profile_dialog->popup_centered();
new_profile_name->clear();
new_profile_name->grab_focus();
} break;
@@ -430,7 +430,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) {
ERR_FAIL_COND(selected == String());
erase_profile_dialog->set_text(vformat(TTR("Erase profile '%s'? (no undo)"), selected));
- erase_profile_dialog->popup_centered_minsize();
+ erase_profile_dialog->popup_centered();
} break;
}
}
@@ -485,7 +485,7 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S
bool disabled_editor = edited->is_class_editor_disabled(p_class);
bool disabled_properties = edited->has_class_properties_disabled(p_class);
if (disabled) {
- class_item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ class_item->set_custom_color(0, class_list->get_theme_color("disabled_font_color", "Editor"));
} else if (disabled_editor && disabled_properties) {
text += " " + TTR("(Editor Disabled, Properties Disabled)");
} else if (disabled_properties) {
@@ -805,7 +805,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
current_profile_name = memnew(LineEdit);
name_hbc->add_child(current_profile_name);
current_profile_name->set_editable(false);
- current_profile_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ current_profile_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
profile_actions[PROFILE_CLEAR] = memnew(Button(TTR("Unset")));
name_hbc->add_child(profile_actions[PROFILE_CLEAR]);
profile_actions[PROFILE_CLEAR]->set_disabled(true);
@@ -815,7 +815,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
HBoxContainer *profiles_hbc = memnew(HBoxContainer);
profile_list = memnew(OptionButton);
- profile_list->set_h_size_flags(SIZE_EXPAND_FILL);
+ profile_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
profiles_hbc->add_child(profile_list);
profile_list->connect("item_selected", callable_mp(this, &EditorFeatureProfileManager::_profile_selected));
@@ -849,12 +849,12 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
main_vbc->add_margin_child(TTR("Available Profiles:"), profiles_hbc);
h_split = memnew(HSplitContainer);
- h_split->set_v_size_flags(SIZE_EXPAND_FILL);
+ h_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_vbc->add_child(h_split);
VBoxContainer *class_list_vbc = memnew(VBoxContainer);
h_split->add_child(class_list_vbc);
- class_list_vbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ class_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
class_list = memnew(Tree);
class_list_vbc->add_margin_child(TTR("Enabled Classes:"), class_list, true);
@@ -865,7 +865,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
VBoxContainer *property_list_vbc = memnew(VBoxContainer);
h_split->add_child(property_list_vbc);
- property_list_vbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ property_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
property_list = memnew(Tree);
property_list_vbc->add_margin_child(TTR("Class Options"), property_list, true);
@@ -891,7 +891,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
import_profiles = memnew(EditorFileDialog);
add_child(import_profiles);
- import_profiles->set_mode(EditorFileDialog::MODE_OPEN_FILES);
+ import_profiles->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
import_profiles->add_filter("*.profile; " + TTR("Godot Feature Profile"));
import_profiles->connect("files_selected", callable_mp(this, &EditorFeatureProfileManager::_import_profiles));
import_profiles->set_title(TTR("Import Profile(s)"));
@@ -899,7 +899,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
export_profile = memnew(EditorFileDialog);
add_child(export_profile);
- export_profile->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ export_profile->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
export_profile->add_filter("*.profile; " + TTR("Godot Feature Profile"));
export_profile->connect("file_selected", callable_mp(this, &EditorFeatureProfileManager::_export_profile));
export_profile->set_title(TTR("Export Profile"));
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 250fa6b3e0..fca59946ae 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -42,6 +42,7 @@
#include "scene/gui/center_container.h"
#include "scene/gui/label.h"
#include "scene/gui/margin_container.h"
+#include "servers/display_server.h"
EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = NULL;
EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = NULL;
@@ -58,17 +59,17 @@ void EditorFileDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
// update icons
- mode_thumbnails->set_icon(get_icon("FileThumbnail", "EditorIcons"));
- mode_list->set_icon(get_icon("FileList", "EditorIcons"));
- dir_prev->set_icon(get_icon("Back", "EditorIcons"));
- dir_next->set_icon(get_icon("Forward", "EditorIcons"));
- dir_up->set_icon(get_icon("ArrowUp", "EditorIcons"));
- refresh->set_icon(get_icon("Reload", "EditorIcons"));
- favorite->set_icon(get_icon("Favorites", "EditorIcons"));
- show_hidden->set_icon(get_icon("GuiVisibilityVisible", "EditorIcons"));
-
- fav_up->set_icon(get_icon("MoveUp", "EditorIcons"));
- fav_down->set_icon(get_icon("MoveDown", "EditorIcons"));
+ mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons"));
+ mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons"));
+ dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
+ dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons"));
+ refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons"));
+ favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons"));
+ show_hidden->set_icon(item_list->get_theme_icon("GuiVisibilityVisible", "EditorIcons"));
+
+ fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons"));
+ fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons"));
} else if (p_what == NOTIFICATION_PROCESS) {
@@ -78,14 +79,11 @@ void EditorFileDialog::_notification(int p_what) {
preview_wheel_index++;
if (preview_wheel_index >= 8)
preview_wheel_index = 0;
- Ref<Texture2D> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons");
+ Ref<Texture2D> frame = item_list->get_theme_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons");
preview->set_texture(frame);
preview_wheel_timeout = 0.1;
}
}
- } else if (p_what == NOTIFICATION_POPUP_HIDE) {
-
- set_process_unhandled_input(false);
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
@@ -95,18 +93,23 @@ void EditorFileDialog::_notification(int p_what) {
set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
// update icons
- mode_thumbnails->set_icon(get_icon("FileThumbnail", "EditorIcons"));
- mode_list->set_icon(get_icon("FileList", "EditorIcons"));
- dir_prev->set_icon(get_icon("Back", "EditorIcons"));
- dir_next->set_icon(get_icon("Forward", "EditorIcons"));
- dir_up->set_icon(get_icon("ArrowUp", "EditorIcons"));
- refresh->set_icon(get_icon("Reload", "EditorIcons"));
- favorite->set_icon(get_icon("Favorites", "EditorIcons"));
-
- fav_up->set_icon(get_icon("MoveUp", "EditorIcons"));
- fav_down->set_icon(get_icon("MoveDown", "EditorIcons"));
+ mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons"));
+ mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons"));
+ dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons"));
+ dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons"));
+ dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons"));
+ refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons"));
+ favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons"));
+
+ fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons"));
+ fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons"));
// DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD
invalidate();
+ } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+
+ if (!is_visible()) {
+ set_process_unhandled_input(false);
+ }
}
}
@@ -114,7 +117,7 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && is_window_modal_on_top()) {
+ if (k.is_valid()) {
if (k->is_pressed()) {
@@ -176,7 +179,7 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
}
if (handled) {
- accept_event();
+ set_input_as_handled();
}
}
}
@@ -208,15 +211,15 @@ void EditorFileDialog::update_dir() {
get_ok()->set_disabled(_is_open_should_be_disabled());
switch (mode) {
- case MODE_OPEN_FILE:
- case MODE_OPEN_FILES:
+ case FILE_MODE_OPEN_FILE:
+ case FILE_MODE_OPEN_FILES:
get_ok()->set_text(TTR("Open"));
break;
- case MODE_OPEN_DIR:
+ case FILE_MODE_OPEN_DIR:
get_ok()->set_text(TTR("Select Current Folder"));
break;
- case MODE_OPEN_ANY:
- case MODE_SAVE_FILE:
+ case FILE_MODE_OPEN_ANY:
+ case FILE_MODE_SAVE_FILE:
// FIXME: Implement, or refactor to avoid duplication with set_mode
break;
}
@@ -251,23 +254,23 @@ void EditorFileDialog::_post_popup() {
update_file_list();
invalidated = false;
}
- if (mode == MODE_SAVE_FILE)
+ if (mode == FILE_MODE_SAVE_FILE)
file->grab_focus();
else
item_list->grab_focus();
- if (mode == MODE_OPEN_DIR) {
+ if (mode == FILE_MODE_OPEN_DIR) {
file_box->set_visible(false);
} else {
file_box->set_visible(true);
}
- if (is_visible_in_tree() && get_current_file() != "")
+ if (is_visible() && get_current_file() != "")
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
- if (is_visible_in_tree()) {
- Ref<Texture2D> folder = get_icon("folder", "FileDialog");
- const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
+ if (is_visible()) {
+ Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog");
+ const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog");
recent->clear();
bool res = access == ACCESS_RESOURCES;
@@ -346,7 +349,7 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) {
void EditorFileDialog::_action_pressed() {
- if (mode == MODE_OPEN_FILES) {
+ if (mode == FILE_MODE_OPEN_FILES) {
String fbase = dir_access->get_current_dir();
@@ -367,11 +370,11 @@ void EditorFileDialog::_action_pressed() {
String f = dir_access->get_current_dir().plus_file(file->get_text());
- if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
+ if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) {
_save_to_recent();
hide();
emit_signal("file_selected", f);
- } else if (mode == MODE_OPEN_ANY || mode == MODE_OPEN_DIR) {
+ } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) {
String path = dir_access->get_current_dir();
@@ -393,7 +396,7 @@ void EditorFileDialog::_action_pressed() {
emit_signal("dir_selected", path);
}
- if (mode == MODE_SAVE_FILE) {
+ if (mode == FILE_MODE_SAVE_FILE) {
bool valid = false;
@@ -446,7 +449,7 @@ void EditorFileDialog::_action_pressed() {
if (!valid) {
- exterr->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ exterr->popup_centered(Size2(250, 80) * EDSCALE);
return;
}
@@ -481,7 +484,7 @@ void EditorFileDialog::_item_selected(int p_item) {
file->set_text(d["name"]);
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
- } else if (mode == MODE_OPEN_DIR) {
+ } else if (mode == FILE_MODE_OPEN_DIR) {
get_ok()->set_text(TTR("Select This Folder"));
}
@@ -512,19 +515,19 @@ void EditorFileDialog::_items_clear_selection() {
// If nothing is selected, then block Open button.
switch (mode) {
- case MODE_OPEN_FILE:
- case MODE_OPEN_FILES:
+ case FILE_MODE_OPEN_FILE:
+ case FILE_MODE_OPEN_FILES:
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(!item_list->is_anything_selected());
break;
- case MODE_OPEN_DIR:
+ case FILE_MODE_OPEN_DIR:
get_ok()->set_disabled(false);
get_ok()->set_text(TTR("Select Current Folder"));
break;
- case MODE_OPEN_ANY:
- case MODE_SAVE_FILE:
+ case FILE_MODE_OPEN_ANY:
+ case FILE_MODE_SAVE_FILE:
// FIXME: Implement, or refactor to avoid duplication with set_mode
break;
}
@@ -586,16 +589,16 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p
}
if (single_item_selected) {
- item_menu->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH);
+ item_menu->add_icon_item(item_list->get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH);
}
if (allow_delete) {
- item_menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE);
+ item_menu->add_icon_item(item_list->get_theme_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE);
}
if (single_item_selected) {
item_menu->add_separator();
Dictionary item_meta = item_list->get_item_metadata(p_item);
String item_text = item_meta["dir"] ? TTR("Open in File Manager") : TTR("Show in File Manager");
- item_menu->add_icon_item(get_icon("Filesystem", "EditorIcons"), item_text, ITEM_MENU_SHOW_IN_EXPLORER);
+ item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), item_text, ITEM_MENU_SHOW_IN_EXPLORER);
}
if (item_menu->get_item_count() > 0) {
@@ -615,11 +618,11 @@ void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) {
item_menu->set_size(Size2(1, 1));
if (can_create_dir) {
- item_menu->add_icon_item(get_icon("folder", "FileDialog"), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N);
+ item_menu->add_icon_item(item_list->get_theme_icon("folder", "FileDialog"), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N);
}
- item_menu->add_icon_item(get_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5);
+ item_menu->add_icon_item(item_list->get_theme_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5);
item_menu->add_separator();
- item_menu->add_icon_item(get_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER);
+ item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER);
item_menu->set_position(item_list->get_global_position() + p_pos);
item_menu->popup();
@@ -631,7 +634,7 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) {
case ITEM_MENU_COPY_PATH: {
Dictionary item_meta = item_list->get_item_metadata(item_list->get_current());
- OS::get_singleton()->set_clipboard(item_meta["path"]);
+ DisplayServer::get_singleton()->clipboard_set(item_meta["path"]);
} break;
case ITEM_MENU_DELETE: {
@@ -667,18 +670,18 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) {
bool EditorFileDialog::_is_open_should_be_disabled() {
- if (mode == MODE_OPEN_ANY || mode == MODE_SAVE_FILE)
+ if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE)
return false;
Vector<int> items = item_list->get_selected_items();
if (items.size() == 0)
- return mode != MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder.
+ return mode != FILE_MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder.
for (int i = 0; i < items.size(); i++) {
Dictionary d = item_list->get_item_metadata(items.get(i));
- if (((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || (mode == MODE_OPEN_DIR && !d["dir"]))
+ if (((mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES) && d["dir"]) || (mode == FILE_MODE_OPEN_DIR && !d["dir"]))
return true;
}
@@ -724,11 +727,11 @@ void EditorFileDialog::update_file_list() {
item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
if (thumbnail_size < 64) {
- folder_thumbnail = get_icon("FolderMediumThumb", "EditorIcons");
- file_thumbnail = get_icon("FileMediumThumb", "EditorIcons");
+ folder_thumbnail = item_list->get_theme_icon("FolderMediumThumb", "EditorIcons");
+ file_thumbnail = item_list->get_theme_icon("FileMediumThumb", "EditorIcons");
} else {
- folder_thumbnail = get_icon("FolderBigThumb", "EditorIcons");
- file_thumbnail = get_icon("FileBigThumb", "EditorIcons");
+ folder_thumbnail = item_list->get_theme_icon("FolderBigThumb", "EditorIcons");
+ file_thumbnail = item_list->get_theme_icon("FileBigThumb", "EditorIcons");
}
preview_vb->hide();
@@ -748,8 +751,8 @@ void EditorFileDialog::update_file_list() {
dir_access->list_dir_begin();
- Ref<Texture2D> folder = get_icon("folder", "FileDialog");
- const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
+ Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog");
+ const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@@ -978,7 +981,7 @@ void EditorFileDialog::set_current_file(const String &p_file) {
file->grab_focus();
}
- if (is_visible_in_tree())
+ if (is_visible())
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
}
void EditorFileDialog::set_current_path(const String &p_path) {
@@ -998,39 +1001,39 @@ void EditorFileDialog::set_current_path(const String &p_path) {
}
}
-void EditorFileDialog::set_mode(Mode p_mode) {
+void EditorFileDialog::set_file_mode(FileMode p_mode) {
mode = p_mode;
switch (mode) {
- case MODE_OPEN_FILE:
+ case FILE_MODE_OPEN_FILE:
get_ok()->set_text(TTR("Open"));
set_title(TTR("Open a File"));
can_create_dir = false;
break;
- case MODE_OPEN_FILES:
+ case FILE_MODE_OPEN_FILES:
get_ok()->set_text(TTR("Open"));
set_title(TTR("Open File(s)"));
can_create_dir = false;
break;
- case MODE_OPEN_DIR:
+ case FILE_MODE_OPEN_DIR:
get_ok()->set_text(TTR("Open"));
set_title(TTR("Open a Directory"));
can_create_dir = true;
break;
- case MODE_OPEN_ANY:
+ case FILE_MODE_OPEN_ANY:
get_ok()->set_text(TTR("Open"));
set_title(TTR("Open a File or Directory"));
can_create_dir = true;
break;
- case MODE_SAVE_FILE:
+ case FILE_MODE_SAVE_FILE:
get_ok()->set_text(TTR("Save"));
set_title(TTR("Save a File"));
can_create_dir = true;
break;
}
- if (mode == MODE_OPEN_FILES) {
+ if (mode == FILE_MODE_OPEN_FILES) {
item_list->set_select_mode(ItemList::SELECT_MULTI);
} else {
item_list->set_select_mode(ItemList::SELECT_SINGLE);
@@ -1043,7 +1046,7 @@ void EditorFileDialog::set_mode(Mode p_mode) {
}
}
-EditorFileDialog::Mode EditorFileDialog::get_mode() const {
+EditorFileDialog::FileMode EditorFileDialog::get_file_mode() const {
return mode;
}
@@ -1077,7 +1080,7 @@ void EditorFileDialog::set_access(Access p_access) {
void EditorFileDialog::invalidate() {
- if (is_visible_in_tree()) {
+ if (is_visible()) {
update_file_list();
_update_favorites();
invalidated = false;
@@ -1102,14 +1105,14 @@ void EditorFileDialog::_make_dir_confirm() {
_push_history();
EditorFileSystem::get_singleton()->scan_changes(); //we created a dir, so rescan changes
} else {
- mkdirerr->popup_centered_minsize(Size2(250, 50) * EDSCALE);
+ mkdirerr->popup_centered(Size2(250, 50) * EDSCALE);
}
makedirname->set_text(""); // reset label
}
void EditorFileDialog::_make_dir() {
- makedialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ makedialog->popup_centered(Size2(250, 80) * EDSCALE);
makedirname->grab_focus();
}
@@ -1224,8 +1227,8 @@ void EditorFileDialog::_update_favorites() {
bool res = access == ACCESS_RESOURCES;
String current = get_current_dir();
- Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons");
- const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
+ Ref<Texture2D> folder_icon = item_list->get_theme_icon("Folder", "EditorIcons");
+ const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog");
favorites->clear();
favorite->set_pressed(false);
@@ -1383,8 +1386,8 @@ void EditorFileDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_current_dir", "dir"), &EditorFileDialog::set_current_dir);
ClassDB::bind_method(D_METHOD("set_current_file", "file"), &EditorFileDialog::set_current_file);
ClassDB::bind_method(D_METHOD("set_current_path", "path"), &EditorFileDialog::set_current_path);
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &EditorFileDialog::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &EditorFileDialog::get_mode);
+ ClassDB::bind_method(D_METHOD("set_file_mode", "mode"), &EditorFileDialog::set_file_mode);
+ ClassDB::bind_method(D_METHOD("get_file_mode"), &EditorFileDialog::get_file_mode);
ClassDB::bind_method(D_METHOD("get_vbox"), &EditorFileDialog::get_vbox);
ClassDB::bind_method(D_METHOD("set_access", "access"), &EditorFileDialog::set_access);
ClassDB::bind_method(D_METHOD("get_access"), &EditorFileDialog::get_access);
@@ -1408,18 +1411,18 @@ void EditorFileDialog::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access");
ADD_PROPERTY(PropertyInfo(Variant::INT, "display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List"), "set_display_mode", "get_display_mode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_mode", "get_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "file_mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_file_mode", "get_file_mode");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_dir", PROPERTY_HINT_DIR), "set_current_dir", "get_current_dir");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_file", PROPERTY_HINT_FILE, "*"), "set_current_file", "get_current_file");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_path"), "set_current_path", "get_current_path");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), "set_show_hidden_files", "is_showing_hidden_files");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_overwrite_warning"), "set_disable_overwrite_warning", "is_overwrite_warning_disabled");
- BIND_ENUM_CONSTANT(MODE_OPEN_FILE);
- BIND_ENUM_CONSTANT(MODE_OPEN_FILES);
- BIND_ENUM_CONSTANT(MODE_OPEN_DIR);
- BIND_ENUM_CONSTANT(MODE_OPEN_ANY);
- BIND_ENUM_CONSTANT(MODE_SAVE_FILE);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_FILE);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_FILES);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_DIR);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_ANY);
+ BIND_ENUM_CONSTANT(FILE_MODE_SAVE_FILE);
BIND_ENUM_CONSTANT(ACCESS_RESOURCES);
BIND_ENUM_CONSTANT(ACCESS_USERDATA);
@@ -1483,8 +1486,6 @@ bool EditorFileDialog::is_overwrite_warning_disabled() const {
EditorFileDialog::EditorFileDialog() {
- set_resizable(true);
-
show_hidden_files = default_show_hidden_files;
display_mode = default_display_mode;
local_history_pos = 0;
@@ -1492,7 +1493,7 @@ EditorFileDialog::EditorFileDialog() {
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- mode = MODE_SAVE_FILE;
+ mode = FILE_MODE_SAVE_FILE;
set_title(TTR("Save a File"));
ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT | KEY_LEFT);
@@ -1532,7 +1533,7 @@ EditorFileDialog::EditorFileDialog() {
dir = memnew(LineEdit);
pathhb->add_child(dir);
- dir->set_h_size_flags(SIZE_EXPAND_FILL);
+ dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
refresh = memnew(ToolButton);
refresh->set_tooltip(TTR("Refresh files."));
@@ -1588,7 +1589,7 @@ EditorFileDialog::EditorFileDialog() {
vbc->add_child(pathhb);
vbc->add_child(list_hb);
- list_hb->set_v_size_flags(SIZE_EXPAND_FILL);
+ list_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
VSplitContainer *vsc = memnew(VSplitContainer);
list_hb->add_child(vsc);
@@ -1596,7 +1597,7 @@ EditorFileDialog::EditorFileDialog() {
VBoxContainer *fav_vb = memnew(VBoxContainer);
vsc->add_child(fav_vb);
fav_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
- fav_vb->set_v_size_flags(SIZE_EXPAND_FILL);
+ fav_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *fav_hb = memnew(HBoxContainer);
fav_vb->add_child(fav_hb);
fav_hb->add_child(memnew(Label(TTR("Favorites:"))));
@@ -1610,13 +1611,13 @@ EditorFileDialog::EditorFileDialog() {
favorites = memnew(ItemList);
fav_vb->add_child(favorites);
- favorites->set_v_size_flags(SIZE_EXPAND_FILL);
+ favorites->set_v_size_flags(Control::SIZE_EXPAND_FILL);
favorites->connect("item_selected", callable_mp(this, &EditorFileDialog::_favorite_selected));
VBoxContainer *rec_vb = memnew(VBoxContainer);
vsc->add_child(rec_vb);
rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
- rec_vb->set_v_size_flags(SIZE_EXPAND_FILL);
+ rec_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
recent = memnew(ItemList);
recent->set_allow_reselect(true);
rec_vb->add_margin_child(TTR("Recent:"), recent, true);
@@ -1627,18 +1628,18 @@ EditorFileDialog::EditorFileDialog() {
item_vb->set_custom_minimum_size(Size2(320, 0) * EDSCALE);
HBoxContainer *preview_hb = memnew(HBoxContainer);
- preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);
+ preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
item_vb->add_child(preview_hb);
VBoxContainer *list_vb = memnew(VBoxContainer);
- list_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ list_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
list_vb->add_child(memnew(Label(TTR("Directories & Files:"))));
preview_hb->add_child(list_vb);
// Item (files and folders) list with context menu.
item_list = memnew(ItemList);
- item_list->set_v_size_flags(SIZE_EXPAND_FILL);
+ item_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
item_list->connect("item_rmb_selected", callable_mp(this, &EditorFileDialog::_item_list_item_rmb_selected));
item_list->connect("rmb_clicked", callable_mp(this, &EditorFileDialog::_item_list_rmb_clicked));
item_list->set_allow_rmb_select(true);
@@ -1662,14 +1663,14 @@ EditorFileDialog::EditorFileDialog() {
file_box->add_child(memnew(Label(TTR("File:"))));
file = memnew(LineEdit);
file->set_stretch_ratio(4);
- file->set_h_size_flags(SIZE_EXPAND_FILL);
+ file->set_h_size_flags(Control::SIZE_EXPAND_FILL);
file_box->add_child(file);
filter = memnew(OptionButton);
filter->set_stretch_ratio(3);
- filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_clip_text(true); // Too many extensions overflow it.
file_box->add_child(filter);
- file_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ file_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
item_vb->add_child(file_box);
dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
@@ -1686,7 +1687,7 @@ EditorFileDialog::EditorFileDialog() {
filter->connect("item_selected", callable_mp(this, &EditorFileDialog::_filter_selected));
confirm_save = memnew(ConfirmationDialog);
- confirm_save->set_as_toplevel(true);
+ //confirm_save->set_as_toplevel(true);
add_child(confirm_save);
confirm_save->connect("confirmed", callable_mp(this, &EditorFileDialog::_save_confirm_pressed));
@@ -1736,7 +1737,7 @@ EditorFileDialog::~EditorFileDialog() {
void EditorLineEditFileChooser::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED)
- button->set_icon(get_icon("Folder", "EditorIcons"));
+ button->set_icon(get_theme_icon("Folder", "EditorIcons"));
}
void EditorLineEditFileChooser::_bind_methods() {
@@ -1761,7 +1762,7 @@ EditorLineEditFileChooser::EditorLineEditFileChooser() {
line_edit = memnew(LineEdit);
add_child(line_edit);
- line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
button = memnew(Button);
add_child(button);
button->connect("pressed", callable_mp(this, &EditorLineEditFileChooser::_browse));
diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h
index 998ac33761..ed23f14ebe 100644
--- a/editor/editor_file_dialog.h
+++ b/editor/editor_file_dialog.h
@@ -60,12 +60,12 @@ public:
ACCESS_FILESYSTEM
};
- enum Mode {
- MODE_OPEN_FILE,
- MODE_OPEN_FILES,
- MODE_OPEN_DIR,
- MODE_OPEN_ANY,
- MODE_SAVE_FILE
+ enum FileMode {
+ FILE_MODE_OPEN_FILE,
+ FILE_MODE_OPEN_FILES,
+ FILE_MODE_OPEN_DIR,
+ FILE_MODE_OPEN_ANY,
+ FILE_MODE_SAVE_FILE
};
typedef Ref<Texture2D> (*GetIconFunc)(const String &);
@@ -92,7 +92,7 @@ private:
Access access;
//Button *action;
VBoxContainer *vbox;
- Mode mode;
+ FileMode mode;
bool can_create_dir;
LineEdit *dir;
@@ -221,8 +221,8 @@ public:
void set_display_mode(DisplayMode p_mode);
DisplayMode get_display_mode() const;
- void set_mode(Mode p_mode);
- Mode get_mode() const;
+ void set_file_mode(FileMode p_mode);
+ FileMode get_file_mode() const;
VBoxContainer *get_vbox();
LineEdit *get_line_edit() { return file; }
@@ -267,7 +267,7 @@ public:
EditorLineEditFileChooser();
};
-VARIANT_ENUM_CAST(EditorFileDialog::Mode);
+VARIANT_ENUM_CAST(EditorFileDialog::FileMode);
VARIANT_ENUM_CAST(EditorFileDialog::Access);
VARIANT_ENUM_CAST(EditorFileDialog::DisplayMode);
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 171b7a2176..8aadf02ea6 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -231,7 +231,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
// Default font
MAKE_DEFAULT_FONT(df, default_font_size);
- p_theme->set_default_theme_font(df);
+ p_theme->set_font("font", "Node", df); // Default theme font
p_theme->set_font("main", "EditorFonts", df);
// Bold font
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 874f984844..9d8c46cc2d 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -30,7 +30,7 @@
#include "editor_help.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "doc_data_compressed.gen.h"
#include "editor/plugins/script_editor_plugin.h"
@@ -46,17 +46,17 @@ DocData *EditorHelp::doc = NULL;
void EditorHelp::_init_colors() {
- title_color = get_color("accent_color", "Editor");
- text_color = get_color("default_color", "RichTextLabel");
- headline_color = get_color("headline_color", "EditorHelp");
+ title_color = get_theme_color("accent_color", "Editor");
+ text_color = get_theme_color("default_color", "RichTextLabel");
+ headline_color = get_theme_color("headline_color", "EditorHelp");
base_type_color = title_color.linear_interpolate(text_color, 0.5);
comment_color = text_color * Color(1, 1, 1, 0.6);
symbol_color = comment_color;
value_color = text_color * Color(1, 1, 1, 0.6);
qualifier_color = text_color * Color(1, 1, 1, 0.8);
- type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
- class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
- class_desc->add_constant_override("line_separation", Math::round(5 * EDSCALE));
+ type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
+ class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+ class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE));
}
void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
@@ -173,14 +173,14 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
void EditorHelp::_class_desc_resized() {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
- Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
+ Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts");
real_t char_width = doc_code_font->get_char_size('x').width;
const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
- Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate();
+ Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "RichTextLabel")->duplicate();
class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin);
class_desc_stylebox->set_default_margin(MARGIN_RIGHT, display_margin);
- class_desc->add_style_override("normal", class_desc_stylebox);
+ class_desc->add_theme_style_override("normal", class_desc_stylebox);
}
void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
@@ -197,8 +197,8 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
t = p_enum.get_slice(".", 0);
}
}
- const Color text_color = get_color("default_color", "RichTextLabel");
- const Color type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
+ const Color text_color = get_theme_color("default_color", "RichTextLabel");
+ const Color type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
class_desc->push_color(type_color);
if (can_ref) {
if (p_enum.empty()) {
@@ -346,10 +346,10 @@ void EditorHelp::_update_doc() {
DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying
- Ref<Font> doc_font = get_font("doc", "EditorFonts");
- Ref<Font> doc_bold_font = get_font("doc_bold", "EditorFonts");
- Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts");
- Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
+ Ref<Font> doc_font = get_theme_font("doc", "EditorFonts");
+ Ref<Font> doc_bold_font = get_theme_font("doc_bold", "EditorFonts");
+ Ref<Font> doc_title_font = get_theme_font("doc_title", "EditorFonts");
+ Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts");
String link_color_text = title_color.to_html(false);
// Class name
@@ -1072,7 +1072,7 @@ void EditorHelp::_update_doc() {
if (cd.properties[i].description.strip_edges() != String()) {
_add_text(DTR(cd.properties[i].description));
} else {
- class_desc->add_image(get_icon("Error", "EditorIcons"));
+ class_desc->add_image(get_theme_icon("Error", "EditorIcons"));
class_desc->add_text(" ");
class_desc->push_color(comment_color);
class_desc->append_bbcode(TTR("There is currently no description for this property. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
@@ -1125,7 +1125,7 @@ void EditorHelp::_update_doc() {
if (methods_filtered[i].description.strip_edges() != String()) {
_add_text(DTR(methods_filtered[i].description));
} else {
- class_desc->add_image(get_icon("Error", "EditorIcons"));
+ class_desc->add_image(get_theme_icon("Error", "EditorIcons"));
class_desc->add_text(" ");
class_desc->push_color(comment_color);
class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
@@ -1209,12 +1209,12 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
DocData *doc = EditorHelp::get_doc_data();
String base_path;
- Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts");
- Ref<Font> doc_bold_font = p_rt->get_font("doc_bold", "EditorFonts");
- Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts");
+ Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts");
+ Ref<Font> doc_bold_font = p_rt->get_theme_font("doc_bold", "EditorFonts");
+ Ref<Font> doc_code_font = p_rt->get_theme_font("doc_source", "EditorFonts");
- Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp");
- Color accent_color = p_rt->get_color("accent_color", "Editor");
+ Color font_color_hl = p_rt->get_theme_color("headline_color", "EditorHelp");
+ Color accent_color = p_rt->get_theme_color("accent_color", "Editor");
Color link_color = accent_color.linear_interpolate(font_color_hl, 0.8);
Color code_color = accent_color.linear_interpolate(font_color_hl, 0.6);
@@ -1545,7 +1545,7 @@ EditorHelp::EditorHelp() {
class_desc = memnew(RichTextLabel);
add_child(class_desc);
class_desc->set_v_size_flags(SIZE_EXPAND_FILL);
- class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+ class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
class_desc->connect("meta_clicked", callable_mp(this, &EditorHelp::_class_desc_select));
class_desc->connect("gui_input", callable_mp(this, &EditorHelp::_class_desc_input));
@@ -1610,9 +1610,14 @@ void EditorHelpBit::_bind_methods() {
void EditorHelpBit::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_READY: {
+ rich_text->clear();
+ _add_text_to_rt(text, rich_text);
+
+ } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- rich_text->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+ rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
} break;
default: break;
}
@@ -1620,8 +1625,9 @@ void EditorHelpBit::_notification(int p_what) {
void EditorHelpBit::set_text(const String &p_text) {
+ text = p_text;
rich_text->clear();
- _add_text_to_rt(p_text, rich_text);
+ _add_text_to_rt(text, rich_text);
}
EditorHelpBit::EditorHelpBit() {
@@ -1629,7 +1635,7 @@ EditorHelpBit::EditorHelpBit() {
rich_text = memnew(RichTextLabel);
add_child(rich_text);
rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked));
- rich_text->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+ rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
rich_text->set_override_selected_font_color(false);
set_custom_minimum_size(Size2(0, 70 * EDSCALE));
}
@@ -1693,13 +1699,13 @@ void FindBar::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
- find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
- hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
- hide_button->set_hover_texture(get_icon("Close", "EditorIcons"));
- hide_button->set_pressed_texture(get_icon("Close", "EditorIcons"));
+ find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
+ find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
+ hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
+ hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons"));
+ hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons"));
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
- matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor"));
+ matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -1780,7 +1786,7 @@ void FindBar::_update_matches_label() {
} else {
matches_label->show();
- matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor"));
+ matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count));
}
}
@@ -1828,7 +1834,7 @@ void FindBar::_search_text_changed(const String &p_text) {
void FindBar::_search_text_entered(const String &p_text) {
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
search_prev();
} else {
search_next();
diff --git a/editor/editor_help.h b/editor/editor_help.h
index a690e10e7e..d9c7194003 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -32,7 +32,7 @@
#define EDITOR_HELP_H
#include "editor/code_editor.h"
-#include "editor/doc/doc_data.h"
+#include "editor/doc_data.h"
#include "editor/editor_plugin.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/menu_button.h"
@@ -200,6 +200,8 @@ class EditorHelpBit : public PanelContainer {
void _go_to_help(String p_what);
void _meta_clicked(String p_select);
+ String text;
+
protected:
static void _bind_methods();
void _notification(int p_what);
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index f7ce2dd4fc..6fba5b1b4c 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -37,13 +37,13 @@
void EditorHelpSearch::_update_icons() {
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(results_tree->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
- case_sensitive_button->set_icon(get_icon("MatchCase", "EditorIcons"));
- hierarchy_button->set_icon(get_icon("ClassList", "EditorIcons"));
+ search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon("Search", "EditorIcons"));
+ case_sensitive_button->set_icon(results_tree->get_theme_icon("MatchCase", "EditorIcons"));
+ hierarchy_button->set_icon(results_tree->get_theme_icon("ClassList", "EditorIcons"));
- if (is_visible_in_tree())
+ if (is_visible())
_update_results();
}
@@ -57,7 +57,7 @@ void EditorHelpSearch::_update_results() {
if (hierarchy_button->is_pressed())
search_flags |= SEARCH_SHOW_HIERARCHY;
- search = Ref<Runner>(memnew(Runner(this, results_tree, term, search_flags)));
+ search = Ref<Runner>(memnew(Runner(results_tree, results_tree, term, search_flags)));
set_process(true);
}
@@ -105,6 +105,13 @@ void EditorHelpSearch::_confirmed() {
void EditorHelpSearch::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible()) {
+ results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation.
+ get_ok()->set_disabled(true);
+ EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size()));
+ }
+ } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_icons();
@@ -114,12 +121,7 @@ void EditorHelpSearch::_notification(int p_what) {
connect("confirmed", callable_mp(this, &EditorHelpSearch::_confirmed));
_update_icons();
} break;
- case NOTIFICATION_POPUP_HIDE: {
- results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation.
- get_ok()->set_disabled(true);
- EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", get_rect());
- } break;
case NOTIFICATION_PROCESS: {
// Update background search.
@@ -184,7 +186,7 @@ EditorHelpSearch::EditorHelpSearch() {
old_search = false;
set_hide_on_ok(false);
- set_resizable(true);
+
set_title(TTR("Search Help"));
get_ok()->set_disabled(true);
@@ -200,7 +202,7 @@ EditorHelpSearch::EditorHelpSearch() {
search_box = memnew(LineEdit);
search_box->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
- search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_box->connect("gui_input", callable_mp(this, &EditorHelpSearch::_search_box_gui_input));
search_box->connect("text_changed", callable_mp(this, &EditorHelpSearch::_search_box_text_changed));
register_text_enter(search_box);
@@ -210,7 +212,7 @@ EditorHelpSearch::EditorHelpSearch() {
case_sensitive_button->set_tooltip(TTR("Case Sensitive"));
case_sensitive_button->connect("pressed", callable_mp(this, &EditorHelpSearch::_update_results));
case_sensitive_button->set_toggle_mode(true);
- case_sensitive_button->set_focus_mode(FOCUS_NONE);
+ case_sensitive_button->set_focus_mode(Control::FOCUS_NONE);
hbox->add_child(case_sensitive_button);
hierarchy_button = memnew(ToolButton);
@@ -218,7 +220,7 @@ EditorHelpSearch::EditorHelpSearch() {
hierarchy_button->connect("pressed", callable_mp(this, &EditorHelpSearch::_update_results));
hierarchy_button->set_toggle_mode(true);
hierarchy_button->set_pressed(true);
- hierarchy_button->set_focus_mode(FOCUS_NONE);
+ hierarchy_button->set_focus_mode(Control::FOCUS_NONE);
hbox->add_child(hierarchy_button);
filter_combo = memnew(OptionButton);
@@ -237,7 +239,7 @@ EditorHelpSearch::EditorHelpSearch() {
// Create the results tree.
results_tree = memnew(Tree);
- results_tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ results_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
results_tree->set_columns(2);
results_tree->set_column_title(0, TTR("Name"));
results_tree->set_column_title(1, TTR("Member Type"));
@@ -479,10 +481,10 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_
TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) {
Ref<Texture2D> icon = empty_icon;
- if (ui_service->has_icon(p_doc->name, "EditorIcons"))
- icon = ui_service->get_icon(p_doc->name, "EditorIcons");
+ if (ui_service->has_theme_icon(p_doc->name, "EditorIcons"))
+ icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons");
else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object"))
- icon = ui_service->get_icon("Object", "EditorIcons");
+ icon = ui_service->get_theme_icon("Object", "EditorIcons");
String tooltip = p_doc->brief_description.strip_edges();
TreeItem *item = results_tree->create_item(p_parent);
@@ -557,10 +559,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons
Ref<Texture2D> icon;
String text;
if (search_flags & SEARCH_SHOW_HIERARCHY) {
- icon = ui_service->get_icon(p_icon, "EditorIcons");
+ icon = ui_service->get_theme_icon(p_icon, "EditorIcons");
text = p_name;
} else {
- icon = ui_service->get_icon(p_icon, "EditorIcons");
+ icon = ui_service->get_theme_icon(p_icon, "EditorIcons");
/*// In flat mode, show the class icon.
if (ui_service->has_icon(p_class_name, "EditorIcons"))
icon = ui_service->get_icon(p_class_name, "EditorIcons");
@@ -598,6 +600,6 @@ EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree,
results_tree(p_results_tree),
term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()),
search_flags(p_search_flags),
- empty_icon(ui_service->get_icon("ArrowRight", "EditorIcons")),
- disabled_color(ui_service->get_color("disabled_font_color", "Editor")) {
+ empty_icon(ui_service->get_theme_icon("ArrowRight", "EditorIcons")),
+ disabled_color(ui_service->get_theme_color("disabled_font_color", "Editor")) {
}
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index be3ee397e8..013ba88c30 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -41,7 +41,7 @@
Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
ms.height = font->get_height();
for (int i = 0; i < get_child_count(); i++) {
@@ -62,17 +62,17 @@ Size2 EditorProperty::get_minimum_size() const {
}
if (keying) {
- Ref<Texture2D> key = get_icon("Key", "EditorIcons");
- ms.width += key->get_width() + get_constant("hseparator", "Tree");
+ Ref<Texture2D> key = get_theme_icon("Key", "EditorIcons");
+ ms.width += key->get_width() + get_theme_constant("hseparator", "Tree");
}
if (checkable) {
- Ref<Texture2D> check = get_icon("checked", "CheckBox");
- ms.width += check->get_width() + get_constant("hseparation", "CheckBox") + get_constant("hseparator", "Tree");
+ Ref<Texture2D> check = get_theme_icon("checked", "CheckBox");
+ ms.width += check->get_width() + get_theme_constant("hseparation", "CheckBox") + get_theme_constant("hseparator", "Tree");
}
if (bottom_editor != NULL && bottom_editor->is_visible()) {
- ms.height += get_constant("vseparation", "Tree");
+ ms.height += get_theme_constant("vseparation", "Tree");
Size2 bems = bottom_editor->get_combined_minimum_size();
//bems.width += get_constant("item_margin", "Tree");
ms.height += bems.height;
@@ -103,7 +103,7 @@ void EditorProperty::_notification(int p_what) {
{
int child_room = size.width * (1.0 - split_ratio);
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
int height = font->get_height();
bool no_children = true;
@@ -136,19 +136,19 @@ void EditorProperty::_notification(int p_what) {
int m = 0; //get_constant("item_margin", "Tree");
- bottom_rect = Rect2(m, rect.size.height + get_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height);
+ bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height);
}
if (keying) {
Ref<Texture2D> key;
if (use_keying_next()) {
- key = get_icon("KeyNext", "EditorIcons");
+ key = get_theme_icon("KeyNext", "EditorIcons");
} else {
- key = get_icon("Key", "EditorIcons");
+ key = get_theme_icon("Key", "EditorIcons");
}
- rect.size.x -= key->get_width() + get_constant("hseparator", "Tree");
+ rect.size.x -= key->get_width() + get_theme_constant("hseparator", "Tree");
if (no_children) {
text_size -= key->get_width() + 4 * EDSCALE;
@@ -180,8 +180,8 @@ void EditorProperty::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
- Ref<Font> font = get_font("font", "Tree");
- Color dark_color = get_color("dark_color_2", "Editor");
+ Ref<Font> font = get_theme_font("font", "Tree");
+ Color dark_color = get_theme_color("dark_color_2", "Editor");
Size2 size = get_size();
if (bottom_editor) {
@@ -191,7 +191,7 @@ void EditorProperty::_notification(int p_what) {
}
if (selected) {
- Ref<StyleBox> sb = get_stylebox("selected", "Tree");
+ Ref<StyleBox> sb = get_theme_stylebox("selected", "Tree");
draw_style_box(sb, Rect2(Vector2(), size));
}
@@ -204,9 +204,9 @@ void EditorProperty::_notification(int p_what) {
Color color;
if (draw_red) {
- color = get_color("error_color", "Editor");
+ color = get_theme_color("error_color", "Editor");
} else {
- color = get_color("property_color", "Editor");
+ color = get_theme_color("property_color", "Editor");
}
if (label.find(".") != -1) {
color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides
@@ -218,9 +218,9 @@ void EditorProperty::_notification(int p_what) {
if (checkable) {
Ref<Texture2D> checkbox;
if (checked)
- checkbox = get_icon("GuiChecked", "EditorIcons");
+ checkbox = get_theme_icon("GuiChecked", "EditorIcons");
else
- checkbox = get_icon("GuiUnchecked", "EditorIcons");
+ checkbox = get_theme_icon("GuiUnchecked", "EditorIcons");
Color color2(1, 1, 1);
if (check_hover) {
@@ -230,16 +230,16 @@ void EditorProperty::_notification(int p_what) {
}
check_rect = Rect2(ofs, ((size.height - checkbox->get_height()) / 2), checkbox->get_width(), checkbox->get_height());
draw_texture(checkbox, check_rect.position, color2);
- ofs += get_constant("hseparator", "Tree") + checkbox->get_width() + get_constant("hseparation", "CheckBox");
+ ofs += get_theme_constant("hseparator", "Tree") + checkbox->get_width() + get_theme_constant("hseparation", "CheckBox");
text_limit -= ofs;
} else {
check_rect = Rect2();
}
if (can_revert) {
- Ref<Texture2D> reload_icon = get_icon("ReloadSmall", "EditorIcons");
- text_limit -= reload_icon->get_width() + get_constant("hseparator", "Tree") * 2;
- revert_rect = Rect2(text_limit + get_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height());
+ Ref<Texture2D> reload_icon = get_theme_icon("ReloadSmall", "EditorIcons");
+ text_limit -= reload_icon->get_width() + get_theme_constant("hseparator", "Tree") * 2;
+ revert_rect = Rect2(text_limit + get_theme_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height());
Color color2(1, 1, 1);
if (revert_hover) {
@@ -260,12 +260,12 @@ void EditorProperty::_notification(int p_what) {
Ref<Texture2D> key;
if (use_keying_next()) {
- key = get_icon("KeyNext", "EditorIcons");
+ key = get_theme_icon("KeyNext", "EditorIcons");
} else {
- key = get_icon("Key", "EditorIcons");
+ key = get_theme_icon("Key", "EditorIcons");
}
- ofs = size.width - key->get_width() - get_constant("hseparator", "Tree");
+ ofs = size.width - key->get_width() - get_theme_constant("hseparator", "Tree");
Color color2(1, 1, 1);
if (keying_hover) {
@@ -646,7 +646,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) {
- if (property == "frame_coords" && (object->is_class("Sprite") || object->is_class("Sprite3D"))) {
+ if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) {
Vector2 new_coords = object->get(property);
new_coords.x++;
if (new_coords.x >= object->get("hframes").operator int64_t()) {
@@ -776,13 +776,14 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
tooltip_text = p_text;
EditorHelpBit *help_bit = memnew(EditorHelpBit);
- help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
+ //help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
+ String text;
PackedStringArray slices = p_text.split("::", false);
if (!slices.empty()) {
String property_name = slices[0].strip_edges();
- String text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]";
+ text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]";
if (slices.size() > 1) {
String property_doc = slices[1].strip_edges();
@@ -790,7 +791,7 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
text += "\n" + property_doc;
}
}
- help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ help_bit->set_text(text);
}
return help_bit;
@@ -987,9 +988,9 @@ void EditorInspectorCategory::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
draw_rect(Rect2(Vector2(), get_size()), bg_color);
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
- int hs = get_constant("hseparation", "Tree");
+ int hs = get_theme_constant("hseparation", "Tree");
int w = font->get_string_size(label).width;
if (icon.is_valid()) {
@@ -1003,7 +1004,7 @@ void EditorInspectorCategory::_notification(int p_what) {
ofs += hs + icon->get_width();
}
- Color color = get_color("font_color", "Tree");
+ Color color = get_theme_color("font_color", "Tree");
draw_string(font, Point2(ofs, font->get_ascent() + (get_size().height - font->get_height()) / 2).floor(), label, color, get_size().width);
}
}
@@ -1012,7 +1013,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
tooltip_text = p_text;
EditorHelpBit *help_bit = memnew(EditorHelpBit);
- help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
+ help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
PackedStringArray slices = p_text.split("::", false);
@@ -1026,7 +1027,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
text += "\n" + property_doc;
}
}
- help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ help_bit->set_text(text); //hack so it uses proper theme once inside scene
}
return help_bit;
@@ -1034,7 +1035,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
Size2 EditorInspectorCategory::get_minimum_size() const {
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
Size2 ms;
ms.width = 1;
@@ -1042,7 +1043,7 @@ Size2 EditorInspectorCategory::get_minimum_size() const {
if (icon.is_valid()) {
ms.height = MAX(icon->get_height(), ms.height);
}
- ms.height += get_constant("vseparation", "Tree");
+ ms.height += get_theme_constant("vseparation", "Tree");
return ms;
}
@@ -1074,14 +1075,14 @@ void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_SORT_CHILDREN) {
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
Ref<Texture2D> arrow;
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
- arrow = get_icon("arrow", "Tree");
+ arrow = get_theme_icon("arrow", "Tree");
} else {
- arrow = get_icon("arrow_collapsed", "Tree");
+ arrow = get_theme_icon("arrow_collapsed", "Tree");
}
}
@@ -1092,8 +1093,8 @@ void EditorInspectorSection::_notification(int p_what) {
offset.y = MAX(offset.y, arrow->get_height());
}
- offset.y += get_constant("vseparation", "Tree");
- offset.x += get_constant("inspector_margin", "Editor");
+ offset.y += get_theme_constant("vseparation", "Tree");
+ offset.x += get_theme_constant("inspector_margin", "Editor");
Rect2 rect(offset, size - offset);
@@ -1120,24 +1121,24 @@ void EditorInspectorSection::_notification(int p_what) {
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
- arrow = get_icon("arrow", "Tree");
+ arrow = get_theme_icon("arrow", "Tree");
} else {
- arrow = get_icon("arrow_collapsed", "Tree");
+ arrow = get_theme_icon("arrow_collapsed", "Tree");
}
}
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
int h = font->get_height();
if (arrow.is_valid()) {
h = MAX(h, arrow->get_height());
}
- h += get_constant("vseparation", "Tree");
+ h += get_theme_constant("vseparation", "Tree");
draw_rect(Rect2(Vector2(), Vector2(get_size().width, h)), bg_color);
const int arrow_margin = 3;
- Color color = get_color("font_color", "Tree");
+ Color color = get_theme_color("font_color", "Tree");
draw_string(font, Point2(Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent() + (h - font->get_height()) / 2).floor(), label, color, get_size().width);
if (arrow.is_valid()) {
@@ -1163,9 +1164,9 @@ Size2 EditorInspectorSection::get_minimum_size() const {
ms.height = MAX(ms.height, minsize.height);
}
- Ref<Font> font = get_font("font", "Tree");
- ms.height += font->get_height() + get_constant("vseparation", "Tree");
- ms.width += get_constant("inspector_margin", "Editor");
+ Ref<Font> font = get_theme_font("font", "Tree");
+ ms.height += font->get_height() + get_theme_constant("vseparation", "Tree");
+ ms.width += get_theme_constant("inspector_margin", "Editor");
return ms;
}
@@ -1201,7 +1202,7 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
- Ref<Font> font = get_font("font", "Tree");
+ Ref<Font> font = get_theme_font("font", "Tree");
if (mb->get_position().y > font->get_height()) { //clicked outside
return;
}
@@ -1488,7 +1489,7 @@ void EditorInspector::update_tree() {
item_path[""] = main_vbox;
- Color sscolor = get_color("prop_subsection", "Editor");
+ Color sscolor = get_theme_color("prop_subsection", "Editor");
for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) {
Ref<EditorInspectorPlugin> ped = E->get();
@@ -1540,7 +1541,7 @@ void EditorInspector::update_tree() {
category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
category->label = type;
- category->bg_color = get_color("prop_category", "Editor");
+ category->bg_color = get_theme_color("prop_category", "Editor");
if (use_doc_hints) {
StringName type2 = p.name;
if (!class_descr_cache.has(type2)) {
@@ -1568,7 +1569,7 @@ void EditorInspector::update_tree() {
} else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name))
continue;
- if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && VS::get_singleton()->is_low_end())
+ if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end())
continue; //do not show this property in low end gfx
if (p.name == "script" && (hide_script || bool(object->call("_hide_script_from_inspector")))) {
@@ -1978,9 +1979,9 @@ void EditorInspector::set_sub_inspector(bool p_enable) {
return;
if (sub_inspector) {
- add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
+ add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
} else {
- add_style_override("bg", get_stylebox("bg", "Tree"));
+ add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
}
}
@@ -2203,9 +2204,9 @@ void EditorInspector::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
if (sub_inspector) {
- add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
+ add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
} else {
- add_style_override("bg", get_stylebox("bg", "Tree"));
+ add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
}
}
@@ -2266,9 +2267,9 @@ void EditorInspector::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
if (sub_inspector) {
- add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
+ add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
} else if (is_inside_tree()) {
- add_style_override("bg", get_stylebox("bg", "Tree"));
+ add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
}
update_tree();
@@ -2331,7 +2332,7 @@ EditorInspector::EditorInspector() {
undo_redo = NULL;
main_vbox = memnew(VBoxContainer);
main_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
- main_vbox->add_constant_override("separation", 0);
+ main_vbox->add_theme_constant_override("separation", 0);
add_child(main_vbox);
set_enable_h_scroll(false);
set_enable_v_scroll(true);
diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp
index 776fbd9314..dbd043c494 100644
--- a/editor/editor_layouts_dialog.cpp
+++ b/editor/editor_layouts_dialog.cpp
@@ -52,12 +52,12 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) {
if (get_hide_on_ok())
hide();
ok_pressed();
- accept_event();
+ set_input_as_handled();
} break;
case KEY_ESCAPE: {
hide();
- accept_event();
+ set_input_as_handled();
} break;
}
}
@@ -110,15 +110,15 @@ EditorLayoutsDialog::EditorLayoutsDialog() {
makevb = memnew(VBoxContainer);
add_child(makevb);
- makevb->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
- makevb->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5);
+ makevb->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5);
+ makevb->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5);
layout_names = memnew(ItemList);
makevb->add_child(layout_names);
layout_names->set_visible(true);
layout_names->set_margin(MARGIN_TOP, 5);
- layout_names->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
- layout_names->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5);
+ layout_names->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5);
+ layout_names->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5);
layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL);
layout_names->set_select_mode(ItemList::SELECT_MULTI);
layout_names->set_allow_rmb_select(true);
@@ -126,8 +126,8 @@ EditorLayoutsDialog::EditorLayoutsDialog() {
name = memnew(LineEdit);
makevb->add_child(name);
name->set_margin(MARGIN_TOP, 5);
- name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
- name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5);
+ name->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5);
+ name->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5);
name->connect("gui_input", callable_mp(this, &EditorLayoutsDialog::_line_gui_input));
name->connect("focus_entered", callable_mp(layout_names, &ItemList::unselect_all));
}
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 0e50a5e95c..91e53edeac 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -62,12 +62,12 @@ void EditorLog::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
//button->set_icon(get_icon("Console","EditorIcons"));
- log->add_font_override("normal_font", get_font("output_source", "EditorFonts"));
+ log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts"));
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<DynamicFont> df_output_code = get_font("output_source", "EditorFonts");
+ Ref<DynamicFont> df_output_code = get_theme_font("output_source", "EditorFonts");
if (df_output_code.is_valid()) {
if (log != NULL) {
- log->add_font_override("normal_font", get_font("output_source", "EditorFonts"));
+ log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts"));
}
}
}
@@ -101,22 +101,22 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) {
case MSG_TYPE_STD: {
} break;
case MSG_TYPE_ERROR: {
- log->push_color(get_color("error_color", "Editor"));
- Ref<Texture2D> icon = get_icon("Error", "EditorIcons");
+ log->push_color(get_theme_color("error_color", "Editor"));
+ Ref<Texture2D> icon = get_theme_icon("Error", "EditorIcons");
log->add_image(icon);
log->add_text(" ");
tool_button->set_icon(icon);
} break;
case MSG_TYPE_WARNING: {
- log->push_color(get_color("warning_color", "Editor"));
- Ref<Texture2D> icon = get_icon("Warning", "EditorIcons");
+ log->push_color(get_theme_color("warning_color", "Editor"));
+ Ref<Texture2D> icon = get_theme_icon("Warning", "EditorIcons");
log->add_image(icon);
log->add_text(" ");
tool_button->set_icon(icon);
} break;
case MSG_TYPE_EDITOR: {
// Distinguish editor messages from messages printed by the project
- log->push_color(get_color("font_color", "Editor") * Color(1, 1, 1, 0.6));
+ log->push_color(get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.6));
} break;
}
@@ -181,7 +181,7 @@ EditorLog::EditorLog() {
current = Thread::get_caller_id();
- add_constant_override("separation", get_constant("separation", "VBoxContainer"));
+ add_theme_constant_override("separation", get_theme_constant("separation", "VBoxContainer"));
EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk, this);
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f40762586e..2ba67ae879 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -32,6 +32,7 @@
#include "core/bind/core_bind.h"
#include "core/class_db.h"
+#include "core/input/input_filter.h"
#include "core/io/config_file.h"
#include "core/io/image_loader.h"
#include "core/io/resource_loader.h"
@@ -39,7 +40,6 @@
#include "core/io/stream_peer_ssl.h"
#include "core/message_queue.h"
#include "core/os/file_access.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/path_remap.h"
@@ -47,7 +47,6 @@
#include "core/project_settings.h"
#include "core/translation.h"
#include "core/version.h"
-#include "main/input_default.h"
#include "main/main.h"
#include "scene/gui/center_container.h"
#include "scene/gui/control.h"
@@ -62,9 +61,9 @@
#include "scene/gui/texture_progress.h"
#include "scene/gui/tool_button.h"
#include "scene/resources/packed_scene.h"
-#include "servers/navigation_2d_server.h"
-#include "servers/navigation_server.h"
-#include "servers/physics_2d_server.h"
+#include "servers/navigation_server_2d.h"
+#include "servers/navigation_server_3d.h"
+#include "servers/physics_server_2d.h"
#include "editor/audio_stream_preview.h"
#include "editor/debugger/editor_debugger_node.h"
@@ -115,32 +114,33 @@
#include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/baked_lightmap_editor_plugin.h"
-#include "editor/plugins/camera_editor_plugin.h"
+#include "editor/plugins/camera_3d_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/collision_polygon_2d_editor_plugin.h"
-#include "editor/plugins/collision_polygon_editor_plugin.h"
+#include "editor/plugins/collision_polygon_3d_editor_plugin.h"
#include "editor/plugins/collision_shape_2d_editor_plugin.h"
#include "editor/plugins/cpu_particles_2d_editor_plugin.h"
-#include "editor/plugins/cpu_particles_editor_plugin.h"
+#include "editor/plugins/cpu_particles_3d_editor_plugin.h"
#include "editor/plugins/curve_editor_plugin.h"
#include "editor/plugins/debugger_editor_plugin.h"
#include "editor/plugins/editor_preview_plugins.h"
#include "editor/plugins/gi_probe_editor_plugin.h"
+#include "editor/plugins/gpu_particles_2d_editor_plugin.h"
+#include "editor/plugins/gpu_particles_3d_editor_plugin.h"
#include "editor/plugins/gradient_editor_plugin.h"
#include "editor/plugins/item_list_editor_plugin.h"
#include "editor/plugins/light_occluder_2d_editor_plugin.h"
#include "editor/plugins/line_2d_editor_plugin.h"
#include "editor/plugins/material_editor_plugin.h"
#include "editor/plugins/mesh_editor_plugin.h"
-#include "editor/plugins/mesh_instance_editor_plugin.h"
+#include "editor/plugins/mesh_instance_3d_editor_plugin.h"
#include "editor/plugins/mesh_library_editor_plugin.h"
#include "editor/plugins/multimesh_editor_plugin.h"
#include "editor/plugins/navigation_polygon_editor_plugin.h"
-#include "editor/plugins/particles_2d_editor_plugin.h"
-#include "editor/plugins/particles_editor_plugin.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/plugins/path_2d_editor_plugin.h"
-#include "editor/plugins/path_editor_plugin.h"
-#include "editor/plugins/physical_bone_plugin.h"
+#include "editor/plugins/path_3d_editor_plugin.h"
+#include "editor/plugins/physical_bone_3d_editor_plugin.h"
#include "editor/plugins/polygon_2d_editor_plugin.h"
#include "editor/plugins/resource_preloader_editor_plugin.h"
#include "editor/plugins/root_motion_editor_plugin.h"
@@ -148,10 +148,9 @@
#include "editor/plugins/script_text_editor.h"
#include "editor/plugins/shader_editor_plugin.h"
#include "editor/plugins/skeleton_2d_editor_plugin.h"
-#include "editor/plugins/skeleton_editor_plugin.h"
-#include "editor/plugins/skeleton_ik_editor_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "editor/plugins/sprite_editor_plugin.h"
+#include "editor/plugins/skeleton_3d_editor_plugin.h"
+#include "editor/plugins/skeleton_ik_3d_editor_plugin.h"
+#include "editor/plugins/sprite_2d_editor_plugin.h"
#include "editor/plugins/sprite_frames_editor_plugin.h"
#include "editor/plugins/style_box_editor_plugin.h"
#include "editor/plugins/text_editor.h"
@@ -170,7 +169,8 @@
#include "editor/register_exporters.h"
#include "editor/run_settings_dialog.h"
#include "editor/settings_config_dialog.h"
-
+#include "scene/main/window.h"
+#include "servers/display_server.h"
#include <stdio.h>
#include <stdlib.h>
@@ -180,10 +180,12 @@ void EditorNode::_update_scene_tabs() {
bool show_rb = EditorSettings::get_singleton()->get("interface/scene_tabs/show_script_button");
- OS::get_singleton()->global_menu_clear("_dock");
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
+ DisplayServer::get_singleton()->global_menu_clear("_dock");
+ }
scene_tabs->clear_tabs();
- Ref<Texture2D> script_icon = gui_base->get_icon("Script", "EditorIcons");
+ Ref<Texture2D> script_icon = gui_base->get_theme_icon("Script", "EditorIcons");
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *type_node = editor_data.get_edited_scene_root(i);
@@ -196,15 +198,19 @@ void EditorNode::_update_scene_tabs() {
bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon);
- OS::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), GLOBAL_SCENE, i);
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
+ DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), callable_mp(this, &EditorNode::_global_menu_scene), i);
+ }
if (show_rb && editor_data.get_scene_root_script(i).is_valid()) {
scene_tabs->set_tab_right_button(i, script_icon);
}
}
- OS::get_singleton()->global_menu_add_separator("_dock");
- OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
+ DisplayServer::get_singleton()->global_menu_add_separator("_dock");
+ DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &EditorNode::_global_menu_new_window));
+ }
scene_tabs->set_current_tab(editor_data.get_edited_scene());
@@ -253,16 +259,13 @@ void EditorNode::_update_title() {
if (unsaved_cache)
title += " (*)";
- OS::get_singleton()->set_window_title(title);
+ DisplayServer::get_singleton()->window_set_title(title);
}
void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
- if (Node::get_viewport()->get_modal_stack_top())
- return; //ignore because of modal window
-
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && k->is_pressed() && !k->is_echo() && !gui_base->get_viewport()->gui_has_modal_stack()) {
+ if (k.is_valid() && k->is_pressed() && !k->is_echo()) {
EditorPlugin *old_editor = editor_plugin_screen;
@@ -297,7 +300,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
}
if (old_editor != editor_plugin_screen) {
- get_tree()->set_input_as_handled();
+ get_tree()->get_root()->set_input_as_handled();
}
}
}
@@ -335,13 +338,13 @@ void EditorNode::_notification(int p_what) {
// update the icon itself only when the spinner is visible
if (EditorSettings::get_singleton()->get("interface/editor/show_update_spinner")) {
- update_spinner->set_icon(gui_base->get_icon("Progress" + itos(update_spinner_step + 1), "EditorIcons"));
+ update_spinner->set_icon(gui_base->get_theme_icon("Progress" + itos(update_spinner_step + 1), "EditorIcons"));
}
}
editor_selection->update();
- scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")));
+ //scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")));
{ //TODO should only happen on settings changed
int current_filter = GLOBAL_GET("rendering/canvas_textures/default_texture_filter");
@@ -355,13 +358,13 @@ void EditorNode::_notification(int p_what) {
scene_root->set_default_canvas_item_texture_repeat(tr);
}
- VS::DOFBokehShape dof_shape = VS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape")));
- VS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape);
- VS::DOFBlurQuality dof_quality = VS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality")));
+ RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape")));
+ RS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape);
+ RS::DOFBlurQuality dof_quality = RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality")));
bool dof_jitter = GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter");
- VS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter);
- VS::get_singleton()->environment_set_ssao_quality(VS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
- VS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve"));
+ RS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter);
+ RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
+ RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve"));
}
ResourceImporterTexture::get_singleton()->update_imports();
@@ -374,8 +377,7 @@ void EditorNode::_notification(int p_what) {
get_tree()->get_root()->set_as_audio_listener(false);
get_tree()->get_root()->set_as_audio_listener_2d(false);
get_tree()->set_auto_accept_quit(false);
- get_tree()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files));
- get_tree()->connect("global_menu_action", callable_mp(this, &EditorNode::_global_menu_action));
+ get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files));
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
} break;
@@ -402,9 +404,9 @@ void EditorNode::_notification(int p_what) {
_initializing_addons = false;
}
- VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true);
- VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true);
- VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true);
+ RenderingServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true);
+ RenderingServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true);
+ RenderingServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true);
feature_profile_manager->notify_changed();
@@ -417,7 +419,7 @@ void EditorNode::_notification(int p_what) {
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
// Restore the original FPS cap after focusing back on the editor
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
@@ -425,18 +427,18 @@ void EditorNode::_notification(int p_what) {
EditorFileSystem::get_singleton()->scan_changes();
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_WM_FOCUS_OUT: {
// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));
} break;
- case MainLoop::NOTIFICATION_WM_ABOUT: {
+ case NOTIFICATION_WM_ABOUT: {
show_about();
} break;
- case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
+ case NOTIFICATION_WM_CLOSE_REQUEST: {
_menu_option_confirm(FILE_QUIT, false);
} break;
@@ -448,17 +450,17 @@ void EditorNode::_notification(int p_what) {
theme_base->set_theme(theme);
gui_base->set_theme(theme);
- gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
- scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
- scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
- scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
+ gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles"));
+ scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles"));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer"));
+ scene_tabs->add_theme_style_override("tab_fg", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles"));
+ scene_tabs->add_theme_style_override("tab_bg", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles"));
- file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
- project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
- debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
- settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
- help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
+ project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
+ debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
+ settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
+ help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) {
scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE);
@@ -471,7 +473,7 @@ void EditorNode::_notification(int p_what) {
// debugger area
if (EditorDebuggerNode::get_singleton()->is_visible())
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
// update_icons
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
@@ -482,36 +484,36 @@ void EditorNode::_notification(int p_what) {
if (icon.is_valid()) {
tb->set_icon(icon);
- } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) {
- tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
+ } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), "EditorIcons")) {
+ tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons"));
}
}
_build_icon_type_cache();
- play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
- play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
- pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons"));
- stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons"));
+ play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons"));
+ pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons"));
+ stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons"));
- prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons"));
- distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons"));
- scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons"));
+ prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons"));
+ distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons"));
+ scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons"));
- bottom_panel_raise->set_icon(gui_base->get_icon("ExpandBottomDock", "EditorIcons"));
+ bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons"));
// clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property
dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
PopupMenu *p = help_menu->get_popup();
- p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_icon("HelpSearch", "EditorIcons"));
- p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_icon("Instance", "EditorIcons"));
- p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_icon("Instance", "EditorIcons"));
- p->set_item_icon(p->get_item_index(HELP_ISSUES), gui_base->get_icon("Instance", "EditorIcons"));
- p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_icon("Instance", "EditorIcons"));
- p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_icon("Godot", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon("HelpSearch", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon("Instance", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon("Instance", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(HELP_ISSUES), gui_base->get_theme_icon("Instance", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon("Instance", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons"));
_update_update_spinner();
} break;
@@ -822,7 +824,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
}
}
- file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
saving_resource = p_resource;
current_option = RESOURCE_SAVE_AS;
@@ -1105,7 +1107,7 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) {
if (p_node->is_class("CanvasItem"))
count_2d++;
- else if (p_node->is_class("Spatial"))
+ else if (p_node->is_class("Node3D"))
count_3d++;
for (int i = 0; i < p_node->get_child_count(); i++)
@@ -1137,7 +1139,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
if (is2d) {
img = scene_root->get_texture()->get_data();
} else {
- img = SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
+ img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
}
if (img.is_valid()) {
@@ -1466,7 +1468,7 @@ void EditorNode::_dialog_action(String p_file) {
int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing;
- if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
+ if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
bool same_open_scene = false;
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
if (editor_data.get_scene_path(i) == p_file && i != scene_idx)
@@ -1490,7 +1492,7 @@ void EditorNode::_dialog_action(String p_file) {
} break;
case FILE_SAVE_AND_RUN: {
- if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
+ if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
_save_default_environment();
_save_scene_with_preview(p_file);
@@ -1620,7 +1622,7 @@ void EditorNode::_dialog_action(String p_file) {
} break;
default: { //save scene?
- if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
+ if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
_save_scene_with_preview(p_file);
}
@@ -1970,11 +1972,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
}
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
+ play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons"));
play_scene_button->set_pressed(false);
- play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons"));
String main_scene;
String run_filename;
@@ -2057,14 +2059,14 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
emit_signal("play_pressed");
if (p_current) {
play_scene_button->set_pressed(true);
- play_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons"));
} else if (p_custom != "") {
run_custom_filename = p_custom;
play_custom_scene_button->set_pressed(true);
- play_custom_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons"));
} else {
play_button->set_pressed(true);
- play_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
+ play_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons"));
}
stop_button->set_disabled(false);
@@ -2085,7 +2087,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case FILE_NEW_INHERITED_SCENE:
case FILE_OPEN_SCENE: {
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
@@ -2158,7 +2160,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename();
save_confirmation->get_ok()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene"));
- save_confirmation->popup_centered_minsize();
+ save_confirmation->popup_centered();
break;
}
} else if (p_option == FILE_CLOSE) {
@@ -2212,7 +2214,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
break;
}
- file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
List<String> extensions;
Ref<PackedScene> sd = memnew(PackedScene);
@@ -2254,7 +2256,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
confirmation->get_cancel()->set_text(TTR("No"));
confirmation->get_ok()->set_text(TTR("Yes"));
confirmation->set_text(TTR("This scene has never been saved. Save before running?"));
- confirmation->popup_centered_minsize();
+ confirmation->popup_centered();
break;
}
@@ -2326,7 +2328,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
confirmation->get_ok()->set_text(TTR("Open"));
confirmation->set_text(TTR("Current scene not saved. Open anyway?"));
- confirmation->popup_centered_minsize();
+ confirmation->popup_centered();
break;
}
@@ -2341,7 +2343,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case EDIT_UNDO: {
- if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
+ if (InputFilter::get_singleton()->get_mouse_button_mask() & 0x7) {
log->add_message("Can't undo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR);
} else {
String action = editor_data.get_undo_redo().get_current_action_name();
@@ -2355,7 +2357,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case EDIT_REDO: {
- if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
+ if (InputFilter::get_singleton()->get_mouse_button_mask() & 0x7) {
log->add_message("Can't redo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR);
} else {
if (!editor_data.get_undo_redo().redo()) {
@@ -2384,7 +2386,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (unsaved_cache && !p_confirmed) {
confirmation->get_ok()->set_text(TTR("Revert"));
confirmation->set_text(TTR("This action cannot be undone. Revert anyway?"));
- confirmation->popup_centered_minsize();
+ confirmation->popup_centered();
break;
}
@@ -2424,11 +2426,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
editor_run.stop();
run_custom_filename.clear();
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
+ play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons"));
play_scene_button->set_pressed(false);
- play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons"));
stop_button->set_disabled(true);
if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) {
@@ -2487,11 +2489,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
export_template_manager->install_android_template();
} else {
if (DirAccess::exists("res://android/build")) {
- remove_android_build_template->popup_centered_minsize();
+ remove_android_build_template->popup_centered();
} else if (export_template_manager->can_install_android_template()) {
- install_android_build_template->popup_centered_minsize();
+ install_android_build_template->popup_centered();
} else {
- custom_build_manage_templates->popup_centered_minsize();
+ custom_build_manage_templates->popup_centered();
}
}
} break;
@@ -2513,7 +2515,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
confirmation->set_text(p_option == FILE_QUIT ? TTR("Exit the editor?") : TTR("Open Project Manager?"));
- confirmation->popup_centered_minsize();
+ confirmation->popup_centered();
} else {
_discard_changes();
break;
@@ -2534,11 +2536,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
save_confirmation->get_ok()->set_text(TTR("Save & Quit"));
save_confirmation->set_text((p_option == FILE_QUIT ? TTR("Save changes to the following scene(s) before quitting?") : TTR("Save changes the following scene(s) before opening Project Manager?")) + unsaved_scenes);
- save_confirmation->popup_centered_minsize();
+ save_confirmation->popup_centered();
}
}
- OS::get_singleton()->request_attention();
+ DisplayServer::get_singleton()->window_request_attention();
break;
}
@@ -2586,13 +2588,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case SETTINGS_TOGGLE_FULLSCREEN: {
- OS::get_singleton()->set_window_fullscreen(!OS::get_singleton()->is_window_fullscreen());
+ DisplayServer::get_singleton()->window_set_mode(DisplayServer::get_singleton()->window_get_mode() == DisplayServer::WINDOW_MODE_FULLSCREEN ? DisplayServer::WINDOW_MODE_WINDOWED : DisplayServer::WINDOW_MODE_FULLSCREEN);
} break;
case SETTINGS_TOGGLE_CONSOLE: {
- bool was_visible = OS::get_singleton()->is_console_visible();
- OS::get_singleton()->set_console_visible(!was_visible);
+ bool was_visible = DisplayServer::get_singleton()->is_console_visible();
+ DisplayServer::get_singleton()->console_set_visible(!was_visible);
EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", was_visible);
} break;
case EDITOR_SCREENSHOT: {
@@ -2601,7 +2603,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case SETTINGS_PICK_MAIN_SCENE: {
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
@@ -2634,7 +2636,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
OS::get_singleton()->shell_open("https://godotengine.org/community");
} break;
case HELP_ABOUT: {
- about->popup_centered_minsize(Size2(780, 500) * EDSCALE);
+ about->popup_centered(Size2(780, 500) * EDSCALE);
} break;
case SET_VIDEO_DRIVER_SAVE_AND_RESTART: {
@@ -2663,10 +2665,10 @@ void EditorNode::_screenshot(bool p_use_utc) {
void EditorNode::_save_screenshot(NodePath p_path) {
- Viewport *viewport = EditorInterface::get_singleton()->get_editor_viewport()->get_viewport();
- viewport->set_clear_mode(Viewport::CLEAR_MODE_ONLY_NEXT_FRAME);
+ SubViewport *viewport = Object::cast_to<SubViewport>(EditorInterface::get_singleton()->get_editor_viewport()->get_viewport());
+ viewport->set_clear_mode(SubViewport::CLEAR_MODE_ONLY_NEXT_FRAME);
Ref<Image> img = viewport->get_texture()->get_data();
- viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS);
+ viewport->set_clear_mode(SubViewport::CLEAR_MODE_ALWAYS);
Error error = img->save_png(p_path);
ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'.");
}
@@ -2884,8 +2886,8 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
if (icon.is_valid()) {
tb->set_icon(icon);
- } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) {
- tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
+ } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), "EditorIcons")) {
+ tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons"));
}
tb->set_name(p_editor->get_name());
@@ -3269,7 +3271,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (!p_force_open_imported && FileAccess::exists(p_scene + ".import")) {
open_imported->set_text(vformat(TTR("Scene '%s' was automatically imported, so it can't be modified.\nTo make changes to it, a new inherited scene can be created."), p_scene.get_file()));
- open_imported->popup_centered_minsize();
+ open_imported->popup_centered();
new_inherited_button->grab_focus();
open_import_request = p_scene;
return OK;
@@ -3553,7 +3555,7 @@ void EditorNode::add_io_error(const String &p_error) {
void EditorNode::_load_error_notify(void *p_ud, const String &p_text) {
EditorNode *en = (EditorNode *)p_ud;
- en->load_errors->add_image(en->gui_base->get_icon("Error", "EditorIcons"));
+ en->load_errors->add_image(en->gui_base->get_theme_icon("Error", "EditorIcons"));
en->load_errors->add_text(p_text + "\n");
en->load_error_dialog->popup_centered_ratio(0.5);
}
@@ -3593,8 +3595,8 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorSelection>();
ClassDB::register_class<EditorFileDialog>();
ClassDB::register_virtual_class<EditorSettings>();
- ClassDB::register_class<EditorSpatialGizmo>();
- ClassDB::register_class<EditorSpatialGizmoPlugin>();
+ ClassDB::register_class<EditorNode3DGizmo>();
+ ClassDB::register_class<EditorNode3DGizmoPlugin>();
ClassDB::register_virtual_class<EditorResourcePreview>();
ClassDB::register_class<EditorResourcePreviewGenerator>();
ClassDB::register_virtual_class<EditorFileSystem>();
@@ -3746,11 +3748,11 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String
if (p_object->has_meta("_editor_icon"))
return p_object->get_meta("_editor_icon");
- if (gui_base->has_icon(p_object->get_class(), "EditorIcons"))
- return gui_base->get_icon(p_object->get_class(), "EditorIcons");
+ if (gui_base->has_theme_icon(p_object->get_class(), "EditorIcons"))
+ return gui_base->get_theme_icon(p_object->get_class(), "EditorIcons");
if (p_fallback.length())
- return gui_base->get_icon(p_fallback, "EditorIcons");
+ return gui_base->get_theme_icon(p_fallback, "EditorIcons");
return NULL;
}
@@ -3758,8 +3760,8 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String
Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const {
ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty.");
- if (gui_base->has_icon(p_class, "EditorIcons")) {
- return gui_base->get_icon(p_class, "EditorIcons");
+ if (gui_base->has_theme_icon(p_class, "EditorIcons")) {
+ return gui_base->get_theme_icon(p_class, "EditorIcons");
}
if (ScriptServer::is_global_class(p_class)) {
@@ -3782,7 +3784,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
}
if (icon.is_null()) {
- icon = gui_base->get_icon(ScriptServer::get_global_class_base(p_class), "EditorIcons");
+ icon = gui_base->get_theme_icon(ScriptServer::get_global_class_base(p_class), "EditorIcons");
}
return icon;
@@ -3800,8 +3802,8 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
}
}
- if (p_fallback.length() && gui_base->has_icon(p_fallback, "EditorIcons"))
- return gui_base->get_icon(p_fallback, "EditorIcons");
+ if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons"))
+ return gui_base->get_theme_icon(p_fallback, "EditorIcons");
return NULL;
}
@@ -3922,7 +3924,7 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) {
current_option = -1;
accept->get_ok()->set_text(p_title);
accept->set_text(p_text);
- accept->popup_centered_minsize();
+ accept->popup_centered();
}
void EditorNode::show_warning(const String &p_text, const String &p_title) {
@@ -3930,7 +3932,7 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) {
if (warning->is_inside_tree()) {
warning->set_text(p_text);
warning->set_title(p_title);
- warning->popup_centered_minsize();
+ warning->popup_centered();
} else {
WARN_PRINT(p_title + " " + p_text);
}
@@ -3938,7 +3940,78 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) {
void EditorNode::_copy_warning(const String &p_str) {
- OS::get_singleton()->set_clipboard(warning->get_text());
+ DisplayServer::get_singleton()->clipboard_set(warning->get_text());
+}
+
+void EditorNode::_dock_floating_close_request(Control *p_control) {
+ Window *window = (Window *)p_control->get_parent();
+ int window_slot = window->get_meta("dock_slot");
+
+ window->remove_child(p_control);
+ dock_slot[window_slot]->add_child(p_control);
+
+ window->queue_delete();
+
+ _update_dock_containers();
+
+ floating_docks.erase(p_control);
+}
+
+void EditorNode::_dock_make_float() {
+ Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
+ ERR_FAIL_COND(!dock);
+
+ Size2 dock_size = dock->get_size(); //remember size
+ Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position();
+
+ print_line("dock pos: " + dock->get_global_position() + " window pos: " + get_tree()->get_root()->get_position());
+ dock_slot[dock_popup_selected]->remove_child(dock);
+
+ Window *window = memnew(Window);
+ window->set_title(dock->get_name());
+ Panel *p = memnew(Panel);
+ p->set_mode(Panel::MODE_FOREGROUND);
+ p->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ window->add_child(p);
+ dock->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ window->add_child(dock);
+ window->set_wrap_controls(true);
+ window->set_size(dock_size);
+ window->set_position(dock_screen_pos);
+ window->set_transient(true);
+ window->connect("close_requested", callable_mp(this, &EditorNode::_dock_floating_close_request), varray(dock));
+ window->set_meta("dock_slot", dock_popup_selected);
+ gui_base->add_child(window);
+
+ dock_select_popup->hide();
+
+ _update_dock_containers();
+
+ floating_docks.push_back(dock);
+}
+
+void EditorNode::_update_dock_containers() {
+
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
+ if (dock_slot[i]->get_tab_count() == 0 && dock_slot[i]->is_visible()) {
+ dock_slot[i]->hide();
+ }
+ if (dock_slot[i]->get_tab_count() > 0 && !dock_slot[i]->is_visible()) {
+ dock_slot[i]->show();
+ }
+ }
+ for (int i = 0; i < vsplits.size(); i++) {
+ bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
+ if (in_use)
+ vsplits[i]->show();
+ else
+ vsplits[i]->hide();
+ }
+
+ if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible())
+ right_hsplit->show();
+ else
+ right_hsplit->hide();
}
void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
@@ -3986,18 +4059,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
dock_slot[nrect]->show();
dock_select->update();
- for (int i = 0; i < vsplits.size(); i++) {
- bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
- if (in_use)
- vsplits[i]->show();
- else
- vsplits[i]->hide();
- }
-
- if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible())
- right_hsplit->show();
- else
- right_hsplit->hide();
+ _update_dock_containers();
_edit_current();
_save_docks();
@@ -4051,7 +4113,7 @@ void EditorNode::_dock_select_draw() {
Color used = Color(0.6, 0.6, 0.6, 0.8);
Color used_selected = Color(0.8, 0.8, 0.8, 0.8);
- Color tab_selected = theme_base->get_color("mono_color", "Editor");
+ Color tab_selected = theme_base->get_theme_color("mono_color", "Editor");
Color unused = used;
unused.a = 0.4;
Color unusable = unused;
@@ -4454,7 +4516,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
current_option = -1;
pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
- pick_main_scene->popup_centered_minsize();
+ pick_main_scene->popup_centered();
return false;
}
@@ -4462,7 +4524,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
current_option = -1;
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
- pick_main_scene->popup_centered_minsize();
+ pick_main_scene->popup_centered();
return false;
}
@@ -4470,7 +4532,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
current_option = -1;
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
- pick_main_scene->popup_centered_minsize();
+ pick_main_scene->popup_centered();
return false;
}
@@ -4590,7 +4652,7 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) {
if (unsaved) {
save_confirmation->get_ok()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene"));
- save_confirmation->popup_centered_minsize();
+ save_confirmation->popup_centered();
} else {
_discard_changes();
}
@@ -4814,9 +4876,9 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
bottom_panel_items[i].control->set_visible(i == p_idx);
}
if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { // this is the debug panel which uses tabs, so the top section should be smaller
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
} else {
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer"));
}
center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
center_split->set_collapsed(false);
@@ -4826,7 +4888,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
bottom_panel_raise->show();
} else {
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer"));
bottom_panel_items[p_idx].button->set_pressed(false);
bottom_panel_items[p_idx].control->set_visible(false);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
@@ -4919,7 +4981,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) {
{
//todo make proper previews
- Ref<ImageTexture> pic = gui_base->get_icon("FileBigThumb", "EditorIcons");
+ Ref<ImageTexture> pic = gui_base->get_theme_icon("FileBigThumb", "EditorIcons");
Ref<Image> img = pic->get_data();
img = img->duplicate();
img->resize(48, 48); //meh
@@ -4971,10 +5033,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *
if (p_paths[i].ends_with("/")) {
label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file());
- icon->set_texture(gui_base->get_icon("Folder", "EditorIcons"));
+ icon->set_texture(gui_base->get_theme_icon("Folder", "EditorIcons"));
} else {
label->set_text(p_paths[i].get_file());
- icon->set_texture(gui_base->get_icon("File", "EditorIcons"));
+ icon->set_texture(gui_base->get_theme_icon("File", "EditorIcons"));
}
icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
icon->set_size(Size2(16, 16));
@@ -5042,21 +5104,19 @@ void EditorNode::remove_tool_menu_item(const String &p_name) {
}
}
-void EditorNode::_global_menu_action(const Variant &p_id, const Variant &p_meta) {
+void EditorNode::_global_menu_scene(const Variant &p_tag) {
+ int idx = (int)p_tag;
+ scene_tabs->set_current_tab(idx);
+}
- int id = (int)p_id;
- if (id == GLOBAL_NEW_WINDOW) {
- if (OS::get_singleton()->get_main_loop()) {
- List<String> args;
- args.push_back("-e");
- String exec = OS::get_singleton()->get_executable_path();
+void EditorNode::_global_menu_new_window(const Variant &p_tag) {
+ if (OS::get_singleton()->get_main_loop()) {
+ List<String> args;
+ args.push_back("-p");
+ String exec = OS::get_singleton()->get_executable_path();
- OS::ProcessID pid = 0;
- OS::get_singleton()->execute(exec, args, false, &pid);
- }
- } else if (id == GLOBAL_SCENE) {
- int idx = (int)p_meta;
- scene_tabs->set_current_tab(idx);
+ OS::ProcessID pid = 0;
+ OS::get_singleton()->execute(exec, args, false, &pid);
}
}
@@ -5277,9 +5337,9 @@ void EditorNode::_update_video_driver_color() {
// TODO: Probably should de-hardcode this and add to editor settings.
if (video_driver->get_text() == "GLES2") {
- video_driver->add_color_override("font_color", Color::hex(0x5586a4ff));
+ video_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
} else if (video_driver->get_text() == "Vulkan") {
- video_driver->add_color_override("font_color", theme_base->get_color("vulkan_color", "Editor"));
+ video_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor"));
}
}
@@ -5287,14 +5347,14 @@ void EditorNode::_video_driver_selected(int p_which) {
String driver = video_driver->get_item_metadata(p_which);
- String current = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
+ String current = ""; //OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
if (driver == current) {
return;
}
video_driver_request = driver;
- video_restart_dialog->popup_centered_minsize();
+ video_restart_dialog->popup_centered();
video_driver->select(video_driver_current);
_update_video_driver_color();
}
@@ -5376,6 +5436,7 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes);
ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);
+
ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource);
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
@@ -5466,15 +5527,15 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p
EditorNode::EditorNode() {
- Input::get_singleton()->set_use_accumulated_input(true);
+ InputFilter::get_singleton()->set_use_accumulated_input(true);
Resource::_get_local_scene_func = _resource_get_edited_scene;
- VisualServer::get_singleton()->set_debug_generate_wireframes(true);
+ RenderingServer::get_singleton()->set_debug_generate_wireframes(true);
- NavigationServer::get_singleton()->set_active(false); // no nav by default if editor
+ NavigationServer3D::get_singleton()->set_active(false); // no nav by default if editor
- PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor
- Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor
+ PhysicsServer3D::get_singleton()->set_active(false); // no physics by default if editor
+ PhysicsServer2D::get_singleton()->set_active(false); // no physics by default if editor
ScriptServer::set_scripting_enabled(false); // no scripting by default if editor
EditorHelp::generate_doc(); //before any editor classes are created
@@ -5482,15 +5543,22 @@ EditorNode::EditorNode() {
ResourceLoader::clear_translation_remaps(); //no remaps using during editor
ResourceLoader::clear_path_remaps();
- InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
+ InputFilter *id = InputFilter::get_singleton();
if (id) {
- if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) {
+ bool found_touchscreen = false;
+ for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
+ if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) {
+ found_touchscreen = true;
+ }
+ }
+
+ if (!found_touchscreen && InputFilter::get_singleton()) {
//only if no touchscreen ui hint, set emulation
id->set_emulate_touch_from_mouse(false); //just disable just in case
}
- id->set_custom_mouse_cursor(RES());
+ DisplayServer::get_singleton()->cursor_set_custom_image(RES());
}
singleton = this;
@@ -5519,8 +5587,12 @@ EditorNode::EditorNode() {
switch (display_scale) {
case 0: {
// Try applying a suitable display scale automatically
- const int screen = OS::get_singleton()->get_current_screen();
- editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
+ const int screen = DisplayServer::get_singleton()->window_get_current_screen();
+#ifdef OSX_ENABLED
+ editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen));
+#else
+ editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0);
+#endif
} break;
case 1: {
@@ -5554,7 +5626,7 @@ EditorNode::EditorNode() {
}
// Define a minimum window size to prevent UI elements from overlapping or being cut off
- OS::get_singleton()->set_min_window_size(Size2(1024, 600) * EDSCALE);
+ DisplayServer::get_singleton()->window_set_min_size(Size2(1024, 600) * EDSCALE);
ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
@@ -5713,7 +5785,7 @@ EditorNode::EditorNode() {
theme_base->set_theme(theme);
gui_base->set_theme(theme);
- gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
+ gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles"));
resource_preview = memnew(EditorResourcePreview);
add_child(resource_preview);
@@ -5728,7 +5800,7 @@ EditorNode::EditorNode() {
main_vbox = memnew(VBoxContainer);
gui_base->add_child(main_vbox);
main_vbox->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8);
- main_vbox->add_constant_override("separation", 8 * EDSCALE);
+ main_vbox->add_theme_constant_override("separation", 8 * EDSCALE);
menu_hb = memnew(HBoxContainer);
main_vbox->add_child(menu_hb);
@@ -5832,6 +5904,14 @@ EditorNode::EditorNode() {
dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_vb->add_child(dock_select);
+ dock_float = memnew(Button);
+ dock_float->set_text("Make Floating");
+ dock_float->set_focus_mode(Control::FOCUS_NONE);
+ dock_float->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
+ dock_float->connect("pressed", callable_mp(this, &EditorNode::_dock_make_float));
+
+ dock_vb->add_child(dock_float);
+
dock_select_popup->set_as_minsize();
dock_select_rect_over = -1;
dock_popup_selected = -1;
@@ -5861,7 +5941,7 @@ EditorNode::EditorNode() {
VBoxContainer *srt = memnew(VBoxContainer);
srt->set_v_size_flags(Control::SIZE_EXPAND_FILL);
top_split->add_child(srt);
- srt->add_constant_override("separation", 0);
+ srt->add_theme_constant_override("separation", 0);
tab_preview_panel = memnew(Panel);
tab_preview_panel->set_size(Size2(100, 100) * EDSCALE);
@@ -5876,8 +5956,8 @@ EditorNode::EditorNode() {
tab_preview_panel->add_child(tab_preview);
scene_tabs = memnew(Tabs);
- scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
- scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
+ scene_tabs->add_theme_style_override("tab_fg", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles"));
+ scene_tabs->add_theme_style_override("tab_bg", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles"));
scene_tabs->set_select_with_rmb(true);
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_LEFT);
@@ -5899,7 +5979,6 @@ EditorNode::EditorNode() {
scene_tabs_context_menu = memnew(PopupMenu);
tabbar_container->add_child(scene_tabs_context_menu);
scene_tabs_context_menu->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option));
- scene_tabs_context_menu->set_hide_on_window_lose_focus(true);
srt->add_child(tabbar_container);
tabbar_container->add_child(scene_tabs);
@@ -5911,34 +5990,34 @@ EditorNode::EditorNode() {
#endif
distraction_free->set_tooltip(TTR("Toggle distraction-free mode."));
distraction_free->connect("pressed", callable_mp(this, &EditorNode::_toggle_distraction_free_mode));
- distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons"));
+ distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons"));
distraction_free->set_toggle_mode(true);
scene_tab_add = memnew(ToolButton);
tabbar_container->add_child(scene_tab_add);
tabbar_container->add_child(distraction_free);
scene_tab_add->set_tooltip(TTR("Add a new scene."));
- scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons"));
- scene_tab_add->add_color_override("icon_color_normal", Color(0.6f, 0.6f, 0.6f, 0.8f));
+ scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons"));
+ scene_tab_add->add_theme_color_override("icon_color_normal", Color(0.6f, 0.6f, 0.6f, 0.8f));
scene_tab_add->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_NEW_SCENE));
scene_root_parent = memnew(PanelContainer);
scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
- scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles"));
scene_root_parent->set_draw_behind_parent(true);
srt->add_child(scene_root_parent);
scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- scene_root = memnew(Viewport);
+ scene_root = memnew(SubViewport);
//scene_root->set_usage(Viewport::USAGE_2D); canvas BG mode prevents usage of this as 2D
- VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
+ RenderingServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true);
viewport = memnew(VBoxContainer);
viewport->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- viewport->add_constant_override("separation", 0);
+ viewport->add_theme_constant_override("separation", 0);
scene_root_parent->add_child(viewport);
HBoxContainer *left_menu_hb = memnew(HBoxContainer);
@@ -5948,11 +6027,11 @@ EditorNode::EditorNode() {
file_menu->set_flat(false);
file_menu->set_switch_on_hover(true);
file_menu->set_text(TTR("Scene"));
- file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
left_menu_hb->add_child(file_menu);
prev_scene = memnew(ToolButton);
- prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons"));
+ prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons"));
prev_scene->set_tooltip(TTR("Go to previously opened scene."));
prev_scene->set_disabled(true);
prev_scene->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_OPEN_PREV));
@@ -6004,7 +6083,7 @@ EditorNode::EditorNode() {
file_menu->set_tooltip(TTR("Operations with scene files."));
p = file_menu->get_popup();
- p->set_hide_on_window_lose_focus(true);
+
p->add_shortcut(ED_SHORTCUT("editor/new_scene", TTR("New Scene")), FILE_NEW_SCENE);
p->add_shortcut(ED_SHORTCUT("editor/new_inherited_scene", TTR("New Inherited Scene...")), FILE_NEW_INHERITED_SCENE);
p->add_shortcut(ED_SHORTCUT("editor/open_scene", TTR("Open Scene..."), KEY_MASK_CMD + KEY_O), FILE_OPEN_SCENE);
@@ -6052,11 +6131,11 @@ EditorNode::EditorNode() {
project_menu->set_switch_on_hover(true);
project_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools."));
project_menu->set_text(TTR("Project"));
- project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
left_menu_hb->add_child(project_menu);
p = project_menu->get_popup();
- p->set_hide_on_window_lose_focus(true);
+
p->add_shortcut(ED_SHORTCUT("editor/project_settings", TTR("Project Settings...")), RUN_SETTINGS);
p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option));
@@ -6102,19 +6181,20 @@ EditorNode::EditorNode() {
debug_menu->set_flat(false);
debug_menu->set_switch_on_hover(true);
debug_menu->set_text(TTR("Debug"));
- debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
left_menu_hb->add_child(debug_menu);
+
menu_hb->add_spacer();
settings_menu = memnew(MenuButton);
settings_menu->set_flat(false);
settings_menu->set_switch_on_hover(true);
settings_menu->set_text(TTR("Editor"));
- settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
left_menu_hb->add_child(settings_menu);
p = settings_menu->get_popup();
- p->set_hide_on_window_lose_focus(true);
+
p->add_shortcut(ED_SHORTCUT("editor/editor_settings", TTR("Editor Settings...")), SETTINGS_PREFERENCES);
p->add_separator();
@@ -6158,20 +6238,19 @@ EditorNode::EditorNode() {
help_menu->set_flat(false);
help_menu->set_switch_on_hover(true);
help_menu->set_text(TTR("Help"));
- help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles"));
left_menu_hb->add_child(help_menu);
p = help_menu->get_popup();
- p->set_hide_on_window_lose_focus(true);
p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option));
- p->add_icon_shortcut(gui_base->get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search"), KEY_MASK_SHIFT | KEY_F1), HELP_SEARCH);
+ p->add_icon_shortcut(gui_base->get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search"), KEY_MASK_SHIFT | KEY_F1), HELP_SEARCH);
p->add_separator();
- p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Docs")), HELP_DOCS);
- p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Q&A")), HELP_QA);
- p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/issue_tracker", TTR("Issue Tracker")), HELP_ISSUES);
- p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY);
+ p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Docs")), HELP_DOCS);
+ p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Q&A")), HELP_QA);
+ p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/issue_tracker", TTR("Issue Tracker")), HELP_ISSUES);
+ p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY);
p->add_separator();
- p->add_icon_shortcut(gui_base->get_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About")), HELP_ABOUT);
+ p->add_icon_shortcut(gui_base->get_theme_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About")), HELP_ABOUT);
HBoxContainer *play_hb = memnew(HBoxContainer);
menu_hb->add_child(play_hb);
@@ -6179,7 +6258,7 @@ EditorNode::EditorNode() {
play_button = memnew(ToolButton);
play_hb->add_child(play_button);
play_button->set_toggle_mode(true);
- play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
+ play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons"));
play_button->set_focus_mode(Control::FOCUS_NONE);
play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY));
play_button->set_tooltip(TTR("Play the project."));
@@ -6191,7 +6270,7 @@ EditorNode::EditorNode() {
pause_button = memnew(ToolButton);
pause_button->set_toggle_mode(true);
- pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons"));
+ pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons"));
pause_button->set_focus_mode(Control::FOCUS_NONE);
pause_button->set_tooltip(TTR("Pause the scene execution for debugging."));
pause_button->set_disabled(true);
@@ -6205,7 +6284,7 @@ EditorNode::EditorNode() {
stop_button = memnew(ToolButton);
play_hb->add_child(stop_button);
stop_button->set_focus_mode(Control::FOCUS_NONE);
- stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons"));
+ stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons"));
stop_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_STOP));
stop_button->set_tooltip(TTR("Stop the scene."));
stop_button->set_disabled(true);
@@ -6223,7 +6302,7 @@ EditorNode::EditorNode() {
play_hb->add_child(play_scene_button);
play_scene_button->set_toggle_mode(true);
play_scene_button->set_focus_mode(Control::FOCUS_NONE);
- play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons"));
play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_SCENE));
play_scene_button->set_tooltip(TTR("Play the edited scene."));
#ifdef OSX_ENABLED
@@ -6236,7 +6315,7 @@ EditorNode::EditorNode() {
play_hb->add_child(play_custom_scene_button);
play_custom_scene_button->set_toggle_mode(true);
play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE);
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons"));
play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_CUSTOM_SCENE));
play_custom_scene_button->set_tooltip(TTR("Play custom scene"));
#ifdef OSX_ENABLED
@@ -6253,11 +6332,15 @@ EditorNode::EditorNode() {
video_driver->set_flat(true);
video_driver->set_focus_mode(Control::FOCUS_NONE);
video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected));
- video_driver->add_font_override("font", gui_base->get_font("bold", "EditorFonts"));
+ video_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts"));
// TODO re-enable when GLES2 is ported
video_driver->set_disabled(true);
right_menu_hb->add_child(video_driver);
+#ifndef _MSC_VER
+#warning neeeds to be reimplemented
+#endif
+#if 0
String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/quality/driver/driver_name"].hint_string;
String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
video_driver_current = 0;
@@ -6273,7 +6356,7 @@ EditorNode::EditorNode() {
}
_update_video_driver_color();
-
+#endif
video_restart_dialog = memnew(ConfirmationDialog);
video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor."));
video_restart_dialog->get_ok()->set_text(TTR("Save & Restart"));
@@ -6291,7 +6374,7 @@ EditorNode::EditorNode() {
update_spinner = memnew(MenuButton);
update_spinner->set_tooltip(TTR("Spins when the editor window redraws."));
right_menu_hb->add_child(update_spinner);
- update_spinner->set_icon(gui_base->get_icon("Progress1", "EditorIcons"));
+ update_spinner->set_icon(gui_base->get_theme_icon("Progress1", "EditorIcons"));
update_spinner->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option));
p = update_spinner->get_popup();
p->add_radio_check_item(TTR("Update Continuously"), SETTINGS_UPDATE_CONTINUOUSLY);
@@ -6367,7 +6450,7 @@ EditorNode::EditorNode() {
// Bottom panels
bottom_panel = memnew(PanelContainer);
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer"));
center_split->add_child(bottom_panel);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
@@ -6389,7 +6472,7 @@ EditorNode::EditorNode() {
bottom_panel_hb->add_child(version_label);
bottom_panel_raise = memnew(ToolButton);
- bottom_panel_raise->set_icon(gui_base->get_icon("ExpandBottomDock", "EditorIcons"));
+ bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons"));
bottom_panel_raise->set_shortcut(ED_SHORTCUT("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KEY_MASK_SHIFT | KEY_F12));
@@ -6414,7 +6497,7 @@ EditorNode::EditorNode() {
confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
save_confirmation = memnew(ConfirmationDialog);
- save_confirmation->add_button(TTR("Don't Save"), OS::get_singleton()->get_swap_ok_cancel(), "discard");
+ save_confirmation->add_button(TTR("Don't Save"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "discard");
gui_base->add_child(save_confirmation);
save_confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
save_confirmation->connect("custom_action", callable_mp(this, &EditorNode::_discard_changes));
@@ -6441,7 +6524,7 @@ EditorNode::EditorNode() {
file_templates->set_title(TTR("Import Templates From ZIP File"));
gui_base->add_child(file_templates);
- file_templates->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_templates->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_templates->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_templates->clear_filters();
file_templates->add_filter("*.tpz ; " + TTR("Template Package"));
@@ -6452,7 +6535,7 @@ EditorNode::EditorNode() {
file_export_lib = memnew(EditorFileDialog);
file_export_lib->set_title(TTR("Export Library"));
- file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_export_lib->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_export_lib->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action));
file_export_lib_merge = memnew(CheckBox);
file_export_lib_merge->set_text(TTR("Merge With Existing"));
@@ -6463,7 +6546,7 @@ EditorNode::EditorNode() {
file_script = memnew(EditorFileDialog);
file_script->set_title(TTR("Open & Run a Script"));
file_script->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- file_script->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> sexts;
ResourceLoader::get_recognized_extensions_for_type("Script", &sexts);
for (List<String>::Element *E = sexts.front(); E; E = E->next()) {
@@ -6473,7 +6556,7 @@ EditorNode::EditorNode() {
file_script->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action));
file_menu->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option));
- file_menu->connect("about_to_show", callable_mp(this, &EditorNode::_update_file_menu_opened));
+ file_menu->connect("about_to_popup", callable_mp(this, &EditorNode::_update_file_menu_opened));
file_menu->get_popup()->connect("popup_hide", callable_mp(this, &EditorNode::_update_file_menu_closed));
settings_menu->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option));
@@ -6488,7 +6571,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(DebuggerEditorPlugin(this, debug_menu)));
add_editor_plugin(memnew(AnimationPlayerEditorPlugin(this)));
add_editor_plugin(memnew(CanvasItemEditorPlugin(this)));
- add_editor_plugin(memnew(SpatialEditorPlugin(this)));
+ add_editor_plugin(memnew(Node3DEditorPlugin(this)));
add_editor_plugin(memnew(ScriptEditorPlugin(this)));
EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor();
@@ -6514,18 +6597,19 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(ShaderEditorPlugin(this)));
add_editor_plugin(memnew(VisualShaderEditorPlugin(this)));
- add_editor_plugin(memnew(CameraEditorPlugin(this)));
+ add_editor_plugin(memnew(Camera3DEditorPlugin(this)));
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
- add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
+ add_editor_plugin(memnew(MeshInstance3DEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
add_editor_plugin(memnew(MeshLibraryEditorPlugin(this)));
add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
- add_editor_plugin(memnew(SpriteEditorPlugin(this)));
+ add_editor_plugin(memnew(Sprite2DEditorPlugin(this)));
add_editor_plugin(memnew(Skeleton2DEditorPlugin(this)));
- add_editor_plugin(memnew(ParticlesEditorPlugin(this)));
+ add_editor_plugin(memnew(GPUParticles2DEditorPlugin(this)));
+ add_editor_plugin(memnew(GPUParticles3DEditorPlugin(this)));
add_editor_plugin(memnew(CPUParticles2DEditorPlugin(this)));
- add_editor_plugin(memnew(CPUParticlesEditorPlugin(this)));
+ add_editor_plugin(memnew(CPUParticles3DEditorPlugin(this)));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this)));
add_editor_plugin(memnew(ItemListEditorPlugin(this)));
add_editor_plugin(memnew(Polygon3DEditorPlugin(this)));
@@ -6534,11 +6618,10 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TileMapEditorPlugin(this)));
add_editor_plugin(memnew(SpriteFramesEditorPlugin(this)));
add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
- add_editor_plugin(memnew(Particles2DEditorPlugin(this)));
add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
- // add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
+ //add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this)));
- add_editor_plugin(memnew(PathEditorPlugin(this)));
+ add_editor_plugin(memnew(Path3DEditorPlugin(this)));
add_editor_plugin(memnew(Line2DEditorPlugin(this)));
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
@@ -6549,9 +6632,9 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TextureEditorPlugin(this)));
add_editor_plugin(memnew(AudioStreamEditorPlugin(this)));
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
- add_editor_plugin(memnew(SkeletonEditorPlugin(this)));
- add_editor_plugin(memnew(SkeletonIKEditorPlugin(this)));
- add_editor_plugin(memnew(PhysicalBonePlugin(this)));
+ add_editor_plugin(memnew(Skeleton3DEditorPlugin(this)));
+ add_editor_plugin(memnew(SkeletonIK3DEditorPlugin(this)));
+ add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this)));
add_editor_plugin(memnew(MeshEditorPlugin(this)));
add_editor_plugin(memnew(MaterialEditorPlugin(this)));
@@ -6625,7 +6708,7 @@ EditorNode::EditorNode() {
open_imported = memnew(ConfirmationDialog);
open_imported->get_ok()->set_text(TTR("Open Anyway"));
- new_inherited_button = open_imported->add_button(TTR("New Inherited"), !OS::get_singleton()->get_swap_ok_cancel(), "inherit");
+ new_inherited_button = open_imported->add_button(TTR("New Inherited"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "inherit");
open_imported->connect("confirmed", callable_mp(this, &EditorNode::_open_imported));
open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported));
gui_base->add_child(open_imported);
@@ -6768,7 +6851,7 @@ bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) {
return discard;
}
-bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
+bool EditorPluginList::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool discard = false;
for (int i = 0; i < plugins_list.size(); i++) {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index bd285db224..9d251690d2 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -84,6 +84,8 @@ class Tabs;
class TextureProgress;
class ToolButton;
class VSplitContainer;
+class Window;
+class SubViewport;
class EditorNode : public Node {
@@ -206,7 +208,7 @@ private:
TOOL_MENU_BASE = 1000
};
- Viewport *scene_root; //root of the scene being edited
+ SubViewport *scene_root; //root of the scene being edited
PanelContainer *scene_root_parent;
Control *theme_base;
@@ -348,11 +350,14 @@ private:
Button *new_inherited_button;
String open_import_request;
+ Vector<Control *> floating_docks;
+
TabContainer *dock_slot[DOCK_SLOT_MAX];
Rect2 dock_select_rect[DOCK_SLOT_MAX];
int dock_select_rect_over;
PopupPanel *dock_select_popup;
Control *dock_select;
+ Button *dock_float;
ToolButton *dock_tab_move_left;
ToolButton *dock_tab_move_right;
int dock_popup_selected;
@@ -493,7 +498,8 @@ private:
void _add_to_recent_scenes(const String &p_scene);
void _update_recent_scenes();
void _open_recent_scene(int p_idx);
- void _global_menu_action(const Variant &p_id, const Variant &p_meta);
+ void _global_menu_scene(const Variant &p_tag);
+ void _global_menu_new_window(const Variant &p_tag);
void _dropped_files(const Vector<String> &p_files, int p_screen);
void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
String _recent_scene;
@@ -560,6 +566,8 @@ private:
bool _find_scene_in_use(Node *p_node, const String &p_path) const;
+ void _update_dock_containers();
+
void _dock_select_input(const Ref<InputEvent> &p_input);
void _dock_move_left();
void _dock_move_right();
@@ -567,6 +575,8 @@ private:
void _dock_pre_popup(int p_which);
void _dock_split_dragged(int ofs);
void _dock_popup_exit();
+ void _dock_floating_close_request(Control *p_control);
+ void _dock_make_float();
void _scene_tab_changed(int p_tab);
void _scene_tab_closed(int p_tab, int option = SCENE_TAB_CLOSE);
void _scene_tab_hover(int p_tab);
@@ -724,7 +734,7 @@ public:
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
- Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
+ SubViewport *get_scene_root() { return scene_root; } //root of the scene being edited
void fix_dependencies(const String &p_for_file);
void clear_scene() { _cleanup_scene(); }
@@ -884,7 +894,7 @@ public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
- bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
+ bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_spatial_draw_over_viewport(Control *p_overlay);
void forward_spatial_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin);
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index 305dc03568..804ad62bbb 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -149,6 +149,6 @@ EditorPath::EditorPath(EditorHistory *p_history) {
history = p_history;
set_clip_text(true);
set_text_align(ALIGN_LEFT);
- get_popup()->connect("about_to_show", callable_mp(this, &EditorPath::_about_to_show));
+ get_popup()->connect("about_to_popup", callable_mp(this, &EditorPath::_about_to_show));
get_popup()->connect("id_pressed", callable_mp(this, &EditorPath::_id_pressed));
}
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 07a63c39ba..8faaabc1fb 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -38,10 +38,10 @@
#include "editor_resource_preview.h"
#include "main/main.h"
#include "plugins/canvas_item_editor_plugin.h"
-#include "plugins/spatial_editor_plugin.h"
-#include "scene/3d/camera.h"
+#include "plugins/node_3d_editor_plugin.h"
+#include "scene/3d/camera_3d.h"
#include "scene/gui/popup_menu.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) {
@@ -64,25 +64,25 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
int size = p_preview_size;
- RID scenario = VS::get_singleton()->scenario_create();
+ RID scenario = RS::get_singleton()->scenario_create();
- RID viewport = VS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ALWAYS);
- VS::get_singleton()->viewport_set_scenario(viewport, scenario);
- VS::get_singleton()->viewport_set_size(viewport, size, size);
- VS::get_singleton()->viewport_set_transparent_background(viewport, true);
- VS::get_singleton()->viewport_set_active(viewport, true);
- RID viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
+ RID viewport = RS::get_singleton()->viewport_create();
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS);
+ RS::get_singleton()->viewport_set_scenario(viewport, scenario);
+ RS::get_singleton()->viewport_set_size(viewport, size, size);
+ RS::get_singleton()->viewport_set_transparent_background(viewport, true);
+ RS::get_singleton()->viewport_set_active(viewport, true);
+ RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
- RID camera = VS::get_singleton()->camera_create();
- VS::get_singleton()->viewport_attach_camera(viewport, camera);
+ RID camera = RS::get_singleton()->camera_create();
+ RS::get_singleton()->viewport_attach_camera(viewport, camera);
- RID light = VS::get_singleton()->directional_light_create();
- RID light_instance = VS::get_singleton()->instance_create2(light, scenario);
+ RID light = RS::get_singleton()->directional_light_create();
+ RID light_instance = RS::get_singleton()->instance_create2(light, scenario);
- RID light2 = VS::get_singleton()->directional_light_create();
- VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
- RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
+ RID light2 = RS::get_singleton()->directional_light_create();
+ RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
+ RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
@@ -101,8 +101,8 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
mesh_xform = (*p_transforms)[i];
}
- RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
- VS::get_singleton()->instance_set_transform(inst, mesh_xform);
+ RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
+ RS::get_singleton()->instance_set_transform(inst, mesh_xform);
AABB aabb = mesh->get_aabb();
Vector3 ofs = aabb.position + aabb.size * 0.5;
@@ -121,32 +121,32 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
xform.invert();
xform = mesh_xform * xform;
- VS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3)));
- VS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
+ RS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3)));
+ RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
- VS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
- VS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
+ RS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
+ RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
ep.step(TTR("Thumbnail..."), i);
Main::iteration();
Main::iteration();
- Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
+ Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
ERR_CONTINUE(!img.is_valid() || img->empty());
Ref<ImageTexture> it(memnew(ImageTexture));
it->create_from_image(img);
- VS::get_singleton()->free(inst);
+ RS::get_singleton()->free(inst);
textures.push_back(it);
}
- VS::get_singleton()->free(viewport);
- VS::get_singleton()->free(light);
- VS::get_singleton()->free(light_instance);
- VS::get_singleton()->free(light2);
- VS::get_singleton()->free(light_instance2);
- VS::get_singleton()->free(camera);
- VS::get_singleton()->free(scenario);
+ RS::get_singleton()->free(viewport);
+ RS::get_singleton()->free(light);
+ RS::get_singleton()->free(light_instance);
+ RS::get_singleton()->free(light2);
+ RS::get_singleton()->free(light_instance2);
+ RS::get_singleton()->free(camera);
+ RS::get_singleton()->free(scenario);
return textures;
}
@@ -371,24 +371,24 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C
case CONTAINER_SPATIAL_EDITOR_MENU: {
- SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
- SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
- SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
+ Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control);
+ Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
- SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
- SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
+ Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control);
+ Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
- SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control);
+ Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
@@ -445,18 +445,18 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati
case CONTAINER_SPATIAL_EDITOR_MENU: {
- SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control);
+ Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT:
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
- SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control);
+ Node3DEditor::get_singleton()->get_palette_split()->remove_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
- SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control);
+ Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
@@ -562,10 +562,10 @@ void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
// Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
int EditorPlugin::update_overlays() const {
- if (SpatialEditor::get_singleton()->is_visible()) {
+ if (Node3DEditor::get_singleton()->is_visible()) {
int count = 0;
- for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
- SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i);
+ for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
+ Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i);
if (vp->is_visible()) {
vp->update_surface();
count++;
@@ -579,7 +579,7 @@ int EditorPlugin::update_overlays() const {
}
}
-bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
@@ -724,12 +724,12 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
}
-void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) {
- SpatialEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
+void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
+ Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
}
-void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) {
- SpatialEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
+void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
+ Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
}
void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
@@ -865,7 +865,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "get_plugin_icon"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen"));
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index cd3f4d0638..12b042d0e5 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -42,14 +42,14 @@
#include "scene/resources/texture.h"
class EditorNode;
-class Spatial;
-class Camera;
+class Node3D;
+class Camera3D;
class EditorSelection;
class EditorExport;
class EditorSettings;
class EditorImportPlugin;
class EditorExportPlugin;
-class EditorSpatialGizmoPlugin;
+class EditorNode3DGizmoPlugin;
class EditorResourcePreview;
class EditorFileSystem;
class EditorToolAddons;
@@ -185,7 +185,7 @@ public:
virtual void forward_canvas_draw_over_viewport(Control *p_overlay);
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay);
- virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
+ virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
virtual void forward_spatial_draw_over_viewport(Control *p_overlay);
virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
@@ -227,8 +227,8 @@ public:
void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
- void add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin);
- void remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin);
+ void add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
+ void remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 33877f86c2..62a76786ae 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -40,7 +40,7 @@
void EditorPluginSettings::_notification(int p_what) {
- if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == NOTIFICATION_WM_FOCUS_IN) {
update_plugins();
} else if (p_what == Node::NOTIFICATION_READY) {
plugin_config_dialog->connect_compat("plugin_ready", EditorNode::get_singleton(), "_on_plugin_ready");
@@ -142,7 +142,7 @@ void EditorPluginSettings::update_plugins() {
bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(d2);
item->set_checked(3, is_active);
item->set_editable(3, true);
- item->add_button(4, get_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin"));
+ item->add_button(4, get_theme_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin"));
}
}
}
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 9a474ed4af..af83e808fc 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -35,7 +35,7 @@
#include "editor_node.h"
#include "editor_properties_array_dict.h"
#include "editor_scale.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
///////////////////// NULL /////////////////////////
@@ -140,9 +140,9 @@ void EditorPropertyMultilineText::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
- Ref<Texture2D> df = get_icon("DistractionFree", "EditorIcons");
+ Ref<Texture2D> df = get_theme_icon("DistractionFree", "EditorIcons");
open_big_text->set_icon(df);
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
text->set_custom_minimum_size(Vector2(0, font->get_height() * 6));
} break;
@@ -240,10 +240,10 @@ void EditorPropertyPath::_path_pressed() {
}
if (folder) {
- dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
dialog->set_current_dir(full_path);
} else {
- dialog->set_mode(save_mode ? EditorFileDialog::MODE_SAVE_FILE : EditorFileDialog::MODE_OPEN_FILE);
+ dialog->set_file_mode(save_mode ? EditorFileDialog::FILE_MODE_SAVE_FILE : EditorFileDialog::FILE_MODE_OPEN_FILE);
for (int i = 0; i < extensions.size(); i++) {
String e = extensions[i].strip_edges();
if (e != String()) {
@@ -278,7 +278,7 @@ void EditorPropertyPath::set_save_mode() {
void EditorPropertyPath::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- path_edit->set_icon(get_icon("Folder", "EditorIcons"));
+ path_edit->set_icon(get_theme_icon("Folder", "EditorIcons"));
}
}
@@ -604,7 +604,7 @@ public:
Vector<String> tooltips;
virtual Size2 get_minimum_size() const {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
return Vector2(0, font->get_height() * 2);
}
@@ -646,7 +646,7 @@ public:
int h = bsize * 2 + 1;
int vofs = (rect.size.height - h) / 2;
- Color color = get_color("highlight_color", "Editor");
+ Color color = get_theme_color("highlight_color", "Editor");
for (int i = 0; i < 2; i++) {
Point2 ofs(4, vofs);
@@ -749,10 +749,10 @@ void EditorPropertyLayers::_button_pressed() {
layers->set_item_checked(idx, grid->value & (1 << i));
}
- Rect2 gp = button->get_global_rect();
+ Rect2 gp = button->get_screen_rect();
layers->set_as_minsize();
- Vector2 popup_pos = gp.position - Vector2(layers->get_combined_minimum_size().x, 0);
- layers->set_global_position(popup_pos);
+ Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0);
+ layers->set_position(popup_pos);
layers->popup();
}
@@ -920,7 +920,7 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
}
if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
- preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
+ preset->set_position(easing_draw->get_screen_transform().xform(mb->get_position()));
preset->popup();
// Ensure the easing doesn't appear as being dragged
@@ -976,13 +976,13 @@ void EditorPropertyEasing::_draw_easing() {
float prev = 1.0;
const float exp = get_edited_object()->get(get_edited_property());
- const Ref<Font> f = get_font("font", "Label");
- const Color font_color = get_color("font_color", "Label");
+ const Ref<Font> f = get_theme_font("font", "Label");
+ const Color font_color = get_theme_color("font_color", "Label");
Color line_color;
if (dragging) {
- line_color = get_color("accent_color", "Editor");
+ line_color = get_theme_color("accent_color", "Editor");
} else {
- line_color = get_color("font_color", "Label") * Color(1, 1, 1, 0.9);
+ line_color = get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.9);
}
Vector<Point2> lines;
@@ -1058,15 +1058,15 @@ void EditorPropertyEasing::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
preset->clear();
- preset->add_icon_item(get_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO);
- preset->add_icon_item(get_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR);
- preset->add_icon_item(get_icon("CurveIn", "EditorIcons"), "In", EASING_IN);
- preset->add_icon_item(get_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT);
+ preset->add_icon_item(get_theme_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO);
+ preset->add_icon_item(get_theme_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR);
+ preset->add_icon_item(get_theme_icon("CurveIn", "EditorIcons"), "In", EASING_IN);
+ preset->add_icon_item(get_theme_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT);
if (full) {
- preset->add_icon_item(get_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT);
- preset->add_icon_item(get_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN);
+ preset->add_icon_item(get_theme_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT);
+ preset->add_icon_item(get_theme_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN);
}
- easing_draw->set_custom_minimum_size(Size2(0, get_font("font", "Label")->get_height() * 2));
+ easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height() * 2));
} break;
}
}
@@ -1126,7 +1126,7 @@ void EditorPropertyVector2::update_property() {
void EditorPropertyVector2::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 2; i++) {
Color c = base;
@@ -1208,7 +1208,7 @@ void EditorPropertyRect2::update_property() {
}
void EditorPropertyRect2::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 4; i++) {
Color c = base;
@@ -1288,7 +1288,7 @@ void EditorPropertyVector3::update_property() {
}
void EditorPropertyVector3::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
Color c = base;
@@ -1368,7 +1368,7 @@ void EditorPropertyPlane::update_property() {
}
void EditorPropertyPlane::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
Color c = base;
@@ -1450,7 +1450,7 @@ void EditorPropertyQuat::update_property() {
}
void EditorPropertyQuat::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
Color c = base;
@@ -1537,7 +1537,7 @@ void EditorPropertyAABB::update_property() {
}
void EditorPropertyAABB::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 6; i++) {
Color c = base;
@@ -1611,7 +1611,7 @@ void EditorPropertyTransform2D::update_property() {
}
void EditorPropertyTransform2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 6; i++) {
Color c = base;
@@ -1690,7 +1690,7 @@ void EditorPropertyBasis::update_property() {
}
void EditorPropertyBasis::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 9; i++) {
Color c = base;
@@ -1775,7 +1775,7 @@ void EditorPropertyTransform::update_property() {
}
void EditorPropertyTransform::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Color base = get_color("accent_color", "Editor");
+ Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 12; i++) {
Color c = base;
@@ -1983,7 +1983,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam
void EditorPropertyNodePath::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_icon("Clear", "EditorIcons");
+ Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons");
clear->set_icon(t);
}
}
@@ -2074,7 +2074,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
file->connect("file_selected", callable_mp(this, &EditorPropertyResource::_file_selected));
add_child(file);
}
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
String type = base_type;
List<String> extensions;
@@ -2294,7 +2294,7 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T
}
if (p_preview.is_valid()) {
- preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_constant("hseparation", "Button"));
+ preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_theme_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_theme_constant("hseparation", "Button"));
if (type == "GradientTexture") {
preview->set_stretch_mode(TextureRect::STRETCH_SCALE);
assign->set_custom_minimum_size(Size2(1, 1));
@@ -2318,8 +2318,8 @@ void EditorPropertyResource::_update_menu_items() {
menu->clear();
if (get_edited_property() == "script" && base_type == "Script" && Object::cast_to<Node>(get_edited_object())) {
- menu->add_icon_item(get_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
- menu->add_icon_item(get_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
+ menu->add_icon_item(get_theme_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_icon_item(get_theme_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT);
menu->add_separator();
} else if (base_type != "") {
int idx = 0;
@@ -2381,7 +2381,7 @@ void EditorPropertyResource::_update_menu_items() {
inheritors_array.push_back(t);
if (!icon.is_valid())
- icon = get_icon(has_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
+ icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
int id = TYPE_BASE_ID + idx;
menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
@@ -2394,14 +2394,14 @@ void EditorPropertyResource::_update_menu_items() {
menu->add_separator();
}
- menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD);
+ menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD);
if (!res.is_null()) {
- menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT);
- menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR);
- menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
- menu->add_icon_item(get_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE);
+ menu->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT);
+ menu->add_icon_item(get_theme_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR);
+ menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
+ menu->add_icon_item(get_theme_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE);
RES r = res;
if (r.is_valid() && r->get_path().is_resource_file()) {
menu->add_separator();
@@ -2445,12 +2445,12 @@ void EditorPropertyResource::_update_menu_items() {
for (int i = 0; i < conversions.size(); i++) {
String what = conversions[i]->converts_to();
Ref<Texture2D> icon;
- if (has_icon(what, "EditorIcons")) {
+ if (has_theme_icon(what, "EditorIcons")) {
- icon = get_icon(what, "EditorIcons");
+ icon = get_theme_icon(what, "EditorIcons");
} else {
- icon = get_icon(what, "Resource");
+ icon = get_theme_icon(what, "Resource");
}
menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i);
@@ -2462,11 +2462,11 @@ void EditorPropertyResource::_update_menu() {
_update_menu_items();
- Rect2 gt = edit->get_global_rect();
+ Rect2 gt = edit->get_screen_rect();
menu->set_as_minsize();
- int ms = menu->get_combined_minimum_size().width;
+ int ms = menu->get_contents_minimum_size().width;
Vector2 popup_pos = gt.position + gt.size - Vector2(ms, 0);
- menu->set_global_position(popup_pos);
+ menu->set_position(popup_pos);
menu->popup();
}
@@ -2490,10 +2490,10 @@ void EditorPropertyResource::_button_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid()) {
if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
_update_menu_items();
- Vector2 pos = mb->get_global_position();
+ Vector2 pos = get_screen_position() + mb->get_position();
//pos = assign->get_global_transform().xform(pos);
menu->set_as_minsize();
- menu->set_global_position(pos);
+ menu->set_position(pos);
menu->popup();
}
}
@@ -2663,7 +2663,7 @@ void EditorPropertyResource::setup(const String &p_base_type) {
void EditorPropertyResource::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_icon("select_arrow", "Tree");
+ Ref<Texture2D> t = get_theme_icon("select_arrow", "Tree");
edit->set_icon(t);
}
@@ -2718,7 +2718,7 @@ void EditorPropertyResource::expand_all_folding() {
void EditorPropertyResource::_button_draw() {
if (dropping) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
assign->draw_rect(Rect2(Point2(), assign->get_size()), color, false);
}
}
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index c2a6aeb582..13eb2e19d6 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -184,9 +184,9 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) {
Button *button = Object::cast_to<Button>(p_button);
changing_type_idx = p_index;
- Rect2 rect = button->get_global_rect();
+ Rect2 rect = button->get_screen_rect();
change_type->set_as_minsize();
- change_type->set_global_position(rect.position + rect.size - Vector2(change_type->get_combined_minimum_size().x, 0));
+ change_type->set_position(rect.position + rect.size - Vector2(change_type->get_contents_minimum_size().x, 0));
change_type->popup();
}
@@ -373,13 +373,13 @@ void EditorPropertyArray::update_property() {
if (is_untyped_array) {
Button *edit = memnew(Button);
- edit->set_icon(get_icon("Edit", "EditorIcons"));
+ edit->set_icon(get_theme_icon("Edit", "EditorIcons"));
hb->add_child(edit);
edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type), varray(edit, i + offset));
} else {
Button *remove = memnew(Button);
- remove->set_icon(get_icon("Remove", "EditorIcons"));
+ remove->set_icon(get_theme_icon("Remove", "EditorIcons"));
remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset));
hb->add_child(remove);
}
@@ -553,9 +553,9 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) {
Button *button = Object::cast_to<Button>(p_button);
- Rect2 rect = button->get_global_rect();
+ Rect2 rect = button->get_screen_rect();
change_type->set_as_minsize();
- change_type->set_global_position(rect.position + rect.size - Vector2(change_type->get_combined_minimum_size().x, 0));
+ change_type->set_position(rect.position + rect.size - Vector2(change_type->get_contents_minimum_size().x, 0));
change_type->popup();
changing_type_idx = p_index;
}
@@ -909,9 +909,9 @@ void EditorPropertyDictionary::update_property() {
for (int j = 0; j < 4; j++) {
flat->set_default_margin(Margin(j), 2 * EDSCALE);
}
- flat->set_bg_color(get_color("prop_subsection", "Editor"));
+ flat->set_bg_color(get_theme_color("prop_subsection", "Editor"));
- pc->add_style_override("panel", flat);
+ pc->add_theme_style_override("panel", flat);
add_vbox = memnew(VBoxContainer);
pc->add_child(add_vbox);
}
@@ -944,7 +944,7 @@ void EditorPropertyDictionary::update_property() {
hb->add_child(prop);
prop->set_h_size_flags(SIZE_EXPAND_FILL);
Button *edit = memnew(Button);
- edit->set_icon(get_icon("Edit", "EditorIcons"));
+ edit->set_icon(get_theme_icon("Edit", "EditorIcons"));
hb->add_child(edit);
edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type), varray(edit, change_index));
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 98bc544478..4db8fb98f1 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -168,7 +168,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
}
r_texture = generated;
- int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size
+ int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size
small_thumbnail_size *= EDSCALE;
if (preview_generators[i]->can_generate_small_preview()) {
@@ -465,7 +465,7 @@ void EditorResourcePreview::stop() {
preview_sem.post();
while (!exited) {
OS::get_singleton()->delay_usec(10000);
- VisualServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server
+ RenderingServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server
}
Thread::wait_to_finish(thread);
memdelete(thread);
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index 9f0e1f2349..b4ddb7ebfa 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -32,6 +32,7 @@
#include "core/project_settings.h"
#include "editor_settings.h"
+#include "servers/display_server.h"
EditorRun::Status EditorRun::get_status() const {
@@ -70,19 +71,19 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
int screen = EditorSettings::get_singleton()->get("run/window_placement/screen");
if (screen == 0) {
// Same as editor
- screen = OS::get_singleton()->get_current_screen();
+ screen = DisplayServer::get_singleton()->window_get_current_screen();
} else if (screen == 1) {
// Previous monitor (wrap to the other end if needed)
screen = Math::wrapi(
- OS::get_singleton()->get_current_screen() - 1,
+ DisplayServer::get_singleton()->window_get_current_screen() - 1,
0,
- OS::get_singleton()->get_screen_count());
+ DisplayServer::get_singleton()->get_screen_count());
} else if (screen == 2) {
// Next monitor (wrap to the other end if needed)
screen = Math::wrapi(
- OS::get_singleton()->get_current_screen() + 1,
+ DisplayServer::get_singleton()->window_get_current_screen() + 1,
0,
- OS::get_singleton()->get_screen_count());
+ DisplayServer::get_singleton()->get_screen_count());
} else {
// Fixed monitor ID
// There are 3 special options, so decrement the option ID by 3 to get the monitor ID
@@ -94,8 +95,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
}
Rect2 screen_rect;
- screen_rect.position = OS::get_singleton()->get_screen_position(screen);
- screen_rect.size = OS::get_singleton()->get_screen_size(screen);
+ screen_rect.position = DisplayServer::get_singleton()->screen_get_position(screen);
+ screen_rect.size = DisplayServer::get_singleton()->screen_get_size(screen);
Size2 desired_size;
desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/width");
@@ -120,7 +121,9 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
case 1: { // centered
int display_scale = 1;
#ifdef OSX_ENABLED
- if (OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000) {
+ display_scale = DisplayServer::get_singleton()->screen_get_scale(screen);
+#else
+ if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000) {
display_scale = 2;
}
#endif
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index fe28efedeb..2c895a3e9d 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -257,7 +257,7 @@ void SectionedInspector::update_category_list() {
for (int i = 0; i < sc; i++) {
TreeItem *parent = section_map[metasection];
- parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
if (i > 0) {
metasection += "/" + sectionarr[i];
@@ -309,7 +309,7 @@ SectionedInspector::SectionedInspector() :
filter(memnew(SectionedInspectorFilter)),
inspector(memnew(EditorInspector)),
search_box(NULL) {
- add_constant_override("autohide", 1); // Fixes the dragger always showing up
+ add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up
VBoxContainer *left_vb = memnew(VBoxContainer);
left_vb->set_custom_minimum_size(Size2(190, 0) * EDSCALE);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index a32b736851..286ca7b184 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -49,7 +49,7 @@
#include "editor/editor_translations.gen.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
// PRIVATE METHODS
@@ -599,7 +599,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("run/window_placement/rect", 1);
hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen");
String screen_hints = "Same as Editor,Previous Monitor,Next Monitor";
- for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) {
+ for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
screen_hints += ",Monitor " + itos(i + 1);
}
_initial_set("run/window_placement/rect_custom_position", Vector2());
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 0ede0a3b7a..2c115c66cb 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -29,8 +29,9 @@
/*************************************************************************/
#include "editor_spin_slider.h"
+
+#include "core/input/input_filter.h"
#include "core/math/expression.h"
-#include "core/os/input.h"
#include "editor_node.h"
#include "editor_scale.h"
@@ -67,7 +68,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
grabbing_spinner_dist_cache = 0;
pre_grab_value = get_value();
grabbing_spinner = false;
- grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position();
+ grabbing_spinner_mouse_pos = InputFilter::get_singleton()->get_mouse_position();
}
} else {
@@ -75,8 +76,8 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
if (grabbing_spinner) {
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
- Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
+ InputFilter::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
update();
} else {
_focus_entered();
@@ -105,7 +106,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
grabbing_spinner_dist_cache += diff_x;
if (!grabbing_spinner && ABS(grabbing_spinner_dist_cache) > 4 * EDSCALE) {
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_CAPTURED);
grabbing_spinner = true;
}
@@ -176,11 +177,11 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
void EditorSpinSlider::_notification(int p_what) {
- if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT ||
- p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN ||
+ if (p_what == NOTIFICATION_WM_FOCUS_OUT ||
+ p_what == NOTIFICATION_WM_FOCUS_IN ||
p_what == NOTIFICATION_EXIT_TREE) {
if (grabbing_spinner) {
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
grabbing_spinner = false;
grabbing_spinner_attempt = false;
}
@@ -191,30 +192,30 @@ void EditorSpinSlider::_notification(int p_what) {
// when it's edited. The LineEdit "focus" stylebox uses the "normal" stylebox's
// default margins.
Ref<StyleBoxFlat> stylebox =
- EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "LineEdit")->duplicate();
+ EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "LineEdit")->duplicate();
// EditorSpinSliders with a label have more space on the left, so add an
// higher margin to match the location where the text begins.
// The margin values below were determined by empirical testing.
stylebox->set_default_margin(MARGIN_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE);
- value_input->add_style_override("normal", stylebox);
+ value_input->add_theme_style_override("normal", stylebox);
}
if (p_what == NOTIFICATION_DRAW) {
updown_offset = -1;
- Ref<StyleBox> sb = get_stylebox("normal", "LineEdit");
+ Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit");
if (!flat) {
draw_style_box(sb, Rect2(Vector2(), get_size()));
}
- Ref<Font> font = get_font("font", "LineEdit");
+ Ref<Font> font = get_theme_font("font", "LineEdit");
int sep_base = 4 * EDSCALE;
int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better
int string_width = font->get_string_size(label).width;
int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep;
- Ref<Texture2D> updown = get_icon("updown", "SpinBox");
+ Ref<Texture2D> updown = get_theme_icon("updown", "SpinBox");
if (get_step() == 1) {
number_width -= updown->get_width();
@@ -224,7 +225,7 @@ void EditorSpinSlider::_notification(int p_what) {
int vofs = (get_size().height - font->get_height()) / 2 + font->get_ascent();
- Color fc = get_color("font_color", "LineEdit");
+ Color fc = get_theme_color("font_color", "LineEdit");
Color lc;
if (use_custom_label_color) {
lc = custom_label_color;
@@ -233,12 +234,12 @@ void EditorSpinSlider::_notification(int p_what) {
}
if (flat && label != String()) {
- Color label_bg_color = get_color("dark_color_3", "Editor");
+ Color label_bg_color = get_theme_color("dark_color_3", "Editor");
draw_rect(Rect2(Vector2(), Vector2(sb->get_offset().x * 2 + string_width, get_size().height)), label_bg_color);
}
if (has_focus()) {
- Ref<StyleBox> focus = get_stylebox("focus", "LineEdit");
+ Ref<StyleBox> focus = get_theme_stylebox("focus", "LineEdit");
draw_style_box(focus, Rect2(Vector2(), get_size()));
}
@@ -247,7 +248,7 @@ void EditorSpinSlider::_notification(int p_what) {
draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width);
if (get_step() == 1) {
- Ref<Texture2D> updown2 = get_icon("updown", "SpinBox");
+ Ref<Texture2D> updown2 = get_theme_icon("updown", "SpinBox");
int updown_vofs = (get_size().height - updown2->get_height()) / 2;
updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width();
Color c(1, 1, 1);
@@ -272,7 +273,7 @@ void EditorSpinSlider::_notification(int p_what) {
Rect2 grabber_rect = Rect2(ofs + gofs, svofs + 1, grabber_w, 2 * EDSCALE);
draw_rect(grabber_rect, c);
- bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input->is_visible();
+ bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input_popup->is_visible();
if (grabber->is_visible() != display_grabber) {
if (display_grabber) {
grabber->show();
@@ -284,9 +285,9 @@ void EditorSpinSlider::_notification(int p_what) {
if (display_grabber) {
Ref<Texture2D> grabber_tex;
if (mouse_over_grabber) {
- grabber_tex = get_icon("grabber_highlight", "HSlider");
+ grabber_tex = get_theme_icon("grabber_highlight", "HSlider");
} else {
- grabber_tex = get_icon("grabber", "HSlider");
+ grabber_tex = get_theme_icon("grabber", "HSlider");
}
if (grabber->get_texture() != grabber_tex) {
@@ -297,7 +298,7 @@ void EditorSpinSlider::_notification(int p_what) {
grabber->set_position(get_global_position() + grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5);
if (mousewheel_over_grabber) {
- Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);
+ InputFilter::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);
}
grabber_range = width;
@@ -316,12 +317,7 @@ void EditorSpinSlider::_notification(int p_what) {
update();
}
if (p_what == NOTIFICATION_FOCUS_ENTER) {
- /* Sorry, I don't like this, it makes navigating the different fields with arrows more difficult.
- * Just press enter to edit.
- * if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && !value_input_just_closed) {
- _focus_entered();
- }*/
- if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) {
+ if ((InputFilter::get_singleton()->is_action_pressed("ui_focus_next") || InputFilter::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) {
_focus_entered();
}
value_input_just_closed = false;
@@ -330,8 +326,8 @@ void EditorSpinSlider::_notification(int p_what) {
Size2 EditorSpinSlider::get_minimum_size() const {
- Ref<StyleBox> sb = get_stylebox("normal", "LineEdit");
- Ref<Font> font = get_font("font", "LineEdit");
+ Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit");
+ Ref<Font> font = get_theme_font("font", "LineEdit");
Size2 ms = sb->get_minimum_size();
ms.height += font->get_height();
@@ -375,7 +371,7 @@ void EditorSpinSlider::_evaluate_input_text() {
//text_entered signal
void EditorSpinSlider::_value_input_entered(const String &p_text) {
value_input_just_closed = true;
- value_input->hide();
+ value_input_popup->hide();
}
//modal_closed signal
@@ -398,7 +394,7 @@ void EditorSpinSlider::_value_focus_exited() {
// -> modal_close was not called
// -> need to close/hide manually
if (!value_input_just_closed) { //value_input_just_closed should do the same
- value_input->hide();
+ value_input_popup->hide();
//tab was pressed
} else {
//enter, click, esc
@@ -441,11 +437,11 @@ void EditorSpinSlider::set_custom_label_color(bool p_use_custom_label_color, Col
}
void EditorSpinSlider::_focus_entered() {
- Rect2 gr = get_global_rect();
+ Rect2 gr = get_screen_rect();
value_input->set_text(get_text_value());
- value_input->set_position(gr.position);
- value_input->set_size(gr.size);
- value_input->call_deferred("show_modal");
+ value_input_popup->set_position(gr.position);
+ value_input_popup->set_size(gr.size);
+ value_input_popup->call_deferred("popup");
value_input->call_deferred("grab_focus");
value_input->call_deferred("select_all");
value_input->set_focus_next(find_next_valid_focus()->get_path());
@@ -492,11 +488,13 @@ EditorSpinSlider::EditorSpinSlider() {
mousewheel_over_grabber = false;
grabbing_grabber = false;
grabber_range = 1;
+ value_input_popup = memnew(Popup);
+ add_child(value_input_popup);
value_input = memnew(LineEdit);
- add_child(value_input);
- value_input->set_as_toplevel(true);
- value_input->hide();
- value_input->connect("modal_closed", callable_mp(this, &EditorSpinSlider::_value_input_closed));
+ value_input_popup->add_child(value_input);
+ value_input_popup->set_wrap_controls(true);
+ value_input->set_anchors_and_margins_preset(PRESET_WIDE);
+ value_input_popup->connect("popup_hide", callable_mp(this, &EditorSpinSlider::_value_input_closed));
value_input->connect("text_entered", callable_mp(this, &EditorSpinSlider::_value_input_entered));
value_input->connect("focus_exited", callable_mp(this, &EditorSpinSlider::_value_focus_exited));
value_input_just_closed = false;
diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h
index 81a7b981cc..db74f5fb70 100644
--- a/editor/editor_spin_slider.h
+++ b/editor/editor_spin_slider.h
@@ -62,6 +62,7 @@ class EditorSpinSlider : public Range {
Vector2 grabbing_spinner_mouse_pos;
double pre_grab_value;
+ Popup *value_input_popup;
LineEdit *value_input;
bool value_input_just_closed;
diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp
index 3ebd8f0475..cd5768551f 100644
--- a/editor/editor_sub_scene.cpp
+++ b/editor/editor_sub_scene.cpp
@@ -70,11 +70,11 @@ void EditorSubScene::_path_browse() {
}
void EditorSubScene::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible() && scene == NULL)
+ if (is_visible() && scene == NULL) {
_path_browse();
+ }
}
}
@@ -240,7 +240,7 @@ EditorSubScene::EditorSubScene() {
path = memnew(LineEdit);
path->connect("text_entered", callable_mp(this, &EditorSubScene::_path_changed));
hb->add_child(path);
- path->set_h_size_flags(SIZE_EXPAND_FILL);
+ path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Button *b = memnew(Button);
b->set_text(TTR("Browse"));
hb->add_child(b);
@@ -248,7 +248,7 @@ EditorSubScene::EditorSubScene() {
vb->add_margin_child(TTR("Scene Path:"), hb);
tree = memnew(Tree);
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vb->add_margin_child(TTR("Import From Node:"), tree, true);
tree->set_select_mode(Tree::SELECT_MULTI);
tree->connect("multi_selected", callable_mp(this, &EditorSubScene::_item_multi_selected));
@@ -266,7 +266,7 @@ EditorSubScene::EditorSubScene() {
file_dialog->add_filter("*." + E->get());
}
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
add_child(file_dialog);
file_dialog->connect("file_selected", callable_mp(this, &EditorSubScene::_path_selected));
}
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 1263eb166b..ac902854b7 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -910,14 +910,17 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_window->set_border_color(tab_color);
style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE);
style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE);
- theme->set_stylebox("panel", "WindowDialog", style_window);
- theme->set_color("title_color", "WindowDialog", font_color);
- theme->set_icon("close", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
- theme->set_icon("close_highlight", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
- theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE);
- theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE);
- theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE);
- theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts"));
+
+ theme->set_stylebox("panel", "Window", style_default);
+ theme->set_stylebox("panel_window", "Window", style_window);
+ theme->set_color("title_color", "Window", font_color);
+ theme->set_icon("close", "Window", theme->get_icon("GuiClose", "EditorIcons"));
+ theme->set_icon("close_highlight", "Window", theme->get_icon("GuiClose", "EditorIcons"));
+ theme->set_constant("close_h_ofs", "Window", 22 * EDSCALE);
+ theme->set_constant("close_v_ofs", "Window", 20 * EDSCALE);
+ theme->set_constant("title_height", "Window", 24 * EDSCALE);
+ theme->set_constant("resize_margin", "Window", 4 * EDSCALE);
+ theme->set_font("title_font", "Window", theme->get_font("title", "EditorFonts"));
// complex window, for now only Editor settings and Project settings
Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
@@ -974,10 +977,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
+ theme->set_stylebox("panel", "EditorHelpBit", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
+
theme->set_color("headline_color", "EditorHelp", mono_color);
// Panel
theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
+ theme->set_stylebox("panel_fg", "Panel", style_default);
// Label
theme->set_stylebox("normal", "Label", style_empty);
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 9328a5e04d..61ec9c44c2 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -30,10 +30,10 @@
#include "export_template_manager.h"
+#include "core/input/input_filter.h"
#include "core/io/json.h"
#include "core/io/zip_io.h"
#include "core/os/dir_access.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/version.h"
#include "editor_node.h"
@@ -82,11 +82,11 @@ void ExportTemplateManager::_update_template_list() {
String(VERSION_STATUS) != String("rc");
Label *current = memnew(Label);
- current->set_h_size_flags(SIZE_EXPAND_FILL);
+ current->set_h_size_flags(Control::SIZE_EXPAND_FILL);
current_hb->add_child(current);
if (templates.has(current_version)) {
- current->add_color_override("font_color", get_color("success_color", "Editor"));
+ current->add_theme_color_override("font_color", current->get_theme_color("success_color", "Editor"));
// Only display a redownload button if it can be downloaded in the first place
if (downloads_available) {
@@ -103,7 +103,7 @@ void ExportTemplateManager::_update_template_list() {
uninstall->connect("pressed", callable_mp(this, &ExportTemplateManager::_uninstall_template), varray(current_version));
} else {
- current->add_color_override("font_color", get_color("error_color", "Editor"));
+ current->add_theme_color_override("font_color", current->get_theme_color("error_color", "Editor"));
Button *redownload = memnew(Button);
redownload->set_text(TTR("Download"));
@@ -121,13 +121,13 @@ void ExportTemplateManager::_update_template_list() {
HBoxContainer *hbc = memnew(HBoxContainer);
Label *version = memnew(Label);
- version->set_modulate(get_color("disabled_font_color", "Editor"));
+ version->set_modulate(current->get_theme_color("disabled_font_color", "Editor"));
String text = E->get();
if (text == current_version) {
text += " " + TTR("(Current)");
}
version->set_text(text);
- version->set_h_size_flags(SIZE_EXPAND_FILL);
+ version->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(version);
Button *uninstall = memnew(Button);
@@ -145,7 +145,7 @@ void ExportTemplateManager::_download_template(const String &p_version) {
while (template_list->get_child_count()) {
memdelete(template_list->get_child(0));
}
- template_downloader->popup_centered_minsize();
+ template_downloader->popup_centered();
template_list_state->set_text(TTR("Retrieving mirrors, please wait..."));
template_download_progress->set_max(100);
template_download_progress->set_value(0);
@@ -157,7 +157,7 @@ void ExportTemplateManager::_download_template(const String &p_version) {
void ExportTemplateManager::_uninstall_template(const String &p_version) {
remove_confirm->set_text(vformat(TTR("Remove template version '%s'?"), p_version));
- remove_confirm->popup_centered_minsize();
+ remove_confirm->popup_centered();
to_remove = p_version;
}
@@ -342,7 +342,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
void ExportTemplateManager::popup_manager() {
_update_template_list();
- popup_centered_minsize(Size2(400, 400) * EDSCALE);
+ popup_centered(Size2(400, 400) * EDSCALE);
}
void ExportTemplateManager::ok_pressed() {
@@ -446,7 +446,7 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
void ExportTemplateManager::_begin_template_download(const String &p_url) {
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
OS::get_singleton()->shell_open(p_url);
return;
}
@@ -483,6 +483,11 @@ void ExportTemplateManager::_window_template_downloader_closed() {
void ExportTemplateManager::_notification(int p_what) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ if (!is_visible()) {
+ set_process(false);
+ }
+ }
if (p_what == NOTIFICATION_PROCESS) {
update_countdown -= get_process_delta_time();
@@ -536,12 +541,6 @@ void ExportTemplateManager::_notification(int p_what) {
set_process(false);
}
}
-
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (!is_visible_in_tree()) {
- set_process(false);
- }
- }
}
bool ExportTemplateManager::can_install_android_template() {
@@ -674,7 +673,7 @@ ExportTemplateManager::ExportTemplateManager() {
installed_scroll->add_child(installed_vb);
installed_scroll->set_enable_v_scroll(true);
installed_scroll->set_enable_h_scroll(false);
- installed_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ installed_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
get_cancel()->set_text(TTR("Close"));
get_ok()->set_text(TTR("Install From File"));
@@ -688,7 +687,7 @@ ExportTemplateManager::ExportTemplateManager() {
template_open->set_title(TTR("Select Template File"));
template_open->add_filter("*.tpz ; " + TTR("Godot Export Templates"));
template_open->set_access(FileDialog::ACCESS_FILESYSTEM);
- template_open->set_mode(FileDialog::MODE_OPEN_FILE);
+ template_open->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
template_open->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_from_file), varray(true));
add_child(template_open);
@@ -708,7 +707,7 @@ ExportTemplateManager::ExportTemplateManager() {
template_downloader->get_ok()->set_text(TTR("Close"));
template_downloader->set_exclusive(true);
add_child(template_downloader);
- template_downloader->connect("popup_hide", callable_mp(this, &ExportTemplateManager::_window_template_downloader_closed));
+ template_downloader->connect("cancelled", callable_mp(this, &ExportTemplateManager::_window_template_downloader_closed));
VBoxContainer *vbc = memnew(VBoxContainer);
template_downloader->add_child(vbc);
diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp
deleted file mode 100644
index 52ab80cc48..0000000000
--- a/editor/file_type_cache.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*************************************************************************/
-/* file_type_cache.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "file_type_cache.h"
-
-#include "core/os/file_access.h"
-#include "core/project_settings.h"
-
-FileTypeCache *FileTypeCache::singleton = NULL;
-
-bool FileTypeCache::has_file(const String &p_path) const {
-
- GLOBAL_LOCK_FUNCTION
- return file_type_map.has(p_path);
-}
-
-String FileTypeCache::get_file_type(const String &p_path) const {
-
- GLOBAL_LOCK_FUNCTION
- ERR_FAIL_COND_V(!file_type_map.has(p_path), "");
- return file_type_map[p_path];
-}
-void FileTypeCache::set_file_type(const String &p_path, const String &p_type) {
-
- GLOBAL_LOCK_FUNCTION
- file_type_map[p_path] = p_type;
-}
-
-void FileTypeCache::load() {
-
- GLOBAL_LOCK_FUNCTION
- String project = ProjectSettings::get_singleton()->get_resource_path();
- FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::READ);
-
- if (!f) {
-
- WARN_PRINT("Can't open file_type_cache.cch.");
- return;
- }
-
- file_type_map.clear();
- while (!f->eof_reached()) {
-
- String path = f->get_line();
- if (f->eof_reached())
- break;
- String type = f->get_line();
- set_file_type(path, type);
- }
-
- memdelete(f);
-}
-
-void FileTypeCache::save() {
-
- GLOBAL_LOCK_FUNCTION
- String project = ProjectSettings::get_singleton()->get_resource_path();
- FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE);
-
- ERR_FAIL_COND_MSG(!f, "Can't open file_type_cache.cch for writing, not saving file type cache!");
-
- const String *K = NULL;
-
- while ((K = file_type_map.next(K))) {
-
- f->store_line(*K);
- f->store_line(file_type_map[*K]);
- }
-
- memdelete(f);
-}
-
-FileTypeCache::FileTypeCache() {
-
- ERR_FAIL_COND_MSG(singleton, "FileTypeCache singleton already exist.");
- singleton = this;
-}
diff --git a/editor/file_type_cache.h b/editor/file_type_cache.h
deleted file mode 100644
index 216effea00..0000000000
--- a/editor/file_type_cache.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*************************************************************************/
-/* file_type_cache.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef FILE_TYPE_CACHE_H
-#define FILE_TYPE_CACHE_H
-
-#include "core/object.h"
-
-class FileTypeCache : Object {
-
- GDCLASS(FileTypeCache, Object);
-
- HashMap<String, String> file_type_map;
-
- static FileTypeCache *singleton;
-
-public:
- static FileTypeCache *get_singleton() { return singleton; }
-
- bool has_file(const String &p_path) const;
- String get_file_type(const String &p_path) const;
- void set_file_type(const String &p_path, const String &p_type);
-
- void load();
- void save();
-
- FileTypeCache();
-};
-
-#endif // FILE_TYPE_CACHE_H
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 962d95736f..e1fcddda3a 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -42,16 +42,17 @@
#include "editor_scale.h"
#include "editor_settings.h"
#include "import_dock.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
+#include "servers/display_server.h"
Ref<Texture2D> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) {
Ref<Texture2D> file_icon;
if (!p_dir->get_file_import_is_valid(p_idx)) {
- file_icon = get_icon("ImportFail", "EditorIcons");
+ file_icon = get_theme_icon("ImportFail", "EditorIcons");
} else {
String file_type = p_dir->get_file_type(p_idx);
- file_icon = (has_icon(file_type, "EditorIcons")) ? get_icon(file_type, "EditorIcons") : get_icon("File", "EditorIcons");
+ file_icon = (has_theme_icon(file_type, "EditorIcons")) ? get_theme_icon(file_type, "EditorIcons") : get_theme_icon("File", "EditorIcons");
}
return file_icon;
}
@@ -66,8 +67,8 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
dname = "res://";
subdirectory_item->set_text(0, dname);
- subdirectory_item->set_icon(0, get_icon("Folder", "EditorIcons"));
- subdirectory_item->set_icon_modulate(0, get_color("folder_icon_modulate", "FileDialog"));
+ subdirectory_item->set_icon(0, get_theme_icon("Folder", "EditorIcons"));
+ subdirectory_item->set_icon_modulate(0, get_theme_color("folder_icon_modulate", "FileDialog"));
subdirectory_item->set_selectable(0, true);
String lpath = p_dir->get_path();
subdirectory_item->set_metadata(0, lpath);
@@ -121,7 +122,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
file_item->set_as_cursor(0);
}
if (main_scene == file_metadata) {
- file_item->set_custom_color(0, get_color("accent_color", "Editor"));
+ file_item->set_custom_color(0, get_theme_color("accent_color", "Editor"));
}
Array udata;
udata.push_back(tree_update_id);
@@ -187,7 +188,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
// Handles the favorites.
TreeItem *favorites = tree->create_item(root);
- favorites->set_icon(0, get_icon("Favorites", "EditorIcons"));
+ favorites->set_icon(0, get_theme_icon("Favorites", "EditorIcons"));
favorites->set_text(0, TTR("Favorites:"));
favorites->set_metadata(0, "Favorites");
favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
@@ -198,8 +199,8 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
if (!fave.begins_with("res://"))
continue;
- Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons");
- const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
+ Ref<Texture2D> folder_icon = get_theme_icon("Folder", "EditorIcons");
+ const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog");
String text;
Ref<Texture2D> icon;
@@ -219,7 +220,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
if (dir) {
icon = _get_tree_item_icon(dir, index);
} else {
- icon = get_icon("File", "EditorIcons");
+ icon = get_theme_icon("File", "EditorIcons");
}
color = Color(1, 1, 1);
}
@@ -306,20 +307,21 @@ void FileSystemDock::_notification(int p_what) {
EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated));
String ei = "EditorIcons";
- button_reload->set_icon(get_icon("Reload", ei));
- button_toggle_display_mode->set_icon(get_icon("Panels2", ei));
+
+ button_reload->set_icon(get_theme_icon("Reload", ei));
+ button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei));
button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display));
files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file));
button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history));
button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history));
- tree_search_box->set_right_icon(get_icon("Search", ei));
+ tree_search_box->set_right_icon(get_theme_icon("Search", ei));
tree_search_box->set_clear_button_enabled(true);
- file_list_search_box->set_right_icon(get_icon("Search", ei));
+ file_list_search_box->set_right_icon(get_theme_icon("Search", ei));
file_list_search_box->set_clear_button_enabled(true);
- button_hist_next->set_icon(get_icon("Forward", ei));
- button_hist_prev->set_icon(get_icon("Back", ei));
+ button_hist_next->set_icon(get_theme_icon("Forward", ei));
+ button_hist_prev->set_icon(get_theme_icon("Back", ei));
file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option));
tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option));
@@ -369,19 +371,19 @@ void FileSystemDock::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
// Update icons.
String ei = "EditorIcons";
- button_reload->set_icon(get_icon("Reload", ei));
- button_toggle_display_mode->set_icon(get_icon("Panels2", ei));
- button_hist_next->set_icon(get_icon("Forward", ei));
- button_hist_prev->set_icon(get_icon("Back", ei));
+ button_reload->set_icon(get_theme_icon("Reload", ei));
+ button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei));
+ button_hist_next->set_icon(get_theme_icon("Forward", ei));
+ button_hist_prev->set_icon(get_theme_icon("Back", ei));
if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) {
- button_file_list_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
+ button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons"));
} else {
- button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
+ button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons"));
}
- tree_search_box->set_right_icon(get_icon("Search", ei));
+ tree_search_box->set_right_icon(get_theme_icon("Search", ei));
tree_search_box->set_clear_button_enabled(true);
- file_list_search_box->set_right_icon(get_icon("Search", ei));
+ file_list_search_box->set_right_icon(get_theme_icon("Search", ei));
file_list_search_box->set_clear_button_enabled(true);
// Update always show folders.
@@ -532,11 +534,11 @@ void FileSystemDock::_toggle_file_display() {
void FileSystemDock::_set_file_display(bool p_active) {
if (p_active) {
file_list_display_mode = FILE_LIST_DISPLAY_LIST;
- button_file_list_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
+ button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons"));
button_file_list_display_mode->set_tooltip(TTR("View items as a grid of thumbnails."));
} else {
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
- button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
+ button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons"));
button_file_list_display_mode->set_tooltip(TTR("View items as a list."));
}
@@ -628,13 +630,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
if (thumbnail_size < 64) {
- folder_thumbnail = get_icon("FolderMediumThumb", ei);
- file_thumbnail = get_icon("FileMediumThumb", ei);
- file_thumbnail_broken = get_icon("FileDeadMediumThumb", ei);
+ folder_thumbnail = get_theme_icon("FolderMediumThumb", ei);
+ file_thumbnail = get_theme_icon("FileMediumThumb", ei);
+ file_thumbnail_broken = get_theme_icon("FileDeadMediumThumb", ei);
} else {
- folder_thumbnail = get_icon("FolderBigThumb", ei);
- file_thumbnail = get_icon("FileBigThumb", ei);
- file_thumbnail_broken = get_icon("FileDeadBigThumb", ei);
+ folder_thumbnail = get_theme_icon("FolderBigThumb", ei);
+ file_thumbnail = get_theme_icon("FileBigThumb", ei);
+ file_thumbnail_broken = get_theme_icon("FileDeadBigThumb", ei);
}
} else {
// No thumbnails.
@@ -645,8 +647,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
files->set_fixed_icon_size(Size2());
}
- Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog");
- const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
+ Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon("folder", "FileDialog");
+ const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog");
// Build the FileInfo list.
List<FileInfo> filelist;
@@ -766,10 +768,10 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
// Select the icons.
if (!finfo->import_broken) {
- type_icon = (has_icon(ftype, ei)) ? get_icon(ftype, ei) : get_icon(oi, ei);
+ type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei);
big_icon = file_thumbnail;
} else {
- type_icon = get_icon("ImportFail", ei);
+ type_icon = get_theme_icon("ImportFail", ei);
big_icon = file_thumbnail_broken;
tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually.");
}
@@ -789,7 +791,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
}
if (fpath == main_scene) {
- files->set_item_custom_fg_color(item_index, get_color("accent_color", "Editor"));
+ files->set_item_custom_fg_color(item_index, get_theme_color("accent_color", "Editor"));
}
// Generate the preview.
@@ -1412,7 +1414,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove
bool can_move = _check_existing();
if (!can_move) {
// Ask to do something.
- overwrite_dialog->popup_centered_minsize();
+ overwrite_dialog->popup_centered();
return;
}
}
@@ -1676,7 +1678,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
rename_dialog_text->set_text(name);
rename_dialog_text->select(0, name.length());
}
- rename_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ rename_dialog->popup_centered(Size2(250, 80) * EDSCALE);
rename_dialog_text->grab_focus();
}
}
@@ -1720,7 +1722,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
duplicate_dialog_text->set_text(name);
duplicate_dialog_text->select(0, name.length());
}
- duplicate_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ duplicate_dialog->popup_centered(Size2(250, 80) * EDSCALE);
duplicate_dialog_text->grab_focus();
}
} break;
@@ -1742,14 +1744,14 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_NEW_FOLDER: {
make_dir_dialog_text->set_text("new folder");
make_dir_dialog_text->select_all();
- make_dir_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ make_dir_dialog->popup_centered(Size2(250, 80) * EDSCALE);
make_dir_dialog_text->grab_focus();
} break;
case FILE_NEW_SCENE: {
make_scene_dialog_text->set_text("new scene");
make_scene_dialog_text->select_all();
- make_scene_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
+ make_scene_dialog->popup_centered(Size2(250, 80) * EDSCALE);
make_scene_dialog_text->grab_focus();
} break;
@@ -1765,7 +1767,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_COPY_PATH: {
if (!p_selected.empty()) {
String fpath = p_selected[0];
- OS::get_singleton()->set_clipboard(fpath);
+ DisplayServer::get_singleton()->clipboard_set(fpath);
}
} break;
@@ -2178,28 +2180,28 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
if (all_files) {
if (all_files_scenes) {
if (filenames.size() == 1) {
- p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN);
- p_popup->add_icon_item(get_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT);
+ p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN);
+ p_popup->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT);
if (ProjectSettings::get_singleton()->get("application/run/main_scene") != filenames[0]) {
- p_popup->add_icon_item(get_icon("PlayScene", "EditorIcons"), TTR("Set As Main Scene"), FILE_MAIN_SCENE);
+ p_popup->add_icon_item(get_theme_icon("PlayScene", "EditorIcons"), TTR("Set As Main Scene"), FILE_MAIN_SCENE);
}
} else {
- p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN);
+ p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN);
}
- p_popup->add_icon_item(get_icon("Instance", "EditorIcons"), TTR("Instance"), FILE_INSTANCE);
+ p_popup->add_icon_item(get_theme_icon("Instance", "EditorIcons"), TTR("Instance"), FILE_INSTANCE);
p_popup->add_separator();
} else if (filenames.size() == 1) {
- p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN);
+ p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN);
p_popup->add_separator();
}
}
if (p_paths.size() >= 1) {
if (!all_favorites) {
- p_popup->add_icon_item(get_icon("Favorites", "EditorIcons"), TTR("Add to Favorites"), FILE_ADD_FAVORITE);
+ p_popup->add_icon_item(get_theme_icon("Favorites", "EditorIcons"), TTR("Add to Favorites"), FILE_ADD_FAVORITE);
}
if (!all_not_favorites) {
- p_popup->add_icon_item(get_icon("NonFavorite", "EditorIcons"), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE);
+ p_popup->add_icon_item(get_theme_icon("NonFavorite", "EditorIcons"), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE);
}
p_popup->add_separator();
}
@@ -2212,36 +2214,36 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
}
} else if (all_folders && foldernames.size() > 0) {
- p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN);
+ p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN);
p_popup->add_separator();
}
if (p_paths.size() == 1) {
- p_popup->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), FILE_COPY_PATH);
+ p_popup->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), FILE_COPY_PATH);
if (p_paths[0] != "res://") {
- p_popup->add_icon_item(get_icon("Rename", "EditorIcons"), TTR("Rename..."), FILE_RENAME);
- p_popup->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate..."), FILE_DUPLICATE);
+ p_popup->add_icon_item(get_theme_icon("Rename", "EditorIcons"), TTR("Rename..."), FILE_RENAME);
+ p_popup->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate..."), FILE_DUPLICATE);
}
}
if (p_paths.size() > 1 || p_paths[0] != "res://") {
- p_popup->add_icon_item(get_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE);
- p_popup->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete"), FILE_REMOVE);
+ p_popup->add_icon_item(get_theme_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE);
+ p_popup->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete"), FILE_REMOVE);
}
if (p_paths.size() == 1) {
p_popup->add_separator();
if (p_display_path_dependent_options) {
- p_popup->add_icon_item(get_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER);
- p_popup->add_icon_item(get_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE);
- p_popup->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT);
- p_popup->add_icon_item(get_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE);
+ p_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER);
+ p_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE);
+ p_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT);
+ p_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE);
p_popup->add_separator();
}
String fpath = p_paths[0];
String item_text = fpath.ends_with("/") ? TTR("Open in File Manager") : TTR("Show in File Manager");
- p_popup->add_icon_item(get_icon("Filesystem", "EditorIcons"), item_text, FILE_SHOW_IN_EXPLORER);
+ p_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), item_text, FILE_SHOW_IN_EXPLORER);
}
}
@@ -2251,8 +2253,8 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) {
if (paths.size() == 1) {
if (paths[0].ends_with("/")) {
- tree_popup->add_icon_item(get_icon("GuiTreeArrowDown", "EditorIcons"), TTR("Expand All"), FOLDER_EXPAND_ALL);
- tree_popup->add_icon_item(get_icon("GuiTreeArrowRight", "EditorIcons"), TTR("Collapse All"), FOLDER_COLLAPSE_ALL);
+ tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowDown", "EditorIcons"), TTR("Expand All"), FOLDER_EXPAND_ALL);
+ tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowRight", "EditorIcons"), TTR("Collapse All"), FOLDER_COLLAPSE_ALL);
tree_popup->add_separator();
}
}
@@ -2272,10 +2274,10 @@ void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) {
path = "res://";
tree_popup->clear();
tree_popup->set_size(Size2(1, 1));
- tree_popup->add_icon_item(get_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER);
- tree_popup->add_icon_item(get_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE);
- tree_popup->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT);
- tree_popup->add_icon_item(get_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE);
+ tree_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER);
+ tree_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE);
+ tree_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT);
+ tree_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE);
tree_popup->set_position(tree->get_global_position() + p_pos);
tree_popup->popup();
}
@@ -2315,12 +2317,12 @@ void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) {
file_list_popup->clear();
file_list_popup->set_size(Size2(1, 1));
- file_list_popup->add_icon_item(get_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER);
- file_list_popup->add_icon_item(get_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE);
- file_list_popup->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT);
- file_list_popup->add_icon_item(get_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE);
+ file_list_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER);
+ file_list_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE);
+ file_list_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT);
+ file_list_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE);
file_list_popup->add_separator();
- file_list_popup->add_icon_item(get_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER);
+ file_list_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER);
file_list_popup->set_position(files->get_global_position() + p_pos);
file_list_popup->popup();
}
@@ -2348,8 +2350,6 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
}
void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
- if (get_viewport()->get_modal_stack_top())
- return; // Ignore because of modal window.
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
@@ -2366,8 +2366,6 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
}
void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
- if (get_viewport()->get_modal_stack_top())
- return; // Ignore because of modal window.
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
@@ -2492,7 +2490,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
add_child(top_vbc);
HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
- toolbar_hbc->add_constant_override("separation", 0);
+ toolbar_hbc->add_theme_constant_override("separation", 0);
top_vbc->add_child(toolbar_hbc);
button_hist_prev = memnew(ToolButton);
@@ -2529,7 +2527,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
toolbar_hbc->add_child(button_toggle_display_mode);
HBoxContainer *toolbar2_hbc = memnew(HBoxContainer);
- toolbar2_hbc->add_constant_override("separation", 0);
+ toolbar2_hbc->add_theme_constant_override("separation", 0);
top_vbc->add_child(toolbar2_hbc);
tree_search_box = memnew(LineEdit);
@@ -2539,11 +2537,11 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
toolbar2_hbc->add_child(tree_search_box);
file_list_popup = memnew(PopupMenu);
- file_list_popup->set_hide_on_window_lose_focus(true);
+
add_child(file_list_popup);
tree_popup = memnew(PopupMenu);
- tree_popup->set_hide_on_window_lose_focus(true);
+
add_child(tree_popup);
split_box = memnew(VSplitContainer);
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 5a7d4cede7..61afc9115f 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -299,14 +299,14 @@ const char *FindInFilesDialog::SIGNAL_REPLACE_REQUESTED = "replace_requested";
FindInFilesDialog::FindInFilesDialog() {
- set_custom_minimum_size(Size2(500 * EDSCALE, 0));
+ set_min_size(Size2(500 * EDSCALE, 0));
set_title(TTR("Find in Files"));
VBoxContainer *vbc = memnew(VBoxContainer);
- vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE);
add_child(vbc);
GridContainer *gc = memnew(GridContainer);
@@ -318,7 +318,7 @@ FindInFilesDialog::FindInFilesDialog() {
gc->add_child(find_label);
_search_text_line_edit = memnew(LineEdit);
- _search_text_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ _search_text_line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
_search_text_line_edit->connect("text_changed", callable_mp(this, &FindInFilesDialog::_on_search_text_modified));
_search_text_line_edit->connect("text_entered", callable_mp(this, &FindInFilesDialog::_on_search_text_entered));
gc->add_child(_search_text_line_edit);
@@ -329,7 +329,7 @@ FindInFilesDialog::FindInFilesDialog() {
gc->add_child(_replace_label);
_replace_text_line_edit = memnew(LineEdit);
- _replace_text_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ _replace_text_line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
_replace_text_line_edit->connect("text_entered", callable_mp(this, &FindInFilesDialog::_on_replace_text_entered));
_replace_text_line_edit->hide();
gc->add_child(_replace_text_line_edit);
@@ -362,7 +362,7 @@ FindInFilesDialog::FindInFilesDialog() {
hbc->add_child(prefix_label);
_folder_line_edit = memnew(LineEdit);
- _folder_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ _folder_line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(_folder_line_edit);
Button *folder_button = memnew(Button);
@@ -371,7 +371,7 @@ FindInFilesDialog::FindInFilesDialog() {
hbc->add_child(folder_button);
_folder_dialog = memnew(FileDialog);
- _folder_dialog->set_mode(FileDialog::MODE_OPEN_DIR);
+ _folder_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR);
_folder_dialog->connect("dir_selected", callable_mp(this, &FindInFilesDialog::_on_folder_selected));
add_child(_folder_dialog);
@@ -464,6 +464,7 @@ Set<String> FindInFilesDialog::get_filter() const {
void FindInFilesDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+
if (is_visible()) {
// Doesn't work more than once if not deferred...
_search_text_line_edit->call_deferred("grab_focus");
@@ -576,7 +577,7 @@ FindInFilesPanel::FindInFilesPanel() {
hbc->add_child(find_label);
_search_text_label = memnew(Label);
- _search_text_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
+ _search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts"));
hbc->add_child(_search_text_label);
_progress_bar = memnew(ProgressBar);
@@ -604,7 +605,7 @@ FindInFilesPanel::FindInFilesPanel() {
}
_results_display = memnew(Tree);
- _results_display->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
+ _results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts"));
_results_display->set_v_size_flags(SIZE_EXPAND_FILL);
_results_display->connect("item_selected", callable_mp(this, &FindInFilesPanel::_on_result_selected));
_results_display->connect("item_edited", callable_mp(this, &FindInFilesPanel::_on_item_edited));
@@ -734,7 +735,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
item->set_text(text_index, item_text);
item->set_custom_draw(text_index, this, "_draw_result_text");
- Ref<Font> font = _results_display->get_font("font");
+ Ref<Font> font = _results_display->get_theme_font("font");
float raw_text_width = font->get_string_size(text).x;
float item_text_width = font->get_string_size(item_text).x;
@@ -780,11 +781,11 @@ void FindInFilesPanel::_on_item_edited() {
TreeItem *item = _results_display->get_selected();
if (item->is_checked(0)) {
- item->set_custom_color(1, _results_display->get_color("font_color"));
+ item->set_custom_color(1, _results_display->get_theme_color("font_color"));
} else {
// Grey out
- Color color = _results_display->get_color("font_color");
+ Color color = _results_display->get_theme_color("font_color");
color.a /= 2.0;
item->set_custom_color(1, color);
}
diff --git a/editor/find_in_files.h b/editor/find_in_files.h
index 7002f750b7..41adb156b6 100644
--- a/editor/find_in_files.h
+++ b/editor/find_in_files.h
@@ -120,10 +120,11 @@ public:
Set<String> get_filter() const;
protected:
- static void _bind_methods();
-
void _notification(int p_what);
+
+ void _visibility_changed();
void custom_action(const String &p_action);
+ static void _bind_methods();
private:
void _on_folder_button_pressed();
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index b4c9a01f2a..686ca869a6 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -94,7 +94,7 @@ void GroupDialog::_load_nodes(Node *p_current) {
if (!_can_edit(p_current, selected_group)) {
node->set_selectable(0, false);
- node->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ node->set_custom_color(0, groups->get_theme_color("disabled_font_color", "Editor"));
}
}
@@ -204,7 +204,7 @@ void GroupDialog::_add_group(String p_name) {
TreeItem *new_group = groups->create_item(groups_root);
new_group->set_text(0, name);
- new_group->add_button(0, get_icon("Remove", "EditorIcons"), 0);
+ new_group->add_button(0, groups->get_theme_icon("Remove", "EditorIcons"), 0);
new_group->set_editable(0, true);
new_group->select(0);
groups->ensure_cursor_is_visible();
@@ -361,12 +361,12 @@ void GroupDialog::_delete_group_item(const String &p_name) {
void GroupDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- add_button->set_icon(get_icon("Forward", "EditorIcons"));
- remove_button->set_icon(get_icon("Back", "EditorIcons"));
+ add_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons"));
+ remove_button->set_icon(groups->get_theme_icon("Back", "EditorIcons"));
- add_filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ add_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons"));
add_filter->set_clear_button_enabled(true);
- remove_filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ remove_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons"));
remove_filter->set_clear_button_enabled(true);
} break;
}
@@ -399,21 +399,21 @@ void GroupDialog::_bind_methods() {
}
GroupDialog::GroupDialog() {
- set_custom_minimum_size(Size2(600, 400) * EDSCALE);
+ set_min_size(Size2(600, 400) * EDSCALE);
scene_tree = SceneTree::get_singleton();
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- vbc->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
+ vbc->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
HBoxContainer *hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
- hbc->set_v_size_flags(SIZE_EXPAND_FILL);
+ hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
VBoxContainer *vbc_left = memnew(VBoxContainer);
hbc->add_child(vbc_left);
- vbc_left->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Label *group_title = memnew(Label);
group_title->set_text(TTR("Groups"));
@@ -425,19 +425,19 @@ GroupDialog::GroupDialog() {
groups->set_select_mode(Tree::SELECT_SINGLE);
groups->set_allow_reselect(true);
groups->set_allow_rmb_select(true);
- groups->set_v_size_flags(SIZE_EXPAND_FILL);
- groups->add_constant_override("draw_guides", 1);
+ groups->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ groups->add_theme_constant_override("draw_guides", 1);
groups->connect("item_selected", callable_mp(this, &GroupDialog::_group_selected));
groups->connect("button_pressed", callable_mp(this, &GroupDialog::_delete_group_pressed));
groups->connect("item_edited", callable_mp(this, &GroupDialog::_group_renamed));
HBoxContainer *chbc = memnew(HBoxContainer);
vbc_left->add_child(chbc);
- chbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ chbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_group_text = memnew(LineEdit);
chbc->add_child(add_group_text);
- add_group_text->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_group_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_group_text->connect("text_entered", callable_mp(this, &GroupDialog::_add_group_pressed));
Button *add_group_button = memnew(Button);
@@ -447,7 +447,7 @@ GroupDialog::GroupDialog() {
VBoxContainer *vbc_add = memnew(VBoxContainer);
hbc->add_child(vbc_add);
- vbc_add->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_add->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Label *out_of_group_title = memnew(Label);
out_of_group_title->set_text(TTR("Nodes Not in Group"));
@@ -458,23 +458,23 @@ GroupDialog::GroupDialog() {
nodes_to_add->set_hide_root(true);
nodes_to_add->set_hide_folding(true);
nodes_to_add->set_select_mode(Tree::SELECT_MULTI);
- nodes_to_add->set_v_size_flags(SIZE_EXPAND_FILL);
- nodes_to_add->add_constant_override("draw_guides", 1);
+ nodes_to_add->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ nodes_to_add->add_theme_constant_override("draw_guides", 1);
HBoxContainer *add_filter_hbc = memnew(HBoxContainer);
- add_filter_hbc->add_constant_override("separate", 0);
+ add_filter_hbc->add_theme_constant_override("separate", 0);
vbc_add->add_child(add_filter_hbc);
add_filter = memnew(LineEdit);
- add_filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_filter->set_placeholder(TTR("Filter nodes"));
add_filter_hbc->add_child(add_filter);
add_filter->connect("text_changed", callable_mp(this, &GroupDialog::_add_filter_changed));
VBoxContainer *vbc_buttons = memnew(VBoxContainer);
hbc->add_child(vbc_buttons);
- vbc_buttons->set_h_size_flags(SIZE_SHRINK_CENTER);
- vbc_buttons->set_v_size_flags(SIZE_SHRINK_CENTER);
+ vbc_buttons->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
+ vbc_buttons->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
add_button = memnew(ToolButton);
add_button->set_text(TTR("Add"));
@@ -493,7 +493,7 @@ GroupDialog::GroupDialog() {
VBoxContainer *vbc_remove = memnew(VBoxContainer);
hbc->add_child(vbc_remove);
- vbc_remove->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_remove->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Label *in_group_title = memnew(Label);
in_group_title->set_text(TTR("Nodes in Group"));
@@ -501,18 +501,18 @@ GroupDialog::GroupDialog() {
nodes_to_remove = memnew(Tree);
vbc_remove->add_child(nodes_to_remove);
- nodes_to_remove->set_v_size_flags(SIZE_EXPAND_FILL);
+ nodes_to_remove->set_v_size_flags(Control::SIZE_EXPAND_FILL);
nodes_to_remove->set_hide_root(true);
nodes_to_remove->set_hide_folding(true);
nodes_to_remove->set_select_mode(Tree::SELECT_MULTI);
- nodes_to_remove->add_constant_override("draw_guides", 1);
+ nodes_to_remove->add_theme_constant_override("draw_guides", 1);
HBoxContainer *remove_filter_hbc = memnew(HBoxContainer);
- remove_filter_hbc->add_constant_override("separate", 0);
+ remove_filter_hbc->add_theme_constant_override("separate", 0);
vbc_remove->add_child(remove_filter_hbc);
remove_filter = memnew(LineEdit);
- remove_filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ remove_filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
remove_filter->set_placeholder(TTR("Filter nodes"));
remove_filter_hbc->add_child(remove_filter);
remove_filter->connect("text_changed", callable_mp(this, &GroupDialog::_remove_filter_changed));
@@ -524,11 +524,9 @@ GroupDialog::GroupDialog() {
group_empty->set_autowrap(true);
group_empty->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
nodes_to_remove->add_child(group_empty);
- group_empty->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
+ group_empty->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
set_title(TTR("Group Editor"));
- set_as_toplevel(true);
- set_resizable(true);
error = memnew(ConfirmationDialog);
add_child(error);
@@ -639,7 +637,7 @@ void GroupsEditor::update_tree() {
TreeItem *item = tree->create_item(root);
item->set_text(0, gi.name);
if (can_be_deleted) {
- item->add_button(0, get_icon("Remove", "EditorIcons"), 0);
+ item->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0);
} else {
item->set_selectable(0, false);
}
@@ -669,7 +667,7 @@ GroupsEditor::GroupsEditor() {
VBoxContainer *vbc = this;
group_dialog = memnew(GroupDialog);
- group_dialog->set_as_toplevel(true);
+
add_child(group_dialog);
group_dialog->connect("group_edited", callable_mp(this, &GroupsEditor::update_tree));
@@ -682,7 +680,7 @@ GroupsEditor::GroupsEditor() {
vbc->add_child(hbc);
group_name = memnew(LineEdit);
- group_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ group_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(group_name);
group_name->connect("text_entered", callable_mp(this, &GroupsEditor::_add_group));
@@ -693,11 +691,11 @@ GroupsEditor::GroupsEditor() {
tree = memnew(Tree);
tree->set_hide_root(true);
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(tree);
tree->connect("button_pressed", callable_mp(this, &GroupsEditor::_remove_group));
- tree->add_constant_override("draw_guides", 1);
- add_constant_override("separation", 3 * EDSCALE);
+ tree->add_theme_constant_override("draw_guides", 1);
+ add_theme_constant_override("separation", 3 * EDSCALE);
}
GroupsEditor::~GroupsEditor() {
diff --git a/editor/groups_editor.h b/editor/groups_editor.h
index 84c653bdea..40c7b3c75a 100644
--- a/editor/groups_editor.h
+++ b/editor/groups_editor.h
@@ -41,9 +41,9 @@
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
-class GroupDialog : public WindowDialog {
+class GroupDialog : public AcceptDialog {
- GDCLASS(GroupDialog, WindowDialog);
+ GDCLASS(GroupDialog, AcceptDialog);
ConfirmationDialog *error;
diff --git a/editor/icons/AnimatedSprite.svg b/editor/icons/AnimatedSprite2D.svg
index 411ddda015..411ddda015 100644
--- a/editor/icons/AnimatedSprite.svg
+++ b/editor/icons/AnimatedSprite2D.svg
diff --git a/editor/icons/Area.svg b/editor/icons/Area3D.svg
index 21ebe3c251..21ebe3c251 100644
--- a/editor/icons/Area.svg
+++ b/editor/icons/Area3D.svg
diff --git a/editor/icons/BoneAttachment.svg b/editor/icons/BoneAttachment3D.svg
index 0b7dede0b6..0b7dede0b6 100644
--- a/editor/icons/BoneAttachment.svg
+++ b/editor/icons/BoneAttachment3D.svg
diff --git a/editor/icons/BoxShape.svg b/editor/icons/BoxShape3D.svg
index 171e95f4fa..171e95f4fa 100644
--- a/editor/icons/BoxShape.svg
+++ b/editor/icons/BoxShape3D.svg
diff --git a/editor/icons/CPUParticles.svg b/editor/icons/CPUParticles3D.svg
index af4115c93f..af4115c93f 100644
--- a/editor/icons/CPUParticles.svg
+++ b/editor/icons/CPUParticles3D.svg
diff --git a/editor/icons/Camera.svg b/editor/icons/Camera3D.svg
index af1cb8a2e9..af1cb8a2e9 100644
--- a/editor/icons/Camera.svg
+++ b/editor/icons/Camera3D.svg
diff --git a/editor/icons/CapsuleShape.svg b/editor/icons/CapsuleShape3D.svg
index ba035ca196..ba035ca196 100644
--- a/editor/icons/CapsuleShape.svg
+++ b/editor/icons/CapsuleShape3D.svg
diff --git a/editor/icons/ClippedCamera.svg b/editor/icons/ClippedCamera3D.svg
index 8c80c04e27..8c80c04e27 100644
--- a/editor/icons/ClippedCamera.svg
+++ b/editor/icons/ClippedCamera3D.svg
diff --git a/editor/icons/CollisionPolygon.svg b/editor/icons/CollisionPolygon3D.svg
index 5e849ae4e3..5e849ae4e3 100644
--- a/editor/icons/CollisionPolygon.svg
+++ b/editor/icons/CollisionPolygon3D.svg
diff --git a/editor/icons/CollisionShape.svg b/editor/icons/CollisionShape3D.svg
index 8f14996a97..8f14996a97 100644
--- a/editor/icons/CollisionShape.svg
+++ b/editor/icons/CollisionShape3D.svg
diff --git a/editor/icons/ConcavePolygonShape.svg b/editor/icons/ConcavePolygonShape3D.svg
index 001ab82826..001ab82826 100644
--- a/editor/icons/ConcavePolygonShape.svg
+++ b/editor/icons/ConcavePolygonShape3D.svg
diff --git a/editor/icons/ConeTwistJoint.svg b/editor/icons/ConeTwistJoint3D.svg
index 0e5e98a17b..0e5e98a17b 100644
--- a/editor/icons/ConeTwistJoint.svg
+++ b/editor/icons/ConeTwistJoint3D.svg
diff --git a/editor/icons/ConvexPolygonShape.svg b/editor/icons/ConvexPolygonShape3D.svg
index bfb9230586..bfb9230586 100644
--- a/editor/icons/ConvexPolygonShape.svg
+++ b/editor/icons/ConvexPolygonShape3D.svg
diff --git a/editor/icons/CylinderShape.svg b/editor/icons/CylinderShape3D.svg
index f0aa5833d2..f0aa5833d2 100644
--- a/editor/icons/CylinderShape.svg
+++ b/editor/icons/CylinderShape3D.svg
diff --git a/editor/icons/DirectionalLight.svg b/editor/icons/DirectionalLight3D.svg
index faac2be134..faac2be134 100644
--- a/editor/icons/DirectionalLight.svg
+++ b/editor/icons/DirectionalLight3D.svg
diff --git a/editor/icons/Particles2D.svg b/editor/icons/GPUParticles2D.svg
index 7151194e36..7151194e36 100644
--- a/editor/icons/Particles2D.svg
+++ b/editor/icons/GPUParticles2D.svg
diff --git a/editor/icons/Particles.svg b/editor/icons/GPUParticles3D.svg
index f1378e3f8c..f1378e3f8c 100644
--- a/editor/icons/Particles.svg
+++ b/editor/icons/GPUParticles3D.svg
diff --git a/editor/icons/Generic6DOFJoint.svg b/editor/icons/Generic6DOFJoint3D.svg
index 30d892e7a1..30d892e7a1 100644
--- a/editor/icons/Generic6DOFJoint.svg
+++ b/editor/icons/Generic6DOFJoint3D.svg
diff --git a/editor/icons/GizmoSpatialSamplePlayer.svg b/editor/icons/Gizmo3DSamplePlayer.svg
index ee471124dc..ee471124dc 100644
--- a/editor/icons/GizmoSpatialSamplePlayer.svg
+++ b/editor/icons/Gizmo3DSamplePlayer.svg
diff --git a/editor/icons/HeightMapShape.svg b/editor/icons/HeightMapShape3D.svg
index 2e0bf53565..2e0bf53565 100644
--- a/editor/icons/HeightMapShape.svg
+++ b/editor/icons/HeightMapShape3D.svg
diff --git a/editor/icons/HingeJoint.svg b/editor/icons/HingeJoint3D.svg
index 21b3e29cb5..21b3e29cb5 100644
--- a/editor/icons/HingeJoint.svg
+++ b/editor/icons/HingeJoint3D.svg
diff --git a/editor/icons/ImmediateGeometry.svg b/editor/icons/ImmediateGeometry3D.svg
index 5679d5906f..5679d5906f 100644
--- a/editor/icons/ImmediateGeometry.svg
+++ b/editor/icons/ImmediateGeometry3D.svg
diff --git a/editor/icons/KinematicBody.svg b/editor/icons/KinematicBody3D.svg
index 16078fbdec..16078fbdec 100644
--- a/editor/icons/KinematicBody.svg
+++ b/editor/icons/KinematicBody3D.svg
diff --git a/editor/icons/Listener.svg b/editor/icons/Listener3D.svg
index 96eaeaffa9..96eaeaffa9 100644
--- a/editor/icons/Listener.svg
+++ b/editor/icons/Listener3D.svg
diff --git a/editor/icons/MeshInstance.svg b/editor/icons/MeshInstance3D.svg
index 68344b7dbd..68344b7dbd 100644
--- a/editor/icons/MeshInstance.svg
+++ b/editor/icons/MeshInstance3D.svg
diff --git a/editor/icons/MultiMeshInstance.svg b/editor/icons/MultiMeshInstance3D.svg
index c114a725db..c114a725db 100644
--- a/editor/icons/MultiMeshInstance.svg
+++ b/editor/icons/MultiMeshInstance3D.svg
diff --git a/editor/icons/Navigation.svg b/editor/icons/Navigation3D.svg
index d5a8f8618b..d5a8f8618b 100644
--- a/editor/icons/Navigation.svg
+++ b/editor/icons/Navigation3D.svg
diff --git a/editor/icons/NavigationAgent.svg b/editor/icons/NavigationAgent3D.svg
index 44c991d44c..44c991d44c 100644
--- a/editor/icons/NavigationAgent.svg
+++ b/editor/icons/NavigationAgent3D.svg
diff --git a/editor/icons/NavigationObstacle.svg b/editor/icons/NavigationObstacle3D.svg
index 42481a6067..42481a6067 100644
--- a/editor/icons/NavigationObstacle.svg
+++ b/editor/icons/NavigationObstacle3D.svg
diff --git a/editor/icons/NavigationRegion.svg b/editor/icons/NavigationRegion3D.svg
index 61f43497b4..61f43497b4 100644
--- a/editor/icons/NavigationRegion.svg
+++ b/editor/icons/NavigationRegion3D.svg
diff --git a/editor/icons/Spatial.svg b/editor/icons/Node3D.svg
index 6a469dde13..6a469dde13 100644
--- a/editor/icons/Spatial.svg
+++ b/editor/icons/Node3D.svg
diff --git a/editor/icons/OmniLight.svg b/editor/icons/OmniLight3D.svg
index 6fa0454e8c..6fa0454e8c 100644
--- a/editor/icons/OmniLight.svg
+++ b/editor/icons/OmniLight3D.svg
diff --git a/editor/icons/Path.svg b/editor/icons/Path3D.svg
index cde9a06903..cde9a06903 100644
--- a/editor/icons/Path.svg
+++ b/editor/icons/Path3D.svg
diff --git a/editor/icons/PathFollow.svg b/editor/icons/PathFollow3D.svg
index 8e904ab5a5..8e904ab5a5 100644
--- a/editor/icons/PathFollow.svg
+++ b/editor/icons/PathFollow3D.svg
diff --git a/editor/icons/PhysicalBone.svg b/editor/icons/PhysicalBone3D.svg
index 0a34eb6e48..0a34eb6e48 100644
--- a/editor/icons/PhysicalBone.svg
+++ b/editor/icons/PhysicalBone3D.svg
diff --git a/editor/icons/PinJoint.svg b/editor/icons/PinJoint3D.svg
index 147553d316..147553d316 100644
--- a/editor/icons/PinJoint.svg
+++ b/editor/icons/PinJoint3D.svg
diff --git a/editor/icons/ProximityGroup.svg b/editor/icons/ProximityGroup3D.svg
index 7df1cc9093..7df1cc9093 100644
--- a/editor/icons/ProximityGroup.svg
+++ b/editor/icons/ProximityGroup3D.svg
diff --git a/editor/icons/RayCast.svg b/editor/icons/RayCast3D.svg
index e782b27e9f..e782b27e9f 100644
--- a/editor/icons/RayCast.svg
+++ b/editor/icons/RayCast3D.svg
diff --git a/editor/icons/RayShape.svg b/editor/icons/RayShape3D.svg
index 37c2206740..37c2206740 100644
--- a/editor/icons/RayShape.svg
+++ b/editor/icons/RayShape3D.svg
diff --git a/editor/icons/RemoteTransform.svg b/editor/icons/RemoteTransform3D.svg
index 2bdf8cd858..2bdf8cd858 100644
--- a/editor/icons/RemoteTransform.svg
+++ b/editor/icons/RemoteTransform3D.svg
diff --git a/editor/icons/RigidBody.svg b/editor/icons/RigidBody3D.svg
index 5d766f7c3d..5d766f7c3d 100644
--- a/editor/icons/RigidBody.svg
+++ b/editor/icons/RigidBody3D.svg
diff --git a/editor/icons/Skeleton.svg b/editor/icons/Skeleton3D.svg
index 015c842125..015c842125 100644
--- a/editor/icons/Skeleton.svg
+++ b/editor/icons/Skeleton3D.svg
diff --git a/editor/icons/SkeletonIK.svg b/editor/icons/SkeletonIK3D.svg
index e69f6e8bf3..e69f6e8bf3 100644
--- a/editor/icons/SkeletonIK.svg
+++ b/editor/icons/SkeletonIK3D.svg
diff --git a/editor/icons/SliderJoint.svg b/editor/icons/SliderJoint3D.svg
index fdd7487bbf..fdd7487bbf 100644
--- a/editor/icons/SliderJoint.svg
+++ b/editor/icons/SliderJoint3D.svg
diff --git a/editor/icons/SoftBody.svg b/editor/icons/SoftBody3D.svg
index 2c907df847..2c907df847 100644
--- a/editor/icons/SoftBody.svg
+++ b/editor/icons/SoftBody3D.svg
diff --git a/editor/icons/SpatialMaterial.svg b/editor/icons/SpatialMaterial.svg
deleted file mode 100644
index cfd994a0fe..0000000000
--- a/editor/icons/SpatialMaterial.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.9629 1.002a1.0001 1.0001 0 0 0 -.41016.10352l-3.7891 1.8945h8.4727l-3.7891-1.8945a1.0001 1.0001 0 0 0 -.48438-.10352z" fill="#ff7070"/><path d="m3.7637 3-2.2109 1.1055a1.0001 1.0001 0 0 0 -.55273.89453h3.2363l3.7637-1.8809 3.7637 1.8809h3.2363a1.0001 1.0001 0 0 0 -.55273-.89453l-2.2109-1.1055h-8.4727z" fill="#ffeb70"/><path d="m1 5v2h2v-.38086l.76172.38086h8.4766l.76172-.38086v.38086h2v-2h-3.2363l-3.7637 1.8828-3.7637-1.8828h-3.2363z" fill="#9dff70"/><path d="m1 7v2h2v-2zm2.7617 0 3.2383 1.6191v.38086h2v-.38086l3.2383-1.6191zm9.2383 0v2h2v-2z" fill="#70ffb9"/><path d="m1 9v2h3.2344l-1.2344-.61719v-1.3828h-2zm6 0v2h2v-2zm6 0v1.3828l-1.2344.61719h3.2344v-2h-2z" fill="#70deff"/><path d="m3.7637 13 3.7891 1.8945a1.0001 1.0001 0 0 0 .48438.10547 1.0001 1.0001 0 0 0 .41016-.10547l3.7891-1.8945h-8.4727z" fill="#ff70ac"/><path d="m1 11a1.0001 1.0001 0 0 0 .55273.89453l2.2109 1.1055h8.4727l2.2109-1.1055a1.0001 1.0001 0 0 0 .55273-.89453h-3.2344l-2.7656 1.3828v-1.3828h-2v1.3828l-2.7656-1.3828h-3.2344z" fill="#9f70ff"/></svg> \ No newline at end of file
diff --git a/editor/icons/SphereShape.svg b/editor/icons/SphereShape3D.svg
index 4da18a1a38..4da18a1a38 100644
--- a/editor/icons/SphereShape.svg
+++ b/editor/icons/SphereShape3D.svg
diff --git a/editor/icons/SpotLight.svg b/editor/icons/SpotLight3D.svg
index 6a35ee3890..6a35ee3890 100644
--- a/editor/icons/SpotLight.svg
+++ b/editor/icons/SpotLight3D.svg
diff --git a/editor/icons/SpringArm.svg b/editor/icons/SpringArm3D.svg
index eb0c1ebd7d..eb0c1ebd7d 100644
--- a/editor/icons/SpringArm.svg
+++ b/editor/icons/SpringArm3D.svg
diff --git a/editor/icons/Sprite.svg b/editor/icons/Sprite2D.svg
index 26a10625fc..26a10625fc 100644
--- a/editor/icons/Sprite.svg
+++ b/editor/icons/Sprite2D.svg
diff --git a/editor/icons/StaticBody.svg b/editor/icons/StaticBody3D.svg
index de819bd76b..de819bd76b 100644
--- a/editor/icons/StaticBody.svg
+++ b/editor/icons/StaticBody3D.svg
diff --git a/editor/icons/VehicleBody.svg b/editor/icons/VehicleBody3D.svg
index a509730602..a509730602 100644
--- a/editor/icons/VehicleBody.svg
+++ b/editor/icons/VehicleBody3D.svg
diff --git a/editor/icons/VehicleWheel.svg b/editor/icons/VehicleWheel3D.svg
index bd870c0118..bd870c0118 100644
--- a/editor/icons/VehicleWheel.svg
+++ b/editor/icons/VehicleWheel3D.svg
diff --git a/editor/icons/VisibilityEnabler.svg b/editor/icons/VisibilityEnabler3D.svg
index 70e4f081c2..70e4f081c2 100644
--- a/editor/icons/VisibilityEnabler.svg
+++ b/editor/icons/VisibilityEnabler3D.svg
diff --git a/editor/icons/VisibilityNotifier.svg b/editor/icons/VisibilityNotifier3D.svg
index c908d5c99d..c908d5c99d 100644
--- a/editor/icons/VisibilityNotifier.svg
+++ b/editor/icons/VisibilityNotifier3D.svg
diff --git a/editor/icons/World.svg b/editor/icons/World3D.svg
index 3db96a75a6..3db96a75a6 100644
--- a/editor/icons/World.svg
+++ b/editor/icons/World3D.svg
diff --git a/editor/icons/WorldMarginShape.svg b/editor/icons/WorldMarginShape.svg
deleted file mode 100644
index 2c90cf6d53..0000000000
--- a/editor/icons/WorldMarginShape.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1044.4 7 3 7-3-7-3z" fill="#a2d2ff" fill-rule="evenodd" transform="translate(0 -1036.4)"/></svg> \ No newline at end of file
diff --git a/editor/icons/PlaneShape.svg b/editor/icons/WorldMarginShape3D.svg
index 2c90cf6d53..2c90cf6d53 100644
--- a/editor/icons/PlaneShape.svg
+++ b/editor/icons/WorldMarginShape3D.svg
diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py
index ea2c2e57d1..a00f21c265 100644
--- a/editor/icons/editor_icons_builders.py
+++ b/editor/icons/editor_icons_builders.py
@@ -3,9 +3,10 @@
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
"""
+
import os
+from io import StringIO
from platform_methods import subprocess_main
-from compat import StringIO
def make_editor_icons_action(target, source, env):
diff --git a/editor/collada/collada.cpp b/editor/import/collada.cpp
index 8ef9d17083..8ef9d17083 100644
--- a/editor/collada/collada.cpp
+++ b/editor/import/collada.cpp
diff --git a/editor/collada/collada.h b/editor/import/collada.h
index 4707d7d779..4707d7d779 100644
--- a/editor/collada/collada.h
+++ b/editor/import/collada.h
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 3cc6e7a50c..6c089d7020 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -31,14 +31,14 @@
#include "editor_import_collada.h"
#include "core/os/os.h"
-#include "editor/collada/collada.h"
#include "editor/editor_node.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/light.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/path.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "editor/import/collada.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/path_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/packed_scene.h"
@@ -47,13 +47,13 @@
struct ColladaImport {
Collada collada;
- Spatial *scene;
+ Node3D *scene;
Vector<Ref<Animation>> animations;
struct NodeMap {
//String path;
- Spatial *node;
+ Node3D *node;
int bone;
List<int> anim_tracks;
@@ -76,17 +76,17 @@ struct ColladaImport {
Map<String, Ref<ArrayMesh>> mesh_cache;
Map<String, Ref<Curve3D>> curve_cache;
Map<String, Ref<Material>> material_cache;
- Map<Collada::Node *, Skeleton *> skeleton_map;
+ Map<Collada::Node *, Skeleton3D *> skeleton_map;
- Map<Skeleton *, Map<String, int>> skeleton_bone_map;
+ Map<Skeleton3D *, Map<String, int>> skeleton_bone_map;
Set<String> valid_animated_nodes;
Vector<int> valid_animated_properties;
Map<String, bool> bones_with_animation;
- Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
+ Error _populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
Error _create_scene_skeletons(Collada::Node *p_node);
- Error _create_scene(Collada::Node *p_node, Spatial *p_parent);
+ Error _create_scene(Collada::Node *p_node, Node3D *p_parent);
Error _create_resources(Collada::Node *p_node, bool p_use_compression);
Error _create_material(const String &p_target);
Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes = Vector<Ref<ArrayMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false);
@@ -110,7 +110,7 @@ struct ColladaImport {
}
};
-Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {
+Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {
if (p_node->type != Collada::Node::TYPE_JOINT)
return OK;
@@ -174,7 +174,7 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
if (p_node->type == Collada::Node::TYPE_SKELETON) {
- Skeleton *sk = memnew(Skeleton);
+ Skeleton3D *sk = memnew(Skeleton3D);
int bone = 0;
for (int i = 0; i < p_node->children.size(); i++) {
@@ -193,15 +193,15 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
return OK;
}
-Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
+Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
- Spatial *node = NULL;
+ Node3D *node = NULL;
switch (p_node->type) {
case Collada::Node::TYPE_NODE: {
- node = memnew(Spatial);
+ node = memnew(Node3D);
} break;
case Collada::Node::TYPE_JOINT: {
@@ -223,7 +223,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (!bool(GLOBAL_DEF("collada/use_ambient", false)))
return OK;
//well, it's an ambient light..
- Light *l = memnew(DirectionalLight);
+ Light3D *l = memnew(DirectionalLight3D);
//l->set_color(Light::COLOR_AMBIENT,ld.color);
//l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0));
//l->set_color(Light::COLOR_SPECULAR,Color(0,0,0));
@@ -232,7 +232,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) {
//well, it's an ambient light..
- Light *l = memnew(DirectionalLight);
+ Light3D *l = memnew(DirectionalLight3D);
/*
if (found_ambient) //use it here
l->set_color(Light::COLOR_AMBIENT,ambient);
@@ -243,12 +243,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
node = l;
} else {
- Light *l;
+ Light3D *l;
if (ld.mode == Collada::LightData::MODE_OMNI)
- l = memnew(OmniLight);
+ l = memnew(OmniLight3D);
else {
- l = memnew(SpotLight);
+ l = memnew(SpotLight3D);
//l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle);
//l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp);
}
@@ -262,13 +262,13 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else {
- node = memnew(Spatial);
+ node = memnew(Node3D);
}
} break;
case Collada::Node::TYPE_CAMERA: {
Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node);
- Camera *camera = memnew(Camera);
+ Camera3D *camera = memnew(Camera3D);
if (collada.state.camera_data_map.has(cam->camera)) {
@@ -280,12 +280,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (cd.orthogonal.y_mag) {
- camera->set_keep_aspect_mode(Camera::KEEP_HEIGHT);
+ camera->set_keep_aspect_mode(Camera3D::KEEP_HEIGHT);
camera->set_orthogonal(cd.orthogonal.y_mag * 2.0, cd.z_near, cd.z_far);
} else if (!cd.orthogonal.y_mag && cd.orthogonal.x_mag) {
- camera->set_keep_aspect_mode(Camera::KEEP_WIDTH);
+ camera->set_keep_aspect_mode(Camera3D::KEEP_WIDTH);
camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far);
}
@@ -314,17 +314,17 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (collada.state.curve_data_map.has(ng->source)) {
- node = memnew(Path);
+ node = memnew(Path3D);
} else {
//mesh since nothing else
- node = memnew(MeshInstance);
+ node = memnew(MeshInstance3D);
//Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
}
} break;
case Collada::Node::TYPE_SKELETON: {
ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE);
- Skeleton *sk = skeleton_map[p_node];
+ Skeleton3D *sk = skeleton_map[p_node];
node = sk;
} break;
}
@@ -922,10 +922,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
if (has_weights) {
Vector<float> weights;
Vector<int> bones;
- weights.resize(VS::ARRAY_WEIGHTS_SIZE);
- bones.resize(VS::ARRAY_WEIGHTS_SIZE);
+ weights.resize(RS::ARRAY_WEIGHTS_SIZE);
+ bones.resize(RS::ARRAY_WEIGHTS_SIZE);
//float sum=0.0;
- for (int l = 0; l < VS::ARRAY_WEIGHTS_SIZE; l++) {
+ for (int l = 0; l < RS::ARRAY_WEIGHTS_SIZE; l++) {
if (l < vertex_array[k].weights.size()) {
weights.write[l] = vertex_array[k].weights[l].weight;
bones.write[l] = vertex_array[k].weights[l].bone_idx;
@@ -963,7 +963,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
////////////////////////////
Array d = surftool->commit_to_arrays();
- d.resize(VS::ARRAY_MAX);
+ d.resize(RS::ARRAY_MAX);
Array mr;
@@ -1010,12 +1010,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
- Spatial *node = node_map[p_node->id].node;
+ Node3D *node = node_map[p_node->id].node;
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
- if (Object::cast_to<Path>(node)) {
+ if (Object::cast_to<Path3D>(node)) {
- Path *path = Object::cast_to<Path>(node);
+ Path3D *path = Object::cast_to<Path3D>(node);
if (curve_cache.has(ng->source)) {
@@ -1083,11 +1083,11 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
}
}
- if (Object::cast_to<MeshInstance>(node)) {
+ if (Object::cast_to<MeshInstance3D>(node)) {
Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node);
- MeshInstance *mi = Object::cast_to<MeshInstance>(node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node);
ERR_FAIL_COND_V(!mi, ERR_BUG);
@@ -1114,7 +1114,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
String skname = skeletons[0];
ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA);
NodeMap nmsk = node_map[skname];
- Skeleton *sk = Object::cast_to<Skeleton>(nmsk.node);
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(nmsk.node);
ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA);
ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA);
Map<String, int> &bone_remap_map = skeleton_bone_map[sk];
@@ -1265,7 +1265,7 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA);
Collada::VisualScene &vs = collada.state.visual_scene_map[collada.state.root_visual_scene];
- scene = memnew(Spatial); // root
+ scene = memnew(Node3D); // root
//determine what's going on with the lights
for (int i = 0; i < vs.root_nodes.size(); i++) {
@@ -1530,7 +1530,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
String path = scene->get_path_to(nm.node);
if (nm.bone >= 0) {
- Skeleton *sk = static_cast<Skeleton *>(nm.node);
+ Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node);
String name = sk->get_bone_name(nm.bone);
path = path + ":" + name;
}
@@ -1621,7 +1621,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (nm.bone >= 0) {
//make bone transform relative to rest (in case of skeleton)
- Skeleton *sk = Object::cast_to<Skeleton>(nm.node);
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(nm.node);
if (sk) {
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;
@@ -1662,7 +1662,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
NodeMap &nm = node_map[E->key()];
String path = scene->get_path_to(nm.node);
ERR_CONTINUE(nm.bone < 0);
- Skeleton *sk = static_cast<Skeleton *>(nm.node);
+ Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node);
String name = sk->get_bone_name(nm.bone);
path = path + ":" + name;
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 398fc9ff49..208dc8fc26 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -37,9 +37,9 @@
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "modules/regex/regex.h"
-#include "scene/3d/bone_attachment.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/bone_attachment_3d.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/surface_tool.h"
@@ -2108,7 +2108,7 @@ Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) {
GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i];
- Skeleton *skeleton = memnew(Skeleton);
+ Skeleton3D *skeleton = memnew(Skeleton3D);
gltf_skeleton.godot_skeleton = skeleton;
// Make a unique name, no gltf node represents this skeleton
@@ -2485,12 +2485,12 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) {
}
}
-BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index) {
+BoneAttachment3D *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
const GLTFNode *bone_node = state.nodes[gltf_node->parent];
- BoneAttachment *bone_attachment = memnew(BoneAttachment);
+ BoneAttachment3D *bone_attachment = memnew(BoneAttachment3D);
print_verbose("glTF: Creating bone attachment for: " + gltf_node->name);
ERR_FAIL_COND_V(!bone_node->joint, nullptr);
@@ -2500,12 +2500,12 @@ BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &st
return bone_attachment;
}
-MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
+MeshInstance3D *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
ERR_FAIL_INDEX_V(gltf_node->mesh, state.meshes.size(), nullptr);
- MeshInstance *mi = memnew(MeshInstance);
+ MeshInstance3D *mi = memnew(MeshInstance3D);
print_verbose("glTF: Creating mesh for: " + gltf_node->name);
GLTFMesh &mesh = state.meshes.write[gltf_node->mesh];
@@ -2522,12 +2522,12 @@ MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state,
return mi;
}
-Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
+Camera3D *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
ERR_FAIL_INDEX_V(gltf_node->camera, state.cameras.size(), nullptr);
- Camera *camera = memnew(Camera);
+ Camera3D *camera = memnew(Camera3D);
print_verbose("glTF: Creating camera for: " + gltf_node->name);
const GLTFCamera &c = state.cameras[gltf_node->camera];
@@ -2540,26 +2540,26 @@ Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_
return camera;
}
-Spatial *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
+Node3D *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
- Spatial *spatial = memnew(Spatial);
+ Node3D *spatial = memnew(Node3D);
print_verbose("glTF: Creating spatial for: " + gltf_node->name);
return spatial;
}
-void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index) {
+void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
- Spatial *current_node = nullptr;
+ Node3D *current_node = nullptr;
// Is our parent a skeleton
- Skeleton *active_skeleton = Object::cast_to<Skeleton>(scene_parent);
+ Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(scene_parent);
if (gltf_node->skeleton >= 0) {
- Skeleton *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton;
+ Skeleton3D *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton;
if (active_skeleton != skeleton) {
ERR_FAIL_COND_MSG(active_skeleton != nullptr, "glTF: Generating scene detected direct parented Skeletons");
@@ -2577,7 +2577,7 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene
// If we have an active skeleton, and the node is node skinned, we need to create a bone attachment
if (current_node == nullptr && active_skeleton != nullptr && gltf_node->skin < 0) {
- BoneAttachment *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index);
+ BoneAttachment3D *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index);
scene_parent->add_child(bone_attachment);
bone_attachment->set_owner(scene_root);
@@ -2776,7 +2776,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
const GLTFNode *node = state.nodes[E->key()];
if (node->skeleton >= 0) {
- const Skeleton *sk = Object::cast_to<Skeleton>(state.scene_nodes.find(node_index)->get());
+ const Skeleton3D *sk = Object::cast_to<Skeleton3D>(state.scene_nodes.find(node_index)->get());
ERR_FAIL_COND(sk == nullptr);
const String path = ap->get_parent()->get_path_to(sk);
@@ -2853,7 +2853,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
xform.basis.set_quat_scale(rot, scale);
xform.origin = pos;
- const Skeleton *skeleton = state.skeletons[node->skeleton].godot_skeleton;
+ const Skeleton3D *skeleton = state.skeletons[node->skeleton].godot_skeleton;
const int bone_idx = skeleton->find_bone(node->name);
xform = skeleton->get_bone_rest(bone_idx).affine_inverse() * xform;
@@ -2922,7 +2922,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
ap->add_animation(name, animation);
}
-void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial *scene_root) {
+void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D *scene_root) {
for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) {
const GLTFNode *node = state.nodes[node_i];
@@ -2930,12 +2930,12 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial
const GLTFSkinIndex skin_i = node->skin;
Map<GLTFNodeIndex, Node *>::Element *mi_element = state.scene_nodes.find(node_i);
- MeshInstance *mi = Object::cast_to<MeshInstance>(mi_element->get());
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get());
ERR_FAIL_COND(mi == nullptr);
const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton;
const GLTFSkeleton &gltf_skeleton = state.skeletons[skel_i];
- Skeleton *skeleton = gltf_skeleton.godot_skeleton;
+ Skeleton3D *skeleton = gltf_skeleton.godot_skeleton;
ERR_FAIL_COND(skeleton == nullptr);
mi->get_parent()->remove_child(mi);
@@ -2949,9 +2949,9 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial
}
}
-Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) {
+Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) {
- Spatial *root = memnew(Spatial);
+ Node3D *root = memnew(Node3D);
// scene_name is already unique
root->set_name(state.scene_name);
@@ -3084,7 +3084,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla
_assign_scene_names(state);
/* STEP 17 MAKE SCENE! */
- Spatial *scene = _generate_scene(state, p_bake_fps);
+ Node3D *scene = _generate_scene(state, p_bake_fps);
return scene;
}
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
index 9f354fde2d..79395cca93 100644
--- a/editor/import/editor_scene_importer_gltf.h
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -32,12 +32,12 @@
#define EDITOR_SCENE_IMPORTER_GLTF_H
#include "editor/import/resource_importer_scene.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
class AnimationPlayer;
-class BoneAttachment;
-class MeshInstance;
+class BoneAttachment3D;
+class MeshInstance3D;
class EditorSceneImporterGLTF : public EditorSceneImporter {
@@ -192,7 +192,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<GLTFNodeIndex> roots;
// The created Skeleton for the scene
- Skeleton *godot_skeleton;
+ Skeleton3D *godot_skeleton;
// Set of unique bone names for the skeleton
Set<String> unique_names;
@@ -395,15 +395,15 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Error _parse_animations(GLTFState &state);
- BoneAttachment *_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index);
- MeshInstance *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
- Camera *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
- Spatial *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
+ BoneAttachment3D *_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index);
+ MeshInstance3D *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
+ Camera3D *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
+ Node3D *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
- void _generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index);
- Spatial *_generate_scene(GLTFState &state, const int p_bake_fps);
+ void _generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index);
+ Node3D *_generate_scene(GLTFState &state, const int p_bake_fps);
- void _process_mesh_instances(GLTFState &state, Spatial *scene_root);
+ void _process_mesh_instances(GLTFState &state, Node3D *scene_root);
void _assign_scene_names(GLTFState &state);
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index fb1782cb65..4be6f2ed80 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -32,8 +32,8 @@
#include "core/io/resource_saver.h"
#include "core/os/file_access.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/mesh.h"
#include "scene/resources/surface_tool.h"
@@ -431,11 +431,11 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
return NULL;
}
- Spatial *scene = memnew(Spatial);
+ Node3D *scene = memnew(Node3D);
for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) {
- MeshInstance *mi = memnew(MeshInstance);
+ MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(E->get());
mi->set_name(E->get()->get_name());
scene->add_child(mi);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 94a6fee6b7..fb57773b18 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -32,19 +32,19 @@
#include "core/io/resource_saver.h"
#include "editor/editor_node.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/navigation.h"
-#include "scene/3d/physics_body.h"
-#include "scene/3d/vehicle_body.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/navigation_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/3d/vehicle_body_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
-#include "scene/resources/box_shape.h"
+#include "scene/resources/box_shape_3d.h"
#include "scene/resources/packed_scene.h"
-#include "scene/resources/ray_shape.h"
+#include "scene/resources/ray_shape_3d.h"
#include "scene/resources/resource_format_text.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/world_margin_shape.h"
+#include "scene/resources/sphere_shape_3d.h"
+#include "scene/resources/world_margin_shape_3d.h"
uint32_t EditorSceneImporter::get_import_flags() const {
@@ -276,15 +276,15 @@ static String _fixstr(const String &p_what, const String &p_str) {
return what;
}
-static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape>> &r_shape_list, bool p_convex) {
+static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) {
if (!p_convex) {
- Ref<Shape> shape = mesh->create_trimesh_shape();
+ Ref<Shape3D> shape = mesh->create_trimesh_shape();
r_shape_list.push_back(shape);
} else {
- Vector<Ref<Shape>> cd = mesh->convex_decompose();
+ Vector<Ref<Shape3D>> cd = mesh->convex_decompose();
if (cd.size()) {
for (int i = 0; i < cd.size(); i++) {
r_shape_list.push_back(cd[i]);
@@ -293,7 +293,7 @@ static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape>> &r_shape_lis
}
}
-Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape>>> &collision_map, LightBakeMode p_light_bake_mode) {
+Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode) {
// children first
for (int i = 0; i < p_node->get_child_count(); i++) {
@@ -314,9 +314,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
return NULL;
}
- if (Object::cast_to<MeshInstance>(p_node)) {
+ if (Object::cast_to<MeshInstance3D>(p_node)) {
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> m = mi->get_mesh();
@@ -344,7 +344,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
if (p_light_bake_mode != LIGHT_BAKE_DISABLED) {
- mi->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
+ mi->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true);
}
}
@@ -377,12 +377,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
if (isroot)
return p_node;
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
- List<Ref<Shape>> shapes;
+ List<Ref<Shape3D>> shapes;
String fixed_name;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
@@ -404,7 +404,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
if (shapes.size()) {
- StaticBody *col = memnew(StaticBody);
+ StaticBody3D *col = memnew(StaticBody3D);
col->set_transform(mi->get_transform());
col->set_name(fixed_name);
p_node->replace_by(col);
@@ -412,9 +412,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
p_node = col;
int idx = 0;
- for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
+ for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@@ -427,55 +427,55 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
- StaticBody *sb = memnew(StaticBody);
+ StaticBody3D *sb = memnew(StaticBody3D);
sb->set_name(_fixstr(name, "colonly"));
- Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
+ Object::cast_to<Node3D>(sb)->set_transform(Object::cast_to<Node3D>(p_node)->get_transform());
p_node->replace_by(sb);
memdelete(p_node);
p_node = NULL;
- CollisionShape *colshape = memnew(CollisionShape);
+ CollisionShape3D *colshape = memnew(CollisionShape3D);
if (empty_draw_type == "CUBE") {
- BoxShape *boxShape = memnew(BoxShape);
+ BoxShape3D *boxShape = memnew(BoxShape3D);
boxShape->set_extents(Vector3(1, 1, 1));
colshape->set_shape(boxShape);
- colshape->set_name("BoxShape");
+ colshape->set_name("BoxShape3D");
} else if (empty_draw_type == "SINGLE_ARROW") {
- RayShape *rayShape = memnew(RayShape);
+ RayShape3D *rayShape = memnew(RayShape3D);
rayShape->set_length(1);
colshape->set_shape(rayShape);
- colshape->set_name("RayShape");
- Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2);
+ colshape->set_name("RayShape3D");
+ Object::cast_to<Node3D>(sb)->rotate_x(Math_PI / 2);
} else if (empty_draw_type == "IMAGE") {
- WorldMarginShape *world_margin_shape = memnew(WorldMarginShape);
+ WorldMarginShape3D *world_margin_shape = memnew(WorldMarginShape3D);
colshape->set_shape(world_margin_shape);
colshape->set_name("WorldMarginShape");
} else {
- SphereShape *sphereShape = memnew(SphereShape);
+ SphereShape3D *sphereShape = memnew(SphereShape3D);
sphereShape->set_radius(1);
colshape->set_shape(sphereShape);
- colshape->set_name("SphereShape");
+ colshape->set_name("SphereShape3D");
}
sb->add_child(colshape);
colshape->set_owner(sb->get_owner());
}
- } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) {
+ } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance3D>(p_node)) {
if (isroot)
return p_node;
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
- List<Ref<Shape>> shapes;
+ List<Ref<Shape3D>> shapes;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else {
_gen_shape_list(mesh, shapes, true);
}
- RigidBody *rigid_body = memnew(RigidBody);
+ RigidBody3D *rigid_body = memnew(RigidBody3D);
rigid_body->set_name(_fixstr(name, "rigid"));
p_node->replace_by(rigid_body);
rigid_body->set_transform(mi->get_transform());
@@ -486,9 +486,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
mi->set_owner(rigid_body->get_owner());
int idx = 0;
- for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
+ for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
rigid_body->add_child(cshape);
@@ -498,14 +498,14 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
}
- } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance>(p_node)) {
+ } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance3D>(p_node)) {
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
- List<Ref<Shape>> shapes;
+ List<Ref<Shape3D>> shapes;
String fixed_name;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
@@ -530,15 +530,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
if (shapes.size()) {
- StaticBody *col = memnew(StaticBody);
+ StaticBody3D *col = memnew(StaticBody3D);
col->set_name("static_collision");
mi->add_child(col);
col->set_owner(mi->get_owner());
int idx = 0;
- for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
+ for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@@ -550,22 +550,22 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
}
- } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) {
+ } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance3D>(p_node)) {
if (isroot)
return p_node;
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
ERR_FAIL_COND_V(mesh.is_null(), NULL);
- NavigationRegion *nmi = memnew(NavigationRegion);
+ NavigationRegion3D *nmi = memnew(NavigationRegion3D);
nmi->set_name(_fixstr(name, "navmesh"));
Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
nmesh->create_from_mesh(mesh);
nmi->set_navigation_mesh(nmesh);
- Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform());
+ Object::cast_to<Node3D>(nmi)->set_transform(mi->get_transform());
p_node->replace_by(nmi);
memdelete(p_node);
p_node = nmi;
@@ -575,8 +575,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
return p_node;
Node *owner = p_node->get_owner();
- Spatial *s = Object::cast_to<Spatial>(p_node);
- VehicleBody *bv = memnew(VehicleBody);
+ Node3D *s = Object::cast_to<Node3D>(p_node);
+ VehicleBody3D *bv = memnew(VehicleBody3D);
String n = _fixstr(p_node->get_name(), "vehicle");
bv->set_name(n);
p_node->replace_by(bv);
@@ -595,8 +595,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
return p_node;
Node *owner = p_node->get_owner();
- Spatial *s = Object::cast_to<Spatial>(p_node);
- VehicleWheel *bv = memnew(VehicleWheel);
+ Node3D *s = Object::cast_to<Node3D>(p_node);
+ VehicleWheel3D *bv = memnew(VehicleWheel3D);
String n = _fixstr(p_node->get_name(), "wheel");
bv->set_name(n);
p_node->replace_by(bv);
@@ -609,16 +609,16 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
p_node = bv;
- } else if (Object::cast_to<MeshInstance>(p_node)) {
+ } else if (Object::cast_to<MeshInstance3D>(p_node)) {
//last attempt, maybe collision inside the mesh data
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
- List<Ref<Shape>> shapes;
+ List<Ref<Shape3D>> shapes;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else if (_teststr(mesh->get_name(), "col")) {
@@ -632,15 +632,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
if (shapes.size()) {
- StaticBody *col = memnew(StaticBody);
+ StaticBody3D *col = memnew(StaticBody3D);
col->set_name("static_collision");
p_node->add_child(col);
col->set_owner(p_node->get_owner());
int idx = 0;
- for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
+ for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@@ -934,14 +934,14 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans
List<PropertyInfo> pi;
p_node->get_property_list(&pi);
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi) {
Ref<ArrayMesh> mesh = mi->get_mesh();
if (mesh.is_valid() && !meshes.has(mesh)) {
- Spatial *s = mi;
+ Node3D *s = mi;
Transform transform;
while (s) {
transform = transform * s->get_transform();
@@ -1141,7 +1141,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const {
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Spatial"));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Node3D"));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root"));
List<String> script_extentions;
@@ -1333,7 +1333,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
root_type = ScriptServer::get_global_class_base(root_type);
}
- if (root_type != "Spatial") {
+ if (root_type != "Node3D") {
Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
if (base_node) {
@@ -1348,9 +1348,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
scene->set_script(Variant(root_script));
}
- if (Object::cast_to<Spatial>(scene)) {
+ if (Object::cast_to<Node3D>(scene)) {
float root_scale = p_options["nodes/root_scale"];
- Object::cast_to<Spatial>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
+ Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
}
if (p_options["nodes/root_name"] != "Scene Root")
@@ -1368,7 +1368,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"];
int light_bake_mode = p_options["meshes/light_baking"];
- Map<Ref<Mesh>, List<Ref<Shape>>> collision_map;
+ Map<Ref<Mesh>, List<Ref<Shape3D>>> collision_map;
scene = _fix_node(scene, scene, collision_map, LightBakeMode(light_bake_mode));
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 6d1043eb28..bb01725854 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -34,7 +34,7 @@
#include "core/io/resource_importer.h"
#include "scene/resources/animation.h"
#include "scene/resources/mesh.h"
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
class Material;
@@ -147,7 +147,7 @@ public:
void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation>> &p_animations, Map<Ref<Material>, Ref<Material>> &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh>> &p_meshes);
- Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape>>> &collision_map, LightBakeMode p_light_bake_mode);
+ Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode);
void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all);
void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 0090d30b9c..c218697423 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -36,7 +36,7 @@
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
-void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_channel) {
+void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) {
MutexLock lock(singleton->mutex);
diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h
index ed0fe1be89..5f5fb75585 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -35,7 +35,7 @@
#include "core/io/resource_importer.h"
#include "core/os/file_access.h"
#include "scene/resources/texture.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
class StreamTexture;
@@ -63,16 +63,16 @@ protected:
int flags;
String normal_path_for_roughness;
- VS::TextureDetectRoughnessChannel channel_for_roughness;
+ RS::TextureDetectRoughnessChannel channel_for_roughness;
MakeInfo() {
flags = 0;
- channel_for_roughness = VS::TEXTURE_DETECT_ROUGNHESS_R;
+ channel_for_roughness = RS::TEXTURE_DETECT_ROUGNHESS_R;
}
};
Map<StringName, MakeInfo> make_flags;
- static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VisualServer::TextureDetectRoughnessChannel p_channel);
+ static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex);
static void _texture_reimport_normal(const Ref<StreamTexture> &p_tex);
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index e2e68f0f41..23be42aaea 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -424,7 +424,7 @@ void ImportDock::_reimport_attempt() {
if (need_restart) {
label_warning->set_visible(used_in_resources);
- reimport_confirm->popup_centered_minsize();
+ reimport_confirm->popup_centered();
return;
}
@@ -492,13 +492,13 @@ void ImportDock::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- imported->add_style_override("normal", get_stylebox("normal", "LineEdit"));
+ imported->add_theme_style_override("normal", get_theme_stylebox("normal", "LineEdit"));
} break;
case NOTIFICATION_ENTER_TREE: {
import_opts->edit(params);
- label_warning->add_color_override("font_color", get_color("warning_color", "Editor"));
+ label_warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
} break;
}
}
@@ -526,7 +526,7 @@ ImportDock::ImportDock() {
set_name("Import");
imported = memnew(Label);
- imported->add_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "LineEdit"));
+ imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit"));
imported->set_clip_text(true);
add_child(imported);
HBoxContainer *hb = memnew(HBoxContainer);
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 2729d9ecb5..223e7a841f 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -140,7 +140,7 @@ void InspectorDock::_new_resource() {
}
void InspectorDock::_load_resource(const String &p_type) {
- load_resource_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ load_resource_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type(p_type, &extensions);
@@ -214,7 +214,7 @@ void InspectorDock::_prepare_history() {
history_menu->get_popup()->clear();
- Ref<Texture2D> base_icon = get_icon("Object", "EditorIcons");
+ Ref<Texture2D> base_icon = get_theme_icon("Object", "EditorIcons");
Set<ObjectID> already;
for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) {
@@ -310,14 +310,14 @@ void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_valu
}
void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) {
- Spatial *s = Object::cast_to<Spatial>(sp);
+ Node3D *s = Object::cast_to<Node3D>(sp);
if (!s)
return;
AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(s, p_sub, p_key);
}
void InspectorDock::_warning_pressed() {
- warning_dialog->popup_centered_minsize();
+ warning_dialog->popup_centered();
}
Container *InspectorDock::get_addon_area() {
@@ -328,15 +328,15 @@ void InspectorDock::_notification(int p_what) {
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
set_theme(editor->get_gui_base()->get_theme());
- resource_new_button->set_icon(get_icon("New", "EditorIcons"));
- resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
- resource_save_button->set_icon(get_icon("Save", "EditorIcons"));
- backward_button->set_icon(get_icon("Back", "EditorIcons"));
- forward_button->set_icon(get_icon("Forward", "EditorIcons"));
- history_menu->set_icon(get_icon("History", "EditorIcons"));
- object_menu->set_icon(get_icon("Tools", "EditorIcons"));
- warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
- warning->add_color_override("font_color", get_color("warning_color", "Editor"));
+ resource_new_button->set_icon(get_theme_icon("New", "EditorIcons"));
+ resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons"));
+ resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons"));
+ backward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
+ forward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ history_menu->set_icon(get_theme_icon("History", "EditorIcons"));
+ object_menu->set_icon(get_theme_icon("Tools", "EditorIcons"));
+ warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons"));
+ warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
} break;
}
}
@@ -435,7 +435,7 @@ void InspectorDock::update(Object *p_object) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES);
p->add_separator();
- p->add_icon_shortcut(get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP);
+ p->add_icon_shortcut(get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP);
}
List<MethodInfo> methods;
@@ -496,21 +496,21 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
resource_new_button = memnew(ToolButton);
resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it."));
- resource_new_button->set_icon(get_icon("New", "EditorIcons"));
+ resource_new_button->set_icon(get_theme_icon("New", "EditorIcons"));
general_options_hb->add_child(resource_new_button);
resource_new_button->connect("pressed", callable_mp(this, &InspectorDock::_new_resource));
resource_new_button->set_focus_mode(Control::FOCUS_NONE);
resource_load_button = memnew(ToolButton);
resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it."));
- resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
+ resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons"));
general_options_hb->add_child(resource_load_button);
resource_load_button->connect("pressed", callable_mp(this, &InspectorDock::_open_resource_selector));
resource_load_button->set_focus_mode(Control::FOCUS_NONE);
resource_save_button = memnew(MenuButton);
resource_save_button->set_tooltip(TTR("Save the currently edited resource."));
- resource_save_button->set_icon(get_icon("Save", "EditorIcons"));
+ resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons"));
general_options_hb->add_child(resource_save_button);
resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE);
resource_save_button->get_popup()->add_item(TTR("Save As..."), RESOURCE_SAVE_AS);
@@ -522,7 +522,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
backward_button = memnew(ToolButton);
general_options_hb->add_child(backward_button);
- backward_button->set_icon(get_icon("Back", "EditorIcons"));
+ backward_button->set_icon(get_theme_icon("Back", "EditorIcons"));
backward_button->set_flat(true);
backward_button->set_tooltip(TTR("Go to the previous edited object in history."));
backward_button->set_disabled(true);
@@ -530,7 +530,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
forward_button = memnew(ToolButton);
general_options_hb->add_child(forward_button);
- forward_button->set_icon(get_icon("Forward", "EditorIcons"));
+ forward_button->set_icon(get_theme_icon("Forward", "EditorIcons"));
forward_button->set_flat(true);
forward_button->set_tooltip(TTR("Go to the next edited object in history."));
forward_button->set_disabled(true);
@@ -538,9 +538,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
history_menu = memnew(MenuButton);
history_menu->set_tooltip(TTR("History of recently edited objects."));
- history_menu->set_icon(get_icon("History", "EditorIcons"));
+ history_menu->set_icon(get_theme_icon("History", "EditorIcons"));
general_options_hb->add_child(history_menu);
- history_menu->connect("about_to_show", callable_mp(this, &InspectorDock::_prepare_history));
+ history_menu->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_history));
history_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_select_history));
HBoxContainer *node_info_hb = memnew(HBoxContainer);
@@ -551,7 +551,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
node_info_hb->add_child(editor_path);
object_menu = memnew(MenuButton);
- object_menu->set_icon(get_icon("Tools", "EditorIcons"));
+ object_menu->set_icon(get_theme_icon("Tools", "EditorIcons"));
node_info_hb->add_child(object_menu);
object_menu->set_tooltip(TTR("Object properties."));
object_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option));
@@ -564,15 +564,15 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
search = memnew(LineEdit);
search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search->set_placeholder(TTR("Filter properties"));
- search->set_right_icon(get_icon("Search", "EditorIcons"));
+ search->set_right_icon(get_theme_icon("Search", "EditorIcons"));
search->set_clear_button_enabled(true);
add_child(search);
warning = memnew(Button);
add_child(warning);
warning->set_text(TTR("Changes may be lost!"));
- warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
- warning->add_color_override("font_color", get_color("warning_color", "Editor"));
+ warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons"));
+ warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
warning->set_clip_text(true);
warning->hide();
warning->connect("pressed", callable_mp(this, &InspectorDock::_warning_pressed));
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp
index d6e443ec14..40c17a9fc3 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/node_3d_editor_gizmos.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial_editor_gizmos.cpp */
+/* node_3d_editor_gizmos.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,45 +28,45 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "spatial_editor_gizmos.h"
+#include "node_3d_editor_gizmos.h"
#include "core/math/geometry.h"
#include "core/math/quick_hull.h"
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/baked_lightmap.h"
-#include "scene/3d/collision_polygon.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/cpu_particles.h"
+#include "scene/3d/collision_polygon_3d.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/cpu_particles_3d.h"
#include "scene/3d/gi_probe.h"
-#include "scene/3d/light.h"
-#include "scene/3d/listener.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/navigation_region.h"
-#include "scene/3d/particles.h"
-#include "scene/3d/physics_joint.h"
+#include "scene/3d/gpu_particles_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/listener_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/navigation_region_3d.h"
+#include "scene/3d/physics_joint_3d.h"
#include "scene/3d/position_3d.h"
-#include "scene/3d/ray_cast.h"
+#include "scene/3d/ray_cast_3d.h"
#include "scene/3d/reflection_probe.h"
-#include "scene/3d/soft_body.h"
-#include "scene/3d/spring_arm.h"
+#include "scene/3d/soft_body_3d.h"
+#include "scene/3d/spring_arm_3d.h"
#include "scene/3d/sprite_3d.h"
-#include "scene/3d/vehicle_body.h"
-#include "scene/3d/visibility_notifier.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/cylinder_shape.h"
-#include "scene/resources/height_map_shape.h"
+#include "scene/3d/vehicle_body_3d.h"
+#include "scene/3d/visibility_notifier_3d.h"
+#include "scene/resources/box_shape_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/cylinder_shape_3d.h"
+#include "scene/resources/height_map_shape_3d.h"
#include "scene/resources/primitive_meshes.h"
-#include "scene/resources/ray_shape.h"
-#include "scene/resources/sphere_shape.h"
+#include "scene/resources/ray_shape_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
#include "scene/resources/surface_tool.h"
-#include "scene/resources/world_margin_shape.h"
+#include "scene/resources/world_margin_shape_3d.h"
#define HANDLE_HALF_SIZE 9.5
-bool EditorSpatialGizmo::is_editable() const {
+bool EditorNode3DGizmo::is_editable() const {
ERR_FAIL_COND_V(!spatial_node, false);
Node *edited_root = spatial_node->get_tree()->get_edited_scene_root();
@@ -81,12 +81,12 @@ bool EditorSpatialGizmo::is_editable() const {
return false;
}
-void EditorSpatialGizmo::clear() {
+void EditorNode3DGizmo::clear() {
for (int i = 0; i < instances.size(); i++) {
if (instances[i].instance.is_valid())
- VS::get_singleton()->free(instances[i].instance);
+ RS::get_singleton()->free(instances[i].instance);
}
billboard_handle = false;
@@ -97,7 +97,7 @@ void EditorSpatialGizmo::clear() {
secondary_handles.clear();
}
-void EditorSpatialGizmo::redraw() {
+void EditorNode3DGizmo::redraw() {
if (get_script_instance() && get_script_instance()->has_method("redraw")) {
get_script_instance()->call("redraw");
@@ -108,7 +108,7 @@ void EditorSpatialGizmo::redraw() {
gizmo_plugin->redraw(this);
}
-String EditorSpatialGizmo::get_handle_name(int p_idx) const {
+String EditorNode3DGizmo::get_handle_name(int p_idx) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) {
return get_script_instance()->call("get_handle_name", p_idx);
@@ -118,7 +118,7 @@ String EditorSpatialGizmo::get_handle_name(int p_idx) const {
return gizmo_plugin->get_handle_name(this, p_idx);
}
-bool EditorSpatialGizmo::is_handle_highlighted(int p_idx) const {
+bool EditorNode3DGizmo::is_handle_highlighted(int p_idx) const {
if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) {
return get_script_instance()->call("is_handle_highlighted", p_idx);
@@ -128,7 +128,7 @@ bool EditorSpatialGizmo::is_handle_highlighted(int p_idx) const {
return gizmo_plugin->is_handle_highlighted(this, p_idx);
}
-Variant EditorSpatialGizmo::get_handle_value(int p_idx) {
+Variant EditorNode3DGizmo::get_handle_value(int p_idx) {
if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) {
return get_script_instance()->call("get_handle_value", p_idx);
@@ -138,7 +138,7 @@ Variant EditorSpatialGizmo::get_handle_value(int p_idx) {
return gizmo_plugin->get_handle_value(this, p_idx);
}
-void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
+void EditorNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
if (get_script_instance() && get_script_instance()->has_method("set_handle")) {
get_script_instance()->call("set_handle", p_idx, p_camera, p_point);
@@ -149,7 +149,7 @@ void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p
gizmo_plugin->set_handle(this, p_idx, p_camera, p_point);
}
-void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
+void EditorNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
if (get_script_instance() && get_script_instance()->has_method("commit_handle")) {
get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel);
@@ -160,27 +160,27 @@ void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel);
}
-void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) {
+void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) {
ERR_FAIL_NULL(p_node);
spatial_node = p_node;
}
-void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidden) {
+void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) {
- instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario());
- VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id());
+ instance = RS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario());
+ RS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id());
if (skin_reference.is_valid()) {
- VS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton());
+ RS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton());
}
if (extra_margin)
- VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF);
- int layer = p_hidden ? 0 : 1 << SpatialEditorViewport::GIZMO_EDIT_LAYER;
- VS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26
+ RS::get_singleton()->instance_set_extra_visibility_margin(instance, 1);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, RS::SHADOW_CASTING_SETTING_OFF);
+ int layer = p_hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER;
+ RS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26
}
-void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) {
+void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -191,16 +191,16 @@ void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard
ins.material = p_material;
if (valid) {
ins.create_instance(spatial_node, hidden);
- VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
+ RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
if (ins.material.is_valid()) {
- VS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid());
+ RS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid());
}
}
instances.push_back(ins);
}
-void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard, const Color &p_modulate) {
+void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard, const Color &p_modulate) {
if (p_lines.empty()) {
return;
}
@@ -246,13 +246,13 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat
ins.mesh = mesh;
if (valid) {
ins.create_instance(spatial_node, hidden);
- VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
+ RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
instances.push_back(ins);
}
-void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) {
+void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -310,7 +310,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
ins.billboard = true;
if (valid) {
ins.create_instance(spatial_node, hidden);
- VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
+ RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
selectable_icon_size = p_scale;
@@ -318,11 +318,11 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
instances.push_back(ins);
}
-void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh) {
+void EditorNode3DGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh) {
collision_mesh = p_tmesh;
}
-void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines) {
+void EditorNode3DGizmo::add_collision_segments(const Vector<Vector3> &p_lines) {
int from = collision_segments.size();
collision_segments.resize(from + p_lines.size());
@@ -332,7 +332,7 @@ void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines)
}
}
-void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) {
+void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) {
billboard_handle = p_billboard;
@@ -346,8 +346,8 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
Ref<ArrayMesh> mesh = memnew(ArrayMesh);
Array a;
- a.resize(VS::ARRAY_MAX);
- a[VS::ARRAY_VERTEX] = p_handles;
+ a.resize(RS::ARRAY_MAX);
+ a[RS::ARRAY_VERTEX] = p_handles;
Vector<Color> colors;
{
colors.resize(p_handles.size());
@@ -358,13 +358,13 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
if (is_handle_highlighted(i))
col = Color(0, 0, 1, 0.9);
- if (SpatialEditor::get_singleton()->get_over_gizmo_handle() != i)
+ if (Node3DEditor::get_singleton()->get_over_gizmo_handle() != i)
col.a = 0.8;
w[i] = col;
}
}
- a[VS::ARRAY_COLOR] = colors;
+ a[RS::ARRAY_COLOR] = colors;
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a);
mesh->surface_set_material(0, p_material);
@@ -384,7 +384,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
ins.extra_margin = true;
if (valid) {
ins.create_instance(spatial_node, hidden);
- VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
+ RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
instances.push_back(ins);
if (!p_secondary) {
@@ -403,21 +403,21 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
}
}
-void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) {
+void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) {
ERR_FAIL_COND(!spatial_node);
CubeMesh cubem;
cubem.set_size(p_size);
Array arrays = cubem.surface_get_arrays(0);
- PackedVector3Array vertex = arrays[VS::ARRAY_VERTEX];
+ PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX];
Vector3 *w = vertex.ptrw();
for (int i = 0; i < vertex.size(); ++i) {
w[i] += p_position;
}
- arrays[VS::ARRAY_VERTEX] = vertex;
+ arrays[RS::ARRAY_VERTEX] = vertex;
Ref<ArrayMesh> m = memnew(ArrayMesh);
m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), arrays);
@@ -425,7 +425,7 @@ void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size
add_mesh(m);
}
-bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum) {
+bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) {
ERR_FAIL_COND_V(!spatial_node, false);
ERR_FAIL_COND_V(!valid, false);
@@ -497,7 +497,7 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector<
return false;
}
-bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) {
+bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) {
ERR_FAIL_COND_V(!spatial_node, false);
ERR_FAIL_COND_V(!valid, false);
@@ -574,7 +574,7 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point,
float scale = t.origin.distance_to(p_camera->get_camera_transform().origin);
- if (p_camera->get_projection() == Camera::PROJECTION_ORTHOGONAL) {
+ if (p_camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL) {
float aspect = p_camera->get_viewport()->get_visible_rect().size.aspect();
float size = p_camera->get_size();
scale = size / aspect;
@@ -689,7 +689,7 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point,
return false;
}
-void EditorSpatialGizmo::create() {
+void EditorNode3DGizmo::create() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(valid);
@@ -703,16 +703,16 @@ void EditorSpatialGizmo::create() {
transform();
}
-void EditorSpatialGizmo::transform() {
+void EditorNode3DGizmo::transform() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
for (int i = 0; i < instances.size(); i++) {
- VS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform());
+ RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform());
}
}
-void EditorSpatialGizmo::free() {
+void EditorNode3DGizmo::free() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
@@ -720,7 +720,7 @@ void EditorSpatialGizmo::free() {
for (int i = 0; i < instances.size(); i++) {
if (instances[i].instance.is_valid())
- VS::get_singleton()->free(instances[i].instance);
+ RS::get_singleton()->free(instances[i].instance);
instances.write[i].instance = RID();
}
@@ -729,31 +729,31 @@ void EditorSpatialGizmo::free() {
valid = false;
}
-void EditorSpatialGizmo::set_hidden(bool p_hidden) {
+void EditorNode3DGizmo::set_hidden(bool p_hidden) {
hidden = p_hidden;
- int layer = hidden ? 0 : 1 << SpatialEditorViewport::GIZMO_EDIT_LAYER;
+ int layer = hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER;
for (int i = 0; i < instances.size(); ++i) {
- VS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer);
+ RS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer);
}
}
-void EditorSpatialGizmo::set_plugin(EditorSpatialGizmoPlugin *p_plugin) {
+void EditorNode3DGizmo::set_plugin(EditorNode3DGizmoPlugin *p_plugin) {
gizmo_plugin = p_plugin;
}
-void EditorSpatialGizmo::_bind_methods() {
+void EditorNode3DGizmo::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorSpatialGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1)));
- ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorSpatialGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorSpatialGizmo::add_collision_segments);
- ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorSpatialGizmo::add_collision_triangles);
- ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1)));
- ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorSpatialGizmo::add_handles, DEFVAL(false), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorSpatialGizmo::_set_spatial_node);
- ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorSpatialGizmo::get_spatial_node);
- ClassDB::bind_method(D_METHOD("get_plugin"), &EditorSpatialGizmo::get_plugin);
- ClassDB::bind_method(D_METHOD("clear"), &EditorSpatialGizmo::clear);
- ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorSpatialGizmo::set_hidden);
+ ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorNode3DGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorNode3DGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorNode3DGizmo::add_collision_segments);
+ ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorNode3DGizmo::add_collision_triangles);
+ ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorNode3DGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorNode3DGizmo::_set_spatial_node);
+ ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorNode3DGizmo::get_spatial_node);
+ ClassDB::bind_method(D_METHOD("get_plugin"), &EditorNode3DGizmo::get_plugin);
+ ClassDB::bind_method(D_METHOD("clear"), &EditorNode3DGizmo::clear);
+ ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorNode3DGizmo::set_hidden);
BIND_VMETHOD(MethodInfo("redraw"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", PropertyInfo(Variant::INT, "index")));
@@ -763,13 +763,13 @@ void EditorSpatialGizmo::_bind_methods() {
hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(hvget);
- BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point")));
+ BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point")));
MethodInfo cm = MethodInfo("commit_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
cm.default_arguments.push_back(false);
BIND_VMETHOD(cm);
}
-EditorSpatialGizmo::EditorSpatialGizmo() {
+EditorNode3DGizmo::EditorNode3DGizmo() {
valid = false;
billboard_handle = false;
hidden = false;
@@ -781,13 +781,13 @@ EditorSpatialGizmo::EditorSpatialGizmo() {
selectable_icon_size = -1.0f;
}
-EditorSpatialGizmo::~EditorSpatialGizmo() {
+EditorNode3DGizmo::~EditorNode3DGizmo() {
if (gizmo_plugin != NULL) gizmo_plugin->unregister_gizmo(this);
clear();
}
-Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const {
+Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3());
@@ -796,34 +796,34 @@ Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const {
//// light gizmo
-LightSpatialGizmoPlugin::LightSpatialGizmoPlugin() {
+LightNode3DGizmoPlugin::LightNode3DGizmoPlugin() {
// Enable vertex colors for the materials below as the gizmo color depends on the light color.
create_material("lines_primary", Color(1, 1, 1), false, false, true);
create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true);
create_material("lines_billboard", Color(1, 1, 1), true, false, true);
- create_icon_material("light_directional_icon", SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons"));
- create_icon_material("light_omni_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
- create_icon_material("light_spot_icon", SpatialEditor::get_singleton()->get_icon("GizmoSpotLight", "EditorIcons"));
+ create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoDirectionalLight", "EditorIcons"));
+ create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLight", "EditorIcons"));
+ create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoSpotLight", "EditorIcons"));
create_handle_material("handles");
create_handle_material("handles_billboard", true);
}
-bool LightSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<Light>(p_spatial) != NULL;
+bool LightNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<Light3D>(p_spatial) != NULL;
}
-String LightSpatialGizmoPlugin::get_name() const {
+String LightNode3DGizmoPlugin::get_name() const {
return "Lights";
}
-int LightSpatialGizmoPlugin::get_priority() const {
+int LightNode3DGizmoPlugin::get_priority() const {
return -1;
}
-String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String LightNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
if (p_idx == 0)
return "Radius";
@@ -831,13 +831,13 @@ String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizm
return "Aperture";
}
-Variant LightSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant LightNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
if (p_idx == 0)
- return light->get_param(Light::PARAM_RANGE);
+ return light->get_param(Light3D::PARAM_RANGE);
if (p_idx == 1)
- return light->get_param(Light::PARAM_SPOT_ANGLE);
+ return light->get_param(Light3D::PARAM_SPOT_ANGLE);
return Variant();
}
@@ -871,9 +871,9 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec
return a * 180.0 / Math_PI;
}
-void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void LightNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
Transform gt = light->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -883,20 +883,20 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx,
Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (p_idx == 0) {
- if (Object::cast_to<SpotLight>(light)) {
+ if (Object::cast_to<SpotLight3D>(light)) {
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb);
float d = -ra.z;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d <= 0) // Equal is here for negative zero.
d = 0;
- light->set_param(Light::PARAM_RANGE, d);
- } else if (Object::cast_to<OmniLight>(light)) {
+ light->set_param(Light3D::PARAM_RANGE, d);
+ } else if (Object::cast_to<OmniLight3D>(light)) {
Plane cp = Plane(gt.origin, p_camera->get_transform().basis.get_axis(2));
@@ -904,48 +904,48 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx,
if (cp.intersects_ray(ray_from, ray_dir, &inters)) {
float r = inters.distance_to(gt.origin);
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- r = Math::stepify(r, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ r = Math::stepify(r, Node3DEditor::get_singleton()->get_translate_snap());
}
- light->set_param(Light::PARAM_RANGE, r);
+ light->set_param(Light3D::PARAM_RANGE, r);
}
}
} else if (p_idx == 1) {
- float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light::PARAM_RANGE), gt);
- light->set_param(Light::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99));
+ float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light3D::PARAM_RANGE), gt);
+ light->set_param(Light3D::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99));
}
}
-void LightSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void LightNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
- light->set_param(p_idx == 0 ? Light::PARAM_RANGE : Light::PARAM_SPOT_ANGLE, p_restore);
+ light->set_param(p_idx == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore);
} else if (p_idx == 0) {
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Light Radius"));
- ur->add_do_method(light, "set_param", Light::PARAM_RANGE, light->get_param(Light::PARAM_RANGE));
- ur->add_undo_method(light, "set_param", Light::PARAM_RANGE, p_restore);
+ ur->add_do_method(light, "set_param", Light3D::PARAM_RANGE, light->get_param(Light3D::PARAM_RANGE));
+ ur->add_undo_method(light, "set_param", Light3D::PARAM_RANGE, p_restore);
ur->commit_action();
} else if (p_idx == 1) {
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Light Radius"));
- ur->add_do_method(light, "set_param", Light::PARAM_SPOT_ANGLE, light->get_param(Light::PARAM_SPOT_ANGLE));
- ur->add_undo_method(light, "set_param", Light::PARAM_SPOT_ANGLE, p_restore);
+ ur->add_do_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, light->get_param(Light3D::PARAM_SPOT_ANGLE));
+ ur->add_undo_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, p_restore);
ur->commit_action();
}
}
-void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void LightNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node());
+ Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
Color color = light->get_color();
// Make the gizmo color as bright as possible for better visibility
@@ -953,7 +953,7 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->clear();
- if (Object::cast_to<DirectionalLight>(light)) {
+ if (Object::cast_to<DirectionalLight3D>(light)) {
Ref<Material> material = get_material("lines_primary", p_gizmo);
Ref<Material> icon = get_material("light_directional_icon", p_gizmo);
@@ -991,15 +991,15 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_unscaled_billboard(icon, 0.05, color);
}
- if (Object::cast_to<OmniLight>(light)) {
+ if (Object::cast_to<OmniLight3D>(light)) {
// Use both a billboard circle and 3 non-billboard circles for a better sphere-like representation
const Ref<Material> lines_material = get_material("lines_secondary", p_gizmo);
const Ref<Material> lines_billboard_material = get_material("lines_billboard", p_gizmo);
const Ref<Material> icon = get_material("light_omni_icon", p_gizmo);
- OmniLight *on = Object::cast_to<OmniLight>(light);
- const float r = on->get_param(Light::PARAM_RANGE);
+ OmniLight3D *on = Object::cast_to<OmniLight3D>(light);
+ const float r = on->get_param(Light3D::PARAM_RANGE);
Vector<Vector3> points;
Vector<Vector3> points_billboard;
@@ -1033,7 +1033,7 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, get_material("handles_billboard"), true);
}
- if (Object::cast_to<SpotLight>(light)) {
+ if (Object::cast_to<SpotLight3D>(light)) {
const Ref<Material> material_primary = get_material("lines_primary", p_gizmo);
const Ref<Material> material_secondary = get_material("lines_secondary", p_gizmo);
@@ -1041,11 +1041,11 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Vector<Vector3> points_primary;
Vector<Vector3> points_secondary;
- SpotLight *sl = Object::cast_to<SpotLight>(light);
+ SpotLight3D *sl = Object::cast_to<SpotLight3D>(light);
- float r = sl->get_param(Light::PARAM_RANGE);
- float w = r * Math::sin(Math::deg2rad(sl->get_param(Light::PARAM_SPOT_ANGLE)));
- float d = r * Math::cos(Math::deg2rad(sl->get_param(Light::PARAM_SPOT_ANGLE)));
+ float r = sl->get_param(Light3D::PARAM_RANGE);
+ float w = r * Math::sin(Math::deg2rad(sl->get_param(Light3D::PARAM_SPOT_ANGLE)));
+ float d = r * Math::cos(Math::deg2rad(sl->get_param(Light3D::PARAM_SPOT_ANGLE)));
for (int i = 0; i < 120; i++) {
@@ -1086,39 +1086,39 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
//////
//// player gizmo
-AudioStreamPlayer3DSpatialGizmoPlugin::AudioStreamPlayer3DSpatialGizmoPlugin() {
+AudioStreamPlayer3DNode3DGizmoPlugin::AudioStreamPlayer3DNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1));
- create_icon_material("stream_player_3d_icon", SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons"));
+ create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("Gizmo3DSamplePlayer", "EditorIcons"));
create_material("stream_player_3d_material_primary", gizmo_color);
create_material("stream_player_3d_material_secondary", gizmo_color * Color(1, 1, 1, 0.35));
create_handle_material("handles");
}
-bool AudioStreamPlayer3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
+bool AudioStreamPlayer3DNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<AudioStreamPlayer3D>(p_spatial) != NULL;
}
-String AudioStreamPlayer3DSpatialGizmoPlugin::get_name() const {
+String AudioStreamPlayer3DNode3DGizmoPlugin::get_name() const {
return "AudioStreamPlayer3D";
}
-int AudioStreamPlayer3DSpatialGizmoPlugin::get_priority() const {
+int AudioStreamPlayer3DNode3DGizmoPlugin::get_priority() const {
return -1;
}
-String AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String AudioStreamPlayer3DNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
return "Emission Radius";
}
-Variant AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant AudioStreamPlayer3DNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
return player->get_emission_angle();
}
-void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void AudioStreamPlayer3DNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
@@ -1157,7 +1157,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_giz
}
}
-void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void AudioStreamPlayer3DNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
@@ -1167,7 +1167,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_
} else {
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change AudioStreamPlayer3D Emission Angle"));
ur->add_do_method(player, "set_emission_angle", player->get_emission_angle());
ur->add_undo_method(player, "set_emission_angle", p_restore);
@@ -1175,7 +1175,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_
}
}
-void AudioStreamPlayer3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void AudioStreamPlayer3DNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
@@ -1233,7 +1233,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo)
//////
-CameraSpatialGizmoPlugin::CameraSpatialGizmoPlugin() {
+CameraNode3DGizmoPlugin::CameraNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8));
@@ -1241,34 +1241,34 @@ CameraSpatialGizmoPlugin::CameraSpatialGizmoPlugin() {
create_handle_material("handles");
}
-bool CameraSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<Camera>(p_spatial) != NULL;
+bool CameraNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<Camera3D>(p_spatial) != NULL;
}
-String CameraSpatialGizmoPlugin::get_name() const {
- return "Camera";
+String CameraNode3DGizmoPlugin::get_name() const {
+ return "Camera3D";
}
-int CameraSpatialGizmoPlugin::get_priority() const {
+int CameraNode3DGizmoPlugin::get_priority() const {
return -1;
}
-String CameraSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String CameraNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
- Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
- if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
return "FOV";
} else {
return "Size";
}
}
-Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant CameraNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
- if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
return camera->get_fov();
} else {
@@ -1276,9 +1276,9 @@ Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo,
}
}
-void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void CameraNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
Transform gt = camera->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -1288,7 +1288,7 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx
Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
- if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
Transform gt2 = camera->get_global_transform();
float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2);
camera->set("fov", CLAMP(a * 2.0, 1, 179));
@@ -1297,8 +1297,8 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb);
float d = ra.x * 2.0;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
d = CLAMP(d, 0.1, 16384);
@@ -1307,17 +1307,17 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx
}
}
-void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void CameraNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
- if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
if (p_cancel) {
camera->set("fov", p_restore);
} else {
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Camera FOV"));
ur->add_do_property(camera, "fov", camera->get_fov());
ur->add_undo_property(camera, "fov", p_restore);
@@ -1330,7 +1330,7 @@ void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_
camera->set("size", p_restore);
} else {
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Camera Size"));
ur->add_do_property(camera, "size", camera->get_size());
ur->add_undo_property(camera, "size", p_restore);
@@ -1339,9 +1339,9 @@ void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_
}
}
-void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void CameraNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node());
+ Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1374,7 +1374,7 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
switch (camera->get_projection()) {
- case Camera::PROJECTION_PERSPECTIVE: {
+ case Camera3D::PROJECTION_PERSPECTIVE: {
// The real FOV is halved for accurate representation
float fov = camera->get_fov() / 2.0;
@@ -1396,7 +1396,7 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
ADD_TRIANGLE(tup, side + up, nside + up);
} break;
- case Camera::PROJECTION_ORTHOGONAL: {
+ case Camera3D::PROJECTION_ORTHOGONAL: {
float size = camera->get_size();
@@ -1418,7 +1418,7 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
ADD_TRIANGLE(tup, right + up + back, -right + up + back);
} break;
- case Camera::PROJECTION_FRUSTUM: {
+ case Camera3D::PROJECTION_FRUSTUM: {
float hsize = camera->get_size() / 2.0;
Vector3 side = Vector3(hsize, 0, -camera->get_znear()).normalized();
@@ -1445,9 +1445,9 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_lines(lines, material);
p_gizmo->add_handles(handles, get_material("handles"));
- ClippedCamera *clipcam = Object::cast_to<ClippedCamera>(camera);
+ ClippedCamera3D *clipcam = Object::cast_to<ClippedCamera3D>(camera);
if (clipcam) {
- Spatial *parent = Object::cast_to<Spatial>(camera->get_parent());
+ Node3D *parent = Object::cast_to<Node3D>(camera->get_parent());
if (!parent) {
return;
}
@@ -1489,28 +1489,28 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
//////
-MeshInstanceSpatialGizmoPlugin::MeshInstanceSpatialGizmoPlugin() {
+MeshInstanceNode3DGizmoPlugin::MeshInstanceNode3DGizmoPlugin() {
}
-bool MeshInstanceSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<MeshInstance>(p_spatial) != NULL && Object::cast_to<SoftBody>(p_spatial) == NULL;
+bool MeshInstanceNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<MeshInstance3D>(p_spatial) != NULL && Object::cast_to<SoftBody3D>(p_spatial) == NULL;
}
-String MeshInstanceSpatialGizmoPlugin::get_name() const {
- return "MeshInstance";
+String MeshInstanceNode3DGizmoPlugin::get_name() const {
+ return "MeshInstance3D";
}
-int MeshInstanceSpatialGizmoPlugin::get_priority() const {
+int MeshInstanceNode3DGizmoPlugin::get_priority() const {
return -1;
}
-bool MeshInstanceSpatialGizmoPlugin::can_be_hidden() const {
+bool MeshInstanceNode3DGizmoPlugin::can_be_hidden() const {
return false;
}
-void MeshInstanceSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void MeshInstanceNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- MeshInstance *mesh = Object::cast_to<MeshInstance>(p_gizmo->get_spatial_node());
+ MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1526,26 +1526,26 @@ void MeshInstanceSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
/////
-Sprite3DSpatialGizmoPlugin::Sprite3DSpatialGizmoPlugin() {
+Sprite3DNode3DGizmoPlugin::Sprite3DNode3DGizmoPlugin() {
}
-bool Sprite3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
+bool Sprite3DNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<Sprite3D>(p_spatial) != NULL;
}
-String Sprite3DSpatialGizmoPlugin::get_name() const {
+String Sprite3DNode3DGizmoPlugin::get_name() const {
return "Sprite3D";
}
-int Sprite3DSpatialGizmoPlugin::get_priority() const {
+int Sprite3DNode3DGizmoPlugin::get_priority() const {
return -1;
}
-bool Sprite3DSpatialGizmoPlugin::can_be_hidden() const {
+bool Sprite3DNode3DGizmoPlugin::can_be_hidden() const {
return false;
}
-void Sprite3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void Sprite3DNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_spatial_node());
@@ -1559,7 +1559,7 @@ void Sprite3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
///
-Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() {
+Position3DNode3DGizmoPlugin::Position3DNode3DGizmoPlugin() {
pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
cursor_points = Vector<Vector3>();
@@ -1571,12 +1571,12 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() {
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(EditorNode::get_singleton()->get_gui_base()->get_color("axis_x_color", "Editor"));
- cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_x_color", "Editor"));
- cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_y_color", "Editor"));
- cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_y_color", "Editor"));
- cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor"));
- cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor"));
+ cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_x_color", "Editor"));
+ cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_x_color", "Editor"));
+ cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_y_color", "Editor"));
+ cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_y_color", "Editor"));
+ cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_z_color", "Editor"));
+ cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_z_color", "Editor"));
Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -1585,26 +1585,26 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() {
mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
Array d;
- d.resize(VS::ARRAY_MAX);
+ d.resize(RS::ARRAY_MAX);
d[Mesh::ARRAY_VERTEX] = cursor_points;
d[Mesh::ARRAY_COLOR] = cursor_colors;
pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);
pos3d_mesh->surface_set_material(0, mat);
}
-bool Position3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
+bool Position3DNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<Position3D>(p_spatial) != NULL;
}
-String Position3DSpatialGizmoPlugin::get_name() const {
+String Position3DNode3DGizmoPlugin::get_name() const {
return "Position3D";
}
-int Position3DSpatialGizmoPlugin::get_priority() const {
+int Position3DNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void Position3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void Position3DNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
p_gizmo->add_mesh(pos3d_mesh);
@@ -1613,27 +1613,27 @@ void Position3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
/////
-SkeletonSpatialGizmoPlugin::SkeletonSpatialGizmoPlugin() {
+SkeletonNode3DGizmoPlugin::SkeletonNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/skeleton", Color(1, 0.8, 0.4));
create_material("skeleton_material", gizmo_color);
}
-bool SkeletonSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<Skeleton>(p_spatial) != NULL;
+bool SkeletonNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<Skeleton3D>(p_spatial) != NULL;
}
-String SkeletonSpatialGizmoPlugin::get_name() const {
- return "Skeleton";
+String SkeletonNode3DGizmoPlugin::get_name() const {
+ return "Skeleton3D";
}
-int SkeletonSpatialGizmoPlugin::get_priority() const {
+int SkeletonNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void SkeletonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void SkeletonNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Skeleton *skel = Object::cast_to<Skeleton>(p_gizmo->get_spatial_node());
+ Skeleton3D *skel = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1822,54 +1822,54 @@ void SkeletonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
////
-PhysicalBoneSpatialGizmoPlugin::PhysicalBoneSpatialGizmoPlugin() {
+PhysicalBoneNode3DGizmoPlugin::PhysicalBoneNode3DGizmoPlugin() {
create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1)));
}
-bool PhysicalBoneSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<PhysicalBone>(p_spatial) != NULL;
+bool PhysicalBoneNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<PhysicalBone3D>(p_spatial) != NULL;
}
-String PhysicalBoneSpatialGizmoPlugin::get_name() const {
+String PhysicalBoneNode3DGizmoPlugin::get_name() const {
return "PhysicalBones";
}
-int PhysicalBoneSpatialGizmoPlugin::get_priority() const {
+int PhysicalBoneNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void PhysicalBoneNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
- PhysicalBone *physical_bone = Object::cast_to<PhysicalBone>(p_gizmo->get_spatial_node());
+ PhysicalBone3D *physical_bone = Object::cast_to<PhysicalBone3D>(p_gizmo->get_spatial_node());
if (!physical_bone)
return;
- Skeleton *sk(physical_bone->find_skeleton_parent());
+ Skeleton3D *sk(physical_bone->find_skeleton_parent());
if (!sk)
return;
- PhysicalBone *pb(sk->get_physical_bone(physical_bone->get_bone_id()));
+ PhysicalBone3D *pb(sk->get_physical_bone(physical_bone->get_bone_id()));
if (!pb)
return;
- PhysicalBone *pbp(sk->get_physical_bone_parent(physical_bone->get_bone_id()));
+ PhysicalBone3D *pbp(sk->get_physical_bone_parent(physical_bone->get_bone_id()));
if (!pbp)
return;
Vector<Vector3> points;
switch (physical_bone->get_joint_type()) {
- case PhysicalBone::JOINT_TYPE_PIN: {
+ case PhysicalBone3D::JOINT_TYPE_PIN: {
- JointSpatialGizmoPlugin::CreatePinJointGizmo(physical_bone->get_joint_offset(), points);
+ JointNode3DGizmoPlugin::CreatePinJointGizmo(physical_bone->get_joint_offset(), points);
} break;
- case PhysicalBone::JOINT_TYPE_CONE: {
+ case PhysicalBone3D::JOINT_TYPE_CONE: {
- const PhysicalBone::ConeJointData *cjd(static_cast<const PhysicalBone::ConeJointData *>(physical_bone->get_joint_data()));
- JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(
+ const PhysicalBone3D::ConeJointData *cjd(static_cast<const PhysicalBone3D::ConeJointData *>(physical_bone->get_joint_data()));
+ JointNode3DGizmoPlugin::CreateConeTwistJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb->get_global_transform(),
@@ -1879,10 +1879,10 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
&points,
&points);
} break;
- case PhysicalBone::JOINT_TYPE_HINGE: {
+ case PhysicalBone3D::JOINT_TYPE_HINGE: {
- const PhysicalBone::HingeJointData *hjd(static_cast<const PhysicalBone::HingeJointData *>(physical_bone->get_joint_data()));
- JointSpatialGizmoPlugin::CreateHingeJointGizmo(
+ const PhysicalBone3D::HingeJointData *hjd(static_cast<const PhysicalBone3D::HingeJointData *>(physical_bone->get_joint_data()));
+ JointNode3DGizmoPlugin::CreateHingeJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb->get_global_transform(),
@@ -1894,10 +1894,10 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
&points,
&points);
} break;
- case PhysicalBone::JOINT_TYPE_SLIDER: {
+ case PhysicalBone3D::JOINT_TYPE_SLIDER: {
- const PhysicalBone::SliderJointData *sjd(static_cast<const PhysicalBone::SliderJointData *>(physical_bone->get_joint_data()));
- JointSpatialGizmoPlugin::CreateSliderJointGizmo(
+ const PhysicalBone3D::SliderJointData *sjd(static_cast<const PhysicalBone3D::SliderJointData *>(physical_bone->get_joint_data()));
+ JointNode3DGizmoPlugin::CreateSliderJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb->get_global_transform(),
@@ -1910,10 +1910,10 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
&points,
&points);
} break;
- case PhysicalBone::JOINT_TYPE_6DOF: {
+ case PhysicalBone3D::JOINT_TYPE_6DOF: {
- const PhysicalBone::SixDOFJointData *sdofjd(static_cast<const PhysicalBone::SixDOFJointData *>(physical_bone->get_joint_data()));
- JointSpatialGizmoPlugin::CreateGeneric6DOFJointGizmo(
+ const PhysicalBone3D::SixDOFJointData *sdofjd(static_cast<const PhysicalBone3D::SixDOFJointData *>(physical_bone->get_joint_data()));
+ JointNode3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
@@ -1957,7 +1957,7 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
/////
-RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() {
+RayCastNode3DGizmoPlugin::RayCastNode3DGizmoPlugin() {
const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
@@ -1966,21 +1966,21 @@ RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() {
create_material("shape_material_disabled", gizmo_color_disabled);
}
-bool RayCastSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<RayCast>(p_spatial) != NULL;
+bool RayCastNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<RayCast3D>(p_spatial) != NULL;
}
-String RayCastSpatialGizmoPlugin::get_name() const {
+String RayCastNode3DGizmoPlugin::get_name() const {
return "RayCast";
}
-int RayCastSpatialGizmoPlugin::get_priority() const {
+int RayCastNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void RayCastNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- RayCast *raycast = Object::cast_to<RayCast>(p_gizmo->get_spatial_node());
+ RayCast3D *raycast = Object::cast_to<RayCast3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1998,9 +1998,9 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
/////
-void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void SpringArmNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- SpringArm *spring_arm = Object::cast_to<SpringArm>(p_gizmo->get_spatial_node());
+ SpringArm3D *spring_arm = Object::cast_to<SpringArm3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2015,46 +2015,46 @@ void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_collision_segments(lines);
}
-SpringArmSpatialGizmoPlugin::SpringArmSpatialGizmoPlugin() {
+SpringArmNode3DGizmoPlugin::SpringArmNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
}
-bool SpringArmSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<SpringArm>(p_spatial) != NULL;
+bool SpringArmNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<SpringArm3D>(p_spatial) != NULL;
}
-String SpringArmSpatialGizmoPlugin::get_name() const {
+String SpringArmNode3DGizmoPlugin::get_name() const {
return "SpringArm";
}
-int SpringArmSpatialGizmoPlugin::get_priority() const {
+int SpringArmNode3DGizmoPlugin::get_priority() const {
return -1;
}
/////
-VehicleWheelSpatialGizmoPlugin::VehicleWheelSpatialGizmoPlugin() {
+VehicleWheelNode3DGizmoPlugin::VehicleWheelNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
}
-bool VehicleWheelSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<VehicleWheel>(p_spatial) != NULL;
+bool VehicleWheelNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<VehicleWheel3D>(p_spatial) != NULL;
}
-String VehicleWheelSpatialGizmoPlugin::get_name() const {
+String VehicleWheelNode3DGizmoPlugin::get_name() const {
return "VehicleWheel";
}
-int VehicleWheelSpatialGizmoPlugin::get_priority() const {
+int VehicleWheelNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void VehicleWheelSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void VehicleWheelNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- VehicleWheel *car_wheel = Object::cast_to<VehicleWheel>(p_gizmo->get_spatial_node());
+ VehicleWheel3D *car_wheel = Object::cast_to<VehicleWheel3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2108,30 +2108,30 @@ void VehicleWheelSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
///////////
-SoftBodySpatialGizmoPlugin::SoftBodySpatialGizmoPlugin() {
+SoftBodyNode3DGizmoPlugin::SoftBodyNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
create_handle_material("handles");
}
-bool SoftBodySpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<SoftBody>(p_spatial) != NULL;
+bool SoftBodyNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<SoftBody3D>(p_spatial) != NULL;
}
-String SoftBodySpatialGizmoPlugin::get_name() const {
+String SoftBodyNode3DGizmoPlugin::get_name() const {
return "SoftBody";
}
-int SoftBodySpatialGizmoPlugin::get_priority() const {
+int SoftBodyNode3DGizmoPlugin::get_priority() const {
return -1;
}
-bool SoftBodySpatialGizmoPlugin::is_selectable_when_hidden() const {
+bool SoftBodyNode3DGizmoPlugin::is_selectable_when_hidden() const {
return true;
}
-void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
- SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
+void SoftBodyNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2161,22 +2161,22 @@ void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_collision_triangles(tm);
}
-String SoftBodySpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String SoftBodyNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
return "SoftBody pin point";
}
-Variant SoftBodySpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
- SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
+Variant SoftBodyNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
return Variant(soft_body->is_point_pinned(p_idx));
}
-void SoftBodySpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
+void SoftBodyNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
soft_body->pin_point_toggle(p_idx);
}
-bool SoftBodySpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const {
- SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node());
+bool SoftBodyNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const {
+ SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
return soft_body->is_point_pinned(idx);
}
@@ -2190,8 +2190,8 @@ VisibilityNotifierGizmoPlugin::VisibilityNotifierGizmoPlugin() {
create_handle_material("handles");
}
-bool VisibilityNotifierGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<VisibilityNotifier>(p_spatial) != NULL;
+bool VisibilityNotifierGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<VisibilityNotifier3D>(p_spatial) != NULL;
}
String VisibilityNotifierGizmoPlugin::get_name() const {
@@ -2202,7 +2202,7 @@ int VisibilityNotifierGizmoPlugin::get_priority() const {
return -1;
}
-String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
switch (p_idx) {
case 0: return "Size X";
@@ -2216,14 +2216,14 @@ String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *
return "";
}
-Variant VisibilityNotifierGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant VisibilityNotifierGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
+ VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
return notifier->get_aabb();
}
-void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void VisibilityNotifierGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
+ VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
Transform gt = notifier->get_global_transform();
@@ -2249,8 +2249,8 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int
Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5;
@@ -2261,8 +2261,8 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int
Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx] - ofs[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -2274,25 +2274,25 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int
}
}
-void VisibilityNotifierGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void VisibilityNotifierGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
+ VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
notifier->set_aabb(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Notifier AABB"));
ur->add_do_method(notifier, "set_aabb", notifier->get_aabb());
ur->add_undo_method(notifier, "set_aabb", p_restore);
ur->commit_action();
}
-void VisibilityNotifierGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void VisibilityNotifierGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node());
+ VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2343,11 +2343,11 @@ void VisibilityNotifierGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
////
CPUParticlesGizmoPlugin::CPUParticlesGizmoPlugin() {
- create_icon_material("particles_icon", SpatialEditor::get_singleton()->get_icon("GizmoCPUParticles", "EditorIcons"));
+ create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCPUParticles", "EditorIcons"));
}
-bool CPUParticlesGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<CPUParticles>(p_spatial) != NULL;
+bool CPUParticlesGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<CPUParticles3D>(p_spatial) != NULL;
}
String CPUParticlesGizmoPlugin::get_name() const {
@@ -2362,7 +2362,7 @@ bool CPUParticlesGizmoPlugin::is_selectable_when_hidden() const {
return true;
}
-void CPUParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void CPUParticlesGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Ref<Material> icon = get_material("particles_icon", p_gizmo);
p_gizmo->add_unscaled_billboard(icon, 0.05);
}
@@ -2374,12 +2374,12 @@ ParticlesGizmoPlugin::ParticlesGizmoPlugin() {
create_material("particles_material", gizmo_color);
gizmo_color.a = 0.1;
create_material("particles_solid_material", gizmo_color);
- create_icon_material("particles_icon", SpatialEditor::get_singleton()->get_icon("GizmoParticles", "EditorIcons"));
+ create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoParticles", "EditorIcons"));
create_handle_material("handles");
}
-bool ParticlesGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<Particles>(p_spatial) != NULL;
+bool ParticlesGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<GPUParticles3D>(p_spatial) != NULL;
}
String ParticlesGizmoPlugin::get_name() const {
@@ -2394,7 +2394,7 @@ bool ParticlesGizmoPlugin::is_selectable_when_hidden() const {
return true;
}
-String ParticlesGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String ParticlesGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
switch (p_idx) {
case 0: return "Size X";
@@ -2407,14 +2407,14 @@ String ParticlesGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo,
return "";
}
-Variant ParticlesGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant ParticlesGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
return particles->get_visibility_aabb();
}
-void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void ParticlesGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
Transform gt = particles->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -2439,8 +2439,8 @@ void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Ca
Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5;
@@ -2451,8 +2451,8 @@ void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Ca
Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx] - ofs[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -2464,25 +2464,25 @@ void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Ca
}
}
-void ParticlesGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void ParticlesGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
particles->set_visibility_aabb(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Particles AABB"));
ur->add_do_method(particles, "set_visibility_aabb", particles->get_visibility_aabb());
ur->add_undo_method(particles, "set_visibility_aabb", p_restore);
ur->commit_action();
}
-void ParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void ParticlesGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node());
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2543,11 +2543,11 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() {
gizmo_color.a = 0.1;
create_material("reflection_probe_solid_material", gizmo_color);
- create_icon_material("reflection_probe_icon", SpatialEditor::get_singleton()->get_icon("GizmoReflectionProbe", "EditorIcons"));
+ create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoReflectionProbe", "EditorIcons"));
create_handle_material("handles");
}
-bool ReflectionProbeGizmoPlugin::has_gizmo(Spatial *p_spatial) {
+bool ReflectionProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<ReflectionProbe>(p_spatial) != NULL;
}
@@ -2559,7 +2559,7 @@ int ReflectionProbeGizmoPlugin::get_priority() const {
return -1;
}
-String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
switch (p_idx) {
case 0: return "Extents X";
@@ -2572,12 +2572,12 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_g
return "";
}
-Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
return AABB(probe->get_extents(), probe->get_origin_offset());
}
-void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform();
@@ -2598,8 +2598,8 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -2626,8 +2626,8 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
Geometry::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb);
// Adjust the actual position to account for the gizmo handle position
float d = ra[p_idx] + 0.25;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
origin[p_idx] = d;
@@ -2635,7 +2635,7 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
}
}
-void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
@@ -2647,7 +2647,7 @@ void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Probe Extents"));
ur->add_do_method(probe, "set_extents", probe->get_extents());
ur->add_do_method(probe, "set_origin_offset", probe->get_origin_offset());
@@ -2656,7 +2656,7 @@ void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
-void ReflectionProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
@@ -2731,11 +2731,11 @@ GIProbeGizmoPlugin::GIProbeGizmoPlugin() {
gizmo_color.a = 0.05;
create_material("gi_probe_solid_material", gizmo_color);
- create_icon_material("gi_probe_icon", SpatialEditor::get_singleton()->get_icon("GizmoGIProbe", "EditorIcons"));
+ create_icon_material("gi_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGIProbe", "EditorIcons"));
create_handle_material("handles");
}
-bool GIProbeGizmoPlugin::has_gizmo(Spatial *p_spatial) {
+bool GIProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<GIProbe>(p_spatial) != NULL;
}
@@ -2747,7 +2747,7 @@ int GIProbeGizmoPlugin::get_priority() const {
return -1;
}
-String GIProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
switch (p_idx) {
case 0: return "Extents X";
@@ -2757,12 +2757,12 @@ String GIProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, in
return "";
}
-Variant GIProbeGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
return probe->get_extents();
}
-void GIProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
@@ -2782,8 +2782,8 @@ void GIProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Came
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -2793,7 +2793,7 @@ void GIProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Came
probe->set_extents(extents);
}
-void GIProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
@@ -2804,14 +2804,14 @@ void GIProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, c
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Probe Extents"));
ur->add_do_method(probe, "set_extents", probe->get_extents());
ur->add_undo_method(probe, "set_extents", restore);
ur->commit_action();
}
-void GIProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
@@ -2911,11 +2911,11 @@ BakedIndirectLightGizmoPlugin::BakedIndirectLightGizmoPlugin() {
gizmo_color.a = 0.1;
create_material("baked_indirect_light_internal_material", gizmo_color);
- create_icon_material("baked_indirect_light_icon", SpatialEditor::get_singleton()->get_icon("GizmoBakedLightmap", "EditorIcons"));
+ create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_icon("GizmoBakedLightmap", "EditorIcons"));
create_handle_material("handles");
}
-String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
switch (p_idx) {
case 0: return "Extents X";
@@ -2925,12 +2925,12 @@ String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorSpatialGizmo *
return "";
}
-Variant BakedIndirectLightGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant BakedIndirectLightGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
return baker->get_extents();
}
-void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void BakedIndirectLightGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
@@ -2950,8 +2950,8 @@ void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -2961,7 +2961,7 @@ void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int
baker->set_extents(extents);
}
-void BakedIndirectLightGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void BakedIndirectLightGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
@@ -2972,7 +2972,7 @@ void BakedIndirectLightGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, i
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Probe Extents"));
ur->add_do_method(baker, "set_extents", baker->get_extents());
ur->add_undo_method(baker, "set_extents", restore);
@@ -2991,7 +2991,7 @@ int BakedIndirectLightGizmoPlugin::get_priority() const {
return -1;
}
-void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void BakedIndirectLightGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
@@ -3034,7 +3034,7 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
#endif
////
-CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() {
+CollisionShapeNode3DGizmoPlugin::CollisionShapeNode3DGizmoPlugin() {
const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
const float gizmo_value = gizmo_color.get_v();
@@ -3043,47 +3043,47 @@ CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() {
create_handle_material("handles");
}
-bool CollisionShapeSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<CollisionShape>(p_spatial) != NULL;
+bool CollisionShapeNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<CollisionShape3D>(p_spatial) != NULL;
}
-String CollisionShapeSpatialGizmoPlugin::get_name() const {
- return "CollisionShape";
+String CollisionShapeNode3DGizmoPlugin::get_name() const {
+ return "CollisionShape3D";
}
-int CollisionShapeSpatialGizmoPlugin::get_priority() const {
+int CollisionShapeNode3DGizmoPlugin::get_priority() const {
return -1;
}
-String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String CollisionShapeNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
- const CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
+ const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
- Ref<Shape> s = cs->get_shape();
+ Ref<Shape3D> s = cs->get_shape();
if (s.is_null())
return "";
- if (Object::cast_to<SphereShape>(*s)) {
+ if (Object::cast_to<SphereShape3D>(*s)) {
return "Radius";
}
- if (Object::cast_to<BoxShape>(*s)) {
+ if (Object::cast_to<BoxShape3D>(*s)) {
return "Extents";
}
- if (Object::cast_to<CapsuleShape>(*s)) {
+ if (Object::cast_to<CapsuleShape3D>(*s)) {
return p_idx == 0 ? "Radius" : "Height";
}
- if (Object::cast_to<CylinderShape>(*s)) {
+ if (Object::cast_to<CylinderShape3D>(*s)) {
return p_idx == 0 ? "Radius" : "Height";
}
- if (Object::cast_to<RayShape>(*s)) {
+ if (Object::cast_to<RayShape3D>(*s)) {
return "Length";
}
@@ -3091,51 +3091,51 @@ String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizm
return "";
}
-Variant CollisionShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant CollisionShapeNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
- Ref<Shape> s = cs->get_shape();
+ Ref<Shape3D> s = cs->get_shape();
if (s.is_null())
return Variant();
- if (Object::cast_to<SphereShape>(*s)) {
+ if (Object::cast_to<SphereShape3D>(*s)) {
- Ref<SphereShape> ss = s;
+ Ref<SphereShape3D> ss = s;
return ss->get_radius();
}
- if (Object::cast_to<BoxShape>(*s)) {
+ if (Object::cast_to<BoxShape3D>(*s)) {
- Ref<BoxShape> bs = s;
+ Ref<BoxShape3D> bs = s;
return bs->get_extents();
}
- if (Object::cast_to<CapsuleShape>(*s)) {
+ if (Object::cast_to<CapsuleShape3D>(*s)) {
- Ref<CapsuleShape> cs2 = s;
+ Ref<CapsuleShape3D> cs2 = s;
return p_idx == 0 ? cs2->get_radius() : cs2->get_height();
}
- if (Object::cast_to<CylinderShape>(*s)) {
+ if (Object::cast_to<CylinderShape3D>(*s)) {
- Ref<CylinderShape> cs2 = s;
+ Ref<CylinderShape3D> cs2 = s;
return p_idx == 0 ? cs2->get_radius() : cs2->get_height();
}
- if (Object::cast_to<RayShape>(*s)) {
+ if (Object::cast_to<RayShape3D>(*s)) {
- Ref<RayShape> cs2 = s;
+ Ref<RayShape3D> cs2 = s;
return cs2->get_length();
}
return Variant();
}
-void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void CollisionShapeNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
- Ref<Shape> s = cs->get_shape();
+ Ref<Shape3D> s = cs->get_shape();
if (s.is_null())
return;
@@ -3147,14 +3147,14 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
- if (Object::cast_to<SphereShape>(*s)) {
+ if (Object::cast_to<SphereShape3D>(*s)) {
- Ref<SphereShape> ss = s;
+ Ref<SphereShape3D> ss = s;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -3163,14 +3163,14 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
ss->set_radius(d);
}
- if (Object::cast_to<RayShape>(*s)) {
+ if (Object::cast_to<RayShape3D>(*s)) {
- Ref<RayShape> rs = s;
+ Ref<RayShape3D> rs = s;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, 4096), sg[0], sg[1], ra, rb);
float d = ra.z;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -3179,16 +3179,16 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
rs->set_length(d);
}
- if (Object::cast_to<BoxShape>(*s)) {
+ if (Object::cast_to<BoxShape3D>(*s)) {
Vector3 axis;
axis[p_idx] = 1.0;
- Ref<BoxShape> bs = s;
+ Ref<BoxShape3D> bs = s;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -3199,19 +3199,19 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
bs->set_extents(he);
}
- if (Object::cast_to<CapsuleShape>(*s)) {
+ if (Object::cast_to<CapsuleShape3D>(*s)) {
Vector3 axis;
axis[p_idx == 0 ? 0 : 2] = 1.0;
- Ref<CapsuleShape> cs2 = s;
+ Ref<CapsuleShape3D> cs2 = s;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
if (p_idx == 1)
d -= cs2->get_radius();
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -3223,16 +3223,16 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
cs2->set_height(d * 2.0);
}
- if (Object::cast_to<CylinderShape>(*s)) {
+ if (Object::cast_to<CylinderShape3D>(*s)) {
Vector3 axis;
axis[p_idx == 0 ? 0 : 1] = 1.0;
- Ref<CylinderShape> cs2 = s;
+ Ref<CylinderShape3D> cs2 = s;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -3244,47 +3244,47 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i
cs2->set_height(d * 2.0);
}
}
-void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void CollisionShapeNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
- Ref<Shape> s = cs->get_shape();
+ Ref<Shape3D> s = cs->get_shape();
if (s.is_null())
return;
- if (Object::cast_to<SphereShape>(*s)) {
+ if (Object::cast_to<SphereShape3D>(*s)) {
- Ref<SphereShape> ss = s;
+ Ref<SphereShape3D> ss = s;
if (p_cancel) {
ss->set_radius(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Sphere Shape Radius"));
ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius());
ur->add_undo_method(ss.ptr(), "set_radius", p_restore);
ur->commit_action();
}
- if (Object::cast_to<BoxShape>(*s)) {
+ if (Object::cast_to<BoxShape3D>(*s)) {
- Ref<BoxShape> ss = s;
+ Ref<BoxShape3D> ss = s;
if (p_cancel) {
ss->set_extents(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Box Shape Extents"));
ur->add_do_method(ss.ptr(), "set_extents", ss->get_extents());
ur->add_undo_method(ss.ptr(), "set_extents", p_restore);
ur->commit_action();
}
- if (Object::cast_to<CapsuleShape>(*s)) {
+ if (Object::cast_to<CapsuleShape3D>(*s)) {
- Ref<CapsuleShape> ss = s;
+ Ref<CapsuleShape3D> ss = s;
if (p_cancel) {
if (p_idx == 0)
ss->set_radius(p_restore);
@@ -3293,7 +3293,7 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx == 0) {
ur->create_action(TTR("Change Capsule Shape Radius"));
ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius());
@@ -3307,9 +3307,9 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo
ur->commit_action();
}
- if (Object::cast_to<CylinderShape>(*s)) {
+ if (Object::cast_to<CylinderShape3D>(*s)) {
- Ref<CylinderShape> ss = s;
+ Ref<CylinderShape3D> ss = s;
if (p_cancel) {
if (p_idx == 0)
ss->set_radius(p_restore);
@@ -3318,7 +3318,7 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx == 0) {
ur->create_action(TTR("Change Cylinder Shape Radius"));
ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius());
@@ -3336,28 +3336,28 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo
ur->commit_action();
}
- if (Object::cast_to<RayShape>(*s)) {
+ if (Object::cast_to<RayShape3D>(*s)) {
- Ref<RayShape> ss = s;
+ Ref<RayShape3D> ss = s;
if (p_cancel) {
ss->set_length(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Ray Shape Length"));
ur->add_do_method(ss.ptr(), "set_length", ss->get_length());
ur->add_undo_method(ss.ptr(), "set_length", p_restore);
ur->commit_action();
}
}
-void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void CollisionShapeNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node());
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
- Ref<Shape> s = cs->get_shape();
+ Ref<Shape3D> s = cs->get_shape();
if (s.is_null())
return;
@@ -3365,9 +3365,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
get_material(!cs->is_disabled() ? "shape_material" : "shape_material_disabled", p_gizmo);
Ref<Material> handles_material = get_material("handles");
- if (Object::cast_to<SphereShape>(*s)) {
+ if (Object::cast_to<SphereShape3D>(*s)) {
- Ref<SphereShape> sp = s;
+ Ref<SphereShape3D> sp = s;
float r = sp->get_radius();
Vector<Vector3> points;
@@ -3411,9 +3411,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<BoxShape>(*s)) {
+ if (Object::cast_to<BoxShape3D>(*s)) {
- Ref<BoxShape> bs = s;
+ Ref<BoxShape3D> bs = s;
Vector<Vector3> lines;
AABB aabb;
aabb.position = -bs->get_extents();
@@ -3440,9 +3440,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CapsuleShape>(*s)) {
+ if (Object::cast_to<CapsuleShape3D>(*s)) {
- Ref<CapsuleShape> cs2 = s;
+ Ref<CapsuleShape3D> cs2 = s;
float radius = cs2->get_radius();
float height = cs2->get_height();
@@ -3515,9 +3515,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CylinderShape>(*s)) {
+ if (Object::cast_to<CylinderShape3D>(*s)) {
- Ref<CylinderShape> cs2 = s;
+ Ref<CylinderShape3D> cs2 = s;
float radius = cs2->get_radius();
float height = cs2->get_height();
@@ -3576,9 +3576,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<WorldMarginShape>(*s)) {
+ if (Object::cast_to<WorldMarginShape3D>(*s)) {
- Ref<WorldMarginShape> ps = s;
+ Ref<WorldMarginShape3D> ps = s;
Plane p = ps->get_plane();
Vector<Vector3> points;
@@ -3607,9 +3607,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_collision_segments(points);
}
- if (Object::cast_to<ConvexPolygonShape>(*s)) {
+ if (Object::cast_to<ConvexPolygonShape3D>(*s)) {
- Vector<Vector3> points = Object::cast_to<ConvexPolygonShape>(*s)->get_points();
+ Vector<Vector3> points = Object::cast_to<ConvexPolygonShape3D>(*s)->get_points();
if (points.size() > 3) {
@@ -3630,17 +3630,17 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
}
- if (Object::cast_to<ConcavePolygonShape>(*s)) {
+ if (Object::cast_to<ConcavePolygonShape3D>(*s)) {
- Ref<ConcavePolygonShape> cs2 = s;
+ Ref<ConcavePolygonShape3D> cs2 = s;
Ref<ArrayMesh> mesh = cs2->get_debug_mesh();
p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material);
p_gizmo->add_collision_segments(cs2->get_debug_mesh_lines());
}
- if (Object::cast_to<RayShape>(*s)) {
+ if (Object::cast_to<RayShape3D>(*s)) {
- Ref<RayShape> rs = s;
+ Ref<RayShape3D> rs = s;
Vector<Vector3> points;
points.push_back(Vector3());
@@ -3652,9 +3652,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<HeightMapShape>(*s)) {
+ if (Object::cast_to<HeightMapShape3D>(*s)) {
- Ref<HeightMapShape> hms = s;
+ Ref<HeightMapShape3D> hms = s;
Ref<ArrayMesh> mesh = hms->get_debug_mesh();
p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material);
@@ -3663,7 +3663,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
/////
-CollisionPolygonSpatialGizmoPlugin::CollisionPolygonSpatialGizmoPlugin() {
+CollisionPolygonNode3DGizmoPlugin::CollisionPolygonNode3DGizmoPlugin() {
const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
const float gizmo_value = gizmo_color.get_v();
@@ -3671,21 +3671,21 @@ CollisionPolygonSpatialGizmoPlugin::CollisionPolygonSpatialGizmoPlugin() {
create_material("shape_material_disabled", gizmo_color_disabled);
}
-bool CollisionPolygonSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<CollisionPolygon>(p_spatial) != NULL;
+bool CollisionPolygonNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<CollisionPolygon3D>(p_spatial) != NULL;
}
-String CollisionPolygonSpatialGizmoPlugin::get_name() const {
- return "CollisionPolygon";
+String CollisionPolygonNode3DGizmoPlugin::get_name() const {
+ return "CollisionPolygon3D";
}
-int CollisionPolygonSpatialGizmoPlugin::get_priority() const {
+int CollisionPolygonNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void CollisionPolygonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void CollisionPolygonNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CollisionPolygon *polygon = Object::cast_to<CollisionPolygon>(p_gizmo->get_spatial_node());
+ CollisionPolygon3D *polygon = Object::cast_to<CollisionPolygon3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -3713,28 +3713,28 @@ void CollisionPolygonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
////
-NavigationMeshSpatialGizmoPlugin::NavigationMeshSpatialGizmoPlugin() {
+NavigationMeshNode3DGizmoPlugin::NavigationMeshNode3DGizmoPlugin() {
create_material("navigation_edge_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge", Color(0.5, 1, 1)));
create_material("navigation_edge_material_disabled", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled", Color(0.7, 0.7, 0.7)));
create_material("navigation_solid_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid", Color(0.5, 1, 1, 0.4)));
create_material("navigation_solid_material_disabled", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled", Color(0.7, 0.7, 0.7, 0.4)));
}
-bool NavigationMeshSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<NavigationRegion>(p_spatial) != NULL;
+bool NavigationMeshNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<NavigationRegion3D>(p_spatial) != NULL;
}
-String NavigationMeshSpatialGizmoPlugin::get_name() const {
+String NavigationMeshNode3DGizmoPlugin::get_name() const {
return "NavigationRegion";
}
-int NavigationMeshSpatialGizmoPlugin::get_priority() const {
+int NavigationMeshNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void NavigationMeshNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- NavigationRegion *navmesh = Object::cast_to<NavigationRegion>(p_gizmo->get_spatial_node());
+ NavigationRegion3D *navmesh = Object::cast_to<NavigationRegion3D>(p_gizmo->get_spatial_node());
Ref<Material> edge_material = get_material("navigation_edge_material", p_gizmo);
Ref<Material> edge_material_disabled = get_material("navigation_edge_material_disabled", p_gizmo);
@@ -4078,37 +4078,37 @@ void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base
////
-JointSpatialGizmoPlugin::JointSpatialGizmoPlugin() {
+JointNode3DGizmoPlugin::JointNode3DGizmoPlugin() {
create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1)));
create_material("joint_body_a_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_a", Color(0.6, 0.8, 1)));
create_material("joint_body_b_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_b", Color(0.6, 0.9, 1)));
}
-bool JointSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<Joint>(p_spatial) != NULL;
+bool JointNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<Joint3D>(p_spatial) != NULL;
}
-String JointSpatialGizmoPlugin::get_name() const {
+String JointNode3DGizmoPlugin::get_name() const {
return "Joints";
}
-int JointSpatialGizmoPlugin::get_priority() const {
+int JointNode3DGizmoPlugin::get_priority() const {
return -1;
}
-void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
- Joint *joint = Object::cast_to<Joint>(p_gizmo->get_spatial_node());
+void JointNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
+ Joint3D *joint = Object::cast_to<Joint3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
- Spatial *node_body_a = NULL;
+ Node3D *node_body_a = NULL;
if (!joint->get_node_a().is_empty()) {
- node_body_a = Object::cast_to<Spatial>(joint->get_node(joint->get_node_a()));
+ node_body_a = Object::cast_to<Node3D>(joint->get_node(joint->get_node_a()));
}
- Spatial *node_body_b = NULL;
+ Node3D *node_body_b = NULL;
if (!joint->get_node_b().is_empty()) {
- node_body_b = Object::cast_to<Spatial>(joint->get_node(joint->get_node_b()));
+ node_body_b = Object::cast_to<Node3D>(joint->get_node(joint->get_node_b()));
}
if (!node_body_a && !node_body_b) {
@@ -4123,13 +4123,13 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Vector<Vector3> body_a_points;
Vector<Vector3> body_b_points;
- if (Object::cast_to<PinJoint>(joint)) {
+ if (Object::cast_to<PinJoint3D>(joint)) {
CreatePinJointGizmo(Transform(), points);
p_gizmo->add_collision_segments(points);
p_gizmo->add_lines(points, common_material);
}
- HingeJoint *hinge = Object::cast_to<HingeJoint>(joint);
+ HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint);
if (hinge) {
CreateHingeJointGizmo(
@@ -4137,9 +4137,9 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
hinge->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(),
node_body_b ? node_body_b->get_global_transform() : Transform(),
- hinge->get_param(HingeJoint::PARAM_LIMIT_LOWER),
- hinge->get_param(HingeJoint::PARAM_LIMIT_UPPER),
- hinge->get_flag(HingeJoint::FLAG_USE_LIMIT),
+ hinge->get_param(HingeJoint3D::PARAM_LIMIT_LOWER),
+ hinge->get_param(HingeJoint3D::PARAM_LIMIT_UPPER),
+ hinge->get_flag(HingeJoint3D::FLAG_USE_LIMIT),
points,
node_body_a ? &body_a_points : NULL,
node_body_b ? &body_b_points : NULL);
@@ -4153,7 +4153,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_lines(body_b_points, body_b_material);
}
- SliderJoint *slider = Object::cast_to<SliderJoint>(joint);
+ SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint);
if (slider) {
CreateSliderJointGizmo(
@@ -4161,10 +4161,10 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
slider->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(),
node_body_b ? node_body_b->get_global_transform() : Transform(),
- slider->get_param(SliderJoint::PARAM_ANGULAR_LIMIT_LOWER),
- slider->get_param(SliderJoint::PARAM_ANGULAR_LIMIT_UPPER),
- slider->get_param(SliderJoint::PARAM_LINEAR_LIMIT_LOWER),
- slider->get_param(SliderJoint::PARAM_LINEAR_LIMIT_UPPER),
+ slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_LOWER),
+ slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_UPPER),
+ slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_LOWER),
+ slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_UPPER),
points,
node_body_a ? &body_a_points : NULL,
node_body_b ? &body_b_points : NULL);
@@ -4178,7 +4178,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_lines(body_b_points, body_b_material);
}
- ConeTwistJoint *cone = Object::cast_to<ConeTwistJoint>(joint);
+ ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint);
if (cone) {
CreateConeTwistJointGizmo(
@@ -4186,8 +4186,8 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
cone->get_global_transform(),
node_body_a ? node_body_a->get_global_transform() : Transform(),
node_body_b ? node_body_b->get_global_transform() : Transform(),
- cone->get_param(ConeTwistJoint::PARAM_SWING_SPAN),
- cone->get_param(ConeTwistJoint::PARAM_TWIST_SPAN),
+ cone->get_param(ConeTwistJoint3D::PARAM_SWING_SPAN),
+ cone->get_param(ConeTwistJoint3D::PARAM_TWIST_SPAN),
node_body_a ? &body_a_points : NULL,
node_body_b ? &body_b_points : NULL);
@@ -4198,7 +4198,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_lines(body_b_points, body_b_material);
}
- Generic6DOFJoint *gen = Object::cast_to<Generic6DOFJoint>(joint);
+ Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint);
if (gen) {
CreateGeneric6DOFJointGizmo(
@@ -4207,26 +4207,26 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
node_body_a ? node_body_a->get_global_transform() : Transform(),
node_body_b ? node_body_b->get_global_transform() : Transform(),
- gen->get_param_x(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT),
- gen->get_param_x(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT),
- gen->get_param_x(Generic6DOFJoint::PARAM_LINEAR_LOWER_LIMIT),
- gen->get_param_x(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT),
- gen->get_flag_x(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT),
- gen->get_flag_x(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT),
-
- gen->get_param_y(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT),
- gen->get_param_y(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT),
- gen->get_param_y(Generic6DOFJoint::PARAM_LINEAR_LOWER_LIMIT),
- gen->get_param_y(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT),
- gen->get_flag_y(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT),
- gen->get_flag_y(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT),
-
- gen->get_param_z(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT),
- gen->get_param_z(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT),
- gen->get_param_z(Generic6DOFJoint::PARAM_LINEAR_LOWER_LIMIT),
- gen->get_param_z(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT),
- gen->get_flag_z(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT),
- gen->get_flag_z(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT),
+ gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT),
+ gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT),
+ gen->get_param_x(Generic6DOFJoint3D::PARAM_LINEAR_LOWER_LIMIT),
+ gen->get_param_x(Generic6DOFJoint3D::PARAM_LINEAR_UPPER_LIMIT),
+ gen->get_flag_x(Generic6DOFJoint3D::FLAG_ENABLE_ANGULAR_LIMIT),
+ gen->get_flag_x(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT),
+
+ gen->get_param_y(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT),
+ gen->get_param_y(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT),
+ gen->get_param_y(Generic6DOFJoint3D::PARAM_LINEAR_LOWER_LIMIT),
+ gen->get_param_y(Generic6DOFJoint3D::PARAM_LINEAR_UPPER_LIMIT),
+ gen->get_flag_y(Generic6DOFJoint3D::FLAG_ENABLE_ANGULAR_LIMIT),
+ gen->get_flag_y(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT),
+
+ gen->get_param_z(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT),
+ gen->get_param_z(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT),
+ gen->get_param_z(Generic6DOFJoint3D::PARAM_LINEAR_LOWER_LIMIT),
+ gen->get_param_z(Generic6DOFJoint3D::PARAM_LINEAR_UPPER_LIMIT),
+ gen->get_flag_z(Generic6DOFJoint3D::FLAG_ENABLE_ANGULAR_LIMIT),
+ gen->get_flag_z(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT),
points,
node_body_a ? &body_a_points : NULL,
@@ -4242,7 +4242,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
}
-void JointSpatialGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points) {
+void JointNode3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points) {
float cs = 0.25;
r_cursor_points.push_back(p_offset.translated(Vector3(+cs, 0, 0)).origin);
@@ -4253,7 +4253,7 @@ void JointSpatialGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vec
r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, -cs)).origin);
}
-void JointSpatialGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
+void JointNode3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin);
r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin);
@@ -4285,7 +4285,7 @@ void JointSpatialGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, c
}
}
-void JointSpatialGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
+void JointNode3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
p_linear_limit_lower = -p_linear_limit_lower;
p_linear_limit_upper = -p_linear_limit_upper;
@@ -4345,7 +4345,7 @@ void JointSpatialGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset,
true);
}
-void JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
+void JointNode3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
if (r_body_a_points)
JointGizmosDrawer::draw_cone(
@@ -4364,7 +4364,7 @@ void JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offse
*r_body_b_points);
}
-void JointSpatialGizmoPlugin::CreateGeneric6DOFJointGizmo(
+void JointNode3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
const Transform &p_offset,
const Transform &p_trs_joint,
const Transform &p_trs_body_a,
diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h
new file mode 100644
index 0000000000..014b736a0d
--- /dev/null
+++ b/editor/node_3d_editor_gizmos.h
@@ -0,0 +1,434 @@
+/*************************************************************************/
+/* node_3d_editor_gizmos.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef SPATIAL_EDITOR_GIZMOS_H
+#define SPATIAL_EDITOR_GIZMOS_H
+
+#include "editor/plugins/node_3d_editor_plugin.h"
+#include "scene/3d/camera_3d.h"
+
+class Camera3D;
+
+class LightNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(LightNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ LightNode3DGizmoPlugin();
+};
+
+class AudioStreamPlayer3DNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(AudioStreamPlayer3DNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ AudioStreamPlayer3DNode3DGizmoPlugin();
+};
+
+class CameraNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(CameraNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ CameraNode3DGizmoPlugin();
+};
+
+class MeshInstanceNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(MeshInstanceNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ bool can_be_hidden() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ MeshInstanceNode3DGizmoPlugin();
+};
+
+class Sprite3DNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(Sprite3DNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ bool can_be_hidden() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ Sprite3DNode3DGizmoPlugin();
+};
+
+class Position3DNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(Position3DNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+ Ref<ArrayMesh> pos3d_mesh;
+ Vector<Vector3> cursor_points;
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ Position3DNode3DGizmoPlugin();
+};
+
+class SkeletonNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(SkeletonNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ SkeletonNode3DGizmoPlugin();
+};
+
+class PhysicalBoneNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(PhysicalBoneNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ PhysicalBoneNode3DGizmoPlugin();
+};
+
+class RayCastNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(RayCastNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ RayCastNode3DGizmoPlugin();
+};
+
+class SpringArmNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(SpringArmNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ SpringArmNode3DGizmoPlugin();
+};
+
+class VehicleWheelNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(VehicleWheelNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ VehicleWheelNode3DGizmoPlugin();
+};
+
+class SoftBodyNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(SoftBodyNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ bool is_selectable_when_hidden() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
+ bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const;
+
+ SoftBodyNode3DGizmoPlugin();
+};
+
+class VisibilityNotifierGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(VisibilityNotifierGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ VisibilityNotifierGizmoPlugin();
+};
+
+class CPUParticlesGizmoPlugin : public EditorNode3DGizmoPlugin {
+ GDCLASS(CPUParticlesGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ bool is_selectable_when_hidden() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+ CPUParticlesGizmoPlugin();
+};
+
+class ParticlesGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(ParticlesGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ bool is_selectable_when_hidden() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ ParticlesGizmoPlugin();
+};
+
+class ReflectionProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(ReflectionProbeGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ ReflectionProbeGizmoPlugin();
+};
+
+class GIProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(GIProbeGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ GIProbeGizmoPlugin();
+};
+
+#if 0
+class BakedIndirectLightGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(BakedIndirectLightGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Spatial *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ BakedIndirectLightGizmoPlugin();
+};
+#endif
+class CollisionShapeNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(CollisionShapeNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+
+ CollisionShapeNode3DGizmoPlugin();
+};
+
+class CollisionPolygonNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+ GDCLASS(CollisionPolygonNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+ CollisionPolygonNode3DGizmoPlugin();
+};
+
+class NavigationMeshNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(NavigationMeshNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+ struct _EdgeKey {
+
+ Vector3 from;
+ Vector3 to;
+
+ bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; }
+ };
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ NavigationMeshNode3DGizmoPlugin();
+};
+
+class JointGizmosDrawer {
+public:
+ static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform);
+ static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform);
+ static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform);
+ static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform);
+ /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis
+ /// with axis X and Y that are looking toward the body and oriented toward up
+ static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform);
+
+ // Draw circle around p_axis
+ static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false);
+ static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points);
+};
+
+class JointNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+
+ GDCLASS(JointNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial);
+ String get_name() const;
+ int get_priority() const;
+ void redraw(EditorNode3DGizmo *p_gizmo);
+
+ static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points);
+ static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
+ static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
+ static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
+ static void CreateGeneric6DOFJointGizmo(
+ const Transform &p_offset,
+ const Transform &p_trs_joint,
+ const Transform &p_trs_body_a,
+ const Transform &p_trs_body_b,
+ real_t p_angular_limit_lower_x,
+ real_t p_angular_limit_upper_x,
+ real_t p_linear_limit_lower_x,
+ real_t p_linear_limit_upper_x,
+ bool p_enable_angular_limit_x,
+ bool p_enable_linear_limit_x,
+ real_t p_angular_limit_lower_y,
+ real_t p_angular_limit_upper_y,
+ real_t p_linear_limit_lower_y,
+ real_t p_linear_limit_upper_y,
+ bool p_enable_angular_limit_y,
+ bool p_enable_linear_limit_y,
+ real_t p_angular_limit_lower_z,
+ real_t p_angular_limit_upper_z,
+ real_t p_linear_limit_lower_z,
+ real_t p_linear_limit_upper_z,
+ bool p_enable_angular_limit_z,
+ bool p_enable_linear_limit_z,
+ Vector<Vector3> &r_points,
+ Vector<Vector3> *r_body_a_points,
+ Vector<Vector3> *r_body_b_points);
+
+ JointNode3DGizmoPlugin();
+};
+
+#endif // SPATIAL_EDITOR_GIZMOS_H
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index 3013406152..0c511e4819 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -55,8 +55,8 @@ void NodeDock::_bind_methods() {
void NodeDock::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- connections_button->set_icon(get_icon("Signals", "EditorIcons"));
- groups_button->set_icon(get_icon("Groups", "EditorIcons"));
+ connections_button->set_icon(get_theme_icon("Signals", "EditorIcons"));
+ groups_button->set_icon(get_theme_icon("Groups", "EditorIcons"));
}
}
diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp
index b143f86ada..ce90fa94dc 100644
--- a/editor/pane_drag.cpp
+++ b/editor/pane_drag.cpp
@@ -45,7 +45,7 @@ void PaneDrag::_notification(int p_what) {
case NOTIFICATION_DRAW: {
- Ref<Texture2D> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons");
+ Ref<Texture2D> icon = mouse_over ? get_theme_icon("PaneDragHover", "EditorIcons") : get_theme_icon("PaneDrag", "EditorIcons");
if (!icon.is_null())
icon->draw(get_canvas_item(), Point2(0, 0));
@@ -62,7 +62,7 @@ void PaneDrag::_notification(int p_what) {
}
Size2 PaneDrag::get_minimum_size() const {
- Ref<Texture2D> icon = get_icon("PaneDrag", "EditorIcons");
+ Ref<Texture2D> icon = get_theme_icon("PaneDrag", "EditorIcons");
if (!icon.is_null())
return icon->get_size();
return Size2();
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp
index 1e7c625abb..4317a5e80f 100644
--- a/editor/plugin_config_dialog.cpp
+++ b/editor/plugin_config_dialog.cpp
@@ -131,14 +131,15 @@ void PluginConfigDialog::_on_required_text_changed(const String &) {
void PluginConfigDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (is_visible()) {
+ name_edit->grab_focus();
+ }
+ } break;
case NOTIFICATION_READY: {
connect("confirmed", callable_mp(this, &PluginConfigDialog::_on_confirmed));
get_cancel()->connect("pressed", callable_mp(this, &PluginConfigDialog::_on_cancelled));
} break;
-
- case NOTIFICATION_POST_POPUP: {
- name_edit->grab_focus();
- } break;
}
}
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 8d5444db73..e3e9eae31a 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -204,9 +204,9 @@ void AbstractPolygon2DEditor::_notification(int p_what) {
disable_polygon_editing(false, String());
- button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
- button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
- button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
+ button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons"));
+ button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons"));
+ button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons"));
button_edit->set_pressed(true);
get_tree()->connect("node_removed", callable_mp(this, &AbstractPolygon2DEditor::_node_removed));
@@ -310,7 +310,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
create_resource->set_text(String("No polygon resource on this node.\nCreate and assign one?"));
- create_resource->popup_centered_minsize();
+ create_resource->popup_centered();
}
return (mb.is_valid() && mb->get_button_index() == 1);
}
@@ -573,7 +573,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
// All polygon points are sharp, so use the sharp handle icon
- const Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
+ const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons");
const Vertex active_point = get_active_point();
const int n_polygons = _get_polygon_count();
@@ -651,7 +651,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate);
if (vertex == hover_point) {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
String num = String::num(vertex.vertex);
Size2 num_size = font->get_string_size(num);
p_overlay->draw_string(font, point - num_size * 0.5, num, Color(1.0, 1.0, 1.0, 0.5));
@@ -661,7 +661,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
if (edge_point.valid()) {
- Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
+ Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5);
}
}
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index 7916ac71ea..86c43ea9ab 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -73,7 +73,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
ap->get_animation_list(&names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- animations_menu->add_icon_item(get_icon("Animation", "EditorIcons"), E->get());
+ animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get());
animations_to_add.push_back(E->get());
}
}
@@ -97,7 +97,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
menu->add_separator();
menu->add_item(TTR("Load..."), MENU_LOAD_FILE);
- menu->set_global_position(blend_space_draw->get_global_transform().xform(mb->get_position()));
+ menu->set_position(blend_space_draw->get_screen_transform().xform(mb->get_position()));
menu->popup();
add_point_pos = (mb->get_position() / blend_space_draw->get_size()).x;
@@ -197,18 +197,18 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
- Color linecolor = get_color("font_color", "Label");
+ Color linecolor = get_theme_color("font_color", "Label");
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
- Ref<Font> font = get_font("font", "Label");
- Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons");
- Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons");
+ Ref<Font> font = get_theme_font("font", "Label");
+ Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons");
+ Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons");
Size2 s = blend_space_draw->get_size();
if (blend_space_draw->has_focus()) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
blend_space_draw->draw_rect(Rect2(Point2(), s), color, false);
}
@@ -280,7 +280,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
{
Color color;
if (tool_blend->is_pressed()) {
- color = get_color("accent_color", "Editor");
+ color = get_theme_color("accent_color", "Editor");
} else {
color = linecolor;
color.a *= 0.5;
@@ -532,15 +532,15 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() {
void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
- panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- tool_blend->set_icon(get_icon("EditPivot", "EditorIcons"));
- tool_select->set_icon(get_icon("ToolSelect", "EditorIcons"));
- tool_create->set_icon(get_icon("EditKey", "EditorIcons"));
- tool_erase->set_icon(get_icon("Remove", "EditorIcons"));
- snap->set_icon(get_icon("SnapGrid", "EditorIcons"));
- open_editor->set_icon(get_icon("Edit", "EditorIcons"));
+ error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
+ panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ tool_blend->set_icon(get_theme_icon("EditPivot", "EditorIcons"));
+ tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ tool_create->set_icon(get_theme_icon("EditKey", "EditorIcons"));
+ tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ snap->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
+ open_editor->set_icon(get_theme_icon("Edit", "EditorIcons"));
}
if (p_what == NOTIFICATION_PROCESS) {
@@ -735,7 +735,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
- open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 663f2dde05..843beacfd6 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -30,9 +30,9 @@
#include "animation_blend_space_2d_editor.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
#include "core/math/delaunay.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_scale.h"
@@ -40,7 +40,7 @@
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) {
@@ -100,7 +100,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
List<StringName> names;
ap->get_animation_list(&names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- animations_menu->add_icon_item(get_icon("Animation", "EditorIcons"), E->get());
+ animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get());
animations_to_add.push_back(E->get());
}
}
@@ -124,7 +124,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
menu->add_separator();
menu->add_item(TTR("Load..."), MENU_LOAD_FILE);
- menu->set_global_position(blend_space_draw->get_global_transform().xform(mb->get_position()));
+ menu->set_position(blend_space_draw->get_screen_transform().xform(mb->get_position()));
menu->popup();
add_point_pos = (mb->get_position() / blend_space_draw->get_size());
add_point_pos.y = 1.0 - add_point_pos.y;
@@ -406,17 +406,17 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) {
void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
- Color linecolor = get_color("font_color", "Label");
+ Color linecolor = get_theme_color("font_color", "Label");
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
- Ref<Font> font = get_font("font", "Label");
- Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons");
- Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons");
+ Ref<Font> font = get_theme_font("font", "Label");
+ Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons");
+ Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons");
Size2 s = blend_space_draw->get_size();
if (blend_space_draw->has_focus()) {
- Color color = get_color("accent_color", "Editor");
+ Color color = get_theme_color("accent_color", "Editor");
blend_space_draw->draw_rect(Rect2(Point2(), s), color, false);
}
blend_space_draw->draw_line(Point2(1, 0), Point2(1, s.height - 1), linecolor);
@@ -502,7 +502,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
Color color;
if (i == selected_triangle) {
- color = get_color("accent_color", "Editor");
+ color = get_theme_color("accent_color", "Editor");
color.a *= 0.5;
} else {
color = linecolor;
@@ -563,7 +563,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
{
Color color;
if (tool_blend->is_pressed()) {
- color = get_color("accent_color", "Editor");
+ color = get_theme_color("accent_color", "Editor");
} else {
color = linecolor;
color.a *= 0.5;
@@ -754,21 +754,21 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) {
void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
- panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- tool_blend->set_icon(get_icon("EditPivot", "EditorIcons"));
- tool_select->set_icon(get_icon("ToolSelect", "EditorIcons"));
- tool_create->set_icon(get_icon("EditKey", "EditorIcons"));
- tool_triangle->set_icon(get_icon("ToolTriangle", "EditorIcons"));
- tool_erase->set_icon(get_icon("Remove", "EditorIcons"));
- snap->set_icon(get_icon("SnapGrid", "EditorIcons"));
- open_editor->set_icon(get_icon("Edit", "EditorIcons"));
- auto_triangles->set_icon(get_icon("AutoTriangle", "EditorIcons"));
+ error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
+ panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ tool_blend->set_icon(get_theme_icon("EditPivot", "EditorIcons"));
+ tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ tool_create->set_icon(get_theme_icon("EditKey", "EditorIcons"));
+ tool_triangle->set_icon(get_theme_icon("ToolTriangle", "EditorIcons"));
+ tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ snap->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
+ open_editor->set_icon(get_theme_icon("Edit", "EditorIcons"));
+ auto_triangles->set_icon(get_theme_icon("AutoTriangle", "EditorIcons"));
interpolation->clear();
- interpolation->add_icon_item(get_icon("TrackContinuous", "EditorIcons"), "", 0);
- interpolation->add_icon_item(get_icon("TrackDiscrete", "EditorIcons"), "", 1);
- interpolation->add_icon_item(get_icon("TrackCapture", "EditorIcons"), "", 2);
+ interpolation->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), "", 0);
+ interpolation->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), "", 1);
+ interpolation->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), "", 2);
}
if (p_what == NOTIFICATION_PROCESS) {
@@ -1042,7 +1042,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
- open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index e79909fae1..4491c002e3 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -30,8 +30,8 @@
#include "animation_blend_tree_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_inspector.h"
@@ -40,7 +40,7 @@
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
#include "scene/gui/progress_bar.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script) {
@@ -145,7 +145,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
name->set_text(E->get());
name->set_expand_to_text_length(true);
node->add_child(name);
- node->set_slot(0, false, 0, Color(), true, 0, get_color("font_color", "Label"));
+ node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label"));
name->connect("text_entered", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode));
name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out), varray(name, agnode), CONNECT_DEFERRED);
base = 1;
@@ -157,7 +157,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
Label *in_name = memnew(Label);
node->add_child(in_name);
in_name->set_text(agnode->get_input_name(i));
- node->set_slot(base + i, true, 0, get_color("font_color", "Label"), false, 0, Color());
+ node->set_slot(base + i, true, 0, get_theme_color("font_color", "Label"), false, 0, Color());
}
List<PropertyInfo> pinfo;
@@ -185,7 +185,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
node->add_child(memnew(HSeparator));
Button *open_in_editor = memnew(Button);
open_in_editor->set_text(TTR("Open Editor"));
- open_in_editor->set_icon(get_icon("Edit", "EditorIcons"));
+ open_in_editor->set_icon(get_theme_icon("Edit", "EditorIcons"));
node->add_child(open_in_editor);
open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E->get()), CONNECT_DEFERRED);
open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
@@ -196,7 +196,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
node->add_child(memnew(HSeparator));
Button *edit_filters = memnew(Button);
edit_filters->set_text(TTR("Edit Filters"));
- edit_filters->set_icon(get_icon("AnimationFilter", "EditorIcons"));
+ edit_filters->set_icon(get_theme_icon("AnimationFilter", "EditorIcons"));
node->add_child(edit_filters);
edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E->get()), CONNECT_DEFERRED);
edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER);
@@ -207,7 +207,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
MenuButton *mb = memnew(MenuButton);
mb->set_text(anim->get_animation());
- mb->set_icon(get_icon("Animation", "EditorIcons"));
+ mb->set_icon(get_theme_icon("Animation", "EditorIcons"));
Array options;
node->add_child(memnew(HSeparator));
@@ -242,16 +242,16 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
}
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
- Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode");
+ Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode");
Color c = sb->get_border_color();
Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0);
mono_color.a = 0.85;
c = mono_color;
- node->add_color_override("title_color", c);
+ node->add_theme_color_override("title_color", c);
c.a = 0.7;
- node->add_color_override("close_color", c);
- node->add_color_override("resizer_color", c);
+ node->add_theme_color_override("close_color", c);
+ node->add_theme_color_override("resizer_color", c);
}
}
@@ -619,7 +619,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
String concat = path.get_concatenated_subnames();
- Skeleton *skeleton = Object::cast_to<Skeleton>(node);
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
if (skeleton && skeleton->find_bone(concat) != -1) {
//path in skeleton
const String &bone = concat;
@@ -643,7 +643,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
ti->set_text(0, F->get());
ti->set_selectable(0, false);
ti->set_editable(0, false);
- ti->set_icon(0, get_icon("BoneAttachment", "EditorIcons"));
+ ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons"));
} else {
ti = parenthood[accum];
}
@@ -654,7 +654,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
ti->set_text(0, concat);
ti->set_checked(0, anode->is_path_filtered(path));
- ti->set_icon(0, get_icon("BoneAttachment", "EditorIcons"));
+ ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons"));
ti->set_metadata(0, path);
} else {
@@ -705,7 +705,7 @@ void AnimationNodeBlendTreeEditor::_edit_filters(const String &p_which) {
if (!_update_filters(anode))
return;
- filter_dialog->popup_centered_minsize(Size2(500, 500) * EDSCALE);
+ filter_dialog->popup_centered(Size2(500, 500) * EDSCALE);
}
void AnimationNodeBlendTreeEditor::_removed_from_graph() {
@@ -718,8 +718,8 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree())
_update_graph();
@@ -931,7 +931,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
add_node->set_text(TTR("Add Node..."));
graph->get_zoom_hbox()->move_child(add_node, 0);
add_node->get_popup()->connect("id_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_add_node));
- add_node->connect("about_to_show", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu));
+ add_node->connect("about_to_popup", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu));
add_options.push_back(AddOption("Animation", "AnimationNodeAnimation"));
add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot"));
@@ -975,7 +975,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
- open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendTreeEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
}
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index af12335a27..0b0f93bcb5 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -30,18 +30,18 @@
#include "animation_player_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/animation_track_editor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning.
-#include "editor/plugins/spatial_editor_plugin.h" // For onion skinning.
-#include "scene/main/viewport.h"
-#include "servers/visual_server.h"
+#include "editor/plugins/node_3d_editor_plugin.h" // For onion skinning.
+#include "scene/main/window.h"
+#include "servers/rendering_server.h"
void AnimationPlayerEditor::_node_removed(Node *p_node) {
@@ -105,33 +105,33 @@ void AnimationPlayerEditor::_notification(int p_what) {
get_tree()->connect("node_removed", callable_mp(this, &AnimationPlayerEditor::_node_removed));
- add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel"));
+ add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel"));
+ add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
} break;
case NOTIFICATION_THEME_CHANGED: {
- autoplay->set_icon(get_icon("AutoPlay", "EditorIcons"));
+ autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons"));
- play->set_icon(get_icon("PlayStart", "EditorIcons"));
- play_from->set_icon(get_icon("Play", "EditorIcons"));
- play_bw->set_icon(get_icon("PlayStartBackwards", "EditorIcons"));
- play_bw_from->set_icon(get_icon("PlayBackwards", "EditorIcons"));
+ play->set_icon(get_theme_icon("PlayStart", "EditorIcons"));
+ play_from->set_icon(get_theme_icon("Play", "EditorIcons"));
+ play_bw->set_icon(get_theme_icon("PlayStartBackwards", "EditorIcons"));
+ play_bw_from->set_icon(get_theme_icon("PlayBackwards", "EditorIcons"));
- autoplay_icon = get_icon("AutoPlay", "EditorIcons");
- stop->set_icon(get_icon("Stop", "EditorIcons"));
+ autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons");
+ stop->set_icon(get_theme_icon("Stop", "EditorIcons"));
- onion_toggle->set_icon(get_icon("Onion", "EditorIcons"));
- onion_skinning->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
+ onion_toggle->set_icon(get_theme_icon("Onion", "EditorIcons"));
+ onion_skinning->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
- pin->set_icon(get_icon("Pin", "EditorIcons"));
+ pin->set_icon(get_theme_icon("Pin", "EditorIcons"));
- tool_anim->add_style_override("normal", get_stylebox("normal", "Button"));
- track_editor->get_edit_menu()->add_style_override("normal", get_stylebox("normal", "Button"));
+ tool_anim->add_theme_style_override("normal", get_theme_stylebox("normal", "Button"));
+ track_editor->get_edit_menu()->add_theme_style_override("normal", get_theme_stylebox("normal", "Button"));
-#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_icon(m_icon, "EditorIcons"))
+#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(m_icon, "EditorIcons"))
ITEM_ICON(TOOL_NEW_ANIM, "New");
ITEM_ICON(TOOL_LOAD_ANIM, "Load");
@@ -349,7 +349,7 @@ void AnimationPlayerEditor::_animation_rename() {
}
void AnimationPlayerEditor::_animation_load() {
ERR_FAIL_COND(!player);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file->clear_filters();
List<String> extensions;
@@ -392,7 +392,7 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) {
- file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
List<String> extensions;
ResourceSaver::get_recognized_extensions(p_resource, &extensions);
@@ -434,7 +434,7 @@ void AnimationPlayerEditor::_animation_remove() {
return;
delete_dialog->set_text(TTR("Delete Animation?"));
- delete_dialog->popup_centered_minsize();
+ delete_dialog->popup_centered();
}
void AnimationPlayerEditor::_animation_remove_confirmed() {
@@ -488,7 +488,7 @@ double AnimationPlayerEditor::_get_editor_step() const {
ERR_FAIL_COND_V(!anim.is_valid(), 0.0);
// Use more precise snapping when holding Shift
- return Input::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step();
+ return InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step();
}
return 0.0;
@@ -501,7 +501,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
String new_name = name->get_text();
if (new_name == "" || new_name.find(":") != -1 || new_name.find("/") != -1) {
error_dialog->set_text(TTR("Invalid animation name!"));
- error_dialog->popup_centered_minsize();
+ error_dialog->popup_centered();
return;
}
@@ -512,7 +512,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
if (player->has_animation(new_name)) {
error_dialog->set_text(TTR("Animation name already exists!"));
- error_dialog->popup_centered_minsize();
+ error_dialog->popup_centered();
return;
}
@@ -947,8 +947,8 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o
alpha += alpha_step;
if (onion.captures_valid[cidx]) {
- VS::get_singleton()->canvas_item_add_texture_rect_region(
- ci, dst_rect, VS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha));
+ RS::get_singleton()->canvas_item_add_texture_rect_region(
+ ci, dst_rect, RS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha));
}
cidx++;
@@ -961,8 +961,8 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o
alpha -= alpha_step;
if (onion.captures_valid[cidx]) {
- VS::get_singleton()->canvas_item_add_texture_rect_region(
- ci, dst_rect, VS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha));
+ RS::get_singleton()->canvas_item_add_texture_rect_region(
+ ci, dst_rect, RS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha));
}
cidx++;
@@ -1058,7 +1058,7 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
if (player == p_pl && is_visible_in_tree()) {
_update_player();
- if (blend_editor.dialog->is_visible_in_tree())
+ if (blend_editor.dialog->is_visible())
_animation_blend(); // Update.
}
}
@@ -1152,7 +1152,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
if (!animation->get_item_count()) {
error_dialog->set_text(TTR("No animation to copy!"));
- error_dialog->popup_centered_minsize();
+ error_dialog->popup_centered();
return;
}
@@ -1165,7 +1165,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
if (!anim2.is_valid()) {
error_dialog->set_text(TTR("No animation resource on clipboard!"));
- error_dialog->popup_centered_minsize();
+ error_dialog->popup_centered();
return;
}
@@ -1195,7 +1195,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
if (!animation->get_item_count()) {
error_dialog->set_text(TTR("No animation to edit!"));
- error_dialog->popup_centered_minsize();
+ error_dialog->popup_centered();
return;
}
@@ -1318,17 +1318,17 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
bool is_present = onion.differences_only && i == captures - 1;
// Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport.
- onion.captures.write[i] = VS::get_singleton()->viewport_create();
+ onion.captures.write[i] = RS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height);
- VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS);
- VS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present);
- VS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas);
+ RS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height);
+ RS::get_singleton()->viewport_set_update_mode(onion.captures[i], RS::VIEWPORT_UPDATE_ALWAYS);
+ RS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present);
+ RS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas);
}
// Reset the capture canvas item to the current root viewport texture (defensive).
- VS::get_singleton()->canvas_item_clear(onion.capture.canvas_item);
- VS::get_singleton()->canvas_item_add_texture_rect(onion.capture.canvas_item, Rect2(Point2(), capture_size), get_tree()->get_root()->get_texture()->get_rid());
+ RS::get_singleton()->canvas_item_clear(onion.capture.canvas_item);
+ RS::get_singleton()->canvas_item_add_texture_rect(onion.capture.canvas_item, Rect2(Point2(), capture_size), get_tree()->get_root()->get_texture()->get_rid());
onion.capture_size = capture_size;
}
@@ -1337,7 +1337,7 @@ void AnimationPlayerEditor::_free_onion_layers() {
for (int i = 0; i < onion.captures.size(); i++) {
if (onion.captures[i].is_valid()) {
- VS::get_singleton()->free(onion.captures[i]);
+ RS::get_singleton()->free(onion.captures[i]);
}
}
onion.captures.clear();
@@ -1385,9 +1385,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
// Hide superfluous elements that would make the overlay unnecessary cluttered.
Dictionary canvas_edit_state;
Dictionary spatial_edit_state;
- if (SpatialEditor::get_singleton()->is_visible()) {
+ if (Node3DEditor::get_singleton()->is_visible()) {
// 3D
- spatial_edit_state = SpatialEditor::get_singleton()->get_state();
+ spatial_edit_state = Node3DEditor::get_singleton()->get_state();
Dictionary new_state = spatial_edit_state.duplicate();
new_state["show_grid"] = false;
new_state["show_origin"] = false;
@@ -1404,7 +1404,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
}
new_state["viewports"] = vp;
// TODO: Save/restore only affected entries.
- SpatialEditor::get_singleton()->set_state(new_state);
+ Node3DEditor::get_singleton()->set_state(new_state);
} else { // CanvasItemEditor
// 2D
canvas_edit_state = CanvasItemEditor::get_singleton()->get_state();
@@ -1420,19 +1420,19 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
// Tweak the root viewport to ensure it's rendered before our target.
RID root_vp = get_tree()->get_root()->get_viewport_rid();
- Rect2 root_vp_screen_rect = get_tree()->get_root()->get_attach_to_screen_rect();
- VS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2());
- VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_ALWAYS);
+ Rect2 root_vp_screen_rect = Rect2(Vector2(), get_tree()->get_root()->get_size());
+ RS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2());
+ RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_ALWAYS);
RID present_rid;
if (onion.differences_only) {
// Capture present scene as it is.
- VS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, RID());
+ RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, RID());
present_rid = onion.captures[onion.captures.size() - 1];
- VS::get_singleton()->viewport_set_active(present_rid, true);
- VS::get_singleton()->viewport_set_parent_viewport(root_vp, present_rid);
- VS::get_singleton()->draw(false);
- VS::get_singleton()->viewport_set_active(present_rid, false);
+ RS::get_singleton()->viewport_set_active(present_rid, true);
+ RS::get_singleton()->viewport_set_parent_viewport(root_vp, present_rid);
+ RS::get_singleton()->draw(false);
+ RS::get_singleton()->viewport_set_active(present_rid, false);
}
// Backup current animation state.
@@ -1441,10 +1441,10 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
// Render every past/future step with the capture shader.
- VS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid());
+ RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid());
onion.capture.material->set_shader_param("bkg_color", GLOBAL_GET("rendering/environment/default_clear_color"));
onion.capture.material->set_shader_param("differences_only", onion.differences_only);
- onion.capture.material->set_shader_param("present", onion.differences_only ? VS::get_singleton()->viewport_get_texture(present_rid) : RID());
+ onion.capture.material->set_shader_param("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID());
int step_off_a = onion.past ? -onion.steps : 0;
int step_off_b = onion.future ? onion.steps : 0;
@@ -1465,22 +1465,22 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
onion.captures_valid.write[cidx] = valid;
if (valid) {
player->seek(pos, true);
- get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials.
+ get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds.
values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D).
- VS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
- VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);
- VS::get_singleton()->draw(false);
- VS::get_singleton()->viewport_set_active(onion.captures[cidx], false);
+ RS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
+ RS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);
+ RS::get_singleton()->draw(false);
+ RS::get_singleton()->viewport_set_active(onion.captures[cidx], false);
}
cidx++;
}
// Restore root viewport.
- VS::get_singleton()->viewport_set_parent_viewport(root_vp, RID());
- VS::get_singleton()->viewport_attach_to_screen(root_vp, root_vp_screen_rect);
- VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_WHEN_VISIBLE);
+ RS::get_singleton()->viewport_set_parent_viewport(root_vp, RID());
+ RS::get_singleton()->viewport_attach_to_screen(root_vp, root_vp_screen_rect);
+ RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
// Restore animation state
// (Seeking with update=true wouldn't do the trick because the current value of the properties
@@ -1489,9 +1489,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
player->restore_animated_values(values_backup);
// Restore state of main editors.
- if (SpatialEditor::get_singleton()->is_visible()) {
+ if (Node3DEditor::get_singleton()->is_visible()) {
// 3D
- SpatialEditor::get_singleton()->set_state(spatial_edit_state);
+ Node3DEditor::get_singleton()->set_state(spatial_edit_state);
} else { // CanvasItemEditor
// 2D
CanvasItemEditor::get_singleton()->set_state(canvas_edit_state);
@@ -1764,9 +1764,9 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
onion.last_frame = 0;
onion.can_overlay = false;
onion.capture_size = Size2();
- onion.capture.canvas = VS::get_singleton()->canvas_create();
- onion.capture.canvas_item = VS::get_singleton()->canvas_item_create();
- VS::get_singleton()->canvas_item_set_parent(onion.capture.canvas_item, onion.capture.canvas);
+ onion.capture.canvas = RS::get_singleton()->canvas_create();
+ onion.capture.canvas_item = RS::get_singleton()->canvas_item_create();
+ RS::get_singleton()->canvas_item_set_parent(onion.capture.canvas_item, onion.capture.canvas);
onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial));
@@ -1792,14 +1792,14 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \
} \
");
- VS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid());
+ RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid());
}
AnimationPlayerEditor::~AnimationPlayerEditor() {
_free_onion_layers();
- VS::get_singleton()->free(onion.capture.canvas);
- VS::get_singleton()->free(onion.capture.canvas_item);
+ RS::get_singleton()->free(onion.capture.canvas);
+ RS::get_singleton()->free(onion.capture.canvas_item);
}
void AnimationPlayerEditorPlugin::_notification(int p_what) {
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index cae959e1f4..8ff8c92f4d 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -30,9 +30,9 @@
#include "animation_state_machine_editor.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
#include "core/math/delaunay.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_scale.h"
@@ -40,7 +40,7 @@
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
bool AnimationNodeStateMachineEditor::can_edit(const Ref<AnimationNode> &p_node) {
@@ -97,7 +97,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
List<StringName> names;
ap->get_animation_list(&names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- animations_menu->add_icon_item(get_icon("Animation", "EditorIcons"), E->get());
+ animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get());
animations_to_add.push_back(E->get());
}
}
@@ -121,7 +121,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
menu->add_separator();
menu->add_item(TTR("Load..."), MENU_LOAD_FILE);
- menu->set_global_position(state_machine_draw->get_global_transform().xform(mb->get_position()));
+ menu->set_position(state_machine_draw->get_screen_transform().xform(mb->get_position()));
menu->popup();
add_node_pos = mb->get_position() / EDSCALE + state_machine->get_graph_offset();
}
@@ -149,16 +149,16 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
if (node_rects[i].name.has_point(mb->get_position())) { //edit name
- Ref<StyleBox> line_sb = get_stylebox("normal", "LineEdit");
+ Ref<StyleBox> line_sb = get_theme_stylebox("normal", "LineEdit");
Rect2 edit_rect = node_rects[i].name;
edit_rect.position -= line_sb->get_offset();
edit_rect.size += line_sb->get_minimum_size();
- name_edit->set_global_position(state_machine_draw->get_global_transform().xform(edit_rect.position));
- name_edit->set_size(edit_rect.size);
+ name_edit_popup->set_position(state_machine_draw->get_screen_transform().xform(edit_rect.position));
+ name_edit_popup->set_size(edit_rect.size);
name_edit->set_text(node_rects[i].node_name);
- name_edit->show_modal();
+ name_edit_popup->popup();
name_edit->grab_focus();
name_edit->select_all();
@@ -504,9 +504,9 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, bool p_auto_advance) {
- Color linecolor = get_color("font_color", "Label");
+ Color linecolor = get_theme_color("font_color", "Label");
Color icon_color(1, 1, 1);
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
if (!p_enabled) {
linecolor.a *= 0.2;
@@ -515,12 +515,12 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
}
Ref<Texture2D> icons[6] = {
- get_icon("TransitionImmediateBig", "EditorIcons"),
- get_icon("TransitionSyncBig", "EditorIcons"),
- get_icon("TransitionEndBig", "EditorIcons"),
- get_icon("TransitionImmediateAutoBig", "EditorIcons"),
- get_icon("TransitionSyncAutoBig", "EditorIcons"),
- get_icon("TransitionEndAutoBig", "EditorIcons")
+ get_theme_icon("TransitionImmediateBig", "EditorIcons"),
+ get_theme_icon("TransitionSyncBig", "EditorIcons"),
+ get_theme_icon("TransitionEndBig", "EditorIcons"),
+ get_theme_icon("TransitionImmediateAutoBig", "EditorIcons"),
+ get_theme_icon("TransitionSyncAutoBig", "EditorIcons"),
+ get_theme_icon("TransitionEndAutoBig", "EditorIcons")
};
if (p_selected) {
@@ -573,18 +573,18 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
- Ref<StyleBox> style = get_stylebox("state_machine_frame", "GraphNode");
- Ref<StyleBox> style_selected = get_stylebox("state_machine_selectedframe", "GraphNode");
+ Ref<StyleBox> style = get_theme_stylebox("state_machine_frame", "GraphNode");
+ Ref<StyleBox> style_selected = get_theme_stylebox("state_machine_selectedframe", "GraphNode");
- Ref<Font> font = get_font("title_font", "GraphNode");
- Color font_color = get_color("title_color", "GraphNode");
- Ref<Texture2D> play = get_icon("Play", "EditorIcons");
- Ref<Texture2D> auto_play = get_icon("AutoPlay", "EditorIcons");
- Ref<Texture2D> edit = get_icon("Edit", "EditorIcons");
- Color accent = get_color("accent_color", "Editor");
- Color linecolor = get_color("font_color", "Label");
+ Ref<Font> font = get_theme_font("title_font", "GraphNode");
+ Color font_color = get_theme_color("title_color", "GraphNode");
+ Ref<Texture2D> play = get_theme_icon("Play", "EditorIcons");
+ Ref<Texture2D> auto_play = get_theme_icon("AutoPlay", "EditorIcons");
+ Ref<Texture2D> edit = get_theme_icon("Edit", "EditorIcons");
+ Color accent = get_theme_color("accent_color", "Editor");
+ Color linecolor = get_theme_color("font_color", "Label");
linecolor.a *= 0.3;
- Ref<StyleBox> playing_overlay = get_stylebox("position", "GraphNode");
+ Ref<StyleBox> playing_overlay = get_theme_stylebox("position", "GraphNode");
bool playing = false;
StringName current;
@@ -686,7 +686,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
_connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false);
}
- Ref<Texture2D> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons");
+ Ref<Texture2D> tr_reference_icon = get_theme_icon("TransitionImmediateBig", "EditorIcons");
float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8);
//draw transition lines
@@ -879,7 +879,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
float pos = CLAMP(play_pos, 0, len);
float c = pos / len;
- Color fg = get_color("font_color", "Label");
+ Color fg = get_theme_color("font_color", "Label");
Color bg = fg;
bg.a *= 0.3;
@@ -905,26 +905,26 @@ void AnimationNodeStateMachineEditor::_update_graph() {
void AnimationNodeStateMachineEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
- panel->add_style_override("panel", get_stylebox("bg", "Tree"));
+ error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
+ panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
- tool_select->set_icon(get_icon("ToolSelect", "EditorIcons"));
- tool_create->set_icon(get_icon("ToolAddNode", "EditorIcons"));
- tool_connect->set_icon(get_icon("ToolConnect", "EditorIcons"));
+ tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ tool_create->set_icon(get_theme_icon("ToolAddNode", "EditorIcons"));
+ tool_connect->set_icon(get_theme_icon("ToolConnect", "EditorIcons"));
transition_mode->clear();
- transition_mode->add_icon_item(get_icon("TransitionImmediate", "EditorIcons"), TTR("Immediate"));
- transition_mode->add_icon_item(get_icon("TransitionSync", "EditorIcons"), TTR("Sync"));
- transition_mode->add_icon_item(get_icon("TransitionEnd", "EditorIcons"), TTR("At End"));
+ transition_mode->add_icon_item(get_theme_icon("TransitionImmediate", "EditorIcons"), TTR("Immediate"));
+ transition_mode->add_icon_item(get_theme_icon("TransitionSync", "EditorIcons"), TTR("Sync"));
+ transition_mode->add_icon_item(get_theme_icon("TransitionEnd", "EditorIcons"), TTR("At End"));
- tool_erase->set_icon(get_icon("Remove", "EditorIcons"));
- tool_autoplay->set_icon(get_icon("AutoPlay", "EditorIcons"));
- tool_end->set_icon(get_icon("AutoEnd", "EditorIcons"));
+ tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ tool_autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons"));
+ tool_end->set_icon(get_theme_icon("AutoEnd", "EditorIcons"));
play_mode->clear();
- play_mode->add_icon_item(get_icon("PlayTravel", "EditorIcons"), TTR("Travel"));
- play_mode->add_icon_item(get_icon("Play", "EditorIcons"), TTR("Immediate"));
+ play_mode->add_icon_item(get_theme_icon("PlayTravel", "EditorIcons"), TTR("Travel"));
+ play_mode->add_icon_item(get_theme_icon("Play", "EditorIcons"), TTR("Immediate"));
}
if (p_what == NOTIFICATION_PROCESS) {
@@ -1110,7 +1110,7 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
- name_edit->hide();
+ name_edit_popup->hide();
updating = false;
state_machine_draw->update();
@@ -1357,17 +1357,19 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
animations_menu->set_name("animations");
animations_menu->connect("index_pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_add_animation_type));
+ name_edit_popup = memnew(Popup);
+ add_child(name_edit_popup);
name_edit = memnew(LineEdit);
- state_machine_draw->add_child(name_edit);
- name_edit->hide();
+ name_edit_popup->add_child(name_edit);
+ name_edit->set_anchors_and_margins_preset(PRESET_WIDE);
+ name_edit_popup->add_child(name_edit);
name_edit->connect("text_entered", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited));
name_edit->connect("focus_exited", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited_focus_out));
- name_edit->set_as_toplevel(true);
open_file = memnew(EditorFileDialog);
add_child(open_file);
open_file->set_title(TTR("Open Animation Node"));
- open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
open_file->connect("file_selected", callable_mp(this, &AnimationNodeStateMachineEditor::_file_opened));
undo_redo = EditorNode::get_undo_redo();
diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h
index 132e66b28d..5c4fc87df5 100644
--- a/editor/plugins/animation_state_machine_editor.h
+++ b/editor/plugins/animation_state_machine_editor.h
@@ -50,6 +50,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
ToolButton *tool_select;
ToolButton *tool_create;
ToolButton *tool_connect;
+ Popup *name_edit_popup;
LineEdit *name_edit;
HBoxContainer *tool_erase_hb;
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index c9706a7f68..605696aa75 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -34,9 +34,9 @@
#include "animation_blend_space_2d_editor.h"
#include "animation_blend_tree_editor_plugin.h"
#include "animation_state_machine_editor.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
#include "core/math/delaunay.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_scale.h"
@@ -44,7 +44,7 @@
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
void AnimationTreeEditor::edit(AnimationTree *p_tree) {
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 80b7e6ffc8..3b104e34b2 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -30,8 +30,8 @@
#include "asset_library_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/io/json.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/version.h"
#include "editor/editor_node.h"
@@ -62,10 +62,10 @@ void EditorAssetLibraryItem::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- icon->set_normal_texture(get_icon("ProjectIconLoading", "EditorIcons"));
- category->add_color_override("font_color", Color(0.5, 0.5, 0.5));
- author->add_color_override("font_color", Color(0.5, 0.5, 0.5));
- price->add_color_override("font_color", Color(0.5, 0.5, 0.5));
+ icon->set_normal_texture(get_theme_icon("ProjectIconLoading", "EditorIcons"));
+ category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
+ author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
+ price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
}
}
@@ -99,11 +99,11 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
border->set_default_margin(MARGIN_RIGHT, 5 * EDSCALE);
border->set_default_margin(MARGIN_BOTTOM, 5 * EDSCALE);
border->set_default_margin(MARGIN_TOP, 5 * EDSCALE);
- add_style_override("panel", border);
+ add_theme_style_override("panel", border);
HBoxContainer *hb = memnew(HBoxContainer);
// Add some spacing to visually separate the icon from the asset details.
- hb->add_constant_override("separation", 15 * EDSCALE);
+ hb->add_theme_constant_override("separation", 15 * EDSCALE);
add_child(hb);
icon = memnew(TextureButton);
@@ -116,7 +116,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
VBoxContainer *vb = memnew(VBoxContainer);
hb->add_child(vb);
- vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
title = memnew(LinkButton);
title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
@@ -137,7 +137,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
vb->add_child(price);
set_custom_minimum_size(Size2(250, 100) * EDSCALE);
- set_h_size_flags(SIZE_EXPAND_FILL);
+ set_h_size_flags(Control::SIZE_EXPAND_FILL);
}
//////////////////////////////////////////////////////////////////////////////
@@ -156,7 +156,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
for (int i = 0; i < preview_images.size(); i++) {
if (preview_images[i].id == p_index) {
if (preview_images[i].is_video) {
- Ref<Image> overlay = get_icon("PlayOverlay", "EditorIcons")->get_data();
+ Ref<Image> overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_data();
Ref<Image> thumbnail = p_image->get_data();
thumbnail = thumbnail->duplicate();
Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2);
@@ -172,7 +172,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
preview_images[i].button->set_icon(tex);
// Make it clearer that clicking it will open an external link
- preview_images[i].button->set_default_cursor_shape(CURSOR_POINTING_HAND);
+ preview_images[i].button->set_default_cursor_shape(Control::CURSOR_POINTING_HAND);
} else {
preview_images[i].button->set_icon(p_image);
}
@@ -198,7 +198,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
void EditorAssetLibraryItemDescription::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- previews_bg->add_style_override("panel", get_stylebox("normal", "TextEdit"));
+ previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox("normal", "TextEdit"));
} break;
}
}
@@ -219,7 +219,7 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) {
if (!preview_images[i].is_video) {
if (preview_images[i].image.is_valid()) {
preview->set_texture(preview_images[i].image);
- minimum_size_changed();
+ child_controls_changed();
}
} else {
_link_click(preview_images[i].video_link);
@@ -256,12 +256,12 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons
preview.is_video = p_video;
preview.button = memnew(Button);
preview.button->set_flat(true);
- preview.button->set_icon(get_icon("ThumbnailWait", "EditorIcons"));
+ preview.button->set_icon(previews->get_theme_icon("ThumbnailWait", "EditorIcons"));
preview.button->set_toggle_mode(true);
preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click), varray(p_id));
preview_hb->add_child(preview.button);
if (!p_video) {
- preview.image = get_icon("ThumbnailWait", "EditorIcons");
+ preview.image = previews->get_theme_icon("ThumbnailWait", "EditorIcons");
}
preview_images.push_back(preview);
if (preview_images.size() == 1 && !p_video) {
@@ -275,7 +275,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
add_child(hbox);
VBoxContainer *desc_vbox = memnew(VBoxContainer);
hbox->add_child(desc_vbox);
- hbox->add_constant_override("separation", 15 * EDSCALE);
+ hbox->add_theme_constant_override("separation", 15 * EDSCALE);
item = memnew(EditorAssetLibraryItem);
@@ -284,14 +284,14 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
description = memnew(RichTextLabel);
desc_vbox->add_child(description);
- description->set_v_size_flags(SIZE_EXPAND_FILL);
+ description->set_v_size_flags(Control::SIZE_EXPAND_FILL);
description->connect("meta_clicked", callable_mp(this, &EditorAssetLibraryItemDescription::_link_click));
- description->add_constant_override("line_separation", Math::round(5 * EDSCALE));
+ description->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE));
VBoxContainer *previews_vbox = memnew(VBoxContainer);
hbox->add_child(previews_vbox);
- previews_vbox->add_constant_override("separation", 15 * EDSCALE);
- previews_vbox->set_v_size_flags(SIZE_EXPAND_FILL);
+ previews_vbox->add_theme_constant_override("separation", 15 * EDSCALE);
+ previews_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
preview = memnew(TextureRect);
previews_vbox->add_child(preview);
@@ -308,7 +308,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
previews->set_enable_v_scroll(false);
previews->set_enable_h_scroll(true);
preview_hb = memnew(HBoxContainer);
- preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);
+ preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
previews->add_child(preview_hb);
get_ok()->set_text(TTR("Download"));
@@ -375,7 +375,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
if (error_text != String()) {
download_error->set_text(TTR("Asset Download Error:") + "\n" + error_text);
- download_error->popup_centered_minsize();
+ download_error->popup_centered();
return;
}
@@ -393,7 +393,7 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse
icon->set_texture(p_preview);
asset_id = p_asset_id;
if (!p_preview.is_valid())
- icon->set_texture(get_icon("FileBrokenBigThumb", "EditorIcons"));
+ icon->set_texture(get_theme_icon("FileBrokenBigThumb", "EditorIcons"));
host = p_download_url;
sha256 = p_sha256_hash;
_make_request();
@@ -406,8 +406,8 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
// FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used.
case NOTIFICATION_ENTER_TREE: {
- add_style_override("panel", get_stylebox("panel", "TabContainer"));
- dismiss->set_normal_texture(get_icon("Close", "EditorIcons"));
+ add_theme_style_override("panel", get_theme_stylebox("panel", "TabContainer"));
+ dismiss->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
} break;
case NOTIFICATION_PROCESS: {
@@ -507,13 +507,13 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
VBoxContainer *vb = memnew(VBoxContainer);
hb->add_child(vb);
- vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *title_hb = memnew(HBoxContainer);
vb->add_child(title_hb);
title = memnew(Label);
title_hb->add_child(title);
- title->set_h_size_flags(SIZE_EXPAND_FILL);
+ title->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dismiss = memnew(TextureButton);
dismiss->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDownload::_close));
@@ -525,7 +525,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
status = memnew(Label(TTR("Idle")));
vb->add_child(status);
- status->add_color_override("font_color", Color(0.5, 0.5, 0.5));
+ status->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
progress = memnew(ProgressBar);
vb->add_child(progress);
@@ -571,8 +571,8 @@ void EditorAssetLibrary::_notification(int p_what) {
case NOTIFICATION_READY: {
- error_tr->set_texture(get_icon("Error", "EditorIcons"));
- filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ error_tr->set_texture(get_theme_icon("Error", "EditorIcons"));
+ filter->set_right_icon(get_theme_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
error_label->raise();
@@ -602,10 +602,10 @@ void EditorAssetLibrary::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
- library_scroll_bg->add_style_override("panel", get_stylebox("bg", "Tree"));
- downloads_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
- error_tr->set_texture(get_icon("Error", "EditorIcons"));
- filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ downloads_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ error_tr->set_texture(get_theme_icon("Error", "EditorIcons"));
+ filter->set_right_icon(get_theme_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
} break;
}
@@ -774,7 +774,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB
}
if (!image_set && final) {
- obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("FileBrokenBigThumb", "EditorIcons"));
+ obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons"));
}
}
}
@@ -819,7 +819,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
WARN_PRINT("Error getting image file from URL: " + image_queue[p_queue_id].image_url);
Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
if (obj) {
- obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("FileBrokenBigThumb", "EditorIcons"));
+ obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons"));
}
}
@@ -976,7 +976,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
to = p_page_count;
hbc->add_spacer();
- hbc->add_constant_override("separation", 5 * EDSCALE);
+ hbc->add_theme_constant_override("separation", 5 * EDSCALE);
Button *first = memnew(Button);
first->set_text(TTR("First"));
@@ -1191,8 +1191,8 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_constant_override("hseparation", 10 * EDSCALE);
- asset_items->add_constant_override("vseparation", 10 * EDSCALE);
+ asset_items->add_theme_constant_override("hseparation", 10 * EDSCALE);
+ asset_items->add_theme_constant_override("vseparation", 10 * EDSCALE);
library_vb->add_child(asset_items);
@@ -1260,7 +1260,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
description = memnew(EditorAssetLibraryItemDescription);
add_child(description);
- description->popup_centered_minsize();
+ description->popup_centered();
description->connect("confirmed", callable_mp(this, &EditorAssetLibrary::_install_asset));
description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]);
@@ -1353,11 +1353,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
HBoxContainer *search_hb = memnew(HBoxContainer);
library_main->add_child(search_hb);
- library_main->add_constant_override("separation", 10 * EDSCALE);
+ library_main->add_theme_constant_override("separation", 10 * EDSCALE);
filter = memnew(LineEdit);
search_hb->add_child(filter);
- filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->connect("text_entered", callable_mp(this, &EditorAssetLibrary::_search_text_entered));
search = memnew(Button(TTR("Search")));
search->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), make_binds(0));
@@ -1392,7 +1392,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(sort);
- sort->set_h_size_flags(SIZE_EXPAND_FILL);
+ sort->set_h_size_flags(Control::SIZE_EXPAND_FILL);
sort->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search));
search_hb2->add_child(memnew(VSeparator));
@@ -1401,7 +1401,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
categories = memnew(OptionButton);
categories->add_item(TTR("All"));
search_hb2->add_child(categories);
- categories->set_h_size_flags(SIZE_EXPAND_FILL);
+ categories->set_h_size_flags(Control::SIZE_EXPAND_FILL);
categories->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search));
search_hb2->add_child(memnew(VSeparator));
@@ -1417,7 +1417,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
repository->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_repository_changed));
search_hb2->add_child(repository);
- repository->set_h_size_flags(SIZE_EXPAND_FILL);
+ repository->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_hb2->add_child(memnew(VSeparator));
@@ -1435,7 +1435,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_scroll_bg = memnew(PanelContainer);
library_main->add_child(library_scroll_bg);
- library_scroll_bg->set_v_size_flags(SIZE_EXPAND_FILL);
+ library_scroll_bg->set_v_size_flags(Control::SIZE_EXPAND_FILL);
library_scroll = memnew(ScrollContainer);
library_scroll->set_enable_v_scroll(true);
@@ -1452,11 +1452,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
PanelContainer *library_vb_border = memnew(PanelContainer);
library_scroll->add_child(library_vb_border);
- library_vb_border->add_style_override("panel", border2);
- library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL);
+ library_vb_border->add_theme_style_override("panel", border2);
+ library_vb_border->set_h_size_flags(Control::SIZE_EXPAND_FILL);
library_vb = memnew(VBoxContainer);
- library_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ library_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
library_vb_border->add_child(library_vb);
@@ -1474,8 +1474,8 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_constant_override("hseparation", 10 * EDSCALE);
- asset_items->add_constant_override("vseparation", 10 * EDSCALE);
+ asset_items->add_theme_constant_override("hseparation", 10 * EDSCALE);
+ asset_items->add_theme_constant_override("vseparation", 10 * EDSCALE);
library_vb->add_child(asset_items);
@@ -1489,12 +1489,12 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
last_queue_id = 0;
- library_vb->add_constant_override("separation", 20 * EDSCALE);
+ library_vb->add_theme_constant_override("separation", 20 * EDSCALE);
error_hb = memnew(HBoxContainer);
library_main->add_child(error_hb);
error_label = memnew(Label);
- error_label->add_color_override("color", get_color("error_color", "Editor"));
+ error_label->add_theme_color_override("color", get_theme_color("error_color", "Editor"));
error_hb->add_child(error_label);
error_tr = memnew(TextureRect);
error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
@@ -1516,7 +1516,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
asset_open->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
asset_open->add_filter("*.zip ; " + TTR("Assets ZIP File"));
- asset_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ asset_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
add_child(asset_open);
asset_open->connect("file_selected", callable_mp(this, &EditorAssetLibrary::_asset_file_selected));
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index 7a1722c73b..0459ac7618 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -43,10 +43,10 @@ void AudioStreamEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
- _play_button->set_icon(get_icon("MainPlay", "EditorIcons"));
- _stop_button->set_icon(get_icon("Stop", "EditorIcons"));
- _preview->set_frame_color(get_color("dark_color_2", "Editor"));
- set_frame_color(get_color("dark_color_1", "Editor"));
+ _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
+ _stop_button->set_icon(get_theme_icon("Stop", "EditorIcons"));
+ _preview->set_frame_color(get_theme_color("dark_color_2", "Editor"));
+ set_frame_color(get_theme_color("dark_color_1", "Editor"));
_indicator->update();
_preview->update();
@@ -87,9 +87,9 @@ void AudioStreamEditor::_draw_preview() {
}
Vector<Color> color;
- color.push_back(get_color("contrast_color_2", "Editor"));
+ color.push_back(get_theme_color("contrast_color_2", "Editor"));
- VS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color);
+ RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color);
}
void AudioStreamEditor::_preview_changed(ObjectID p_which) {
@@ -110,11 +110,11 @@ void AudioStreamEditor::_play() {
if (_player->is_playing()) {
_player->stop();
- _play_button->set_icon(get_icon("MainPlay", "EditorIcons"));
+ _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
set_process(false);
} else {
_player->play(_current);
- _play_button->set_icon(get_icon("Pause", "EditorIcons"));
+ _play_button->set_icon(get_theme_icon("Pause", "EditorIcons"));
set_process(true);
}
}
@@ -122,7 +122,7 @@ void AudioStreamEditor::_play() {
void AudioStreamEditor::_stop() {
_player->stop();
- _play_button->set_icon(get_icon("MainPlay", "EditorIcons"));
+ _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
_current = 0;
_indicator->update();
set_process(false);
@@ -130,7 +130,7 @@ void AudioStreamEditor::_stop() {
void AudioStreamEditor::_on_finished() {
- _play_button->set_icon(get_icon("MainPlay", "EditorIcons"));
+ _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
if (_current == _player->get_stream()->get_length()) {
_current = 0;
_indicator->update();
@@ -146,7 +146,7 @@ void AudioStreamEditor::_draw_indicator() {
Rect2 rect = _preview->get_rect();
float len = stream->get_length();
float ofs_x = _current / len * rect.size.width;
- _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), get_color("accent_color", "Editor"), 1);
+ _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), get_theme_color("accent_color", "Editor"), 1);
_current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /");
}
@@ -225,7 +225,7 @@ AudioStreamEditor::AudioStreamEditor() {
_preview->add_child(_indicator);
HBoxContainer *hbox = memnew(HBoxContainer);
- hbox->add_constant_override("separation", 0);
+ hbox->add_theme_constant_override("separation", 0);
vbox->add_child(hbox);
_play_button = memnew(ToolButton);
@@ -241,12 +241,12 @@ AudioStreamEditor::AudioStreamEditor() {
_current_label = memnew(Label);
_current_label->set_align(Label::ALIGN_RIGHT);
_current_label->set_h_size_flags(SIZE_EXPAND_FILL);
- _current_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts"));
+ _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
_current_label->set_modulate(Color(1, 1, 1, 0.5));
hbox->add_child(_current_label);
_duration_label = memnew(Label);
- _duration_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts"));
+ _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts"));
hbox->add_child(_duration_label);
}
diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp
index 8726c8c552..3d9b74c2da 100644
--- a/editor/plugins/camera_editor_plugin.cpp
+++ b/editor/plugins/camera_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* camera_editor_plugin.cpp */
+/* camera_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,45 +28,45 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "camera_editor_plugin.h"
+#include "camera_3d_editor_plugin.h"
-#include "spatial_editor_plugin.h"
+#include "node_3d_editor_plugin.h"
-void CameraEditor::_node_removed(Node *p_node) {
+void Camera3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
- SpatialEditor::get_singleton()->set_custom_camera(NULL);
+ Node3DEditor::get_singleton()->set_custom_camera(NULL);
hide();
}
}
-void CameraEditor::_pressed() {
+void Camera3DEditor::_pressed() {
Node *sn = (node && preview->is_pressed()) ? node : NULL;
- SpatialEditor::get_singleton()->set_custom_camera(sn);
+ Node3DEditor::get_singleton()->set_custom_camera(sn);
}
-void CameraEditor::_bind_methods() {
+void Camera3DEditor::_bind_methods() {
}
-void CameraEditor::edit(Node *p_camera) {
+void Camera3DEditor::edit(Node *p_camera) {
node = p_camera;
if (!node) {
preview->set_pressed(false);
- SpatialEditor::get_singleton()->set_custom_camera(NULL);
+ Node3DEditor::get_singleton()->set_custom_camera(NULL);
} else {
if (preview->is_pressed())
- SpatialEditor::get_singleton()->set_custom_camera(p_camera);
+ Node3DEditor::get_singleton()->set_custom_camera(p_camera);
else
- SpatialEditor::get_singleton()->set_custom_camera(NULL);
+ Node3DEditor::get_singleton()->set_custom_camera(NULL);
}
}
-CameraEditor::CameraEditor() {
+Camera3DEditor::Camera3DEditor() {
preview = memnew(Button);
add_child(preview);
@@ -79,30 +79,30 @@ CameraEditor::CameraEditor() {
preview->set_margin(MARGIN_RIGHT, 0);
preview->set_margin(MARGIN_TOP, 0);
preview->set_margin(MARGIN_BOTTOM, 10);
- preview->connect("pressed", callable_mp(this, &CameraEditor::_pressed));
+ preview->connect("pressed", callable_mp(this, &Camera3DEditor::_pressed));
}
-void CameraEditorPlugin::edit(Object *p_object) {
+void Camera3DEditorPlugin::edit(Object *p_object) {
- SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
+ Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object));
//camera_editor->edit(Object::cast_to<Node>(p_object));
}
-bool CameraEditorPlugin::handles(Object *p_object) const {
+bool Camera3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Camera");
+ return p_object->is_class("Camera3D");
}
-void CameraEditorPlugin::make_visible(bool p_visible) {
+void Camera3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- //SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
+ //Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
} else {
- SpatialEditor::get_singleton()->set_can_preview(NULL);
+ Node3DEditor::get_singleton()->set_can_preview(NULL);
}
}
-CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
+Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
/* camera_editor = memnew( CameraEditor );
@@ -120,5 +120,5 @@ CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
*/
}
-CameraEditorPlugin::~CameraEditorPlugin() {
+Camera3DEditorPlugin::~Camera3DEditorPlugin() {
}
diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h
index 9758a1ffbd..1e57ac7cd2 100644
--- a/editor/plugins/camera_editor_plugin.h
+++ b/editor/plugins/camera_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* camera_editor_plugin.h */
+/* camera_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,11 +33,11 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/camera.h"
+#include "scene/3d/camera_3d.h"
-class CameraEditor : public Control {
+class Camera3DEditor : public Control {
- GDCLASS(CameraEditor, Control);
+ GDCLASS(Camera3DEditor, Control);
Panel *panel;
Button *preview;
@@ -51,25 +51,25 @@ protected:
public:
void edit(Node *p_camera);
- CameraEditor();
+ Camera3DEditor();
};
-class CameraEditorPlugin : public EditorPlugin {
+class Camera3DEditorPlugin : public EditorPlugin {
- GDCLASS(CameraEditorPlugin, EditorPlugin);
+ GDCLASS(Camera3DEditorPlugin, EditorPlugin);
//CameraEditor *camera_editor;
EditorNode *editor;
public:
- virtual String get_name() const { return "Camera"; }
+ virtual String get_name() const { return "Camera3D"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- CameraEditorPlugin(EditorNode *p_node);
- ~CameraEditorPlugin();
+ Camera3DEditorPlugin(EditorNode *p_node);
+ ~Camera3DEditorPlugin();
};
#endif // CAMERA_EDITOR_PLUGIN_H
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 9f66672f4a..c7ddcd5e46 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -30,7 +30,7 @@
#include "canvas_item_editor_plugin.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/project_settings.h"
@@ -40,17 +40,17 @@
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
+#include "scene/2d/gpu_particles_2d.h"
#include "scene/2d/light_2d.h"
-#include "scene/2d/particles_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/skeleton_2d.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/2d/touch_screen_button.h"
#include "scene/gui/grid_container.h"
#include "scene/gui/nine_patch_rect.h"
#include "scene/gui/viewport_container.h"
#include "scene/main/canvas_layer.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#define MIN_ZOOM 0.01
@@ -99,7 +99,7 @@ public:
label = memnew(Label);
label->set_text(TTR("Grid Offset:"));
child_container->add_child(label);
- label->set_h_size_flags(SIZE_EXPAND_FILL);
+ label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grid_offset_x = memnew(SpinBox);
grid_offset_x->set_min(-SPIN_BOX_GRID_RANGE);
@@ -107,7 +107,7 @@ public:
grid_offset_x->set_allow_lesser(true);
grid_offset_x->set_allow_greater(true);
grid_offset_x->set_suffix("px");
- grid_offset_x->set_h_size_flags(SIZE_EXPAND_FILL);
+ grid_offset_x->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(grid_offset_x);
grid_offset_y = memnew(SpinBox);
@@ -116,20 +116,20 @@ public:
grid_offset_y->set_allow_lesser(true);
grid_offset_y->set_allow_greater(true);
grid_offset_y->set_suffix("px");
- grid_offset_y->set_h_size_flags(SIZE_EXPAND_FILL);
+ grid_offset_y->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(grid_offset_y);
label = memnew(Label);
label->set_text(TTR("Grid Step:"));
child_container->add_child(label);
- label->set_h_size_flags(SIZE_EXPAND_FILL);
+ label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grid_step_x = memnew(SpinBox);
grid_step_x->set_min(0.01);
grid_step_x->set_max(SPIN_BOX_GRID_RANGE);
grid_step_x->set_allow_greater(true);
grid_step_x->set_suffix("px");
- grid_step_x->set_h_size_flags(SIZE_EXPAND_FILL);
+ grid_step_x->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(grid_step_x);
grid_step_y = memnew(SpinBox);
@@ -137,7 +137,7 @@ public:
grid_step_y->set_max(SPIN_BOX_GRID_RANGE);
grid_step_y->set_allow_greater(true);
grid_step_y->set_suffix("px");
- grid_step_y->set_h_size_flags(SIZE_EXPAND_FILL);
+ grid_step_y->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(grid_step_y);
child_container = memnew(GridContainer);
@@ -146,7 +146,7 @@ public:
label = memnew(Label);
label->set_text(TTR("Primary Line Every:"));
- label->set_h_size_flags(SIZE_EXPAND_FILL);
+ label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(label);
primary_grid_steps = memnew(SpinBox);
@@ -155,7 +155,7 @@ public:
primary_grid_steps->set_max(100);
primary_grid_steps->set_allow_greater(true);
primary_grid_steps->set_suffix(TTR("steps"));
- primary_grid_steps->set_h_size_flags(SIZE_EXPAND_FILL);
+ primary_grid_steps->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(primary_grid_steps);
container->add_child(memnew(HSeparator));
@@ -169,25 +169,25 @@ public:
label = memnew(Label);
label->set_text(TTR("Rotation Offset:"));
child_container->add_child(label);
- label->set_h_size_flags(SIZE_EXPAND_FILL);
+ label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rotation_offset = memnew(SpinBox);
rotation_offset->set_min(-SPIN_BOX_ROTATION_RANGE);
rotation_offset->set_max(SPIN_BOX_ROTATION_RANGE);
rotation_offset->set_suffix("deg");
- rotation_offset->set_h_size_flags(SIZE_EXPAND_FILL);
+ rotation_offset->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(rotation_offset);
label = memnew(Label);
label->set_text(TTR("Rotation Step:"));
child_container->add_child(label);
- label->set_h_size_flags(SIZE_EXPAND_FILL);
+ label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rotation_step = memnew(SpinBox);
rotation_step->set_min(-SPIN_BOX_ROTATION_RANGE);
rotation_step->set_max(SPIN_BOX_ROTATION_RANGE);
rotation_step->set_suffix("deg");
- rotation_step->set_h_size_flags(SIZE_EXPAND_FILL);
+ rotation_step->set_h_size_flags(Control::SIZE_EXPAND_FILL);
child_container->add_child(rotation_step);
container->add_child(memnew(HSeparator));
@@ -198,13 +198,13 @@ public:
label = memnew(Label);
label->set_text(TTR("Scale Step:"));
child_container->add_child(label);
- label->set_h_size_flags(SIZE_EXPAND_FILL);
+ label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
scale_step = memnew(SpinBox);
scale_step->set_min(SPIN_BOX_SCALE_MIN);
scale_step->set_max(SPIN_BOX_SCALE_MAX);
scale_step->set_allow_greater(true);
- scale_step->set_h_size_flags(SIZE_EXPAND_FILL);
+ scale_step->set_h_size_flags(Control::SIZE_EXPAND_FILL);
scale_step->set_step(0.01f);
child_container->add_child(scale_step);
}
@@ -334,7 +334,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
- bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_snap_active = smart_snap_active ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
// Smart snap using the canvas position
Vector2 output = p_target;
@@ -462,7 +462,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
- if (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) {
+ if (((smart_snap_active || snap_rotation) ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) {
if (snap_relative) {
return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step);
} else {
@@ -477,7 +477,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventKey> k = p_ev;
- if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
+ if (!is_visible_in_tree())
return;
if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
@@ -1284,7 +1284,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
// Pan the viewport
Point2i relative;
if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) {
- relative = Input::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect());
+ relative = InputFilter::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect());
} else {
relative = m->get_relative();
}
@@ -1912,7 +1912,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform;
bool uniform = m->get_shift();
- bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
Point2 drag_from_local = simple_xform.xform(drag_from);
Point2 drag_to_local = simple_xform.xform(drag_to);
@@ -2207,10 +2207,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (k.is_valid() && !k->is_pressed() && drag_type == DRAG_KEY_MOVE && tool == TOOL_SELECT &&
(k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) {
// Confirm canvas items move by arrow keys
- if ((!Input::get_singleton()->is_key_pressed(KEY_UP)) &&
- (!Input::get_singleton()->is_key_pressed(KEY_DOWN)) &&
- (!Input::get_singleton()->is_key_pressed(KEY_LEFT)) &&
- (!Input::get_singleton()->is_key_pressed(KEY_RIGHT))) {
+ if ((!InputFilter::get_singleton()->is_key_pressed(KEY_UP)) &&
+ (!InputFilter::get_singleton()->is_key_pressed(KEY_DOWN)) &&
+ (!InputFilter::get_singleton()->is_key_pressed(KEY_LEFT)) &&
+ (!InputFilter::get_singleton()->is_key_pressed(KEY_RIGHT))) {
_commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true);
drag_type = DRAG_NONE;
}
@@ -2284,7 +2284,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
selection_menu_additive_selection = b->get_shift();
- selection_menu->set_global_position(b->get_global_position());
+ selection_menu->set_position(get_screen_transform().xform(b->get_position()));
selection_menu->popup();
return true;
}
@@ -2588,9 +2588,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
}
void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Margin p_side) {
- Color color = get_color("font_color", "Editor");
+ Color color = get_theme_color("font_color", "Editor");
color.a = 0.8;
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
Size2 text_size = font->get_string_size(p_string);
switch (p_side) {
case MARGIN_LEFT:
@@ -2626,7 +2626,7 @@ void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_posi
void CanvasItemEditor::_draw_focus() {
// Draw the focus around the base viewport
if (viewport->has_focus()) {
- get_stylebox("Focus", "EditorStyles")->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size()));
+ get_theme_stylebox("Focus", "EditorStyles")->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size()));
}
}
@@ -2657,18 +2657,18 @@ void CanvasItemEditor::_draw_guides() {
}
// Dragged guide
- Color text_color = get_color("font_color", "Editor");
+ Color text_color = get_theme_color("font_color", "Editor");
text_color.a = 0.5;
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) {
String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x));
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
Size2 text_size = font->get_string_size(str);
viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, text_color);
viewport->draw_line(Point2(dragged_guide_pos.x, 0), Point2(dragged_guide_pos.x, viewport->get_size().y), guide_color, Math::round(EDSCALE));
}
if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) {
String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y));
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
Size2 text_size = font->get_string_size(str);
viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, text_color);
viewport->draw_line(Point2(0, dragged_guide_pos.y), Point2(viewport->get_size().x, dragged_guide_pos.y), guide_color, Math::round(EDSCALE));
@@ -2690,11 +2690,11 @@ void CanvasItemEditor::_draw_smart_snapping() {
}
void CanvasItemEditor::_draw_rulers() {
- Color bg_color = get_color("dark_color_2", "Editor");
- Color graduation_color = get_color("font_color", "Editor").linear_interpolate(bg_color, 0.5);
- Color font_color = get_color("font_color", "Editor");
+ Color bg_color = get_theme_color("dark_color_2", "Editor");
+ Color graduation_color = get_theme_color("font_color", "Editor").linear_interpolate(bg_color, 0.5);
+ Color font_color = get_theme_color("font_color", "Editor");
font_color.a = 0.8;
- Ref<Font> font = get_font("rulers", "EditorFonts");
+ Ref<Font> font = get_theme_font("rulers", "EditorFonts");
// The rule transform
Transform2D ruler_transform = Transform2D();
@@ -2856,7 +2856,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
return;
if (ruler_tool_active) {
- Color ruler_primary_color = get_color("accent_color", "Editor");
+ Color ruler_primary_color = get_theme_color("accent_color", "Editor");
Color ruler_secondary_color = ruler_primary_color;
ruler_secondary_color.a = 0.5;
@@ -2873,8 +2873,8 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE));
}
- Ref<Font> font = get_font("bold", "EditorFonts");
- Color font_color = get_color("font_color", "Editor");
+ Ref<Font> font = get_theme_font("bold", "EditorFonts");
+ Color font_color = get_theme_color("font_color", "Editor");
Color font_secondary_color = font_color;
font_secondary_color.a = 0.5;
float text_height = font->get_height();
@@ -2974,8 +2974,8 @@ void CanvasItemEditor::_draw_ruler_tool() {
} else {
if (grid_snap_active) {
- Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons");
- viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
+ Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons");
+ viewport->draw_texture(get_theme_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
}
@@ -3187,9 +3187,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
}
void CanvasItemEditor::_draw_selection() {
- Ref<Texture2D> pivot_icon = get_icon("EditorPivot", "EditorIcons");
- Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons");
- Ref<Texture2D> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons");
+ Ref<Texture2D> pivot_icon = get_theme_icon("EditorPivot", "EditorIcons");
+ Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons");
+ Ref<Texture2D> previous_position_icon = get_theme_icon("EditorPositionPrevious", "EditorIcons");
RID ci = viewport->get_canvas_item();
@@ -3297,8 +3297,8 @@ void CanvasItemEditor::_draw_selection() {
}
// Draw the move handles
- bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
- bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
+ bool is_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool is_alt = InputFilter::get_singleton()->is_key_pressed(KEY_ALT);
if (tool == TOOL_MOVE && show_transformation_gizmos) {
if (_is_node_movable(canvas_item)) {
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
@@ -3312,16 +3312,16 @@ void CanvasItemEditor::_draw_selection() {
points.push_back(Vector2(move_factor.x * EDSCALE, -5 * EDSCALE));
points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0));
- viewport->draw_colored_polygon(points, get_color("axis_x_color", "Editor"));
- viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE));
+ viewport->draw_colored_polygon(points, get_theme_color("axis_x_color", "Editor"));
+ viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color("axis_x_color", "Editor"), Math::round(EDSCALE));
points.clear();
points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE));
points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE));
points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE));
- viewport->draw_colored_polygon(points, get_color("axis_y_color", "Editor"));
- viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE));
+ viewport->draw_colored_polygon(points, get_theme_color("axis_y_color", "Editor"));
+ viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color("axis_y_color", "Editor"), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3334,7 +3334,7 @@ void CanvasItemEditor::_draw_selection() {
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
- bool uniform = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ bool uniform = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom;
if (drag_type == DRAG_SCALE_X) {
@@ -3351,12 +3351,12 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_set_transform_matrix(simple_xform);
Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- viewport->draw_rect(x_handle_rect, get_color("axis_x_color", "Editor"));
- viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE));
+ viewport->draw_rect(x_handle_rect, get_theme_color("axis_x_color", "Editor"));
+ viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color("axis_x_color", "Editor"), Math::round(EDSCALE));
Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- viewport->draw_rect(y_handle_rect, get_color("axis_y_color", "Editor"));
- viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(EDSCALE));
+ viewport->draw_rect(y_handle_rect, get_theme_color("axis_y_color", "Editor"));
+ viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color("axis_y_color", "Editor"), Math::round(EDSCALE));
viewport->draw_set_transform_matrix(viewport->get_transform());
}
@@ -3371,11 +3371,11 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_rect(
Rect2(bsfrom, bsto - bsfrom),
- get_color("box_selection_fill_color", "Editor"));
+ get_theme_color("box_selection_fill_color", "Editor"));
viewport->draw_rect(
Rect2(bsfrom, bsto - bsfrom),
- get_color("box_selection_stroke_color", "Editor"),
+ get_theme_color("box_selection_stroke_color", "Editor"),
false,
Math::round(EDSCALE));
}
@@ -3385,7 +3385,7 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_line(
transform.xform(drag_rotation_center),
transform.xform(drag_to),
- get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
+ get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
Math::round(2 * EDSCALE));
}
}
@@ -3427,7 +3427,7 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c
}
}
if (points.size() >= 2) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, points[0], points[1], p_color);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, points[0], points[1], p_color);
}
}
@@ -3435,8 +3435,8 @@ void CanvasItemEditor::_draw_axis() {
if (show_origin) {
- _draw_straight_line(Point2(), Point2(1, 0), get_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75));
- _draw_straight_line(Point2(), Point2(0, 1), get_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75));
+ _draw_straight_line(Point2(), Point2(1, 0), get_theme_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75));
+ _draw_straight_line(Point2(), Point2(0, 1), get_theme_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75));
}
if (show_viewport) {
@@ -3455,7 +3455,7 @@ void CanvasItemEditor::_draw_axis() {
};
for (int i = 0; i < 4; i++) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color);
}
}
}
@@ -3512,8 +3512,8 @@ void CanvasItemEditor::_draw_bones() {
outline_colors.push_back(bone_outline_color);
}
- VisualServer::get_singleton()->canvas_item_add_polygon(ci, bone_shape_outline, outline_colors);
- VisualServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID());
+ RenderingServer::get_singleton()->canvas_item_add_polygon(ci, bone_shape_outline, outline_colors);
+ RenderingServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID());
}
}
}
@@ -3547,7 +3547,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
Transform2D xform = transform * canvas_xform * parent_xform;
// Draw the node's position
- Ref<Texture2D> position_icon = get_icon("EditorPositionUnselected", "EditorIcons");
+ Ref<Texture2D> position_icon = get_theme_icon("EditorPositionUnselected", "EditorIcons");
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@@ -3564,7 +3564,7 @@ void CanvasItemEditor::_draw_hover() {
Ref<Texture2D> node_icon = hovering_results[i].icon;
String node_name = hovering_results[i].name;
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
Size2 node_name_size = font->get_string_size(node_name);
Size2 item_size = Size2(node_icon->get_size().x + 4 + node_name_size.x, MAX(node_icon->get_size().y, node_name_size.y - 3));
@@ -3615,13 +3615,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
if (canvas_item) {
float offset = 0;
- Ref<Texture2D> lock = get_icon("LockViewport", "EditorIcons");
+ Ref<Texture2D> lock = get_theme_icon("LockViewport", "EditorIcons");
if (p_node->has_meta("_edit_lock_") && show_edit_locks) {
lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
offset += lock->get_size().x;
}
- Ref<Texture2D> group = get_icon("GroupViewport", "EditorIcons");
+ Ref<Texture2D> group = get_theme_icon("GroupViewport", "EditorIcons");
if (canvas_item->has_meta("_edit_group_") && show_edit_locks) {
group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
//offset += group->get_size().x;
@@ -3744,7 +3744,7 @@ void CanvasItemEditor::_draw_viewport() {
}
RID ci = viewport->get_canvas_item();
- VisualServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D());
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D());
EditorPluginList *over_plugin_list = editor->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
@@ -3893,7 +3893,7 @@ void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- select_sb->set_texture(get_icon("EditorRect2D", "EditorIcons"));
+ select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons"));
for (int i = 0; i < 4; i++) {
select_sb->set_margin_size(Margin(i), 4);
select_sb->set_default_margin(Margin(i), 4);
@@ -3906,7 +3906,7 @@ void CanvasItemEditor::_notification(int p_what) {
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- select_sb->set_texture(get_icon("EditorRect2D", "EditorIcons"));
+ select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons"));
}
if (p_what == NOTIFICATION_EXIT_TREE) {
@@ -3915,85 +3915,85 @@ void CanvasItemEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- select_button->set_icon(get_icon("ToolSelect", "EditorIcons"));
- list_select_button->set_icon(get_icon("ListSelect", "EditorIcons"));
- move_button->set_icon(get_icon("ToolMove", "EditorIcons"));
- scale_button->set_icon(get_icon("ToolScale", "EditorIcons"));
- rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons"));
- smart_snap_button->set_icon(get_icon("Snap", "EditorIcons"));
- grid_snap_button->set_icon(get_icon("SnapGrid", "EditorIcons"));
- snap_config_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
- skeleton_menu->set_icon(get_icon("Bone", "EditorIcons"));
- override_camera_button->set_icon(get_icon("Camera2D", "EditorIcons"));
- pan_button->set_icon(get_icon("ToolPan", "EditorIcons"));
- ruler_button->set_icon(get_icon("Ruler", "EditorIcons"));
- pivot_button->set_icon(get_icon("EditPivot", "EditorIcons"));
- select_handle = get_icon("EditorHandle", "EditorIcons");
- anchor_handle = get_icon("EditorControlAnchor", "EditorIcons");
- lock_button->set_icon(get_icon("Lock", "EditorIcons"));
- unlock_button->set_icon(get_icon("Unlock", "EditorIcons"));
- group_button->set_icon(get_icon("Group", "EditorIcons"));
- ungroup_button->set_icon(get_icon("Ungroup", "EditorIcons"));
- key_loc_button->set_icon(get_icon("KeyPosition", "EditorIcons"));
- key_rot_button->set_icon(get_icon("KeyRotation", "EditorIcons"));
- key_scale_button->set_icon(get_icon("KeyScale", "EditorIcons"));
- key_insert_button->set_icon(get_icon("Key", "EditorIcons"));
- key_auto_insert_button->set_icon(get_icon("AutoKey", "EditorIcons"));
- animation_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
-
- zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons"));
- zoom_plus->set_icon(get_icon("ZoomMore", "EditorIcons"));
-
- presets_menu->set_icon(get_icon("ControlLayout", "EditorIcons"));
+ select_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ list_select_button->set_icon(get_theme_icon("ListSelect", "EditorIcons"));
+ move_button->set_icon(get_theme_icon("ToolMove", "EditorIcons"));
+ scale_button->set_icon(get_theme_icon("ToolScale", "EditorIcons"));
+ rotate_button->set_icon(get_theme_icon("ToolRotate", "EditorIcons"));
+ smart_snap_button->set_icon(get_theme_icon("Snap", "EditorIcons"));
+ grid_snap_button->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
+ snap_config_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
+ skeleton_menu->set_icon(get_theme_icon("Bone", "EditorIcons"));
+ override_camera_button->set_icon(get_theme_icon("Camera2D", "EditorIcons"));
+ pan_button->set_icon(get_theme_icon("ToolPan", "EditorIcons"));
+ ruler_button->set_icon(get_theme_icon("Ruler", "EditorIcons"));
+ pivot_button->set_icon(get_theme_icon("EditPivot", "EditorIcons"));
+ select_handle = get_theme_icon("EditorHandle", "EditorIcons");
+ anchor_handle = get_theme_icon("EditorControlAnchor", "EditorIcons");
+ lock_button->set_icon(get_theme_icon("Lock", "EditorIcons"));
+ unlock_button->set_icon(get_theme_icon("Unlock", "EditorIcons"));
+ group_button->set_icon(get_theme_icon("Group", "EditorIcons"));
+ ungroup_button->set_icon(get_theme_icon("Ungroup", "EditorIcons"));
+ key_loc_button->set_icon(get_theme_icon("KeyPosition", "EditorIcons"));
+ key_rot_button->set_icon(get_theme_icon("KeyRotation", "EditorIcons"));
+ key_scale_button->set_icon(get_theme_icon("KeyScale", "EditorIcons"));
+ key_insert_button->set_icon(get_theme_icon("Key", "EditorIcons"));
+ key_auto_insert_button->set_icon(get_theme_icon("AutoKey", "EditorIcons"));
+ animation_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
+
+ zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons"));
+ zoom_plus->set_icon(get_theme_icon("ZoomMore", "EditorIcons"));
+
+ presets_menu->set_icon(get_theme_icon("ControlLayout", "EditorIcons"));
PopupMenu *p = presets_menu->get_popup();
p->clear();
- p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT);
- p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT);
+ p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT);
+ p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT);
- p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP);
- p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM);
- p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER);
+ p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT);
+ p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP);
+ p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM);
+ p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE);
- p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE);
- p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE);
- p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE);
- p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE);
- p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE);
+ p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE);
+ p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE);
- p->add_icon_item(get_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO);
+ p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE);
+ p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO);
p->add_separator();
p->add_submenu_item(TTR("Anchors only"), "Anchors");
- p->set_item_icon(21, get_icon("Anchor", "EditorIcons"));
+ p->set_item_icon(21, get_theme_icon("Anchor", "EditorIcons"));
anchors_popup->clear();
- anchors_popup->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT);
- anchors_popup->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT);
anchors_popup->add_separator();
- anchors_popup->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT);
- anchors_popup->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP);
- anchors_popup->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM);
- anchors_popup->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_PRESET_CENTER);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_PRESET_CENTER);
anchors_popup->add_separator();
- anchors_popup->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE);
- anchors_popup->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE);
anchors_popup->add_separator();
- anchors_popup->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE);
+ anchors_popup->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE);
- anchor_mode_button->set_icon(get_icon("Anchor", "EditorIcons"));
+ anchor_mode_button->set_icon(get_theme_icon("Anchor", "EditorIcons"));
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -4911,7 +4911,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
bool preview = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE));
preview = !preview;
- VS::get_singleton()->canvas_set_disable_scale(!preview);
+ RS::get_singleton()->canvas_set_disable_scale(!preview);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE), preview);
} break;
@@ -5420,18 +5420,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
bottom_split = memnew(VSplitContainer);
add_child(bottom_split);
- bottom_split->set_v_size_flags(SIZE_EXPAND_FILL);
+ bottom_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
palette_split = memnew(HSplitContainer);
bottom_split->add_child(palette_split);
- palette_split->set_v_size_flags(SIZE_EXPAND_FILL);
+ palette_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
viewport_scrollable = memnew(Control);
palette_split->add_child(viewport_scrollable);
viewport_scrollable->set_mouse_filter(MOUSE_FILTER_PASS);
viewport_scrollable->set_clip_contents(true);
- viewport_scrollable->set_v_size_flags(SIZE_EXPAND_FILL);
- viewport_scrollable->set_h_size_flags(SIZE_EXPAND_FILL);
+ viewport_scrollable->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ viewport_scrollable->set_h_size_flags(Control::SIZE_EXPAND_FILL);
viewport_scrollable->connect("draw", callable_mp(this, &CanvasItemEditor::_update_scrollbars));
ViewportContainer *scene_tree = memnew(ViewportContainer);
@@ -5445,7 +5445,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_hb = memnew(HBoxContainer);
// Bring the zoom percentage closer to the zoom buttons
- zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE));
+ zoom_hb->add_theme_constant_override("separation", Math::round(-8 * EDSCALE));
controls_vb->add_child(zoom_hb);
viewport = memnew(CanvasItemEditorViewport(p_editor, this));
@@ -5462,7 +5462,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
info_overlay->set_margin(MARGIN_LEFT, 10);
info_overlay->set_margin(MARGIN_BOTTOM, -15);
info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN);
- info_overlay->add_constant_override("separation", 10);
+ info_overlay->add_theme_constant_override("separation", 10);
viewport_scrollable->add_child(info_overlay);
Theme *info_overlay_theme = memnew(Theme);
@@ -5477,8 +5477,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
warning_child_of_container = memnew(Label);
warning_child_of_container->hide();
warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent."));
- warning_child_of_container->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor"));
- warning_child_of_container->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts"));
+ warning_child_of_container->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"));
+ warning_child_of_container->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
add_control_to_info_overlay(warning_child_of_container);
h_scroll = memnew(HScrollBar);
@@ -5783,7 +5783,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
selection_menu = memnew(PopupMenu);
add_child(selection_menu);
- selection_menu->set_custom_minimum_size(Vector2(100, 0));
+ selection_menu->set_min_size(Vector2(100, 0));
selection_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_selection_result_pressed));
selection_menu->connect("popup_hide", callable_mp(this, &CanvasItemEditor::_selection_menu_hide));
@@ -5818,13 +5818,13 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
canvas_item_editor->show();
canvas_item_editor->set_physics_process(true);
- VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false);
+ RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false);
} else {
canvas_item_editor->hide();
canvas_item_editor->set_physics_process(false);
- VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true);
+ RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true);
}
}
@@ -5888,7 +5888,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {
if (texture != NULL) {
- Sprite *sprite = memnew(Sprite);
+ Sprite2D *sprite = memnew(Sprite2D);
sprite->set_texture(texture);
sprite->set_modulate(Color(1, 1, 1, 0.7f));
preview_node->add_child(sprite);
@@ -6049,7 +6049,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
// Without root dropping multiple files is not allowed
if (!target_node && selected_files.size() > 1) {
accept->set_text(TTR("Cannot instantiate multiple nodes without root."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
@@ -6083,8 +6083,8 @@ void CanvasItemEditorViewport::_perform_drop_data() {
Node *child;
if (default_type == "Light2D")
child = memnew(Light2D);
- else if (default_type == "Particles2D")
- child = memnew(Particles2D);
+ else if (default_type == "GPUParticles2D")
+ child = memnew(GPUParticles2D);
else if (default_type == "Polygon2D")
child = memnew(Polygon2D);
else if (default_type == "TouchScreenButton")
@@ -6094,7 +6094,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
else if (default_type == "NinePatchRect")
child = memnew(NinePatchRect);
else
- child = memnew(Sprite); // default
+ child = memnew(Sprite2D); // default
_create_nodes(target_node, child, path, drop_pos);
}
@@ -6110,7 +6110,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
}
files_str = files_str.substr(0, files_str.length() - 1);
accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
- accept->popup_centered_minsize();
+ accept->popup_centered();
}
}
@@ -6176,7 +6176,7 @@ void CanvasItemEditorViewport::_show_resource_type_selector() {
check->set_pressed(check->get_text() == default_type);
}
selector->set_title(vformat(TTR("Add %s"), default_type));
- selector->popup_centered_minsize();
+ selector->popup_centered();
}
bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
@@ -6191,8 +6191,8 @@ bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
}
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
- bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
- bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
+ bool is_shift = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
+ bool is_alt = InputFilter::get_singleton()->is_key_pressed(KEY_ALT);
selected_files.clear();
Dictionary d = p_data;
@@ -6233,7 +6233,7 @@ void CanvasItemEditorViewport::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit));
- label->add_color_override("font_color", get_color("warning_color", "Editor"));
+ label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
} break;
case NOTIFICATION_EXIT_TREE: {
disconnect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit));
@@ -6247,11 +6247,11 @@ void CanvasItemEditorViewport::_bind_methods() {
}
CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas_item_editor) {
- default_type = "Sprite";
+ default_type = "Sprite2D";
// Node2D
- types.push_back("Sprite");
+ types.push_back("Sprite2D");
types.push_back("Light2D");
- types.push_back("Particles2D");
+ types.push_back("GPUParticles2D");
types.push_back("Polygon2D");
types.push_back("TouchScreenButton");
// Control
@@ -6271,12 +6271,12 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
editor->get_gui_base()->add_child(selector);
selector->set_title(TTR("Change Default Type"));
selector->connect("confirmed", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_confirmed));
- selector->connect("popup_hide", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_closed));
+ selector->connect("cancelled", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_closed));
VBoxContainer *vbc = memnew(VBoxContainer);
selector->add_child(vbc);
- vbc->set_h_size_flags(SIZE_EXPAND_FILL);
- vbc->set_v_size_flags(SIZE_EXPAND_FILL);
+ vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ vbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->set_custom_minimum_size(Size2(200, 260) * EDSCALE);
btn_group = memnew(VBoxContainer);
@@ -6293,21 +6293,21 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
}
label = memnew(Label);
- label->add_color_override("font_color_shadow", Color(0, 0, 0, 1));
- label->add_constant_override("shadow_as_outline", 1 * EDSCALE);
+ label->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 1));
+ label->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE);
label->hide();
canvas_item_editor->get_controls_container()->add_child(label);
label_desc = memnew(Label);
label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type"));
- label_desc->add_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1));
- label_desc->add_color_override("font_color_shadow", Color(0.2f, 0.2f, 0.2f, 1));
- label_desc->add_constant_override("shadow_as_outline", 1 * EDSCALE);
- label_desc->add_constant_override("line_spacing", 0);
+ label_desc->add_theme_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1));
+ label_desc->add_theme_color_override("font_color_shadow", Color(0.2f, 0.2f, 0.2f, 1));
+ label_desc->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE);
+ label_desc->add_theme_constant_override("line_spacing", 0);
label_desc->hide();
canvas_item_editor->get_controls_container()->add_child(label_desc);
- VS::get_singleton()->canvas_set_disable_scale(true);
+ RS::get_singleton()->canvas_set_disable_scale(true);
}
CanvasItemEditorViewport::~CanvasItemEditorViewport() {
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 3c4cacf5c8..34965868e0 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/2d/canvas_item.h"
#include "scene/gui/box_container.h"
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/spin_box.h"
+#include "scene/main/canvas_item.h"
class CanvasItemEditorViewport;
@@ -687,7 +687,7 @@ class CanvasItemEditorViewport : public Control {
CanvasItemEditor *canvas_item_editor;
Node2D *preview_node;
AcceptDialog *accept;
- WindowDialog *selector;
+ AcceptDialog *selector;
Label *selector_label;
Label *label;
Label *label_desc;
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
index 1562286073..5b35a4826c 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_polygon_editor_plugin.cpp */
+/* collision_polygon_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,26 +28,26 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_polygon_editor_plugin.h"
+#include "collision_polygon_3d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/os/file_access.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_settings.h"
-#include "scene/3d/camera.h"
-#include "spatial_editor_plugin.h"
+#include "node_3d_editor_plugin.h"
+#include "scene/3d/camera_3d.h"
-void Polygon3DEditor::_notification(int p_what) {
+void CollisionPolygon3DEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- button_create->set_icon(get_icon("Edit", "EditorIcons"));
- button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
+ button_create->set_icon(get_theme_icon("Edit", "EditorIcons"));
+ button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed));
+ get_tree()->connect("node_removed", callable_mp(this, &CollisionPolygon3DEditor::_node_removed));
} break;
case NOTIFICATION_PROCESS: {
@@ -63,7 +63,7 @@ void Polygon3DEditor::_notification(int p_what) {
} break;
}
}
-void Polygon3DEditor::_node_removed(Node *p_node) {
+void CollisionPolygon3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@@ -74,7 +74,7 @@ void Polygon3DEditor::_node_removed(Node *p_node) {
}
}
-void Polygon3DEditor::_menu_option(int p_option) {
+void CollisionPolygon3DEditor::_menu_option(int p_option) {
switch (p_option) {
@@ -93,7 +93,7 @@ void Polygon3DEditor::_menu_option(int p_option) {
}
}
-void Polygon3DEditor::_wip_close() {
+void CollisionPolygon3DEditor::_wip_close() {
undo_redo->create_action(TTR("Create Polygon3D"));
undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon"));
@@ -109,7 +109,7 @@ void Polygon3DEditor::_wip_close() {
undo_redo->commit_action();
}
-bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!node)
return false;
@@ -342,14 +342,14 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
Vector2 cpoint(spoint.x, spoint.y);
- if (snap_ignore && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (snap_ignore && !InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
snap_ignore = false;
}
- if (!snap_ignore && SpatialEditor::get_singleton()->is_snap_enabled()) {
+ if (!snap_ignore && Node3DEditor::get_singleton()->is_snap_enabled()) {
cpoint = cpoint.snapped(Vector2(
- SpatialEditor::get_singleton()->get_translate_snap(),
- SpatialEditor::get_singleton()->get_translate_snap()));
+ Node3DEditor::get_singleton()->get_translate_snap(),
+ Node3DEditor::get_singleton()->get_translate_snap()));
}
edited_point_pos = cpoint;
@@ -360,7 +360,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
return false;
}
-float Polygon3DEditor::_get_depth() {
+float CollisionPolygon3DEditor::_get_depth() {
if (bool(node->call("_has_editable_3d_polygon_no_depth")))
return 0;
@@ -368,7 +368,7 @@ float Polygon3DEditor::_get_depth() {
return float(node->call("get_depth"));
}
-void Polygon3DEditor::_polygon_draw() {
+void CollisionPolygon3DEditor::_polygon_draw() {
if (!node)
return;
@@ -489,11 +489,11 @@ void Polygon3DEditor::_polygon_draw() {
m->surface_set_material(0, handle_material);
}
-void Polygon3DEditor::edit(Node *p_collision_polygon) {
+void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
- node = Object::cast_to<Spatial>(p_collision_polygon);
+ node = Object::cast_to<Node3D>(p_collision_polygon);
//Enable the pencil tool if the polygon is empty
if (Vector<Vector2>(node->call("get_polygon")).size() == 0) {
_menu_option(MODE_CREATE);
@@ -516,12 +516,12 @@ void Polygon3DEditor::edit(Node *p_collision_polygon) {
}
}
-void Polygon3DEditor::_bind_methods() {
+void CollisionPolygon3DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_polygon_draw"), &Polygon3DEditor::_polygon_draw);
+ ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygon3DEditor::_polygon_draw);
}
-Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
+CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
node = NULL;
editor = p_editor;
@@ -530,17 +530,17 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
add_child(memnew(VSeparator));
button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_CREATE));
+ button_create->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_EDIT));
+ button_edit->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
mode = MODE_EDIT;
wip_active = false;
- imgeom = memnew(ImmediateGeometry);
+ imgeom = memnew(ImmediateGeometry3D);
imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
@@ -556,11 +556,11 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
- Ref<Texture2D> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
+ Ref<Texture2D> handle = editor->get_gui_base()->get_theme_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle->get_width());
handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle);
- pointsm = memnew(MeshInstance);
+ pointsm = memnew(MeshInstance3D);
imgeom->add_child(pointsm);
m.instance();
pointsm->set_mesh(m);
@@ -569,7 +569,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
snap_ignore = false;
}
-Polygon3DEditor::~Polygon3DEditor() {
+CollisionPolygon3DEditor::~CollisionPolygon3DEditor() {
memdelete(imgeom);
}
@@ -581,7 +581,7 @@ void Polygon3DEditorPlugin::edit(Object *p_object) {
bool Polygon3DEditorPlugin::handles(Object *p_object) const {
- return Object::cast_to<Spatial>(p_object) && bool(p_object->call("_is_editable_3d_polygon"));
+ return Object::cast_to<Node3D>(p_object) && bool(p_object->call("_is_editable_3d_polygon"));
}
void Polygon3DEditorPlugin::make_visible(bool p_visible) {
@@ -598,8 +598,8 @@ void Polygon3DEditorPlugin::make_visible(bool p_visible) {
Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- collision_polygon_editor = memnew(Polygon3DEditor(p_node));
- SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
+ collision_polygon_editor = memnew(CollisionPolygon3DEditor(p_node));
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
}
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_3d_editor_plugin.h
index 3b6c25ac17..9751b1f79e 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_polygon_editor_plugin.h */
+/* collision_polygon_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,16 +33,16 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/collision_polygon.h"
-#include "scene/3d/immediate_geometry.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/collision_polygon_3d.h"
+#include "scene/3d/immediate_geometry_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/tool_button.h"
class CanvasItemEditor;
-class Polygon3DEditor : public HBoxContainer {
+class CollisionPolygon3DEditor : public HBoxContainer {
- GDCLASS(Polygon3DEditor, HBoxContainer);
+ GDCLASS(CollisionPolygon3DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -62,9 +62,9 @@ class Polygon3DEditor : public HBoxContainer {
EditorNode *editor;
Panel *panel;
- Spatial *node;
- ImmediateGeometry *imgeom;
- MeshInstance *pointsm;
+ Node3D *node;
+ ImmediateGeometry3D *imgeom;
+ MeshInstance3D *pointsm;
Ref<ArrayMesh> m;
MenuButton *options;
@@ -90,21 +90,21 @@ protected:
static void _bind_methods();
public:
- virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
+ virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_collision_polygon);
- Polygon3DEditor(EditorNode *p_editor);
- ~Polygon3DEditor();
+ CollisionPolygon3DEditor(EditorNode *p_editor);
+ ~CollisionPolygon3DEditor();
};
class Polygon3DEditorPlugin : public EditorPlugin {
GDCLASS(Polygon3DEditorPlugin, EditorPlugin);
- Polygon3DEditor *collision_polygon_editor;
+ CollisionPolygon3DEditor *collision_polygon_editor;
EditorNode *editor;
public:
- virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
+ virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual String get_name() const { return "Polygon3DEditor"; }
bool has_main_screen() const { return false; }
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 01b4a61a85..709ff91fc0 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -435,7 +435,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture2D> h = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> h = get_theme_icon("EditorHandle", "EditorIcons");
Vector2 size = h->get_size() * 0.5;
handles.clear();
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index 119528dfc8..022663a61d 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -60,7 +60,7 @@ void CPUParticles2DEditorPlugin::make_visible(bool p_visible) {
void CPUParticles2DEditorPlugin::_file_selected(const String &p_file) {
source_emission_file = p_file;
- emission_mask->popup_centered_minsize();
+ emission_mask->popup_centered();
}
void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
@@ -73,7 +73,7 @@ void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
} break;
case MENU_CLEAR_EMISSION_MASK: {
- emission_mask->popup_centered_minsize();
+ emission_mask->popup_centered();
} break;
case MENU_RESTART: {
@@ -241,7 +241,7 @@ void CPUParticles2DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback));
- menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
+ menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons"));
file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected));
}
}
@@ -265,8 +265,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
menu->get_popup()->add_separator();
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
- // menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
- menu->set_text(TTR("Particles"));
+ menu->set_text(TTR("CPUParticles2D"));
menu->set_switch_on_hover(true);
toolbar->add_child(menu);
@@ -276,7 +275,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
for (List<String>::Element *E = ext.front(); E; E = E->next()) {
file->add_filter("*." + E->get() + "; " + E->get().to_upper());
}
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
toolbar->add_child(file);
epoints = memnew(SpinBox);
diff --git a/editor/plugins/cpu_particles_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
index 2161041ee6..887e9e48df 100644
--- a/editor/plugins/cpu_particles_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cpu_particles_editor_plugin.cpp */
+/* cpu_particles_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "cpu_particles_editor_plugin.h"
+#include "cpu_particles_3d_editor_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
-void CPUParticlesEditor::_node_removed(Node *p_node) {
+void CPUParticles3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@@ -40,14 +40,14 @@ void CPUParticlesEditor::_node_removed(Node *p_node) {
}
}
-void CPUParticlesEditor::_notification(int p_notification) {
+void CPUParticles3DEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE) {
- options->set_icon(options->get_popup()->get_icon("CPUParticles", "EditorIcons"));
+ options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons"));
}
}
-void CPUParticlesEditor::_menu_option(int p_option) {
+void CPUParticles3DEditor::_menu_option(int p_option) {
switch (p_option) {
@@ -65,13 +65,13 @@ void CPUParticlesEditor::_menu_option(int p_option) {
}
}
-void CPUParticlesEditor::edit(CPUParticles *p_particles) {
+void CPUParticles3DEditor::edit(CPUParticles3D *p_particles) {
base_node = p_particles;
node = p_particles;
}
-void CPUParticlesEditor::_generate_emission_points() {
+void CPUParticles3DEditor::_generate_emission_points() {
/// hacer codigo aca
Vector<Vector3> points;
@@ -82,45 +82,45 @@ void CPUParticlesEditor::_generate_emission_points() {
}
if (normals.size() == 0) {
- node->set_emission_shape(CPUParticles::EMISSION_SHAPE_POINTS);
+ node->set_emission_shape(CPUParticles3D::EMISSION_SHAPE_POINTS);
node->set_emission_points(points);
} else {
- node->set_emission_shape(CPUParticles::EMISSION_SHAPE_DIRECTED_POINTS);
+ node->set_emission_shape(CPUParticles3D::EMISSION_SHAPE_DIRECTED_POINTS);
node->set_emission_points(points);
node->set_emission_normals(normals);
}
}
-void CPUParticlesEditor::_bind_methods() {
+void CPUParticles3DEditor::_bind_methods() {
}
-CPUParticlesEditor::CPUParticlesEditor() {
+CPUParticles3DEditor::CPUParticles3DEditor() {
particles_editor_hb = memnew(HBoxContainer);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
options = memnew(MenuButton);
options->set_switch_on_hover(true);
particles_editor_hb->add_child(options);
particles_editor_hb->hide();
- options->set_text(TTR("CPUParticles"));
+ options->set_text(TTR("CPUParticles3D"));
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
- options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticlesEditor::_menu_option));
+ options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles3DEditor::_menu_option));
}
-void CPUParticlesEditorPlugin::edit(Object *p_object) {
+void CPUParticles3DEditorPlugin::edit(Object *p_object) {
- particles_editor->edit(Object::cast_to<CPUParticles>(p_object));
+ particles_editor->edit(Object::cast_to<CPUParticles3D>(p_object));
}
-bool CPUParticlesEditorPlugin::handles(Object *p_object) const {
+bool CPUParticles3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("CPUParticles");
+ return p_object->is_class("CPUParticles3D");
}
-void CPUParticlesEditorPlugin::make_visible(bool p_visible) {
+void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
particles_editor->show();
@@ -132,14 +132,14 @@ void CPUParticlesEditorPlugin::make_visible(bool p_visible) {
}
}
-CPUParticlesEditorPlugin::CPUParticlesEditorPlugin(EditorNode *p_node) {
+CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- particles_editor = memnew(CPUParticlesEditor);
+ particles_editor = memnew(CPUParticles3DEditor);
editor->get_viewport()->add_child(particles_editor);
particles_editor->hide();
}
-CPUParticlesEditorPlugin::~CPUParticlesEditorPlugin() {
+CPUParticles3DEditorPlugin::~CPUParticles3DEditorPlugin() {
}
diff --git a/editor/plugins/cpu_particles_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h
index 4cf143fc0c..aac9cc9a2f 100644
--- a/editor/plugins/cpu_particles_editor_plugin.h
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cpu_particles_editor_plugin.h */
+/* cpu_particles_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,12 +31,12 @@
#ifndef CPU_PARTICLES_EDITOR_PLUGIN_H
#define CPU_PARTICLES_EDITOR_PLUGIN_H
-#include "editor/plugins/particles_editor_plugin.h"
-#include "scene/3d/cpu_particles.h"
+#include "editor/plugins/gpu_particles_3d_editor_plugin.h"
+#include "scene/3d/cpu_particles_3d.h"
-class CPUParticlesEditor : public ParticlesEditorBase {
+class CPUParticles3DEditor : public GPUParticles3DEditorBase {
- GDCLASS(CPUParticlesEditor, ParticlesEditorBase);
+ GDCLASS(CPUParticles3DEditor, GPUParticles3DEditorBase);
enum Menu {
@@ -46,11 +46,11 @@ class CPUParticlesEditor : public ParticlesEditorBase {
};
- CPUParticles *node;
+ CPUParticles3D *node;
void _menu_option(int);
- friend class CPUParticlesEditorPlugin;
+ friend class CPUParticles3DEditorPlugin;
virtual void _generate_emission_points();
@@ -60,15 +60,15 @@ protected:
static void _bind_methods();
public:
- void edit(CPUParticles *p_particles);
- CPUParticlesEditor();
+ void edit(CPUParticles3D *p_particles);
+ CPUParticles3DEditor();
};
-class CPUParticlesEditorPlugin : public EditorPlugin {
+class CPUParticles3DEditorPlugin : public EditorPlugin {
- GDCLASS(CPUParticlesEditorPlugin, EditorPlugin);
+ GDCLASS(CPUParticles3DEditorPlugin, EditorPlugin);
- CPUParticlesEditor *particles_editor;
+ CPUParticles3DEditor *particles_editor;
EditorNode *editor;
public:
@@ -78,8 +78,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- CPUParticlesEditorPlugin(EditorNode *p_node);
- ~CPUParticlesEditorPlugin();
+ CPUParticles3DEditorPlugin(EditorNode *p_node);
+ ~CPUParticles3DEditorPlugin();
};
#endif // CPU_PARTICLES_EDITOR_PLUGIN_H
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 878787231d..0fd8ea4fb5 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -32,7 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/core_string_names.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
@@ -210,7 +210,7 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
else
tangent = 9999 * (dir.y >= 0 ? 1 : -1);
- bool link = !Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ bool link = !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
if (_selected_tangent == TANGENT_LEFT) {
curve.set_point_left_tangent(_selected_point, tangent);
@@ -511,7 +511,7 @@ void CurveEditor::set_hover_point_index(int index) {
}
void CurveEditor::update_view_transform() {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
const real_t margin = font->get_height() + 2 * EDSCALE;
float min_y = 0;
@@ -626,7 +626,7 @@ void CurveEditor::_draw() {
// Background
Vector2 view_size = get_rect().size;
- draw_style_box(get_stylebox("bg", "Tree"), Rect2(Point2(), view_size));
+ draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), view_size));
// Grid
@@ -635,8 +635,8 @@ void CurveEditor::_draw() {
Vector2 min_edge = get_world_pos(Vector2(0, view_size.y));
Vector2 max_edge = get_world_pos(Vector2(view_size.x, 0));
- const Color grid_color0 = get_color("mono_color", "Editor") * Color(1, 1, 1, 0.15);
- const Color grid_color1 = get_color("mono_color", "Editor") * Color(1, 1, 1, 0.07);
+ const Color grid_color0 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.15);
+ const Color grid_color1 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.07);
draw_line(Vector2(min_edge.x, curve.get_min_value()), Vector2(max_edge.x, curve.get_min_value()), grid_color0);
draw_line(Vector2(max_edge.x, curve.get_max_value()), Vector2(min_edge.x, curve.get_max_value()), grid_color0);
draw_line(Vector2(0, min_edge.y), Vector2(0, max_edge.y), grid_color0);
@@ -656,9 +656,9 @@ void CurveEditor::_draw() {
draw_set_transform_matrix(Transform2D());
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
float font_height = font->get_height();
- Color text_color = get_color("font_color", "Editor");
+ Color text_color = get_theme_color("font_color", "Editor");
{
// X axis
@@ -686,7 +686,7 @@ void CurveEditor::_draw() {
if (_selected_point >= 0) {
- const Color tangent_color = get_color("accent_color", "Editor");
+ const Color tangent_color = get_theme_color("accent_color", "Editor");
int i = _selected_point;
Vector2 pos = curve.get_point_position(i);
@@ -708,8 +708,8 @@ void CurveEditor::_draw() {
draw_set_transform_matrix(_world_to_view);
- const Color line_color = get_color("font_color", "Editor");
- const Color edge_line_color = get_color("highlight_color", "Editor");
+ const Color line_color = get_theme_color("font_color", "Editor");
+ const Color edge_line_color = get_theme_color("highlight_color", "Editor");
CanvasItemPlotCurve plot_func(*this, line_color, edge_line_color);
plot_curve_accurate(curve, 4.f / view_size.x, plot_func);
@@ -718,8 +718,8 @@ void CurveEditor::_draw() {
draw_set_transform_matrix(Transform2D());
- const Color point_color = get_color("font_color", "Editor");
- const Color selected_point_color = get_color("accent_color", "Editor");
+ const Color point_color = get_theme_color("font_color", "Editor");
+ const Color selected_point_color = get_theme_color("accent_color", "Editor");
for (int i = 0; i < curve.get_point_count(); ++i) {
Vector2 pos = curve.get_point_position(i);
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index c4069ac2ab..566ff378c3 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -54,7 +54,6 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
// Main editor debug menu.
debug_menu = p_debug_menu;
PopupMenu *p = debug_menu->get_popup();
- p->set_hide_on_window_lose_focus(true);
p->set_hide_on_checkable_item_selection(false);
p->add_check_shortcut(ED_SHORTCUT("editor/deploy_with_remote_debug", TTR("Deploy with Remote Debug")), RUN_DEPLOY_REMOTE_DEBUG);
p->set_item_tooltip(p->get_item_count() - 1, TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged."));
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 3c173ab783..a8c4bddccf 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -328,19 +328,19 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si
if (material->get_shader_mode() == Shader::MODE_SPATIAL) {
- VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid());
+ RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid());
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture
preview_done = false;
- VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant());
+ RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant());
while (!preview_done) {
OS::get_singleton()->delay_usec(10);
}
- Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
- VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID());
+ Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
+ RS::get_singleton()->mesh_surface_set_material(sphere, 0, RID());
ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>());
@@ -358,35 +358,35 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si
EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
- scenario = VS::get_singleton()->scenario_create();
+ scenario = RS::get_singleton()->scenario_create();
- viewport = VS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_scenario(viewport, scenario);
- VS::get_singleton()->viewport_set_size(viewport, 128, 128);
- VS::get_singleton()->viewport_set_transparent_background(viewport, true);
- VS::get_singleton()->viewport_set_active(viewport, true);
- viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
+ viewport = RS::get_singleton()->viewport_create();
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
+ RS::get_singleton()->viewport_set_scenario(viewport, scenario);
+ RS::get_singleton()->viewport_set_size(viewport, 128, 128);
+ RS::get_singleton()->viewport_set_transparent_background(viewport, true);
+ RS::get_singleton()->viewport_set_active(viewport, true);
+ viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
- camera = VS::get_singleton()->camera_create();
- VS::get_singleton()->viewport_attach_camera(viewport, camera);
- VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3)));
- VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10);
+ camera = RS::get_singleton()->camera_create();
+ RS::get_singleton()->viewport_attach_camera(viewport, camera);
+ RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3)));
+ RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10);
- light = VS::get_singleton()->directional_light_create();
- light_instance = VS::get_singleton()->instance_create2(light, scenario);
- VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
+ light = RS::get_singleton()->directional_light_create();
+ light_instance = RS::get_singleton()->instance_create2(light, scenario);
+ RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
- light2 = VS::get_singleton()->directional_light_create();
- VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
- //VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
+ light2 = RS::get_singleton()->directional_light_create();
+ RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
+ //RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
- light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
+ light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
- VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
+ RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
- sphere = VS::get_singleton()->mesh_create();
- sphere_instance = VS::get_singleton()->instance_create2(sphere, scenario);
+ sphere = RS::get_singleton()->mesh_create();
+ sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario);
int lats = 32;
int lons = 32;
@@ -453,25 +453,25 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
}
Array arr;
- arr.resize(VS::ARRAY_MAX);
- arr[VS::ARRAY_VERTEX] = vertices;
- arr[VS::ARRAY_NORMAL] = normals;
- arr[VS::ARRAY_TANGENT] = tangents;
- arr[VS::ARRAY_TEX_UV] = uvs;
- VS::get_singleton()->mesh_add_surface_from_arrays(sphere, VS::PRIMITIVE_TRIANGLES, arr);
+ arr.resize(RS::ARRAY_MAX);
+ arr[RS::ARRAY_VERTEX] = vertices;
+ arr[RS::ARRAY_NORMAL] = normals;
+ arr[RS::ARRAY_TANGENT] = tangents;
+ arr[RS::ARRAY_TEX_UV] = uvs;
+ RS::get_singleton()->mesh_add_surface_from_arrays(sphere, RS::PRIMITIVE_TRIANGLES, arr);
}
EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() {
- VS::get_singleton()->free(sphere);
- VS::get_singleton()->free(sphere_instance);
- VS::get_singleton()->free(viewport);
- VS::get_singleton()->free(light);
- VS::get_singleton()->free(light_instance);
- VS::get_singleton()->free(light2);
- VS::get_singleton()->free(light_instance2);
- VS::get_singleton()->free(camera);
- VS::get_singleton()->free(scenario);
+ RS::get_singleton()->free(sphere);
+ RS::get_singleton()->free(sphere_instance);
+ RS::get_singleton()->free(viewport);
+ RS::get_singleton()->free(light);
+ RS::get_singleton()->free(light_instance);
+ RS::get_singleton()->free(light2);
+ RS::get_singleton()->free(light_instance2);
+ RS::get_singleton()->free(camera);
+ RS::get_singleton()->free(scenario);
}
///////////////////////////////////////////////////////////////////////////
@@ -706,7 +706,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
Ref<Mesh> mesh = p_from;
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>());
- VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
+ RS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
AABB aabb = mesh->get_aabb();
Vector3 ofs = aabb.position + aabb.size * 0.5;
@@ -723,21 +723,21 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
xform.basis.scale(Vector3(m, m, m));
xform.origin = -xform.basis.xform(ofs); //-ofs*m;
xform.origin.z -= rot_aabb.size.z * 2;
- VS::get_singleton()->instance_set_transform(mesh_instance, xform);
+ RS::get_singleton()->instance_set_transform(mesh_instance, xform);
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture
preview_done = false;
- VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant());
+ RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant());
while (!preview_done) {
OS::get_singleton()->delay_usec(10);
}
- Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
+ Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
- VS::get_singleton()->instance_set_base(mesh_instance, RID());
+ RS::get_singleton()->instance_set_base(mesh_instance, RID());
img->convert(Image::FORMAT_RGBA8);
@@ -759,49 +759,49 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
- scenario = VS::get_singleton()->scenario_create();
+ scenario = RS::get_singleton()->scenario_create();
- viewport = VS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_scenario(viewport, scenario);
- VS::get_singleton()->viewport_set_size(viewport, 128, 128);
- VS::get_singleton()->viewport_set_transparent_background(viewport, true);
- VS::get_singleton()->viewport_set_active(viewport, true);
- viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
+ viewport = RS::get_singleton()->viewport_create();
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
+ RS::get_singleton()->viewport_set_scenario(viewport, scenario);
+ RS::get_singleton()->viewport_set_size(viewport, 128, 128);
+ RS::get_singleton()->viewport_set_transparent_background(viewport, true);
+ RS::get_singleton()->viewport_set_active(viewport, true);
+ viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
- camera = VS::get_singleton()->camera_create();
- VS::get_singleton()->viewport_attach_camera(viewport, camera);
- VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3)));
- //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
- VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0);
+ camera = RS::get_singleton()->camera_create();
+ RS::get_singleton()->viewport_attach_camera(viewport, camera);
+ RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3)));
+ //RS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
+ RS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0);
- light = VS::get_singleton()->directional_light_create();
- light_instance = VS::get_singleton()->instance_create2(light, scenario);
- VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
+ light = RS::get_singleton()->directional_light_create();
+ light_instance = RS::get_singleton()->instance_create2(light, scenario);
+ RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
- light2 = VS::get_singleton()->directional_light_create();
- VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
- //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
- light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
+ light2 = RS::get_singleton()->directional_light_create();
+ RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
+ //RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
+ light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
- VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
+ RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
- //sphere = VS::get_singleton()->mesh_create();
- mesh_instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_scenario(mesh_instance, scenario);
+ //sphere = RS::get_singleton()->mesh_create();
+ mesh_instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_scenario(mesh_instance, scenario);
}
EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() {
- //VS::get_singleton()->free(sphere);
- VS::get_singleton()->free(mesh_instance);
- VS::get_singleton()->free(viewport);
- VS::get_singleton()->free(light);
- VS::get_singleton()->free(light_instance);
- VS::get_singleton()->free(light2);
- VS::get_singleton()->free(light_instance2);
- VS::get_singleton()->free(camera);
- VS::get_singleton()->free(scenario);
+ //RS::get_singleton()->free(sphere);
+ RS::get_singleton()->free(mesh_instance);
+ RS::get_singleton()->free(viewport);
+ RS::get_singleton()->free(light);
+ RS::get_singleton()->free(light_instance);
+ RS::get_singleton()->free(light2);
+ RS::get_singleton()->free(light_instance2);
+ RS::get_singleton()->free(camera);
+ RS::get_singleton()->free(scenario);
}
///////////////////////////////////////////////////////////////////////////
@@ -849,16 +849,16 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
font->draw(canvas_item, pos, sampled_text);
preview_done = false;
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
- VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant());
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture
+ RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant());
while (!preview_done) {
OS::get_singleton()->delay_usec(10);
}
- VS::get_singleton()->canvas_item_clear(canvas_item);
+ RS::get_singleton()->canvas_item_clear(canvas_item);
- Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
+ Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
img->convert(Image::FORMAT_RGBA8);
@@ -891,22 +891,22 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2
EditorFontPreviewPlugin::EditorFontPreviewPlugin() {
- viewport = VS::get_singleton()->viewport_create();
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED);
- VS::get_singleton()->viewport_set_size(viewport, 128, 128);
- VS::get_singleton()->viewport_set_active(viewport, true);
- viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
+ viewport = RS::get_singleton()->viewport_create();
+ RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
+ RS::get_singleton()->viewport_set_size(viewport, 128, 128);
+ RS::get_singleton()->viewport_set_active(viewport, true);
+ viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
- canvas = VS::get_singleton()->canvas_create();
- canvas_item = VS::get_singleton()->canvas_item_create();
+ canvas = RS::get_singleton()->canvas_create();
+ canvas_item = RS::get_singleton()->canvas_item_create();
- VS::get_singleton()->viewport_attach_canvas(viewport, canvas);
- VS::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
+ RS::get_singleton()->viewport_attach_canvas(viewport, canvas);
+ RS::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
}
EditorFontPreviewPlugin::~EditorFontPreviewPlugin() {
- VS::get_singleton()->free(canvas_item);
- VS::get_singleton()->free(canvas);
- VS::get_singleton()->free(viewport);
+ RS::get_singleton()->free(canvas_item);
+ RS::get_singleton()->free(canvas);
+ RS::get_singleton()->free(viewport);
}
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index c077c23e8a..908a32fdb6 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -87,16 +87,16 @@ void GIProbeEditorPlugin::_notification(int p_what) {
Color color;
if (size_mb <= 16.0 + CMP_EPSILON) {
// Fast.
- color = bake_info->get_color("success_color", "Editor");
+ color = bake_info->get_theme_color("success_color", "Editor");
} else if (size_mb <= 64.0 + CMP_EPSILON) {
// Medium.
- color = bake_info->get_color("warning_color", "Editor");
+ color = bake_info->get_theme_color("warning_color", "Editor");
} else {
// Slow.
- color = bake_info->get_color("error_color", "Editor");
+ color = bake_info->get_theme_color("error_color", "Editor");
}
+ bake_info->add_theme_color_override("font_color", color);
- bake_info->add_color_override("font_color", color);
bake_info->set_text(text);
}
}
@@ -153,7 +153,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
bake_hb->hide();
bake = memnew(ToolButton);
- bake->set_icon(editor->get_gui_base()->get_icon("Bake", "EditorIcons"));
+ bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons"));
bake->set_text(TTR("Bake GI Probe"));
bake->connect("pressed", callable_mp(this, &GIProbeEditorPlugin::_bake));
bake_hb->add_child(bake);
@@ -165,7 +165,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
gi_probe = NULL;
probe_file = memnew(EditorFileDialog);
- probe_file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
probe_file->add_filter("*.res");
probe_file->connect("file_selected", callable_mp(this, &GIProbeEditorPlugin::_giprobe_save_path_and_bake));
get_editor_interface()->get_base_control()->add_child(probe_file);
diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
index 812144742f..89bff7ccab 100644
--- a/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles_2d_editor_plugin.cpp */
+/* gpu_particles_2d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "particles_2d_editor_plugin.h"
+#include "gpu_particles_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "core/io/image_loader.h"
@@ -36,17 +36,17 @@
#include "scene/gui/separator.h"
#include "scene/resources/particles_material.h"
-void Particles2DEditorPlugin::edit(Object *p_object) {
+void GPUParticles2DEditorPlugin::edit(Object *p_object) {
- particles = Object::cast_to<Particles2D>(p_object);
+ particles = Object::cast_to<GPUParticles2D>(p_object);
}
-bool Particles2DEditorPlugin::handles(Object *p_object) const {
+bool GPUParticles2DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Particles2D");
+ return p_object->is_class("GPUParticles2D");
}
-void Particles2DEditorPlugin::make_visible(bool p_visible) {
+void GPUParticles2DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
@@ -57,13 +57,13 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) {
}
}
-void Particles2DEditorPlugin::_file_selected(const String &p_file) {
+void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) {
source_emission_file = p_file;
- emission_mask->popup_centered_minsize();
+ emission_mask->popup_centered();
}
-void Particles2DEditorPlugin::_menu_callback(int p_idx) {
+void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
switch (p_idx) {
case MENU_GENERATE_VISIBILITY_RECT: {
@@ -72,7 +72,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
generate_seconds->set_value(1.0);
else
generate_seconds->set_value(trunc(gen_time) + 1.0);
- generate_visibility_rect->popup_centered_minsize();
+ generate_visibility_rect->popup_centered();
} break;
case MENU_LOAD_EMISSION_MASK: {
@@ -81,7 +81,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
} break;
case MENU_CLEAR_EMISSION_MASK: {
- emission_mask->popup_centered_minsize();
+ emission_mask->popup_centered();
} break;
case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
@@ -94,7 +94,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
cpu_particles->set_z_index(particles->get_z_index());
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action(TTR("Convert to CPUParticles"));
+ ur->create_action(TTR("Convert to CPUParticles2D"));
ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", particles, cpu_particles, true, false);
ur->add_do_reference(cpu_particles);
ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, particles, false, false);
@@ -109,7 +109,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
}
}
-void Particles2DEditorPlugin::_generate_visibility_rect() {
+void GPUParticles2DEditorPlugin::_generate_visibility_rect() {
float time = generate_seconds->get_value();
@@ -149,7 +149,7 @@ void Particles2DEditorPlugin::_generate_visibility_rect() {
undo_redo->commit_action();
}
-void Particles2DEditorPlugin::_generate_emission_mask() {
+void GPUParticles2DEditorPlugin::_generate_emission_mask() {
Ref<ParticlesMaterial> pm = particles->get_process_material();
if (!pm.is_valid()) {
@@ -345,20 +345,20 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
}
}
-void Particles2DEditorPlugin::_notification(int p_what) {
+void GPUParticles2DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- menu->get_popup()->connect("id_pressed", callable_mp(this, &Particles2DEditorPlugin::_menu_callback));
- menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
- file->connect("file_selected", callable_mp(this, &Particles2DEditorPlugin::_file_selected));
+ menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback));
+ menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons"));
+ file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected));
}
}
-void Particles2DEditorPlugin::_bind_methods() {
+void GPUParticles2DEditorPlugin::_bind_methods() {
}
-Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
+GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) {
particles = NULL;
editor = p_node;
@@ -376,10 +376,10 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
menu->get_popup()->add_separator();
- menu->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
+ menu->get_popup()->add_item(TTR("Convert to CPUParticles2D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
menu->get_popup()->add_separator();
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
- menu->set_text(TTR("Particles"));
+ menu->set_text(TTR("GPUParticles2D"));
menu->set_switch_on_hover(true);
toolbar->add_child(menu);
@@ -389,7 +389,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
for (List<String>::Element *E = ext.front(); E; E = E->next()) {
file->add_filter("*." + E->get() + "; " + E->get().to_upper());
}
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
toolbar->add_child(file);
epoints = memnew(SpinBox);
@@ -411,7 +411,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(generate_visibility_rect);
- generate_visibility_rect->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_visibility_rect));
+ generate_visibility_rect->connect("confirmed", callable_mp(this, &GPUParticles2DEditorPlugin::_generate_visibility_rect));
emission_mask = memnew(ConfirmationDialog);
emission_mask->set_title(TTR("Load Emission Mask"));
@@ -428,8 +428,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(emission_mask);
- emission_mask->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_emission_mask));
+ emission_mask->connect("confirmed", callable_mp(this, &GPUParticles2DEditorPlugin::_generate_emission_mask));
}
-Particles2DEditorPlugin::~Particles2DEditorPlugin() {
+GPUParticles2DEditorPlugin::~GPUParticles2DEditorPlugin() {
}
diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h
index 29652a1826..904786ffae 100644
--- a/editor/plugins/particles_2d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles_2d_editor_plugin.h */
+/* gpu_particles_2d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,13 +34,13 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/collision_polygon_2d.h"
-#include "scene/2d/particles_2d.h"
+#include "scene/2d/gpu_particles_2d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/file_dialog.h"
-class Particles2DEditorPlugin : public EditorPlugin {
+class GPUParticles2DEditorPlugin : public EditorPlugin {
- GDCLASS(Particles2DEditorPlugin, EditorPlugin);
+ GDCLASS(GPUParticles2DEditorPlugin, EditorPlugin);
enum {
@@ -57,7 +57,7 @@ class Particles2DEditorPlugin : public EditorPlugin {
EMISSION_MODE_BORDER_DIRECTED
};
- Particles2D *particles;
+ GPUParticles2D *particles;
EditorFileDialog *file;
EditorNode *editor;
@@ -93,8 +93,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- Particles2DEditorPlugin(EditorNode *p_node);
- ~Particles2DEditorPlugin();
+ GPUParticles2DEditorPlugin(EditorNode *p_node);
+ ~GPUParticles2DEditorPlugin();
};
#endif // PARTICLES_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index a4d704c6e1..655f03b7e0 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles_editor_plugin.cpp */
+/* gpu_particles_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "particles_editor_plugin.h"
+#include "gpu_particles_3d_editor_plugin.h"
#include "core/io/resource_loader.h"
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/3d/cpu_particles.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
+#include "scene/3d/cpu_particles_3d.h"
#include "scene/resources/particles_material.h"
-bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) {
+bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) {
bool use_normals = emission_fill->get_selected() == 1;
@@ -161,26 +161,26 @@ bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &no
return true;
}
-void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
+void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) {
Node *sel = get_node(p_path);
if (!sel)
return;
- if (!sel->is_class("Spatial")) {
+ if (!sel->is_class("Node3D")) {
- EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Spatial."), sel->get_name()));
+ EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Node3D."), sel->get_name()));
return;
}
- VisualInstance *vi = Object::cast_to<VisualInstance>(sel);
+ VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sel);
if (!vi) {
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain geometry."), sel->get_name()));
return;
}
- geometry = vi->get_faces(VisualInstance::FACES_SOLID);
+ geometry = vi->get_faces(VisualInstance3D::FACES_SOLID);
if (geometry.size() == 0) {
@@ -202,10 +202,10 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
emission_dialog->popup_centered(Size2(300, 130));
}
-void ParticlesEditorBase::_bind_methods() {
+void GPUParticles3DEditorBase::_bind_methods() {
}
-ParticlesEditorBase::ParticlesEditorBase() {
+GPUParticles3DEditorBase::GPUParticles3DEditorBase() {
emission_dialog = memnew(ConfirmationDialog);
emission_dialog->set_title(TTR("Create Emitter"));
@@ -226,14 +226,14 @@ ParticlesEditorBase::ParticlesEditorBase() {
emd_vb->add_margin_child(TTR("Emission Source: "), emission_fill);
emission_dialog->get_ok()->set_text(TTR("Create"));
- emission_dialog->connect("confirmed", callable_mp(this, &ParticlesEditorBase::_generate_emission_points));
+ emission_dialog->connect("confirmed", callable_mp(this, &GPUParticles3DEditorBase::_generate_emission_points));
emission_tree_dialog = memnew(SceneTreeDialog);
add_child(emission_tree_dialog);
- emission_tree_dialog->connect("selected", callable_mp(this, &ParticlesEditorBase::_node_selected));
+ emission_tree_dialog->connect("selected", callable_mp(this, &GPUParticles3DEditorBase::_node_selected));
}
-void ParticlesEditor::_node_removed(Node *p_node) {
+void GPUParticles3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@@ -241,15 +241,15 @@ void ParticlesEditor::_node_removed(Node *p_node) {
}
}
-void ParticlesEditor::_notification(int p_notification) {
+void GPUParticles3DEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE) {
- options->set_icon(options->get_popup()->get_icon("Particles", "EditorIcons"));
- get_tree()->connect("node_removed", callable_mp(this, &ParticlesEditor::_node_removed));
+ options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons"));
+ get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed));
}
}
-void ParticlesEditor::_menu_option(int p_option) {
+void GPUParticles3DEditor::_menu_option(int p_option) {
switch (p_option) {
@@ -260,7 +260,7 @@ void ParticlesEditor::_menu_option(int p_option) {
generate_seconds->set_value(1.0);
else
generate_seconds->set_value(trunc(gen_time) + 1.0);
- generate_aabb->popup_centered_minsize();
+ generate_aabb->popup_centered();
} break;
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
Ref<ParticlesMaterial> material = node->get_process_material();
@@ -274,7 +274,7 @@ void ParticlesEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
- CPUParticles *cpu_particles = memnew(CPUParticles);
+ CPUParticles3D *cpu_particles = memnew(CPUParticles3D);
cpu_particles->convert_from_particles(node);
cpu_particles->set_name(node->get_name());
cpu_particles->set_transform(node->get_transform());
@@ -282,7 +282,7 @@ void ParticlesEditor::_menu_option(int p_option) {
cpu_particles->set_pause_mode(node->get_pause_mode());
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action(TTR("Convert to CPUParticles"));
+ ur->create_action(TTR("Convert to CPUParticles3D"));
ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, cpu_particles, true, false);
ur->add_do_reference(cpu_particles);
ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, node, false, false);
@@ -298,7 +298,7 @@ void ParticlesEditor::_menu_option(int p_option) {
}
}
-void ParticlesEditor::_generate_aabb() {
+void GPUParticles3DEditor::_generate_aabb() {
float time = generate_seconds->get_value();
@@ -340,13 +340,13 @@ void ParticlesEditor::_generate_aabb() {
ur->commit_action();
}
-void ParticlesEditor::edit(Particles *p_particles) {
+void GPUParticles3DEditor::edit(GPUParticles3D *p_particles) {
base_node = p_particles;
node = p_particles;
}
-void ParticlesEditor::_generate_emission_points() {
+void GPUParticles3DEditor::_generate_emission_points() {
/// hacer codigo aca
Vector<Vector3> points;
@@ -419,29 +419,29 @@ void ParticlesEditor::_generate_emission_points() {
}
}
-void ParticlesEditor::_bind_methods() {
+void GPUParticles3DEditor::_bind_methods() {
}
-ParticlesEditor::ParticlesEditor() {
+GPUParticles3DEditor::GPUParticles3DEditor() {
node = NULL;
particles_editor_hb = memnew(HBoxContainer);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
options = memnew(MenuButton);
options->set_switch_on_hover(true);
particles_editor_hb->add_child(options);
particles_editor_hb->hide();
- options->set_text(TTR("Particles"));
+ options->set_text(TTR("GPUParticles3D"));
options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
+ options->get_popup()->add_item(TTR("Convert to CPUParticles3D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
- options->get_popup()->connect("id_pressed", callable_mp(this, &ParticlesEditor::_menu_option));
+ options->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles3DEditor::_menu_option));
generate_aabb = memnew(ConfirmationDialog);
generate_aabb->set_title(TTR("Generate Visibility AABB"));
@@ -455,20 +455,20 @@ ParticlesEditor::ParticlesEditor() {
add_child(generate_aabb);
- generate_aabb->connect("confirmed", callable_mp(this, &ParticlesEditor::_generate_aabb));
+ generate_aabb->connect("confirmed", callable_mp(this, &GPUParticles3DEditor::_generate_aabb));
}
-void ParticlesEditorPlugin::edit(Object *p_object) {
+void GPUParticles3DEditorPlugin::edit(Object *p_object) {
- particles_editor->edit(Object::cast_to<Particles>(p_object));
+ particles_editor->edit(Object::cast_to<GPUParticles3D>(p_object));
}
-bool ParticlesEditorPlugin::handles(Object *p_object) const {
+bool GPUParticles3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Particles");
+ return p_object->is_class("GPUParticles3D");
}
-void ParticlesEditorPlugin::make_visible(bool p_visible) {
+void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
particles_editor->show();
@@ -480,14 +480,14 @@ void ParticlesEditorPlugin::make_visible(bool p_visible) {
}
}
-ParticlesEditorPlugin::ParticlesEditorPlugin(EditorNode *p_node) {
+GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- particles_editor = memnew(ParticlesEditor);
+ particles_editor = memnew(GPUParticles3DEditor);
editor->get_viewport()->add_child(particles_editor);
particles_editor->hide();
}
-ParticlesEditorPlugin::~ParticlesEditorPlugin() {
+GPUParticles3DEditorPlugin::~GPUParticles3DEditorPlugin() {
}
diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h
index fb5ce17560..d730457d01 100644
--- a/editor/plugins/particles_editor_plugin.h
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles_editor_plugin.h */
+/* gpu_particles_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,15 +33,15 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/particles.h"
+#include "scene/3d/gpu_particles_3d.h"
#include "scene/gui/spin_box.h"
-class ParticlesEditorBase : public Control {
+class GPUParticles3DEditorBase : public Control {
- GDCLASS(ParticlesEditorBase, Control);
+ GDCLASS(GPUParticles3DEditorBase, Control);
protected:
- Spatial *base_node;
+ Node3D *base_node;
Panel *panel;
MenuButton *options;
HBoxContainer *particles_editor_hb;
@@ -61,16 +61,16 @@ protected:
static void _bind_methods();
public:
- ParticlesEditorBase();
+ GPUParticles3DEditorBase();
};
-class ParticlesEditor : public ParticlesEditorBase {
+class GPUParticles3DEditor : public GPUParticles3DEditorBase {
- GDCLASS(ParticlesEditor, ParticlesEditorBase);
+ GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase);
ConfirmationDialog *generate_aabb;
SpinBox *generate_seconds;
- Particles *node;
+ GPUParticles3D *node;
enum Menu {
@@ -86,7 +86,7 @@ class ParticlesEditor : public ParticlesEditorBase {
void _menu_option(int);
- friend class ParticlesEditorPlugin;
+ friend class GPUParticles3DEditorPlugin;
virtual void _generate_emission_points();
@@ -96,15 +96,15 @@ protected:
static void _bind_methods();
public:
- void edit(Particles *p_particles);
- ParticlesEditor();
+ void edit(GPUParticles3D *p_particles);
+ GPUParticles3DEditor();
};
-class ParticlesEditorPlugin : public EditorPlugin {
+class GPUParticles3DEditorPlugin : public EditorPlugin {
- GDCLASS(ParticlesEditorPlugin, EditorPlugin);
+ GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin);
- ParticlesEditor *particles_editor;
+ GPUParticles3DEditor *particles_editor;
EditorNode *editor;
public:
@@ -114,8 +114,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- ParticlesEditorPlugin(EditorNode *p_node);
- ~ParticlesEditorPlugin();
+ GPUParticles3DEditorPlugin(EditorNode *p_node);
+ ~GPUParticles3DEditorPlugin();
};
#endif // PARTICLES_EDITOR_PLUGIN_H
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index ff03fcf159..54b7840124 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -32,7 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "editor/editor_scale.h"
-#include "spatial_editor_plugin.h"
+#include "node_3d_editor_plugin.h"
Size2 GradientEditor::get_minimum_size() const {
return Size2(0, 60) * EDSCALE;
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index ba640883c7..9ae4d2ae9d 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -264,8 +264,8 @@ void ItemListEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) {
- add_button->set_icon(get_icon("Add", "EditorIcons"));
- del_button->set_icon(get_icon("Remove", "EditorIcons"));
+ add_button->set_icon(get_theme_icon("Add", "EditorIcons"));
+ del_button->set_icon(get_theme_icon("Remove", "EditorIcons"));
} else if (p_notification == NOTIFICATION_READY) {
get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed));
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index d388296927..5623805201 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -44,15 +44,15 @@ void MaterialEditor::_notification(int p_what) {
if (first_enter) {
//it's in propertyeditor so.. could be moved around
- light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1", "EditorIcons"));
- light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons"));
- light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons"));
- light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons"));
+ light_1_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight1", "EditorIcons"));
+ light_1_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight1Off", "EditorIcons"));
+ light_2_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight2", "EditorIcons"));
+ light_2_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight2Off", "EditorIcons"));
- sphere_switch->set_normal_texture(get_icon("MaterialPreviewSphereOff", "EditorIcons"));
- sphere_switch->set_pressed_texture(get_icon("MaterialPreviewSphere", "EditorIcons"));
- box_switch->set_normal_texture(get_icon("MaterialPreviewCubeOff", "EditorIcons"));
- box_switch->set_pressed_texture(get_icon("MaterialPreviewCube", "EditorIcons"));
+ sphere_switch->set_normal_texture(get_theme_icon("MaterialPreviewSphereOff", "EditorIcons"));
+ sphere_switch->set_pressed_texture(get_theme_icon("MaterialPreviewSphere", "EditorIcons"));
+ box_switch->set_normal_texture(get_theme_icon("MaterialPreviewCubeOff", "EditorIcons"));
+ box_switch->set_pressed_texture(get_theme_icon("MaterialPreviewCube", "EditorIcons"));
first_enter = false;
}
@@ -60,7 +60,7 @@ void MaterialEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons");
+ Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
@@ -114,8 +114,8 @@ MaterialEditor::MaterialEditor() {
vc->set_stretch(true);
add_child(vc);
vc->set_anchors_and_margins_preset(PRESET_WIDE);
- viewport = memnew(Viewport);
- Ref<World> world;
+ viewport = memnew(SubViewport);
+ Ref<World3D> world;
world.instance();
viewport->set_world(world); //use own world
vc->add_child(viewport);
@@ -123,25 +123,25 @@ MaterialEditor::MaterialEditor() {
viewport->set_transparent_background(true);
viewport->set_msaa(Viewport::MSAA_4X);
- camera = memnew(Camera);
+ camera = memnew(Camera3D);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 3)));
camera->set_perspective(45, 0.1, 10);
camera->make_current();
viewport->add_child(camera);
- light1 = memnew(DirectionalLight);
+ light1 = memnew(DirectionalLight3D);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
- light2 = memnew(DirectionalLight);
+ light2 = memnew(DirectionalLight3D);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
- sphere_instance = memnew(MeshInstance);
+ sphere_instance = memnew(MeshInstance3D);
viewport->add_child(sphere_instance);
- box_instance = memnew(MeshInstance);
+ box_instance = memnew(MeshInstance3D);
viewport->add_child(box_instance);
Transform box_xform;
@@ -256,14 +256,14 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p
Ref<Shader> shader;
shader.instance();
- String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid());
+ String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
- VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
+ RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
@@ -273,7 +273,7 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p
if (texture.is_valid()) {
smat->set_shader_param(E->get().name, texture);
} else {
- Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
+ Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
smat->set_shader_param(E->get().name, value);
}
}
@@ -302,17 +302,17 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_
Ref<Shader> shader;
shader.instance();
- String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid());
+ String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
- VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
+ RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
+ Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
smat->set_shader_param(E->get().name, value);
}
@@ -340,17 +340,17 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p
Ref<Shader> shader;
shader.instance();
- String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid());
+ String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
- VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
+ RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
+ Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
smat->set_shader_param(E->get().name, value);
}
@@ -378,17 +378,17 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource>
Ref<Shader> shader;
shader.instance();
- String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid());
+ String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
- VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
+ RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
+ Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
smat->set_shader_param(E->get().name, value);
}
@@ -416,17 +416,17 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &
Ref<Shader> shader;
shader.instance();
- String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid());
+ String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
- VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
+ RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
+ Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
smat->set_shader_param(E->get().name, value);
}
@@ -454,17 +454,17 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &
Ref<Shader> shader;
shader.instance();
- String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid());
+ String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid());
shader->set_code(code);
smat->set_shader(shader);
List<PropertyInfo> params;
- VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
+ RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
- Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
+ Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name);
smat->set_shader_param(E->get().name, value);
}
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 84e69425d0..0938e79ca2 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -36,9 +36,9 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/light.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/resources/material.h"
class ViewportContainer;
@@ -48,12 +48,12 @@ class MaterialEditor : public Control {
GDCLASS(MaterialEditor, Control);
ViewportContainer *vc;
- Viewport *viewport;
- MeshInstance *sphere_instance;
- MeshInstance *box_instance;
- DirectionalLight *light1;
- DirectionalLight *light2;
- Camera *camera;
+ SubViewport *viewport;
+ MeshInstance3D *sphere_instance;
+ MeshInstance3D *box_instance;
+ DirectionalLight3D *light1;
+ DirectionalLight3D *light2;
+ Camera3D *camera;
Ref<SphereMesh> sphere_mesh;
Ref<CubeMesh> box_mesh;
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 5a17f0d4f1..a8b455fdd2 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -57,10 +57,10 @@ void MeshEditor::_notification(int p_what) {
if (first_enter) {
//it's in propertyeditor so. could be moved around
- light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1", "EditorIcons"));
- light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons"));
- light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons"));
- light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons"));
+ light_1_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight1", "EditorIcons"));
+ light_1_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight1Off", "EditorIcons"));
+ light_2_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight2", "EditorIcons"));
+ light_2_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight2Off", "EditorIcons"));
first_enter = false;
}
}
@@ -115,31 +115,31 @@ void MeshEditor::_bind_methods() {
MeshEditor::MeshEditor() {
- viewport = memnew(Viewport);
- Ref<World> world;
+ viewport = memnew(SubViewport);
+ Ref<World3D> world;
world.instance();
viewport->set_world(world); //use own world
add_child(viewport);
viewport->set_disable_input(true);
viewport->set_msaa(Viewport::MSAA_2X);
set_stretch(true);
- camera = memnew(Camera);
+ camera = memnew(Camera3D);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
camera->set_perspective(45, 0.1, 10);
viewport->add_child(camera);
- light1 = memnew(DirectionalLight);
+ light1 = memnew(DirectionalLight3D);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
- light2 = memnew(DirectionalLight);
+ light2 = memnew(DirectionalLight3D);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
- rotation = memnew(Spatial);
+ rotation = memnew(Node3D);
viewport->add_child(rotation);
- mesh_instance = memnew(MeshInstance);
+ mesh_instance = memnew(MeshInstance3D);
rotation->add_child(mesh_instance);
set_custom_minimum_size(Size2(1, 150) * EDSCALE);
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 87c4a1776b..59810517d9 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -33,9 +33,9 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/light.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/viewport_container.h"
#include "scene/resources/material.h"
@@ -46,12 +46,12 @@ class MeshEditor : public ViewportContainer {
float rot_x;
float rot_y;
- Viewport *viewport;
- MeshInstance *mesh_instance;
- Spatial *rotation;
- DirectionalLight *light1;
- DirectionalLight *light2;
- Camera *camera;
+ SubViewport *viewport;
+ MeshInstance3D *mesh_instance;
+ Node3D *rotation;
+ DirectionalLight3D *light1;
+ DirectionalLight3D *light2;
+ Camera3D *camera;
Ref<Mesh> mesh;
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index 6025e7dd9d..a4e7b2df08 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* mesh_instance_editor_plugin.cpp */
+/* mesh_instance_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "mesh_instance_editor_plugin.h"
+#include "mesh_instance_3d_editor_plugin.h"
#include "editor/editor_scale.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/navigation_region.h"
-#include "scene/3d/physics_body.h"
+#include "node_3d_editor_plugin.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/navigation_region_3d.h"
+#include "scene/3d/physics_body_3d.h"
#include "scene/gui/box_container.h"
-#include "spatial_editor_plugin.h"
-void MeshInstanceEditor::_node_removed(Node *p_node) {
+void MeshInstance3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@@ -45,17 +45,17 @@ void MeshInstanceEditor::_node_removed(Node *p_node) {
}
}
-void MeshInstanceEditor::edit(MeshInstance *p_mesh) {
+void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) {
node = p_mesh;
}
-void MeshInstanceEditor::_menu_option(int p_option) {
+void MeshInstance3DEditor::_menu_option(int p_option) {
Ref<Mesh> mesh = node->get_mesh();
if (mesh.is_null()) {
err_dialog->set_text(TTR("Mesh is empty!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -68,16 +68,16 @@ void MeshInstanceEditor::_menu_option(int p_option) {
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
- Ref<Shape> shape = mesh->create_trimesh_shape();
+ Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
- StaticBody *body = memnew(StaticBody);
+ StaticBody3D *body = memnew(StaticBody3D);
body->add_child(cshape);
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
@@ -96,7 +96,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- MeshInstance *instance = Object::cast_to<MeshInstance>(E->get());
+ MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get());
if (!instance)
continue;
@@ -104,13 +104,13 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (m.is_null())
continue;
- Ref<Shape> shape = m->create_trimesh_shape();
+ Ref<Shape3D> shape = m->create_trimesh_shape();
if (shape.is_null())
continue;
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
- StaticBody *body = memnew(StaticBody);
+ StaticBody3D *body = memnew(StaticBody3D);
body->add_child(cshape);
Node *owner = instance == get_tree()->get_edited_scene_root() ? instance : instance->get_owner();
@@ -130,15 +130,15 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("This doesn't work on scene root!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- Ref<Shape> shape = mesh->create_trimesh_shape();
+ Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null())
return;
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
Node *owner = node->get_owner();
@@ -158,22 +158,22 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("Can't create a single convex collision shape for the scene root."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- Ref<Shape> shape = mesh->create_convex_shape();
+ Ref<Shape3D> shape = mesh->create_convex_shape();
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a single convex collision shape."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Create Single Convex Shape"));
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
cshape->set_transform(node->get_transform());
@@ -192,15 +192,15 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("Can't create multiple convex collision shapes for the scene root."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- Vector<Ref<Shape>> shapes = mesh->convex_decompose();
+ Vector<Ref<Shape3D>> shapes = mesh->convex_decompose();
if (!shapes.size()) {
err_dialog->set_text(TTR("Couldn't create any collision shapes."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -209,7 +209,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
for (int i = 0; i < shapes.size(); i++) {
- CollisionShape *cshape = memnew(CollisionShape);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shapes[i]);
cshape->set_transform(node->get_transform());
@@ -233,7 +233,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
nmesh->create_from_mesh(mesh);
- NavigationRegion *nmi = memnew(NavigationRegion);
+ NavigationRegion3D *nmi = memnew(NavigationRegion3D);
nmi->set_navigation_mesh(nmesh);
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
@@ -258,14 +258,14 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Ref<ArrayMesh> mesh2 = node->get_mesh();
if (!mesh2.is_valid()) {
err_dialog->set_text(TTR("Contained Mesh is not of type ArrayMesh."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
Error err = mesh2->lightmap_unwrap(node->get_global_transform());
if (err != OK) {
err_dialog->set_text(TTR("UV Unwrap failed, mesh may not be manifold?"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -274,7 +274,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Ref<Mesh> mesh2 = node->get_mesh();
if (!mesh2.is_valid()) {
err_dialog->set_text(TTR("No mesh to debug."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
_create_uv_lines(0);
@@ -283,7 +283,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
Ref<Mesh> mesh2 = node->get_mesh();
if (!mesh2.is_valid()) {
err_dialog->set_text(TTR("No mesh to debug."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
_create_uv_lines(1);
@@ -291,20 +291,20 @@ void MeshInstanceEditor::_menu_option(int p_option) {
}
}
-struct MeshInstanceEditorEdgeSort {
+struct MeshInstance3DEditorEdgeSort {
Vector2 a;
Vector2 b;
- bool operator<(const MeshInstanceEditorEdgeSort &p_b) const {
+ bool operator<(const MeshInstance3DEditorEdgeSort &p_b) const {
if (a == p_b.a)
return b < p_b.b;
else
return a < p_b.a;
}
- MeshInstanceEditorEdgeSort() {}
- MeshInstanceEditorEdgeSort(const Vector2 &p_a, const Vector2 &p_b) {
+ MeshInstance3DEditorEdgeSort() {}
+ MeshInstance3DEditorEdgeSort(const Vector2 &p_a, const Vector2 &p_b) {
if (p_a < p_b) {
a = p_a;
b = p_b;
@@ -315,12 +315,12 @@ struct MeshInstanceEditorEdgeSort {
}
};
-void MeshInstanceEditor::_create_uv_lines(int p_layer) {
+void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
Ref<Mesh> mesh = node->get_mesh();
ERR_FAIL_COND(!mesh.is_valid());
- Set<MeshInstanceEditorEdgeSort> edges;
+ Set<MeshInstance3DEditorEdgeSort> edges;
uv_lines.clear();
for (int i = 0; i < mesh->get_surface_count(); i++) {
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
@@ -330,7 +330,7 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) {
Vector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2];
if (uv.size() == 0) {
err_dialog->set_text(TTR("Model has no UV in this layer"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -355,7 +355,7 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) {
for (int k = 0; k < 3; k++) {
- MeshInstanceEditorEdgeSort edge;
+ MeshInstance3DEditorEdgeSort edge;
if (use_indices) {
edge.a = r[ri[j + k]];
edge.b = r[ri[j + ((k + 1) % 3)]];
@@ -374,10 +374,10 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) {
}
}
- debug_uv_dialog->popup_centered_minsize();
+ debug_uv_dialog->popup_centered();
}
-void MeshInstanceEditor::_debug_uv_draw() {
+void MeshInstance3DEditor::_debug_uv_draw() {
if (uv_lines.size() == 0)
return;
@@ -388,22 +388,22 @@ void MeshInstanceEditor::_debug_uv_draw() {
debug_uv->draw_multiline(uv_lines, Color(1.0, 0.8, 0.7));
}
-void MeshInstanceEditor::_create_outline_mesh() {
+void MeshInstance3DEditor::_create_outline_mesh() {
Ref<Mesh> mesh = node->get_mesh();
if (mesh.is_null()) {
err_dialog->set_text(TTR("MeshInstance lacks a Mesh!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
if (mesh->get_surface_count() == 0) {
err_dialog->set_text(TTR("Mesh has not surface to create outlines from!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
} else if (mesh->get_surface_count() == 1 && mesh->surface_get_primitive_type(0) != Mesh::PRIMITIVE_TRIANGLES) {
err_dialog->set_text(TTR("Mesh primitive type is not PRIMITIVE_TRIANGLES!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -411,11 +411,11 @@ void MeshInstanceEditor::_create_outline_mesh() {
if (mesho.is_null()) {
err_dialog->set_text(TTR("Could not create outline!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- MeshInstance *mi = memnew(MeshInstance);
+ MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(mesho);
Node *owner = node->get_owner();
if (get_tree()->get_edited_scene_root() == node) {
@@ -434,17 +434,17 @@ void MeshInstanceEditor::_create_outline_mesh() {
ur->commit_action();
}
-void MeshInstanceEditor::_bind_methods() {
+void MeshInstance3DEditor::_bind_methods() {
}
-MeshInstanceEditor::MeshInstanceEditor() {
+MeshInstance3DEditor::MeshInstance3DEditor() {
options = memnew(MenuButton);
options->set_switch_on_hover(true);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text(TTR("Mesh"));
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance", "EditorIcons"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance3D", "EditorIcons"));
options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection."));
@@ -459,13 +459,13 @@ MeshInstanceEditor::MeshInstanceEditor() {
options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH);
- options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible."));
+ options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the StandardMaterial Grow property when using that property isn't possible."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1);
options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2);
options->get_popup()->add_item(TTR("Unwrap UV2 for Lightmap/AO"), MENU_OPTION_CREATE_UV2);
- options->get_popup()->connect("id_pressed", callable_mp(this, &MeshInstanceEditor::_menu_option));
+ options->get_popup()->connect("id_pressed", callable_mp(this, &MeshInstance3DEditor::_menu_option));
outline_dialog = memnew(ConfirmationDialog);
outline_dialog->set_title(TTR("Create Outline Mesh"));
@@ -483,7 +483,7 @@ MeshInstanceEditor::MeshInstanceEditor() {
outline_dialog_vbc->add_margin_child(TTR("Outline Size:"), outline_size);
add_child(outline_dialog);
- outline_dialog->connect("confirmed", callable_mp(this, &MeshInstanceEditor::_create_outline_mesh));
+ outline_dialog->connect("confirmed", callable_mp(this, &MeshInstance3DEditor::_create_outline_mesh));
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@@ -493,21 +493,21 @@ MeshInstanceEditor::MeshInstanceEditor() {
add_child(debug_uv_dialog);
debug_uv = memnew(Control);
debug_uv->set_custom_minimum_size(Size2(600, 600) * EDSCALE);
- debug_uv->connect("draw", callable_mp(this, &MeshInstanceEditor::_debug_uv_draw));
+ debug_uv->connect("draw", callable_mp(this, &MeshInstance3DEditor::_debug_uv_draw));
debug_uv_dialog->add_child(debug_uv);
}
-void MeshInstanceEditorPlugin::edit(Object *p_object) {
+void MeshInstance3DEditorPlugin::edit(Object *p_object) {
- mesh_editor->edit(Object::cast_to<MeshInstance>(p_object));
+ mesh_editor->edit(Object::cast_to<MeshInstance3D>(p_object));
}
-bool MeshInstanceEditorPlugin::handles(Object *p_object) const {
+bool MeshInstance3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("MeshInstance");
+ return p_object->is_class("MeshInstance3D");
}
-void MeshInstanceEditorPlugin::make_visible(bool p_visible) {
+void MeshInstance3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
mesh_editor->options->show();
@@ -518,14 +518,14 @@ void MeshInstanceEditorPlugin::make_visible(bool p_visible) {
}
}
-MeshInstanceEditorPlugin::MeshInstanceEditorPlugin(EditorNode *p_node) {
+MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- mesh_editor = memnew(MeshInstanceEditor);
+ mesh_editor = memnew(MeshInstance3DEditor);
editor->get_viewport()->add_child(mesh_editor);
mesh_editor->options->hide();
}
-MeshInstanceEditorPlugin::~MeshInstanceEditorPlugin() {
+MeshInstance3DEditorPlugin::~MeshInstance3DEditorPlugin() {
}
diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h
index 5ca9aa3fec..a5d90c42d5 100644
--- a/editor/plugins/mesh_instance_editor_plugin.h
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* mesh_instance_editor_plugin.h */
+/* mesh_instance_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/spin_box.h"
-class MeshInstanceEditor : public Control {
+class MeshInstance3DEditor : public Control {
- GDCLASS(MeshInstanceEditor, Control);
+ GDCLASS(MeshInstance3DEditor, Control);
enum Menu {
@@ -53,7 +53,7 @@ class MeshInstanceEditor : public Control {
MENU_OPTION_DEBUG_UV2,
};
- MeshInstance *node;
+ MeshInstance3D *node;
MenuButton *options;
@@ -70,7 +70,7 @@ class MeshInstanceEditor : public Control {
void _create_outline_mesh();
void _create_uv_lines(int p_layer);
- friend class MeshInstanceEditorPlugin;
+ friend class MeshInstance3DEditorPlugin;
void _debug_uv_draw();
@@ -79,26 +79,26 @@ protected:
static void _bind_methods();
public:
- void edit(MeshInstance *p_mesh);
- MeshInstanceEditor();
+ void edit(MeshInstance3D *p_mesh);
+ MeshInstance3DEditor();
};
-class MeshInstanceEditorPlugin : public EditorPlugin {
+class MeshInstance3DEditorPlugin : public EditorPlugin {
- GDCLASS(MeshInstanceEditorPlugin, EditorPlugin);
+ GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin);
- MeshInstanceEditor *mesh_editor;
+ MeshInstance3DEditor *mesh_editor;
EditorNode *editor;
public:
- virtual String get_name() const { return "MeshInstance"; }
+ virtual String get_name() const { return "MeshInstance3D"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- MeshInstanceEditorPlugin(EditorNode *p_node);
- ~MeshInstanceEditorPlugin();
+ MeshInstance3DEditorPlugin(EditorNode *p_node);
+ ~MeshInstance3DEditorPlugin();
};
#endif // MESH_EDITOR_PLUGIN_H
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index 4e63a498b8..a3e3d88ae2 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "main/main.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/navigation_region.h"
-#include "scene/3d/physics_body.h"
-#include "scene/main/viewport.h"
+#include "node_3d_editor_plugin.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/navigation_region_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
-#include "spatial_editor_plugin.h"
void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_mesh_library) {
@@ -71,16 +71,16 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
if (!p_merge)
p_library->clear();
- Map<int, MeshInstance *> mesh_instances;
+ Map<int, MeshInstance3D *> mesh_instances;
for (int i = 0; i < p_scene->get_child_count(); i++) {
Node *child = p_scene->get_child(i);
- if (!Object::cast_to<MeshInstance>(child)) {
+ if (!Object::cast_to<MeshInstance3D>(child)) {
if (child->get_child_count() > 0) {
child = child->get_child(0);
- if (!Object::cast_to<MeshInstance>(child)) {
+ if (!Object::cast_to<MeshInstance3D>(child)) {
continue;
}
@@ -88,7 +88,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue;
}
- MeshInstance *mi = Object::cast_to<MeshInstance>(child);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(child);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_null())
continue;
@@ -118,10 +118,10 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
- if (!Object::cast_to<StaticBody>(child2))
+ if (!Object::cast_to<StaticBody3D>(child2))
continue;
- StaticBody *sb = Object::cast_to<StaticBody>(child2);
+ StaticBody3D *sb = Object::cast_to<StaticBody3D>(child2);
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
@@ -135,7 +135,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
- Ref<Shape> collision = sb->shape_owner_get_shape(E->get(), k);
+ Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k);
if (!collision.is_valid())
continue;
MeshLibrary::ShapeData shape_data;
@@ -152,9 +152,9 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Transform navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
- if (!Object::cast_to<NavigationRegion>(child2))
+ if (!Object::cast_to<NavigationRegion3D>(child2))
continue;
- NavigationRegion *sb = Object::cast_to<NavigationRegion>(child2);
+ NavigationRegion3D *sb = Object::cast_to<NavigationRegion3D>(child2);
navmesh = sb->get_navigation_mesh();
navmesh_transform = sb->get_transform();
if (!navmesh.is_null())
@@ -253,7 +253,7 @@ void MeshLibraryEditor::_bind_methods() {
MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
file = memnew(EditorFileDialog);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
//not for now?
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
@@ -267,10 +267,10 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
file->connect("file_selected", callable_mp(this, &MeshLibraryEditor::_import_scene_cbk));
menu = memnew(MenuButton);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(menu);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(menu);
menu->set_position(Point2(1, 1));
menu->set_text(TTR("Mesh Library"));
- menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshLibrary", "EditorIcons"));
+ menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshLibrary", "EditorIcons"));
menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM);
menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM);
menu->get_popup()->add_separator();
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index 27d400c035..658e3ea565 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -30,9 +30,9 @@
#include "multimesh_editor_plugin.h"
-#include "scene/3d/mesh_instance.h"
+#include "node_3d_editor_plugin.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h"
-#include "spatial_editor_plugin.h"
void MultiMeshEditor::_node_removed(Node *p_node) {
@@ -56,13 +56,13 @@ void MultiMeshEditor::_populate() {
if (multimesh.is_null()) {
err_dialog->set_text(TTR("No mesh source specified (and no MultiMesh set in node)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
if (multimesh->get_mesh().is_null()) {
err_dialog->set_text(TTR("No mesh source specified (and MultiMesh contains no Mesh)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -74,16 +74,16 @@ void MultiMeshEditor::_populate() {
if (!ms_node) {
err_dialog->set_text(TTR("Mesh source is invalid (invalid path)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- MeshInstance *ms_instance = Object::cast_to<MeshInstance>(ms_node);
+ MeshInstance3D *ms_instance = Object::cast_to<MeshInstance3D>(ms_node);
if (!ms_instance) {
err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -92,7 +92,7 @@ void MultiMeshEditor::_populate() {
if (mesh.is_null()) {
err_dialog->set_text(TTR("Mesh source is invalid (contains no Mesh resource)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
}
@@ -100,7 +100,7 @@ void MultiMeshEditor::_populate() {
if (surface_source->get_text() == "") {
err_dialog->set_text(TTR("No surface source specified."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -109,27 +109,27 @@ void MultiMeshEditor::_populate() {
if (!ss_node) {
err_dialog->set_text(TTR("Surface source is invalid (invalid path)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
- GeometryInstance *ss_instance = Object::cast_to<MeshInstance>(ss_node);
+ GeometryInstance3D *ss_instance = Object::cast_to<MeshInstance3D>(ss_node);
if (!ss_instance) {
err_dialog->set_text(TTR("Surface source is invalid (no geometry)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
Transform geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform();
- Vector<Face3> geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID);
+ Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID);
if (geometry.size() == 0) {
err_dialog->set_text(TTR("Surface source is invalid (no faces)."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -261,7 +261,7 @@ void MultiMeshEditor::_menu_option(int p_option) {
}
}
-void MultiMeshEditor::edit(MultiMeshInstance *p_multimesh) {
+void MultiMeshEditor::edit(MultiMeshInstance3D *p_multimesh) {
node = p_multimesh;
}
@@ -284,10 +284,10 @@ MultiMeshEditor::MultiMeshEditor() {
options = memnew(MenuButton);
options->set_switch_on_hover(true);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text("MultiMesh");
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance", "EditorIcons"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MultiMeshInstance3D", "EditorIcons"));
options->get_popup()->add_item(TTR("Populate Surface"));
options->get_popup()->connect("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option));
@@ -379,12 +379,12 @@ MultiMeshEditor::MultiMeshEditor() {
void MultiMeshEditorPlugin::edit(Object *p_object) {
- multimesh_editor->edit(Object::cast_to<MultiMeshInstance>(p_object));
+ multimesh_editor->edit(Object::cast_to<MultiMeshInstance3D>(p_object));
}
bool MultiMeshEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("MultiMeshInstance");
+ return p_object->is_class("MultiMeshInstance3D");
}
void MultiMeshEditorPlugin::make_visible(bool p_visible) {
diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h
index 2c7b98cfbc..15c9b91fee 100644
--- a/editor/plugins/multimesh_editor_plugin.h
+++ b/editor/plugins/multimesh_editor_plugin.h
@@ -33,7 +33,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/multimesh_instance.h"
+#include "scene/3d/multimesh_instance_3d.h"
#include "scene/gui/spin_box.h"
class MultiMeshEditor : public Control {
@@ -44,11 +44,11 @@ class MultiMeshEditor : public Control {
AcceptDialog *err_dialog;
MenuButton *options;
- MultiMeshInstance *_last_pp_node;
+ MultiMeshInstance3D *_last_pp_node;
bool browsing_source;
Panel *panel;
- MultiMeshInstance *node;
+ MultiMeshInstance3D *node;
LineEdit *surface_source;
LineEdit *mesh_source;
@@ -78,7 +78,7 @@ protected:
static void _bind_methods();
public:
- void edit(MultiMeshInstance *p_multimesh);
+ void edit(MultiMeshInstance3D *p_multimesh);
MultiMeshEditor();
};
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 10f8cbc0a5..0bc35e2498 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -32,7 +32,7 @@
#define NAVIGATIONPOLYGONEDITORPLUGIN_H
#include "editor/plugins/abstract_polygon_2d_editor.h"
-#include "scene/2d/navigation_polygon.h"
+#include "scene/2d/navigation_region_2d.h"
class NavigationPolygonEditor : public AbstractPolygon2DEditor {
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 2f1274a99a..6f6d06b09d 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial_editor_plugin.cpp */
+/* node_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "spatial_editor_plugin.h"
+#include "node_3d_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/math/camera_matrix.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/project_settings.h"
@@ -40,17 +40,18 @@
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/node_3d_editor_gizmos.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "editor/spatial_editor_gizmos.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/physics_body.h"
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/gui/viewport_container.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"
+#include "servers/display_server.h"
#define DISTANCE_DEFAULT 4
@@ -80,17 +81,17 @@ void ViewportRotationControl::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
axis_menu_options.clear();
- axis_menu_options.push_back(SpatialEditorViewport::VIEW_RIGHT);
- axis_menu_options.push_back(SpatialEditorViewport::VIEW_TOP);
- axis_menu_options.push_back(SpatialEditorViewport::VIEW_FRONT);
- axis_menu_options.push_back(SpatialEditorViewport::VIEW_LEFT);
- axis_menu_options.push_back(SpatialEditorViewport::VIEW_BOTTOM);
- axis_menu_options.push_back(SpatialEditorViewport::VIEW_REAR);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_TOP);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_LEFT);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_BOTTOM);
+ axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR);
axis_colors.clear();
- axis_colors.push_back(get_color("axis_x_color", "Editor"));
- axis_colors.push_back(get_color("axis_y_color", "Editor"));
- axis_colors.push_back(get_color("axis_z_color", "Editor"));
+ axis_colors.push_back(get_theme_color("axis_x_color", "Editor"));
+ axis_colors.push_back(get_theme_color("axis_y_color", "Editor"));
+ axis_colors.push_back(get_theme_color("axis_z_color", "Editor"));
update();
if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) {
@@ -139,7 +140,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {
if (front) {
String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z");
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c);
- draw_char(get_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", Color(0.3, 0.3, 0.3));
+ draw_char(get_theme_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", Color(0.3, 0.3, 0.3));
} else {
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS * (0.55 + (0.2 * (1.0 + p_axis.z_axis))), c);
}
@@ -238,7 +239,7 @@ void ViewportRotationControl::_on_mouse_exited() {
update();
}
-void ViewportRotationControl::set_viewport(SpatialEditorViewport *p_viewport) {
+void ViewportRotationControl::set_viewport(Node3DEditorViewport *p_viewport) {
viewport = p_viewport;
}
@@ -246,9 +247,9 @@ void ViewportRotationControl::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ViewportRotationControl::_gui_input);
}
-void SpatialEditorViewport::_update_camera(float p_interp_delta) {
+void Node3DEditorViewport::_update_camera(float p_interp_delta) {
- bool is_orthogonal = camera->get_projection() == Camera::PROJECTION_ORTHOGONAL;
+ bool is_orthogonal = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL;
Cursor old_camera_cursor = camera_cursor;
camera_cursor = cursor;
@@ -297,10 +298,10 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) {
float zoom_inertia = EDITOR_GET("editors/3d/navigation_feel/zoom_inertia");
//determine if being manipulated
- bool manipulated = Input::get_singleton()->get_mouse_button_mask() & (2 | 4);
- manipulated |= Input::get_singleton()->is_key_pressed(KEY_SHIFT);
- manipulated |= Input::get_singleton()->is_key_pressed(KEY_ALT);
- manipulated |= Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool manipulated = InputFilter::get_singleton()->get_mouse_button_mask() & (2 | 4);
+ manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
+ manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_ALT);
+ manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
float orbit_inertia = MAX(0.00001, manipulated ? manip_orbit_inertia : free_orbit_inertia);
float translation_inertia = MAX(0.0001, manipulated ? manip_translation_inertia : free_translation_inertia);
@@ -356,7 +357,7 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) {
}
}
-Transform SpatialEditorViewport::to_camera_transform(const Cursor &p_cursor) const {
+Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const {
Transform camera_transform;
camera_transform.translate(p_cursor.pos);
camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot);
@@ -370,7 +371,7 @@ Transform SpatialEditorViewport::to_camera_transform(const Cursor &p_cursor) con
return camera_transform;
}
-int SpatialEditorViewport::get_selected_count() const {
+int Node3DEditorViewport::get_selected_count() const {
Map<Node *, Object *> &selection = editor_selection->get_selection();
@@ -378,11 +379,11 @@ int SpatialEditorViewport::get_selected_count() const {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->key());
+ Node3D *sp = Object::cast_to<Node3D>(E->key());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -392,68 +393,68 @@ int SpatialEditorViewport::get_selected_count() const {
return count;
}
-float SpatialEditorViewport::get_znear() const {
+float Node3DEditorViewport::get_znear() const {
return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z);
}
-float SpatialEditorViewport::get_zfar() const {
+float Node3DEditorViewport::get_zfar() const {
return CLAMP(spatial_editor->get_zfar(), MIN_Z, MAX_Z);
}
-float SpatialEditorViewport::get_fov() const {
+float Node3DEditorViewport::get_fov() const {
return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV);
}
-Transform SpatialEditorViewport::_get_camera_transform() const {
+Transform Node3DEditorViewport::_get_camera_transform() const {
return camera->get_global_transform();
}
-Vector3 SpatialEditorViewport::_get_camera_position() const {
+Vector3 Node3DEditorViewport::_get_camera_position() const {
return _get_camera_transform().origin;
}
-Point2 SpatialEditorViewport::_point_to_screen(const Vector3 &p_point) {
+Point2 Node3DEditorViewport::_point_to_screen(const Vector3 &p_point) {
return camera->unproject_position(p_point) * viewport_container->get_stretch_shrink();
}
-Vector3 SpatialEditorViewport::_get_ray_pos(const Vector2 &p_pos) const {
+Vector3 Node3DEditorViewport::_get_ray_pos(const Vector2 &p_pos) const {
return camera->project_ray_origin(p_pos / viewport_container->get_stretch_shrink());
}
-Vector3 SpatialEditorViewport::_get_camera_normal() const {
+Vector3 Node3DEditorViewport::_get_camera_normal() const {
return -_get_camera_transform().basis.get_axis(2);
}
-Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) const {
+Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const {
return camera->project_ray_normal(p_pos / viewport_container->get_stretch_shrink());
}
-void SpatialEditorViewport::_clear_selected() {
+void Node3DEditorViewport::_clear_selected() {
editor_selection->clear();
}
-void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) {
+void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) {
if (clicked.is_null())
return;
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked));
- Spatial *selected = Object::cast_to<Spatial>(node);
+ Node3D *selected = Object::cast_to<Node3D>(node);
if (!selected)
return;
if (!p_allow_locked) {
// Replace the node by the group if grouped
while (node && node != editor->get_edited_scene()->get_parent()) {
- Spatial *selected_tmp = Object::cast_to<Spatial>(node);
+ Node3D *selected_tmp = Object::cast_to<Node3D>(node);
if (selected_tmp && node->has_meta("_edit_group_")) {
selected = selected_tmp;
}
@@ -466,7 +467,7 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p
}
}
-void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single) {
+void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) {
if (!p_append) {
editor_selection->clear();
@@ -486,7 +487,7 @@ void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single)
}
}
-ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) {
+ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) {
if (r_gizmo_handle)
*r_gizmo_handle = -1;
@@ -495,8 +496,8 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Vector3 pos = _get_ray_pos(p_pos);
Vector2 shrinked_pos = p_pos / viewport_container->get_stretch_shrink();
- Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
- Set<Ref<EditorSpatialGizmo>> found_gizmos;
+ Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
+ Set<Ref<EditorNode3DGizmo>> found_gizmos;
Node *edited_scene = get_tree()->get_edited_scene_root();
ObjectID closest;
@@ -506,12 +507,12 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
for (int i = 0; i < instances.size(); i++) {
- Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
+ Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i]));
if (!spat)
continue;
- Ref<EditorSpatialGizmo> seg = spat->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = spat->get_gizmo();
if ((!seg.is_valid()) || found_gizmos.has(seg)) {
continue;
@@ -557,24 +558,24 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
return closest;
}
-void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) {
+void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) {
Vector3 ray = _get_ray(p_pos);
Vector3 pos = _get_ray_pos(p_pos);
- Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
- Set<Ref<EditorSpatialGizmo>> found_gizmos;
+ Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
+ Set<Ref<EditorNode3DGizmo>> found_gizmos;
r_includes_current = false;
for (int i = 0; i < instances.size(); i++) {
- Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
+ Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i]));
if (!spat)
continue;
- Ref<EditorSpatialGizmo> seg = spat->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = spat->get_gizmo();
if (!seg.is_valid())
continue;
@@ -613,7 +614,7 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_incl
results.sort();
}
-Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
+Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
CameraMatrix cm;
if (orthogonal) {
@@ -632,7 +633,7 @@ Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
return camera_transform.xform(Vector3(((p_vector3.x / get_size().width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (p_vector3.y / get_size().height)) * 2.0 - 1.0) * screen_he.y, -(get_znear() + p_vector3.z)));
}
-void SpatialEditorViewport::_select_region() {
+void Node3DEditorViewport::_select_region() {
if (cursor.region_begin == cursor.region_end)
return; //nothing really
@@ -685,14 +686,14 @@ void SpatialEditorViewport::_select_region() {
frustum.push_back(far);
}
- Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario());
+ Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario());
Vector<Node *> selected;
Node *edited_scene = get_tree()->get_edited_scene_root();
for (int i = 0; i < instances.size(); i++) {
- Spatial *sp = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
+ Node3D *sp = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i]));
if (!sp || _is_node_locked(sp))
continue;
@@ -702,10 +703,10 @@ void SpatialEditorViewport::_select_region() {
}
// Replace the node by the group if grouped
- if (item->is_class("Spatial")) {
- Spatial *sel = Object::cast_to<Spatial>(item);
+ if (item->is_class("Node3D")) {
+ Node3D *sel = Object::cast_to<Node3D>(item);
while (item && item != editor->get_edited_scene()->get_parent()) {
- Spatial *selected_tmp = Object::cast_to<Spatial>(item);
+ Node3D *selected_tmp = Object::cast_to<Node3D>(item);
if (selected_tmp && item->has_meta("_edit_group_")) {
sel = selected_tmp;
}
@@ -718,7 +719,7 @@ void SpatialEditorViewport::_select_region() {
if (_is_node_locked(item)) continue;
- Ref<EditorSpatialGizmo> seg = sp->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = sp->get_gizmo();
if (!seg.is_valid())
continue;
@@ -734,7 +735,7 @@ void SpatialEditorViewport::_select_region() {
}
}
-void SpatialEditorViewport::_update_name() {
+void Node3DEditorViewport::_update_name() {
String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective");
@@ -750,7 +751,7 @@ void SpatialEditorViewport::_update_name() {
view_menu->set_size(Vector2(0, 0)); // resets the button size
}
-void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
+void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
_edit.click_ray = _get_ray(Vector2(p_point.x, p_point.y));
_edit.click_ray_pos = _get_ray_pos(Vector2(p_point.x, p_point.y));
@@ -762,11 +763,11 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -800,7 +801,7 @@ static int _get_key_modifier(Ref<InputEventWithModifiers> e) {
return 0;
}
-bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {
+bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {
if (!spatial_editor->is_gizmo_visible())
return false;
@@ -816,7 +817,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig
Transform gt = spatial_editor->get_gizmo_transform();
float gs = gizmo_scale;
- if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE) {
+ if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
int col_axis = -1;
float col_d = 1e20;
@@ -885,7 +886,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig
}
}
- if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
+ if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
int col_axis = -1;
float col_d = 1e20;
@@ -924,7 +925,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig
}
}
- if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE) {
+ if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
int col_axis = -1;
float col_d = 1e20;
@@ -999,37 +1000,37 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig
return false;
}
-void SpatialEditorViewport::_surface_mouse_enter() {
+void Node3DEditorViewport::_surface_mouse_enter() {
if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
surface->grab_focus();
}
-void SpatialEditorViewport::_surface_mouse_exit() {
+void Node3DEditorViewport::_surface_mouse_exit() {
_remove_preview();
}
-void SpatialEditorViewport::_surface_focus_enter() {
+void Node3DEditorViewport::_surface_focus_enter() {
view_menu->set_disable_shortcuts(false);
}
-void SpatialEditorViewport::_surface_focus_exit() {
+void Node3DEditorViewport::_surface_focus_exit() {
view_menu->set_disable_shortcuts(true);
}
-bool SpatialEditorViewport ::_is_node_locked(const Node *p_node) {
+bool Node3DEditorViewport ::_is_node_locked(const Node *p_node) {
return p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_");
}
-void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
+void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
_find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->get_shift());
Node *scene = editor->get_edited_scene();
for (int i = 0; i < selection_results.size(); i++) {
- Spatial *item = selection_results[i].item;
+ Node3D *item = selection_results[i].item;
if (item != scene && item->get_owner() != scene && !scene->is_editable_instance(item->get_owner())) {
//invalid result
selection_results.remove(i);
@@ -1045,7 +1046,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
selection_results.clear();
if (clicked.is_valid()) {
- _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
+ _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != Node3DEditor::TOOL_MODE_LIST_SELECT);
clicked = ObjectID();
}
@@ -1056,7 +1057,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
for (int i = 0; i < selection_results.size(); i++) {
- Spatial *spat = selection_results[i].item;
+ Node3D *spat = selection_results[i].item;
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
@@ -1070,7 +1071,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
Node *node = spat;
while (node && node != ed_scene->get_parent()) {
- Spatial *selected_tmp = Object::cast_to<Spatial>(node);
+ Node3D *selected_tmp = Object::cast_to<Node3D>(node);
if (selected_tmp && node->has_meta("_edit_group_")) {
locked = 2;
}
@@ -1090,12 +1091,12 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_class() + "\nPath: " + node_path);
}
- selection_menu->set_global_position(b->get_global_position());
+ selection_menu->set_position(get_screen_transform().xform(b->get_position()));
selection_menu->popup();
}
}
-void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
+void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (previewing)
return; //do NONE
@@ -1148,7 +1149,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (b->is_pressed() && _edit.gizmo.is_valid()) {
//restore
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, true);
- _edit.gizmo = Ref<EditorSpatialGizmo>();
+ _edit.gizmo = Ref<EditorNode3DGizmo>();
}
if (_edit.mode == TRANSFORM_NONE && b->is_pressed()) {
@@ -1171,11 +1172,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -1250,7 +1251,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
break;
}
- if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_LIST_SELECT) {
+ if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_LIST_SELECT) {
_list_select(b);
break;
}
@@ -1270,7 +1271,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (can_select_gizmos && spatial_editor->get_selected()) {
- Ref<EditorSpatialGizmo> seg = spatial_editor->get_selected()->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo();
if (seg.is_valid()) {
int handle = -1;
Vector3 point;
@@ -1292,7 +1293,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked = ObjectID();
clicked_includes_current = false;
- if ((spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
+ if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
/* HANDLE ROTATION */
if (get_selected_count() == 0)
@@ -1303,7 +1304,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
break;
}
- if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE) {
+ if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
if (get_selected_count() == 0)
break; //bye
@@ -1313,7 +1314,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
break;
}
- if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE) {
+ if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
if (get_selected_count() == 0)
break; //bye
@@ -1346,10 +1347,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (clicked.is_valid() && gizmo_handle >= 0) {
- Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked));
+ Node3D *spa = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked));
if (spa) {
- Ref<EditorSpatialGizmo> seg = spa->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = spa->get_gizmo();
if (seg.is_valid()) {
_edit.gizmo = seg;
@@ -1366,7 +1367,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (_edit.gizmo.is_valid()) {
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, false);
- _edit.gizmo = Ref<EditorSpatialGizmo>();
+ _edit.gizmo = Ref<EditorNode3DGizmo>();
break;
}
if (clicked.is_valid()) {
@@ -1393,11 +1394,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -1424,7 +1425,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (spatial_editor->get_selected()) {
- Ref<EditorSpatialGizmo> seg = spatial_editor->get_selected()->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo();
if (seg.is_valid()) {
int selected_handle = -1;
@@ -1592,12 +1593,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp) {
continue;
}
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se) {
continue;
}
@@ -1717,12 +1718,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp) {
continue;
}
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se) {
continue;
}
@@ -1815,11 +1816,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -2053,7 +2054,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
@@ -2082,7 +2083,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
accept_event();
}
-void SpatialEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
+void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
@@ -2102,7 +2103,7 @@ void SpatialEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const
cursor.pos = camera_transform.origin;
}
-void SpatialEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
+void Node3DEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
@@ -2125,7 +2126,7 @@ void SpatialEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, cons
}
}
-void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
+void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
if (lock_rotation) {
_nav_pan(p_event, p_relative);
@@ -2154,7 +2155,7 @@ void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, con
_update_name();
}
-void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
+void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
if (orthogonal) {
_nav_pan(p_event, p_relative);
@@ -2194,7 +2195,7 @@ void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, cons
_update_name();
}
-void SpatialEditorViewport::set_freelook_active(bool active_now) {
+void Node3DEditorViewport::set_freelook_active(bool active_now) {
if (!freelook_active && active_now) {
// Sync camera cursor to cursor to "cut" interpolation jumps due to changing referential
@@ -2213,20 +2214,20 @@ void SpatialEditorViewport::set_freelook_active(bool active_now) {
}
// Hide mouse like in an FPS (warping doesn't work)
- OS::get_singleton()->set_mouse_mode(OS::MOUSE_MODE_CAPTURED);
+ DisplayServer::get_singleton()->mouse_set_mode(DisplayServer::MOUSE_MODE_CAPTURED);
} else if (freelook_active && !active_now) {
// Sync camera cursor to cursor to "cut" interpolation jumps due to changing referential
cursor = camera_cursor;
// Restore mouse
- OS::get_singleton()->set_mouse_mode(OS::MOUSE_MODE_VISIBLE);
+ DisplayServer::get_singleton()->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
}
freelook_active = active_now;
}
-void SpatialEditorViewport::scale_cursor_distance(real_t scale) {
+void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
// Prevents zero distance which would short-circuit any scaling
if (cursor.distance < ZOOM_MIN_DISTANCE)
@@ -2241,7 +2242,7 @@ void SpatialEditorViewport::scale_cursor_distance(real_t scale) {
surface->update();
}
-void SpatialEditorViewport::scale_freelook_speed(real_t scale) {
+void Node3DEditorViewport::scale_freelook_speed(real_t scale) {
// Prevents zero distance which would short-circuit any scaling
if (freelook_speed < FREELOOK_MIN_SPEED)
@@ -2256,10 +2257,10 @@ void SpatialEditorViewport::scale_freelook_speed(real_t scale) {
surface->update();
}
-Point2i SpatialEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const {
+Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const {
Point2i relative;
if (bool(EDITOR_DEF("editors/3d/navigation/warped_mouse_panning", false))) {
- relative = Input::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect());
+ relative = InputFilter::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect());
} else {
relative = p_ev_mouse_motion->get_relative();
}
@@ -2275,12 +2276,12 @@ static bool is_shortcut_pressed(const String &p_path) {
if (k == NULL) {
return false;
}
- const Input &input = *Input::get_singleton();
+ const InputFilter &input = *InputFilter::get_singleton();
int keycode = k->get_keycode();
return input.is_key_pressed(keycode);
}
-void SpatialEditorViewport::_update_freelook(real_t delta) {
+void Node3DEditorViewport::_update_freelook(real_t delta) {
if (!is_freelook_active()) {
return;
@@ -2325,22 +2326,22 @@ void SpatialEditorViewport::_update_freelook(real_t delta) {
cursor.eye_pos += motion;
}
-void SpatialEditorViewport::set_message(String p_message, float p_time) {
+void Node3DEditorViewport::set_message(String p_message, float p_time) {
message = p_message;
message_time = p_time;
}
-void SpatialEditorPlugin::edited_scene_changed() {
- for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
- SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(i);
+void Node3DEditorPlugin::edited_scene_changed() {
+ for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
+ Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(i);
if (viewport->is_visible()) {
viewport->notification(Control::NOTIFICATION_VISIBILITY_CHANGED);
}
}
}
-void SpatialEditorViewport::_notification(int p_what) {
+void Node3DEditorViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -2366,7 +2367,7 @@ void SpatialEditorViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
// The crosshair icon doesn't depend on the editor theme.
- crosshair->set_texture(get_icon("Crosshair", "EditorIcons"));
+ crosshair->set_texture(get_theme_icon("Crosshair", "EditorIcons"));
// Set the anchors and margins after changing the icon to ensure it's centered correctly.
crosshair->set_anchors_and_margins_preset(PRESET_CENTER);
}
@@ -2386,15 +2387,15 @@ void SpatialEditorViewport::_notification(int p_what) {
Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root();
if (previewing_cinema && scene_root != NULL) {
- Camera *cam = scene_root->get_viewport()->get_camera();
+ Camera3D *cam = scene_root->get_viewport()->get_camera();
if (cam != NULL && cam != previewing) {
//then switch the viewport's camera to the scene's viewport camera
if (previewing != NULL) {
- previewing->disconnect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
+ previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
}
previewing = cam;
- previewing->connect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
- VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera());
+ previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera());
surface->update();
}
}
@@ -2408,11 +2409,11 @@ void SpatialEditorViewport::_notification(int p_what) {
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->key());
+ Node3D *sp = Object::cast_to<Node3D>(E->key());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -2425,7 +2426,7 @@ void SpatialEditorViewport::_notification(int p_what) {
se->last_xform_dirty = false;
se->last_xform = t;
- VisualInstance *vi = Object::cast_to<VisualInstance>(sp);
+ VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp);
se->aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp);
@@ -2436,7 +2437,7 @@ void SpatialEditorViewport::_notification(int p_what) {
aabb_s.scale(se->aabb.size);
t.basis = t.basis * aabb_s;
- VisualServer::get_singleton()->instance_set_transform(se->sbox_instance, t);
+ RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t);
}
if (changed || (spatial_editor->is_gizmo_visible() && !exist)) {
@@ -2483,7 +2484,7 @@ void SpatialEditorViewport::_notification(int p_what) {
bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
info_label->set_visible(show_info);
- Camera *current_camera;
+ Camera3D *current_camera;
if (previewing) {
current_camera = previewing;
@@ -2537,12 +2538,12 @@ void SpatialEditorViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- surface->connect("draw", callable_mp(this, &SpatialEditorViewport::_draw));
- surface->connect("gui_input", callable_mp(this, &SpatialEditorViewport::_sinput));
- surface->connect("mouse_entered", callable_mp(this, &SpatialEditorViewport::_surface_mouse_enter));
- surface->connect("mouse_exited", callable_mp(this, &SpatialEditorViewport::_surface_mouse_exit));
- surface->connect("focus_entered", callable_mp(this, &SpatialEditorViewport::_surface_focus_enter));
- surface->connect("focus_exited", callable_mp(this, &SpatialEditorViewport::_surface_focus_exit));
+ surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw));
+ surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput));
+ surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter));
+ surface->connect("mouse_exited", callable_mp(this, &Node3DEditorViewport::_surface_mouse_exit));
+ surface->connect("focus_entered", callable_mp(this, &Node3DEditorViewport::_surface_focus_enter));
+ surface->connect("focus_exited", callable_mp(this, &Node3DEditorViewport::_surface_focus_exit));
_init_gizmo_instance(index);
}
@@ -2554,25 +2555,25 @@ void SpatialEditorViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED) {
- view_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
- preview_camera->set_icon(get_icon("Camera", "EditorIcons"));
+ view_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
+ preview_camera->set_icon(get_theme_icon("Camera3D", "EditorIcons"));
- view_menu->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- view_menu->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- view_menu->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- view_menu->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- view_menu->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
- preview_camera->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- preview_camera->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- preview_camera->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- preview_camera->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- preview_camera->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
- info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- cinema_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- locked_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ info_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ fps_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ cinema_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ locked_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
}
}
@@ -2597,7 +2598,7 @@ static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> ico
surface.draw_texture(icon, icon_pos);
}
-void SpatialEditorViewport::_draw() {
+void Node3DEditorViewport::_draw() {
EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
@@ -2612,7 +2613,7 @@ void SpatialEditorViewport::_draw() {
if (surface->has_focus()) {
Size2 size = surface->get_size();
Rect2 r = Rect2(Point2(), size);
- get_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r);
+ get_theme_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r);
}
if (cursor.region_select) {
@@ -2620,11 +2621,11 @@ void SpatialEditorViewport::_draw() {
surface->draw_rect(
selection_rect,
- get_color("box_selection_fill_color", "Editor"));
+ get_theme_color("box_selection_fill_color", "Editor"));
surface->draw_rect(
selection_rect,
- get_color("box_selection_stroke_color", "Editor"),
+ get_theme_color("box_selection_stroke_color", "Editor"),
false,
Math::round(EDSCALE));
}
@@ -2632,7 +2633,7 @@ void SpatialEditorViewport::_draw() {
RID ci = surface->get_canvas_item();
if (message_time > 0) {
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
Point2 msgpos = Point2(5, get_size().y - 20);
font->draw(ci, msgpos + Point2(1, 1), message, Color(0, 0, 0, 0.8));
font->draw(ci, msgpos + Point2(-1, -1), message, Color(0, 0, 0, 0.8));
@@ -2642,11 +2643,11 @@ void SpatialEditorViewport::_draw() {
if (_edit.mode == TRANSFORM_ROTATE) {
Point2 center = _point_to_screen(_edit.center);
- VisualServer::get_singleton()->canvas_item_add_line(
+ RenderingServer::get_singleton()->canvas_item_add_line(
ci,
_edit.mouse_pos,
center,
- get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
+ get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
Math::round(2 * EDSCALE));
}
if (previewing) {
@@ -2658,14 +2659,14 @@ void SpatialEditorViewport::_draw() {
Rect2 draw_rect;
switch (previewing->get_keep_aspect_mode()) {
- case Camera::KEEP_WIDTH: {
+ case Camera3D::KEEP_WIDTH: {
draw_rect.size = Size2(s.width, s.width / aspect);
draw_rect.position.x = 0;
draw_rect.position.y = (s.height - draw_rect.size.y) * 0.5;
} break;
- case Camera::KEEP_HEIGHT: {
+ case Camera3D::KEEP_HEIGHT: {
draw_rect.size = Size2(s.height * aspect, s.height);
draw_rect.position.y = 0;
@@ -2697,7 +2698,7 @@ void SpatialEditorViewport::_draw() {
if (logscale_t < 0.25)
logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0);
- draw_indicator_bar(*surface, 1.0 - logscale_t, get_icon("ViewportSpeed", "EditorIcons"));
+ draw_indicator_bar(*surface, 1.0 - logscale_t, get_theme_icon("ViewportSpeed", "EditorIcons"));
}
} else {
@@ -2715,14 +2716,14 @@ void SpatialEditorViewport::_draw() {
if (logscale_t < 0.25)
logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0);
- draw_indicator_bar(*surface, logscale_t, get_icon("ViewportZoom", "EditorIcons"));
+ draw_indicator_bar(*surface, logscale_t, get_theme_icon("ViewportZoom", "EditorIcons"));
}
}
}
}
}
-void SpatialEditorViewport::_menu_option(int p_option) {
+void Node3DEditorViewport::_menu_option(int p_option) {
switch (p_option) {
@@ -2809,11 +2810,11 @@ void SpatialEditorViewport::_menu_option(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -2845,11 +2846,11 @@ void SpatialEditorViewport::_menu_option(int p_option) {
undo_redo->create_action(TTR("Align Rotation with View"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -2869,7 +2870,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
camera->set_environment(RES());
} else {
- camera->set_environment(SpatialEditor::get_singleton()->get_viewport_environment());
+ camera->set_environment(Node3DEditor::get_singleton()->get_viewport_environment());
}
view_menu->get_popup()->set_item_checked(idx, current);
@@ -2933,7 +2934,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
- camera->set_doppler_tracking(current ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED);
+ camera->set_doppler_tracking(current ? Camera3D::DOPPLER_TRACKING_IDLE_STEP : Camera3D::DOPPLER_TRACKING_DISABLED);
view_menu->get_popup()->set_item_checked(idx, current);
} break;
@@ -3060,84 +3061,84 @@ void SpatialEditorViewport::_menu_option(int p_option) {
}
}
-void SpatialEditorViewport::_set_auto_orthogonal() {
+void Node3DEditorViewport::_set_auto_orthogonal() {
if (!orthogonal && view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL))) {
_menu_option(VIEW_ORTHOGONAL);
auto_orthogonal = true;
}
}
-void SpatialEditorViewport::_preview_exited_scene() {
+void Node3DEditorViewport::_preview_exited_scene() {
- preview_camera->disconnect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
+ preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview));
preview_camera->set_pressed(false);
_toggle_camera_preview(false);
- preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
+ preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview));
view_menu->show();
}
-void SpatialEditorViewport::_init_gizmo_instance(int p_idx) {
+void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
uint32_t layer = 1 << (GIZMO_BASE_LAYER + p_idx);
for (int i = 0; i < 3; i++) {
- move_gizmo_instance[i] = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer);
-
- move_plane_gizmo_instance[i] = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer);
-
- rotate_gizmo_instance[i] = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer);
-
- scale_gizmo_instance[i] = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer);
-
- scale_plane_gizmo_instance[i] = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer);
- }
-}
-
-void SpatialEditorViewport::_finish_gizmo_instances() {
+ move_gizmo_instance[i] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid());
+ RS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ RS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer);
+
+ move_plane_gizmo_instance[i] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid());
+ RS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ RS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer);
+
+ rotate_gizmo_instance[i] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid());
+ RS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ RS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer);
+
+ scale_gizmo_instance[i] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid());
+ RS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ RS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer);
+
+ scale_plane_gizmo_instance[i] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid());
+ RS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ RS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer);
+ }
+}
+
+void Node3DEditorViewport::_finish_gizmo_instances() {
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->free(move_gizmo_instance[i]);
- VS::get_singleton()->free(move_plane_gizmo_instance[i]);
- VS::get_singleton()->free(rotate_gizmo_instance[i]);
- VS::get_singleton()->free(scale_gizmo_instance[i]);
- VS::get_singleton()->free(scale_plane_gizmo_instance[i]);
+ RS::get_singleton()->free(move_gizmo_instance[i]);
+ RS::get_singleton()->free(move_plane_gizmo_instance[i]);
+ RS::get_singleton()->free(rotate_gizmo_instance[i]);
+ RS::get_singleton()->free(scale_gizmo_instance[i]);
+ RS::get_singleton()->free(scale_plane_gizmo_instance[i]);
}
}
-void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
+void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {
ERR_FAIL_COND(p_activate && !preview);
ERR_FAIL_COND(!p_activate && !previewing);
if (!p_activate) {
- previewing->disconnect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
+ previewing->disconnect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
previewing = NULL;
- VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
+ RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
if (!preview)
preview_camera->hide();
view_menu->set_disabled(false);
@@ -3146,21 +3147,21 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
} else {
previewing = preview;
- previewing->connect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
- VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
+ previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
view_menu->set_disabled(true);
surface->update();
}
}
-void SpatialEditorViewport::_toggle_cinema_preview(bool p_activate) {
+void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) {
previewing_cinema = p_activate;
if (!previewing_cinema) {
if (previewing != NULL)
- previewing->disconnect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
+ previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
previewing = NULL;
- VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
+ RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
preview_camera->set_pressed(false);
if (!preview) {
preview_camera->hide();
@@ -3172,7 +3173,7 @@ void SpatialEditorViewport::_toggle_cinema_preview(bool p_activate) {
}
}
-void SpatialEditorViewport::_selection_result_pressed(int p_result) {
+void Node3DEditorViewport::_selection_result_pressed(int p_result) {
if (selection_results.size() <= p_result)
return;
@@ -3180,19 +3181,19 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
clicked = selection_results[p_result].item->get_instance_id();
if (clicked.is_valid()) {
- _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT);
+ _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != Node3DEditor::TOOL_MODE_LIST_SELECT);
clicked = ObjectID();
}
}
-void SpatialEditorViewport::_selection_menu_hide() {
+void Node3DEditorViewport::_selection_menu_hide() {
selection_results.clear();
selection_menu->clear();
selection_menu->set_size(Vector2(0, 0));
}
-void SpatialEditorViewport::set_can_preview(Camera *p_preview) {
+void Node3DEditorViewport::set_can_preview(Camera3D *p_preview) {
preview = p_preview;
@@ -3200,7 +3201,7 @@ void SpatialEditorViewport::set_can_preview(Camera *p_preview) {
preview_camera->set_visible(p_preview);
}
-void SpatialEditorViewport::update_transform_gizmo_view() {
+void Node3DEditorViewport::update_transform_gizmo_view() {
if (!is_visible_in_tree())
return;
@@ -3211,11 +3212,11 @@ void SpatialEditorViewport::update_transform_gizmo_view() {
if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) {
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
- VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
- VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
- VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
- VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
}
return;
}
@@ -3243,20 +3244,20 @@ void SpatialEditorViewport::update_transform_gizmo_view() {
xform.basis.scale(scale);
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform);
- VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE));
- VisualServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform);
- VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE));
- VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform);
- VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE));
- VisualServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform);
- VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE));
- VisualServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform);
- VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE));
+ RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform);
+ RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE));
+ RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform);
+ RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE));
+ RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform);
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE));
+ RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform);
+ RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
+ RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform);
+ RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
}
}
-void SpatialEditorViewport::set_state(const Dictionary &p_state) {
+void Node3DEditorViewport::set_state(const Dictionary &p_state) {
if (p_state.has("position"))
cursor.pos = p_state["position"];
@@ -3317,7 +3318,7 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
bool doppler = p_state["doppler"];
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER);
- camera->set_doppler_tracking(doppler ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED);
+ camera->set_doppler_tracking(doppler ? Camera3D::DOPPLER_TRACKING_IDLE_STEP : Camera3D::DOPPLER_TRACKING_DISABLED);
view_menu->get_popup()->set_item_checked(idx, doppler);
}
if (p_state.has("gizmos")) {
@@ -3354,25 +3355,25 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
view_menu->get_popup()->set_item_checked(idx, previewing_cinema);
}
- if (preview_camera->is_connected("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview))) {
- preview_camera->disconnect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
+ if (preview_camera->is_connected("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview))) {
+ preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview));
}
if (p_state.has("previewing")) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
- if (Object::cast_to<Camera>(pv)) {
- previewing = Object::cast_to<Camera>(pv);
- previewing->connect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene));
- VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
+ if (Object::cast_to<Camera3D>(pv)) {
+ previewing = Object::cast_to<Camera3D>(pv);
+ previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->set_disabled(true);
surface->update();
preview_camera->set_pressed(true);
preview_camera->show();
}
}
- preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
+ preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview));
}
-Dictionary SpatialEditorViewport::get_state() const {
+Dictionary Node3DEditorViewport::get_state() const {
Dictionary d;
d["position"] = cursor.pos;
@@ -3380,7 +3381,7 @@ Dictionary SpatialEditorViewport::get_state() const {
d["y_rotation"] = cursor.y_rot;
d["distance"] = cursor.distance;
d["use_environment"] = camera->get_environment().is_valid();
- d["use_orthogonal"] = camera->get_projection() == Camera::PROJECTION_ORTHOGONAL;
+ d["use_orthogonal"] = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL;
d["view_name"] = name;
d["auto_orthogonal"] = auto_orthogonal;
d["auto_orthogonal_enabled"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL));
@@ -3407,17 +3408,17 @@ Dictionary SpatialEditorViewport::get_state() const {
return d;
}
-void SpatialEditorViewport::_bind_methods() {
+void Node3DEditorViewport::_bind_methods() {
- ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view); // Used by call_deferred.
- ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpatialEditorViewport::can_drop_data_fw);
- ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpatialEditorViewport::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &Node3DEditorViewport::update_transform_gizmo_view); // Used by call_deferred.
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &Node3DEditorViewport::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &Node3DEditorViewport::drop_data_fw);
ADD_SIGNAL(MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport")));
ADD_SIGNAL(MethodInfo("clicked", PropertyInfo(Variant::OBJECT, "viewport")));
}
-void SpatialEditorViewport::reset() {
+void Node3DEditorViewport::reset() {
orthogonal = false;
auto_orthogonal = false;
@@ -3435,7 +3436,7 @@ void SpatialEditorViewport::reset() {
_update_name();
}
-void SpatialEditorViewport::focus_selection() {
+void Node3DEditorViewport::focus_selection() {
if (!get_selected_count())
return;
@@ -3446,11 +3447,11 @@ void SpatialEditorViewport::focus_selection() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -3465,20 +3466,20 @@ void SpatialEditorViewport::focus_selection() {
cursor.pos = center;
}
-void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) {
+void Node3DEditorViewport::assign_pending_data_pointers(Node3D *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) {
preview_node = p_preview_node;
preview_bounds = p_preview_bounds;
accept = p_accept;
}
-Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const {
+Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const {
const float MAX_DISTANCE = 10;
Vector3 world_ray = _get_ray(p_pos);
Vector3 world_pos = _get_ray_pos(p_pos);
- Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario());
- Set<Ref<EditorSpatialGizmo>> found_gizmos;
+ Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario());
+ Set<Ref<EditorNode3DGizmo>> found_gizmos;
float closest_dist = MAX_DISTANCE;
@@ -3487,12 +3488,12 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const
for (int i = 0; i < instances.size(); i++) {
- MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(ObjectDB::get_instance(instances[i]));
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(instances[i]));
if (!mesh_instance)
continue;
- Ref<EditorSpatialGizmo> seg = mesh_instance->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = mesh_instance->get_gizmo();
if ((!seg.is_valid()) || found_gizmos.has(seg)) {
continue;
@@ -3528,20 +3529,20 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const
return point + offset;
}
-AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, bool p_exclude_toplevel_transform) {
+AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_toplevel_transform) {
AABB bounds;
- const MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(p_parent);
+ const MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_parent);
if (mesh_instance) {
bounds = mesh_instance->get_aabb();
}
for (int i = 0; i < p_parent->get_child_count(); i++) {
- Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i));
+ Node3D *child = Object::cast_to<Node3D>(p_parent->get_child(i));
if (child) {
AABB child_bounds = _calculate_spatial_bounds(child, false);
- if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Spatial")) {
+ if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Node3D")) {
bounds = child_bounds;
} else {
bounds.merge_with(child_bounds);
@@ -3549,7 +3550,7 @@ AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, b
}
}
- if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Spatial")) {
+ if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Node3D")) {
bounds = AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
}
@@ -3560,7 +3561,7 @@ AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, b
return bounds;
}
-void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
+void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
@@ -3569,7 +3570,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res));
if (mesh != NULL || scene != NULL) {
if (mesh != NULL) {
- MeshInstance *mesh_instance = memnew(MeshInstance);
+ MeshInstance3D *mesh_instance = memnew(MeshInstance3D);
mesh_instance->set_mesh(mesh);
preview_node->add_child(mesh_instance);
} else {
@@ -3586,7 +3587,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
*preview_bounds = _calculate_spatial_bounds(preview_node);
}
-void SpatialEditorViewport::_remove_preview() {
+void Node3DEditorViewport::_remove_preview() {
if (preview_node->get_parent()) {
for (int i = preview_node->get_child_count() - 1; i >= 0; i--) {
Node *node = preview_node->get_child(i);
@@ -3597,7 +3598,7 @@ void SpatialEditorViewport::_remove_preview() {
}
}
-bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
+bool Node3DEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
if (p_desired_node->get_filename() == p_target_scene_path) {
return true;
}
@@ -3612,7 +3613,7 @@ bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_s
return false;
}
-bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
+bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
RES res = ResourceLoader::load(path);
ERR_FAIL_COND_V(res.is_null(), false);
@@ -3623,7 +3624,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P
if (mesh != NULL || scene != NULL) {
if (mesh != NULL) {
- MeshInstance *mesh_instance = memnew(MeshInstance);
+ MeshInstance3D *mesh_instance = memnew(MeshInstance3D);
mesh_instance->set_mesh(mesh);
mesh_instance->set_name(path.get_file().get_basename());
instanced_scene = mesh_instance;
@@ -3662,7 +3663,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
Transform global_transform;
- Spatial *parent_spatial = Object::cast_to<Spatial>(parent);
+ Node3D *parent_spatial = Object::cast_to<Node3D>(parent);
if (parent_spatial)
global_transform = parent_spatial->get_global_gizmo_transform();
@@ -3673,7 +3674,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P
return true;
}
-void SpatialEditorViewport::_perform_drop_data() {
+void Node3DEditorViewport::_perform_drop_data() {
_remove_preview();
Vector<String> error_files;
@@ -3705,11 +3706,11 @@ void SpatialEditorViewport::_perform_drop_data() {
}
files_str = files_str.substr(0, files_str.length() - 1);
accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
- accept->popup_centered_minsize();
+ accept->popup_centered();
}
}
-bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
+bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
bool can_instance = false;
@@ -3766,11 +3767,11 @@ bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Varian
return can_instance;
}
-void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
if (!can_drop_data_fw(p_point, p_data, p_from))
return;
- bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ bool is_shift = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
selected_files.clear();
Dictionary d = p_data;
@@ -3785,14 +3786,14 @@ void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p
list.push_back(root_node);
} else {
accept->set_text(TTR("No parent to instance a child at."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
_remove_preview();
return;
}
}
if (list.size() != 1) {
accept->set_text(TTR("This operation requires a single selected node."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
_remove_preview();
return;
}
@@ -3806,7 +3807,7 @@ void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p
_perform_drop_data();
}
-SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
+Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
_edit.mode = TRANSFORM_NONE;
_edit.plane = TRANSFORM_VIEW;
@@ -3833,7 +3834,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
c->set_stretch(true);
add_child(c);
c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- viewport = memnew(Viewport);
+ viewport = memnew(SubViewport);
viewport->set_disable_input(true);
c->add_child(viewport);
@@ -3842,7 +3843,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
add_child(surface);
surface->set_anchors_and_margins_preset(Control::PRESET_WIDE);
surface->set_clip_contents(true);
- camera = memnew(Camera);
+ camera = memnew(Camera3D);
camera->set_disable_gizmo(true);
camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER));
viewport->add_child(camera);
@@ -3923,11 +3924,14 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_transform_with_view"), VIEW_ALIGN_TRANSFORM_WITH_VIEW);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_rotation_with_view"), VIEW_ALIGN_ROTATION_WITH_VIEW);
- view_menu->get_popup()->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_menu_option));
- display_submenu->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_menu_option));
+ view_menu->get_popup()->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option));
+ display_submenu->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option));
view_menu->set_disable_shortcuts(true);
-
- if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+#ifndef _MSC_VER
+#warning this needs to be fixed
+#endif
+ //if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+ if (false) {
// Alternate display modes only work when using the Vulkan renderer; make this explicit.
const int normal_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL);
const int wireframe_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME);
@@ -3959,7 +3963,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
vbox->add_child(preview_camera);
preview_camera->set_h_size_flags(0);
preview_camera->hide();
- preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview));
+ preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview));
previewing = NULL;
gizmo_scale = 1.0;
@@ -4033,9 +4037,9 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
selection_menu = memnew(PopupMenu);
add_child(selection_menu);
- selection_menu->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
- selection_menu->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_selection_result_pressed));
- selection_menu->connect("popup_hide", callable_mp(this, &SpatialEditorViewport::_selection_menu_hide));
+ selection_menu->set_min_size(Size2(100, 0) * EDSCALE);
+ selection_menu->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_selection_result_pressed));
+ selection_menu->connect("popup_hide", callable_mp(this, &Node3DEditorViewport::_selection_menu_hide));
if (p_index == 0) {
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true);
@@ -4045,12 +4049,12 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
name = "";
_update_name();
- EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &SpatialEditorViewport::update_transform_gizmo_view));
+ EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Node3DEditorViewport::update_transform_gizmo_view));
}
//////////////////////////////////////////////////////////////
-void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
+void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
@@ -4059,8 +4063,8 @@ void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event)
if (mb->is_pressed()) {
Vector2 size = get_size();
- int h_sep = get_constant("separation", "HSplitContainer");
- int v_sep = get_constant("separation", "VSplitContainer");
+ int h_sep = get_theme_constant("separation", "HSplitContainer");
+ int v_sep = get_theme_constant("separation", "VSplitContainer");
int mid_w = size.width * ratio_h;
int mid_h = size.height * ratio_v;
@@ -4110,8 +4114,8 @@ void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event)
if (view == VIEW_USE_3_VIEWPORTS || view == VIEW_USE_3_VIEWPORTS_ALT || view == VIEW_USE_4_VIEWPORTS) {
Vector2 size = get_size();
- int h_sep = get_constant("separation", "HSplitContainer");
- int v_sep = get_constant("separation", "VSplitContainer");
+ int h_sep = get_theme_constant("separation", "HSplitContainer");
+ int v_sep = get_theme_constant("separation", "VSplitContainer");
int mid_w = size.width * ratio_h;
int mid_h = size.height * ratio_v;
@@ -4143,7 +4147,7 @@ void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event)
}
}
-void SpatialEditorViewportContainer::_notification(int p_what) {
+void Node3DEditorViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_MOUSE_ENTER || p_what == NOTIFICATION_MOUSE_EXIT) {
@@ -4153,18 +4157,18 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && mouseover) {
- Ref<Texture2D> h_grabber = get_icon("grabber", "HSplitContainer");
- Ref<Texture2D> v_grabber = get_icon("grabber", "VSplitContainer");
+ Ref<Texture2D> h_grabber = get_theme_icon("grabber", "HSplitContainer");
+ Ref<Texture2D> v_grabber = get_theme_icon("grabber", "VSplitContainer");
- Ref<Texture2D> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons");
- Ref<Texture2D> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons");
- Ref<Texture2D> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons");
+ Ref<Texture2D> hdiag_grabber = get_theme_icon("GuiViewportHdiagsplitter", "EditorIcons");
+ Ref<Texture2D> vdiag_grabber = get_theme_icon("GuiViewportVdiagsplitter", "EditorIcons");
+ Ref<Texture2D> vh_grabber = get_theme_icon("GuiViewportVhsplitter", "EditorIcons");
Vector2 size = get_size();
- int h_sep = get_constant("separation", "HSplitContainer");
+ int h_sep = get_theme_constant("separation", "HSplitContainer");
- int v_sep = get_constant("separation", "VSplitContainer");
+ int v_sep = get_theme_constant("separation", "VSplitContainer");
int mid_w = size.width * ratio_h;
int mid_h = size.height * ratio_v;
@@ -4239,10 +4243,10 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_SORT_CHILDREN) {
- SpatialEditorViewport *viewports[4];
+ Node3DEditorViewport *viewports[4];
int vc = 0;
for (int i = 0; i < get_child_count(); i++) {
- viewports[vc] = Object::cast_to<SpatialEditorViewport>(get_child(i));
+ viewports[vc] = Object::cast_to<Node3DEditorViewport>(get_child(i));
if (viewports[vc]) {
vc++;
}
@@ -4258,9 +4262,9 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
}
return;
}
- int h_sep = get_constant("separation", "HSplitContainer");
+ int h_sep = get_theme_constant("separation", "HSplitContainer");
- int v_sep = get_constant("separation", "VSplitContainer");
+ int v_sep = get_theme_constant("separation", "VSplitContainer");
int mid_w = size.width * ratio_h;
int mid_h = size.height * ratio_v;
@@ -4358,23 +4362,23 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
}
}
-void SpatialEditorViewportContainer::set_view(View p_view) {
+void Node3DEditorViewportContainer::set_view(View p_view) {
view = p_view;
queue_sort();
}
-SpatialEditorViewportContainer::View SpatialEditorViewportContainer::get_view() {
+Node3DEditorViewportContainer::View Node3DEditorViewportContainer::get_view() {
return view;
}
-void SpatialEditorViewportContainer::_bind_methods() {
+void Node3DEditorViewportContainer::_bind_methods() {
- ClassDB::bind_method("_gui_input", &SpatialEditorViewportContainer::_gui_input);
+ ClassDB::bind_method("_gui_input", &Node3DEditorViewportContainer::_gui_input);
}
-SpatialEditorViewportContainer::SpatialEditorViewportContainer() {
+Node3DEditorViewportContainer::Node3DEditorViewportContainer() {
set_clip_contents(true);
view = VIEW_USE_1_VIEWPORT;
@@ -4389,15 +4393,15 @@ SpatialEditorViewportContainer::SpatialEditorViewportContainer() {
///////////////////////////////////////////////////////////////////
-SpatialEditor *SpatialEditor::singleton = NULL;
+Node3DEditor *Node3DEditor::singleton = NULL;
-SpatialEditorSelectedItem::~SpatialEditorSelectedItem() {
+Node3DEditorSelectedItem::~Node3DEditorSelectedItem() {
if (sbox_instance.is_valid())
- VisualServer::get_singleton()->free(sbox_instance);
+ RenderingServer::get_singleton()->free(sbox_instance);
}
-void SpatialEditor::select_gizmo_highlight_axis(int p_axis) {
+void Node3DEditor::select_gizmo_highlight_axis(int p_axis) {
for (int i = 0; i < 3; i++) {
@@ -4409,7 +4413,7 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) {
}
}
-void SpatialEditor::update_transform_gizmo() {
+void Node3DEditor::update_transform_gizmo() {
List<Node *> &selection = editor_selection->get_selected_node_list();
AABB center;
@@ -4420,11 +4424,11 @@ void SpatialEditor::update_transform_gizmo() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -4455,7 +4459,7 @@ void SpatialEditor::update_transform_gizmo() {
void _update_all_gizmos(Node *p_node) {
for (int i = p_node->get_child_count() - 1; 0 <= i; --i) {
- Spatial *spatial_node = Object::cast_to<Spatial>(p_node->get_child(i));
+ Node3D *spatial_node = Object::cast_to<Node3D>(p_node->get_child(i));
if (spatial_node) {
spatial_node->update_gizmo();
}
@@ -4464,29 +4468,29 @@ void _update_all_gizmos(Node *p_node) {
}
}
-void SpatialEditor::update_all_gizmos(Node *p_node) {
+void Node3DEditor::update_all_gizmos(Node *p_node) {
if (!p_node) {
p_node = SceneTree::get_singleton()->get_root();
}
_update_all_gizmos(p_node);
}
-Object *SpatialEditor::_get_editor_data(Object *p_what) {
+Object *Node3DEditor::_get_editor_data(Object *p_what) {
- Spatial *sp = Object::cast_to<Spatial>(p_what);
+ Node3D *sp = Object::cast_to<Node3D>(p_what);
if (!sp)
return NULL;
- SpatialEditorSelectedItem *si = memnew(SpatialEditorSelectedItem);
+ Node3DEditorSelectedItem *si = memnew(Node3DEditorSelectedItem);
si->sp = sp;
- si->sbox_instance = VisualServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario());
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF);
+ si->sbox_instance = RenderingServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario());
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, RS::SHADOW_CASTING_SETTING_OFF);
return si;
}
-void SpatialEditor::_generate_selection_box() {
+void Node3DEditor::_generate_selection_box() {
AABB aabb(Vector3(), Vector3(1, 1, 1));
aabb.grow_by(aabb.get_longest_axis_size() / 20.0);
@@ -4520,7 +4524,7 @@ void SpatialEditor::_generate_selection_box() {
selection_box = st->commit();
}
-Dictionary SpatialEditor::get_state() const {
+Dictionary Node3DEditor::get_state() const {
Dictionary d;
@@ -4571,7 +4575,7 @@ Dictionary SpatialEditor::get_state() const {
return d;
}
-void SpatialEditor::set_state(const Dictionary &p_state) {
+void Node3DEditor::set_state(const Dictionary &p_state) {
Dictionary d = p_state;
@@ -4645,7 +4649,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
if (use != view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN))) {
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), use);
- VisualServer::get_singleton()->instance_set_visible(origin_instance, use);
+ RenderingServer::get_singleton()->instance_set_visible(origin_instance, use);
}
}
@@ -4656,7 +4660,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
for (int j = 0; j < gizmo_plugins_by_name.size(); ++j) {
if (!gizmo_plugins_by_name[j]->can_be_hidden()) continue;
- int state = EditorSpatialGizmoPlugin::VISIBLE;
+ int state = EditorNode3DGizmoPlugin::VISIBLE;
for (int i = 0; i < keys.size(); i++) {
if (gizmo_plugins_by_name.write[j]->get_name() == keys[i]) {
state = gizmos_status[keys[i]];
@@ -4670,12 +4674,12 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
}
}
-void SpatialEditor::edit(Spatial *p_spatial) {
+void Node3DEditor::edit(Node3D *p_spatial) {
if (p_spatial != selected) {
if (selected) {
- Ref<EditorSpatialGizmo> seg = selected->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = selected->get_gizmo();
if (seg.is_valid()) {
seg->set_selected(false);
selected->update_gizmo();
@@ -4687,7 +4691,7 @@ void SpatialEditor::edit(Spatial *p_spatial) {
if (selected) {
- Ref<EditorSpatialGizmo> seg = selected->get_gizmo();
+ Ref<EditorNode3DGizmo> seg = selected->get_gizmo();
if (seg.is_valid()) {
seg->set_selected(true);
selected->update_gizmo();
@@ -4696,21 +4700,21 @@ void SpatialEditor::edit(Spatial *p_spatial) {
}
}
-void SpatialEditor::_snap_changed() {
+void Node3DEditor::_snap_changed() {
snap_translate_value = snap_translate->get_text().to_double();
snap_rotate_value = snap_rotate->get_text().to_double();
snap_scale_value = snap_scale->get_text().to_double();
}
-void SpatialEditor::_snap_update() {
+void Node3DEditor::_snap_update() {
snap_translate->set_text(String::num(snap_translate_value));
snap_rotate->set_text(String::num(snap_rotate_value));
snap_scale->set_text(String::num(snap_scale_value));
}
-void SpatialEditor::_xform_dialog_action() {
+void Node3DEditor::_xform_dialog_action() {
Transform t;
//translation
@@ -4734,11 +4738,11 @@ void SpatialEditor::_xform_dialog_action() {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp)
continue;
- SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
if (!se)
continue;
@@ -4759,7 +4763,7 @@ void SpatialEditor::_xform_dialog_action() {
undo_redo->commit_action();
}
-void SpatialEditor::_menu_item_toggled(bool pressed, int p_option) {
+void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) {
switch (p_option) {
case MENU_TOOL_LOCAL_COORDS: {
@@ -4788,7 +4792,7 @@ void SpatialEditor::_menu_item_toggled(bool pressed, int p_option) {
}
}
-void SpatialEditor::_menu_gizmo_toggled(int p_option) {
+void Node3DEditor::_menu_gizmo_toggled(int p_option) {
const int idx = gizmos_menu->get_item_index(p_option);
gizmos_menu->toggle_item_multistate(idx);
@@ -4796,14 +4800,14 @@ void SpatialEditor::_menu_gizmo_toggled(int p_option) {
// Change icon
const int state = gizmos_menu->get_item_state(idx);
switch (state) {
- case EditorSpatialGizmoPlugin::VISIBLE:
- gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_icon("visibility_visible"));
+ case EditorNode3DGizmoPlugin::VISIBLE:
+ gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_visible"));
break;
- case EditorSpatialGizmoPlugin::ON_TOP:
- gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_icon("visibility_xray"));
+ case EditorNode3DGizmoPlugin::ON_TOP:
+ gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_xray"));
break;
- case EditorSpatialGizmoPlugin::HIDDEN:
- gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_icon("visibility_hidden"));
+ case EditorNode3DGizmoPlugin::HIDDEN:
+ gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_hidden"));
break;
}
@@ -4812,7 +4816,7 @@ void SpatialEditor::_menu_gizmo_toggled(int p_option) {
update_all_gizmos();
}
-void SpatialEditor::_update_camera_override_button(bool p_game_running) {
+void Node3DEditor::_update_camera_override_button(bool p_game_running) {
Button *const button = tool_option_button[TOOL_OPT_OVERRIDE_CAMERA];
if (p_game_running) {
@@ -4825,8 +4829,8 @@ void SpatialEditor::_update_camera_override_button(bool p_game_running) {
}
}
-void SpatialEditor::_update_camera_override_viewport(Object *p_viewport) {
- SpatialEditorViewport *current_viewport = Object::cast_to<SpatialEditorViewport>(p_viewport);
+void Node3DEditor::_update_camera_override_viewport(Object *p_viewport) {
+ Node3DEditorViewport *current_viewport = Object::cast_to<Node3DEditorViewport>(p_viewport);
if (!current_viewport)
return;
@@ -4841,7 +4845,7 @@ void SpatialEditor::_update_camera_override_viewport(Object *p_viewport) {
}
}
-void SpatialEditor::_menu_item_pressed(int p_option) {
+void Node3DEditor::_menu_item_pressed(int p_option) {
switch (p_option) {
@@ -4875,7 +4879,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_1_VIEWPORT: {
- viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_1_VIEWPORT);
+ viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_1_VIEWPORT);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), true);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
@@ -4887,7 +4891,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_2_VIEWPORTS: {
- viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_2_VIEWPORTS);
+ viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_2_VIEWPORTS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), true);
@@ -4899,7 +4903,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_2_VIEWPORTS_ALT: {
- viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_2_VIEWPORTS_ALT);
+ viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_2_VIEWPORTS_ALT);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
@@ -4911,7 +4915,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_3_VIEWPORTS: {
- viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_3_VIEWPORTS);
+ viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_3_VIEWPORTS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
@@ -4923,7 +4927,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_3_VIEWPORTS_ALT: {
- viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_3_VIEWPORTS_ALT);
+ viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_3_VIEWPORTS_ALT);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
@@ -4935,7 +4939,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_4_VIEWPORTS: {
- viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_4_VIEWPORTS);
+ viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_4_VIEWPORTS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
@@ -4950,7 +4954,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
origin_enabled = !is_checked;
- VisualServer::get_singleton()->instance_set_visible(origin_instance, origin_enabled);
+ RenderingServer::get_singleton()->instance_set_visible(origin_instance, origin_enabled);
// Update the grid since its appearance depends on whether the origin is enabled
_finish_grid();
_init_grid();
@@ -4965,7 +4969,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
for (int i = 0; i < 3; ++i) {
if (grid_enable[i]) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled);
grid_visible[i] = grid_enabled;
}
}
@@ -4987,7 +4991,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *spatial = Object::cast_to<Spatial>(E->get());
+ Node3D *spatial = Object::cast_to<Node3D>(E->get());
if (!spatial || !spatial->is_visible_in_tree())
continue;
@@ -5011,7 +5015,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *spatial = Object::cast_to<Spatial>(E->get());
+ Node3D *spatial = Object::cast_to<Node3D>(E->get());
if (!spatial || !spatial->is_visible_in_tree())
continue;
@@ -5035,7 +5039,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *spatial = Object::cast_to<Spatial>(E->get());
+ Node3D *spatial = Object::cast_to<Node3D>(E->get());
if (!spatial || !spatial->is_visible_in_tree())
continue;
@@ -5058,7 +5062,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *spatial = Object::cast_to<Spatial>(E->get());
+ Node3D *spatial = Object::cast_to<Node3D>(E->get());
if (!spatial || !spatial->is_visible_in_tree())
continue;
@@ -5078,7 +5082,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
}
}
-void SpatialEditor::_init_indicators() {
+void Node3DEditor::_init_indicators() {
{
origin_enabled = true;
@@ -5098,13 +5102,13 @@ void SpatialEditor::_init_indicators() {
Color origin_color;
switch (i) {
case 0:
- origin_color = get_color("axis_x_color", "Editor");
+ origin_color = get_theme_color("axis_x_color", "Editor");
break;
case 1:
- origin_color = get_color("axis_y_color", "Editor");
+ origin_color = get_theme_color("axis_y_color", "Editor");
break;
case 2:
- origin_color = get_color("axis_z_color", "Editor");
+ origin_color = get_theme_color("axis_z_color", "Editor");
break;
default:
origin_color = Color();
@@ -5125,19 +5129,19 @@ void SpatialEditor::_init_indicators() {
_init_grid();
- origin = VisualServer::get_singleton()->mesh_create();
+ origin = RenderingServer::get_singleton()->mesh_create();
Array d;
- d.resize(VS::ARRAY_MAX);
- d[VisualServer::ARRAY_VERTEX] = origin_points;
- d[VisualServer::ARRAY_COLOR] = origin_colors;
+ d.resize(RS::ARRAY_MAX);
+ d[RenderingServer::ARRAY_VERTEX] = origin_points;
+ d[RenderingServer::ARRAY_COLOR] = origin_colors;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin, VisualServer::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid());
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(origin, RenderingServer::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid());
- origin_instance = VisualServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << SpatialEditorViewport::GIZMO_GRID_LAYER);
+ origin_instance = RenderingServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario());
+ RS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << Node3DEditorViewport::GIZMO_GRID_LAYER);
- VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, VS::SHADOW_CASTING_SETTING_OFF);
+ RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, RS::SHADOW_CASTING_SETTING_OFF);
}
{
@@ -5149,13 +5153,13 @@ void SpatialEditor::_init_indicators() {
Color col;
switch (i) {
case 0:
- col = get_color("axis_x_color", "Editor");
+ col = get_theme_color("axis_x_color", "Editor");
break;
case 1:
- col = get_color("axis_y_color", "Editor");
+ col = get_theme_color("axis_y_color", "Editor");
break;
case 2:
- col = get_color("axis_z_color", "Editor");
+ col = get_theme_color("axis_z_color", "Editor");
break;
default:
col = Color();
@@ -5415,7 +5419,7 @@ void SpatialEditor::_init_indicators() {
_generate_selection_box();
}
-void SpatialEditor::_update_gizmos_menu() {
+void Node3DEditor::_update_gizmos_menu() {
gizmos_menu->clear();
@@ -5426,39 +5430,39 @@ void SpatialEditor::_update_gizmos_menu() {
gizmos_menu->add_multistate_item(TTR(plugin_name), 3, plugin_state, i);
const int idx = gizmos_menu->get_item_index(i);
switch (plugin_state) {
- case EditorSpatialGizmoPlugin::VISIBLE:
- gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_visible"));
+ case EditorNode3DGizmoPlugin::VISIBLE:
+ gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible"));
break;
- case EditorSpatialGizmoPlugin::ON_TOP:
- gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_xray"));
+ case EditorNode3DGizmoPlugin::ON_TOP:
+ gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray"));
break;
- case EditorSpatialGizmoPlugin::HIDDEN:
- gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_hidden"));
+ case EditorNode3DGizmoPlugin::HIDDEN:
+ gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden"));
break;
}
}
}
-void SpatialEditor::_update_gizmos_menu_theme() {
+void Node3DEditor::_update_gizmos_menu_theme() {
for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) {
if (!gizmo_plugins_by_name[i]->can_be_hidden()) continue;
const int plugin_state = gizmo_plugins_by_name[i]->get_state();
const int idx = gizmos_menu->get_item_index(i);
switch (plugin_state) {
- case EditorSpatialGizmoPlugin::VISIBLE:
- gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_visible"));
+ case EditorNode3DGizmoPlugin::VISIBLE:
+ gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible"));
break;
- case EditorSpatialGizmoPlugin::ON_TOP:
- gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_xray"));
+ case EditorNode3DGizmoPlugin::ON_TOP:
+ gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray"));
break;
- case EditorSpatialGizmoPlugin::HIDDEN:
- gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_hidden"));
+ case EditorNode3DGizmoPlugin::HIDDEN:
+ gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden"));
break;
}
}
}
-void SpatialEditor::_init_grid() {
+void Node3DEditor::_init_grid() {
Vector<Color> grid_colors[3];
Vector<Vector3> grid_points[3];
@@ -5502,37 +5506,37 @@ void SpatialEditor::_init_grid() {
grid_colors[i].push_back(line_color);
}
- grid[i] = VisualServer::get_singleton()->mesh_create();
+ grid[i] = RenderingServer::get_singleton()->mesh_create();
Array d;
- d.resize(VS::ARRAY_MAX);
- d[VisualServer::ARRAY_VERTEX] = grid_points[i];
- d[VisualServer::ARRAY_COLOR] = grid_colors[i];
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
- grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
+ d.resize(RS::ARRAY_MAX);
+ d[RenderingServer::ARRAY_VERTEX] = grid_points[i];
+ d[RenderingServer::ARRAY_COLOR] = grid_colors[i];
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
+ grid_instance[i] = RenderingServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]);
- VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << SpatialEditorViewport::GIZMO_GRID_LAYER);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]);
+ RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER);
}
}
-void SpatialEditor::_finish_indicators() {
+void Node3DEditor::_finish_indicators() {
- VisualServer::get_singleton()->free(origin_instance);
- VisualServer::get_singleton()->free(origin);
+ RenderingServer::get_singleton()->free(origin_instance);
+ RenderingServer::get_singleton()->free(origin);
_finish_grid();
}
-void SpatialEditor::_finish_grid() {
+void Node3DEditor::_finish_grid() {
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->free(grid_instance[i]);
- VisualServer::get_singleton()->free(grid[i]);
+ RenderingServer::get_singleton()->free(grid_instance[i]);
+ RenderingServer::get_singleton()->free(grid[i]);
}
}
-bool SpatialEditor::is_any_freelook_active() const {
+bool Node3DEditor::is_any_freelook_active() const {
for (unsigned int i = 0; i < VIEWPORTS_COUNT; ++i) {
if (viewports[i]->is_freelook_active())
return true;
@@ -5540,7 +5544,7 @@ bool SpatialEditor::is_any_freelook_active() const {
return false;
}
-void SpatialEditor::_refresh_menu_icons() {
+void Node3DEditor::_refresh_menu_icons() {
bool all_locked = true;
bool all_grouped = true;
@@ -5552,13 +5556,13 @@ void SpatialEditor::_refresh_menu_icons() {
all_grouped = false;
} else {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- if (Object::cast_to<Spatial>(E->get()) && !Object::cast_to<Spatial>(E->get())->has_meta("_edit_lock_")) {
+ if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_lock_")) {
all_locked = false;
break;
}
}
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- if (Object::cast_to<Spatial>(E->get()) && !Object::cast_to<Spatial>(E->get())->has_meta("_edit_group_")) {
+ if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_group_")) {
all_grouped = false;
break;
}
@@ -5595,35 +5599,35 @@ Set<T *> _get_child_nodes(Node *parent_node) {
Set<RID> _get_physics_bodies_rid(Node *node) {
Set<RID> rids = Set<RID>();
- PhysicsBody *pb = Node::cast_to<PhysicsBody>(node);
+ PhysicsBody3D *pb = Node::cast_to<PhysicsBody3D>(node);
if (pb) {
rids.insert(pb->get_rid());
}
- Set<PhysicsBody *> child_nodes = _get_child_nodes<PhysicsBody>(node);
- for (Set<PhysicsBody *>::Element *I = child_nodes.front(); I; I = I->next()) {
+ Set<PhysicsBody3D *> child_nodes = _get_child_nodes<PhysicsBody3D>(node);
+ for (Set<PhysicsBody3D *>::Element *I = child_nodes.front(); I; I = I->next()) {
rids.insert(I->get()->get_rid());
}
return rids;
}
-void SpatialEditor::snap_selected_nodes_to_floor() {
+void Node3DEditor::snap_selected_nodes_to_floor() {
List<Node *> &selection = editor_selection->get_selected_node_list();
Dictionary snap_data;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- Spatial *sp = Object::cast_to<Spatial>(E->get());
+ Node3D *sp = Object::cast_to<Node3D>(E->get());
if (sp) {
Vector3 from = Vector3();
Vector3 position_offset = Vector3();
// Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin
- Set<VisualInstance *> vi = _get_child_nodes<VisualInstance>(sp);
- Set<CollisionShape *> cs = _get_child_nodes<CollisionShape>(sp);
+ Set<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp);
+ Set<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp);
if (cs.size()) {
AABB aabb = sp->get_global_transform().xform(cs.front()->get()->get_shape()->get_debug_mesh()->get_aabb());
- for (Set<CollisionShape *>::Element *I = cs.front(); I; I = I->next()) {
+ for (Set<CollisionShape3D *>::Element *I = cs.front(); I; I = I->next()) {
aabb.merge_with(sp->get_global_transform().xform(I->get()->get_shape()->get_debug_mesh()->get_aabb()));
}
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
@@ -5631,7 +5635,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() {
position_offset.y = from.y - sp->get_global_transform().origin.y;
} else if (vi.size()) {
AABB aabb = vi.front()->get()->get_transformed_aabb();
- for (Set<VisualInstance *>::Element *I = vi.front(); I; I = I->next()) {
+ for (Set<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) {
aabb.merge_with(I->get()->get_transformed_aabb());
}
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
@@ -5654,8 +5658,8 @@ void SpatialEditor::snap_selected_nodes_to_floor() {
}
}
- PhysicsDirectSpaceState *ss = get_tree()->get_root()->get_world()->get_direct_space_state();
- PhysicsDirectSpaceState::RayResult result;
+ PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world()->get_direct_space_state();
+ PhysicsDirectSpaceState3D::RayResult result;
Array keys = snap_data.keys();
@@ -5670,7 +5674,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() {
// We need to check this before snapping to register the undo/redo action only if needed.
for (int i = 0; i < keys.size(); i++) {
Node *node = keys[i];
- Spatial *sp = Object::cast_to<Spatial>(node);
+ Node3D *sp = Object::cast_to<Node3D>(node);
Dictionary d = snap_data[node];
Vector3 from = d["from"];
Vector3 to = from - Vector3(0.0, max_snap_height, 0.0);
@@ -5687,7 +5691,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() {
// Perform snapping if at least one node can be snapped
for (int i = 0; i < keys.size(); i++) {
Node *node = keys[i];
- Spatial *sp = Object::cast_to<Spatial>(node);
+ Node3D *sp = Object::cast_to<Node3D>(node);
Dictionary d = snap_data[node];
Vector3 from = d["from"];
Vector3 to = from - Vector3(0.0, max_snap_height, 0.0);
@@ -5712,48 +5716,48 @@ void SpatialEditor::snap_selected_nodes_to_floor() {
}
}
-void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
+void Node3DEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
- if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
+ if (!is_visible_in_tree())
return;
- snap_key_enabled = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ snap_key_enabled = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
}
-void SpatialEditor::_notification(int p_what) {
+void Node3DEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- tool_button[SpatialEditor::TOOL_MODE_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_LOCK_SELECTED]->set_icon(get_icon("Lock", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_icon("Unlock", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_GROUP_SELECTED]->set_icon(get_icon("Group", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_icon("Ungroup", "EditorIcons"));
-
- tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_icon("Object", "EditorIcons"));
- tool_option_button[SpatialEditor::TOOL_OPT_USE_SNAP]->set_icon(get_icon("Snap", "EditorIcons"));
- tool_option_button[SpatialEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_icon("Camera", "EditorIcons"));
-
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_icon("Panels1", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_icon("Panels2", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_icon("Panels2Alt", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_icon("Panels3", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_icon("Panels3Alt", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_icon("Panels4", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon("ListSelect", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon("Lock", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon("Unlock", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon("Group", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon("Ungroup", "EditorIcons"));
+
+ tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon("Object", "EditorIcons"));
+ tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon("Snap", "EditorIcons"));
+ tool_option_button[Node3DEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon("Camera3D", "EditorIcons"));
+
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon("Panels1", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon("Panels2", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon("Panels2Alt", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon("Panels3", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon("Panels3Alt", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon("Panels4", "EditorIcons"));
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
_refresh_menu_icons();
- get_tree()->connect("node_removed", callable_mp(this, &SpatialEditor::_node_removed));
- EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &SpatialEditor::_refresh_menu_icons));
- editor_selection->connect("selection_changed", callable_mp(this, &SpatialEditor::_refresh_menu_icons));
+ get_tree()->connect("node_removed", callable_mp(this, &Node3DEditor::_node_removed));
+ EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons));
+ editor_selection->connect("selection_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons));
- editor->connect("stop_pressed", callable_mp(this, &SpatialEditor::_update_camera_override_button), make_binds(false));
- editor->connect("play_pressed", callable_mp(this, &SpatialEditor::_update_camera_override_button), make_binds(true));
+ editor->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(false));
+ editor->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(true));
} else if (p_what == NOTIFICATION_ENTER_TREE) {
_register_all_gizmos();
@@ -5765,25 +5769,25 @@ void SpatialEditor::_notification(int p_what) {
_finish_indicators();
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- tool_button[SpatialEditor::TOOL_MODE_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_LOCK_SELECTED]->set_icon(get_icon("Lock", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_icon("Unlock", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_GROUP_SELECTED]->set_icon(get_icon("Group", "EditorIcons"));
- tool_button[SpatialEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_icon("Ungroup", "EditorIcons"));
-
- tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_icon("Object", "EditorIcons"));
- tool_option_button[SpatialEditor::TOOL_OPT_USE_SNAP]->set_icon(get_icon("Snap", "EditorIcons"));
-
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_icon("Panels1", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_icon("Panels2", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_icon("Panels2Alt", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_icon("Panels3", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_icon("Panels3Alt", "EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_icon("Panels4", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon("ListSelect", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon("Lock", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon("Unlock", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon("Group", "EditorIcons"));
+ tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon("Ungroup", "EditorIcons"));
+
+ tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon("Object", "EditorIcons"));
+ tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon("Snap", "EditorIcons"));
+
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon("Panels1", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon("Panels2", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon("Panels2Alt", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon("Panels3", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon("Panels3Alt", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon("Panels4", "EditorIcons"));
// Update grid color by rebuilding grid.
_finish_grid();
@@ -5798,41 +5802,41 @@ void SpatialEditor::_notification(int p_what) {
}
}
-void SpatialEditor::add_control_to_menu_panel(Control *p_control) {
+void Node3DEditor::add_control_to_menu_panel(Control *p_control) {
hbc_menu->add_child(p_control);
}
-void SpatialEditor::remove_control_from_menu_panel(Control *p_control) {
+void Node3DEditor::remove_control_from_menu_panel(Control *p_control) {
hbc_menu->remove_child(p_control);
}
-void SpatialEditor::set_can_preview(Camera *p_preview) {
+void Node3DEditor::set_can_preview(Camera3D *p_preview) {
for (int i = 0; i < 4; i++) {
viewports[i]->set_can_preview(p_preview);
}
}
-VSplitContainer *SpatialEditor::get_shader_split() {
+VSplitContainer *Node3DEditor::get_shader_split() {
return shader_split;
}
-HSplitContainer *SpatialEditor::get_palette_split() {
+HSplitContainer *Node3DEditor::get_palette_split() {
return palette_split;
}
-void SpatialEditor::_request_gizmo(Object *p_obj) {
+void Node3DEditor::_request_gizmo(Object *p_obj) {
- Spatial *sp = Object::cast_to<Spatial>(p_obj);
+ Node3D *sp = Object::cast_to<Node3D>(p_obj);
if (!sp)
return;
if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_a_parent_of(sp)))) {
- Ref<EditorSpatialGizmo> seg;
+ Ref<EditorNode3DGizmo> seg;
for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) {
seg = gizmo_plugins_by_priority.write[i]->get_gizmo(sp);
@@ -5851,9 +5855,9 @@ void SpatialEditor::_request_gizmo(Object *p_obj) {
}
}
-void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
+void Node3DEditor::_toggle_maximize_view(Object *p_viewport) {
if (!p_viewport) return;
- SpatialEditorViewport *current_viewport = Object::cast_to<SpatialEditorViewport>(p_viewport);
+ Node3DEditorViewport *current_viewport = Object::cast_to<Node3DEditorViewport>(p_viewport);
if (!current_viewport) return;
int index = -1;
@@ -5896,49 +5900,49 @@ void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
}
}
-void SpatialEditor::_node_removed(Node *p_node) {
+void Node3DEditor::_node_removed(Node *p_node) {
if (p_node == selected)
selected = NULL;
}
-void SpatialEditor::_register_all_gizmos() {
- add_gizmo_plugin(Ref<CameraSpatialGizmoPlugin>(memnew(CameraSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<LightSpatialGizmoPlugin>(memnew(LightSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<AudioStreamPlayer3DSpatialGizmoPlugin>(memnew(AudioStreamPlayer3DSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<MeshInstanceSpatialGizmoPlugin>(memnew(MeshInstanceSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<SoftBodySpatialGizmoPlugin>(memnew(SoftBodySpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<Sprite3DSpatialGizmoPlugin>(memnew(Sprite3DSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<SkeletonSpatialGizmoPlugin>(memnew(SkeletonSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<Position3DSpatialGizmoPlugin>(memnew(Position3DSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<RayCastSpatialGizmoPlugin>(memnew(RayCastSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<SpringArmSpatialGizmoPlugin>(memnew(SpringArmSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<VehicleWheelSpatialGizmoPlugin>(memnew(VehicleWheelSpatialGizmoPlugin)));
+void Node3DEditor::_register_all_gizmos() {
+ add_gizmo_plugin(Ref<CameraNode3DGizmoPlugin>(memnew(CameraNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<LightNode3DGizmoPlugin>(memnew(LightNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<AudioStreamPlayer3DNode3DGizmoPlugin>(memnew(AudioStreamPlayer3DNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<MeshInstanceNode3DGizmoPlugin>(memnew(MeshInstanceNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<SoftBodyNode3DGizmoPlugin>(memnew(SoftBodyNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<Sprite3DNode3DGizmoPlugin>(memnew(Sprite3DNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<SkeletonNode3DGizmoPlugin>(memnew(SkeletonNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<Position3DNode3DGizmoPlugin>(memnew(Position3DNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<RayCastNode3DGizmoPlugin>(memnew(RayCastNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<SpringArmNode3DGizmoPlugin>(memnew(SpringArmNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<VehicleWheelNode3DGizmoPlugin>(memnew(VehicleWheelNode3DGizmoPlugin)));
add_gizmo_plugin(Ref<VisibilityNotifierGizmoPlugin>(memnew(VisibilityNotifierGizmoPlugin)));
add_gizmo_plugin(Ref<ParticlesGizmoPlugin>(memnew(ParticlesGizmoPlugin)));
add_gizmo_plugin(Ref<CPUParticlesGizmoPlugin>(memnew(CPUParticlesGizmoPlugin)));
add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin)));
add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin)));
// add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin)));
- add_gizmo_plugin(Ref<CollisionShapeSpatialGizmoPlugin>(memnew(CollisionShapeSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<CollisionPolygonSpatialGizmoPlugin>(memnew(CollisionPolygonSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<NavigationMeshSpatialGizmoPlugin>(memnew(NavigationMeshSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<JointSpatialGizmoPlugin>(memnew(JointSpatialGizmoPlugin)));
- add_gizmo_plugin(Ref<PhysicalBoneSpatialGizmoPlugin>(memnew(PhysicalBoneSpatialGizmoPlugin)));
+ add_gizmo_plugin(Ref<CollisionShapeNode3DGizmoPlugin>(memnew(CollisionShapeNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<CollisionPolygonNode3DGizmoPlugin>(memnew(CollisionPolygonNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<NavigationMeshNode3DGizmoPlugin>(memnew(NavigationMeshNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<JointNode3DGizmoPlugin>(memnew(JointNode3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<PhysicalBoneNode3DGizmoPlugin>(memnew(PhysicalBoneNode3DGizmoPlugin)));
}
-void SpatialEditor::_bind_methods() {
+void Node3DEditor::_bind_methods() {
- ClassDB::bind_method("_unhandled_key_input", &SpatialEditor::_unhandled_key_input);
- ClassDB::bind_method("_get_editor_data", &SpatialEditor::_get_editor_data);
- ClassDB::bind_method("_request_gizmo", &SpatialEditor::_request_gizmo);
+ ClassDB::bind_method("_unhandled_key_input", &Node3DEditor::_unhandled_key_input);
+ ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data);
+ ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo);
ADD_SIGNAL(MethodInfo("transform_key_request"));
ADD_SIGNAL(MethodInfo("item_lock_status_changed"));
ADD_SIGNAL(MethodInfo("item_group_status_changed"));
}
-void SpatialEditor::clear() {
+void Node3DEditor::clear() {
settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0));
settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05));
@@ -5948,25 +5952,25 @@ void SpatialEditor::clear() {
viewports[i]->reset();
}
- VisualServer::get_singleton()->instance_set_visible(origin_instance, true);
+ RenderingServer::get_singleton()->instance_set_visible(origin_instance, true);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true);
for (int i = 0; i < 3; ++i) {
if (grid_enable[i]) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], true);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], true);
grid_visible[i] = true;
}
}
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
- viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
+ viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(Node3DEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
viewports[i]->viewport->set_as_audio_listener(i == 0);
}
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true);
}
-SpatialEditor::SpatialEditor(EditorNode *p_editor) {
+Node3DEditor::Node3DEditor(EditorNode *p_editor) {
gizmo.visible = true;
gizmo.scale = 1.0;
@@ -6000,7 +6004,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_SELECT]->set_flat(true);
tool_button[TOOL_MODE_SELECT]->set_pressed(true);
button_binds.write[0] = MENU_TOOL_SELECT;
- tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q));
tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection"));
@@ -6011,7 +6015,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_MOVE]->set_toggle_mode(true);
tool_button[TOOL_MODE_MOVE]->set_flat(true);
button_binds.write[0] = MENU_TOOL_MOVE;
- tool_button[TOOL_MODE_MOVE]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_MODE_MOVE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_MOVE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_move", TTR("Move Mode"), KEY_W));
tool_button[TOOL_MODE_ROTATE] = memnew(ToolButton);
@@ -6019,7 +6023,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_ROTATE]->set_toggle_mode(true);
tool_button[TOOL_MODE_ROTATE]->set_flat(true);
button_binds.write[0] = MENU_TOOL_ROTATE;
- tool_button[TOOL_MODE_ROTATE]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_MODE_ROTATE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_ROTATE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Rotate Mode"), KEY_E));
tool_button[TOOL_MODE_SCALE] = memnew(ToolButton);
@@ -6027,7 +6031,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_SCALE]->set_toggle_mode(true);
tool_button[TOOL_MODE_SCALE]->set_flat(true);
button_binds.write[0] = MENU_TOOL_SCALE;
- tool_button[TOOL_MODE_SCALE]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_MODE_SCALE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_SCALE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_scale", TTR("Scale Mode"), KEY_R));
hbc_menu->add_child(memnew(VSeparator));
@@ -6037,31 +6041,31 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true);
tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true);
button_binds.write[0] = MENU_TOOL_LIST_SELECT;
- tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode)."));
tool_button[TOOL_LOCK_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_LOCK_SELECTED]);
button_binds.write[0] = MENU_LOCK_SELECTED;
- tool_button[TOOL_LOCK_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_LOCK_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock the selected object in place (can't be moved)."));
tool_button[TOOL_UNLOCK_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_UNLOCK_SELECTED]);
button_binds.write[0] = MENU_UNLOCK_SELECTED;
- tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock the selected object (can be moved)."));
tool_button[TOOL_GROUP_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_GROUP_SELECTED]);
button_binds.write[0] = MENU_GROUP_SELECTED;
- tool_button[TOOL_GROUP_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_GROUP_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_GROUP_SELECTED]->set_tooltip(TTR("Makes sure the object's children are not selectable."));
tool_button[TOOL_UNGROUP_SELECTED] = memnew(ToolButton);
hbc_menu->add_child(tool_button[TOOL_UNGROUP_SELECTED]);
button_binds.write[0] = MENU_UNGROUP_SELECTED;
- tool_button[TOOL_UNGROUP_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds);
+ tool_button[TOOL_UNGROUP_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds);
tool_button[TOOL_UNGROUP_SELECTED]->set_tooltip(TTR("Restores the object's children's ability to be selected."));
hbc_menu->add_child(memnew(VSeparator));
@@ -6071,7 +6075,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_toggle_mode(true);
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_flat(true);
button_binds.write[0] = MENU_TOOL_LOCAL_COORDS;
- tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds);
+ tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds);
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), KEY_T));
tool_option_button[TOOL_OPT_USE_SNAP] = memnew(ToolButton);
@@ -6079,7 +6083,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_option_button[TOOL_OPT_USE_SNAP]->set_toggle_mode(true);
tool_option_button[TOOL_OPT_USE_SNAP]->set_flat(true);
button_binds.write[0] = MENU_TOOL_USE_SNAP;
- tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds);
+ tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds);
tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), KEY_Y));
hbc_menu->add_child(memnew(VSeparator));
@@ -6090,13 +6094,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_flat(true);
tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_disabled(true);
button_binds.write[0] = MENU_TOOL_OVERRIDE_CAMERA;
- tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds);
+ tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds);
_update_camera_override_button(false);
hbc_menu->add_child(memnew(VSeparator));
// Drag and drop support;
- preview_node = memnew(Spatial);
+ preview_node = memnew(Node3D);
preview_bounds = AABB();
ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7);
@@ -6127,7 +6131,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap...")), MENU_TRANSFORM_CONFIGURE_SNAP);
- p->connect("id_pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed));
+ p->connect("id_pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed));
view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
@@ -6159,13 +6163,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->set_item_checked(p->get_item_index(MENU_VIEW_ORIGIN), true);
p->set_item_checked(p->get_item_index(MENU_VIEW_GRID), true);
- p->connect("id_pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed));
+ p->connect("id_pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed));
gizmos_menu = memnew(PopupMenu);
p->add_child(gizmos_menu);
gizmos_menu->set_name("GizmosMenu");
gizmos_menu->set_hide_on_checkable_item_selection(false);
- gizmos_menu->connect("id_pressed", callable_mp(this, &SpatialEditor::_menu_gizmo_toggled));
+ gizmos_menu->connect("id_pressed", callable_mp(this, &Node3DEditor::_menu_gizmo_toggled));
/* REST OF MENU */
@@ -6176,14 +6180,14 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
shader_split = memnew(VSplitContainer);
shader_split->set_h_size_flags(SIZE_EXPAND_FILL);
palette_split->add_child(shader_split);
- viewport_base = memnew(SpatialEditorViewportContainer);
+ viewport_base = memnew(Node3DEditorViewportContainer);
shader_split->add_child(viewport_base);
viewport_base->set_v_size_flags(SIZE_EXPAND_FILL);
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
- viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
- viewports[i]->connect("toggle_maximize_view", callable_mp(this, &SpatialEditor::_toggle_maximize_view));
- viewports[i]->connect("clicked", callable_mp(this, &SpatialEditor::_update_camera_override_viewport));
+ viewports[i] = memnew(Node3DEditorViewport(this, editor, i));
+ viewports[i]->connect("toggle_maximize_view", callable_mp(this, &Node3DEditor::_toggle_maximize_view));
+ viewports[i]->connect("clicked", callable_mp(this, &Node3DEditor::_update_camera_override_viewport));
viewports[i]->assign_pending_data_pointers(preview_node, &preview_bounds, accept);
viewport_base->add_child(viewports[i]);
}
@@ -6197,8 +6201,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
snap_dialog = memnew(ConfirmationDialog);
snap_dialog->set_title(TTR("Snap Settings"));
add_child(snap_dialog);
- snap_dialog->connect("confirmed", callable_mp(this, &SpatialEditor::_snap_changed));
- snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &SpatialEditor::_snap_update));
+ snap_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_snap_changed));
+ snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &Node3DEditor::_snap_update));
VBoxContainer *snap_dialog_vbc = memnew(VBoxContainer);
snap_dialog->add_child(snap_dialog_vbc);
@@ -6245,7 +6249,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar);
for (uint32_t i = 0; i < VIEWPORTS_COUNT; ++i) {
- settings_dialog->connect("confirmed", callable_mp(viewports[i], &SpatialEditorViewport::_update_camera), varray(0.0));
+ settings_dialog->connect("confirmed", callable_mp(viewports[i], &Node3DEditorViewport::_update_camera), varray(0.0));
}
/* XFORM DIALOG */
@@ -6307,9 +6311,9 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
xform_type->add_item(TTR("Post"));
xform_vbc->add_child(xform_type);
- xform_dialog->connect("confirmed", callable_mp(this, &SpatialEditor::_xform_dialog_action));
+ xform_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_xform_dialog_action));
- scenario_debug = VisualServer::SCENARIO_DEBUG_DISABLED;
+ scenario_debug = RenderingServer::SCENARIO_DEBUG_DISABLED;
selected = NULL;
@@ -6325,11 +6329,11 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
over_gizmo_handle = -1;
}
-SpatialEditor::~SpatialEditor() {
+Node3DEditor::~Node3DEditor() {
memdelete(preview_node);
}
-void SpatialEditorPlugin::make_visible(bool p_visible) {
+void Node3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
@@ -6342,31 +6346,31 @@ void SpatialEditorPlugin::make_visible(bool p_visible) {
spatial_editor->set_process(false);
}
}
-void SpatialEditorPlugin::edit(Object *p_object) {
+void Node3DEditorPlugin::edit(Object *p_object) {
- spatial_editor->edit(Object::cast_to<Spatial>(p_object));
+ spatial_editor->edit(Object::cast_to<Node3D>(p_object));
}
-bool SpatialEditorPlugin::handles(Object *p_object) const {
+bool Node3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Spatial");
+ return p_object->is_class("Node3D");
}
-Dictionary SpatialEditorPlugin::get_state() const {
+Dictionary Node3DEditorPlugin::get_state() const {
return spatial_editor->get_state();
}
-void SpatialEditorPlugin::set_state(const Dictionary &p_state) {
+void Node3DEditorPlugin::set_state(const Dictionary &p_state) {
spatial_editor->set_state(p_state);
}
-void SpatialEditor::snap_cursor_to_plane(const Plane &p_plane) {
+void Node3DEditor::snap_cursor_to_plane(const Plane &p_plane) {
//cursor.pos=p_plane.project(cursor.pos);
}
-Vector3 SpatialEditor::snap_point(Vector3 p_target, Vector3 p_start) const {
+Vector3 Node3DEditor::snap_point(Vector3 p_target, Vector3 p_start) const {
if (is_snap_enabled()) {
p_target.x = Math::snap_scalar(0.0, get_translate_snap(), p_target.x);
p_target.y = Math::snap_scalar(0.0, get_translate_snap(), p_target.y);
@@ -6375,9 +6379,9 @@ Vector3 SpatialEditor::snap_point(Vector3 p_target, Vector3 p_start) const {
return p_target;
}
-float SpatialEditor::get_translate_snap() const {
+float Node3DEditor::get_translate_snap() const {
float snap_value;
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
snap_value = snap_translate->get_text().to_double() / 10.0;
} else {
snap_value = snap_translate->get_text().to_double();
@@ -6386,9 +6390,9 @@ float SpatialEditor::get_translate_snap() const {
return snap_value;
}
-float SpatialEditor::get_rotate_snap() const {
+float Node3DEditor::get_rotate_snap() const {
float snap_value;
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
snap_value = snap_rotate->get_text().to_double() / 3.0;
} else {
snap_value = snap_rotate->get_text().to_double();
@@ -6397,9 +6401,9 @@ float SpatialEditor::get_rotate_snap() const {
return snap_value;
}
-float SpatialEditor::get_scale_snap() const {
+float Node3DEditor::get_scale_snap() const {
float snap_value;
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
snap_value = snap_scale->get_text().to_double() / 2.0;
} else {
snap_value = snap_scale->get_text().to_double();
@@ -6408,19 +6412,19 @@ float SpatialEditor::get_scale_snap() const {
return snap_value;
}
-void SpatialEditorPlugin::_bind_methods() {
+void Node3DEditorPlugin::_bind_methods() {
- ClassDB::bind_method("snap_cursor_to_plane", &SpatialEditorPlugin::snap_cursor_to_plane);
+ ClassDB::bind_method("snap_cursor_to_plane", &Node3DEditorPlugin::snap_cursor_to_plane);
}
-void SpatialEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) {
+void Node3DEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) {
spatial_editor->snap_cursor_to_plane(p_plane);
}
struct _GizmoPluginPriorityComparator {
- bool operator()(const Ref<EditorSpatialGizmoPlugin> &p_a, const Ref<EditorSpatialGizmoPlugin> &p_b) const {
+ bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const {
if (p_a->get_priority() == p_b->get_priority()) {
return p_a->get_name() < p_b->get_name();
}
@@ -6430,12 +6434,12 @@ struct _GizmoPluginPriorityComparator {
struct _GizmoPluginNameComparator {
- bool operator()(const Ref<EditorSpatialGizmoPlugin> &p_a, const Ref<EditorSpatialGizmoPlugin> &p_b) const {
+ bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const {
return p_a->get_name() < p_b->get_name();
}
};
-void SpatialEditor::add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) {
+void Node3DEditor::add_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {
ERR_FAIL_NULL(p_plugin.ptr());
gizmo_plugins_by_priority.push_back(p_plugin);
@@ -6445,19 +6449,19 @@ void SpatialEditor::add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) {
gizmo_plugins_by_name.sort_custom<_GizmoPluginNameComparator>();
_update_gizmos_menu();
- SpatialEditor::get_singleton()->update_all_gizmos();
+ Node3DEditor::get_singleton()->update_all_gizmos();
}
-void SpatialEditor::remove_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) {
+void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {
gizmo_plugins_by_priority.erase(p_plugin);
gizmo_plugins_by_name.erase(p_plugin);
_update_gizmos_menu();
}
-SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
+Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- spatial_editor = memnew(SpatialEditor(p_node));
+ spatial_editor = memnew(Node3DEditor(p_node));
spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->get_viewport()->add_child(spatial_editor);
@@ -6465,10 +6469,10 @@ SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
spatial_editor->connect_compat("transform_key_request", editor->get_inspector_dock(), "_transform_keyed");
}
-SpatialEditorPlugin::~SpatialEditorPlugin() {
+Node3DEditorPlugin::~Node3DEditorPlugin() {
}
-void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) {
+void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) {
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
@@ -6510,7 +6514,7 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
materials[p_name] = mats;
}
-void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) {
+void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) {
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
@@ -6551,12 +6555,12 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const
materials[p_name] = icons;
}
-void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) {
+void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) {
Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
- Ref<Texture2D> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
+ Ref<Texture2D> handle_t = Node3DEditor::get_singleton()->get_theme_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle_t->get_width());
handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t);
handle_material->set_albedo(Color(1, 1, 1));
@@ -6573,12 +6577,12 @@ void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool
materials[p_name].push_back(handle_material);
}
-void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) {
+void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) {
materials[p_name] = Vector<Ref<StandardMaterial3D>>();
materials[p_name].push_back(p_material);
}
-Ref<StandardMaterial3D> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) {
+Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo) {
ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>());
ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>());
@@ -6597,27 +6601,27 @@ Ref<StandardMaterial3D> EditorSpatialGizmoPlugin::get_material(const String &p_n
return mat;
}
-String EditorSpatialGizmoPlugin::get_name() const {
+String EditorNode3DGizmoPlugin::get_name() const {
if (get_script_instance() && get_script_instance()->has_method("get_name")) {
return get_script_instance()->call("get_name");
}
return TTR("Nameless gizmo");
}
-int EditorSpatialGizmoPlugin::get_priority() const {
+int EditorNode3DGizmoPlugin::get_priority() const {
if (get_script_instance() && get_script_instance()->has_method("get_priority")) {
return get_script_instance()->call("get_priority");
}
return 0;
}
-Ref<EditorSpatialGizmo> EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) {
+Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) {
if (get_script_instance() && get_script_instance()->has_method("get_gizmo")) {
return get_script_instance()->call("get_gizmo", p_spatial);
}
- Ref<EditorSpatialGizmo> ref = create_gizmo(p_spatial);
+ Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial);
if (ref.is_null()) return ref;
@@ -6629,18 +6633,18 @@ Ref<EditorSpatialGizmo> EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial)
return ref;
}
-void EditorSpatialGizmoPlugin::_bind_methods() {
-#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorSpatialGizmo")
+void EditorNode3DGizmoPlugin::_bind_methods() {
+#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorNode3DGizmo")
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial")));
- BIND_VMETHOD(MethodInfo(GIZMO_REF, "create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D")));
+ BIND_VMETHOD(MethodInfo(GIZMO_REF, "create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D")));
- ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorSpatialGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorSpatialGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1)));
- ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard"), &EditorSpatialGizmoPlugin::create_handle_material, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorSpatialGizmoPlugin::add_material);
+ ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material);
- ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorSpatialGizmoPlugin::get_material); //, DEFVAL(Ref<EditorSpatialGizmo>()));
+ ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material); //, DEFVAL(Ref<EditorNode3DGizmo>()));
BIND_VMETHOD(MethodInfo(Variant::STRING, "get_name"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "get_priority"));
@@ -6654,7 +6658,7 @@ void EditorSpatialGizmoPlugin::_bind_methods() {
hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(hvget);
- BIND_VMETHOD(MethodInfo("set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point")));
+ BIND_VMETHOD(MethodInfo("set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point")));
MethodInfo cm = MethodInfo("commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
cm.default_arguments.push_back(false);
BIND_VMETHOD(cm);
@@ -6664,103 +6668,103 @@ void EditorSpatialGizmoPlugin::_bind_methods() {
#undef GIZMO_REF
}
-bool EditorSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
+bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
if (get_script_instance() && get_script_instance()->has_method("has_gizmo")) {
return get_script_instance()->call("has_gizmo", p_spatial);
}
return false;
}
-Ref<EditorSpatialGizmo> EditorSpatialGizmoPlugin::create_gizmo(Spatial *p_spatial) {
+Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
if (get_script_instance() && get_script_instance()->has_method("create_gizmo")) {
return get_script_instance()->call("create_gizmo", p_spatial);
}
- Ref<EditorSpatialGizmo> ref;
+ Ref<EditorNode3DGizmo> ref;
if (has_gizmo(p_spatial)) ref.instance();
return ref;
}
-bool EditorSpatialGizmoPlugin::can_be_hidden() const {
+bool EditorNode3DGizmoPlugin::can_be_hidden() const {
if (get_script_instance() && get_script_instance()->has_method("can_be_hidden")) {
return get_script_instance()->call("can_be_hidden");
}
return true;
}
-bool EditorSpatialGizmoPlugin::is_selectable_when_hidden() const {
+bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const {
if (get_script_instance() && get_script_instance()->has_method("is_selectable_when_hidden")) {
return get_script_instance()->call("is_selectable_when_hidden");
}
return false;
}
-void EditorSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
if (get_script_instance() && get_script_instance()->has_method("redraw")) {
- Ref<EditorSpatialGizmo> ref(p_gizmo);
+ Ref<EditorNode3DGizmo> ref(p_gizmo);
get_script_instance()->call("redraw", ref);
}
}
-String EditorSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String EditorNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) {
return get_script_instance()->call("get_handle_name", p_gizmo, p_idx);
}
return "";
}
-Variant EditorSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant EditorNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) {
return get_script_instance()->call("get_handle_value", p_gizmo, p_idx);
}
return Variant();
}
-void EditorSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void EditorNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
if (get_script_instance() && get_script_instance()->has_method("set_handle")) {
get_script_instance()->call("set_handle", p_gizmo, p_idx, p_camera, p_point);
}
}
-void EditorSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void EditorNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
if (get_script_instance() && get_script_instance()->has_method("commit_handle")) {
get_script_instance()->call("commit_handle", p_gizmo, p_idx, p_restore, p_cancel);
}
}
-bool EditorSpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) {
return get_script_instance()->call("is_handle_highlighted", p_gizmo, p_idx);
}
return false;
}
-void EditorSpatialGizmoPlugin::set_state(int p_state) {
+void EditorNode3DGizmoPlugin::set_state(int p_state) {
current_state = p_state;
for (int i = 0; i < current_gizmos.size(); ++i) {
current_gizmos[i]->set_hidden(current_state == HIDDEN);
}
}
-int EditorSpatialGizmoPlugin::get_state() const {
+int EditorNode3DGizmoPlugin::get_state() const {
return current_state;
}
-void EditorSpatialGizmoPlugin::unregister_gizmo(EditorSpatialGizmo *p_gizmo) {
+void EditorNode3DGizmoPlugin::unregister_gizmo(EditorNode3DGizmo *p_gizmo) {
current_gizmos.erase(p_gizmo);
}
-EditorSpatialGizmoPlugin::EditorSpatialGizmoPlugin() {
+EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() {
current_state = VISIBLE;
}
-EditorSpatialGizmoPlugin::~EditorSpatialGizmoPlugin() {
+EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() {
for (int i = 0; i < current_gizmos.size(); ++i) {
current_gizmos[i]->set_plugin(NULL);
current_gizmos[i]->get_spatial_node()->set_gizmo(NULL);
}
- if (SpatialEditor::get_singleton()) {
- SpatialEditor::get_singleton()->update_all_gizmos();
+ if (Node3DEditor::get_singleton()) {
+ Node3DEditor::get_singleton()->update_all_gizmos();
}
}
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index b67459b9d0..4b9f5a605b 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial_editor_plugin.h */
+/* node_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,20 +34,20 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "editor/editor_scale.h"
-#include "scene/3d/immediate_geometry.h"
-#include "scene/3d/light.h"
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/immediate_geometry_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/gui/panel_container.h"
-class Camera;
-class SpatialEditor;
-class EditorSpatialGizmoPlugin;
-class SpatialEditorViewport;
+class Camera3D;
+class Node3DEditor;
+class EditorNode3DGizmoPlugin;
+class Node3DEditorViewport;
class ViewportContainer;
-class EditorSpatialGizmo : public SpatialGizmo {
+class EditorNode3DGizmo : public Node3DGizmo {
- GDCLASS(EditorSpatialGizmo, SpatialGizmo);
+ GDCLASS(EditorNode3DGizmo, Node3DGizmo);
bool selected;
bool instanced;
@@ -75,7 +75,7 @@ public:
extra_margin = false;
}
- void create_instance(Spatial *p_base, bool p_hidden = false);
+ void create_instance(Node3D *p_base, bool p_hidden = false);
};
Vector<Vector3> collision_segments;
@@ -93,12 +93,12 @@ public:
bool valid;
bool hidden;
- Spatial *base;
+ Node3D *base;
Vector<Instance> instances;
- Spatial *spatial_node;
- EditorSpatialGizmoPlugin *gizmo_plugin;
+ Node3D *spatial_node;
+ EditorNode3DGizmoPlugin *gizmo_plugin;
- void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Spatial>(p_node)); }
+ void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); }
protected:
static void _bind_methods();
@@ -115,15 +115,15 @@ public:
virtual bool is_handle_highlighted(int p_idx) const;
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx);
- virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
- void set_spatial_node(Spatial *p_node);
- Spatial *get_spatial_node() const { return spatial_node; }
- Ref<EditorSpatialGizmoPlugin> get_plugin() const { return gizmo_plugin; }
+ void set_spatial_node(Node3D *p_node);
+ Node3D *get_spatial_node() const { return spatial_node; }
+ Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; }
Vector3 get_handle_pos(int p_idx) const;
- bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
- bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
+ bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum);
+ bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
virtual void clear();
virtual void create();
@@ -134,10 +134,10 @@ public:
virtual bool is_editable() const;
void set_hidden(bool p_hidden);
- void set_plugin(EditorSpatialGizmoPlugin *p_plugin);
+ void set_plugin(EditorNode3DGizmoPlugin *p_plugin);
- EditorSpatialGizmo();
- ~EditorSpatialGizmo();
+ EditorNode3DGizmo();
+ ~EditorNode3DGizmo();
};
class ViewportRotationControl : public Control {
@@ -155,7 +155,7 @@ class ViewportRotationControl : public Control {
}
};
- SpatialEditorViewport *viewport = nullptr;
+ Node3DEditorViewport *viewport = nullptr;
Vector<Color> axis_colors;
Vector<int> axis_menu_options;
bool orbiting = false;
@@ -174,13 +174,13 @@ protected:
void _on_mouse_exited();
public:
- void set_viewport(SpatialEditorViewport *p_viewport);
+ void set_viewport(Node3DEditorViewport *p_viewport);
};
-class SpatialEditorViewport : public Control {
+class Node3DEditorViewport : public Control {
- GDCLASS(SpatialEditorViewport, Control);
- friend class SpatialEditor;
+ GDCLASS(Node3DEditorViewport, Control);
+ friend class Node3DEditor;
friend class ViewportRotationControl;
enum {
@@ -242,7 +242,7 @@ private:
String name;
void _menu_option(int p_option);
void _set_auto_orthogonal();
- Spatial *preview_node;
+ Node3D *preview_node;
AABB *preview_bounds;
Vector<String> selected_files;
AcceptDialog *accept;
@@ -262,8 +262,8 @@ private:
PopupMenu *display_submenu;
Control *surface;
- Viewport *viewport;
- Camera *camera;
+ SubViewport *viewport;
+ Camera3D *camera;
bool transforming;
bool orthogonal;
bool auto_orthogonal;
@@ -284,7 +284,7 @@ private:
struct _RayResult {
- Spatial *item;
+ Node3D *item;
float depth;
int handle;
_FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; }
@@ -366,7 +366,7 @@ private:
int edited_gizmo;
Point2 mouse_pos;
bool snap;
- Ref<EditorSpatialGizmo> gizmo;
+ Ref<EditorNode3DGizmo> gizmo;
int gizmo_handle;
Variant gizmo_initial_value;
Vector3 gizmo_initial_pos;
@@ -418,10 +418,10 @@ private:
void _sinput(const Ref<InputEvent> &p_event);
void _update_freelook(real_t delta);
- SpatialEditor *spatial_editor;
+ Node3DEditor *spatial_editor;
- Camera *previewing;
- Camera *preview;
+ Camera3D *previewing;
+ Camera3D *preview;
bool previewing_cinema;
bool _is_node_locked(const Node *p_node);
@@ -436,7 +436,7 @@ private:
Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const;
Vector3 _get_instance_position(const Point2 &p_pos) const;
- static AABB _calculate_spatial_bounds(const Spatial *p_parent, bool p_exclude_toplevel_transform = true);
+ static AABB _calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_toplevel_transform = true);
void _create_preview(const Vector<String> &files) const;
void _remove_preview();
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
@@ -454,7 +454,7 @@ public:
void update_surface() { surface->update(); }
void update_transform_gizmo_view();
- void set_can_preview(Camera *p_preview);
+ void set_can_preview(Camera3D *p_preview);
void set_state(const Dictionary &p_state);
Dictionary get_state() const;
void reset();
@@ -463,19 +463,19 @@ public:
void focus_selection();
void assign_pending_data_pointers(
- Spatial *p_preview_node,
+ Node3D *p_preview_node,
AABB *p_preview_bounds,
AcceptDialog *p_accept);
- Viewport *get_viewport_node() { return viewport; }
- Camera *get_camera() { return camera; } // return the default camera object.
+ SubViewport *get_viewport_node() { return viewport; }
+ Camera3D *get_camera() { return camera; } // return the default camera object.
- SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
+ Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
};
-class SpatialEditorSelectedItem : public Object {
+class Node3DEditorSelectedItem : public Object {
- GDCLASS(SpatialEditorSelectedItem, Object);
+ GDCLASS(Node3DEditorSelectedItem, Object);
public:
AABB aabb;
@@ -483,19 +483,19 @@ public:
Transform original_local;
Transform last_xform; // last transform
bool last_xform_dirty;
- Spatial *sp;
+ Node3D *sp;
RID sbox_instance;
- SpatialEditorSelectedItem() {
+ Node3DEditorSelectedItem() {
sp = NULL;
last_xform_dirty = true;
}
- ~SpatialEditorSelectedItem();
+ ~Node3DEditorSelectedItem();
};
-class SpatialEditorViewportContainer : public Container {
+class Node3DEditorViewportContainer : public Container {
- GDCLASS(SpatialEditorViewportContainer, Container);
+ GDCLASS(Node3DEditorViewportContainer, Container);
public:
enum View {
@@ -531,12 +531,12 @@ public:
void set_view(View p_view);
View get_view();
- SpatialEditorViewportContainer();
+ Node3DEditorViewportContainer();
};
-class SpatialEditor : public VBoxContainer {
+class Node3DEditor : public VBoxContainer {
- GDCLASS(SpatialEditor, VBoxContainer);
+ GDCLASS(Node3DEditor, VBoxContainer);
public:
static const unsigned int VIEWPORTS_COUNT = 4;
@@ -568,8 +568,8 @@ private:
EditorNode *editor;
EditorSelection *editor_selection;
- SpatialEditorViewportContainer *viewport_base;
- SpatialEditorViewport *viewports[VIEWPORTS_COUNT];
+ Node3DEditorViewportContainer *viewport_base;
+ Node3DEditorViewport *viewports[VIEWPORTS_COUNT];
VSplitContainer *shader_split;
HSplitContainer *palette_split;
@@ -578,7 +578,7 @@ private:
ToolMode tool_mode;
bool orthogonal;
- VisualServer::ScenarioDebugMode scenario_debug;
+ RenderingServer::ScenarioDebugMode scenario_debug;
RID origin;
RID origin_instance;
@@ -609,7 +609,7 @@ private:
Ref<StandardMaterial3D> cursor_material;
// Scene drag and drop support
- Spatial *preview_node;
+ Node3D *preview_node;
AABB preview_bounds;
struct Gizmo {
@@ -709,19 +709,19 @@ private:
Ref<Environment> viewport_environment;
- Spatial *selected;
+ Node3D *selected;
void _request_gizmo(Object *p_obj);
- static SpatialEditor *singleton;
+ static Node3DEditor *singleton;
void _node_removed(Node *p_node);
- Vector<Ref<EditorSpatialGizmoPlugin>> gizmo_plugins_by_priority;
- Vector<Ref<EditorSpatialGizmoPlugin>> gizmo_plugins_by_name;
+ Vector<Ref<EditorNode3DGizmoPlugin>> gizmo_plugins_by_priority;
+ Vector<Ref<EditorNode3DGizmoPlugin>> gizmo_plugins_by_name;
void _register_all_gizmos();
- SpatialEditor();
+ Node3DEditor();
bool is_any_freelook_active() const;
@@ -735,7 +735,7 @@ protected:
static void _bind_methods();
public:
- static SpatialEditor *get_singleton() { return singleton; }
+ static Node3DEditor *get_singleton() { return singleton; }
void snap_cursor_to_plane(const Plane &p_plane);
Vector3 snap_point(Vector3 p_target, Vector3 p_start = Vector3(0, 0, 0)) const;
@@ -748,7 +748,7 @@ public:
bool is_gizmo_visible() const { return gizmo.visible; }
ToolMode get_tool_mode() const { return tool_mode; }
- bool are_local_coords_enabled() const { return tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->is_pressed(); }
+ bool are_local_coords_enabled() const { return tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->is_pressed(); }
bool is_snap_enabled() const { return snap_enabled ^ snap_key_enabled; }
float get_translate_snap() const;
float get_rotate_snap() const;
@@ -780,33 +780,33 @@ public:
VSplitContainer *get_shader_split();
HSplitContainer *get_palette_split();
- Spatial *get_selected() { return selected; }
+ Node3D *get_selected() { return selected; }
int get_over_gizmo_handle() const { return over_gizmo_handle; }
void set_over_gizmo_handle(int idx) { over_gizmo_handle = idx; }
- void set_can_preview(Camera *p_preview);
+ void set_can_preview(Camera3D *p_preview);
- SpatialEditorViewport *get_editor_viewport(int p_idx) {
+ Node3DEditorViewport *get_editor_viewport(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, static_cast<int>(VIEWPORTS_COUNT), NULL);
return viewports[p_idx];
}
- void add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin);
- void remove_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin);
+ void add_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin);
+ void remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin);
- void edit(Spatial *p_spatial);
+ void edit(Node3D *p_spatial);
void clear();
- SpatialEditor(EditorNode *p_editor);
- ~SpatialEditor();
+ Node3DEditor(EditorNode *p_editor);
+ ~Node3DEditor();
};
-class SpatialEditorPlugin : public EditorPlugin {
+class Node3DEditorPlugin : public EditorPlugin {
- GDCLASS(SpatialEditorPlugin, EditorPlugin);
+ GDCLASS(Node3DEditorPlugin, EditorPlugin);
- SpatialEditor *spatial_editor;
+ Node3DEditor *spatial_editor;
EditorNode *editor;
protected:
@@ -815,7 +815,7 @@ protected:
public:
void snap_cursor_to_plane(const Plane &p_plane);
- SpatialEditor *get_spatial_editor() { return spatial_editor; }
+ Node3DEditor *get_spatial_editor() { return spatial_editor; }
virtual String get_name() const { return "3D"; }
bool has_main_screen() const { return true; }
virtual void make_visible(bool p_visible);
@@ -828,13 +828,13 @@ public:
virtual void edited_scene_changed();
- SpatialEditorPlugin(EditorNode *p_node);
- ~SpatialEditorPlugin();
+ Node3DEditorPlugin(EditorNode *p_node);
+ ~Node3DEditorPlugin();
};
-class EditorSpatialGizmoPlugin : public Resource {
+class EditorNode3DGizmoPlugin : public Resource {
- GDCLASS(EditorSpatialGizmoPlugin, Resource);
+ GDCLASS(EditorNode3DGizmoPlugin, Resource);
public:
static const int VISIBLE = 0;
@@ -843,13 +843,13 @@ public:
private:
int current_state;
- List<EditorSpatialGizmo *> current_gizmos;
+ List<EditorNode3DGizmo *> current_gizmos;
HashMap<String, Vector<Ref<StandardMaterial3D>>> materials;
protected:
static void _bind_methods();
- virtual bool has_gizmo(Spatial *p_spatial);
- virtual Ref<EditorSpatialGizmo> create_gizmo(Spatial *p_spatial);
+ virtual bool has_gizmo(Node3D *p_spatial);
+ virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial);
public:
void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false);
@@ -857,27 +857,27 @@ public:
void create_handle_material(const String &p_name, bool p_billboard = false);
void add_material(const String &p_name, Ref<StandardMaterial3D> p_material);
- Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>());
+ Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo = Ref<EditorNode3DGizmo>());
virtual String get_name() const;
virtual int get_priority() const;
virtual bool can_be_hidden() const;
virtual bool is_selectable_when_hidden() const;
- virtual void redraw(EditorSpatialGizmo *p_gizmo);
- virtual String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
- virtual bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
+ virtual void redraw(EditorNode3DGizmo *p_gizmo);
+ virtual String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ virtual Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ virtual void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ virtual void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
+ virtual bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
- Ref<EditorSpatialGizmo> get_gizmo(Spatial *p_spatial);
+ Ref<EditorNode3DGizmo> get_gizmo(Node3D *p_spatial);
void set_state(int p_state);
int get_state() const;
- void unregister_gizmo(EditorSpatialGizmo *p_gizmo);
+ void unregister_gizmo(EditorNode3DGizmo *p_gizmo);
- EditorSpatialGizmoPlugin();
- virtual ~EditorSpatialGizmoPlugin();
+ EditorNode3DGizmoPlugin();
+ virtual ~EditorNode3DGizmoPlugin();
};
#endif
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 165df6b500..75c5fcb994 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -373,12 +373,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- const Ref<Texture2D> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons");
- const Ref<Texture2D> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons");
+ const Ref<Texture2D> path_sharp_handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons");
+ const Ref<Texture2D> path_smooth_handle = get_theme_icon("EditorPathSmoothHandle", "EditorIcons");
// Both handle icons must be of the same size
const Size2 handle_size = path_sharp_handle->get_size();
- const Ref<Texture2D> curve_handle = get_icon("EditorCurveHandle", "EditorIcons");
+ const Ref<Texture2D> curve_handle = get_theme_icon("EditorCurveHandle", "EditorIcons");
const Size2 curve_handle_size = curve_handle->get_size();
Ref<Curve2D> curve = node->get_curve();
@@ -420,7 +420,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
if (on_edge) {
- Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
+ Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5);
}
}
@@ -548,35 +548,35 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
sep = memnew(VSeparator);
base_hb->add_child(sep);
curve_edit = memnew(ToolButton);
- curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
+ curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons"));
curve_edit->set_toggle_mode(true);
curve_edit->set_focus_mode(Control::FOCUS_NONE);
curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Left Click: Split Segment (in curve)") + "\n" + TTR("Right Click: Delete Point"));
curve_edit->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_EDIT));
base_hb->add_child(curve_edit);
curve_edit_curve = memnew(ToolButton);
- curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve", "EditorIcons"));
+ curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCurve", "EditorIcons"));
curve_edit_curve->set_toggle_mode(true);
curve_edit_curve->set_focus_mode(Control::FOCUS_NONE);
curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)"));
curve_edit_curve->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_EDIT_CURVE));
base_hb->add_child(curve_edit_curve);
curve_create = memnew(ToolButton);
- curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
+ curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons"));
curve_create->set_toggle_mode(true);
curve_create->set_focus_mode(Control::FOCUS_NONE);
curve_create->set_tooltip(TTR("Add Point (in empty space)"));
curve_create->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_CREATE));
base_hb->add_child(curve_create);
curve_del = memnew(ToolButton);
- curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
+ curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons"));
curve_del->set_toggle_mode(true);
curve_del->set_focus_mode(Control::FOCUS_NONE);
curve_del->set_tooltip(TTR("Delete Point"));
curve_del->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_DELETE));
base_hb->add_child(curve_del);
curve_close = memnew(ToolButton);
- curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons"));
+ curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons"));
curve_close->set_focus_mode(Control::FOCUS_NONE);
curve_close->set_tooltip(TTR("Close Curve"));
curve_close->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(ACTION_CLOSE));
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index 42b1045666..f3729a3e89 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path_editor_plugin.cpp */
+/* path_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "path_editor_plugin.h"
+#include "path_3d_editor_plugin.h"
#include "core/os/keyboard.h"
+#include "node_3d_editor_plugin.h"
#include "scene/resources/curve.h"
-#include "spatial_editor_plugin.h"
-String PathSpatialGizmo::get_handle_name(int p_idx) const {
+String PathNode3DGizmo::get_handle_name(int p_idx) const {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
@@ -57,7 +57,7 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const {
return n;
}
-Variant PathSpatialGizmo::get_handle_value(int p_idx) {
+Variant PathNode3DGizmo::get_handle_value(int p_idx) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
@@ -84,7 +84,7 @@ Variant PathSpatialGizmo::get_handle_value(int p_idx) {
return ofs;
}
-void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
+void PathNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
@@ -104,8 +104,8 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- float snap = SpatialEditor::get_singleton()->get_translate_snap();
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ float snap = Node3DEditor::get_singleton()->get_translate_snap();
inters.snap(Vector3(snap, snap, snap));
}
@@ -130,37 +130,37 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p
// Setting curve in/out positions
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
- if (!PathEditorPlugin::singleton->is_handle_clicked()) {
+ if (!Path3DEditorPlugin::singleton->is_handle_clicked()) {
orig_in_length = c->get_point_in(idx).length();
orig_out_length = c->get_point_out(idx).length();
- PathEditorPlugin::singleton->set_handle_clicked(true);
+ Path3DEditorPlugin::singleton->set_handle_clicked(true);
}
Vector3 local = gi.xform(inters) - base;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- float snap = SpatialEditor::get_singleton()->get_translate_snap();
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ float snap = Node3DEditor::get_singleton()->get_translate_snap();
local.snap(Vector3(snap, snap, snap));
}
if (t == 0) {
c->set_point_in(idx, local);
- if (PathEditorPlugin::singleton->mirror_angle_enabled())
- c->set_point_out(idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length));
+ if (Path3DEditorPlugin::singleton->mirror_angle_enabled())
+ c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length));
} else {
c->set_point_out(idx, local);
- if (PathEditorPlugin::singleton->mirror_angle_enabled())
- c->set_point_in(idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_in_length));
+ if (Path3DEditorPlugin::singleton->mirror_angle_enabled())
+ c->set_point_in(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_in_length));
}
}
}
-void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
+void PathNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
return;
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx < c->get_point_count()) {
@@ -192,9 +192,9 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p
ur->add_do_method(c.ptr(), "set_point_in", idx, c->get_point_in(idx));
ur->add_undo_method(c.ptr(), "set_point_in", idx, p_restore);
- if (PathEditorPlugin::singleton->mirror_angle_enabled()) {
- ur->add_do_method(c.ptr(), "set_point_out", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_in(idx) : (-c->get_point_in(idx).normalized() * orig_out_length));
- ur->add_undo_method(c.ptr(), "set_point_out", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_out_length));
+ if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
+ ur->add_do_method(c.ptr(), "set_point_out", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_in(idx) : (-c->get_point_in(idx).normalized() * orig_out_length));
+ ur->add_undo_method(c.ptr(), "set_point_out", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_out_length));
}
ur->commit_action();
@@ -209,15 +209,15 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p
ur->add_do_method(c.ptr(), "set_point_out", idx, c->get_point_out(idx));
ur->add_undo_method(c.ptr(), "set_point_out", idx, p_restore);
- if (PathEditorPlugin::singleton->mirror_angle_enabled()) {
- ur->add_do_method(c.ptr(), "set_point_in", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_out(idx) : (-c->get_point_out(idx).normalized() * orig_in_length));
- ur->add_undo_method(c.ptr(), "set_point_in", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_in_length));
+ if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
+ ur->add_do_method(c.ptr(), "set_point_in", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_out(idx) : (-c->get_point_out(idx).normalized() * orig_in_length));
+ ur->add_undo_method(c.ptr(), "set_point_in", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_in_length));
}
ur->commit_action();
}
}
-void PathSpatialGizmo::redraw() {
+void PathNode3DGizmo::redraw() {
clear();
@@ -252,7 +252,7 @@ void PathSpatialGizmo::redraw() {
add_collision_segments(v3p);
}
- if (PathEditorPlugin::singleton->get_edited_path() == path) {
+ if (Path3DEditorPlugin::singleton->get_edited_path() == path) {
v3p.clear();
Vector<Vector3> handles;
Vector<Vector3> sec_handles;
@@ -286,13 +286,13 @@ void PathSpatialGizmo::redraw() {
}
}
-PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
+PathNode3DGizmo::PathNode3DGizmo(Path3D *p_path) {
path = p_path;
set_spatial_node(p_path);
}
-bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!path)
return false;
@@ -448,10 +448,10 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
return false;
}
-void PathEditorPlugin::edit(Object *p_object) {
+void Path3DEditorPlugin::edit(Object *p_object) {
if (p_object) {
- path = Object::cast_to<Path>(p_object);
+ path = Object::cast_to<Path3D>(p_object);
if (path) {
if (path->get_curve().is_valid()) {
@@ -459,7 +459,7 @@ void PathEditorPlugin::edit(Object *p_object) {
}
}
} else {
- Path *pre = path;
+ Path3D *pre = path;
path = NULL;
if (pre) {
pre->get_curve()->emit_signal("changed");
@@ -468,12 +468,12 @@ void PathEditorPlugin::edit(Object *p_object) {
//collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
-bool PathEditorPlugin::handles(Object *p_object) const {
+bool Path3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Path");
+ return p_object->is_class("Path3D");
}
-void PathEditorPlugin::make_visible(bool p_visible) {
+void Path3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
@@ -493,7 +493,7 @@ void PathEditorPlugin::make_visible(bool p_visible) {
sep->hide();
{
- Path *pre = path;
+ Path3D *pre = path;
path = NULL;
if (pre && pre->get_curve().is_valid()) {
pre->get_curve()->emit_signal("changed");
@@ -502,14 +502,14 @@ void PathEditorPlugin::make_visible(bool p_visible) {
}
}
-void PathEditorPlugin::_mode_changed(int p_idx) {
+void Path3DEditorPlugin::_mode_changed(int p_idx) {
curve_create->set_pressed(p_idx == 0);
curve_edit->set_pressed(p_idx == 1);
curve_del->set_pressed(p_idx == 2);
}
-void PathEditorPlugin::_close_curve() {
+void Path3DEditorPlugin::_close_curve() {
Ref<Curve3D> c = path->get_curve();
if (c.is_null())
@@ -519,7 +519,7 @@ void PathEditorPlugin::_close_curve() {
c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0));
}
-void PathEditorPlugin::_handle_option_pressed(int p_option) {
+void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
PopupMenu *pm;
pm = handle_menu->get_popup();
@@ -539,23 +539,23 @@ void PathEditorPlugin::_handle_option_pressed(int p_option) {
}
}
-void PathEditorPlugin::_notification(int p_what) {
+void Path3DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- curve_create->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(0));
- curve_edit->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(1));
- curve_del->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(2));
- curve_close->connect("pressed", callable_mp(this, &PathEditorPlugin::_close_curve));
+ curve_create->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(0));
+ curve_edit->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(1));
+ curve_del->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(2));
+ curve_close->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_close_curve));
}
}
-void PathEditorPlugin::_bind_methods() {
+void Path3DEditorPlugin::_bind_methods() {
}
-PathEditorPlugin *PathEditorPlugin::singleton = NULL;
+Path3DEditorPlugin *Path3DEditorPlugin::singleton = NULL;
-PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
+Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) {
path = NULL;
editor = p_node;
@@ -563,54 +563,54 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
mirror_handle_angle = true;
mirror_handle_length = true;
- Ref<PathSpatialGizmoPlugin> gizmo_plugin;
+ Ref<PathNode3DGizmoPlugin> gizmo_plugin;
gizmo_plugin.instance();
- SpatialEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
+ Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
sep = memnew(VSeparator);
sep->hide();
- SpatialEditor::get_singleton()->add_control_to_menu_panel(sep);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(sep);
curve_edit = memnew(ToolButton);
- curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
+ curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons"));
curve_edit->set_toggle_mode(true);
curve_edit->hide();
curve_edit->set_focus_mode(Control::FOCUS_NONE);
curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point"));
- SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_edit);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_edit);
curve_create = memnew(ToolButton);
- curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
+ curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons"));
curve_create->set_toggle_mode(true);
curve_create->hide();
curve_create->set_focus_mode(Control::FOCUS_NONE);
curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)"));
- SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_create);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_create);
curve_del = memnew(ToolButton);
- curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
+ curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons"));
curve_del->set_toggle_mode(true);
curve_del->hide();
curve_del->set_focus_mode(Control::FOCUS_NONE);
curve_del->set_tooltip(TTR("Delete Point"));
- SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_del);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_del);
curve_close = memnew(ToolButton);
- curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons"));
+ curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons"));
curve_close->hide();
curve_close->set_focus_mode(Control::FOCUS_NONE);
curve_close->set_tooltip(TTR("Close Curve"));
- SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_close);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_close);
PopupMenu *menu;
handle_menu = memnew(MenuButton);
handle_menu->set_text(TTR("Options"));
handle_menu->hide();
- SpatialEditor::get_singleton()->add_control_to_menu_panel(handle_menu);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(handle_menu);
menu = handle_menu->get_popup();
menu->add_check_item(TTR("Mirror Handle Angles"));
menu->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle);
menu->add_check_item(TTR("Mirror Handle Lengths"));
menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
- menu->connect("id_pressed", callable_mp(this, &PathEditorPlugin::_handle_option_pressed));
+ menu->connect("id_pressed", callable_mp(this, &Path3DEditorPlugin::_handle_option_pressed));
curve_edit->set_pressed(true);
/*
@@ -624,27 +624,27 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
*/
}
-PathEditorPlugin::~PathEditorPlugin() {
+Path3DEditorPlugin::~Path3DEditorPlugin() {
}
-Ref<EditorSpatialGizmo> PathSpatialGizmoPlugin::create_gizmo(Spatial *p_spatial) {
- Ref<PathSpatialGizmo> ref;
+Ref<EditorNode3DGizmo> PathNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
+ Ref<PathNode3DGizmo> ref;
- Path *path = Object::cast_to<Path>(p_spatial);
- if (path) ref = Ref<PathSpatialGizmo>(memnew(PathSpatialGizmo(path)));
+ Path3D *path = Object::cast_to<Path3D>(p_spatial);
+ if (path) ref = Ref<PathNode3DGizmo>(memnew(PathNode3DGizmo(path)));
return ref;
}
-String PathSpatialGizmoPlugin::get_name() const {
+String PathNode3DGizmoPlugin::get_name() const {
return "Path";
}
-int PathSpatialGizmoPlugin::get_priority() const {
+int PathNode3DGizmoPlugin::get_priority() const {
return -1;
}
-PathSpatialGizmoPlugin::PathSpatialGizmoPlugin() {
+PathNode3DGizmoPlugin::PathNode3DGizmoPlugin() {
Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8));
create_material("path_material", path_color);
diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h
index 8ff83911f8..ca051295f0 100644
--- a/editor/plugins/path_editor_plugin.h
+++ b/editor/plugins/path_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path_editor_plugin.h */
+/* path_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,14 +31,14 @@
#ifndef PATH_EDITOR_PLUGIN_H
#define PATH_EDITOR_PLUGIN_H
-#include "editor/spatial_editor_gizmos.h"
-#include "scene/3d/path.h"
+#include "editor/node_3d_editor_gizmos.h"
+#include "scene/3d/path_3d.h"
-class PathSpatialGizmo : public EditorSpatialGizmo {
+class PathNode3DGizmo : public EditorNode3DGizmo {
- GDCLASS(PathSpatialGizmo, EditorSpatialGizmo);
+ GDCLASS(PathNode3DGizmo, EditorNode3DGizmo);
- Path *path;
+ Path3D *path;
mutable Vector3 original;
mutable float orig_in_length;
mutable float orig_out_length;
@@ -46,29 +46,29 @@ class PathSpatialGizmo : public EditorSpatialGizmo {
public:
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx);
- virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
virtual void redraw();
- PathSpatialGizmo(Path *p_path = NULL);
+ PathNode3DGizmo(Path3D *p_path = NULL);
};
-class PathSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
+class PathNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
- GDCLASS(PathSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
+ GDCLASS(PathNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
protected:
- Ref<EditorSpatialGizmo> create_gizmo(Spatial *p_spatial);
+ Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial);
public:
String get_name() const;
int get_priority() const;
- PathSpatialGizmoPlugin();
+ PathNode3DGizmoPlugin();
};
-class PathEditorPlugin : public EditorPlugin {
+class Path3DEditorPlugin : public EditorPlugin {
- GDCLASS(PathEditorPlugin, EditorPlugin);
+ GDCLASS(Path3DEditorPlugin, EditorPlugin);
Separator *sep;
ToolButton *curve_create;
@@ -79,7 +79,7 @@ class PathEditorPlugin : public EditorPlugin {
EditorNode *editor;
- Path *path;
+ Path3D *path;
void _mode_changed(int p_idx);
void _close_curve();
@@ -98,13 +98,13 @@ protected:
static void _bind_methods();
public:
- Path *get_edited_path() { return path; }
+ Path3D *get_edited_path() { return path; }
- static PathEditorPlugin *singleton;
- virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
+ static Path3DEditorPlugin *singleton;
+ virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
//virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
- //virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
+ //virtual Ref<Node3DEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
virtual String get_name() const { return "Path"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
@@ -116,8 +116,8 @@ public:
bool is_handle_clicked() { return handle_clicked; }
void set_handle_clicked(bool clicked) { handle_clicked = clicked; }
- PathEditorPlugin(EditorNode *p_node);
- ~PathEditorPlugin();
+ Path3DEditorPlugin(EditorNode *p_node);
+ ~Path3DEditorPlugin();
};
#endif // PATH_EDITOR_PLUGIN_H
diff --git a/editor/plugins/physical_bone_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp
index e0d48afeef..dd6d7b109b 100644
--- a/editor/plugins/physical_bone_plugin.cpp
+++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physical_bone_plugin.cpp */
+/* physical_bone_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,32 +28,33 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physical_bone_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/3d/physics_body.h"
+#include "physical_bone_3d_editor_plugin.h"
-void PhysicalBoneEditor::_bind_methods() {
+#include "editor/plugins/node_3d_editor_plugin.h"
+#include "scene/3d/physics_body_3d.h"
+
+void PhysicalBone3DEditor::_bind_methods() {
}
-void PhysicalBoneEditor::_on_toggle_button_transform_joint(bool p_is_pressed) {
+void PhysicalBone3DEditor::_on_toggle_button_transform_joint(bool p_is_pressed) {
_set_move_joint();
}
-void PhysicalBoneEditor::_set_move_joint() {
+void PhysicalBone3DEditor::_set_move_joint() {
if (selected) {
selected->_set_gizmo_move_joint(button_transform_joint->is_pressed());
}
}
-PhysicalBoneEditor::PhysicalBoneEditor(EditorNode *p_editor) :
+PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) :
editor(p_editor),
selected(NULL) {
spatial_editor_hb = memnew(HBoxContainer);
spatial_editor_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
spatial_editor_hb->add_child(memnew(VSeparator));
@@ -61,16 +62,16 @@ PhysicalBoneEditor::PhysicalBoneEditor(EditorNode *p_editor) :
spatial_editor_hb->add_child(button_transform_joint);
button_transform_joint->set_text(TTR("Move Joint"));
- button_transform_joint->set_icon(SpatialEditor::get_singleton()->get_icon("PhysicalBone", "EditorIcons"));
+ button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon("PhysicalBone3D", "EditorIcons"));
button_transform_joint->set_toggle_mode(true);
- button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBoneEditor::_on_toggle_button_transform_joint));
+ button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint));
hide();
}
-PhysicalBoneEditor::~PhysicalBoneEditor() {}
+PhysicalBone3DEditor::~PhysicalBone3DEditor() {}
-void PhysicalBoneEditor::set_selected(PhysicalBone *p_pb) {
+void PhysicalBone3DEditor::set_selected(PhysicalBone3D *p_pb) {
button_transform_joint->set_pressed(false);
@@ -79,20 +80,20 @@ void PhysicalBoneEditor::set_selected(PhysicalBone *p_pb) {
_set_move_joint();
}
-void PhysicalBoneEditor::hide() {
+void PhysicalBone3DEditor::hide() {
spatial_editor_hb->hide();
}
-void PhysicalBoneEditor::show() {
+void PhysicalBone3DEditor::show() {
spatial_editor_hb->show();
}
-PhysicalBonePlugin::PhysicalBonePlugin(EditorNode *p_editor) :
+PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin(EditorNode *p_editor) :
editor(p_editor),
selected(NULL),
physical_bone_editor(editor) {}
-void PhysicalBonePlugin::make_visible(bool p_visible) {
+void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
physical_bone_editor.show();
@@ -104,8 +105,8 @@ void PhysicalBonePlugin::make_visible(bool p_visible) {
}
}
-void PhysicalBonePlugin::edit(Object *p_node) {
- selected = static_cast<PhysicalBone *>(p_node); // Trust it
+void PhysicalBone3DEditorPlugin::edit(Object *p_node) {
+ selected = static_cast<PhysicalBone3D *>(p_node); // Trust it
ERR_FAIL_COND(!selected);
physical_bone_editor.set_selected(selected);
diff --git a/editor/plugins/physical_bone_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h
index 459a67db05..74932710d6 100644
--- a/editor/plugins/physical_bone_plugin.h
+++ b/editor/plugins/physical_bone_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physical_bone_plugin.h */
+/* physical_bone_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,14 +33,14 @@
#include "editor/editor_node.h"
-class PhysicalBoneEditor : public Object {
- GDCLASS(PhysicalBoneEditor, Object);
+class PhysicalBone3DEditor : public Object {
+ GDCLASS(PhysicalBone3DEditor, Object);
EditorNode *editor;
HBoxContainer *spatial_editor_hb;
ToolButton *button_transform_joint;
- PhysicalBone *selected;
+ PhysicalBone3D *selected;
protected:
static void _bind_methods();
@@ -50,29 +50,29 @@ private:
void _set_move_joint();
public:
- PhysicalBoneEditor(EditorNode *p_editor);
- ~PhysicalBoneEditor();
+ PhysicalBone3DEditor(EditorNode *p_editor);
+ ~PhysicalBone3DEditor();
- void set_selected(PhysicalBone *p_pb);
+ void set_selected(PhysicalBone3D *p_pb);
void hide();
void show();
};
-class PhysicalBonePlugin : public EditorPlugin {
- GDCLASS(PhysicalBonePlugin, EditorPlugin);
+class PhysicalBone3DEditorPlugin : public EditorPlugin {
+ GDCLASS(PhysicalBone3DEditorPlugin, EditorPlugin);
EditorNode *editor;
- PhysicalBone *selected;
- PhysicalBoneEditor physical_bone_editor;
+ PhysicalBone3D *selected;
+ PhysicalBone3DEditor physical_bone_editor;
public:
- virtual String get_name() const { return "PhysicalBone"; }
- virtual bool handles(Object *p_object) const { return p_object->is_class("PhysicalBone"); }
+ virtual String get_name() const { return "PhysicalBone3D"; }
+ virtual bool handles(Object *p_object) const { return p_object->is_class("PhysicalBone3D"); }
virtual void make_visible(bool p_visible);
virtual void edit(Object *p_node);
- PhysicalBonePlugin(EditorNode *p_editor);
+ PhysicalBone3DEditorPlugin(EditorNode *p_editor);
};
#endif
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 8c115586a4..f570baa885 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -31,8 +31,8 @@
#include "polygon_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/os/file_access.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
@@ -70,28 +70,28 @@ void Polygon2DEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- uv_edit_draw->add_style_override("panel", get_stylebox("bg", "Tree"));
- bone_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
+ uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ bone_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
- button_uv->set_icon(get_icon("Uv", "EditorIcons"));
+ button_uv->set_icon(get_theme_icon("Uv", "EditorIcons"));
- uv_button[UV_MODE_CREATE]->set_icon(get_icon("Edit", "EditorIcons"));
- uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_icon("EditInternal", "EditorIcons"));
- uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_icon("RemoveInternal", "EditorIcons"));
- uv_button[UV_MODE_EDIT_POINT]->set_icon(get_icon("ToolSelect", "EditorIcons"));
- uv_button[UV_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons"));
- uv_button[UV_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons"));
- uv_button[UV_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons"));
- uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_icon("Edit", "EditorIcons"));
- uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_icon("Close", "EditorIcons"));
- uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_icon("PaintVertex", "EditorIcons"));
- uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_icon("UnpaintVertex", "EditorIcons"));
+ uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon("Edit", "EditorIcons"));
+ uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_theme_icon("EditInternal", "EditorIcons"));
+ uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_theme_icon("RemoveInternal", "EditorIcons"));
+ uv_button[UV_MODE_EDIT_POINT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ uv_button[UV_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons"));
+ uv_button[UV_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons"));
+ uv_button[UV_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons"));
+ uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_theme_icon("Edit", "EditorIcons"));
+ uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_theme_icon("Close", "EditorIcons"));
+ uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_theme_icon("PaintVertex", "EditorIcons"));
+ uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon("UnpaintVertex", "EditorIcons"));
- b_snap_grid->set_icon(get_icon("Grid", "EditorIcons"));
- b_snap_enable->set_icon(get_icon("SnapGrid", "EditorIcons"));
- uv_icon_zoom->set_texture(get_icon("Zoom", "EditorIcons"));
+ b_snap_grid->set_icon(get_theme_icon("Grid", "EditorIcons"));
+ b_snap_enable->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
+ uv_icon_zoom->set_texture(get_theme_icon("Zoom", "EditorIcons"));
uv_vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
@@ -110,7 +110,7 @@ void Polygon2DEditor::_sync_bones() {
Skeleton2D *skeleton = NULL;
if (!node->has_node(node->get_skeleton())) {
error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node"));
- error->popup_centered_minsize();
+ error->popup_centered();
} else {
Node *sn = node->get_node(node->get_skeleton());
skeleton = Object::cast_to<Skeleton2D>(sn);
@@ -121,7 +121,7 @@ void Polygon2DEditor::_sync_bones() {
if (!skeleton) {
error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node"));
- error->popup_centered_minsize();
+ error->popup_centered();
} else {
for (int i = 0; i < skeleton->get_bone_count(); i++) {
NodePath path = skeleton->get_path_to(skeleton->get_bone(i));
@@ -275,7 +275,7 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
void Polygon2DEditor::_uv_edit_popup_hide() {
- EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", uv_edit->get_rect());
+ EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", Rect2(uv_edit->get_position(), uv_edit->get_size()));
_cancel_editing();
}
@@ -289,7 +289,7 @@ void Polygon2DEditor::_menu_option(int p_option) {
if (node->get_texture().is_null()) {
error->set_text(TTR("No texture in this polygon.\nSet a texture to be able to edit UV."));
- error->popup_centered_minsize();
+ error->popup_centered();
return;
}
@@ -351,7 +351,7 @@ void Polygon2DEditor::_menu_option(int p_option) {
} break;
case UVEDIT_GRID_SETTINGS: {
- grid_settings->popup_centered_minsize();
+ grid_settings->popup_centered();
} break;
default: {
@@ -683,7 +683,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
//close
if (polygon_create.size() < 3) {
error->set_text(TTR("Invalid Polygon (need 3 different vertices)"));
- error->popup_centered_minsize();
+ error->popup_centered();
} else {
Array polygons = node->get_polygons();
polygons = polygons.duplicate(); //copy because its a reference
@@ -810,7 +810,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
- if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
@@ -990,9 +990,9 @@ void Polygon2DEditor::_uv_draw() {
mtx.elements[2] = -uv_draw_ofs;
mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom));
- VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx);
+ RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx);
uv_edit_draw->draw_texture(base_tex, Point2());
- VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D());
+ RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D());
if (snap_show_grid) {
Color grid_color = Color(1.0, 1.0, 1.0, 0.15);
@@ -1050,7 +1050,7 @@ void Polygon2DEditor::_uv_draw() {
}
// All UV points are sharp, so use the sharp handle icon
- Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
+ Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons");
Color poly_line_color = Color(0.9, 0.5, 0.5);
if (polygons.size() || polygon_create.size()) {
@@ -1265,8 +1265,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_edit = memnew(AcceptDialog);
add_child(uv_edit);
uv_edit->set_title(TTR("Polygon 2D UV Editor"));
- uv_edit->set_resizable(true);
- uv_edit->connect("popup_hide", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
+ uv_edit->connect("cancelled", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
VBoxContainer *uv_main_vb = memnew(VBoxContainer);
uv_edit->add_child(uv_main_vb);
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index feef505acc..8def56f968 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -41,7 +41,7 @@ void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) {
void ResourcePreloaderEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- load->set_icon(get_icon("Folder", "EditorIcons"));
+ load->set_icon(get_theme_icon("Folder", "EditorIcons"));
}
if (p_what == NOTIFICATION_READY) {
@@ -67,7 +67,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths)
dialog->set_title(TTR("Error!"));
//dialog->get_cancel()->set_text("Close");
dialog->get_ok()->set_text(TTR("Close"));
- dialog->popup_centered_minsize();
+ dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -98,7 +98,7 @@ void ResourcePreloaderEditor::_load_pressed() {
for (int i = 0; i < extensions.size(); i++)
file->add_filter("*." + extensions[i]);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILES);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
file->popup_centered_ratio();
}
@@ -152,7 +152,7 @@ void ResourcePreloaderEditor::_paste_pressed() {
dialog->set_text(TTR("Resource clipboard is empty!"));
dialog->set_title(TTR("Error!"));
dialog->get_ok()->set_text(TTR("Close"));
- dialog->popup_centered_minsize();
+ dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -215,11 +215,11 @@ void ResourcePreloaderEditor::_update_library() {
ti->set_selectable(1, false);
if (type == "PackedScene") {
- ti->add_button(1, get_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor"));
+ ti->add_button(1, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor"));
} else {
- ti->add_button(1, get_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor"));
+ ti->add_button(1, get_theme_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor"));
}
- ti->add_button(1, get_icon("Remove", "EditorIcons"), BUTTON_REMOVE, false, TTR("Remove"));
+ ti->add_button(1, get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE, false, TTR("Remove"));
}
//player->add_resource("default",resource);
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index d932305c63..516c52a8a4 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -30,7 +30,7 @@
#include "root_motion_editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void EditorPropertyRootMotion::_confirmed() {
@@ -128,7 +128,7 @@ void EditorPropertyRootMotion::_node_assign() {
String concat = path.get_concatenated_subnames();
- Skeleton *skeleton = Object::cast_to<Skeleton>(node);
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
if (skeleton && skeleton->find_bone(concat) != -1) {
//path in skeleton
const String &bone = concat;
@@ -152,7 +152,7 @@ void EditorPropertyRootMotion::_node_assign() {
ti->set_text(0, F->get());
ti->set_selectable(0, true);
ti->set_editable(0, false);
- ti->set_icon(0, get_icon("BoneAttachment", "EditorIcons"));
+ ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons"));
ti->set_metadata(0, accum);
} else {
ti = parenthood[accum];
@@ -161,7 +161,7 @@ void EditorPropertyRootMotion::_node_assign() {
ti->set_selectable(0, true);
ti->set_text(0, concat);
- ti->set_icon(0, get_icon("BoneAttachment", "EditorIcons"));
+ ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons"));
ti->set_metadata(0, path);
if (path == current) {
ti->select(0);
@@ -242,7 +242,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) {
void EditorPropertyRootMotion::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- Ref<Texture2D> t = get_icon("Clear", "EditorIcons");
+ Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons");
clear->set_icon(t);
}
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index b3f78b5406..0e867f7b16 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -30,9 +30,9 @@
#include "script_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
#include "core/os/file_access.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@@ -45,9 +45,10 @@
#include "editor/find_in_files.h"
#include "editor/node_dock.h"
#include "editor/plugins/shader_editor_plugin.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
#include "script_text_editor.h"
+#include "servers/display_server.h"
#include "text_editor.h"
/*** SCRIPT EDITOR ****/
@@ -215,8 +216,8 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
search_box->set_clear_button_enabled(true);
[[fallthrough]];
}
- case NOTIFICATION_THEME_CHANGED: {
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons"));
} break;
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
@@ -246,7 +247,7 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() {
search_options->connect("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
- search_options->add_constant_override("draw_guides", 1);
+ search_options->add_theme_constant_override("draw_guides", 1);
}
/////////////////////////////////
@@ -428,7 +429,7 @@ void ScriptEditor::_go_to_tab(int p_idx) {
if (Object::cast_to<ScriptEditorBase>(c)) {
script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
- script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_icon());
+ script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_theme_icon());
if (is_visible_in_tree())
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
@@ -442,7 +443,7 @@ void ScriptEditor::_go_to_tab(int p_idx) {
if (Object::cast_to<EditorHelp>(c)) {
script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class());
- script_icon->set_texture(get_icon("Help", "EditorIcons"));
+ script_icon->set_texture(get_theme_icon("Help", "EditorIcons"));
if (is_visible_in_tree())
Object::cast_to<EditorHelp>(c)->set_focused();
}
@@ -556,7 +557,7 @@ void ScriptEditor::_open_recent_script(int p_idx) {
void ScriptEditor::_show_error_dialog(String p_path) {
error_dialog->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_path));
- error_dialog->popup_centered_minsize();
+ error_dialog->popup_centered();
}
void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
@@ -651,7 +652,7 @@ void ScriptEditor::_close_docs_tab() {
void ScriptEditor::_copy_script_path() {
ScriptEditorBase *se = _get_current_editor();
RES script = se->get_edited_resource();
- OS::get_singleton()->set_clipboard(script->get_path());
+ DisplayServer::get_singleton()->clipboard_set(script->get_path());
}
void ScriptEditor::_close_other_tabs() {
@@ -703,7 +704,7 @@ void ScriptEditor::_close_all_tabs() {
void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) {
erase_tab_confirm->set_text(TTR("Close and save changes?") + "\n\"" + current->get_name() + "\"");
- erase_tab_confirm->popup_centered_minsize();
+ erase_tab_confirm->popup_centered();
}
void ScriptEditor::_resave_scripts(const String &p_str) {
@@ -995,7 +996,7 @@ void ScriptEditor::_menu_option(int p_option) {
script_create_dialog->popup_centered();
} break;
case FILE_NEW_TEXTFILE: {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog_option = FILE_NEW_TEXTFILE;
@@ -1004,7 +1005,7 @@ void ScriptEditor::_menu_option(int p_option) {
file_dialog->set_title(TTR("New Text File..."));
} break;
case FILE_OPEN: {
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog_option = FILE_OPEN;
@@ -1169,7 +1170,7 @@ void ScriptEditor::_menu_option(int p_option) {
Ref<TextFile> text_file = current->get_edited_resource();
if (text_file != NULL) {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog_option = FILE_SAVE_AS;
@@ -1335,7 +1336,7 @@ void ScriptEditor::_menu_option(int p_option) {
void ScriptEditor::_theme_option(int p_option) {
switch (p_option) {
case THEME_IMPORT: {
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog_option = THEME_IMPORT;
file_dialog->clear_filters();
@@ -1360,7 +1361,7 @@ void ScriptEditor::_theme_option(int p_option) {
}
void ScriptEditor::_show_save_theme_as_dialog() {
- file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog_option = THEME_SAVE_AS;
file_dialog->clear_filters();
@@ -1395,19 +1396,19 @@ void ScriptEditor::_notification(int p_what) {
}
case NOTIFICATION_THEME_CHANGED: {
- help_search->set_icon(get_icon("HelpSearch", "EditorIcons"));
- site_search->set_icon(get_icon("Instance", "EditorIcons"));
- request_docs->set_icon(get_icon("Issue", "EditorIcons"));
+ help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons"));
+ site_search->set_icon(get_theme_icon("Instance", "EditorIcons"));
+ request_docs->set_icon(get_theme_icon("Issue", "EditorIcons"));
- script_forward->set_icon(get_icon("Forward", "EditorIcons"));
- script_back->set_icon(get_icon("Back", "EditorIcons"));
+ script_forward->set_icon(get_theme_icon("Forward", "EditorIcons"));
+ script_back->set_icon(get_theme_icon("Back", "EditorIcons"));
- members_overview_alphabeta_sort_button->set_icon(get_icon("Sort", "EditorIcons"));
+ members_overview_alphabeta_sort_button->set_icon(get_theme_icon("Sort", "EditorIcons"));
- filter_scripts->set_right_icon(get_icon("Search", "EditorIcons"));
- filter_methods->set_right_icon(get_icon("Search", "EditorIcons"));
+ filter_scripts->set_right_icon(get_theme_icon("Search", "EditorIcons"));
+ filter_methods->set_right_icon(get_theme_icon("Search", "EditorIcons"));
- filename->add_style_override("normal", editor->get_gui_base()->get_stylebox("normal", "LineEdit"));
+ filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("normal", "LineEdit"));
recent_scripts->set_as_minsize();
} break;
@@ -1424,7 +1425,7 @@ void ScriptEditor::_notification(int p_what) {
editor->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
_test_script_times_on_disk();
_update_modified_scripts_for_external_editor();
@@ -1550,7 +1551,7 @@ void ScriptEditor::_help_overview_selected(int p_idx) {
void ScriptEditor::_script_selected(int p_idx) {
- grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
+ grab_focus_block = !InputFilter::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
_go_to_tab(script_list->get_item_metadata(p_idx));
grab_focus_block = false;
@@ -1717,8 +1718,8 @@ void ScriptEditor::_update_script_colors() {
bool highlight_current = EditorSettings::get_singleton()->get("text_editor/script_list/highlight_current_script");
int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size");
- Color hot_color = get_color("accent_color", "Editor");
- Color cold_color = get_color("font_color", "Editor");
+ Color hot_color = get_theme_color("accent_color", "Editor");
+ Color cold_color = get_theme_color("font_color", "Editor");
for (int i = 0; i < script_list->get_item_count(); i++) {
@@ -1775,7 +1776,7 @@ void ScriptEditor::_update_script_names() {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
- Ref<Texture2D> icon = se->get_icon();
+ Ref<Texture2D> icon = se->get_theme_icon();
String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name;
@@ -1836,7 +1837,7 @@ void ScriptEditor::_update_script_names() {
if (eh) {
String name = eh->get_class();
- Ref<Texture2D> icon = get_icon("Help", "EditorIcons");
+ Ref<Texture2D> icon = get_theme_icon("Help", "EditorIcons");
String tooltip = vformat(TTR("%s Class Reference"), name);
_ScriptEditorItemData sd;
@@ -2346,12 +2347,12 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node);
if (se) {
preview_name = se->get_name();
- preview_icon = se->get_icon();
+ preview_icon = se->get_theme_icon();
}
EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node);
if (eh) {
preview_name = eh->get_class();
- preview_icon = get_icon("Help", "EditorIcons");
+ preview_icon = get_theme_icon("Help", "EditorIcons");
}
if (!preview_icon.is_null()) {
@@ -2952,7 +2953,7 @@ void ScriptEditor::_on_find_in_files_requested(String text) {
find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::SEARCH_MODE);
find_in_files_dialog->set_search_text(text);
- find_in_files_dialog->popup_centered_minsize();
+ find_in_files_dialog->popup_centered();
}
void ScriptEditor::_on_replace_in_files_requested(String text) {
@@ -2960,7 +2961,7 @@ void ScriptEditor::_on_replace_in_files_requested(String text) {
find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::REPLACE_MODE);
find_in_files_dialog->set_search_text(text);
find_in_files_dialog->set_replace_text("");
- find_in_files_dialog->popup_centered_minsize();
+ find_in_files_dialog->popup_centered();
}
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
@@ -3111,7 +3112,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
context_menu = memnew(PopupMenu);
add_child(context_menu);
context_menu->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
- context_menu->set_hide_on_window_lose_focus(true);
overview_vbox = memnew(VBoxContainer);
overview_vbox->set_custom_minimum_size(Size2(0, 90));
@@ -3124,7 +3124,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
filename = memnew(Label);
filename->set_clip_text(true);
filename->set_h_size_flags(SIZE_EXPAND_FILL);
- filename->add_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "LineEdit"));
+ filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit"));
buttons_hbox->add_child(filename);
members_overview_alphabeta_sort_button = memnew(ToolButton);
@@ -3172,7 +3172,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
menu_hb->add_child(file_menu);
file_menu->set_text(TTR("File"));
file_menu->set_switch_on_hover(true);
- file_menu->get_popup()->set_hide_on_window_lose_focus(true);
+
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New Script...")), FILE_NEW);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New Text File...")), FILE_NEW_TEXTFILE);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open...")), FILE_OPEN);
@@ -3229,7 +3229,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
menu_hb->add_child(script_search_menu);
script_search_menu->set_text(TTR("Search"));
script_search_menu->set_switch_on_hover(true);
- script_search_menu->get_popup()->set_hide_on_window_lose_focus(true);
script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option));
MenuButton *debug_menu = memnew(MenuButton);
@@ -3291,7 +3290,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
erase_tab_confirm = memnew(ConfirmationDialog);
erase_tab_confirm->get_ok()->set_text(TTR("Save"));
- erase_tab_confirm->add_button(TTR("Discard"), OS::get_singleton()->get_swap_ok_cancel(), "discard");
+ erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "discard");
erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab));
erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab));
add_child(erase_tab_confirm);
@@ -3325,7 +3324,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::_reload_scripts));
disk_changed->get_ok()->set_text(TTR("Reload"));
- disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");
+ disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "resave");
disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts));
}
@@ -3366,8 +3365,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
ScriptServer::edit_request_func = _open_script_request;
- add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptEditorPanel", "EditorStyles"));
- tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptEditor", "EditorStyles"));
+ add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles"));
+ tab_container->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("ScriptEditor", "EditorStyles"));
}
ScriptEditor::~ScriptEditor() {
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 81f9595264..ec598f0b42 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -92,7 +92,7 @@ public:
virtual void set_edited_resource(const RES &p_res) = 0;
virtual void reload_text() = 0;
virtual String get_name() = 0;
- virtual Ref<Texture2D> get_icon() = 0;
+ virtual Ref<Texture2D> get_theme_icon() = 0;
virtual bool is_unsaved() = 0;
virtual Variant get_edit_state() = 0;
virtual void set_edit_state(const Variant &p_state) = 0;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 176df7efb8..2e95bb92f4 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -65,7 +65,8 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n
node_item->set_editable(0, false);
node_item->set_text(1, connection.signal.get_name());
- node_item->set_icon(1, get_parent_control()->get_icon("Slot", "EditorIcons"));
+ Control *p = Object::cast_to<Control>(get_parent());
+ node_item->set_icon(1, p->get_theme_icon("Slot", "EditorIcons"));
node_item->set_selectable(1, false);
node_item->set_editable(1, false);
@@ -83,10 +84,10 @@ ConnectionInfoDialog::ConnectionInfoDialog() {
set_title(TTR("Connections to method:"));
VBoxContainer *vbc = memnew(VBoxContainer);
- vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE);
add_child(vbc);
method = memnew(Label);
@@ -101,7 +102,7 @@ ConnectionInfoDialog::ConnectionInfoDialog() {
tree->set_column_title(1, TTR("Signal"));
tree->set_column_title(2, TTR("Target"));
vbc->add_child(tree);
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tree->set_allow_rmb_select(true);
}
@@ -229,36 +230,36 @@ void ScriptTextEditor::_load_theme_settings() {
Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
Color string_color = EDITOR_GET("text_editor/highlighting/string_color");
- text_edit->add_color_override("background_color", background_color);
- text_edit->add_color_override("completion_background_color", completion_background_color);
- text_edit->add_color_override("completion_selected_color", completion_selected_color);
- text_edit->add_color_override("completion_existing_color", completion_existing_color);
- text_edit->add_color_override("completion_scroll_color", completion_scroll_color);
- text_edit->add_color_override("completion_font_color", completion_font_color);
- text_edit->add_color_override("font_color", text_color);
- text_edit->add_color_override("line_number_color", line_number_color);
- text_edit->add_color_override("safe_line_number_color", safe_line_number_color);
- text_edit->add_color_override("caret_color", caret_color);
- text_edit->add_color_override("caret_background_color", caret_background_color);
- text_edit->add_color_override("font_color_selected", text_selected_color);
- text_edit->add_color_override("selection_color", selection_color);
- text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color);
- text_edit->add_color_override("current_line_color", current_line_color);
- text_edit->add_color_override("line_length_guideline_color", line_length_guideline_color);
- text_edit->add_color_override("word_highlighted_color", word_highlighted_color);
- text_edit->add_color_override("number_color", number_color);
- text_edit->add_color_override("function_color", function_color);
- text_edit->add_color_override("member_variable_color", member_variable_color);
- text_edit->add_color_override("bookmark_color", bookmark_color);
- text_edit->add_color_override("breakpoint_color", breakpoint_color);
- text_edit->add_color_override("executing_line_color", executing_line_color);
- text_edit->add_color_override("mark_color", mark_color);
- text_edit->add_color_override("code_folding_color", code_folding_color);
- text_edit->add_color_override("search_result_color", search_result_color);
- text_edit->add_color_override("search_result_border_color", search_result_border_color);
- text_edit->add_color_override("symbol_color", symbol_color);
-
- text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6));
+ text_edit->add_theme_color_override("background_color", background_color);
+ text_edit->add_theme_color_override("completion_background_color", completion_background_color);
+ text_edit->add_theme_color_override("completion_selected_color", completion_selected_color);
+ text_edit->add_theme_color_override("completion_existing_color", completion_existing_color);
+ text_edit->add_theme_color_override("completion_scroll_color", completion_scroll_color);
+ text_edit->add_theme_color_override("completion_font_color", completion_font_color);
+ text_edit->add_theme_color_override("font_color", text_color);
+ text_edit->add_theme_color_override("line_number_color", line_number_color);
+ text_edit->add_theme_color_override("safe_line_number_color", safe_line_number_color);
+ text_edit->add_theme_color_override("caret_color", caret_color);
+ text_edit->add_theme_color_override("caret_background_color", caret_background_color);
+ text_edit->add_theme_color_override("font_color_selected", text_selected_color);
+ text_edit->add_theme_color_override("selection_color", selection_color);
+ text_edit->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
+ text_edit->add_theme_color_override("current_line_color", current_line_color);
+ text_edit->add_theme_color_override("line_length_guideline_color", line_length_guideline_color);
+ text_edit->add_theme_color_override("word_highlighted_color", word_highlighted_color);
+ text_edit->add_theme_color_override("number_color", number_color);
+ text_edit->add_theme_color_override("function_color", function_color);
+ text_edit->add_theme_color_override("member_variable_color", member_variable_color);
+ text_edit->add_theme_color_override("bookmark_color", bookmark_color);
+ text_edit->add_theme_color_override("breakpoint_color", breakpoint_color);
+ text_edit->add_theme_color_override("executing_line_color", executing_line_color);
+ text_edit->add_theme_color_override("mark_color", mark_color);
+ text_edit->add_theme_color_override("code_folding_color", code_folding_color);
+ text_edit->add_theme_color_override("search_result_color", search_result_color);
+ text_edit->add_theme_color_override("search_result_border_color", search_result_border_color);
+ text_edit->add_theme_color_override("symbol_color", symbol_color);
+
+ text_edit->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6));
colors_cache.symbol_color = symbol_color;
colors_cache.keyword_color = keyword_color;
@@ -555,10 +556,10 @@ String ScriptTextEditor::get_name() {
return name;
}
-Ref<Texture2D> ScriptTextEditor::get_icon() {
+Ref<Texture2D> ScriptTextEditor::get_theme_icon() {
- if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) {
- return get_parent_control()->get_icon(script->get_class(), "EditorIcons");
+ if (get_parent_control() && get_parent_control()->has_theme_icon(script->get_class(), "EditorIcons")) {
+ return get_parent_control()->get_theme_icon(script->get_class(), "EditorIcons");
}
return Ref<Texture2D>();
@@ -614,7 +615,7 @@ void ScriptTextEditor::_validate_script() {
String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object()));
warnings_panel->push_cell();
- warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor"));
+ warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor"));
warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.callable.get_method(), connection.signal.get_name(), source_path, target_path));
warnings_panel->pop(); // Color.
warnings_panel->pop(); // Cell.
@@ -634,7 +635,7 @@ void ScriptTextEditor::_validate_script() {
warnings_panel->push_cell();
warnings_panel->push_meta(w.line - 1);
- warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor"));
+ warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor"));
warnings_panel->add_text(TTR("Line") + " " + itos(w.line));
warnings_panel->add_text(" (" + w.string_code + "):");
warnings_panel->pop(); // Color.
@@ -821,7 +822,7 @@ void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code,
void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) {
- if (color_panel->is_visible_in_tree()) return;
+ if (color_panel->is_visible()) return;
Node *base = get_tree()->get_edited_scene_root();
if (base) {
base = _find_node_for_script(base, base, script);
@@ -1046,7 +1047,7 @@ void ScriptTextEditor::_update_connected_methods() {
String name = functions[j].get_slice(":", 0);
if (name == connection.callable.get_method()) {
line = functions[j].get_slice(":", 1).to_int();
- text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.callable.get_method());
+ text_edit->set_line_info_icon(line - 1, get_parent_control()->get_theme_icon("Slot", "EditorIcons"), connection.callable.get_method());
methods_found.insert(connection.callable.get_method());
break;
}
@@ -1779,7 +1780,7 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor = memnew(CodeTextEditor);
editor_box->add_child(code_editor);
- code_editor->add_constant_override("separation", 2);
+ code_editor->add_theme_constant_override("separation", 2);
code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
code_editor->connect("validate_script", callable_mp(this, &ScriptTextEditor::_validate_script));
code_editor->connect("load_theme_settings", callable_mp(this, &ScriptTextEditor::_load_theme_settings));
@@ -1817,7 +1818,6 @@ ScriptTextEditor::ScriptTextEditor() {
context_menu = memnew(PopupMenu);
add_child(context_menu);
context_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option));
- context_menu->set_hide_on_window_lose_focus(true);
color_panel = memnew(PopupPanel);
add_child(color_panel);
@@ -1838,7 +1838,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
- edit_menu->get_popup()->set_hide_on_window_lose_focus(true);
+
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
edit_menu->get_popup()->add_separator();
@@ -1889,7 +1889,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_hb->add_child(search_menu);
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
- search_menu->get_popup()->set_hide_on_window_lose_focus(true);
+
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV);
@@ -1918,7 +1918,7 @@ ScriptTextEditor::ScriptTextEditor() {
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
- bookmarks_menu->connect("about_to_show", callable_mp(this, &ScriptTextEditor::_update_bookmark_list));
+ bookmarks_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_bookmark_item_pressed));
breakpoints_menu = memnew(PopupMenu);
@@ -1926,7 +1926,7 @@ ScriptTextEditor::ScriptTextEditor() {
goto_menu->get_popup()->add_child(breakpoints_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Breakpoints"), "Breakpoints");
_update_breakpoint_list();
- breakpoints_menu->connect("about_to_show", callable_mp(this, &ScriptTextEditor::_update_breakpoint_list));
+ breakpoints_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_update_breakpoint_list));
breakpoints_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_breakpoint_item_pressed));
quick_open = memnew(ScriptEditorQuickOpen);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index d2f0b310e6..51ce30c831 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -201,7 +201,7 @@ public:
virtual Vector<String> get_functions();
virtual void reload_text();
virtual String get_name();
- virtual Ref<Texture2D> get_icon();
+ virtual Ref<Texture2D> get_theme_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 01b1e21153..29ebfc8f7a 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -38,7 +38,8 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/property_editor.h"
-#include "servers/visual/shader_types.h"
+#include "servers/display_server.h"
+#include "servers/rendering/shader_types.h"
/*** SHADER SCRIPT EDITOR ****/
@@ -116,49 +117,49 @@ void ShaderTextEditor::_load_theme_settings() {
Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
- get_text_edit()->add_color_override("background_color", background_color);
- get_text_edit()->add_color_override("completion_background_color", completion_background_color);
- get_text_edit()->add_color_override("completion_selected_color", completion_selected_color);
- get_text_edit()->add_color_override("completion_existing_color", completion_existing_color);
- get_text_edit()->add_color_override("completion_scroll_color", completion_scroll_color);
- get_text_edit()->add_color_override("completion_font_color", completion_font_color);
- get_text_edit()->add_color_override("font_color", text_color);
- get_text_edit()->add_color_override("line_number_color", line_number_color);
- get_text_edit()->add_color_override("caret_color", caret_color);
- get_text_edit()->add_color_override("caret_background_color", caret_background_color);
- get_text_edit()->add_color_override("font_color_selected", text_selected_color);
- get_text_edit()->add_color_override("selection_color", selection_color);
- get_text_edit()->add_color_override("brace_mismatch_color", brace_mismatch_color);
- get_text_edit()->add_color_override("current_line_color", current_line_color);
- get_text_edit()->add_color_override("line_length_guideline_color", line_length_guideline_color);
- get_text_edit()->add_color_override("word_highlighted_color", word_highlighted_color);
- get_text_edit()->add_color_override("number_color", number_color);
- get_text_edit()->add_color_override("function_color", function_color);
- get_text_edit()->add_color_override("member_variable_color", member_variable_color);
- get_text_edit()->add_color_override("mark_color", mark_color);
- get_text_edit()->add_color_override("bookmark_color", bookmark_color);
- get_text_edit()->add_color_override("breakpoint_color", breakpoint_color);
- get_text_edit()->add_color_override("executing_line_color", executing_line_color);
- get_text_edit()->add_color_override("code_folding_color", code_folding_color);
- get_text_edit()->add_color_override("search_result_color", search_result_color);
- get_text_edit()->add_color_override("search_result_border_color", search_result_border_color);
- get_text_edit()->add_color_override("symbol_color", symbol_color);
+ get_text_edit()->add_theme_color_override("background_color", background_color);
+ get_text_edit()->add_theme_color_override("completion_background_color", completion_background_color);
+ get_text_edit()->add_theme_color_override("completion_selected_color", completion_selected_color);
+ get_text_edit()->add_theme_color_override("completion_existing_color", completion_existing_color);
+ get_text_edit()->add_theme_color_override("completion_scroll_color", completion_scroll_color);
+ get_text_edit()->add_theme_color_override("completion_font_color", completion_font_color);
+ get_text_edit()->add_theme_color_override("font_color", text_color);
+ get_text_edit()->add_theme_color_override("line_number_color", line_number_color);
+ get_text_edit()->add_theme_color_override("caret_color", caret_color);
+ get_text_edit()->add_theme_color_override("caret_background_color", caret_background_color);
+ get_text_edit()->add_theme_color_override("font_color_selected", text_selected_color);
+ get_text_edit()->add_theme_color_override("selection_color", selection_color);
+ get_text_edit()->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
+ get_text_edit()->add_theme_color_override("current_line_color", current_line_color);
+ get_text_edit()->add_theme_color_override("line_length_guideline_color", line_length_guideline_color);
+ get_text_edit()->add_theme_color_override("word_highlighted_color", word_highlighted_color);
+ get_text_edit()->add_theme_color_override("number_color", number_color);
+ get_text_edit()->add_theme_color_override("function_color", function_color);
+ get_text_edit()->add_theme_color_override("member_variable_color", member_variable_color);
+ get_text_edit()->add_theme_color_override("mark_color", mark_color);
+ get_text_edit()->add_theme_color_override("bookmark_color", bookmark_color);
+ get_text_edit()->add_theme_color_override("breakpoint_color", breakpoint_color);
+ get_text_edit()->add_theme_color_override("executing_line_color", executing_line_color);
+ get_text_edit()->add_theme_color_override("code_folding_color", code_folding_color);
+ get_text_edit()->add_theme_color_override("search_result_color", search_result_color);
+ get_text_edit()->add_theme_color_override("search_result_border_color", search_result_border_color);
+ get_text_edit()->add_theme_color_override("symbol_color", symbol_color);
List<String> keywords;
ShaderLanguage::get_keyword_list(&keywords);
if (shader.is_valid()) {
- for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) {
+ for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) {
for (const Map<StringName, ShaderLanguage::BuiltInInfo>::Element *F = E->get().built_ins.front(); F; F = F->next()) {
keywords.push_back(F->key());
}
}
- for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())).size(); i++) {
+ for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())).size(); i++) {
- keywords.push_back(ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode()))[i]);
+ keywords.push_back(ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()))[i]);
}
}
@@ -199,7 +200,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
ShaderLanguage sl;
String calltip;
- sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip);
+ sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip);
get_text_edit()->set_code_hint(calltip);
}
@@ -214,7 +215,7 @@ void ShaderTextEditor::_validate_script() {
ShaderLanguage sl;
- Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types());
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types());
if (err != OK) {
String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
@@ -351,7 +352,7 @@ void ShaderEditor::_menu_option(int p_option) {
void ShaderEditor::_notification(int p_what) {
- if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == NOTIFICATION_WM_FOCUS_IN) {
_check_for_external_edit();
}
}
@@ -376,7 +377,7 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
- shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
+ shader_editor->get_text_edit()->add_theme_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
@@ -595,7 +596,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
shader_editor = memnew(ShaderTextEditor);
shader_editor->set_v_size_flags(SIZE_EXPAND_FILL);
- shader_editor->add_constant_override("separation", 0);
+ shader_editor->add_theme_constant_override("separation", 0);
shader_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
shader_editor->connect("script_changed", callable_mp(this, &ShaderEditor::apply_shaders));
@@ -614,7 +615,6 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
context_menu = memnew(PopupMenu);
add_child(context_menu);
context_menu->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
- context_menu->set_hide_on_window_lose_focus(true);
VBoxContainer *main_container = memnew(VBoxContainer);
HBoxContainer *hbc = memnew(HBoxContainer);
@@ -622,7 +622,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
- edit_menu->get_popup()->set_hide_on_window_lose_focus(true);
+
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
edit_menu->get_popup()->add_separator();
@@ -646,7 +646,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
search_menu = memnew(MenuButton);
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
- search_menu->get_popup()->set_hide_on_window_lose_focus(true);
+
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV);
@@ -666,13 +666,13 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
- bookmarks_menu->connect("about_to_show", callable_mp(this, &ShaderEditor::_update_bookmark_list));
+ bookmarks_menu->connect("about_to_popup", callable_mp(this, &ShaderEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &ShaderEditor::_bookmark_item_pressed));
help_menu = memnew(MenuButton);
help_menu->set_text(TTR("Help"));
help_menu->set_switch_on_hover(true);
- help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS);
+ help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_theme_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS);
help_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
add_child(main_container);
@@ -681,7 +681,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
hbc->add_child(edit_menu);
hbc->add_child(goto_menu);
hbc->add_child(help_menu);
- hbc->add_style_override("panel", p_node->get_gui_base()->get_stylebox("ScriptEditorPanel", "EditorStyles"));
+ hbc->add_theme_style_override("panel", p_node->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles"));
main_container->add_child(shader_editor);
goto_line_dialog = memnew(GotoLineDialog);
@@ -699,7 +699,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk));
disk_changed->get_ok()->set_text(TTR("Reload"));
- disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");
+ disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "resave");
disk_changed->connect("custom_action", callable_mp(this, &ShaderEditor::save_external_data));
add_child(disk_changed);
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 900b40bd7a..f02ed590fc 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -39,7 +39,7 @@
#include "scene/gui/text_edit.h"
#include "scene/main/timer.h"
#include "scene/resources/shader.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/shader_language.h"
class ShaderTextEditor : public CodeTextEditor {
diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp
index 0b77b987bf..96b2e56538 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_2d_editor_plugin.cpp
@@ -59,7 +59,7 @@ void Skeleton2DEditor::_menu_option(int p_option) {
if (node->get_bone_count() == 0) {
err_dialog->set_text(TTR("This skeleton has no bones, create some children Bone2D nodes."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -75,7 +75,7 @@ void Skeleton2DEditor::_menu_option(int p_option) {
case MENU_OPTION_SET_REST: {
if (node->get_bone_count() == 0) {
err_dialog->set_text(TTR("This skeleton has no bones, create some children Bone2D nodes."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -101,7 +101,7 @@ Skeleton2DEditor::Skeleton2DEditor() {
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text(TTR("Skeleton2D"));
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Skeleton2D", "EditorIcons"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton2D", "EditorIcons"));
options->get_popup()->add_item(TTR("Make Rest Pose (From Bones)"), MENU_OPTION_MAKE_REST);
options->get_popup()->add_separator();
diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 07bd6a0e41..ae289dae4b 100644
--- a/editor/plugins/skeleton_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton_editor_plugin.cpp */
+/* skeleton_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "skeleton_editor_plugin.h"
+#include "skeleton_3d_editor_plugin.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/physics_body.h"
-#include "scene/3d/physics_joint.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/sphere_shape.h"
-#include "spatial_editor_plugin.h"
+#include "node_3d_editor_plugin.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/3d/physics_joint_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
-void SkeletonEditor::_on_click_option(int p_option) {
+void Skeleton3DEditor::_on_click_option(int p_option) {
if (!skeleton) {
return;
}
@@ -49,7 +49,7 @@ void SkeletonEditor::_on_click_option(int p_option) {
}
}
-void SkeletonEditor::create_physical_skeleton() {
+void Skeleton3DEditor::create_physical_skeleton() {
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
Node *owner = skeleton == get_tree()->get_edited_scene_root() ? skeleton : skeleton->get_owner();
@@ -94,25 +94,25 @@ void SkeletonEditor::create_physical_skeleton() {
/// Create joint between parent of parent
if (-1 != parent_parent) {
- bones_infos[parent].physical_bone->set_joint_type(PhysicalBone::JOINT_TYPE_PIN);
+ bones_infos[parent].physical_bone->set_joint_type(PhysicalBone3D::JOINT_TYPE_PIN);
}
}
}
}
}
-PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) {
+PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) {
const Transform child_rest = skeleton->get_bone_rest(bone_child_id);
const real_t half_height(child_rest.origin.length() * 0.5);
const real_t radius(half_height * 0.2);
- CapsuleShape *bone_shape_capsule = memnew(CapsuleShape);
+ CapsuleShape3D *bone_shape_capsule = memnew(CapsuleShape3D);
bone_shape_capsule->set_height((half_height - radius) * 2);
bone_shape_capsule->set_radius(radius);
- CollisionShape *bone_shape = memnew(CollisionShape);
+ CollisionShape3D *bone_shape = memnew(CollisionShape3D);
bone_shape->set_shape(bone_shape_capsule);
Transform body_transform;
@@ -122,7 +122,7 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i
Transform joint_transform;
joint_transform.origin = Vector3(0, 0, half_height);
- PhysicalBone *physical_bone = memnew(PhysicalBone);
+ PhysicalBone3D *physical_bone = memnew(PhysicalBone3D);
physical_bone->add_child(bone_shape);
physical_bone->set_name("Physical Bone " + skeleton->get_bone_name(bone_id));
physical_bone->set_body_offset(body_transform);
@@ -130,18 +130,18 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i
return physical_bone;
}
-void SkeletonEditor::edit(Skeleton *p_node) {
+void Skeleton3DEditor::edit(Skeleton3D *p_node) {
skeleton = p_node;
}
-void SkeletonEditor::_notification(int p_what) {
+void Skeleton3DEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- get_tree()->connect("node_removed", callable_mp(this, &SkeletonEditor::_node_removed));
+ get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed));
}
}
-void SkeletonEditor::_node_removed(Node *p_node) {
+void Skeleton3DEditor::_node_removed(Node *p_node) {
if (p_node == skeleton) {
skeleton = NULL;
@@ -149,34 +149,34 @@ void SkeletonEditor::_node_removed(Node *p_node) {
}
}
-void SkeletonEditor::_bind_methods() {
+void Skeleton3DEditor::_bind_methods() {
}
-SkeletonEditor::SkeletonEditor() {
+Skeleton3DEditor::Skeleton3DEditor() {
skeleton = NULL;
options = memnew(MenuButton);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
- options->set_text(TTR("Skeleton"));
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Skeleton", "EditorIcons"));
+ options->set_text(TTR("Skeleton3D"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton3D", "EditorIcons"));
options->get_popup()->add_item(TTR("Create physical skeleton"), MENU_OPTION_CREATE_PHYSICAL_SKELETON);
- options->get_popup()->connect("id_pressed", callable_mp(this, &SkeletonEditor::_on_click_option));
+ options->get_popup()->connect("id_pressed", callable_mp(this, &Skeleton3DEditor::_on_click_option));
options->hide();
}
-SkeletonEditor::~SkeletonEditor() {}
+Skeleton3DEditor::~Skeleton3DEditor() {}
-void SkeletonEditorPlugin::edit(Object *p_object) {
- skeleton_editor->edit(Object::cast_to<Skeleton>(p_object));
+void Skeleton3DEditorPlugin::edit(Object *p_object) {
+ skeleton_editor->edit(Object::cast_to<Skeleton3D>(p_object));
}
-bool SkeletonEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Skeleton");
+bool Skeleton3DEditorPlugin::handles(Object *p_object) const {
+ return p_object->is_class("Skeleton3D");
}
-void SkeletonEditorPlugin::make_visible(bool p_visible) {
+void Skeleton3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
skeleton_editor->options->show();
} else {
@@ -186,10 +186,10 @@ void SkeletonEditorPlugin::make_visible(bool p_visible) {
}
}
-SkeletonEditorPlugin::SkeletonEditorPlugin(EditorNode *p_node) {
+Skeleton3DEditorPlugin::Skeleton3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- skeleton_editor = memnew(SkeletonEditor);
+ skeleton_editor = memnew(Skeleton3DEditor);
editor->get_viewport()->add_child(skeleton_editor);
}
-SkeletonEditorPlugin::~SkeletonEditorPlugin() {}
+Skeleton3DEditorPlugin::~Skeleton3DEditorPlugin() {}
diff --git a/editor/plugins/skeleton_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h
index 1dce6d12ed..606e04bb79 100644
--- a/editor/plugins/skeleton_editor_plugin.h
+++ b/editor/plugins/skeleton_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton_editor_plugin.h */
+/* skeleton_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,37 +28,37 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SKELETON_EDITOR_PLUGIN_H
-#define SKELETON_EDITOR_PLUGIN_H
+#ifndef SKELETON_3D_EDITOR_PLUGIN_H
+#define SKELETON_3D_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/3d/skeleton.h"
+#include "scene/3d/skeleton_3d.h"
-class PhysicalBone;
-class Joint;
+class PhysicalBone3D;
+class Joint3D;
-class SkeletonEditor : public Node {
- GDCLASS(SkeletonEditor, Node);
+class Skeleton3DEditor : public Node {
+ GDCLASS(Skeleton3DEditor, Node);
enum Menu {
MENU_OPTION_CREATE_PHYSICAL_SKELETON
};
struct BoneInfo {
- PhysicalBone *physical_bone;
+ PhysicalBone3D *physical_bone;
Transform relative_rest; // Relative to skeleton node
BoneInfo() :
physical_bone(NULL) {}
};
- Skeleton *skeleton;
+ Skeleton3D *skeleton;
MenuButton *options;
void _on_click_option(int p_option);
- friend class SkeletonEditorPlugin;
+ friend class Skeleton3DEditorPlugin;
protected:
void _notification(int p_what);
@@ -66,31 +66,31 @@ protected:
static void _bind_methods();
void create_physical_skeleton();
- PhysicalBone *create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos);
+ PhysicalBone3D *create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos);
public:
- void edit(Skeleton *p_node);
+ void edit(Skeleton3D *p_node);
- SkeletonEditor();
- ~SkeletonEditor();
+ Skeleton3DEditor();
+ ~Skeleton3DEditor();
};
-class SkeletonEditorPlugin : public EditorPlugin {
+class Skeleton3DEditorPlugin : public EditorPlugin {
- GDCLASS(SkeletonEditorPlugin, EditorPlugin);
+ GDCLASS(Skeleton3DEditorPlugin, EditorPlugin);
EditorNode *editor;
- SkeletonEditor *skeleton_editor;
+ Skeleton3DEditor *skeleton_editor;
public:
- virtual String get_name() const { return "Skeleton"; }
+ virtual String get_name() const { return "Skeleton3D"; }
virtual bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- SkeletonEditorPlugin(EditorNode *p_node);
- ~SkeletonEditorPlugin();
+ Skeleton3DEditorPlugin(EditorNode *p_node);
+ ~Skeleton3DEditorPlugin();
};
-#endif // SKELETON_EDITOR_PLUGIN_H
+#endif // SKELETON_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/skeleton_ik_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
index b031bd71d3..4b6a86bb5a 100644
--- a/editor/plugins/skeleton_ik_editor_plugin.cpp
+++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton_ik_editor_plugin.cpp */
+/* skeleton_ik_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "skeleton_ik_editor_plugin.h"
+#include "skeleton_ik_3d_editor_plugin.h"
-#include "scene/animation/skeleton_ik.h"
+#include "scene/3d/skeleton_ik_3d.h"
-void SkeletonIKEditorPlugin::_play() {
+void SkeletonIK3DEditorPlugin::_play() {
if (!skeleton_ik)
return;
@@ -44,14 +44,11 @@ void SkeletonIKEditorPlugin::_play() {
skeleton_ik->start();
} else {
skeleton_ik->stop();
-
- for (int i = 0; i < skeleton_ik->get_parent_skeleton()->get_bone_count(); ++i) {
- skeleton_ik->get_parent_skeleton()->set_bone_global_pose_override(i, Transform(), 0);
- }
+ skeleton_ik->get_parent_skeleton()->clear_bones_global_pose_override();
}
}
-void SkeletonIKEditorPlugin::edit(Object *p_object) {
+void SkeletonIK3DEditorPlugin::edit(Object *p_object) {
if (p_object != skeleton_ik) {
if (skeleton_ik) {
@@ -60,19 +57,19 @@ void SkeletonIKEditorPlugin::edit(Object *p_object) {
}
}
- SkeletonIK *s = Object::cast_to<SkeletonIK>(p_object);
+ SkeletonIK3D *s = Object::cast_to<SkeletonIK3D>(p_object);
if (!s)
return;
skeleton_ik = s;
}
-bool SkeletonIKEditorPlugin::handles(Object *p_object) const {
+bool SkeletonIK3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("SkeletonIK");
+ return p_object->is_class("SkeletonIK3D");
}
-void SkeletonIKEditorPlugin::make_visible(bool p_visible) {
+void SkeletonIK3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible)
play_btn->show();
@@ -80,20 +77,20 @@ void SkeletonIKEditorPlugin::make_visible(bool p_visible) {
play_btn->hide();
}
-void SkeletonIKEditorPlugin::_bind_methods() {
+void SkeletonIK3DEditorPlugin::_bind_methods() {
}
-SkeletonIKEditorPlugin::SkeletonIKEditorPlugin(EditorNode *p_node) {
+SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
play_btn = memnew(Button);
- play_btn->set_icon(editor->get_gui_base()->get_icon("Play", "EditorIcons"));
+ play_btn->set_icon(editor->get_gui_base()->get_theme_icon("Play", "EditorIcons"));
play_btn->set_text(TTR("Play IK"));
play_btn->set_toggle_mode(true);
play_btn->hide();
- play_btn->connect("pressed", callable_mp(this, &SkeletonIKEditorPlugin::_play));
+ play_btn->connect("pressed", callable_mp(this, &SkeletonIK3DEditorPlugin::_play));
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, play_btn);
skeleton_ik = NULL;
}
-SkeletonIKEditorPlugin::~SkeletonIKEditorPlugin() {}
+SkeletonIK3DEditorPlugin::~SkeletonIK3DEditorPlugin() {}
diff --git a/editor/plugins/skeleton_ik_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h
index 814eb8ff5b..1466d670ba 100644
--- a/editor/plugins/skeleton_ik_editor_plugin.h
+++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton_ik_editor_plugin.h */
+/* skeleton_ik_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,19 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SKELETON_IK_EDITOR_PLUGIN_H
-#define SKELETON_IK_EDITOR_PLUGIN_H
+#ifndef SKELETON_IK_3D_EDITOR_PLUGIN_H
+#define SKELETON_IK_3D_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-class SkeletonIK;
+class SkeletonIK3D;
-class SkeletonIKEditorPlugin : public EditorPlugin {
+class SkeletonIK3DEditorPlugin : public EditorPlugin {
- GDCLASS(SkeletonIKEditorPlugin, EditorPlugin);
+ GDCLASS(SkeletonIK3DEditorPlugin, EditorPlugin);
- SkeletonIK *skeleton_ik;
+ SkeletonIK3D *skeleton_ik;
Button *play_btn;
EditorNode *editor;
@@ -57,8 +57,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- SkeletonIKEditorPlugin(EditorNode *p_node);
- ~SkeletonIKEditorPlugin();
+ SkeletonIK3DEditorPlugin(EditorNode *p_node);
+ ~SkeletonIK3DEditorPlugin();
};
-#endif // SKELETON_IK_EDITOR_PLUGIN_H
+#endif // SKELETON_IK_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp
index 2897341f06..ce994ee6c7 100644
--- a/editor/plugins/sprite_editor_plugin.cpp
+++ b/editor/plugins/sprite_2d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sprite_editor_plugin.cpp */
+/* sprite_2d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "sprite_editor_plugin.h"
+#include "sprite_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "editor/editor_scale.h"
@@ -39,7 +39,7 @@
#include "scene/gui/box_container.h"
#include "thirdparty/misc/clipper.hpp"
-void SpriteEditor::_node_removed(Node *p_node) {
+void Sprite2DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@@ -47,7 +47,7 @@ void SpriteEditor::_node_removed(Node *p_node) {
}
}
-void SpriteEditor::edit(Sprite *p_sprite) {
+void Sprite2DEditor::edit(Sprite2D *p_sprite) {
node = p_sprite;
}
@@ -114,7 +114,7 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
return outPoints;
}
-void SpriteEditor::_menu_option(int p_option) {
+void Sprite2DEditor::_menu_option(int p_option) {
if (!node) {
return;
@@ -165,18 +165,18 @@ void SpriteEditor::_menu_option(int p_option) {
}
}
-void SpriteEditor::_update_mesh_data() {
+void Sprite2DEditor::_update_mesh_data() {
Ref<Texture2D> texture = node->get_texture();
if (texture.is_null()) {
- err_dialog->set_text(TTR("Sprite is empty!"));
- err_dialog->popup_centered_minsize();
+ err_dialog->set_text(TTR("Sprite2D is empty!"));
+ err_dialog->popup_centered();
return;
}
if (node->get_hframes() > 1 || node->get_vframes() > 1) {
err_dialog->set_text(TTR("Can't convert a sprite using animation frames to mesh."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -296,7 +296,7 @@ void SpriteEditor::_update_mesh_data() {
debug_uv->update();
}
-void SpriteEditor::_create_node() {
+void Sprite2DEditor::_create_node() {
switch (selected_menu_item) {
case MENU_OPTION_CONVERT_TO_MESH_2D: {
_convert_to_mesh_2d_node();
@@ -313,11 +313,11 @@ void SpriteEditor::_create_node() {
}
}
-void SpriteEditor::_convert_to_mesh_2d_node() {
+void Sprite2DEditor::_convert_to_mesh_2d_node() {
if (computed_vertices.size() < 3) {
err_dialog->set_text(TTR("Invalid geometry, can't replace by mesh."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -344,11 +344,11 @@ void SpriteEditor::_convert_to_mesh_2d_node() {
ur->commit_action();
}
-void SpriteEditor::_convert_to_polygon_2d_node() {
+void Sprite2DEditor::_convert_to_polygon_2d_node() {
if (computed_outline_lines.empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create polygon."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -403,11 +403,11 @@ void SpriteEditor::_convert_to_polygon_2d_node() {
ur->commit_action();
}
-void SpriteEditor::_create_collision_polygon_2d_node() {
+void Sprite2DEditor::_create_collision_polygon_2d_node() {
if (computed_outline_lines.empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -427,11 +427,11 @@ void SpriteEditor::_create_collision_polygon_2d_node() {
}
}
-void SpriteEditor::_create_light_occluder_2d_node() {
+void Sprite2DEditor::_create_light_occluder_2d_node() {
if (computed_outline_lines.empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create light occluder."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -462,7 +462,7 @@ void SpriteEditor::_create_light_occluder_2d_node() {
}
}
-void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) {
+void Sprite2DEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) {
// Can't make sibling if own node is scene root
if (p_own_node != this->get_tree()->get_edited_scene_root()) {
p_own_node->get_parent()->add_child(p_new_node, true);
@@ -474,7 +474,7 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node)
p_new_node->set_owner(this->get_tree()->get_edited_scene_root());
}
-void SpriteEditor::_debug_uv_draw() {
+void Sprite2DEditor::_debug_uv_draw() {
Ref<Texture2D> tex = node->get_texture();
ERR_FAIL_COND(!tex.is_valid());
@@ -502,19 +502,19 @@ void SpriteEditor::_debug_uv_draw() {
}
}
-void SpriteEditor::_bind_methods() {
+void Sprite2DEditor::_bind_methods() {
- ClassDB::bind_method("_add_as_sibling_or_child", &SpriteEditor::_add_as_sibling_or_child);
+ ClassDB::bind_method("_add_as_sibling_or_child", &Sprite2DEditor::_add_as_sibling_or_child);
}
-SpriteEditor::SpriteEditor() {
+Sprite2DEditor::Sprite2DEditor() {
options = memnew(MenuButton);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
- options->set_text(TTR("Sprite"));
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Sprite", "EditorIcons"));
+ options->set_text(TTR("Sprite2D"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Sprite2D", "EditorIcons"));
options->get_popup()->add_item(TTR("Convert to Mesh2D"), MENU_OPTION_CONVERT_TO_MESH_2D);
options->get_popup()->add_item(TTR("Convert to Polygon2D"), MENU_OPTION_CONVERT_TO_POLYGON_2D);
@@ -522,7 +522,7 @@ SpriteEditor::SpriteEditor() {
options->get_popup()->add_item(TTR("Create LightOccluder2D Sibling"), MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D);
options->set_switch_on_hover(true);
- options->get_popup()->connect("id_pressed", callable_mp(this, &SpriteEditor::_menu_option));
+ options->get_popup()->connect("id_pressed", callable_mp(this, &Sprite2DEditor::_menu_option));
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@@ -538,9 +538,9 @@ SpriteEditor::SpriteEditor() {
scroll->set_enable_v_scroll(true);
vb->add_margin_child(TTR("Preview:"), scroll, true);
debug_uv = memnew(Control);
- debug_uv->connect("draw", callable_mp(this, &SpriteEditor::_debug_uv_draw));
+ debug_uv->connect("draw", callable_mp(this, &Sprite2DEditor::_debug_uv_draw));
scroll->add_child(debug_uv);
- debug_uv_dialog->connect("confirmed", callable_mp(this, &SpriteEditor::_create_node));
+ debug_uv_dialog->connect("confirmed", callable_mp(this, &Sprite2DEditor::_create_node));
HBoxContainer *hb = memnew(HBoxContainer);
hb->add_child(memnew(Label(TTR("Simplification: "))));
@@ -569,24 +569,24 @@ SpriteEditor::SpriteEditor() {
hb->add_spacer();
update_preview = memnew(Button);
update_preview->set_text(TTR("Update Preview"));
- update_preview->connect("pressed", callable_mp(this, &SpriteEditor::_update_mesh_data));
+ update_preview->connect("pressed", callable_mp(this, &Sprite2DEditor::_update_mesh_data));
hb->add_child(update_preview);
vb->add_margin_child(TTR("Settings:"), hb);
add_child(debug_uv_dialog);
}
-void SpriteEditorPlugin::edit(Object *p_object) {
+void Sprite2DEditorPlugin::edit(Object *p_object) {
- sprite_editor->edit(Object::cast_to<Sprite>(p_object));
+ sprite_editor->edit(Object::cast_to<Sprite2D>(p_object));
}
-bool SpriteEditorPlugin::handles(Object *p_object) const {
+bool Sprite2DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Sprite");
+ return p_object->is_class("Sprite2D");
}
-void SpriteEditorPlugin::make_visible(bool p_visible) {
+void Sprite2DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
sprite_editor->options->show();
@@ -597,15 +597,15 @@ void SpriteEditorPlugin::make_visible(bool p_visible) {
}
}
-SpriteEditorPlugin::SpriteEditorPlugin(EditorNode *p_node) {
+Sprite2DEditorPlugin::Sprite2DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- sprite_editor = memnew(SpriteEditor);
+ sprite_editor = memnew(Sprite2DEditor);
editor->get_viewport()->add_child(sprite_editor);
make_visible(false);
//sprite_editor->options->hide();
}
-SpriteEditorPlugin::~SpriteEditorPlugin() {
+Sprite2DEditorPlugin::~Sprite2DEditorPlugin() {
}
diff --git a/editor/plugins/sprite_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h
index 998851b6ad..d0ebf9c84e 100644
--- a/editor/plugins/sprite_editor_plugin.h
+++ b/editor/plugins/sprite_2d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sprite_editor_plugin.h */
+/* sprite_2d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/gui/spin_box.h"
-class SpriteEditor : public Control {
+class Sprite2DEditor : public Control {
- GDCLASS(SpriteEditor, Control);
+ GDCLASS(Sprite2DEditor, Control);
enum Menu {
MENU_OPTION_CONVERT_TO_MESH_2D,
@@ -49,7 +49,7 @@ class SpriteEditor : public Control {
Menu selected_menu_item;
- Sprite *node;
+ Sprite2D *node;
MenuButton *options;
@@ -74,7 +74,7 @@ class SpriteEditor : public Control {
void _menu_option(int p_option);
//void _create_uv_lines();
- friend class SpriteEditorPlugin;
+ friend class Sprite2DEditorPlugin;
void _debug_uv_draw();
void _update_mesh_data();
@@ -92,15 +92,15 @@ protected:
static void _bind_methods();
public:
- void edit(Sprite *p_sprite);
- SpriteEditor();
+ void edit(Sprite2D *p_sprite);
+ Sprite2DEditor();
};
-class SpriteEditorPlugin : public EditorPlugin {
+class Sprite2DEditorPlugin : public EditorPlugin {
- GDCLASS(SpriteEditorPlugin, EditorPlugin);
+ GDCLASS(Sprite2DEditorPlugin, EditorPlugin);
- SpriteEditor *sprite_editor;
+ Sprite2DEditor *sprite_editor;
EditorNode *editor;
public:
@@ -110,8 +110,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- SpriteEditorPlugin(EditorNode *p_node);
- ~SpriteEditorPlugin();
+ Sprite2DEditorPlugin(EditorNode *p_node);
+ ~Sprite2DEditorPlugin();
};
#endif // SPRITE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index e6b0e3142c..76e60bb014 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -81,7 +81,7 @@ void SpriteFramesEditor::_sheet_preview_draw() {
return;
}
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) {
int idx = E->get();
@@ -223,24 +223,24 @@ void SpriteFramesEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- load->set_icon(get_icon("Load", "EditorIcons"));
- load_sheet->set_icon(get_icon("SpriteSheet", "EditorIcons"));
- copy->set_icon(get_icon("ActionCopy", "EditorIcons"));
- paste->set_icon(get_icon("ActionPaste", "EditorIcons"));
- empty->set_icon(get_icon("InsertBefore", "EditorIcons"));
- empty2->set_icon(get_icon("InsertAfter", "EditorIcons"));
- move_up->set_icon(get_icon("MoveLeft", "EditorIcons"));
- move_down->set_icon(get_icon("MoveRight", "EditorIcons"));
- _delete->set_icon(get_icon("Remove", "EditorIcons"));
- new_anim->set_icon(get_icon("New", "EditorIcons"));
- remove_anim->set_icon(get_icon("Remove", "EditorIcons"));
+ load->set_icon(get_theme_icon("Load", "EditorIcons"));
+ load_sheet->set_icon(get_theme_icon("SpriteSheet", "EditorIcons"));
+ copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons"));
+ paste->set_icon(get_theme_icon("ActionPaste", "EditorIcons"));
+ empty->set_icon(get_theme_icon("InsertBefore", "EditorIcons"));
+ empty2->set_icon(get_theme_icon("InsertAfter", "EditorIcons"));
+ move_up->set_icon(get_theme_icon("MoveLeft", "EditorIcons"));
+ move_down->set_icon(get_theme_icon("MoveRight", "EditorIcons"));
+ _delete->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ new_anim->set_icon(get_theme_icon("New", "EditorIcons"));
+ remove_anim->set_icon(get_theme_icon("Remove", "EditorIcons"));
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
- splite_sheet_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
+ splite_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
- add_constant_override("autohide", 1); // Fixes the dragger always showing up.
+ add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
}
}
@@ -262,7 +262,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_
//dialog->get_cancel()->set_text("Close");
dialog->get_ok()->set_text(TTR("Close"));
- dialog->popup_centered_minsize();
+ dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -301,7 +301,7 @@ void SpriteFramesEditor::_load_pressed() {
for (int i = 0; i < extensions.size(); i++)
file->add_filter("*." + extensions[i]);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILES);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
file->popup_centered_ratio();
}
@@ -316,7 +316,7 @@ void SpriteFramesEditor::_paste_pressed() {
dialog->set_title(TTR("Error!"));
//dialog->get_cancel()->set_text("Close");
dialog->get_ok()->set_text(TTR("Close"));
- dialog->popup_centered_minsize();
+ dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -485,7 +485,7 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr
return;
{
- AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
+ AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node);
if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
@@ -591,7 +591,7 @@ void SpriteFramesEditor::_animation_remove() {
return;
delete_dialog->set_text(TTR("Delete Animation?"));
- delete_dialog->popup_centered_minsize();
+ delete_dialog->popup_centered();
}
void SpriteFramesEditor::_animation_remove_confirmed() {
@@ -1058,7 +1058,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
file_split_sheet = memnew(EditorFileDialog);
file_split_sheet->set_title(TTR("Create Frames from Sprite Sheet"));
- file_split_sheet->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_split_sheet->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
add_child(file_split_sheet);
file_split_sheet->connect("file_selected", callable_mp(this, &SpriteFramesEditor::_prepare_sprite_sheet));
}
@@ -1068,11 +1068,17 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) {
frames_editor->set_undo_redo(&get_undo_redo());
SpriteFrames *s;
- AnimatedSprite *animated_sprite = Object::cast_to<AnimatedSprite>(p_object);
+ AnimatedSprite2D *animated_sprite = Object::cast_to<AnimatedSprite2D>(p_object);
if (animated_sprite) {
s = *animated_sprite->get_sprite_frames();
} else {
- s = Object::cast_to<SpriteFrames>(p_object);
+ AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object);
+ if (animated_sprite_3d) {
+ s = *animated_sprite_3d->get_sprite_frames();
+ } else {
+
+ s = Object::cast_to<SpriteFrames>(p_object);
+ }
}
frames_editor->edit(s);
@@ -1080,9 +1086,12 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) {
bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
- AnimatedSprite *animated_sprite = Object::cast_to<AnimatedSprite>(p_object);
+ AnimatedSprite2D *animated_sprite = Object::cast_to<AnimatedSprite2D>(p_object);
+ AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object);
if (animated_sprite && *animated_sprite->get_sprite_frames()) {
return true;
+ } else if (animated_sprite_3d && *animated_sprite_3d->get_sprite_frames()) {
+ return true;
} else {
return p_object->is_class("SpriteFrames");
}
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 1fa93b5c47..89d9bc6fd3 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -33,7 +33,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/2d/animated_sprite.h"
+#include "scene/2d/animated_sprite_2d.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/split_container.h"
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index a92194da17..41db0308c2 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -57,7 +57,7 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
stylebox->disconnect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
stylebox = p_stylebox;
if (p_stylebox.is_valid()) {
- preview->add_style_override("panel", stylebox);
+ preview->add_theme_style_override("panel", stylebox);
stylebox->connect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
}
_sb_changed();
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 35f23ccf1d..aa86c48af1 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -51,10 +51,10 @@ void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
// so to remove all colours we need to set and unset them here.
if (p_highlighter == NULL) { // standard
TextEdit *text_edit = code_editor->get_text_edit();
- text_edit->add_color_override("number_color", colors_cache.font_color);
- text_edit->add_color_override("function_color", colors_cache.font_color);
- text_edit->add_color_override("number_color", colors_cache.font_color);
- text_edit->add_color_override("member_variable_color", colors_cache.font_color);
+ text_edit->add_theme_color_override("number_color", colors_cache.font_color);
+ text_edit->add_theme_color_override("function_color", colors_cache.font_color);
+ text_edit->add_theme_color_override("number_color", colors_cache.font_color);
+ text_edit->add_theme_color_override("member_variable_color", colors_cache.font_color);
} else {
_load_theme_settings();
}
@@ -107,35 +107,35 @@ void TextEditor::_load_theme_settings() {
Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
Color string_color = EDITOR_GET("text_editor/highlighting/string_color");
- text_edit->add_color_override("background_color", background_color);
- text_edit->add_color_override("completion_background_color", completion_background_color);
- text_edit->add_color_override("completion_selected_color", completion_selected_color);
- text_edit->add_color_override("completion_existing_color", completion_existing_color);
- text_edit->add_color_override("completion_scroll_color", completion_scroll_color);
- text_edit->add_color_override("completion_font_color", completion_font_color);
- text_edit->add_color_override("font_color", text_color);
- text_edit->add_color_override("line_number_color", line_number_color);
- text_edit->add_color_override("caret_color", caret_color);
- text_edit->add_color_override("caret_background_color", caret_background_color);
- text_edit->add_color_override("font_color_selected", text_selected_color);
- text_edit->add_color_override("selection_color", selection_color);
- text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color);
- text_edit->add_color_override("current_line_color", current_line_color);
- text_edit->add_color_override("line_length_guideline_color", line_length_guideline_color);
- text_edit->add_color_override("word_highlighted_color", word_highlighted_color);
- text_edit->add_color_override("number_color", number_color);
- text_edit->add_color_override("function_color", function_color);
- text_edit->add_color_override("member_variable_color", member_variable_color);
- text_edit->add_color_override("breakpoint_color", breakpoint_color);
- text_edit->add_color_override("executing_line_color", executing_line_color);
- text_edit->add_color_override("mark_color", mark_color);
- text_edit->add_color_override("bookmark_color", bookmark_color);
- text_edit->add_color_override("code_folding_color", code_folding_color);
- text_edit->add_color_override("search_result_color", search_result_color);
- text_edit->add_color_override("search_result_border_color", search_result_border_color);
- text_edit->add_color_override("symbol_color", symbol_color);
-
- text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6));
+ text_edit->add_theme_color_override("background_color", background_color);
+ text_edit->add_theme_color_override("completion_background_color", completion_background_color);
+ text_edit->add_theme_color_override("completion_selected_color", completion_selected_color);
+ text_edit->add_theme_color_override("completion_existing_color", completion_existing_color);
+ text_edit->add_theme_color_override("completion_scroll_color", completion_scroll_color);
+ text_edit->add_theme_color_override("completion_font_color", completion_font_color);
+ text_edit->add_theme_color_override("font_color", text_color);
+ text_edit->add_theme_color_override("line_number_color", line_number_color);
+ text_edit->add_theme_color_override("caret_color", caret_color);
+ text_edit->add_theme_color_override("caret_background_color", caret_background_color);
+ text_edit->add_theme_color_override("font_color_selected", text_selected_color);
+ text_edit->add_theme_color_override("selection_color", selection_color);
+ text_edit->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
+ text_edit->add_theme_color_override("current_line_color", current_line_color);
+ text_edit->add_theme_color_override("line_length_guideline_color", line_length_guideline_color);
+ text_edit->add_theme_color_override("word_highlighted_color", word_highlighted_color);
+ text_edit->add_theme_color_override("number_color", number_color);
+ text_edit->add_theme_color_override("function_color", function_color);
+ text_edit->add_theme_color_override("member_variable_color", member_variable_color);
+ text_edit->add_theme_color_override("breakpoint_color", breakpoint_color);
+ text_edit->add_theme_color_override("executing_line_color", executing_line_color);
+ text_edit->add_theme_color_override("mark_color", mark_color);
+ text_edit->add_theme_color_override("bookmark_color", bookmark_color);
+ text_edit->add_theme_color_override("code_folding_color", code_folding_color);
+ text_edit->add_theme_color_override("search_result_color", search_result_color);
+ text_edit->add_theme_color_override("search_result_border_color", search_result_border_color);
+ text_edit->add_theme_color_override("symbol_color", symbol_color);
+
+ text_edit->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6));
colors_cache.font_color = text_color;
colors_cache.symbol_color = symbol_color;
@@ -163,7 +163,7 @@ String TextEditor::get_name() {
return name;
}
-Ref<Texture2D> TextEditor::get_icon() {
+Ref<Texture2D> TextEditor::get_theme_icon() {
return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), "");
}
@@ -624,7 +624,7 @@ void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is
TextEditor::TextEditor() {
code_editor = memnew(CodeTextEditor);
add_child(code_editor);
- code_editor->add_constant_override("separation", 0);
+ code_editor->add_theme_constant_override("separation", 0);
code_editor->connect("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings));
code_editor->connect("validate_script", callable_mp(this, &TextEditor::_validate_script));
code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
@@ -716,7 +716,7 @@ TextEditor::TextEditor() {
goto_menu->get_popup()->add_child(bookmarks_menu);
goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
- bookmarks_menu->connect("about_to_show", callable_mp(this, &TextEditor::_update_bookmark_list));
+ bookmarks_menu->connect("about_to_popup", callable_mp(this, &TextEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &TextEditor::_bookmark_item_pressed));
goto_line_dialog = memnew(GotoLineDialog);
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index c80052e7ba..b41e11c3aa 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -121,7 +121,7 @@ public:
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
virtual String get_name();
- virtual Ref<Texture2D> get_icon();
+ virtual Ref<Texture2D> get_theme_icon();
virtual RES get_edited_resource() const;
virtual void set_edited_resource(const RES &p_res);
void set_edited_file(const Ref<TextFile> &p_file);
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 60f9bb5dc1..3f76854571 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -46,7 +46,7 @@ void TextureEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons");
+ Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
@@ -79,7 +79,7 @@ void TextureEditor::_notification(int p_what) {
draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height));
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
String format;
if (Object::cast_to<ImageTexture>(*texture)) {
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 2262e12f5d..d453598e33 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -31,7 +31,7 @@
#include "texture_region_editor_plugin.h"
#include "core/core_string_names.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "scene/gui/check_box.h"
@@ -43,7 +43,7 @@
void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
Vector2 line = (to - from).normalized() * 10;
while ((to - from).length_squared() > 200) {
- edit_draw->draw_line(from, from + line, EditorNode::get_singleton()->get_theme_base()->get_color("mono_color", "Editor"), 2);
+ edit_draw->draw_line(from, from + line, EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"), 2);
from += line * 2;
}
}
@@ -68,9 +68,9 @@ void TextureRegionEditor::_region_draw() {
mtx.elements[2] = -draw_ofs * draw_zoom;
mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
- VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx);
+ RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx);
edit_draw->draw_texture(base_tex, Point2());
- VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D());
+ RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D());
if (snap_mode == SNAP_GRID) {
Color grid_color = Color(1.0, 1.0, 1.0, 0.15);
@@ -134,7 +134,7 @@ void TextureRegionEditor::_region_draw() {
}
}
- Ref<Texture2D> select_handle = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> select_handle = get_theme_icon("EditorHandle", "EditorIcons");
Rect2 scroll_rect(Point2(), base_tex->get_size());
@@ -150,7 +150,7 @@ void TextureRegionEditor::_region_draw() {
mtx.basis_xform(raw_endpoints[2]),
mtx.basis_xform(raw_endpoints[3])
};
- Color color = get_color("mono_color", "Editor");
+ Color color = get_theme_color("mono_color", "Editor");
for (int i = 0; i < 4; i++) {
int prev = (i + 3) % 4;
@@ -307,7 +307,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
if (E->get().has_point(point)) {
rect = E->get();
- if (Input::get_singleton()->is_key_pressed(KEY_CONTROL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL) && !(InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) {
Rect2 r;
if (node_sprite)
r = node_sprite->get_region_rect();
@@ -449,7 +449,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
- if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
hscroll->set_value(hscroll->get_value() - dragged.x);
@@ -741,12 +741,12 @@ void TextureRegionEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- edit_draw->add_style_override("panel", get_stylebox("bg", "Tree"));
+ edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
- zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
- zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons"));
- zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons"));
+ zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons"));
+ zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons"));
+ zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons"));
vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
@@ -756,7 +756,7 @@ void TextureRegionEditor::_notification(int p_what) {
_update_autoslice();
}
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
// This happens when the user leaves the Editor and returns,
// they could have changed the textures, so the cache is cleared.
cache_map.clear();
@@ -800,7 +800,7 @@ Sprite3D *TextureRegionEditor::get_sprite_3d() {
return node_sprite_3d;
}
-Sprite *TextureRegionEditor::get_sprite() {
+Sprite2D *TextureRegionEditor::get_sprite() {
return node_sprite;
}
@@ -816,7 +816,7 @@ void TextureRegionEditor::edit(Object *p_obj) {
if (atlas_tex.is_valid())
atlas_tex->remove_change_receptor(this);
if (p_obj) {
- node_sprite = Object::cast_to<Sprite>(p_obj);
+ node_sprite = Object::cast_to<Sprite2D>(p_obj);
node_sprite_3d = Object::cast_to<Sprite3D>(p_obj);
node_ninepatch = Object::cast_to<NinePatchRect>(p_obj);
if (Object::cast_to<StyleBoxTexture>(p_obj))
@@ -1037,7 +1037,7 @@ void TextureRegionEditorPlugin::edit(Object *p_object) {
}
bool TextureRegionEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Sprite") || p_object->is_class("Sprite3D") || p_object->is_class("NinePatchRect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture");
+ return p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("NinePatchRect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture");
}
void TextureRegionEditorPlugin::_editor_visiblity_changed() {
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index edc55071b7..c6cd648842 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -34,7 +34,7 @@
#include "canvas_item_editor_plugin.h"
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/3d/sprite_3d.h"
#include "scene/gui/nine_patch_rect.h"
#include "scene/resources/style_box.h"
@@ -84,7 +84,7 @@ class TextureRegionEditor : public VBoxContainer {
Vector2 snap_step;
Vector2 snap_separation;
- Sprite *node_sprite;
+ Sprite2D *node_sprite;
Sprite3D *node_sprite_3d;
NinePatchRect *node_ninepatch;
Ref<StyleBoxTexture> obj_styleBox;
@@ -136,7 +136,7 @@ public:
bool is_atlas_texture();
bool is_ninepatch();
Sprite3D *get_sprite_3d();
- Sprite *get_sprite();
+ Sprite2D *get_sprite();
void edit(Object *p_obj);
TextureRegionEditor(EditorNode *p_editor);
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index aa5caf6658..b246b611fd 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -592,7 +592,7 @@ void ThemeEditor::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED: {
- theme_menu->set_icon(get_icon("Theme", "EditorIcons"));
+ theme_menu->set_icon(get_theme_icon("Theme", "EditorIcons"));
} break;
}
}
@@ -645,10 +645,10 @@ ThemeEditor::ThemeEditor() {
main_container = memnew(MarginContainer);
root_container->add_child(main_container);
- main_container->add_constant_override("margin_right", 4 * EDSCALE);
- main_container->add_constant_override("margin_top", 4 * EDSCALE);
- main_container->add_constant_override("margin_left", 4 * EDSCALE);
- main_container->add_constant_override("margin_bottom", 4 * EDSCALE);
+ main_container->add_theme_constant_override("margin_right", 4 * EDSCALE);
+ main_container->add_theme_constant_override("margin_top", 4 * EDSCALE);
+ main_container->add_theme_constant_override("margin_left", 4 * EDSCALE);
+ main_container->add_theme_constant_override("margin_bottom", 4 * EDSCALE);
HBoxContainer *main_hb = memnew(HBoxContainer);
main_container->add_child(main_hb);
@@ -656,7 +656,7 @@ ThemeEditor::ThemeEditor() {
VBoxContainer *first_vb = memnew(VBoxContainer);
main_hb->add_child(first_vb);
first_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- first_vb->add_constant_override("separation", 10 * EDSCALE);
+ first_vb->add_theme_constant_override("separation", 10 * EDSCALE);
first_vb->add_child(memnew(Label("Label")));
@@ -716,7 +716,7 @@ ThemeEditor::ThemeEditor() {
VBoxContainer *second_vb = memnew(VBoxContainer);
second_vb->set_h_size_flags(SIZE_EXPAND_FILL);
main_hb->add_child(second_vb);
- second_vb->add_constant_override("separation", 10 * EDSCALE);
+ second_vb->add_theme_constant_override("separation", 10 * EDSCALE);
LineEdit *le = memnew(LineEdit);
le->set_text("LineEdit");
second_vb->add_child(le);
@@ -756,7 +756,7 @@ ThemeEditor::ThemeEditor() {
VBoxContainer *third_vb = memnew(VBoxContainer);
third_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- third_vb->add_constant_override("separation", 10 * EDSCALE);
+ third_vb->add_theme_constant_override("separation", 10 * EDSCALE);
main_hb->add_child(third_vb);
TabContainer *tc = memnew(TabContainer);
@@ -776,7 +776,7 @@ ThemeEditor::ThemeEditor() {
Tree *test_tree = memnew(Tree);
third_vb->add_child(test_tree);
test_tree->set_custom_minimum_size(Size2(0, 175) * EDSCALE);
- test_tree->add_constant_override("draw_relationship_lines", 1);
+ test_tree->add_theme_constant_override("draw_relationship_lines", 1);
TreeItem *item = test_tree->create_item();
item->set_text(0, "Tree");
@@ -802,7 +802,7 @@ ThemeEditor::ThemeEditor() {
item->set_text(0, TTR("Has,Many,Options"));
item->set_range(0, 2);
- main_hb->add_constant_override("separation", 20 * EDSCALE);
+ main_hb->add_theme_constant_override("separation", 20 * EDSCALE);
////////
@@ -846,7 +846,7 @@ ThemeEditor::ThemeEditor() {
name_menu->set_text("..");
name_hbc->add_child(name_menu);
- name_menu->get_popup()->connect("about_to_show", callable_mp(this, &ThemeEditor::_name_menu_about_to_show));
+ name_menu->get_popup()->connect("about_to_popup", callable_mp(this, &ThemeEditor::_name_menu_about_to_show));
name_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_name_menu_cbk));
type_select_label = memnew(Label);
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 017f986469..83dc84a0c2 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -31,8 +31,8 @@
#include "tile_map_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/math/math_funcs.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
@@ -60,24 +60,24 @@ void TileMapEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- paint_button->set_icon(get_icon("Edit", "EditorIcons"));
- bucket_fill_button->set_icon(get_icon("Bucket", "EditorIcons"));
- picker_button->set_icon(get_icon("ColorPick", "EditorIcons"));
- select_button->set_icon(get_icon("ActionCopy", "EditorIcons"));
+ paint_button->set_icon(get_theme_icon("Edit", "EditorIcons"));
+ bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons"));
+ picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
+ select_button->set_icon(get_theme_icon("ActionCopy", "EditorIcons"));
- rotate_left_button->set_icon(get_icon("RotateLeft", "EditorIcons"));
- rotate_right_button->set_icon(get_icon("RotateRight", "EditorIcons"));
- flip_horizontal_button->set_icon(get_icon("MirrorX", "EditorIcons"));
- flip_vertical_button->set_icon(get_icon("MirrorY", "EditorIcons"));
- clear_transform_button->set_icon(get_icon("Clear", "EditorIcons"));
+ rotate_left_button->set_icon(get_theme_icon("RotateLeft", "EditorIcons"));
+ rotate_right_button->set_icon(get_theme_icon("RotateRight", "EditorIcons"));
+ flip_horizontal_button->set_icon(get_theme_icon("MirrorX", "EditorIcons"));
+ flip_vertical_button->set_icon(get_theme_icon("MirrorY", "EditorIcons"));
+ clear_transform_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
PopupMenu *p = options->get_popup();
- p->set_item_icon(p->get_item_index(OPTION_CUT), get_icon("ActionCut", "EditorIcons"));
- p->set_item_icon(p->get_item_index(OPTION_COPY), get_icon("Duplicate", "EditorIcons"));
- p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_icon("Remove", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(OPTION_CUT), get_theme_icon("ActionCut", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(OPTION_COPY), get_theme_icon("Duplicate", "EditorIcons"));
+ p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_theme_icon("Remove", "EditorIcons"));
} break;
}
@@ -421,7 +421,7 @@ void TileMapEditor::_update_palette() {
bool show_tile_ids = bool(EDITOR_DEF("editors/tile_map/show_tile_ids", false));
bool sort_by_name = bool(EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true));
- palette->add_constant_override("hseparation", hseparation * EDSCALE);
+ palette->add_theme_constant_override("hseparation", hseparation * EDSCALE);
palette->set_fixed_icon_size(Size2(min_size, min_size));
palette->set_fixed_column_width(min_size * MAX(size_slider->get_value(), 1));
@@ -984,7 +984,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (mb->is_pressed()) {
- if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SPACE))
return false; // Drag.
if (tool == TOOL_NONE) {
@@ -1365,7 +1365,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
- if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (tool == TOOL_PICKING && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
_pick_tile(over_tile);
@@ -1960,7 +1960,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
palette->set_icon_mode(ItemList::ICON_MODE_TOP);
palette->set_max_text_lines(2);
palette->set_select_mode(ItemList::SELECT_MULTI);
- palette->add_constant_override("vseparation", 8 * EDSCALE);
+ palette->add_theme_constant_override("vseparation", 8 * EDSCALE);
palette->connect("item_selected", callable_mp(this, &TileMapEditor::_palette_selected));
palette->connect("multi_selected", callable_mp(this, &TileMapEditor::_palette_multi_selected));
palette_container->add_child(palette);
@@ -2031,7 +2031,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
tile_info = memnew(Label);
tile_info->set_modulate(Color(1, 1, 1, 0.8));
tile_info->set_mouse_filter(MOUSE_FILTER_IGNORE);
- tile_info->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts"));
+ tile_info->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
// The tile info is only displayed after a tile has been hovered.
tile_info->hide();
CanvasItemEditor::get_singleton()->add_control_to_info_overlay(tile_info);
@@ -2039,7 +2039,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
// Menu.
options = memnew(MenuButton);
options->set_text("TileMap");
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("TileMap", "EditorIcons"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("TileMap", "EditorIcons"));
options->set_process_unhandled_key_input(false);
toolbar_right->add_child(options);
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index a5a667802e..f479139e4d 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -30,12 +30,12 @@
#include "tile_set_editor_plugin.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "scene/2d/physics_body_2d.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
@@ -53,7 +53,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Node *child = p_node->get_child(i);
- if (!Object::cast_to<Sprite>(child)) {
+ if (!Object::cast_to<Sprite2D>(child)) {
if (child->get_child_count() > 0) {
_import_node(child, p_library);
}
@@ -61,7 +61,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
continue;
}
- Sprite *mi = Object::cast_to<Sprite>(child);
+ Sprite2D *mi = Object::cast_to<Sprite2D>(child);
Ref<Texture2D> texture = mi->get_texture();
Ref<Texture2D> normal_map = mi->get_normal_map();
Ref<ShaderMaterial> material = mi->get_material();
@@ -284,47 +284,47 @@ void TileSetEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- add_constant_override("autohide", 1); // Fixes the dragger always showing up.
+ add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_icon(get_icon("ToolAddNode", "EditorIcons"));
- tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->set_icon(get_icon("Remove", "EditorIcons"));
- tileset_toolbar_tools->set_icon(get_icon("Tools", "EditorIcons"));
-
- tool_workspacemode[WORKSPACE_EDIT]->set_icon(get_icon("Edit", "EditorIcons"));
- tool_workspacemode[WORKSPACE_CREATE_SINGLE]->set_icon(get_icon("AddSingleTile", "EditorIcons"));
- tool_workspacemode[WORKSPACE_CREATE_AUTOTILE]->set_icon(get_icon("AddAutotile", "EditorIcons"));
- tool_workspacemode[WORKSPACE_CREATE_ATLAS]->set_icon(get_icon("AddAtlasTile", "EditorIcons"));
-
- tools[TOOL_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons"));
- tools[BITMASK_COPY]->set_icon(get_icon("Duplicate", "EditorIcons"));
- tools[BITMASK_PASTE]->set_icon(get_icon("Override", "EditorIcons"));
- tools[BITMASK_CLEAR]->set_icon(get_icon("Clear", "EditorIcons"));
- tools[SHAPE_NEW_POLYGON]->set_icon(get_icon("CollisionPolygon2D", "EditorIcons"));
- tools[SHAPE_NEW_RECTANGLE]->set_icon(get_icon("CollisionShape2D", "EditorIcons"));
- tools[SELECT_PREVIOUS]->set_icon(get_icon("ArrowLeft", "EditorIcons"));
- tools[SELECT_NEXT]->set_icon(get_icon("ArrowRight", "EditorIcons"));
- tools[SHAPE_DELETE]->set_icon(get_icon("Remove", "EditorIcons"));
- tools[SHAPE_KEEP_INSIDE_TILE]->set_icon(get_icon("Snap", "EditorIcons"));
- tools[TOOL_GRID_SNAP]->set_icon(get_icon("SnapGrid", "EditorIcons"));
- tools[ZOOM_OUT]->set_icon(get_icon("ZoomLess", "EditorIcons"));
- tools[ZOOM_1]->set_icon(get_icon("ZoomReset", "EditorIcons"));
- tools[ZOOM_IN]->set_icon(get_icon("ZoomMore", "EditorIcons"));
- tools[VISIBLE_INFO]->set_icon(get_icon("InformationSign", "EditorIcons"));
+ tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_icon(get_theme_icon("ToolAddNode", "EditorIcons"));
+ tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ tileset_toolbar_tools->set_icon(get_theme_icon("Tools", "EditorIcons"));
+
+ tool_workspacemode[WORKSPACE_EDIT]->set_icon(get_theme_icon("Edit", "EditorIcons"));
+ tool_workspacemode[WORKSPACE_CREATE_SINGLE]->set_icon(get_theme_icon("AddSingleTile", "EditorIcons"));
+ tool_workspacemode[WORKSPACE_CREATE_AUTOTILE]->set_icon(get_theme_icon("AddAutotile", "EditorIcons"));
+ tool_workspacemode[WORKSPACE_CREATE_ATLAS]->set_icon(get_theme_icon("AddAtlasTile", "EditorIcons"));
+
+ tools[TOOL_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
+ tools[BITMASK_COPY]->set_icon(get_theme_icon("Duplicate", "EditorIcons"));
+ tools[BITMASK_PASTE]->set_icon(get_theme_icon("Override", "EditorIcons"));
+ tools[BITMASK_CLEAR]->set_icon(get_theme_icon("Clear", "EditorIcons"));
+ tools[SHAPE_NEW_POLYGON]->set_icon(get_theme_icon("CollisionPolygon2D", "EditorIcons"));
+ tools[SHAPE_NEW_RECTANGLE]->set_icon(get_theme_icon("CollisionShape2D", "EditorIcons"));
+ tools[SELECT_PREVIOUS]->set_icon(get_theme_icon("ArrowLeft", "EditorIcons"));
+ tools[SELECT_NEXT]->set_icon(get_theme_icon("ArrowRight", "EditorIcons"));
+ tools[SHAPE_DELETE]->set_icon(get_theme_icon("Remove", "EditorIcons"));
+ tools[SHAPE_KEEP_INSIDE_TILE]->set_icon(get_theme_icon("Snap", "EditorIcons"));
+ tools[TOOL_GRID_SNAP]->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
+ tools[ZOOM_OUT]->set_icon(get_theme_icon("ZoomLess", "EditorIcons"));
+ tools[ZOOM_1]->set_icon(get_theme_icon("ZoomReset", "EditorIcons"));
+ tools[ZOOM_IN]->set_icon(get_theme_icon("ZoomMore", "EditorIcons"));
+ tools[VISIBLE_INFO]->set_icon(get_theme_icon("InformationSign", "EditorIcons"));
_update_toggle_shape_button();
- tool_editmode[EDITMODE_REGION]->set_icon(get_icon("RegionEdit", "EditorIcons"));
- tool_editmode[EDITMODE_COLLISION]->set_icon(get_icon("StaticBody2D", "EditorIcons"));
- tool_editmode[EDITMODE_OCCLUSION]->set_icon(get_icon("LightOccluder2D", "EditorIcons"));
- tool_editmode[EDITMODE_NAVIGATION]->set_icon(get_icon("Navigation2D", "EditorIcons"));
- tool_editmode[EDITMODE_BITMASK]->set_icon(get_icon("PackedDataContainer", "EditorIcons"));
- tool_editmode[EDITMODE_PRIORITY]->set_icon(get_icon("MaterialPreviewLight1", "EditorIcons"));
- tool_editmode[EDITMODE_ICON]->set_icon(get_icon("LargeTexture", "EditorIcons"));
- tool_editmode[EDITMODE_Z_INDEX]->set_icon(get_icon("Sort", "EditorIcons"));
+ tool_editmode[EDITMODE_REGION]->set_icon(get_theme_icon("RegionEdit", "EditorIcons"));
+ tool_editmode[EDITMODE_COLLISION]->set_icon(get_theme_icon("StaticBody2D", "EditorIcons"));
+ tool_editmode[EDITMODE_OCCLUSION]->set_icon(get_theme_icon("LightOccluder2D", "EditorIcons"));
+ tool_editmode[EDITMODE_NAVIGATION]->set_icon(get_theme_icon("Navigation2D", "EditorIcons"));
+ tool_editmode[EDITMODE_BITMASK]->set_icon(get_theme_icon("PackedDataContainer", "EditorIcons"));
+ tool_editmode[EDITMODE_PRIORITY]->set_icon(get_theme_icon("MaterialPreviewLight1", "EditorIcons"));
+ tool_editmode[EDITMODE_ICON]->set_icon(get_theme_icon("LargeTexture", "EditorIcons"));
+ tool_editmode[EDITMODE_Z_INDEX]->set_icon(get_theme_icon("Sort", "EditorIcons"));
- scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
+ scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
}
}
@@ -528,8 +528,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
toolbar->add_child(spin_priority);
spin_z_index = memnew(SpinBox);
- spin_z_index->set_min(VS::CANVAS_ITEM_Z_MIN);
- spin_z_index->set_max(VS::CANVAS_ITEM_Z_MAX);
+ spin_z_index->set_min(RS::CANVAS_ITEM_Z_MIN);
+ spin_z_index->set_max(RS::CANVAS_ITEM_Z_MAX);
spin_z_index->set_step(1);
spin_z_index->set_custom_minimum_size(Size2(100, 0));
spin_z_index->connect("value_changed", callable_mp(this, &TileSetEditor::_on_z_index_changed));
@@ -601,7 +601,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
workspace->set_draw_behind_parent(true);
workspace_overlay->add_child(workspace);
- preview = memnew(Sprite);
+ preview = memnew(Sprite2D);
workspace->add_child(preview);
preview->set_centered(false);
preview->set_draw_behind_parent(true);
@@ -619,7 +619,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
//---------------
texture_dialog = memnew(EditorFileDialog);
texture_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
- texture_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILES);
+ texture_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
texture_dialog->clear_filters();
List<String> extensions;
@@ -1113,7 +1113,7 @@ void TileSetEditor::_on_workspace_draw() {
void TileSetEditor::_on_workspace_process() {
- if (Input::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) {
if (!tile_names_visible) {
tile_names_visible = true;
workspace_overlay->update();
@@ -1153,7 +1153,7 @@ void TileSetEditor::_on_workspace_overlay_draw() {
else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
c = COLOR_ATLAS;
String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
- Ref<Font> font = get_font("font", "Label");
+ Ref<Font> font = get_theme_font("font", "Label");
region.set_size(font->get_string_size(tile_id_name));
workspace_overlay->draw_rect(region, c);
region.position.y += region.size.y - 2;
@@ -1167,7 +1167,7 @@ void TileSetEditor::_on_workspace_overlay_draw() {
if (t_id < 0)
return;
- Ref<Texture2D> handle = get_icon("EditorHandle", "EditorIcons");
+ Ref<Texture2D> handle = get_theme_icon("EditorHandle", "EditorIcons");
if (draw_handles) {
for (int i = 0; i < current_shape.size(); i++) {
workspace_overlay->draw_texture(handle, current_shape[i] * workspace->get_scale().x - handle->get_size() * 0.5);
@@ -1395,7 +1395,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
if ((mb->get_button_index() == BUTTON_RIGHT || mb->get_button_index() == BUTTON_LEFT) && current_tile_region.has_point(mb->get_position())) {
dragging = true;
erasing = (mb->get_button_index() == BUTTON_RIGHT);
- alternative = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ alternative = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT);
Vector2 coord((int)((mb->get_position().x - current_tile_region.position.x) / (spacing + size.x)), (int)((mb->get_position().y - current_tile_region.position.y) / (spacing + size.y)));
Vector2 pos(coord.x * (spacing + size.x), coord.y * (spacing + size.y));
pos = mb->get_position() - (pos + current_tile_region.position);
@@ -2019,10 +2019,10 @@ void TileSetEditor::_update_toggle_shape_button() {
separator_shape_toggle->hide();
tools[SHAPE_TOGGLE_TYPE]->hide();
} else if (concave.is_valid()) {
- tools[SHAPE_TOGGLE_TYPE]->set_icon(get_icon("ConvexPolygonShape2D", "EditorIcons"));
+ tools[SHAPE_TOGGLE_TYPE]->set_icon(get_theme_icon("ConvexPolygonShape2D", "EditorIcons"));
tools[SHAPE_TOGGLE_TYPE]->set_text(TTR("Make Convex"));
} else if (convex.is_valid()) {
- tools[SHAPE_TOGGLE_TYPE]->set_icon(get_icon("ConcavePolygonShape2D", "EditorIcons"));
+ tools[SHAPE_TOGGLE_TYPE]->set_icon(get_theme_icon("ConcavePolygonShape2D", "EditorIcons"));
tools[SHAPE_TOGGLE_TYPE]->set_text(TTR("Make Concave"));
} else {
// Shouldn't happen
@@ -3485,7 +3485,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const
p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_navigation_offset"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_shape_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_shape_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::INT, "tile_z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"));
+ p_list->push_back(PropertyInfo(Variant::INT, "tile_z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"));
}
if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_COLLISION && tileset_editor->edited_collision_shape.is_valid()) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_collision", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_collision_shape->get_class()));
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 0d106ed454..53f8e8c4d6 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -32,7 +32,7 @@
#define TILE_SET_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/tile_set.h"
@@ -136,7 +136,7 @@ class TileSetEditor : public HSplitContainer {
Ref<NavigationPolygon> edited_navigation_shape;
int current_item_index;
- Sprite *preview;
+ Sprite2D *preview;
ScrollContainer *scroll;
Label *empty_message;
Control *workspace_container;
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index da80eee253..3998a3233b 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -217,12 +217,12 @@ void VersionControlEditorPlugin::_stage_selected() {
if (file_entry->is_checked(0)) {
EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0));
- file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor"));
+ file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
staged_files_count++;
} else {
EditorVCSInterface::get_singleton()->unstage_file(file_entry->get_metadata(0));
- file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
}
file_entry = file_entry->get_next();
@@ -248,7 +248,7 @@ void VersionControlEditorPlugin::_stage_all() {
while (file_entry) {
EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0));
- file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor"));
+ file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
file_entry->set_checked(0, true);
staged_files_count++;
@@ -275,20 +275,20 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) {
diff_file_name->set_text(p_file_path);
diff->clear();
- diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
+ diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts"));
for (int i = 0; i < diff_content.size(); i++) {
Dictionary line_result = diff_content[i];
if (line_result["status"] == "+") {
- diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor"));
+ diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
} else if (line_result["status"] == "-") {
- diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
} else {
- diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_color("font_color", "Label"));
+ diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Label"));
}
diff->add_text((String)line_result["content"]);
@@ -408,11 +408,10 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
staged_files_count = 0;
version_control_actions = memnew(PopupMenu);
- version_control_actions->set_v_size_flags(BoxContainer::SIZE_SHRINK_CENTER);
set_up_dialog = memnew(AcceptDialog);
set_up_dialog->set_title(TTR("Set Up Version Control"));
- set_up_dialog->set_custom_minimum_size(Size2(400, 100));
+ set_up_dialog->set_min_size(Size2(400, 100));
version_control_actions->add_child(set_up_dialog);
set_up_ok_button = set_up_dialog->get_ok();
@@ -446,9 +445,6 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_init_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_initialize_vcs));
set_up_vbc->add_child(set_up_init_button);
- version_control_actions->set_v_size_flags(PopupMenu::SIZE_EXPAND_FILL);
- version_control_actions->set_h_size_flags(PopupMenu::SIZE_EXPAND_FILL);
-
version_commit_dock = memnew(VBoxContainer);
version_commit_dock->set_visible(false);
@@ -470,7 +466,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
refresh_button = memnew(Button);
refresh_button->set_tooltip(TTR("Detect new changes"));
refresh_button->set_text(TTR("Refresh"));
- refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Reload", "EditorIcons"));
+ refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons"));
refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));
stage_tools->add_child(refresh_button);
@@ -495,11 +491,11 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
change_type_to_strings[CHANGE_TYPE_DELETED] = TTR("Deleted");
change_type_to_strings[CHANGE_TYPE_TYPECHANGE] = TTR("Typechange");
- change_type_to_color[CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor");
- change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor");
- change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_color("disabled_font_color", "Editor");
- change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor");
- change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_color("font_color", "Editor");
+ change_type_to_color[CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor");
+ change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor");
+ change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("disabled_font_color", "Editor");
+ change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor");
+ change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Editor");
stage_buttons = memnew(HSplitContainer);
stage_buttons->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN_COLLAPSED);
@@ -562,7 +558,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
diff_refresh_button = memnew(Button);
diff_refresh_button->set_tooltip(TTR("Detect changes in file diff"));
- diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Reload", "EditorIcons"));
+ diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons"));
diff_refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_file_diff));
diff_hbc->add_child(diff_refresh_button);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 9100e28352..594dc400ec 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -30,9 +30,9 @@
#include "visual_shader_editor_plugin.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_loader.h"
#include "core/math/math_defs.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "core/version.h"
@@ -42,9 +42,10 @@
#include "scene/animation/animation_player.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/visual_shader_nodes.h"
-#include "servers/visual/shader_types.h"
+#include "servers/display_server.h"
+#include "servers/rendering/shader_types.h"
Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
@@ -312,8 +313,8 @@ void VisualShaderEditor::_update_options_menu() {
bool is_first_item = true;
- Color unsupported_color = get_color("error_color", "Editor");
- Color supported_color = get_color("warning_color", "Editor");
+ Color unsupported_color = get_theme_color("error_color", "Editor");
+ Color supported_color = get_theme_color("warning_color", "Editor");
static bool low_driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name") == "GLES2";
@@ -385,22 +386,22 @@ void VisualShaderEditor::_update_options_menu() {
}
switch (options[i].return_type) {
case VisualShaderNode::PORT_TYPE_SCALAR:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"));
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_SCALAR_INT:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("int", "EditorIcons"));
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_VECTOR:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"));
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_BOOLEAN:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"));
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_TRANSFORM:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"));
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_SAMPLER:
- item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons"));
+ item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"));
break;
default:
break;
@@ -420,7 +421,7 @@ void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) {
if (!button)
return;
- Ref<StyleBox> normal = get_stylebox("normal", "Button");
+ Ref<StyleBox> normal = get_theme_stylebox("normal", "Button");
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
@@ -436,7 +437,7 @@ static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_
void VisualShaderEditor::_update_created_node(GraphNode *node) {
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
- Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode");
+ Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode");
Color c = sb->get_border_color();
Color ic;
Color mono_color;
@@ -450,10 +451,10 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
mono_color.a = 0.85;
c = mono_color;
- node->add_color_override("title_color", c);
+ node->add_theme_color_override("title_color", c);
c.a = 0.7;
- node->add_color_override("close_color", c);
- node->add_color_override("resizer_color", ic);
+ node->add_theme_color_override("close_color", c);
+ node->add_theme_color_override("resizer_color", ic);
}
}
@@ -641,7 +642,7 @@ void VisualShaderEditor::_update_graph() {
}
HBoxContainer *hb = memnew(HBoxContainer);
- hb->add_constant_override("separation", 7 * EDSCALE);
+ hb->add_theme_constant_override("separation", 7 * EDSCALE);
Variant default_value;
@@ -705,7 +706,7 @@ void VisualShaderEditor::_update_graph() {
name_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_port_name_focus_out), varray(name_box, nodes[n_i], i, false));
Button *remove_btn = memnew(Button);
- remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
@@ -713,15 +714,15 @@ void VisualShaderEditor::_update_graph() {
Label *label = memnew(Label);
label->set_text(name_left);
- label->add_style_override("normal", label_style); //more compact
+ label->add_theme_style_override("normal", label_style); //more compact
hb->add_child(label);
if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) {
Label *hint_label = memnew(Label);
hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]");
- hint_label->add_color_override("font_color", get_color("font_color_readonly", "TextEdit"));
- hint_label->add_style_override("normal", label_style);
+ hint_label->add_theme_color_override("font_color", get_theme_color("font_color_readonly", "TextEdit"));
+ hint_label->add_theme_style_override("normal", label_style);
hb->add_child(hint_label);
}
}
@@ -734,7 +735,7 @@ void VisualShaderEditor::_update_graph() {
if (valid_right) {
if (is_group) {
Button *remove_btn = memnew(Button);
- remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_output_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
@@ -760,7 +761,7 @@ void VisualShaderEditor::_update_graph() {
} else {
Label *label = memnew(Label);
label->set_text(name_right);
- label->add_style_override("normal", label_style); //more compact
+ label->add_theme_style_override("normal", label_style); //more compact
hb->add_child(label);
}
}
@@ -769,8 +770,8 @@ void VisualShaderEditor::_update_graph() {
if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) {
TextureButton *preview = memnew(TextureButton);
preview->set_toggle_mode(true);
- preview->set_normal_texture(get_icon("GuiVisibilityHidden", "EditorIcons"));
- preview->set_pressed_texture(get_icon("GuiVisibilityVisible", "EditorIcons"));
+ preview->set_normal_texture(get_theme_icon("GuiVisibilityHidden", "EditorIcons"));
+ preview->set_pressed_texture(get_theme_icon("GuiVisibilityVisible", "EditorIcons"));
preview->set_v_size_flags(SIZE_SHRINK_CENTER);
if (vsnode->get_output_port_for_preview() == i) {
@@ -815,7 +816,7 @@ void VisualShaderEditor::_update_graph() {
String error = vsnode->get_warning(visual_shader->get_mode(), type);
if (error != String()) {
Label *error_label = memnew(Label);
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
error_label->set_text(error);
node->add_child(error_label);
}
@@ -833,16 +834,16 @@ void VisualShaderEditor::_update_graph() {
Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
expression_box->set_syntax_coloring(true);
- expression_box->add_color_override("background_color", background_color);
+ expression_box->add_theme_color_override("background_color", background_color);
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
expression_box->add_keyword_color(E->get(), keyword_color);
}
- expression_box->add_font_override("font", get_font("expression", "EditorFonts"));
- expression_box->add_color_override("font_color", text_color);
- expression_box->add_color_override("symbol_color", symbol_color);
+ expression_box->add_theme_font_override("font", get_theme_font("expression", "EditorFonts"));
+ expression_box->add_theme_color_override("font_color", text_color);
+ expression_box->add_theme_color_override("symbol_color", symbol_color);
expression_box->add_color_region("/*", "*/", comment_color, false);
expression_box->add_color_region("//", "", comment_color, false);
@@ -1272,7 +1273,7 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node,
Button *button = Object::cast_to<Button>(p_button);
ERR_FAIL_COND(!button);
Variant value = vsn->get_input_port_default_value(p_port);
- property_editor->set_global_position(button->get_global_position() + Vector2(0, button->get_size().height));
+ property_editor->set_position(button->get_screen_position() + Vector2(0, button->get_size().height));
property_editor->edit(NULL, "", value.get_type(), value, 0, "");
property_editor->popup();
editing_node = p_node;
@@ -1623,7 +1624,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.empty());
popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.empty());
menu_point = graph->get_local_mouse_position();
- Point2 gpos = Input::get_singleton()->get_mouse_position();
+ Point2 gpos = InputFilter::get_singleton()->get_mouse_position();
popup_menu->set_position(gpos);
popup_menu->popup();
}
@@ -1636,7 +1637,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
saved_node_pos_dirty = true;
saved_node_pos = graph->get_local_mouse_position();
- Point2 gpos = Input::get_singleton()->get_mouse_position();
+ Point2 gpos = InputFilter::get_singleton()->get_mouse_position();
members_dialog->popup();
members_dialog->set_position(gpos);
} else {
@@ -1646,8 +1647,8 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
}
// keep dialog within window bounds
- Size2 window_size = OS::get_singleton()->get_window_size();
- Rect2 dialog_rect = members_dialog->get_global_rect();
+ Size2 window_size = DisplayServer::get_singleton()->window_get_size();
+ Rect2 dialog_rect = Rect2(members_dialog->get_position(), members_dialog->get_size());
if (dialog_rect.position.y + dialog_rect.size.y > window_size.y) {
int difference = dialog_rect.position.y + dialog_rect.size.y - window_size.y;
members_dialog->set_position(members_dialog->get_position() - Point2(0, difference));
@@ -1703,14 +1704,14 @@ void VisualShaderEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- highend_label->set_modulate(get_color("vulkan_color", "Editor"));
+ highend_label->set_modulate(get_theme_color("vulkan_color", "Editor"));
- error_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
+ error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
- node_filter->set_right_icon(Control::get_icon("Search", "EditorIcons"));
+ node_filter->set_right_icon(Control::get_theme_icon("Search", "EditorIcons"));
- preview_shader->set_icon(Control::get_icon("Shader", "EditorIcons"));
+ preview_shader->set_icon(Control::get_theme_icon("Shader", "EditorIcons"));
{
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
@@ -1719,24 +1720,24 @@ void VisualShaderEditor::_notification(int p_what) {
Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
- preview_text->add_color_override("background_color", background_color);
+ preview_text->add_theme_color_override("background_color", background_color);
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
preview_text->add_keyword_color(E->get(), keyword_color);
}
- preview_text->add_font_override("font", get_font("expression", "EditorFonts"));
- preview_text->add_color_override("font_color", text_color);
- preview_text->add_color_override("symbol_color", symbol_color);
+ preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts"));
+ preview_text->add_theme_color_override("font_color", text_color);
+ preview_text->add_theme_color_override("symbol_color", symbol_color);
preview_text->add_color_region("/*", "*/", comment_color, false);
preview_text->add_color_region("//", "", comment_color, false);
- error_text->add_font_override("font", get_font("status_source", "EditorFonts"));
- error_text->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_text->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts"));
+ error_text->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
}
- tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Tools", "EditorIcons"));
+ tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Tools", "EditorIcons"));
if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree())
_update_graph();
@@ -2262,7 +2263,7 @@ void VisualShaderEditor::_update_preview() {
ShaderLanguage sl;
- Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types());
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types());
for (int i = 0; i < preview_text->get_line_count(); i++) {
preview_text->set_line_as_marked(i, false);
@@ -2489,13 +2490,10 @@ VisualShaderEditor::VisualShaderEditor() {
members_dialog->get_ok()->set_text(TTR("Create"));
members_dialog->get_ok()->connect("pressed", callable_mp(this, &VisualShaderEditor::_member_create));
members_dialog->get_ok()->set_disabled(true);
- members_dialog->set_resizable(true);
- members_dialog->set_as_minsize();
- members_dialog->connect("hide", callable_mp(this, &VisualShaderEditor::_member_cancel));
+ members_dialog->connect("cancelled", callable_mp(this, &VisualShaderEditor::_member_cancel));
add_child(members_dialog);
alert = memnew(AcceptDialog);
- alert->set_as_minsize();
alert->get_label()->set_autowrap(true);
alert->get_label()->set_align(Label::ALIGN_CENTER);
alert->get_label()->set_valign(Label::VALIGN_CENTER);
@@ -2669,6 +2667,38 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Transform", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
add_options.push_back(AddOption("Velocity", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ // SKY INPUTS
+
+ add_options.push_back(AddOption("AtCubeMapPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtHalfResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("AtQuarterResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("EyeDir", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("HalfResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("HalfResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light0Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light1Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light2Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Light3Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Position", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("QuarterResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("QuarterResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Radiance", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("SkyCoords", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+ add_options.push_back(AddOption("Time", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY));
+
// SCALAR
add_options.push_back(AddOption("FloatFunc", "Scalar", "Common", "VisualShaderNodeFloatFunc", TTR("Float function."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
@@ -2950,12 +2980,12 @@ public:
void setup(const Ref<VisualShaderNodeInput> &p_input) {
input = p_input;
Ref<Texture2D> type_icon[6] = {
- EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"),
- EditorNode::get_singleton()->get_gui_base()->get_icon("int", "EditorIcons"),
- EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"),
- EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"),
- EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"),
- EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform", "EditorIcons"),
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"),
};
add_item("[None]");
diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp
index cdc5255edd..859718cba4 100644
--- a/editor/progress_dialog.cpp
+++ b/editor/progress_dialog.cpp
@@ -34,6 +34,7 @@
#include "core/os/os.h"
#include "editor_scale.h"
#include "main/main.h"
+#include "servers/display_server.h"
void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) {
@@ -137,16 +138,6 @@ void BackgroundProgress::end_task(const String &p_task) {
ProgressDialog *ProgressDialog::singleton = NULL;
void ProgressDialog::_notification(int p_what) {
-
- switch (p_what) {
-
- case NOTIFICATION_DRAW: {
-
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
- draw_style_box(style, Rect2(Point2(), get_size()));
-
- } break;
- }
}
void ProgressDialog::_popup() {
@@ -154,14 +145,14 @@ void ProgressDialog::_popup() {
Size2 ms = main->get_combined_minimum_size();
ms.width = MAX(500 * EDSCALE, ms.width);
- Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ Ref<StyleBox> style = main->get_theme_stylebox("panel", "PopupMenu");
ms += style->get_minimum_size();
main->set_margin(MARGIN_LEFT, style->get_margin(MARGIN_LEFT));
main->set_margin(MARGIN_RIGHT, -style->get_margin(MARGIN_RIGHT));
main->set_margin(MARGIN_TOP, style->get_margin(MARGIN_TOP));
main->set_margin(MARGIN_BOTTOM, -style->get_margin(MARGIN_BOTTOM));
- raise();
+ //raise();
popup_centered(ms);
}
@@ -219,7 +210,7 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int
t.state->set_text(p_state);
last_progress_tick = OS::get_singleton()->get_ticks_usec();
if (cancel_hb->is_visible()) {
- OS::get_singleton()->force_process_input();
+ DisplayServer::get_singleton()->process_events();
}
Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor
diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h
index e01c7d802b..82f479ae9d 100644
--- a/editor/progress_dialog.h
+++ b/editor/progress_dialog.h
@@ -68,9 +68,9 @@ public:
BackgroundProgress() {}
};
-class ProgressDialog : public Popup {
+class ProgressDialog : public PopupPanel {
- GDCLASS(ProgressDialog, Popup);
+ GDCLASS(ProgressDialog, PopupPanel);
struct Task {
String task;
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 37b959c78a..39c24519c0 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -46,25 +46,28 @@
#include "scene/gui/margin_container.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/tab_container.h"
-
+#include "servers/display_server.h"
+
+void ProjectExportDialog::_theme_changed() {
+ duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons"));
+ delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons"));
+ Control *panel = custom_feature_display->get_parent_control();
+ if (panel)
+ panel->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree"));
+}
void ProjectExportDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible()) {
+ EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "export", Rect2(get_position(), get_size()));
+ }
+ } break;
case NOTIFICATION_READY: {
- duplicate_preset->set_icon(get_icon("Duplicate", "EditorIcons"));
- delete_preset->set_icon(get_icon("Remove", "EditorIcons"));
+ duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons"));
+ delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons"));
connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip));
- custom_feature_display->get_parent_control()->add_style_override("panel", get_stylebox("bg", "Tree"));
- } break;
- case NOTIFICATION_POPUP_HIDE: {
- EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "export", get_rect());
- } break;
- case NOTIFICATION_THEME_CHANGED: {
- duplicate_preset->set_icon(get_icon("Duplicate", "EditorIcons"));
- delete_preset->set_icon(get_icon("Remove", "EditorIcons"));
- Control *panel = custom_feature_display->get_parent_control();
- if (panel)
- panel->add_style_override("panel", get_stylebox("bg", "Tree"));
+ custom_feature_display->get_parent_control()->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree"));
} break;
}
}
@@ -247,8 +250,8 @@ void ProjectExportDialog::_edit_preset(int p_index) {
patch->set_checked(0, true);
patch->set_tooltip(0, patchlist[i]);
patch->set_metadata(0, i);
- patch->add_button(0, get_icon("Remove", "EditorIcons"), 0);
- patch->add_button(0, get_icon("folder", "FileDialog"), 1);
+ patch->add_button(0, presets->get_theme_icon("Remove", "EditorIcons"), 0);
+ patch->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1);
}
TreeItem *patch_add = patches->create_item(patch_root);
@@ -258,7 +261,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
else
patch_add->set_text(0, TTR("Add previous patches..."));
- patch_add->add_button(0, get_icon("folder", "FileDialog"), 1);
+ patch_add->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1);
_fill_resource_tree();
@@ -299,7 +302,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
custom_features->set_text(current->get_custom_features());
_update_feature_list();
_update_export_all();
- minimum_size_changed();
+ child_controls_changed();
int script_export_mode = current->get_script_export_mode();
script_mode->select(script_export_mode);
@@ -388,7 +391,7 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in
Vector<String> patches = current->get_patches();
ERR_FAIL_INDEX(patch_index, patches.size());
patch_erase->set_text(vformat(TTR("Delete patch '%s' from list?"), patches[patch_index].get_file()));
- patch_erase->popup_centered_minsize();
+ patch_erase->popup_centered();
} else {
patch_dialog->popup_centered_ratio();
}
@@ -618,7 +621,7 @@ void ProjectExportDialog::_delete_preset() {
return;
delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name()));
- delete_confirm->popup_centered_minsize();
+ delete_confirm->popup_centered();
}
void ProjectExportDialog::_delete_preset_confirm() {
@@ -649,7 +652,7 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
label->set_text(presets->get_item_text(pos));
drag->add_child(label);
- set_drag_preview(drag);
+ presets->set_drag_preview(drag);
return d;
}
@@ -666,7 +669,7 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
Label *label = memnew(Label);
label->set_text(item->get_text(0));
- set_drag_preview(label);
+ patches->set_drag_preview(label);
return d;
}
@@ -816,7 +819,7 @@ void ProjectExportDialog::_fill_resource_tree() {
bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> &current, bool p_only_scenes) {
- p_item->set_icon(0, get_icon("folder", "FileDialog"));
+ p_item->set_icon(0, presets->get_theme_icon("folder", "FileDialog"));
p_item->set_text(0, p_dir->get_name() + "/");
bool used = false;
@@ -954,7 +957,7 @@ void ProjectExportDialog::_export_project() {
export_project->get_line_edit()->connect_compat("text_entered", export_project, "_file_entered");
}
- export_project->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ export_project->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
export_project->popup_centered_ratio();
}
@@ -979,14 +982,14 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) {
ERR_PRINT(vformat("Failed to export the project for platform '%s'.", platform->get_name()));
error_dialog->show();
- error_dialog->popup_centered_minsize(Size2(300, 80));
+ error_dialog->popup_centered(Size2(300, 80));
}
}
void ProjectExportDialog::_export_all_dialog() {
export_all_dialog->show();
- export_all_dialog->popup_centered_minsize(Size2(300, 80));
+ export_all_dialog->popup_centered(Size2(300, 80));
}
void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
@@ -1017,7 +1020,7 @@ void ProjectExportDialog::_export_all(bool p_debug) {
error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name());
}
error_dialog->show();
- error_dialog->popup_centered_minsize(Size2(300, 80));
+ error_dialog->popup_centered(Size2(300, 80));
ERR_PRINT("Failed to export project");
}
}
@@ -1039,13 +1042,13 @@ void ProjectExportDialog::_bind_methods() {
ProjectExportDialog::ProjectExportDialog() {
set_title(TTR("Export"));
- set_resizable(true);
VBoxContainer *main_vb = memnew(VBoxContainer);
+ main_vb->connect("theme_changed", callable_mp(this, &ProjectExportDialog::_theme_changed));
add_child(main_vb);
HSplitContainer *hbox = memnew(HSplitContainer);
main_vb->add_child(hbox);
- hbox->set_v_size_flags(SIZE_EXPAND_FILL);
+ hbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
// Presets list.
@@ -1064,9 +1067,12 @@ ProjectExportDialog::ProjectExportDialog() {
preset_hb->add_child(add_preset);
MarginContainer *mc = memnew(MarginContainer);
preset_vb->add_child(mc);
- mc->set_v_size_flags(SIZE_EXPAND_FILL);
+ mc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
presets = memnew(ItemList);
- presets->set_drag_forwarding(this);
+#ifndef _MSC_VER
+#warning must reimplement drag forward
+#endif
+ //presets->set_drag_forwarding(this);
mc->add_child(presets);
presets->connect("item_selected", callable_mp(this, &ProjectExportDialog::_edit_preset));
duplicate_preset = memnew(ToolButton);
@@ -1104,14 +1110,14 @@ ProjectExportDialog::ProjectExportDialog() {
sections->set_tab_align(TabContainer::ALIGN_LEFT);
sections->set_use_hidden_tabs_for_min_size(true);
settings_vb->add_child(sections);
- sections->set_v_size_flags(SIZE_EXPAND_FILL);
+ sections->set_v_size_flags(Control::SIZE_EXPAND_FILL);
// Main preset parameters.
parameters = memnew(EditorInspector);
sections->add_child(parameters);
parameters->set_name(TTR("Options"));
- parameters->set_v_size_flags(SIZE_EXPAND_FILL);
+ parameters->set_v_size_flags(Control::SIZE_EXPAND_FILL);
parameters->connect("property_edited", callable_mp(this, &ProjectExportDialog::_update_parameters));
// Resources export parameters.
@@ -1131,7 +1137,7 @@ ProjectExportDialog::ProjectExportDialog() {
include_label->set_text(TTR("Resources to export:"));
resources_vb->add_child(include_label);
include_margin = memnew(MarginContainer);
- include_margin->set_v_size_flags(SIZE_EXPAND_FILL);
+ include_margin->set_v_size_flags(Control::SIZE_EXPAND_FILL);
resources_vb->add_child(include_margin);
include_files = memnew(Tree);
@@ -1163,11 +1169,14 @@ ProjectExportDialog::ProjectExportDialog() {
patches = memnew(Tree);
patch_vb->add_child(patches);
- patches->set_v_size_flags(SIZE_EXPAND_FILL);
+ patches->set_v_size_flags(Control::SIZE_EXPAND_FILL);
patches->set_hide_root(true);
patches->connect("button_pressed", callable_mp(this, &ProjectExportDialog::_patch_button_pressed));
patches->connect("item_edited", callable_mp(this, &ProjectExportDialog::_patch_edited));
- patches->set_drag_forwarding(this);
+#ifndef _MSC_VER
+#warning must reimplement drag forward
+#endif
+ //patches->set_drag_forwarding(this);
patches->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
HBoxContainer *patches_hb = memnew(HBoxContainer);
@@ -1180,7 +1189,7 @@ ProjectExportDialog::ProjectExportDialog() {
patch_dialog = memnew(EditorFileDialog);
patch_dialog->add_filter("*.pck ; " + TTR("Pack File"));
- patch_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ patch_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
patch_dialog->connect("file_selected", callable_mp(this, &ProjectExportDialog::_patch_selected));
add_child(patch_dialog);
@@ -1200,7 +1209,7 @@ ProjectExportDialog::ProjectExportDialog() {
custom_feature_display = memnew(RichTextLabel);
features_panel->add_child(custom_feature_display);
custom_feature_display->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 10 * EDSCALE);
- custom_feature_display->set_v_size_flags(SIZE_EXPAND_FILL);
+ custom_feature_display->set_v_size_flags(Control::SIZE_EXPAND_FILL);
feature_vb->add_margin_child(TTR("Feature List:"), features_panel, true);
sections->add_child(feature_vb);
@@ -1220,7 +1229,7 @@ ProjectExportDialog::ProjectExportDialog() {
script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed));
script_key_error = memnew(Label);
script_key_error->set_text("- " + TTR("Invalid Encryption Key (must be 64 characters long)"));
- script_key_error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
script_vb->add_margin_child(TTR("Script Encryption Key (256-bits as hex):"), script_key);
script_vb->add_child(script_key_error);
sections->add_child(script_vb);
@@ -1250,7 +1259,7 @@ ProjectExportDialog::ProjectExportDialog() {
get_cancel()->set_text(TTR("Close"));
get_ok()->set_text(TTR("Export PCK/Zip"));
- export_button = add_button(TTR("Export Project"), !OS::get_singleton()->get_swap_ok_cancel(), "export");
+ export_button = add_button(TTR("Export Project"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "export");
export_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_project));
// Disable initially before we select a valid preset
export_button->set_disabled(true);
@@ -1265,7 +1274,7 @@ ProjectExportDialog::ProjectExportDialog() {
export_all_dialog->add_button(TTR("Release"), true, "release");
export_all_dialog->connect("custom_action", callable_mp(this, &ProjectExportDialog::_export_all_dialog_action));
- export_all_button = add_button(TTR("Export All"), !OS::get_singleton()->get_swap_ok_cancel(), "export");
+ export_all_button = add_button(TTR("Export All"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "export");
export_all_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_all_dialog));
export_all_button->set_disabled(true);
@@ -1273,14 +1282,14 @@ ProjectExportDialog::ProjectExportDialog() {
export_pck_zip->add_filter("*.zip ; " + TTR("ZIP File"));
export_pck_zip->add_filter("*.pck ; " + TTR("Godot Game Pack"));
export_pck_zip->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- export_pck_zip->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ export_pck_zip->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
add_child(export_pck_zip);
export_pck_zip->connect("file_selected", callable_mp(this, &ProjectExportDialog::_export_pck_zip_selected));
export_error = memnew(Label);
main_vb->add_child(export_error);
export_error->hide();
- export_error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
export_templates_error = memnew(HBoxContainer);
main_vb->add_child(export_templates_error);
@@ -1288,7 +1297,7 @@ ProjectExportDialog::ProjectExportDialog() {
Label *export_error2 = memnew(Label);
export_templates_error->add_child(export_error2);
- export_error2->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " ");
error_dialog = memnew(AcceptDialog);
@@ -1299,7 +1308,7 @@ ProjectExportDialog::ProjectExportDialog() {
LinkButton *download_templates = memnew(LinkButton);
download_templates->set_text(TTR("Manage Export Templates"));
- download_templates->set_v_size_flags(SIZE_SHRINK_CENTER);
+ download_templates->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
export_templates_error->add_child(download_templates);
download_templates->connect("pressed", callable_mp(this, &ProjectExportDialog::_open_export_template_manager));
diff --git a/editor/project_export.h b/editor/project_export.h
index 00e6dfd6e3..2e311eb3b3 100644
--- a/editor/project_export.h
+++ b/editor/project_export.h
@@ -167,6 +167,7 @@ private:
void _tab_changed(int);
protected:
+ void _theme_changed();
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 4e157e927e..d3856cf778 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -51,6 +51,8 @@
#include "scene/gui/separator.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
+#include "scene/main/window.h"
+#include "servers/display_server.h"
static inline String get_project_key_from_path(const String &dir) {
return dir.replace("/", "::");
@@ -115,22 +117,22 @@ private:
case MESSAGE_ERROR: {
- msg->add_color_override("font_color", get_color("error_color", "Editor"));
+ msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor"));
msg->set_modulate(Color(1, 1, 1, 1));
- new_icon = get_icon("StatusError", "EditorIcons");
+ new_icon = msg->get_theme_icon("StatusError", "EditorIcons");
} break;
case MESSAGE_WARNING: {
- msg->add_color_override("font_color", get_color("warning_color", "Editor"));
+ msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor"));
msg->set_modulate(Color(1, 1, 1, 1));
- new_icon = get_icon("StatusWarning", "EditorIcons");
+ new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons");
} break;
case MESSAGE_SUCCESS: {
msg->set_modulate(Color(1, 1, 1, 0));
- new_icon = get_icon("StatusSuccess", "EditorIcons");
+ new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons");
} break;
}
@@ -141,7 +143,7 @@ private:
install_status_rect->set_texture(new_icon);
}
- set_size(Size2(500, 0) * EDSCALE);
+ set_size(Size2i(500, 0) * EDSCALE);
}
String _test_path() {
@@ -377,19 +379,19 @@ private:
if (mode == MODE_IMPORT) {
- fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
+ fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
fdialog->clear_filters();
fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project")));
fdialog->add_filter("*.zip ; " + TTR("ZIP File"));
} else {
- fdialog->set_mode(FileDialog::MODE_OPEN_DIR);
+ fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR);
}
fdialog->popup_centered_ratio();
}
void _browse_install_path() {
fdialog_install->set_current_dir(install_path->get_text());
- fdialog_install->set_mode(FileDialog::MODE_OPEN_DIR);
+ fdialog_install->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR);
fdialog_install->popup_centered_ratio();
}
@@ -416,12 +418,12 @@ private:
} else {
dialog_error->set_text(TTR("Couldn't create folder."));
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
}
} else {
dialog_error->set_text(TTR("There is already a folder in this path with the specified name."));
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
}
}
@@ -498,7 +500,7 @@ private:
if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector<String>(), false) != OK) {
set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR);
} else {
- ResourceSaver::save(dir.plus_file("icon.png"), get_icon("DefaultProjectIcon", "EditorIcons"));
+ ResourceSaver::save(dir.plus_file("icon.png"), msg->get_theme_icon("DefaultProjectIcon", "EditorIcons"));
FileAccess *f = FileAccess::open(dir.plus_file("default_env.tres"), FileAccess::WRITE);
if (!f) {
@@ -527,7 +529,7 @@ private:
if (!pkg) {
dialog_error->set_text(TTR("Error opening package file, not in ZIP format."));
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
return;
}
@@ -605,11 +607,11 @@ private:
}
dialog_error->set_text(msg);
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
} else if (!project_path->get_text().ends_with(".zip")) {
dialog_error->set_text(TTR("Package installed successfully!"));
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
}
}
}
@@ -647,16 +649,16 @@ private:
project_name->clear();
_text_changed("");
- if (status_rect->get_texture() == get_icon("StatusError", "EditorIcons"))
+ if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
msg->show();
- if (install_status_rect->get_texture() == get_icon("StatusError", "EditorIcons"))
+ if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
msg->show();
}
void _notification(int p_what) {
- if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST)
+ if (p_what == NOTIFICATION_WM_CLOSE_REQUEST)
_remove_created_folder();
}
@@ -786,7 +788,7 @@ public:
_test_path();
}
- popup_centered_minsize(Size2(500, 0) * EDSCALE);
+ popup_centered(Size2i(500, 0) * EDSCALE);
}
ProjectDialog() {
@@ -805,7 +807,7 @@ public:
name_container->add_child(pnhb);
project_name = memnew(LineEdit);
- project_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ project_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
pnhb->add_child(project_name);
create_dir = memnew(Button);
@@ -824,7 +826,7 @@ public:
path_container->add_child(pphb);
project_path = memnew(LineEdit);
- project_path->set_h_size_flags(SIZE_EXPAND_FILL);
+ project_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
pphb->add_child(project_path);
install_path_container = memnew(VBoxContainer);
@@ -838,7 +840,7 @@ public:
install_path_container->add_child(iphb);
install_path = memnew(LineEdit);
- install_path->set_h_size_flags(SIZE_EXPAND_FILL);
+ install_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
iphb->add_child(install_path);
// status icon
@@ -876,7 +878,7 @@ public:
rasterizer_button_group.instance();
Container *rvb = memnew(VBoxContainer);
- rvb->set_h_size_flags(SIZE_EXPAND_FILL);
+ rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rshb->add_child(rvb);
Button *rs_button = memnew(CheckBox);
rs_button->set_button_group(rasterizer_button_group);
@@ -895,7 +897,7 @@ public:
TTR("The GLES2 renderer is currently unavailable, as it needs to be reworked for Godot 4.0.\nUse Godot 3.2 if you need GLES2 support.");
rvb = memnew(VBoxContainer);
- rvb->set_h_size_flags(SIZE_EXPAND_FILL);
+ rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
rshb->add_child(rvb);
rs_button = memnew(CheckBox);
rs_button->set_button_group(rasterizer_button_group);
@@ -910,7 +912,7 @@ public:
// Also set the tooltip on the label so it appears when hovering either the checkbox or label.
l->set_tooltip(gles2_unsupported_tooltip);
// Required for the tooltip to show.
- l->set_mouse_filter(MOUSE_FILTER_STOP);
+ l->set_mouse_filter(Control::MOUSE_FILTER_STOP);
rvb->add_child(l);
l = memnew(Label);
@@ -975,7 +977,7 @@ public:
} break;
case NOTIFICATION_DRAW: {
if (hover) {
- draw_style_box(get_stylebox("hover", "Tree"), Rect2(Point2(), get_size() - Size2(10, 0) * EDSCALE));
+ draw_style_box(get_theme_stylebox("hover", "Tree"), Rect2(Point2(), get_size() - Size2(10, 0) * EDSCALE));
}
} break;
}
@@ -1045,6 +1047,9 @@ public:
ProjectList();
~ProjectList();
+ void _global_menu_new_window(const Variant &p_tag);
+ void _global_menu_open_project(const Variant &p_tag);
+
void update_dock_menu();
void load_projects();
void set_search_term(String p_search_term);
@@ -1116,7 +1121,7 @@ ProjectList::ProjectList() {
_order_option = ProjectListFilter::FILTER_EDIT_DATE;
_scroll_children = memnew(VBoxContainer);
- _scroll_children->set_h_size_flags(SIZE_EXPAND_FILL);
+ _scroll_children->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_child(_scroll_children);
_icon_load_index = 0;
@@ -1150,7 +1155,7 @@ void ProjectList::_notification(int p_what) {
void ProjectList::load_project_icon(int p_index) {
Item &item = _projects.write[p_index];
- Ref<Texture2D> default_icon = get_icon("DefaultProjectIcon", "EditorIcons");
+ Ref<Texture2D> default_icon = get_theme_icon("DefaultProjectIcon", "EditorIcons");
Ref<Texture2D> icon;
if (item.icon != "") {
Ref<Image> img;
@@ -1284,7 +1289,11 @@ void ProjectList::load_projects() {
}
void ProjectList::update_dock_menu() {
- OS::get_singleton()->global_menu_clear("_dock");
+
+ if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
+ return;
+ }
+ DisplayServer::get_singleton()->global_menu_clear("_dock");
int favs_added = 0;
int total_added = 0;
@@ -1294,18 +1303,41 @@ void ProjectList::update_dock_menu() {
favs_added++;
} else {
if (favs_added != 0) {
- OS::get_singleton()->global_menu_add_separator("_dock");
+ DisplayServer::get_singleton()->global_menu_add_separator("_dock");
}
favs_added = 0;
}
- OS::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", GLOBAL_OPEN_PROJECT, Variant(_projects[i].path.plus_file("project.godot")));
+ DisplayServer::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", callable_mp(this, &ProjectList::_global_menu_open_project), i);
total_added++;
}
}
if (total_added != 0) {
- OS::get_singleton()->global_menu_add_separator("_dock");
+ DisplayServer::get_singleton()->global_menu_add_separator("_dock");
+ }
+ DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &ProjectList::_global_menu_new_window));
+}
+
+void ProjectList::_global_menu_new_window(const Variant &p_tag) {
+ List<String> args;
+ args.push_back("-p");
+ String exec = OS::get_singleton()->get_executable_path();
+
+ OS::ProcessID pid = 0;
+ OS::get_singleton()->execute(exec, args, false, &pid);
+}
+
+void ProjectList::_global_menu_open_project(const Variant &p_tag) {
+ int idx = (int)p_tag;
+
+ if (idx >= 0 && idx < _projects.size()) {
+ String conf = _projects[idx].path.plus_file("project.godot");
+ List<String> args;
+ args.push_back(conf);
+ String exec = OS::get_singleton()->get_executable_path();
+
+ OS::ProcessID pid = 0;
+ OS::get_singleton()->execute(exec, args, false, &pid);
}
- OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
}
void ProjectList::create_project_item_control(int p_index) {
@@ -1316,13 +1348,13 @@ void ProjectList::create_project_item_control(int p_index) {
Item &item = _projects.write[p_index];
ERR_FAIL_COND(item.control != NULL); // Already created
- Ref<Texture2D> favorite_icon = get_icon("Favorites", "EditorIcons");
- Color font_color = get_color("font_color", "Tree");
+ Ref<Texture2D> favorite_icon = get_theme_icon("Favorites", "EditorIcons");
+ Color font_color = get_theme_color("font_color", "Tree");
ProjectListItemControl *hb = memnew(ProjectListItemControl);
hb->connect("draw", callable_mp(this, &ProjectList::_panel_draw), varray(hb));
hb->connect("gui_input", callable_mp(this, &ProjectList::_panel_input), varray(hb));
- hb->add_constant_override("separation", 10 * EDSCALE);
+ hb->add_theme_constant_override("separation", 10 * EDSCALE);
hb->set_tooltip(item.description);
VBoxContainer *favorite_box = memnew(VBoxContainer);
@@ -1342,7 +1374,7 @@ void ProjectList::create_project_item_control(int p_index) {
TextureRect *tf = memnew(TextureRect);
// The project icon may not be loaded by the time the control is displayed,
// so use a loading placeholder.
- tf->set_texture(get_icon("ProjectIconLoading", "EditorIcons"));
+ tf->set_texture(get_theme_icon("ProjectIconLoading", "EditorIcons"));
tf->set_v_size_flags(SIZE_SHRINK_CENTER);
if (item.missing) {
tf->set_modulate(Color(1, 1, 1, 0.5));
@@ -1353,25 +1385,25 @@ void ProjectList::create_project_item_control(int p_index) {
VBoxContainer *vb = memnew(VBoxContainer);
if (item.grayed)
vb->set_modulate(Color(1, 1, 1, 0.5));
- vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(vb);
Control *ec = memnew(Control);
ec->set_custom_minimum_size(Size2(0, 1));
ec->set_mouse_filter(MOUSE_FILTER_PASS);
vb->add_child(ec);
Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project")));
- title->add_font_override("font", get_font("title", "EditorFonts"));
- title->add_color_override("font_color", font_color);
+ title->add_theme_font_override("font", get_theme_font("title", "EditorFonts"));
+ title->add_theme_color_override("font_color", font_color);
title->set_clip_text(true);
vb->add_child(title);
HBoxContainer *path_hb = memnew(HBoxContainer);
- path_hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ path_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
vb->add_child(path_hb);
Button *show = memnew(Button);
// Display a folder icon if the project directory can be opened, or a "broken file" icon if it can't
- show->set_icon(get_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons"));
+ show->set_icon(get_theme_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons"));
show->set_flat(true);
if (!item.grayed) {
// Don't make the icon less prominent if the parent is already grayed out
@@ -1388,9 +1420,9 @@ void ProjectList::create_project_item_control(int p_index) {
Label *fpath = memnew(Label(item.path));
path_hb->add_child(fpath);
- fpath->set_h_size_flags(SIZE_EXPAND_FILL);
+ fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL);
fpath->set_modulate(Color(1, 1, 1, 0.5));
- fpath->add_color_override("font_color", font_color);
+ fpath->add_theme_color_override("font_color", font_color);
fpath->set_clip_text(true);
_scroll_children->add_child(hb);
@@ -1722,12 +1754,12 @@ void ProjectList::erase_selected_projects() {
void ProjectList::_panel_draw(Node *p_hb) {
Control *hb = Object::cast_to<Control>(p_hb);
- hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree"));
+ hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_theme_color("guide_color", "Tree"));
String key = _projects[p_hb->get_index()].project_key;
if (_selected_project_keys.has(key)) {
- hb->draw_style_box(get_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE));
+ hb->draw_style_box(get_theme_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE));
}
}
@@ -1827,13 +1859,13 @@ void ProjectManager::_notification(int p_what) {
case NOTIFICATION_RESIZED: {
if (open_templates->is_visible()) {
- open_templates->popup_centered_minsize();
+ open_templates->popup_centered();
}
} break;
case NOTIFICATION_READY: {
if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available())
- open_templates->popup_centered_minsize();
+ open_templates->popup_centered();
if (_project_list->get_project_count() >= 1) {
// Focus on the search box immediately to allow the user
@@ -1845,7 +1877,7 @@ void ProjectManager::_notification(int p_what) {
set_process_unhandled_input(is_visible_in_tree());
} break;
- case NOTIFICATION_WM_QUIT_REQUEST: {
+ case NOTIFICATION_WM_CLOSE_REQUEST: {
_dim_window();
} break;
@@ -2018,30 +2050,6 @@ void ProjectManager::_confirm_update_settings() {
_open_selected_projects();
}
-void ProjectManager::_global_menu_action(const Variant &p_id, const Variant &p_meta) {
-
- int id = (int)p_id;
- if (id == ProjectList::GLOBAL_NEW_WINDOW) {
- List<String> args;
- args.push_back("-p");
- String exec = OS::get_singleton()->get_executable_path();
-
- OS::ProcessID pid = 0;
- OS::get_singleton()->execute(exec, args, false, &pid);
- } else if (id == ProjectList::GLOBAL_OPEN_PROJECT) {
- String conf = (String)p_meta;
-
- if (conf != String()) {
- List<String> args;
- args.push_back(conf);
- String exec = OS::get_singleton()->get_executable_path();
-
- OS::ProcessID pid = 0;
- OS::get_singleton()->execute(exec, args, false, &pid);
- }
- }
-}
-
void ProjectManager::_open_selected_projects() {
const Set<String> &selected_list = _project_list->get_selected_project_keys();
@@ -2053,7 +2061,7 @@ void ProjectManager::_open_selected_projects() {
if (!FileAccess::exists(conf)) {
dialog_error->set_text(vformat(TTR("Can't open project at '%s'."), path));
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
return;
}
@@ -2091,7 +2099,7 @@ void ProjectManager::_open_selected_projects_ask() {
if (selected_list.size() > 1) {
multi_open_ask->set_text(TTR("Are you sure to open more than one project?"));
- multi_open_ask->popup_centered_minsize();
+ multi_open_ask->popup_centered();
return;
}
@@ -2107,19 +2115,19 @@ void ProjectManager::_open_selected_projects_ask() {
// Check if the config_version property was empty or 0
if (config_version == 0) {
ask_update_settings->set_text(vformat(TTR("The following project settings file does not specify the version of Godot through which it was created.\n\n%s\n\nIf you proceed with opening it, it will be converted to Godot's current configuration file format.\nWarning: You won't be able to open the project with previous versions of the engine anymore."), conf));
- ask_update_settings->popup_centered_minsize();
+ ask_update_settings->popup_centered();
return;
}
// Check if we need to convert project settings from an earlier engine version
if (config_version < ProjectSettings::CONFIG_VERSION) {
ask_update_settings->set_text(vformat(TTR("The following project settings file was generated by an older engine version, and needs to be converted for this version:\n\n%s\n\nDo you want to convert it?\nWarning: You won't be able to open the project with previous versions of the engine anymore."), conf));
- ask_update_settings->popup_centered_minsize();
+ ask_update_settings->popup_centered();
return;
}
// Check if the file was generated by a newer, incompatible engine version
if (config_version > ProjectSettings::CONFIG_VERSION) {
dialog_error->set_text(vformat(TTR("Can't open project at '%s'.") + "\n" + TTR("The project settings were created by a newer engine version, whose settings are not compatible with this version."), project.path));
- dialog_error->popup_centered_minsize();
+ dialog_error->popup_centered();
return;
}
@@ -2179,7 +2187,7 @@ void ProjectManager::_run_project() {
if (selected_list.size() > 1) {
multi_run_ask->set_text(vformat(TTR("Are you sure to run %d projects at once?"), selected_list.size()));
- multi_run_ask->popup_centered_minsize();
+ multi_run_ask->popup_centered();
} else {
_run_project_confirm();
}
@@ -2276,13 +2284,13 @@ void ProjectManager::_erase_project() {
}
erase_ask->set_text(confirm_message);
- erase_ask->popup_centered_minsize();
+ erase_ask->popup_centered();
}
void ProjectManager::_erase_missing_projects() {
erase_missing_ask->set_text(TTR("Remove all missing projects from the list?\nThe project folders' contents won't be modified."));
- erase_missing_ask->popup_centered_minsize();
+ erase_missing_ask->popup_centered();
}
void ProjectManager::_language_selected(int p_id) {
@@ -2290,7 +2298,7 @@ void ProjectManager::_language_selected(int p_id) {
String lang = language_btn->get_item_metadata(p_id);
EditorSettings::get_singleton()->set("interface/editor/editor_language", lang);
language_btn->set_text(lang);
- language_btn->set_icon(get_icon("Environment", "EditorIcons"));
+ language_btn->set_icon(get_theme_icon("Environment", "EditorIcons"));
language_restart_ask->set_text(TTR("Language changed.\nThe interface will update after restarting the editor or project manager."));
language_restart_ask->popup_centered();
@@ -2357,7 +2365,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
multi_scan_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders), varray(folders));
multi_scan_ask->set_text(
vformat(TTR("Are you sure to scan %s folders for existing Godot projects?\nThis could take a while."), folders.size()));
- multi_scan_ask->popup_centered_minsize();
+ multi_scan_ask->popup_centered();
} else {
_scan_multiple_folders(folders);
}
@@ -2413,8 +2421,12 @@ ProjectManager::ProjectManager() {
switch (display_scale) {
case 0: {
// Try applying a suitable display scale automatically
- const int screen = OS::get_singleton()->get_current_screen();
- editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
+ const int screen = DisplayServer::get_singleton()->window_get_current_screen();
+#ifdef OSX_ENABLED
+ editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen));
+#else
+ editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0);
+#endif
} break;
case 1: editor_set_scale(0.75); break;
@@ -2430,12 +2442,12 @@ ProjectManager::ProjectManager() {
}
// Define a minimum window size to prevent UI elements from overlapping or being cut off
- OS::get_singleton()->set_min_window_size(Size2(750, 420) * EDSCALE);
+ DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE);
#ifndef OSX_ENABLED
// The macOS platform implementation uses its own hiDPI window resizing code
// TODO: Resize windows on hiDPI displays on Windows and Linux and remove the line below
- OS::get_singleton()->set_window_size(OS::get_singleton()->get_window_size() * MAX(1, EDSCALE));
+ DisplayServer::get_singleton()->window_set_size(DisplayServer::get_singleton()->window_get_size() * MAX(1, EDSCALE));
#endif
}
@@ -2451,7 +2463,7 @@ ProjectManager::ProjectManager() {
Panel *panel = memnew(Panel);
gui_base->add_child(panel);
panel->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- panel->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
+ panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles"));
VBoxContainer *vb = memnew(VBoxContainer);
panel->add_child(vb);
@@ -2459,10 +2471,10 @@ ProjectManager::ProjectManager() {
String cp;
cp += 0xA9;
- OS::get_singleton()->set_window_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors");
+ DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors");
Control *center_box = memnew(Control);
- center_box->set_v_size_flags(SIZE_EXPAND_FILL);
+ center_box->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vb->add_child(center_box);
tabs = memnew(TabContainer);
@@ -2479,7 +2491,7 @@ ProjectManager::ProjectManager() {
VBoxContainer *search_tree_vb = memnew(VBoxContainer);
tree_hb->add_child(search_tree_vb);
- search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_tree_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *sort_filters = memnew(HBoxContainer);
Label *sort_label = memnew(Label);
@@ -2511,9 +2523,9 @@ ProjectManager::ProjectManager() {
search_tree_vb->add_child(sort_filters);
PanelContainer *pc = memnew(PanelContainer);
- pc->add_style_override("panel", gui_base->get_stylebox("bg", "Tree"));
+ pc->add_theme_style_override("panel", gui_base->get_theme_stylebox("bg", "Tree"));
search_tree_vb->add_child(pc);
- pc->set_v_size_flags(SIZE_EXPAND_FILL);
+ pc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
_project_list = memnew(ProjectList);
_project_list->connect(ProjectList::SIGNAL_SELECTION_CHANGED, callable_mp(this, &ProjectManager::_update_project_buttons));
@@ -2547,7 +2559,7 @@ ProjectManager::ProjectManager() {
scan_dir = memnew(FileDialog);
scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM);
- scan_dir->set_mode(FileDialog::MODE_OPEN_DIR);
+ scan_dir->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR);
scan_dir->set_title(TTR("Select a Folder to Scan")); // must be after mode or it's overridden
scan_dir->set_current_dir(EditorSettings::get_singleton()->get("filesystem/directories/default_project_path"));
gui_base->add_child(scan_dir);
@@ -2631,7 +2643,7 @@ ProjectManager::ProjectManager() {
language_btn->set_text(lang);
}
}
- language_btn->set_icon(get_icon("Environment", "EditorIcons"));
+ language_btn->set_icon(get_theme_icon("Environment", "EditorIcons"));
settings_hb->add_child(language_btn);
language_btn->connect("item_selected", callable_mp(this, &ProjectManager::_language_selected));
@@ -2689,8 +2701,7 @@ ProjectManager::ProjectManager() {
_scan_begin(EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path"));
}
- SceneTree::get_singleton()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
- SceneTree::get_singleton()->connect("global_menu_action", callable_mp(this, &ProjectManager::_global_menu_action));
+ SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
run_error_diag = memnew(AcceptDialog);
gui_base->add_child(run_error_diag);
@@ -2748,7 +2759,7 @@ void ProjectListFilter::_filter_option_selected(int p_idx) {
void ProjectListFilter::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE && has_search_box) {
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
}
}
@@ -2769,7 +2780,7 @@ void ProjectListFilter::add_search_box() {
search_box = memnew(LineEdit);
search_box->set_placeholder(TTR("Search"));
search_box->connect("text_changed", callable_mp(this, &ProjectListFilter::_search_text_changed));
- search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_child(search_box);
has_search_box = true;
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 8b9c769c59..6385000821 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -97,7 +97,6 @@ class ProjectManager : public Control {
void _restart_confirm();
void _exit_dialog();
void _scan_begin(const String &p_base);
- void _global_menu_action(const Variant &p_id, const Variant &p_meta);
void _confirm_update_settings();
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 4fb61929a3..dfecadeda5 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -31,7 +31,7 @@
#include "project_settings_editor.h"
#include "core/global_constants.h"
-#include "core/input_map.h"
+#include "core/input/input_map.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "core/translation.h"
@@ -80,7 +80,7 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventKey> k = p_event;
- if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) {
+ if (k.is_valid() && k->is_pressed()) {
if (k->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) {
if (search_button->is_pressed()) {
@@ -91,7 +91,7 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
search_button->set_pressed(true);
}
- accept_event();
+ set_input_as_handled();
}
}
}
@@ -99,22 +99,28 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
void ProjectSettingsEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible()) {
+ EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", Rect2(get_position(), get_size()));
+ set_process_unhandled_input(false);
+ }
+ } break;
case NOTIFICATION_ENTER_TREE: {
globals_editor->edit(ProjectSettings::get_singleton());
- search_button->set_icon(get_icon("Search", "EditorIcons"));
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_button->set_icon(input_editor->get_theme_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(input_editor->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
- action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
+ action_add_error->add_theme_color_override("font_color", input_editor->get_theme_color("error_color", "Editor"));
translation_list->connect("button_pressed", callable_mp(this, &ProjectSettingsEditor::_translation_delete));
_update_actions();
- popup_add->add_icon_item(get_icon("Keyboard", "EditorIcons"), TTR("Key"), INPUT_KEY); //"Key " - because the word 'key' has already been used as a key animation
- popup_add->add_icon_item(get_icon("KeyboardPhysical", "EditorIcons"), TTR("Physical Key"), INPUT_KEY_PHYSICAL);
- popup_add->add_icon_item(get_icon("JoyButton", "EditorIcons"), TTR("Joy Button"), INPUT_JOY_BUTTON);
- popup_add->add_icon_item(get_icon("JoyAxis", "EditorIcons"), TTR("Joy Axis"), INPUT_JOY_MOTION);
- popup_add->add_icon_item(get_icon("Mouse", "EditorIcons"), TTR("Mouse Button"), INPUT_MOUSE_BUTTON);
+ popup_add->add_icon_item(input_editor->get_theme_icon("Keyboard", "EditorIcons"), TTR("Key"), INPUT_KEY);
+ popup_add->add_icon_item(input_editor->get_theme_icon("KeyboardPhysical", "EditorIcons"), TTR("Physical Key"), INPUT_KEY_PHYSICAL);
+ popup_add->add_icon_item(input_editor->get_theme_icon("JoyButton", "EditorIcons"), TTR("Joy Button"), INPUT_JOY_BUTTON);
+ popup_add->add_icon_item(input_editor->get_theme_icon("JoyAxis", "EditorIcons"), TTR("Joy Axis"), INPUT_JOY_MOTION);
+ popup_add->add_icon_item(input_editor->get_theme_icon("Mouse", "EditorIcons"), TTR("Mouse Button"), INPUT_MOUSE_BUTTON);
List<String> tfn;
ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
@@ -131,26 +137,22 @@ void ProjectSettingsEditor::_notification(int p_what) {
translation_res_option_file_open->add_filter("*." + E->get());
}
- restart_close_button->set_icon(get_icon("Close", "EditorIcons"));
- restart_container->add_style_override("panel", get_stylebox("bg", "Tree"));
- restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons"));
- restart_label->add_color_override("font_color", get_color("warning_color", "Editor"));
+ restart_close_button->set_icon(input_editor->get_theme_icon("Close", "EditorIcons"));
+ restart_container->add_theme_style_override("panel", input_editor->get_theme_stylebox("bg", "Tree"));
+ restart_icon->set_texture(input_editor->get_theme_icon("StatusWarning", "EditorIcons"));
+ restart_label->add_theme_color_override("font_color", input_editor->get_theme_color("warning_color", "Editor"));
} break;
- case NOTIFICATION_POPUP_HIDE: {
- EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", get_rect());
- set_process_unhandled_input(false);
- } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- search_button->set_icon(get_icon("Search", "EditorIcons"));
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_button->set_icon(input_editor->get_theme_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(input_editor->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
- action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
- popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY), get_icon("Keyboard", "EditorIcons"));
- popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY_PHYSICAL), get_icon("KeyboardPhysical", "EditorIcons"));
- popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_BUTTON), get_icon("JoyButton", "EditorIcons"));
- popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_MOTION), get_icon("JoyAxis", "EditorIcons"));
- popup_add->set_item_icon(popup_add->get_item_index(INPUT_MOUSE_BUTTON), get_icon("Mouse", "EditorIcons"));
+ action_add_error->add_theme_color_override("font_color", input_editor->get_theme_color("error_color", "Editor"));
+ popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY), input_editor->get_theme_icon("Keyboard", "EditorIcons"));
+ popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY_PHYSICAL), input_editor->get_theme_icon("KeyboardPhysical", "EditorIcons"));
+ popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_BUTTON), input_editor->get_theme_icon("JoyButton", "EditorIcons"));
+ popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_MOTION), input_editor->get_theme_icon("JoyAxis", "EditorIcons"));
+ popup_add->set_item_icon(popup_add->get_item_index(INPUT_MOUSE_BUTTON), input_editor->get_theme_icon("Mouse", "EditorIcons"));
_update_actions();
} break;
}
@@ -462,7 +464,7 @@ void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
press_a_key_label->set_text(str);
press_a_key->get_ok()->set_disabled(false);
- press_a_key->accept_event();
+ press_a_key->set_input_as_handled();
}
}
@@ -479,7 +481,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
press_a_key->get_ok()->set_disabled(true);
last_wait_for_key = Ref<InputEvent>();
press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
- press_a_key->grab_focus();
+ //press_a_key->grab_focus();
} break;
case INPUT_KEY_PHYSICAL: {
@@ -505,7 +507,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_index->add_item(TTR("Wheel Right Button"));
device_index->add_item(TTR("X Button 1"));
device_index->add_item(TTR("X Button 2"));
- device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
+ device_input->popup_centered(Size2(350, 95) * EDSCALE);
Ref<InputEventMouseButton> mb = p_exiting_event;
if (mb.is_valid()) {
@@ -527,7 +529,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
String desc = _axis_names[i];
device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc);
}
- device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
+ device_input->popup_centered(Size2(350, 95) * EDSCALE);
Ref<InputEventJoypadMotion> jm = p_exiting_event;
if (jm.is_valid()) {
@@ -549,7 +551,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_index->add_item(itos(i) + ": " + String(_button_names[i]));
}
- device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
+ device_input->popup_centered(Size2(350, 95) * EDSCALE);
Ref<InputEventJoypadButton> jb = p_exiting_event;
if (jb.is_valid()) {
@@ -738,7 +740,7 @@ void ProjectSettingsEditor::_update_actions() {
TreeItem *item = input_editor->create_item(root);
item->set_text(0, name);
- item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ item->set_custom_bg_color(0, input_editor->get_theme_color("prop_subsection", "Editor"));
if (collapsed.has(name))
item->set_collapsed(collapsed[name]);
@@ -746,12 +748,12 @@ void ProjectSettingsEditor::_update_actions() {
item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
item->set_range_config(1, 0.0, 1.0, 0.01);
item->set_range(1, action["deadzone"]);
- item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
+ item->set_custom_bg_color(1, input_editor->get_theme_color("prop_subsection", "Editor"));
const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != NULL;
const String tooltip = is_builtin_input ? TTR("Built-in actions can't be removed as they're used for UI navigation.") : TTR("Remove");
- item->add_button(2, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
- item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, tooltip);
+ item->add_button(2, input_editor->get_theme_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
+ item->add_button(2, input_editor->get_theme_icon("Remove", "EditorIcons"), 2, false, tooltip);
if (is_builtin_input) {
// Built-in action (like `ui_up`). Make the action not removable,
@@ -778,9 +780,9 @@ void ProjectSettingsEditor::_update_actions() {
action2->set_text(0, str);
if ((k->get_keycode() != 0)) {
- action2->set_icon(0, get_icon("Keyboard", "EditorIcons"));
+ action2->set_icon(0, input_editor->get_theme_icon("Keyboard", "EditorIcons"));
} else {
- action2->set_icon(0, get_icon("KeyboardPhysical", "EditorIcons"));
+ action2->set_icon(0, input_editor->get_theme_icon("KeyboardPhysical", "EditorIcons"));
}
}
@@ -794,7 +796,7 @@ void ProjectSettingsEditor::_update_actions() {
}
action2->set_text(0, str);
- action2->set_icon(0, get_icon("JoyButton", "EditorIcons"));
+ action2->set_icon(0, input_editor->get_theme_icon("JoyButton", "EditorIcons"));
}
Ref<InputEventMouseButton> mb = event;
@@ -811,7 +813,7 @@ void ProjectSettingsEditor::_update_actions() {
}
action2->set_text(0, str);
- action2->set_icon(0, get_icon("Mouse", "EditorIcons"));
+ action2->set_icon(0, input_editor->get_theme_icon("Mouse", "EditorIcons"));
}
Ref<InputEventJoypadMotion> jm = event;
@@ -823,13 +825,13 @@ void ProjectSettingsEditor::_update_actions() {
String desc = _axis_names[n];
String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc;
action2->set_text(0, str);
- action2->set_icon(0, get_icon("JoyAxis", "EditorIcons"));
+ action2->set_icon(0, input_editor->get_theme_icon("JoyAxis", "EditorIcons"));
}
action2->set_metadata(0, i);
action2->set_meta("__input", event);
- action2->add_button(2, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
- action2->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
+ action2->add_button(2, input_editor->get_theme_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
+ action2->add_button(2, input_editor->get_theme_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
// Fade out the individual event buttons slightly to make the
// Add/Remove buttons stand out more.
action2->set_button_color(2, 0, Color(1, 1, 1, 0.75));
@@ -1112,7 +1114,7 @@ Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control *
hb->set_modulate(Color(1, 1, 1, 1.0f));
hb->add_child(label);
vb->add_child(hb);
- set_drag_preview(vb);
+ input_editor->set_drag_preview(vb);
Dictionary drag_data;
drag_data["type"] = "nodes";
@@ -1547,7 +1549,7 @@ void ProjectSettingsEditor::_update_translations() {
t->set_text(0, translations[i].replace_first("res://", ""));
t->set_tooltip(0, translations[i]);
t->set_metadata(0, i);
- t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove"));
+ t->add_button(0, input_editor->get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove"));
}
}
@@ -1670,7 +1672,7 @@ void ProjectSettingsEditor::_update_translations() {
t->set_text(0, keys[i].replace_first("res://", ""));
t->set_tooltip(0, keys[i]);
t->set_metadata(0, keys[i]);
- t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove"));
+ t->add_button(0, input_editor->get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove"));
if (keys[i] == remap_selected) {
t->select(0);
translation_res_option_add_button->set_disabled(false);
@@ -1688,7 +1690,7 @@ void ProjectSettingsEditor::_update_translations() {
t2->set_text(0, path.replace_first("res://", ""));
t2->set_tooltip(0, path);
t2->set_metadata(0, j);
- t2->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove"));
+ t2->add_button(0, input_editor->get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove"));
t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
t2->set_text(1, langnames);
t2->set_editable(1, true);
@@ -1774,7 +1776,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
singleton = this;
set_title(TTR("Project Settings (project.godot)"));
- set_resizable(true);
+
undo_redo = &p_data->get_undo_redo();
data = p_data;
@@ -1873,7 +1875,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
add_prop_bar->add_child(popup_copy_to_feature);
popup_copy_to_feature->get_popup()->connect("id_pressed", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform));
- popup_copy_to_feature->get_popup()->connect("about_to_show", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform_about_to_show));
+ popup_copy_to_feature->get_popup()->connect("about_to_popup", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform_about_to_show));
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
@@ -1883,7 +1885,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
HBoxContainer *restart_hb = memnew(HBoxContainer);
restart_container->add_child(restart_hb);
restart_icon = memnew(TextureRect);
- restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER);
+ restart_icon->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
restart_hb->add_child(restart_icon);
restart_label = memnew(Label);
restart_label->set_text(TTR("The editor must be restarted for changes to take effect."));
@@ -1907,10 +1909,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
VBoxContainer *vbc = memnew(VBoxContainer);
input_base->add_child(vbc);
- vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
- vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
- vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
- vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 0);
+ vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, 0);
+ vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 0);
+ vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, 0);
hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
@@ -1920,7 +1922,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
l->set_text(TTR("Action:"));
action_name = memnew(LineEdit);
- action_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ action_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(action_name);
action_name->connect("text_entered", callable_mp(this, &ProjectSettingsEditor::_action_adds));
action_name->connect("text_changed", callable_mp(this, &ProjectSettingsEditor::_action_check));
@@ -1938,7 +1940,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
input_editor = memnew(Tree);
vbc->add_child(input_editor);
- input_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ input_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
input_editor->set_columns(3);
input_editor->set_column_titles_visible(true);
input_editor->set_column_title(0, TTR("Action"));
@@ -1951,7 +1953,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
input_editor->connect("item_activated", callable_mp(this, &ProjectSettingsEditor::_action_activated));
input_editor->connect("cell_selected", callable_mp(this, &ProjectSettingsEditor::_action_selected));
input_editor->connect("button_pressed", callable_mp(this, &ProjectSettingsEditor::_action_button_pressed));
- input_editor->set_drag_forwarding(this);
+#ifndef _MSC_VER
+#warning need to make drag data forwarding to non controls happen
+#endif
+ //input_editor->set_drag_forwarding(this);
popup_add = memnew(PopupMenu);
add_child(popup_add);
@@ -1960,7 +1965,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
press_a_key_physical = false;
press_a_key = memnew(ConfirmationDialog);
- press_a_key->set_focus_mode(FOCUS_ALL);
+ //press_a_key->set_focus_mode(Control::FOCUS_ALL);
add_child(press_a_key);
l = memnew(Label);
@@ -1968,11 +1973,11 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
l->set_anchors_and_margins_preset(Control::PRESET_WIDE);
l->set_align(Label::ALIGN_CENTER);
l->set_margin(MARGIN_TOP, 20);
- l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
+ l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30);
press_a_key->get_ok()->set_disabled(true);
press_a_key_label = l;
press_a_key->add_child(l);
- press_a_key->connect("gui_input", callable_mp(this, &ProjectSettingsEditor::_wait_for_key));
+ press_a_key->connect("window_input", callable_mp(this, &ProjectSettingsEditor::_wait_for_key));
press_a_key->connect("confirmed", callable_mp(this, &ProjectSettingsEditor::_press_a_key_confirm));
device_input = memnew(ConfirmationDialog);
@@ -1998,7 +2003,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
VBoxContainer *vbc_right = memnew(VBoxContainer);
hbc->add_child(vbc_right);
- vbc_right->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_right->set_h_size_flags(Control::SIZE_EXPAND_FILL);
l = memnew(Label);
l->set_text(TTR("Index:"));
@@ -2035,14 +2040,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
thb->add_child(addtr);
VBoxContainer *tmc = memnew(VBoxContainer);
tvb->add_child(tmc);
- tmc->set_v_size_flags(SIZE_EXPAND_FILL);
+ tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_list = memnew(Tree);
- translation_list->set_v_size_flags(SIZE_EXPAND_FILL);
+ translation_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tmc->add_child(translation_list);
translation_file_open = memnew(EditorFileDialog);
add_child(translation_file_open);
- translation_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ translation_file_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
translation_file_open->connect("file_selected", callable_mp(this, &ProjectSettingsEditor::_translation_add));
}
@@ -2059,16 +2064,16 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
thb->add_child(addtr);
VBoxContainer *tmc = memnew(VBoxContainer);
tvb->add_child(tmc);
- tmc->set_v_size_flags(SIZE_EXPAND_FILL);
+ tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_remap = memnew(Tree);
- translation_remap->set_v_size_flags(SIZE_EXPAND_FILL);
+ translation_remap->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_remap->connect("cell_selected", callable_mp(this, &ProjectSettingsEditor::_translation_res_select));
tmc->add_child(translation_remap);
translation_remap->connect("button_pressed", callable_mp(this, &ProjectSettingsEditor::_translation_res_delete));
translation_res_file_open = memnew(EditorFileDialog);
add_child(translation_res_file_open);
- translation_res_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ translation_res_file_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
translation_res_file_open->connect("file_selected", callable_mp(this, &ProjectSettingsEditor::_translation_res_add));
thb = memnew(HBoxContainer);
@@ -2081,9 +2086,9 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
thb->add_child(addtr);
tmc = memnew(VBoxContainer);
tvb->add_child(tmc);
- tmc->set_v_size_flags(SIZE_EXPAND_FILL);
+ tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_remap_options = memnew(Tree);
- translation_remap_options->set_v_size_flags(SIZE_EXPAND_FILL);
+ translation_remap_options->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tmc->add_child(translation_remap_options);
translation_remap_options->set_columns(2);
@@ -2098,7 +2103,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translation_res_option_file_open = memnew(EditorFileDialog);
add_child(translation_res_option_file_open);
- translation_res_option_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ translation_res_option_file_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
translation_res_option_file_open->connect("file_selected", callable_mp(this, &ProjectSettingsEditor::_translation_res_option_add));
}
@@ -2107,7 +2112,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translations->add_child(tvb);
tvb->set_name(TTR("Locales Filter"));
VBoxContainer *tmc = memnew(VBoxContainer);
- tmc->set_v_size_flags(SIZE_EXPAND_FILL);
+ tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tvb->add_child(tmc);
translation_locale_filter_mode = memnew(OptionButton);
@@ -2118,7 +2123,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translation_locale_filter_mode->connect("item_selected", callable_mp(this, &ProjectSettingsEditor::_translation_filter_mode_changed));
translation_filter = memnew(Tree);
- translation_filter->set_v_size_flags(SIZE_EXPAND_FILL);
+ translation_filter->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_filter->set_columns(1);
tmc->add_child(memnew(Label(TTR("Locales:"))));
tmc->add_child(translation_filter);
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 52e7612acd..2cecb13198 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PROJECT_SETTINGS_H
-#define PROJECT_SETTINGS_H
+#ifndef PROJECT_SETTINGS_EDITOR_H
+#define PROJECT_SETTINGS_EDITOR_H
#include "core/undo_redo.h"
#include "editor/editor_autoload_settings.h"
@@ -204,4 +204,4 @@ public:
ProjectSettingsEditor(EditorData *p_data);
};
-#endif // PROJECT_SETTINGS_H
+#endif // PROJECT_SETTINGS_EDITOR_H
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 6913b0253b..8c5b078de0 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -31,11 +31,11 @@
#include "property_editor.h"
#include "core/class_db.h"
+#include "core/input/input_filter.h"
#include "core/io/image_loader.h"
#include "core/io/marshalls.h"
#include "core/io/resource_loader.h"
#include "core/math/expression.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/pair.h"
#include "core/print_string.h"
@@ -53,7 +53,7 @@
#include "editor/multi_node_edit.h"
#include "editor/property_selector.h"
#include "scene/gui/label.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/font.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
@@ -103,12 +103,7 @@ Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_res
void CustomPropertyEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
-
- RID ci = get_canvas_item();
- get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
- }
- if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
+ if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) {
hide();
}
}
@@ -151,7 +146,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
switch (p_which) {
case OBJ_MENU_LOAD: {
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
List<String> extensions;
@@ -493,14 +488,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_EXP_EASING) {
- easing_draw->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5 * EDSCALE);
- easing_draw->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5 * EDSCALE);
- easing_draw->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 5 * EDSCALE);
- easing_draw->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -30 * EDSCALE);
- type_button->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 3 * EDSCALE);
- type_button->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -3 * EDSCALE);
- type_button->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -25 * EDSCALE);
- type_button->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -7 * EDSCALE);
+ easing_draw->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5 * EDSCALE);
+ easing_draw->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5 * EDSCALE);
+ easing_draw->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 5 * EDSCALE);
+ easing_draw->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -30 * EDSCALE);
+ type_button->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 3 * EDSCALE);
+ type_button->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -3 * EDSCALE);
+ type_button->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_END, -25 * EDSCALE);
+ type_button->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -7 * EDSCALE);
type_button->set_text(TTR("Preset..."));
type_button->get_popup()->clear();
type_button->get_popup()->add_item(TTR("Linear"), EASING_LINEAR);
@@ -573,13 +568,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
text_edit->set_text(v);
text_edit->deselect();
- int button_margin = get_constant("button_margin", "Dialogs");
- int margin = get_constant("margin", "Dialogs");
+ int button_margin = text_edit->get_theme_constant("button_margin", "Dialogs");
+ int margin = text_edit->get_theme_constant("margin", "Dialogs");
- action_buttons[0]->set_anchor(MARGIN_LEFT, ANCHOR_END);
- action_buttons[0]->set_anchor(MARGIN_TOP, ANCHOR_END);
- action_buttons[0]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- action_buttons[0]->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_LEFT, Control::ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_TOP, Control::ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END);
action_buttons[0]->set_begin(Point2(-70 * EDSCALE, -button_margin + 5 * EDSCALE));
action_buttons[0]->set_end(Point2(-margin, -margin));
action_buttons[0]->set_text(TTR("Close"));
@@ -900,7 +895,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
break;
if (p_name == "script" && hint_text == "Script" && Object::cast_to<Node>(owner)) {
- menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
+ menu->add_item(TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
menu->add_separator();
} else if (hint_text != "") {
int idx = 0;
@@ -953,17 +948,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
int id = TYPE_BASE_ID + idx;
- if (!icon.is_valid() && has_icon(t, "EditorIcons")) {
- icon = get_icon(t, "EditorIcons");
- }
-
- if (icon.is_valid()) {
-
- menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
- } else {
-
- menu->add_item(vformat(TTR("New %s"), t), id);
- }
+ menu->add_item(vformat(TTR("New %s"), t), id);
idx++;
}
@@ -973,13 +958,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->add_separator();
}
- menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD);
+ menu->add_item(TTR("Load"), OBJ_MENU_LOAD);
if (!RES(v).is_null()) {
- menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT);
- menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR);
- menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
+ menu->add_item(TTR("Edit"), OBJ_MENU_EDIT);
+ menu->add_item(TTR("Clear"), OBJ_MENU_CLEAR);
+ menu->add_item(TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
+
RES r = v;
if (r.is_valid() && r->get_path().is_resource_file()) {
menu->add_separator();
@@ -1022,16 +1008,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
for (int i = 0; i < conversions.size(); i++) {
String what = conversions[i]->converts_to();
- Ref<Texture2D> icon;
- if (has_icon(what, "EditorIcons")) {
-
- icon = get_icon(what, "EditorIcons");
- } else {
-
- icon = get_icon(what, "Resource");
- }
-
- menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i);
+ menu->add_item(vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i);
}
}
@@ -1105,7 +1082,7 @@ void CustomPropertyEditor::_file_selected(String p_file) {
RES res = ResourceLoader::load(p_file, type);
if (res.is_null()) {
error->set_text(TTR("Error loading file: Not a resource!"));
- error->popup_centered_minsize();
+ error->popup_centered();
break;
}
v = res;
@@ -1282,7 +1259,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
else
file->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file->clear_filters();
file->clear_filters();
@@ -1316,7 +1293,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
else
file->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- file->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
file->clear_filters();
file->popup_centered_ratio();
} else {
@@ -1385,7 +1362,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} else if (p_which == 1) {
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
- file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
@@ -1500,7 +1477,7 @@ void CustomPropertyEditor::_draw_easing() {
Size2 s = easing_draw->get_size();
Rect2 r(Point2(), s);
r = r.grow(3);
- get_stylebox("normal", "LineEdit")->draw(ci, r);
+ easing_draw->get_theme_stylebox("normal", "LineEdit")->draw(ci, r);
int points = 48;
@@ -1508,8 +1485,8 @@ void CustomPropertyEditor::_draw_easing() {
float exp = v;
bool flip = hint_text == "attenuation";
- Ref<Font> f = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
+ Ref<Font> f = easing_draw->get_theme_font("font", "Label");
+ Color color = easing_draw->get_theme_color("font_color", "Label");
for (int i = 1; i <= points; i++) {
@@ -1523,7 +1500,7 @@ void CustomPropertyEditor::_draw_easing() {
iflp = 1.0 - iflp;
}
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color);
prev = h;
}
@@ -1743,7 +1720,7 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) {
void CustomPropertyEditor::_emit_changed_whole_or_field() {
- if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (!InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
emit_signal("variant_changed");
} else {
emit_signal("variant_field_changed", field_names[focused_value_editor]);
@@ -1805,7 +1782,7 @@ void CustomPropertyEditor::_focus_exit() {
void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) {
- Ref<StyleBox> sb = get_stylebox("panel");
+ Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox("panel");
int margin_top = sb->get_margin(MARGIN_TOP);
int margin_left = sb->get_margin(MARGIN_LEFT);
int margin_bottom = sb->get_margin(MARGIN_BOTTOM);
@@ -1921,7 +1898,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
checks20[i] = memnew(CheckBox);
checks20[i]->set_toggle_mode(true);
- checks20[i]->set_focus_mode(FOCUS_NONE);
+ checks20[i]->set_focus_mode(Control::FOCUS_NONE);
checks20gc->add_child(checks20[i]);
checks20[i]->hide();
checks20[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), make_binds(i));
@@ -1949,7 +1926,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
color_picker = NULL;
- set_as_toplevel(true);
file = memnew(EditorFileDialog);
add_child(file);
file->hide();
@@ -1983,7 +1959,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
type_button->get_popup()->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_type_create_selected));
menu = memnew(PopupMenu);
- menu->set_pass_on_modal_close_click(false);
+ // menu->set_pass_on_modal_close_click(false);
add_child(menu);
menu->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_menu_option));
diff --git a/editor/property_editor.h b/editor/property_editor.h
index bc2a222714..45466eaa42 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -63,9 +63,9 @@ public:
virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
};
-class CustomPropertyEditor : public Popup {
+class CustomPropertyEditor : public PopupPanel {
- GDCLASS(CustomPropertyEditor, Popup);
+ GDCLASS(CustomPropertyEditor, PopupPanel);
enum {
MAX_VALUE_EDITORS = 12,
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index ede7b860d6..54b94ebb95 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -121,33 +121,33 @@ void PropertySelector::_update_search() {
bool found = false;
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("Path", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("Object", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ search_options->get_theme_icon("Variant", "EditorIcons"),
+ search_options->get_theme_icon("bool", "EditorIcons"),
+ search_options->get_theme_icon("int", "EditorIcons"),
+ search_options->get_theme_icon("float", "EditorIcons"),
+ search_options->get_theme_icon("String", "EditorIcons"),
+ search_options->get_theme_icon("Vector2", "EditorIcons"),
+ search_options->get_theme_icon("Rect2", "EditorIcons"),
+ search_options->get_theme_icon("Vector3", "EditorIcons"),
+ search_options->get_theme_icon("Transform2D", "EditorIcons"),
+ search_options->get_theme_icon("Plane", "EditorIcons"),
+ search_options->get_theme_icon("Quat", "EditorIcons"),
+ search_options->get_theme_icon("AABB", "EditorIcons"),
+ search_options->get_theme_icon("Basis", "EditorIcons"),
+ search_options->get_theme_icon("Transform", "EditorIcons"),
+ search_options->get_theme_icon("Color", "EditorIcons"),
+ search_options->get_theme_icon("Path", "EditorIcons"),
+ search_options->get_theme_icon("RID", "EditorIcons"),
+ search_options->get_theme_icon("Object", "EditorIcons"),
+ search_options->get_theme_icon("Dictionary", "EditorIcons"),
+ search_options->get_theme_icon("Array", "EditorIcons"),
+ search_options->get_theme_icon("PackedByteArray", "EditorIcons"),
+ search_options->get_theme_icon("PackedInt32Array", "EditorIcons"),
+ search_options->get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ search_options->get_theme_icon("PackedStringArray", "EditorIcons"),
+ search_options->get_theme_icon("PackedVector2Array", "EditorIcons"),
+ search_options->get_theme_icon("PackedVector3Array", "EditorIcons"),
+ search_options->get_theme_icon("PackedColorArray", "EditorIcons")
};
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
@@ -161,7 +161,7 @@ void PropertySelector::_update_search() {
Ref<Texture2D> icon;
if (E->get().name == "Script Variables") {
- icon = get_icon("Script", "EditorIcons");
+ icon = search_options->get_theme_icon("Script", "EditorIcons");
} else {
icon = EditorNode::get_singleton()->get_class_icon(E->get().name);
}
@@ -238,7 +238,7 @@ void PropertySelector::_update_search() {
script_methods = false;
String rep = E->get().name.replace("*", "");
if (E->get().name == "*Script Methods") {
- icon = get_icon("Script", "EditorIcons");
+ icon = search_options->get_theme_icon("Script", "EditorIcons");
script_methods = true;
} else {
icon = EditorNode::get_singleton()->get_class_icon(rep);
@@ -390,7 +390,7 @@ void PropertySelector::_item_selected() {
}
void PropertySelector::_hide_requested() {
- _closed(); // From WindowDialog.
+ _cancel_pressed(); // From AcceptDialog.
}
void PropertySelector::_notification(int p_what) {
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index 95277e72d7..58bb061b58 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -142,7 +142,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
if (search_text.is_subsequence_ofi(path)) {
Pair<String, Ref<Texture2D>> pair;
pair.first = path;
- pair.second = get_icon("folder", "FileDialog");
+ pair.second = search_options->get_theme_icon("folder", "FileDialog");
if (search_text != String() && list.size() > 0) {
@@ -171,7 +171,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
if (ClassDB::is_parent_class(efsd->get_file_type(i), base_type) && (search_text.is_subsequence_ofi(file))) {
Pair<String, Ref<Texture2D>> pair;
pair.first = file;
- pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei);
+ pair.second = search_options->get_theme_icon((search_options->has_theme_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei);
list.push_back(pair);
}
}
@@ -253,6 +253,11 @@ void EditorQuickOpen::_confirmed() {
hide();
}
+void EditorQuickOpen::_theme_changed() {
+
+ search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons"));
+}
+
void EditorQuickOpen::_notification(int p_what) {
switch (p_what) {
@@ -262,9 +267,6 @@ void EditorQuickOpen::_notification(int p_what) {
search_box->set_clear_button_enabled(true);
[[fallthrough]];
}
- case NOTIFICATION_THEME_CHANGED: {
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
- } break;
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed));
} break;
@@ -284,6 +286,8 @@ void EditorQuickOpen::_bind_methods() {
EditorQuickOpen::EditorQuickOpen() {
VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc->connect("theme_changed", callable_mp(this, &EditorQuickOpen::_theme_changed));
+
add_child(vbc);
search_box = memnew(LineEdit);
vbc->add_margin_child(TTR("Search:"), search_box);
@@ -298,7 +302,7 @@ EditorQuickOpen::EditorQuickOpen() {
search_options->connect("item_activated", callable_mp(this, &EditorQuickOpen::_confirmed));
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
- search_options->add_constant_override("draw_guides", 1);
+ search_options->add_theme_constant_override("draw_guides", 1);
ei = "EditorIcons";
ot = "Object";
add_directories = false;
diff --git a/editor/quick_open.h b/editor/quick_open.h
index 722bad3429..c0e2cb85d8 100644
--- a/editor/quick_open.h
+++ b/editor/quick_open.h
@@ -56,6 +56,8 @@ class EditorQuickOpen : public ConfirmationDialog {
void _confirmed();
void _text_changed(const String &p_newtext);
+ void _theme_changed();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index 2d7b7027c8..c14462f07d 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -56,7 +56,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
GridContainer *grd_main = memnew(GridContainer);
grd_main->set_columns(2);
- grd_main->set_v_size_flags(SIZE_EXPAND_FILL);
+ grd_main->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(grd_main);
// ---- 1st & 2nd row
@@ -67,7 +67,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
lne_search = memnew(LineEdit);
lne_search->set_placeholder(TTR("Search"));
lne_search->set_name("lne_search");
- lne_search->set_h_size_flags(SIZE_EXPAND_FILL);
+ lne_search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Label *lbl_replace = memnew(Label);
lbl_replace->set_text(TTR("Replace"));
@@ -75,7 +75,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
lne_replace = memnew(LineEdit);
lne_replace->set_placeholder(TTR("Replace"));
lne_replace->set_name("lne_replace");
- lne_replace->set_h_size_flags(SIZE_EXPAND_FILL);
+ lne_replace->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_main->add_child(lbl_search);
grd_main->add_child(lbl_replace);
@@ -90,7 +90,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
lne_prefix = memnew(LineEdit);
lne_prefix->set_placeholder(TTR("Prefix"));
lne_prefix->set_name("lne_prefix");
- lne_prefix->set_h_size_flags(SIZE_EXPAND_FILL);
+ lne_prefix->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Label *lbl_suffix = memnew(Label);
lbl_suffix->set_text(TTR("Suffix"));
@@ -98,7 +98,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
lne_suffix = memnew(LineEdit);
lne_suffix->set_placeholder(TTR("Suffix"));
lne_suffix->set_name("lne_suffix");
- lne_suffix->set_h_size_flags(SIZE_EXPAND_FILL);
+ lne_suffix->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_main->add_child(lbl_prefix);
grd_main->add_child(lbl_suffix);
@@ -124,7 +124,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
// ---- Tab Substitute
VBoxContainer *vbc_substitute = memnew(VBoxContainer);
- vbc_substitute->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_substitute->set_h_size_flags(Control::SIZE_EXPAND_FILL);
vbc_substitute->set_custom_minimum_size(Size2(0, feature_min_height));
vbc_substitute->set_name(TTR("Substitute"));
@@ -143,9 +143,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
but_insert_name = memnew(Button);
but_insert_name->set_text("NAME");
but_insert_name->set_tooltip(String("${NAME}\n") + TTR("Node name"));
- but_insert_name->set_focus_mode(FOCUS_NONE);
+ but_insert_name->set_focus_mode(Control::FOCUS_NONE);
but_insert_name->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${NAME}"));
- but_insert_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ but_insert_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_substitute->add_child(but_insert_name);
// Parent
@@ -153,9 +153,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
but_insert_parent = memnew(Button);
but_insert_parent->set_text("PARENT");
but_insert_parent->set_tooltip(String("${PARENT}\n") + TTR("Node's parent name, if available"));
- but_insert_parent->set_focus_mode(FOCUS_NONE);
+ but_insert_parent->set_focus_mode(Control::FOCUS_NONE);
but_insert_parent->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${PARENT}"));
- but_insert_parent->set_h_size_flags(SIZE_EXPAND_FILL);
+ but_insert_parent->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_substitute->add_child(but_insert_parent);
// Type
@@ -163,9 +163,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
but_insert_type = memnew(Button);
but_insert_type->set_text("TYPE");
but_insert_type->set_tooltip(String("${TYPE}\n") + TTR("Node type"));
- but_insert_type->set_focus_mode(FOCUS_NONE);
+ but_insert_type->set_focus_mode(Control::FOCUS_NONE);
but_insert_type->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${TYPE}"));
- but_insert_type->set_h_size_flags(SIZE_EXPAND_FILL);
+ but_insert_type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_substitute->add_child(but_insert_type);
// Scene
@@ -173,9 +173,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
but_insert_scene = memnew(Button);
but_insert_scene->set_text("SCENE");
but_insert_scene->set_tooltip(String("${SCENE}\n") + TTR("Current scene name"));
- but_insert_scene->set_focus_mode(FOCUS_NONE);
+ but_insert_scene->set_focus_mode(Control::FOCUS_NONE);
but_insert_scene->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${SCENE}"));
- but_insert_scene->set_h_size_flags(SIZE_EXPAND_FILL);
+ but_insert_scene->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_substitute->add_child(but_insert_scene);
// Root
@@ -183,9 +183,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
but_insert_root = memnew(Button);
but_insert_root->set_text("ROOT");
but_insert_root->set_tooltip(String("${ROOT}\n") + TTR("Root node name"));
- but_insert_root->set_focus_mode(FOCUS_NONE);
+ but_insert_root->set_focus_mode(Control::FOCUS_NONE);
but_insert_root->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${ROOT}"));
- but_insert_root->set_h_size_flags(SIZE_EXPAND_FILL);
+ but_insert_root->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_substitute->add_child(but_insert_root);
// Count
@@ -193,9 +193,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
but_insert_count = memnew(Button);
but_insert_count->set_text("COUNTER");
but_insert_count->set_tooltip(String("${COUNTER}\n") + TTR("Sequential integer counter.\nCompare counter options."));
- but_insert_count->set_focus_mode(FOCUS_NONE);
+ but_insert_count->set_focus_mode(Control::FOCUS_NONE);
but_insert_count->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${COUNTER}"));
- but_insert_count->set_h_size_flags(SIZE_EXPAND_FILL);
+ but_insert_count->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grd_substitute->add_child(but_insert_count);
chk_per_level_counter = memnew(CheckBox);
@@ -240,7 +240,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
// ---- Tab Process
VBoxContainer *vbc_process = memnew(VBoxContainer);
- vbc_process->set_h_size_flags(SIZE_EXPAND_FILL);
+ vbc_process->set_h_size_flags(Control::SIZE_EXPAND_FILL);
vbc_process->set_name(TTR("Post-Process"));
vbc_process->set_custom_minimum_size(Size2(0, feature_min_height));
tabc_features->add_child(vbc_process);
@@ -291,13 +291,13 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
lbl_preview = memnew(Label);
lbl_preview->set_text("");
- lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
vbc->add_child(lbl_preview);
// ---- Dialog related
- set_custom_minimum_size(Size2(383, 0));
- set_as_toplevel(true);
+ set_min_size(Size2(383, 0));
+ //set_as_toplevel(true);
get_ok()->set_text(TTR("Rename"));
Button *but_reset = add_button(TTR("Reset"));
@@ -347,7 +347,7 @@ void RenameDialog::_bind_methods() {
void RenameDialog::_update_substitute() {
- LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(get_focus_owner());
+ LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner());
bool is_main_field = _is_main_field(focus_owner_line_edit);
but_insert_name->set_disabled(!is_main_field);
@@ -358,12 +358,12 @@ void RenameDialog::_update_substitute() {
but_insert_count->set_disabled(!is_main_field);
// The focus mode seems to be reset when disabling/re-enabling
- but_insert_name->set_focus_mode(FOCUS_NONE);
- but_insert_parent->set_focus_mode(FOCUS_NONE);
- but_insert_type->set_focus_mode(FOCUS_NONE);
- but_insert_scene->set_focus_mode(FOCUS_NONE);
- but_insert_root->set_focus_mode(FOCUS_NONE);
- but_insert_count->set_focus_mode(FOCUS_NONE);
+ but_insert_name->set_focus_mode(Control::FOCUS_NONE);
+ but_insert_parent->set_focus_mode(Control::FOCUS_NONE);
+ but_insert_type->set_focus_mode(Control::FOCUS_NONE);
+ but_insert_scene->set_focus_mode(Control::FOCUS_NONE);
+ but_insert_root->set_focus_mode(Control::FOCUS_NONE);
+ but_insert_count->set_focus_mode(Control::FOCUS_NONE);
}
void RenameDialog::_post_popup() {
@@ -401,11 +401,11 @@ void RenameDialog::_update_preview(String new_text) {
if (new_name == preview_node->get_name()) {
// New name is identical to the old one. Don't color it as much to avoid distracting the user.
- const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_color("accent_color", "Editor");
- const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_color("default_color", "RichTextLabel");
- lbl_preview->add_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5));
+ const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor");
+ const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("default_color", "RichTextLabel");
+ lbl_preview->add_theme_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5));
} else {
- lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor"));
+ lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
}
}
@@ -491,7 +491,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *
self->has_errors = true;
self->lbl_preview_title->set_text(TTR("Regular Expression Error"));
- self->lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
+ self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str));
}
@@ -652,7 +652,7 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) {
void RenameDialog::_insert_text(String text) {
- LineEdit *focus_owner = Object::cast_to<LineEdit>(get_focus_owner());
+ LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner());
if (_is_main_field(focus_owner)) {
focus_owner->selection_delete();
diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h
index 537aa1703b..1cd0a2cb0f 100644
--- a/editor/rename_dialog.h
+++ b/editor/rename_dialog.h
@@ -103,7 +103,6 @@ class RenameDialog : public ConfirmationDialog {
bool has_errors;
protected:
- void _notification(int p_what){};
static void _bind_methods();
virtual void _post_popup();
diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp
index 551d20eddb..b71c2bd078 100644
--- a/editor/reparent_dialog.cpp
+++ b/editor/reparent_dialog.cpp
@@ -45,12 +45,6 @@ void ReparentDialog::_notification(int p_what) {
disconnect("confirmed", callable_mp(this, &ReparentDialog::_reparent));
}
-
- if (p_what == NOTIFICATION_DRAW) {
-
- //RID ci = get_canvas_item();
- //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- }
}
void ReparentDialog::_cancel() {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 7845af7f79..4b382f09f4 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -30,8 +30,8 @@
#include "scene_tree_dock.h"
+#include "core/input/input_filter.h"
#include "core/io/resource_saver.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/debugger/editor_debugger_node.h"
@@ -42,10 +42,12 @@
#include "editor/multi_node_edit.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
+#include "servers/display_server.h"
+#include "servers/rendering_server.h"
void SceneTreeDock::_nodes_drag_begin() {
@@ -73,9 +75,6 @@ void SceneTreeDock::_input(Ref<InputEvent> p_event) {
void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
- if (get_viewport()->get_modal_stack_top())
- return; //ignore because of modal window
-
if (get_focus_owner() && get_focus_owner()->is_text_field())
return;
@@ -131,7 +130,7 @@ void SceneTreeDock::instance(const String &p_file) {
current_option = -1;
accept->set_text(TTR("No parent to instance a child at."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
};
@@ -153,7 +152,7 @@ void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_paren
if (!parent || !edited_scene) {
accept->set_text(TTR("No parent to instance the scenes at."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
};
@@ -174,7 +173,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
if (!sdata.is_valid()) {
current_option = -1;
accept->set_text(vformat(TTR("Error loading scene from %s"), p_files[i]));
- accept->popup_centered_minsize();
+ accept->popup_centered();
error = true;
break;
}
@@ -183,7 +182,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
if (!instanced_scene) {
current_option = -1;
accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i]));
- accept->popup_centered_minsize();
+ accept->popup_centered();
error = true;
break;
}
@@ -193,7 +192,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
if (_cyclical_dependency_exists(edited_scene->get_filename(), instanced_scene)) {
accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."), p_files[i]));
- accept->popup_centered_minsize();
+ accept->popup_centered();
error = true;
break;
}
@@ -240,14 +239,14 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
Ref<PackedScene> sdata = ResourceLoader::load(p_file);
if (!sdata.is_valid()) {
accept->set_text(vformat(TTR("Error loading scene from %s"), p_file));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
accept->set_text(vformat(TTR("Error instancing scene from %s"), p_file));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
@@ -368,8 +367,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node2D"))
preferred = "Node2D";
- else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Spatial"))
- preferred = "Spatial";
+ else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node3D"))
+ preferred = "Node3D";
}
create_dialog->set_preferred_search_result_type(preferred);
create_dialog->popup_create(true);
@@ -471,7 +470,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
current_option = -1;
accept->set_text(TTR("This operation can't be done on the tree root."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
@@ -535,7 +534,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
current_option = -1;
accept->set_text(TTR("This operation can't be done on the tree root."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
@@ -618,7 +617,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
current_option = -1;
accept->set_text(TTR("This operation can't be done on the tree root."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
@@ -654,19 +653,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (root->get_scene_inherited_state().is_valid()) {
accept->set_text(TTR("Can't reparent nodes in inherited scenes, order of nodes can't change."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
if (node->get_owner() != root) {
accept->set_text(TTR("Node must belong to the edited scene to become root."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
if (node->get_filename() != String()) {
accept->set_text(TTR("Instantiated scenes can't become root"));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
@@ -745,7 +744,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
// This prevents the dialog from being too wide after displaying
// a deletion confirmation for a node with a long name.
delete_dialog->set_size(Size2());
- delete_dialog->popup_centered_minsize();
+ delete_dialog->popup_centered();
}
} break;
@@ -767,7 +766,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!scene) {
accept->set_text(TTR("This operation can't be done without a scene."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
@@ -775,7 +774,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (selection.size() != 1) {
accept->set_text(TTR("This operation requires a single selected node."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
@@ -783,17 +782,17 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (tocopy == scene) {
accept->set_text(TTR("Can not perform with the root node."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_filename() != "") {
accept->set_text(TTR("This operation can't be done on instanced scenes."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
break;
}
- new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ new_scene_from_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
List<String> extensions;
Ref<PackedScene> sd = memnew(PackedScene);
@@ -822,7 +821,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (node) {
Node *root = EditorNode::get_singleton()->get_edited_scene();
NodePath path = root->get_path().rel_path_to(node->get_path());
- OS::get_singleton()->set_clipboard(path);
+ DisplayServer::get_singleton()->clipboard_set(path);
}
}
} break;
@@ -848,7 +847,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (editable) {
editable_instance_remove_dialog->set_text(TTR("Disabling \"editable_instance\" will cause all properties of the node to be reverted to their default."));
- editable_instance_remove_dialog->popup_centered_minsize();
+ editable_instance_remove_dialog->popup_centered();
break;
}
_toggle_editable_children(node);
@@ -872,7 +871,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
// Fire confirmation dialog when children are editable.
if (editable && !placeholder) {
placeholder_editable_instance_remove_dialog->set_text(TTR("Enabling \"Load As Placeholder\" will disable \"Editable Children\" and cause all properties of the node to be reverted to their default."));
- placeholder_editable_instance_remove_dialog->popup_centered_minsize();
+ placeholder_editable_instance_remove_dialog->popup_centered();
break;
}
@@ -929,7 +928,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
- clear_inherit_confirm->popup_centered_minsize();
+ clear_inherit_confirm->popup_centered();
} break;
case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: {
if (!profile_allow_editing) {
@@ -985,7 +984,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} else {
switch (p_tool) {
case TOOL_CREATE_2D_SCENE: new_node = memnew(Node2D); break;
- case TOOL_CREATE_3D_SCENE: new_node = memnew(Spatial); break;
+ case TOOL_CREATE_3D_SCENE: new_node = memnew(Node3D); break;
case TOOL_CREATE_USER_INTERFACE: {
Control *node = memnew(Control);
node->set_anchors_and_margins_preset(PRESET_WIDE); //more useful for resizable UIs.
@@ -1031,7 +1030,7 @@ void SceneTreeDock::_node_collapsed(Object *p_obj) {
if (!ti)
return;
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
_set_collapsed_recursive(ti, ti->is_collapsed());
}
}
@@ -1054,16 +1053,16 @@ void SceneTreeDock::_notification(int p_what) {
scene_tree->connect("node_changed", callable_mp((CanvasItem *)canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), &CanvasItem::update));
}
- SpatialEditorPlugin *spatial_editor_plugin = Object::cast_to<SpatialEditorPlugin>(editor_data->get_editor("3D"));
+ Node3DEditorPlugin *spatial_editor_plugin = Object::cast_to<Node3DEditorPlugin>(editor_data->get_editor("3D"));
spatial_editor_plugin->get_spatial_editor()->connect_compat("item_lock_status_changed", scene_tree, "_update_tree");
spatial_editor_plugin->get_spatial_editor()->connect_compat("item_group_status_changed", scene_tree, "_update_tree");
- button_add->set_icon(get_icon("Add", "EditorIcons"));
- button_instance->set_icon(get_icon("Instance", "EditorIcons"));
- button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons"));
- button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
+ button_add->set_icon(get_theme_icon("Add", "EditorIcons"));
+ button_instance->set_icon(get_theme_icon("Instance", "EditorIcons"));
+ button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons"));
+ button_clear_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons"));
- filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(get_theme_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &SceneTreeDock::_selection_changed));
@@ -1078,7 +1077,7 @@ void SceneTreeDock::_notification(int p_what) {
ToolButton *node_shortcuts_toggle = memnew(ToolButton);
node_shortcuts_toggle->set_name("NodeShortcutsToggle");
- node_shortcuts_toggle->set_icon(get_icon("Favorites", "EditorIcons"));
+ node_shortcuts_toggle->set_icon(get_theme_icon("Favorites", "EditorIcons"));
node_shortcuts_toggle->set_toggle_mode(true);
node_shortcuts_toggle->set_pressed(EDITOR_GET("_use_favorites_root_selection"));
node_shortcuts_toggle->set_anchors_and_margins_preset(Control::PRESET_CENTER_RIGHT);
@@ -1097,18 +1096,19 @@ void SceneTreeDock::_notification(int p_what) {
Button *button_2d = memnew(Button);
beginner_node_shortcuts->add_child(button_2d);
button_2d->set_text(TTR("2D Scene"));
- button_2d->set_icon(get_icon("Node2D", "EditorIcons"));
+ button_2d->set_icon(get_theme_icon("Node2D", "EditorIcons"));
button_2d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_2D_SCENE, false));
+
button_3d = memnew(Button);
beginner_node_shortcuts->add_child(button_3d);
button_3d->set_text(TTR("3D Scene"));
- button_3d->set_icon(get_icon("Spatial", "EditorIcons"));
+ button_3d->set_icon(get_theme_icon("Node3D", "EditorIcons"));
button_3d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_3D_SCENE, false));
Button *button_ui = memnew(Button);
beginner_node_shortcuts->add_child(button_ui);
button_ui->set_text(TTR("User Interface"));
- button_ui->set_icon(get_icon("Control", "EditorIcons"));
+ button_ui->set_icon(get_theme_icon("Control", "EditorIcons"));
button_ui->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_USER_INTERFACE, false));
VBoxContainer *favorite_node_shortcuts = memnew(VBoxContainer);
@@ -1118,7 +1118,7 @@ void SceneTreeDock::_notification(int p_what) {
Button *button_custom = memnew(Button);
node_shortcuts->add_child(button_custom);
button_custom->set_text(TTR("Other Node"));
- button_custom->set_icon(get_icon("Add", "EditorIcons"));
+ button_custom->set_icon(get_theme_icon("Add", "EditorIcons"));
button_custom->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_NEW, false));
node_shortcuts->add_spacer();
@@ -1134,12 +1134,12 @@ void SceneTreeDock::_notification(int p_what) {
clear_inherit_confirm->disconnect("confirmed", callable_mp(this, &SceneTreeDock::_tool_selected));
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- button_add->set_icon(get_icon("Add", "EditorIcons"));
- button_instance->set_icon(get_icon("Instance", "EditorIcons"));
- button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons"));
- button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
+ button_add->set_icon(get_theme_icon("Add", "EditorIcons"));
+ button_instance->set_icon(get_theme_icon("Instance", "EditorIcons"));
+ button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons"));
+ button_clear_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons"));
- filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(get_theme_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
} break;
case NOTIFICATION_PROCESS: {
@@ -1478,7 +1478,7 @@ bool SceneTreeDock::_validate_no_foreign() {
if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) {
accept->set_text(TTR("Can't operate on nodes from a foreign scene!"));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return false;
}
@@ -1492,7 +1492,7 @@ bool SceneTreeDock::_validate_no_foreign() {
if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) {
accept->set_text(TTR("Can't operate on nodes the current scene inherits from!"));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return false;
}
}
@@ -1614,8 +1614,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
if (p_keep_global_xform) {
if (Object::cast_to<Node2D>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node2D>(node)->get_global_transform());
- if (Object::cast_to<Spatial>(node))
- editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Spatial>(node)->get_global_transform());
+ if (Object::cast_to<Node3D>(node))
+ editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node3D>(node)->get_global_transform());
if (Object::cast_to<Control>(node))
editor_data->get_undo_redo().add_do_method(node, "set_global_position", Object::cast_to<Control>(node)->get_global_position());
}
@@ -1655,8 +1655,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
if (p_keep_global_xform) {
if (Object::cast_to<Node2D>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node2D>(node)->get_transform());
- if (Object::cast_to<Spatial>(node))
- editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Spatial>(node)->get_transform());
+ if (Object::cast_to<Node3D>(node))
+ editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node3D>(node)->get_transform());
if (Object::cast_to<Control>(node))
editor_data->get_undo_redo().add_undo_method(node, "set_position", Object::cast_to<Control>(node)->get_position());
}
@@ -1777,7 +1777,7 @@ void SceneTreeDock::_toggle_editable_children(Node *p_node) {
if (editable)
p_node->set_scene_instance_load_placeholder(false);
- SpatialEditor::get_singleton()->update_all_gizmos(p_node);
+ Node3DEditor::get_singleton()->update_all_gizmos(p_node);
scene_tree->update_tree();
}
@@ -2187,13 +2187,13 @@ void SceneTreeDock::_new_scene_from(String p_file) {
if (selection.size() != 1) {
accept->set_text(TTR("This operation requires a single selected node."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
if (EditorNode::get_singleton()->is_scene_open(p_file)) {
accept->set_text(TTR("Can't overwrite scene that is still open!"));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
@@ -2210,7 +2210,7 @@ void SceneTreeDock::_new_scene_from(String p_file) {
if (err != OK) {
accept->set_text(TTR("Couldn't save new scene. Likely dependencies (instances) couldn't be satisfied."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
@@ -2221,13 +2221,13 @@ void SceneTreeDock::_new_scene_from(String p_file) {
err = ResourceSaver::save(p_file, sdata, flg);
if (err != OK) {
accept->set_text(TTR("Error saving scene."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
_replace_with_branch_scene(p_file, base);
} else {
accept->set_text(TTR("Error duplicating scene to save it."));
- accept->popup_centered_minsize();
+ accept->popup_centered();
return;
}
}
@@ -2346,7 +2346,7 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) {
int to_pos = -1;
_normalize_drop(to_node, to_pos, p_type);
- _do_reparent(to_node, to_pos, nodes, !Input::get_singleton()->is_key_pressed(KEY_SHIFT));
+ _do_reparent(to_node, to_pos, nodes, !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT));
}
void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
@@ -2390,8 +2390,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->clear();
if (profile_allow_editing) {
- menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
- menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
+ menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
+ menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
}
menu->set_size(Size2(1, 1));
@@ -2422,10 +2422,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (menu->get_item_count() > 0)
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
- menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
+ menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
+ menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
}
- menu->add_icon_shortcut(get_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE);
+ menu->add_icon_shortcut(get_theme_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE);
menu->add_separator();
existing_script = selected->get_script();
@@ -2440,14 +2440,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (full_selection.size() == 1) {
add_separator = true;
- menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
+ menu->add_icon_shortcut(get_theme_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
if (existing_script.is_valid()) {
- menu->add_icon_shortcut(get_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT);
+ menu->add_icon_shortcut(get_theme_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT);
}
}
if (existing_script.is_valid() && existing_script_removable) {
add_separator = true;
- menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
+ menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
} else if (full_selection.size() > 1) {
bool script_exists = false;
for (List<Node *>::Element *E = full_selection.front(); E; E = E->next()) {
@@ -2459,7 +2459,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (script_exists) {
add_separator = true;
- menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
+ menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
}
}
@@ -2470,19 +2470,19 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (profile_allow_editing) {
if (full_selection.size() == 1) {
- menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME);
+ menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME);
}
- menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE);
+ menu->add_icon_shortcut(get_theme_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE);
if (scene_tree->get_selected() != edited_scene) {
menu->add_separator();
- menu->add_icon_shortcut(get_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP);
- menu->add_icon_shortcut(get_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN);
- menu->add_icon_shortcut(get_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE);
- menu->add_icon_shortcut(get_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT);
- menu->add_icon_shortcut(get_icon("ReparentToNewNode", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE);
+ menu->add_icon_shortcut(get_theme_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP);
+ menu->add_icon_shortcut(get_theme_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN);
+ menu->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE);
+ menu->add_icon_shortcut(get_theme_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT);
+ menu->add_icon_shortcut(get_theme_icon("ReparentToNewNode", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE);
if (selection.size() == 1) {
- menu->add_icon_shortcut(get_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT);
+ menu->add_icon_shortcut(get_theme_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT);
}
}
}
@@ -2490,12 +2490,12 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (profile_allow_editing) {
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
- menu->add_icon_shortcut(get_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
+ menu->add_icon_shortcut(get_theme_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
+ menu->add_icon_shortcut(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
}
if (full_selection.size() == 1) {
menu->add_separator();
- menu->add_icon_shortcut(get_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
+ menu->add_icon_shortcut(get_theme_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
}
bool is_external = (selection[0]->get_filename() != "");
@@ -2507,7 +2507,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (profile_allow_editing) {
menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE);
}
- menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED);
+ menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED);
} else if (!is_top_level) {
menu->add_separator();
bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]);
@@ -2517,7 +2517,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER);
menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL);
}
- menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN);
+ menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN);
if (profile_allow_editing) {
menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable);
menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder);
@@ -2529,14 +2529,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (profile_allow_editing && selection.size() > 1) {
//this is not a commonly used action, it makes no sense for it to be where it was nor always present.
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME);
+ menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME);
}
menu->add_separator();
- menu->add_icon_item(get_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION);
+ menu->add_icon_item(get_theme_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION);
if (profile_allow_editing) {
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
+ menu->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
}
menu->set_size(Size2(1, 1));
menu->set_position(p_menu_pos);
@@ -2568,7 +2568,7 @@ void SceneTreeDock::_focus_node() {
CanvasItemEditorPlugin *editor = Object::cast_to<CanvasItemEditorPlugin>(editor_data->get_editor("2D"));
editor->get_canvas_item_editor()->focus_selection();
} else {
- SpatialEditorPlugin *editor = Object::cast_to<SpatialEditorPlugin>(editor_data->get_editor("3D"));
+ Node3DEditorPlugin *editor = Object::cast_to<Node3DEditorPlugin>(editor_data->get_editor("3D"));
editor->get_spatial_editor()->get_editor_viewport(0)->focus_selection();
}
}
@@ -2795,7 +2795,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
VBoxContainer *vbc = this;
HBoxContainer *filter_hbc = memnew(HBoxContainer);
- filter_hbc->add_constant_override("separate", 0);
+ filter_hbc->add_theme_constant_override("separate", 0);
ED_SHORTCUT("scene_tree/rename", TTR("Rename"));
ED_SHORTCUT("scene_tree/batch_rename", TTR("Batch Rename"), KEY_MASK_CMD | KEY_F2);
@@ -2835,7 +2835,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
filter->set_h_size_flags(SIZE_EXPAND_FILL);
filter->set_placeholder(TTR("Filter nodes"));
filter_hbc->add_child(filter);
- filter->add_constant_override("minimum_spaces", 0);
+ filter->add_theme_constant_override("minimum_spaces", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed));
button_create_script = memnew(ToolButton);
@@ -2939,14 +2939,14 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
import_subscene_dialog->connect("subscene_selected", callable_mp(this, &SceneTreeDock::_import_subscene));
new_scene_from_dialog = memnew(EditorFileDialog);
- new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ new_scene_from_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
add_child(new_scene_from_dialog);
new_scene_from_dialog->connect("file_selected", callable_mp(this, &SceneTreeDock::_new_scene_from));
menu = memnew(PopupMenu);
add_child(menu);
menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(false));
- menu->set_hide_on_window_lose_focus(true);
+
menu_subresources = memnew(PopupMenu);
menu_subresources->set_name("Sub-Resources");
menu_subresources->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(false));
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 782df12d4b..831b7b6775 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -37,7 +37,7 @@
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "scene/gui/label.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
Node *SceneTreeEditor::get_scene_node() {
@@ -92,7 +92,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
} else if (p_id == BUTTON_LOCK) {
undo_redo->create_action(TTR("Unlock Node"));
- if (n->is_class("CanvasItem") || n->is_class("Spatial")) {
+ if (n->is_class("CanvasItem") || n->is_class("Node3D")) {
undo_redo->add_do_method(n, "remove_meta", "_edit_lock_");
undo_redo->add_undo_method(n, "set_meta", "_edit_lock_", true);
@@ -112,7 +112,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
} else if (p_id == BUTTON_GROUP) {
undo_redo->create_action(TTR("Button Group"));
- if (n->is_class("CanvasItem") || n->is_class("Spatial")) {
+ if (n->is_class("CanvasItem") || n->is_class("Node3D")) {
undo_redo->add_do_method(n, "remove_meta", "_edit_group_");
undo_redo->add_undo_method(n, "set_meta", "_edit_group_", true);
@@ -129,7 +129,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
return;
config_err = config_err.word_wrap(80);
warning->set_text(config_err);
- warning->popup_centered_minsize();
+ warning->popup_centered();
} else if (p_id == BUTTON_SIGNALS) {
@@ -201,19 +201,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_metadata(0, p_node->get_path());
if (connect_to_script_mode) {
- Color accent = get_color("accent_color", "Editor");
+ Color accent = get_theme_color("accent_color", "Editor");
Ref<Script> script = p_node->get_script();
if (!script.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != script) {
//has script
- item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
+ item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
} else {
//has no script (or script is a custom type)
- item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor"));
item->set_selectable(0, false);
if (!script.is_null()) { // make sure to mark the script if a custom type
- item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
+ item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
item->set_button_disabled(0, item->get_button_count(0) - 1, true);
}
@@ -231,7 +231,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
} else if (part_of_subscene) {
if (valid_types.size() == 0) {
- item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor"));
}
} else if (marked.has(p_node)) {
@@ -241,14 +241,14 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
item->set_text(0, node_name);
item->set_selectable(0, marked_selectable);
- item->set_custom_color(0, get_color("accent_color", "Editor"));
+ item->set_custom_color(0, get_theme_color("accent_color", "Editor"));
} else if (!marked_selectable && !marked_children_selectable) {
Node *node = p_node;
while (node) {
if (marked.has(node)) {
item->set_selectable(0, false);
- item->set_custom_color(0, get_color("error_color", "Editor"));
+ item->set_custom_color(0, get_theme_color("error_color", "Editor"));
break;
}
node = node->get_parent();
@@ -259,7 +259,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
String warning = p_node->get_configuration_warning();
if (warning != String()) {
- item->add_button(0, get_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + p_node->get_configuration_warning());
+ item->add_button(0, get_theme_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + p_node->get_configuration_warning());
}
int num_connections = p_node->get_persistent_signal_connection_count();
@@ -268,21 +268,21 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (num_connections >= 1 && num_groups >= 1) {
item->add_button(
0,
- get_icon("SignalsAndGroups", "EditorIcons"),
+ get_theme_icon("SignalsAndGroups", "EditorIcons"),
BUTTON_SIGNALS,
false,
vformat(TTR("Node has %s connection(s) and %s group(s).\nClick to show signals dock."), num_connections, num_groups));
} else if (num_connections >= 1) {
item->add_button(
0,
- get_icon("Signals", "EditorIcons"),
+ get_theme_icon("Signals", "EditorIcons"),
BUTTON_SIGNALS,
false,
vformat(TTR("Node has %s connection(s).\nClick to show signals dock."), num_connections));
} else if (num_groups >= 1) {
item->add_button(
0,
- get_icon("Groups", "EditorIcons"),
+ get_theme_icon("Groups", "EditorIcons"),
BUTTON_GROUPS,
false,
vformat(TTR("Node is in %s group(s).\nClick to show groups dock."), num_groups));
@@ -290,7 +290,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
- item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
+ item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
String tooltip = TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
@@ -299,7 +299,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_tooltip(0, tooltip);
} else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) {
- item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
+ item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
String tooltip = TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
@@ -328,7 +328,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
Ref<Script> script = p_node->get_script();
if (!script.is_null()) {
- item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path());
+ item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path());
if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) {
item->set_button_color(0, item->get_button_count(0) - 1, Color(1, 1, 1, 0.5));
}
@@ -338,37 +338,37 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_
if (is_locked)
- item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
+ item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
bool is_grouped = p_node->has_meta("_edit_group_");
if (is_grouped)
- item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
+ item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
bool v = p_node->call("is_visible");
if (v)
- item->add_button(0, get_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
+ item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
else
- item->add_button(0, get_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
+ item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)))
p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node));
_update_visibility_color(p_node, item);
- } else if (p_node->is_class("Spatial")) {
+ } else if (p_node->is_class("Node3D")) {
bool is_locked = p_node->has_meta("_edit_lock_");
if (is_locked)
- item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
+ item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
bool is_grouped = p_node->has_meta("_edit_group_");
if (is_grouped)
- item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
+ item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
bool v = p_node->call("is_visible");
if (v)
- item->add_button(0, get_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
+ item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
else
- item->add_button(0, get_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
+ item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)))
p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node));
@@ -379,7 +379,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned();
if (is_pinned) {
- item->add_button(0, get_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin."));
+ item->add_button(0, get_theme_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin."));
}
}
}
@@ -417,7 +417,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (!valid) {
//item->set_selectable(0,marked_selectable);
- item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor"));
item->set_selectable(0, false);
}
}
@@ -457,20 +457,20 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
if (p_node->is_class("CanvasItem")) {
visible = p_node->call("is_visible");
CanvasItemEditor::get_singleton()->get_viewport_control()->update();
- } else if (p_node->is_class("Spatial")) {
+ } else if (p_node->is_class("Node3D")) {
visible = p_node->call("is_visible");
}
if (visible)
- item->set_button(0, idx, get_icon("GuiVisibilityVisible", "EditorIcons"));
+ item->set_button(0, idx, get_theme_icon("GuiVisibilityVisible", "EditorIcons"));
else
- item->set_button(0, idx, get_icon("GuiVisibilityHidden", "EditorIcons"));
+ item->set_button(0, idx, get_theme_icon("GuiVisibilityHidden", "EditorIcons"));
_update_visibility_color(p_node, item);
}
void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) {
- if (p_node->is_class("CanvasItem") || p_node->is_class("Spatial")) {
+ if (p_node->is_class("CanvasItem") || p_node->is_class("Node3D")) {
Color color(1, 1, 1, 1);
bool visible_on_screen = p_node->call("is_visible_in_tree");
if (!visible_on_screen) {
@@ -498,7 +498,7 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
if (p_node->is_connected("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed)))
p_node->disconnect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed));
- if (p_node->is_class("Spatial") || p_node->is_class("CanvasItem")) {
+ if (p_node->is_class("Node3D") || p_node->is_class("CanvasItem")) {
if (p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)))
p_node->disconnect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed));
}
@@ -757,7 +757,7 @@ void SceneTreeEditor::_renamed() {
if (!Node::_validate_node_name(new_name)) {
error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n" + Node::invalid_character);
- error->popup_centered_minsize();
+ error->popup_centered();
if (new_name.empty()) {
which->set_text(0, n->get_name());
@@ -1141,7 +1141,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
tree->set_begin(Point2(0, p_label ? 18 : 0));
tree->set_end(Point2(0, 0));
- tree->add_constant_override("button_margin", 0);
+ tree->add_theme_constant_override("button_margin", 0);
add_child(tree);
@@ -1193,18 +1193,19 @@ SceneTreeEditor::~SceneTreeEditor() {
void SceneTreeDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+
+ if (is_visible())
+ tree->update_tree();
+ } break;
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &SceneTreeDialog::_select));
- filter->set_right_icon(get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(tree->get_theme_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
} break;
case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &SceneTreeDialog::_select));
} break;
- case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible_in_tree())
- tree->update_tree();
- } break;
}
}
@@ -1239,14 +1240,14 @@ SceneTreeDialog::SceneTreeDialog() {
add_child(vbc);
filter = memnew(LineEdit);
- filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_placeholder(TTR("Filter nodes"));
- filter->add_constant_override("minimum_spaces", 0);
+ filter->add_theme_constant_override("minimum_spaces", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDialog::_filter_changed));
vbc->add_child(filter);
tree = memnew(SceneTreeEditor(false, false, true));
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tree->get_scene_tree()->connect("item_activated", callable_mp(this, &SceneTreeDialog::_select));
vbc->add_child(tree);
}
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 5a111afe32..82199fc1f1 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -40,36 +40,38 @@
#include "editor/editor_scale.h"
#include "editor_file_system.h"
-void ScriptCreateDialog::_notification(int p_what) {
+void ScriptCreateDialog::_theme_changed() {
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ String lang = ScriptServer::get_language(i)->get_type();
+ Ref<Texture2D> lang_icon = gc->get_theme_icon(lang, "EditorIcons");
+ if (lang_icon.is_valid()) {
+ language_menu->set_item_icon(i, lang_icon);
+ }
+ }
- switch (p_what) {
- case NOTIFICATION_THEME_CHANGED:
- case NOTIFICATION_ENTER_TREE: {
- for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- String lang = ScriptServer::get_language(i)->get_type();
- Ref<Texture2D> lang_icon = get_icon(lang, "EditorIcons");
- if (lang_icon.is_valid()) {
- language_menu->set_item_icon(i, lang_icon);
- }
+ String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
+ if (!last_lang.empty()) {
+ for (int i = 0; i < language_menu->get_item_count(); i++) {
+ if (language_menu->get_item_text(i) == last_lang) {
+ language_menu->select(i);
+ current_language = i;
+ break;
}
+ }
+ } else {
+ language_menu->select(default_language);
+ }
- String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
- if (!last_lang.empty()) {
- for (int i = 0; i < language_menu->get_item_count(); i++) {
- if (language_menu->get_item_text(i) == last_lang) {
- language_menu->select(i);
- current_language = i;
- break;
- }
- }
- } else {
- language_menu->select(default_language);
- }
+ path_button->set_icon(gc->get_theme_icon("Folder", "EditorIcons"));
+ parent_browse_button->set_icon(gc->get_theme_icon("Folder", "EditorIcons"));
+ parent_search_button->set_icon(gc->get_theme_icon("ClassList", "EditorIcons"));
+ status_panel->add_theme_style_override("panel", gc->get_theme_stylebox("bg", "Tree"));
+}
+void ScriptCreateDialog::_notification(int p_what) {
- path_button->set_icon(get_icon("Folder", "EditorIcons"));
- parent_browse_button->set_icon(get_icon("Folder", "EditorIcons"));
- parent_search_button->set_icon(get_icon("ClassList", "EditorIcons"));
- status_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ _theme_changed();
} break;
}
}
@@ -442,7 +444,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
override_info += ", ";
}
}
- template_menu->set_item_icon(extended.id, get_icon("Override", "EditorIcons"));
+ template_menu->set_item_icon(extended.id, gc->get_theme_icon("Override", "EditorIcons"));
template_menu->get_popup()->set_item_tooltip(extended.id, override_info.as_string());
}
// Reselect last selected template
@@ -517,11 +519,11 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) {
is_browsing_parent = browse_parent;
if (p_save) {
- file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_browse->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_browse->set_title(TTR("Open Script / Choose Location"));
file_browse->get_ok()->set_text(TTR("Open"));
} else {
- file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_browse->set_title(TTR("Open Script"));
}
@@ -607,9 +609,9 @@ void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
error_label->set_text("- " + TTR(p_msg));
if (valid) {
- error_label->add_color_override("font_color", get_color("success_color", "Editor"));
+ error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor"));
} else {
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_label->add_theme_color_override("font_color", gc->get_theme_color("error_color", "Editor"));
}
}
@@ -617,9 +619,9 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
path_error_label->set_text("- " + TTR(p_msg));
if (valid) {
- path_error_label->add_color_override("font_color", get_color("success_color", "Editor"));
+ path_error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor"));
} else {
- path_error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ path_error_label->add_theme_color_override("font_color", gc->get_theme_color("error_color", "Editor"));
}
}
@@ -739,9 +741,11 @@ ScriptCreateDialog::ScriptCreateDialog() {
/* Main Controls */
- GridContainer *gc = memnew(GridContainer);
+ gc = memnew(GridContainer);
gc->set_columns(2);
+ gc->connect("theme_changed", callable_mp(this, &ScriptCreateDialog::_theme_changed));
+
/* Error Messages Field */
VBoxContainer *vb = memnew(VBoxContainer);
@@ -774,7 +778,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
language_menu = memnew(OptionButton);
language_menu->set_custom_minimum_size(Size2(250, 0) * EDSCALE);
- language_menu->set_h_size_flags(SIZE_EXPAND_FILL);
+ language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL);
gc->add_child(memnew(Label(TTR("Language:"))));
gc->add_child(language_menu);
@@ -798,10 +802,10 @@ ScriptCreateDialog::ScriptCreateDialog() {
base_type = "Object";
hb = memnew(HBoxContainer);
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
parent_name = memnew(LineEdit);
parent_name->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_parent_name_changed));
- parent_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ parent_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(parent_name);
parent_search_button = memnew(Button);
parent_search_button->set_flat(true);
@@ -819,7 +823,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
class_name = memnew(LineEdit);
class_name->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_class_name_changed));
- class_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ class_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
gc->add_child(memnew(Label(TTR("Class Name:"))));
gc->add_child(class_name);
@@ -845,7 +849,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
file_path = memnew(LineEdit);
file_path->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_path_changed));
file_path->connect("text_entered", callable_mp(this, &ScriptCreateDialog::_path_entered));
- file_path->set_h_size_flags(SIZE_EXPAND_FILL);
+ file_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(file_path);
path_button = memnew(Button);
path_button->set_flat(true);
@@ -863,18 +867,16 @@ ScriptCreateDialog::ScriptCreateDialog() {
file_browse = memnew(EditorFileDialog);
file_browse->connect("file_selected", callable_mp(this, &ScriptCreateDialog::_file_selected));
- file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
add_child(file_browse);
get_ok()->set_text(TTR("Create"));
alert = memnew(AcceptDialog);
- alert->set_as_minsize();
alert->get_label()->set_autowrap(true);
alert->get_label()->set_align(Label::ALIGN_CENTER);
alert->get_label()->set_valign(Label::VALIGN_CENTER);
alert->get_label()->set_custom_minimum_size(Size2(325, 60) * EDSCALE);
add_child(alert);
- set_as_minsize();
set_hide_on_ok(false);
set_title(TTR("Attach Node Script"));
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index f73309c373..f164cd2a15 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -45,6 +45,7 @@ class CreateDialog;
class ScriptCreateDialog : public ConfirmationDialog {
GDCLASS(ScriptCreateDialog, ConfirmationDialog);
+ GridContainer *gc;
LineEdit *class_name;
Label *error_label;
Label *path_error_label;
@@ -123,6 +124,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
void _update_dialog();
protected:
+ void _theme_changed();
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index cf93fab9a8..6bd06aff64 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -118,6 +118,12 @@ void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_nam
void EditorSettingsDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (!is_visible()) {
+ EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", Rect2(get_position(), get_size()));
+ set_process_unhandled_input(false);
+ }
+ } break;
case NOTIFICATION_READY: {
undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, NULL);
undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, NULL);
@@ -126,10 +132,6 @@ void EditorSettingsDialog::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
_update_icons();
} break;
- case NOTIFICATION_POPUP_HIDE: {
- EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", get_rect());
- set_process_unhandled_input(false);
- } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_icons();
// Update theme colors.
@@ -143,7 +145,7 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
const Ref<InputEventKey> k = p_event;
- if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) {
+ if (k.is_valid() && k->is_pressed()) {
bool handled = false;
@@ -169,22 +171,22 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
}
if (handled) {
- accept_event();
+ set_input_as_handled();
}
}
}
void EditorSettingsDialog::_update_icons() {
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
- shortcut_search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons"));
shortcut_search_box->set_clear_button_enabled(true);
- restart_close_button->set_icon(get_icon("Close", "EditorIcons"));
- restart_container->add_style_override("panel", get_stylebox("bg", "Tree"));
- restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons"));
- restart_label->add_color_override("font_color", get_color("warning_color", "Editor"));
+ restart_close_button->set_icon(shortcuts->get_theme_icon("Close", "EditorIcons"));
+ restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox("bg", "Tree"));
+ restart_icon->set_texture(shortcuts->get_theme_icon("StatusWarning", "EditorIcons"));
+ restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color("warning_color", "Editor"));
}
void EditorSettingsDialog::_update_shortcuts() {
@@ -230,8 +232,8 @@ void EditorSettingsDialog::_update_shortcuts() {
}
sections[section_name] = section;
- section->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
- section->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
+ section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor"));
+ section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor"));
}
// Don't match unassigned shortcuts when searching for assigned keys in search results.
@@ -243,16 +245,16 @@ void EditorSettingsDialog::_update_shortcuts() {
item->set_text(1, sc->get_as_text());
if (!sc->is_shortcut(original) && !(sc->get_shortcut().is_null() && original.is_null())) {
- item->add_button(1, get_icon("Reload", "EditorIcons"), 2);
+ item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2);
}
if (sc->get_as_text() == "None") {
// Fade out unassigned shortcut labels for easier visual grepping.
- item->set_custom_color(1, get_color("font_color", "Label") * Color(1, 1, 1, 0.5));
+ item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5));
}
- item->add_button(1, get_icon("Edit", "EditorIcons"), 0);
- item->add_button(1, get_icon("Close", "EditorIcons"), 1);
+ item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0);
+ item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1);
item->set_tooltip(0, E->get());
item->set_metadata(0, E->get());
}
@@ -279,9 +281,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
press_a_key_label->set_text(TTR("Press a Key..."));
last_wait_for_key = Ref<InputEventKey>();
press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
- press_a_key->grab_focus();
- press_a_key->get_ok()->set_focus_mode(FOCUS_NONE);
- press_a_key->get_cancel()->set_focus_mode(FOCUS_NONE);
+ //press_a_key->grab_focus();
+ press_a_key->get_ok()->set_focus_mode(Control::FOCUS_NONE);
+ press_a_key->get_cancel()->set_focus_mode(Control::FOCUS_NONE);
shortcut_configured = item;
} else if (p_idx == 1) { //erase
@@ -323,7 +325,7 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) {
const String str = keycode_get_string(k->get_keycode_with_modifiers());
press_a_key_label->set_text(str);
- press_a_key->accept_event();
+ press_a_key->set_input_as_handled();
}
}
@@ -394,7 +396,7 @@ void EditorSettingsDialog::_bind_methods() {
EditorSettingsDialog::EditorSettingsDialog() {
set_title(TTR("Editor Settings"));
- set_resizable(true);
+
undo_redo = memnew(UndoRedo);
tabs = memnew(TabContainer);
@@ -430,7 +432,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
HBoxContainer *restart_hb = memnew(HBoxContainer);
restart_container->add_child(restart_hb);
restart_icon = memnew(TextureRect);
- restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER);
+ restart_icon->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
restart_hb->add_child(restart_icon);
restart_label = memnew(Label);
restart_label->set_text(TTR("The editor must be restarted for changes to take effect."));
@@ -462,7 +464,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
shortcuts = memnew(Tree);
tab_shortcuts->add_child(shortcuts, true);
- shortcuts->set_v_size_flags(SIZE_EXPAND_FILL);
+ shortcuts->set_v_size_flags(Control::SIZE_EXPAND_FILL);
shortcuts->set_columns(2);
shortcuts->set_hide_root(true);
shortcuts->set_column_titles_visible(true);
@@ -471,7 +473,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
shortcuts->connect("button_pressed", callable_mp(this, &EditorSettingsDialog::_shortcut_button_pressed));
press_a_key = memnew(ConfirmationDialog);
- press_a_key->set_focus_mode(FOCUS_ALL);
+ //press_a_key->set_focus_mode(Control::FOCUS_ALL);
add_child(press_a_key);
Label *l = memnew(Label);
@@ -479,10 +481,10 @@ EditorSettingsDialog::EditorSettingsDialog() {
l->set_anchors_and_margins_preset(Control::PRESET_WIDE);
l->set_align(Label::ALIGN_CENTER);
l->set_margin(MARGIN_TOP, 20);
- l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
+ l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30);
press_a_key_label = l;
press_a_key->add_child(l);
- press_a_key->connect("gui_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key));
+ press_a_key->connect("window_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key));
press_a_key->connect("confirmed", callable_mp(this, &EditorSettingsDialog::_press_a_key_confirm));
set_hide_on_ok(true);
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
deleted file mode 100644
index b786aa2b50..0000000000
--- a/editor/spatial_editor_gizmos.h
+++ /dev/null
@@ -1,434 +0,0 @@
-/*************************************************************************/
-/* spatial_editor_gizmos.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef SPATIAL_EDITOR_GIZMOS_H
-#define SPATIAL_EDITOR_GIZMOS_H
-
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/3d/camera.h"
-
-class Camera;
-
-class LightSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(LightSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- LightSpatialGizmoPlugin();
-};
-
-class AudioStreamPlayer3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(AudioStreamPlayer3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- AudioStreamPlayer3DSpatialGizmoPlugin();
-};
-
-class CameraSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(CameraSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- CameraSpatialGizmoPlugin();
-};
-
-class MeshInstanceSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(MeshInstanceSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- bool can_be_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- MeshInstanceSpatialGizmoPlugin();
-};
-
-class Sprite3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(Sprite3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- bool can_be_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- Sprite3DSpatialGizmoPlugin();
-};
-
-class Position3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(Position3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
- Ref<ArrayMesh> pos3d_mesh;
- Vector<Vector3> cursor_points;
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- Position3DSpatialGizmoPlugin();
-};
-
-class SkeletonSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(SkeletonSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- SkeletonSpatialGizmoPlugin();
-};
-
-class PhysicalBoneSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(PhysicalBoneSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- PhysicalBoneSpatialGizmoPlugin();
-};
-
-class RayCastSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(RayCastSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- RayCastSpatialGizmoPlugin();
-};
-
-class SpringArmSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(SpringArmSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- SpringArmSpatialGizmoPlugin();
-};
-
-class VehicleWheelSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(VehicleWheelSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- VehicleWheelSpatialGizmoPlugin();
-};
-
-class SoftBodySpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(SoftBodySpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- bool is_selectable_when_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
- bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const;
-
- SoftBodySpatialGizmoPlugin();
-};
-
-class VisibilityNotifierGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(VisibilityNotifierGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
-
- VisibilityNotifierGizmoPlugin();
-};
-
-class CPUParticlesGizmoPlugin : public EditorSpatialGizmoPlugin {
- GDCLASS(CPUParticlesGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- bool is_selectable_when_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
- CPUParticlesGizmoPlugin();
-};
-
-class ParticlesGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(ParticlesGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- bool is_selectable_when_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
-
- ParticlesGizmoPlugin();
-};
-
-class ReflectionProbeGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(ReflectionProbeGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
-
- ReflectionProbeGizmoPlugin();
-};
-
-class GIProbeGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(GIProbeGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
-
- GIProbeGizmoPlugin();
-};
-
-#if 0
-class BakedIndirectLightGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(BakedIndirectLightGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
-
- BakedIndirectLightGizmoPlugin();
-};
-#endif
-class CollisionShapeSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(CollisionShapeSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
-
- CollisionShapeSpatialGizmoPlugin();
-};
-
-class CollisionPolygonSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
- GDCLASS(CollisionPolygonSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
- CollisionPolygonSpatialGizmoPlugin();
-};
-
-class NavigationMeshSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(NavigationMeshSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
- struct _EdgeKey {
-
- Vector3 from;
- Vector3 to;
-
- bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; }
- };
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- NavigationMeshSpatialGizmoPlugin();
-};
-
-class JointGizmosDrawer {
-public:
- static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform);
- static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform);
- static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform);
- static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform);
- /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis
- /// with axis X and Y that are looking toward the body and oriented toward up
- static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform);
-
- // Draw circle around p_axis
- static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false);
- static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points);
-};
-
-class JointSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
-
- GDCLASS(JointSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
-
-public:
- bool has_gizmo(Spatial *p_spatial);
- String get_name() const;
- int get_priority() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
-
- static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points);
- static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
- static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
- static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
- static void CreateGeneric6DOFJointGizmo(
- const Transform &p_offset,
- const Transform &p_trs_joint,
- const Transform &p_trs_body_a,
- const Transform &p_trs_body_b,
- real_t p_angular_limit_lower_x,
- real_t p_angular_limit_upper_x,
- real_t p_linear_limit_lower_x,
- real_t p_linear_limit_upper_x,
- bool p_enable_angular_limit_x,
- bool p_enable_linear_limit_x,
- real_t p_angular_limit_lower_y,
- real_t p_angular_limit_upper_y,
- real_t p_linear_limit_lower_y,
- real_t p_linear_limit_upper_y,
- bool p_enable_angular_limit_y,
- bool p_enable_linear_limit_y,
- real_t p_angular_limit_lower_z,
- real_t p_angular_limit_upper_z,
- real_t p_linear_limit_lower_z,
- real_t p_linear_limit_upper_z,
- bool p_enable_angular_limit_z,
- bool p_enable_linear_limit_z,
- Vector<Vector3> &r_points,
- Vector<Vector3> *r_body_a_points,
- Vector<Vector3> *r_body_b_points);
-
- JointSpatialGizmoPlugin();
-};
-
-#endif // SPATIAL_EDITOR_GIZMOS_H
diff --git a/gles_builders.py b/gles_builders.py
index 92cf9357cf..e4e5fafc85 100644
--- a/gles_builders.py
+++ b/gles_builders.py
@@ -602,7 +602,7 @@ def build_rd_header(filename):
out_file_class = out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "ShaderRD"
fd.write("\n")
- fd.write("#include \"servers/visual/rasterizer_rd/shader_rd.h\"\n\n")
+ fd.write("#include \"servers/rendering/rasterizer_rd/shader_rd.h\"\n\n")
fd.write("class " + out_file_class + " : public ShaderRD {\n\n")
fd.write("public:\n\n")
diff --git a/main/SCsub b/main/SCsub
index e1efc7e6ed..0262701d79 100644
--- a/main/SCsub
+++ b/main/SCsub
@@ -9,15 +9,6 @@ env.main_sources = []
env.add_source_files(env.main_sources, "*.cpp")
-# Order matters here. Higher index controller database files write on top of lower index database files.
-controller_databases = ["#main/gamecontrollerdb_204.txt", "#main/gamecontrollerdb_205.txt", "#main/gamecontrollerdb.txt", "#main/godotcontrollerdb.txt"]
-
-env.Depends("#main/default_controller_mappings.gen.cpp", controller_databases)
-env.CommandNoCache("#main/default_controller_mappings.gen.cpp", controller_databases, run_in_subprocess(main_builders.make_default_controller_mappings))
-
-# Don't warn about duplicate entry here, we need it registered manually for first build,
-# even if later builds will pick it up twice due to above *.cpp globbing.
-env.add_source_files(env.main_sources, "#main/default_controller_mappings.gen.cpp", warn_duplicates=False)
env.Depends("#main/splash.gen.h", "#main/splash.png")
env.CommandNoCache("#main/splash.gen.h", "#main/splash.png", run_in_subprocess(main_builders.make_splash))
diff --git a/main/main.cpp b/main/main.cpp
index 887d423d52..89c8832731 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -32,7 +32,8 @@
#include "core/crypto/crypto.h"
#include "core/debugger/engine_debugger.h"
-#include "core/input_map.h"
+#include "core/input/input_filter.h"
+#include "core/input/input_map.h"
#include "core/io/file_access_network.h"
#include "core/io/file_access_pack.h"
#include "core/io/file_access_zip.h"
@@ -49,7 +50,6 @@
#include "core/version_hash.gen.h"
#include "drivers/register_driver_types.h"
#include "main/app_icon.gen.h"
-#include "main/input_default.h"
#include "main/main_timer_sync.h"
#include "main/performance.h"
#include "main/splash.gen.h"
@@ -58,21 +58,24 @@
#include "modules/register_module_types.h"
#include "platform/register_platform_apis.h"
#include "scene/main/scene_tree.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/register_scene_types.h"
#include "scene/resources/packed_scene.h"
#include "servers/arvr_server.h"
#include "servers/audio_server.h"
#include "servers/camera_server.h"
-#include "servers/navigation_2d_server.h"
-#include "servers/navigation_server.h"
-#include "servers/physics_2d_server.h"
-#include "servers/physics_server.h"
+#include "servers/display_server.h"
+#include "servers/navigation_server_2d.h"
+#include "servers/navigation_server_3d.h"
+#include "servers/physics_server_2d.h"
+#include "servers/physics_server_3d.h"
#include "servers/register_server_types.h"
+#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_wrap_mt.h"
#ifdef TOOLS_ENABLED
-#include "editor/doc/doc_data.h"
-#include "editor/doc/doc_data_class_path.gen.h"
+#include "editor/doc_data.h"
+#include "editor/doc_data_class_path.gen.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/progress_dialog.h"
@@ -86,6 +89,7 @@
// Initialized in setup()
static Engine *engine = NULL;
static ProjectSettings *globals = NULL;
+static InputFilter *input = NULL;
static InputMap *input_map = NULL;
static TranslationServer *translation_server = NULL;
static Performance *performance = NULL;
@@ -98,22 +102,25 @@ static MessageQueue *message_queue = NULL;
// Initialized in setup2()
static AudioServer *audio_server = NULL;
+static DisplayServer *display_server = NULL;
+static RenderingServer *rendering_server = NULL;
static CameraServer *camera_server = NULL;
static ARVRServer *arvr_server = NULL;
-static PhysicsServer *physics_server = NULL;
-static Physics2DServer *physics_2d_server = NULL;
-static NavigationServer *navigation_server = NULL;
-static Navigation2DServer *navigation_2d_server = NULL;
+static PhysicsServer3D *physics_server = NULL;
+static PhysicsServer2D *physics_2d_server = NULL;
+static NavigationServer3D *navigation_server = NULL;
+static NavigationServer2D *navigation_2d_server = NULL;
// We error out if setup2() doesn't turn this true
static bool _start_success = false;
// Drivers
-static int video_driver_idx = -1;
+static int display_driver_idx = -1;
static int audio_driver_idx = -1;
// Engine config/tools
+static bool single_window = false;
static bool editor = false;
static bool project_manager = false;
static String locale;
@@ -126,7 +133,12 @@ static bool auto_build_solutions = false;
// Display
-static OS::VideoMode video_mode;
+static DisplayServer::WindowMode window_mode = DisplayServer::WINDOW_MODE_WINDOWED;
+static DisplayServer::ScreenOrientation window_orientation = DisplayServer::SCREEN_LANDSCAPE;
+static uint32_t window_flags = 0;
+static Size2i window_size = Size2i(1024, 600);
+static bool window_vsync_via_compositor = false;
+
static int init_screen = -1;
static bool init_fullscreen = false;
static bool init_maximized = false;
@@ -168,29 +180,30 @@ static String get_full_version_string() {
return String(VERSION_FULL_BUILD) + hash;
}
-// FIXME: Could maybe be moved to PhysicsServerManager and Physics2DServerManager directly
+// FIXME: Could maybe be moved to PhysicsServer3DManager and PhysicsServer2DManager directly
// to have less code in main.cpp.
void initialize_physics() {
/// 3D Physics Server
- physics_server = PhysicsServerManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServerManager::setting_property_name));
+ physics_server = PhysicsServer3DManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServer3DManager::setting_property_name));
if (!physics_server) {
// Physics server not found, Use the default physics
- physics_server = PhysicsServerManager::new_default_server();
+ physics_server = PhysicsServer3DManager::new_default_server();
}
ERR_FAIL_COND(!physics_server);
physics_server->init();
/// 2D Physics server
- physics_2d_server = Physics2DServerManager::new_server(ProjectSettings::get_singleton()->get(Physics2DServerManager::setting_property_name));
+ physics_2d_server = PhysicsServer2DManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServer2DManager::setting_property_name));
if (!physics_2d_server) {
// Physics server not found, Use the default physics
- physics_2d_server = Physics2DServerManager::new_default_server();
+ physics_2d_server = PhysicsServer2DManager::new_default_server();
}
ERR_FAIL_COND(!physics_2d_server);
physics_2d_server->init();
}
void finalize_physics() {
+
physics_server->finish();
memdelete(physics_server);
@@ -198,11 +211,19 @@ void finalize_physics() {
memdelete(physics_2d_server);
}
+void finalize_display() {
+
+ rendering_server->finish();
+ memdelete(rendering_server);
+
+ memdelete(display_server);
+}
+
void initialize_navigation_server() {
ERR_FAIL_COND(navigation_server != NULL);
- navigation_server = NavigationServerManager::new_default_server();
- navigation_2d_server = memnew(Navigation2DServer);
+ navigation_server = NavigationServer3DManager::new_default_server();
+ navigation_2d_server = memnew(NavigationServer2D);
}
void finalize_navigation_server() {
@@ -250,20 +271,33 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --render-thread <mode> Render thread mode ('unsafe', 'safe', 'separate').\n");
OS::get_singleton()->print(" --remote-fs <address> Remote filesystem (<host/IP>[:<port>] address).\n");
OS::get_singleton()->print(" --remote-fs-password <password> Password for remote filesystem.\n");
- OS::get_singleton()->print(" --audio-driver <driver> Audio driver (");
- for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
- if (i != 0)
+
+ OS::get_singleton()->print(" --audio-driver <driver> Audio driver [");
+ for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
+ if (i > 0) {
OS::get_singleton()->print(", ");
- OS::get_singleton()->print("'%s'", OS::get_singleton()->get_audio_driver_name(i));
+ }
+ OS::get_singleton()->print("'%s'", AudioDriverManager::get_driver(i)->get_name());
}
- OS::get_singleton()->print(").\n");
- OS::get_singleton()->print(" --video-driver <driver> Video driver (");
- for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
- if (i != 0)
+ OS::get_singleton()->print("].\n");
+
+ OS::get_singleton()->print(" --display-driver <driver> Display driver (and rendering driver) [");
+ for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
+ if (i > 0) {
OS::get_singleton()->print(", ");
- OS::get_singleton()->print("'%s'", OS::get_singleton()->get_video_driver_name(i));
+ }
+ OS::get_singleton()->print("'%s' (", DisplayServer::get_create_function_name(i));
+ Vector<String> rd = DisplayServer::get_create_function_rendering_drivers(i);
+ for (int j = 0; j < rd.size(); j++) {
+ if (j > 0) {
+ OS::get_singleton()->print(", ");
+ }
+ OS::get_singleton()->print("'%s'", rd[j].utf8().get_data());
+ }
+ OS::get_singleton()->print(")");
}
- OS::get_singleton()->print(").\n");
+ OS::get_singleton()->print("].\n");
+ OS::get_singleton()->print(" --rendering-driver <driver> Rendering driver (depends on display driver).\n");
OS::get_singleton()->print("\n");
#ifndef SERVER_ENABLED
@@ -278,6 +312,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --no-window Disable window creation (Windows only). Useful together with --script.\n");
OS::get_singleton()->print(" --enable-vsync-via-compositor When vsync is enabled, vsync via the OS' window compositor (Windows only).\n");
OS::get_singleton()->print(" --disable-vsync-via-compositor Disable vsync via the OS' window compositor (Windows only).\n");
+ OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n");
OS::get_singleton()->print("\n");
#endif
@@ -313,7 +348,7 @@ void Main::print_help(const char *p_binary) {
#ifdef DEBUG_METHODS_ENABLED
OS::get_singleton()->print(" --gdnative-generate-json-api Generate JSON dump of the Godot API for GDNative bindings.\n");
#endif
- OS::get_singleton()->print(" --test <test> Run a unit test (");
+ OS::get_singleton()->print(" --test <test> Run a unit test [");
const char **test_names = tests_get_names();
const char *comma = "";
while (*test_names) {
@@ -321,7 +356,7 @@ void Main::print_help(const char *p_binary) {
test_names++;
comma = ", ";
}
- OS::get_singleton()->print(").\n");
+ OS::get_singleton()->print("].\n");
#endif
}
@@ -353,7 +388,7 @@ void Main::print_help(const char *p_binary) {
Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
- OS::get_singleton()->initialize_core();
+ OS::get_singleton()->initialize();
engine = memnew(Engine);
@@ -403,7 +438,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = args.front();
- String video_driver = "";
+ String display_driver = "";
String audio_driver = "";
String project_path = ".";
bool upwards = false;
@@ -423,6 +458,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
bool found_project = false;
#endif
+ bool use_vsync = false;
packed_data = PackedData::get_singleton();
if (!packed_data)
@@ -469,8 +505,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
audio_driver = I->next()->get();
bool found = false;
- for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
- if (audio_driver == OS::get_singleton()->get_audio_driver_name(i)) {
+ for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
+ if (audio_driver == AudioDriverManager::get_driver(i)->get_name()) {
found = true;
}
}
@@ -478,14 +514,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (!found) {
OS::get_singleton()->print("Unknown audio driver '%s', aborting.\nValid options are ", audio_driver.utf8().get_data());
- for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
- if (i == OS::get_singleton()->get_audio_driver_count() - 1) {
+ for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
+ if (i == AudioDriverManager::get_driver_count() - 1) {
OS::get_singleton()->print(" and ");
} else if (i != 0) {
OS::get_singleton()->print(", ");
}
- OS::get_singleton()->print("'%s'", OS::get_singleton()->get_audio_driver_name(i));
+ OS::get_singleton()->print("'%s'", AudioDriverManager::get_driver(i)->get_name());
}
OS::get_singleton()->print(".\n");
@@ -499,30 +535,30 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
goto error;
}
- } else if (I->get() == "--video-driver") { // force video driver
+ } else if (I->get() == "--display-driver") { // force video driver
if (I->next()) {
- video_driver = I->next()->get();
+ display_driver = I->next()->get();
bool found = false;
- for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
- if (video_driver == OS::get_singleton()->get_video_driver_name(i)) {
+ for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
+ if (display_driver == DisplayServer::get_create_function_name(i)) {
found = true;
}
}
if (!found) {
- OS::get_singleton()->print("Unknown video driver '%s', aborting.\nValid options are ", video_driver.utf8().get_data());
+ OS::get_singleton()->print("Unknown display driver '%s', aborting.\nValid options are ", display_driver.utf8().get_data());
- for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
- if (i == OS::get_singleton()->get_video_driver_count() - 1) {
+ for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
+ if (i == DisplayServer::get_create_function_count() - 1) {
OS::get_singleton()->print(" and ");
} else if (i != 0) {
OS::get_singleton()->print(", ");
}
- OS::get_singleton()->print("'%s'", OS::get_singleton()->get_video_driver_name(i));
+ OS::get_singleton()->print("'%s'", DisplayServer::get_create_function_name(i));
}
OS::get_singleton()->print(".\n");
@@ -542,7 +578,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-m" || I->get() == "--maximized") { // force maximized window
init_maximized = true;
- video_mode.maximized = true;
+ window_mode = DisplayServer::WINDOW_MODE_MAXIMIZED;
} else if (I->get() == "-w" || I->get() == "--windowed") { // force windowed window
@@ -550,6 +586,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--gpu-abort") { // force windowed window
Engine::singleton->abort_on_gpu_errors = true;
+ } else if (I->get() == "--single-window") { // force single window
+
+ single_window = true;
} else if (I->get() == "-t" || I->get() == "--always-on-top") { // force always-on-top window
init_always_on_top = true;
@@ -574,8 +613,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
goto error;
}
- video_mode.width = w;
- video_mode.height = h;
+ window_size.width = w;
+ window_size.height = h;
force_res = true;
N = I->next()->next();
@@ -616,11 +655,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->set_no_window_mode(true);
} else if (I->get() == "--enable-vsync-via-compositor") {
- video_mode.vsync_via_compositor = true;
+ window_vsync_via_compositor = true;
saw_vsync_via_compositor_override = true;
} else if (I->get() == "--disable-vsync-via-compositor") {
- video_mode.vsync_via_compositor = false;
+ window_vsync_via_compositor = false;
saw_vsync_via_compositor_override = true;
#endif
} else if (I->get() == "--profiling") { // enable profiling
@@ -874,7 +913,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#else
const String error_msg = "Error: Couldn't load project data at path \"" + project_path + "\". Is the .pck file missing?\nIf you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
OS::get_singleton()->print("%s", error_msg.ascii().get_data());
- OS::get_singleton()->alert(error_msg);
+ DisplayServer::get_singleton()->alert(error_msg);
goto error;
#endif
@@ -917,7 +956,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
main_args.push_back("--editor");
if (!init_windowed) {
init_maximized = true;
- video_mode.maximized = true;
+ window_mode = DisplayServer::WINDOW_MODE_MAXIMIZED;
}
}
@@ -960,8 +999,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF("rendering/quality/driver/driver_name", "Vulkan");
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_name", PROPERTY_HINT_ENUM, "Vulkan,GLES2"));
- if (video_driver == "") {
- video_driver = GLOBAL_GET("rendering/quality/driver/driver_name");
+ if (display_driver == "") {
+ display_driver = GLOBAL_GET("rendering/quality/driver/driver_name");
}
// Assigning here even though it's GLES2-specific, to be sure that it appears in docs
@@ -983,48 +1022,58 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (use_custom_res) {
if (!force_res) {
- video_mode.width = GLOBAL_GET("display/window/size/width");
- video_mode.height = GLOBAL_GET("display/window/size/height");
+ window_size.width = GLOBAL_GET("display/window/size/width");
+ window_size.height = GLOBAL_GET("display/window/size/height");
if (globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) {
int tw = globals->get("display/window/size/test_width");
if (tw > 0) {
- video_mode.width = tw;
+ window_size.width = tw;
}
int th = globals->get("display/window/size/test_height");
if (th > 0) {
- video_mode.height = th;
+ window_size.height = th;
}
}
}
- video_mode.resizable = GLOBAL_GET("display/window/size/resizable");
- video_mode.borderless_window = GLOBAL_GET("display/window/size/borderless");
- video_mode.fullscreen = GLOBAL_GET("display/window/size/fullscreen");
- video_mode.always_on_top = GLOBAL_GET("display/window/size/always_on_top");
+ if (!bool(GLOBAL_GET("display/window/size/resizable"))) {
+ window_flags |= DisplayServer::WINDOW_FLAG_RESIZE_DISABLED_BIT;
+ }
+ if (bool(GLOBAL_GET("display/window/size/borderless"))) {
+ window_flags |= DisplayServer::WINDOW_FLAG_BORDERLESS_BIT;
+ }
+ if (bool(GLOBAL_GET("display/window/size/fullscreen"))) {
+ window_mode = DisplayServer::WINDOW_MODE_FULLSCREEN;
+ }
+
+ if (bool(GLOBAL_GET("display/window/size/always_on_top"))) {
+ window_flags |= DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP;
+ }
}
if (!force_lowdpi) {
OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false);
}
- video_mode.use_vsync = GLOBAL_DEF_RST("display/window/vsync/use_vsync", true);
- OS::get_singleton()->_use_vsync = video_mode.use_vsync;
+ use_vsync = GLOBAL_DEF_RST("display/window/vsync/use_vsync", true);
+ OS::get_singleton()->_use_vsync = use_vsync;
if (!saw_vsync_via_compositor_override) {
// If one of the command line options to enable/disable vsync via the
// window compositor ("--enable-vsync-via-compositor" or
// "--disable-vsync-via-compositor") was present then it overrides the
// project setting.
- video_mode.vsync_via_compositor = GLOBAL_DEF("display/window/vsync/vsync_via_compositor", false);
+ window_vsync_via_compositor = GLOBAL_DEF("display/window/vsync/vsync_via_compositor", false);
}
- OS::get_singleton()->_vsync_via_compositor = video_mode.vsync_via_compositor;
+ OS::get_singleton()->_vsync_via_compositor = window_vsync_via_compositor;
+ /* todo restore
OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false);
video_mode.layered = GLOBAL_DEF("display/window/per_pixel_transparency/enabled", false);
-
+*/
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2);
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3);
@@ -1049,26 +1098,26 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
/* Determine audio and video drivers */
- for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {
+ for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
- if (video_driver == OS::get_singleton()->get_video_driver_name(i)) {
+ if (display_driver == DisplayServer::get_create_function_name(i)) {
- video_driver_idx = i;
+ display_driver_idx = i;
break;
}
}
- if (video_driver_idx < 0) {
- video_driver_idx = 0;
+ if (display_driver_idx < 0) {
+ display_driver_idx = 0;
}
if (audio_driver == "") { // specified in project.godot
- audio_driver = GLOBAL_DEF_RST("audio/driver", OS::get_singleton()->get_audio_driver_name(0));
+ audio_driver = GLOBAL_DEF_RST("audio/driver", AudioDriverManager::get_driver(0)->get_name());
}
- for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {
+ for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
- if (audio_driver == OS::get_singleton()->get_audio_driver_name(i)) {
+ if (audio_driver == AudioDriverManager::get_driver(i)->get_name()) {
audio_driver_idx = i;
break;
@@ -1083,19 +1132,19 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
String orientation = GLOBAL_DEF("display/window/handheld/orientation", "landscape");
if (orientation == "portrait")
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_PORTRAIT);
+ window_orientation = DisplayServer::SCREEN_PORTRAIT;
else if (orientation == "reverse_landscape")
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_REVERSE_LANDSCAPE);
+ window_orientation = DisplayServer::SCREEN_REVERSE_LANDSCAPE;
else if (orientation == "reverse_portrait")
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_REVERSE_PORTRAIT);
+ window_orientation = DisplayServer::SCREEN_REVERSE_PORTRAIT;
else if (orientation == "sensor_landscape")
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR_LANDSCAPE);
+ window_orientation = DisplayServer::SCREEN_SENSOR_LANDSCAPE;
else if (orientation == "sensor_portrait")
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR_PORTRAIT);
+ window_orientation = DisplayServer::SCREEN_SENSOR_PORTRAIT;
else if (orientation == "sensor")
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR);
+ window_orientation = DisplayServer::SCREEN_SENSOR;
else
- OS::get_singleton()->set_screen_orientation(OS::SCREEN_LANDSCAPE);
+ window_orientation = DisplayServer::SCREEN_LANDSCAPE;
}
Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/physics_fps", 60));
@@ -1131,7 +1180,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
error:
- video_driver = "";
+ display_driver = "";
audio_driver = "";
project_path = "";
@@ -1183,15 +1232,64 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Thread::_main_thread_id = p_main_tid_override;
}
- Error err = OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx);
- if (err != OK) {
- return err;
+ /* Initialize user data dir */
+
+ OS::get_singleton()->ensure_user_data_dir();
+
+ /* Initialize Input */
+
+ input = memnew(InputFilter);
+
+ /* Iniitalize Display Server */
+
+ {
+
+ String rendering_driver; // temp broken
+
+ Error err;
+ display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_flags, window_size, err);
+ if (err != OK) {
+ //ok i guess we can't use this display server, try other ones
+ for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
+ if (i == display_driver_idx) {
+ continue; //don't try the same twice
+ }
+ display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_flags, window_size, err);
+ if (err == OK) {
+ break;
+ }
+ }
+ }
+
+ if (!display_server) {
+ ERR_PRINT("Unable to create DisplayServer, all display drivers failed.");
+ return err;
+ }
+ }
+
+ if (display_server->has_feature(DisplayServer::FEATURE_ORIENTATION)) {
+ display_server->screen_set_orientation(window_orientation);
+ }
+
+ /* Initialize Visual Server */
+
+ rendering_server = memnew(RenderingServerRaster);
+ if (OS::get_singleton()->get_render_thread_mode() != OS::RENDER_THREAD_UNSAFE) {
+ rendering_server = memnew(RenderingServerWrapMT(rendering_server, OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD));
}
+ rendering_server->init();
+
+ OS::get_singleton()->initialize_joypads();
+
+ /* Initialize Audio Driver */
+
+ AudioDriverManager::initialize(audio_driver_idx);
+
print_line(" "); //add a blank line for readability
if (init_use_custom_pos) {
- OS::get_singleton()->set_window_position(init_custom_pos);
+ display_server->window_set_position(init_custom_pos);
}
// right moment to create and initialize the audio server
@@ -1213,21 +1311,21 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
#endif
if (init_screen != -1) {
- OS::get_singleton()->set_current_screen(init_screen);
+ DisplayServer::get_singleton()->window_set_current_screen(init_screen);
}
if (init_windowed) {
//do none..
} else if (init_maximized) {
- OS::get_singleton()->set_window_maximized(true);
+ DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_MAXIMIZED);
} else if (init_fullscreen) {
- OS::get_singleton()->set_window_fullscreen(true);
+ DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_FULLSCREEN);
}
if (init_always_on_top) {
- OS::get_singleton()->set_window_always_on_top(true);
+ DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP, true);
}
if (allow_focus_steal_pid) {
- OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid);
+ DisplayServer::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid);
}
register_server_types();
@@ -1235,7 +1333,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
MAIN_PRINT("Main: Load Remaps");
Color clear = GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3));
- VisualServer::get_singleton()->set_default_clear_color(clear);
+ RenderingServer::get_singleton()->set_default_clear_color(clear);
if (show_logo) { //boot logo!
String boot_logo_path = GLOBAL_DEF("application/boot_splash/image", String());
@@ -1257,7 +1355,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color);
if (boot_logo.is_valid()) {
OS::get_singleton()->_msec_splash = OS::get_singleton()->get_ticks_msec();
- VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter);
+ RenderingServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter);
} else {
#ifndef NO_DEFAULT_BOOT_LOGO
@@ -1269,20 +1367,20 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
#endif
MAIN_PRINT("Main: ClearColor");
- VisualServer::get_singleton()->set_default_clear_color(boot_bg_color);
+ RenderingServer::get_singleton()->set_default_clear_color(boot_bg_color);
MAIN_PRINT("Main: Image");
- VisualServer::get_singleton()->set_boot_image(splash, boot_bg_color, false);
+ RenderingServer::get_singleton()->set_boot_image(splash, boot_bg_color, false);
#endif
}
#ifdef TOOLS_ENABLED
Ref<Image> icon = memnew(Image(app_icon_png));
- OS::get_singleton()->set_icon(icon);
+ DisplayServer::get_singleton()->set_icon(icon);
#endif
}
MAIN_PRINT("Main: DCC");
- VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3)));
+ RenderingServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3)));
MAIN_PRINT("Main: END");
GLOBAL_DEF("application/config/icon", String());
@@ -1294,10 +1392,17 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
GLOBAL_DEF("application/config/windows_native_icon", String());
ProjectSettings::get_singleton()->set_custom_property_info("application/config/windows_native_icon", PropertyInfo(Variant::STRING, "application/config/windows_native_icon", PROPERTY_HINT_FILE, "*.ico"));
- InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
+ InputFilter *id = InputFilter::get_singleton();
if (id) {
if (bool(GLOBAL_DEF("input_devices/pointing/emulate_touch_from_mouse", false)) && !(editor || project_manager)) {
- if (!OS::get_singleton()->has_touchscreen_ui_hint()) {
+
+ bool found_touchscreen = false;
+ for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
+ if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) {
+ found_touchscreen = true;
+ }
+ }
+ if (!found_touchscreen) {
//only if no touchscreen ui hint, set emulation
id->set_emulate_touch_from_mouse(true);
}
@@ -1322,7 +1427,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Ref<Texture2D> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
- Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot);
+ InputFilter::get_singleton()->set_custom_mouse_cursor(cursor, InputFilter::CURSOR_ARROW, hotspot);
}
}
#ifdef TOOLS_ENABLED
@@ -1589,7 +1694,7 @@ bool Main::start() {
if (!main_loop) {
if (!ClassDB::class_exists(main_loop_type)) {
- OS::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
+ DisplayServer::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
return false;
} else {
@@ -1618,6 +1723,9 @@ bool Main::start() {
}
#endif
+ if (single_window) {
+ sml->get_root()->set_embed_subwindows_hint(true);
+ }
ResourceLoader::add_custom_loaders();
ResourceSaver::add_custom_savers();
@@ -1718,7 +1826,7 @@ bool Main::start() {
{
int directional_atlas_size = GLOBAL_GET("rendering/quality/directional_shadow/size");
- VisualServer::get_singleton()->directional_shadow_atlas_set_size(directional_atlas_size);
+ RenderingServer::get_singleton()->directional_shadow_atlas_set_size(directional_atlas_size);
}
if (!editor && !project_manager) {
@@ -1727,31 +1835,32 @@ bool Main::start() {
String stretch_mode = GLOBAL_DEF("display/window/stretch/mode", "disabled");
String stretch_aspect = GLOBAL_DEF("display/window/stretch/aspect", "ignore");
Size2i stretch_size = Size2(GLOBAL_DEF("display/window/size/width", 0), GLOBAL_DEF("display/window/size/height", 0));
- real_t stretch_shrink = GLOBAL_DEF("display/window/stretch/shrink", 1.0);
- SceneTree::StretchMode sml_sm = SceneTree::STRETCH_MODE_DISABLED;
- if (stretch_mode == "2d")
- sml_sm = SceneTree::STRETCH_MODE_2D;
- else if (stretch_mode == "viewport")
- sml_sm = SceneTree::STRETCH_MODE_VIEWPORT;
+ Window::ContentScaleMode cs_sm = Window::CONTENT_SCALE_MODE_DISABLED;
+ if (stretch_mode == "objects")
+ cs_sm = Window::CONTENT_SCALE_MODE_OBJECTS;
+ else if (stretch_mode == "pixels")
+ cs_sm = Window::CONTENT_SCALE_MODE_PIXELS;
- SceneTree::StretchAspect sml_aspect = SceneTree::STRETCH_ASPECT_IGNORE;
+ Window::ContentScaleAspect cs_aspect = Window::CONTENT_SCALE_ASPECT_IGNORE;
if (stretch_aspect == "keep")
- sml_aspect = SceneTree::STRETCH_ASPECT_KEEP;
+ cs_aspect = Window::CONTENT_SCALE_ASPECT_KEEP;
else if (stretch_aspect == "keep_width")
- sml_aspect = SceneTree::STRETCH_ASPECT_KEEP_WIDTH;
+ cs_aspect = Window::CONTENT_SCALE_ASPECT_KEEP_WIDTH;
else if (stretch_aspect == "keep_height")
- sml_aspect = SceneTree::STRETCH_ASPECT_KEEP_HEIGHT;
+ cs_aspect = Window::CONTENT_SCALE_ASPECT_KEEP_HEIGHT;
else if (stretch_aspect == "expand")
- sml_aspect = SceneTree::STRETCH_ASPECT_EXPAND;
+ cs_aspect = Window::CONTENT_SCALE_ASPECT_EXPAND;
- sml->set_screen_stretch(sml_sm, sml_aspect, stretch_size, stretch_shrink);
+ sml->get_root()->set_content_scale_mode(cs_sm);
+ sml->get_root()->set_content_scale_aspect(cs_aspect);
+ sml->get_root()->set_content_scale_size(stretch_size);
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
String appname = ProjectSettings::get_singleton()->get("application/config/name");
appname = TranslationServer::get_singleton()->translate(appname);
- OS::get_singleton()->set_window_title(appname);
+ DisplayServer::get_singleton()->window_set_title(appname);
int shadow_atlas_size = GLOBAL_GET("rendering/quality/shadow_atlas/size");
int shadow_atlas_q0_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_0_subdiv");
@@ -1769,7 +1878,7 @@ bool Main::start() {
sml->get_root()->set_snap_controls_to_pixels(snap_controls);
bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true);
- sml->set_use_font_oversampling(font_oversampling);
+ sml->get_root()->set_use_font_oversampling(font_oversampling);
int texture_filter = GLOBAL_DEF("rendering/canvas_textures/default_texture_filter", 1);
int texture_repeat = GLOBAL_DEF("rendering/canvas_textures/default_texture_repeat", 0);
@@ -1838,11 +1947,11 @@ bool Main::start() {
if (serr != OK)
ERR_PRINT("Failed to load scene");
}
- OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
+ DisplayServer::get_singleton()->set_context(DisplayServer::CONTEXT_EDITOR);
}
#endif
if (!editor) {
- OS::get_singleton()->set_context(OS::CONTEXT_ENGINE);
+ DisplayServer::get_singleton()->set_context(DisplayServer::CONTEXT_ENGINE);
}
}
@@ -1863,7 +1972,7 @@ bool Main::start() {
#ifdef OSX_ENABLED
String mac_iconpath = GLOBAL_DEF("application/config/macos_native_icon", "Variant()");
if (mac_iconpath != "") {
- OS::get_singleton()->set_native_icon(mac_iconpath);
+ DisplayServer::get_singleton()->set_native_icon(mac_iconpath);
hasicon = true;
}
#endif
@@ -1871,7 +1980,7 @@ bool Main::start() {
#ifdef WINDOWS_ENABLED
String win_iconpath = GLOBAL_DEF("application/config/windows_native_icon", "Variant()");
if (win_iconpath != "") {
- OS::get_singleton()->set_native_icon(win_iconpath);
+ DisplayServer::get_singleton()->set_native_icon(win_iconpath);
hasicon = true;
}
#endif
@@ -1881,7 +1990,7 @@ bool Main::start() {
Ref<Image> icon;
icon.instance();
if (ImageLoader::load_image(iconpath, icon) == OK) {
- OS::get_singleton()->set_icon(icon);
+ DisplayServer::get_singleton()->set_icon(icon);
hasicon = true;
}
}
@@ -1896,14 +2005,14 @@ bool Main::start() {
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);
sml->get_root()->add_child(pmanager);
- OS::get_singleton()->set_context(OS::CONTEXT_PROJECTMAN);
+ DisplayServer::get_singleton()->set_context(DisplayServer::CONTEXT_PROJECTMAN);
project_manager = true;
}
if (project_manager || editor) {
// Hide console window if requested (Windows-only).
bool hide_console = EditorSettings::get_singleton()->get_setting("interface/editor/hide_console_window");
- OS::get_singleton()->set_console_visible(!hide_console);
+ DisplayServer::get_singleton()->console_set_visible(!hide_console);
// Load SSL Certificates from Editor Settings (or builtin)
Crypto::load_default_certificates(EditorSettings::get_singleton()->get_setting("network/ssl/editor_ssl_certificates").operator String());
@@ -1913,7 +2022,7 @@ bool Main::start() {
if (!hasicon) {
Ref<Image> icon = memnew(Image(app_icon_png));
- OS::get_singleton()->set_icon(icon);
+ DisplayServer::get_singleton()->set_icon(icon);
}
OS::get_singleton()->set_main_loop(main_loop);
@@ -1992,25 +2101,25 @@ bool Main::iteration() {
uint64_t physics_begin = OS::get_singleton()->get_ticks_usec();
- PhysicsServer::get_singleton()->sync();
- PhysicsServer::get_singleton()->flush_queries();
+ PhysicsServer3D::get_singleton()->sync();
+ PhysicsServer3D::get_singleton()->flush_queries();
- Physics2DServer::get_singleton()->sync();
- Physics2DServer::get_singleton()->flush_queries();
+ PhysicsServer2D::get_singleton()->sync();
+ PhysicsServer2D::get_singleton()->flush_queries();
if (OS::get_singleton()->get_main_loop()->iteration(frame_slice * time_scale)) {
exit = true;
break;
}
- NavigationServer::get_singleton_mut()->process(frame_slice * time_scale);
+ NavigationServer3D::get_singleton_mut()->process(frame_slice * time_scale);
message_queue->flush();
- PhysicsServer::get_singleton()->step(frame_slice * time_scale);
+ PhysicsServer3D::get_singleton()->step(frame_slice * time_scale);
- Physics2DServer::get_singleton()->end_sync();
- Physics2DServer::get_singleton()->step(frame_slice * time_scale);
+ PhysicsServer2D::get_singleton()->end_sync();
+ PhysicsServer2D::get_singleton()->step(frame_slice * time_scale);
message_queue->flush();
@@ -2028,17 +2137,17 @@ bool Main::iteration() {
}
message_queue->flush();
- VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames.
+ RenderingServer::get_singleton()->sync(); //sync if still drawing from previous frames.
- if (OS::get_singleton()->can_draw() && !disable_render_loop) {
+ if (DisplayServer::get_singleton()->can_any_window_draw() && !disable_render_loop) {
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) {
- if (VisualServer::get_singleton()->has_changed()) {
- VisualServer::get_singleton()->draw(true, scaled_step); // flush visual commands
+ if (RenderingServer::get_singleton()->has_changed()) {
+ RenderingServer::get_singleton()->draw(true, scaled_step); // flush visual commands
Engine::get_singleton()->frames_drawn++;
}
} else {
- VisualServer::get_singleton()->draw(true, scaled_step); // flush visual commands
+ RenderingServer::get_singleton()->draw(true, scaled_step); // flush visual commands
Engine::get_singleton()->frames_drawn++;
force_redraw_requested = false;
}
@@ -2085,7 +2194,7 @@ bool Main::iteration() {
if (fixed_fps != -1)
return exit;
- if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw())
+ if (OS::get_singleton()->is_in_low_processor_usage_mode() || !DisplayServer::get_singleton()->can_any_window_draw())
OS::get_singleton()->delay_usec(OS::get_singleton()->get_low_processor_usage_mode_sleep_usec()); //apply some delay to force idle time
else {
uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
@@ -2153,7 +2262,7 @@ void Main::cleanup() {
ScriptServer::finish_languages();
// Sync pending commands that may have been queued from a different thread during ScriptServer finalization
- VisualServer::get_singleton()->sync();
+ RenderingServer::get_singleton()->sync();
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
@@ -2182,8 +2291,14 @@ void Main::cleanup() {
}
OS::get_singleton()->finalize();
+
finalize_physics();
finalize_navigation_server();
+ finalize_display();
+
+ if (input) {
+ memdelete(input);
+ }
if (packed_data)
memdelete(packed_data);
diff --git a/main/main_builders.py b/main/main_builders.py
index c48aaaa572..aebac2b022 100644
--- a/main/main_builders.py
+++ b/main/main_builders.py
@@ -4,7 +4,6 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki
"""
from platform_methods import subprocess_main
-from compat import byte_to_str
from collections import OrderedDict
@@ -22,7 +21,7 @@ def make_splash(target, source, env):
g.write('static const Color boot_splash_bg_color = Color(0.14, 0.14, 0.14);\n')
g.write("static const unsigned char boot_splash_png[] = {\n")
for i in range(len(buf)):
- g.write(byte_to_str(buf[i]) + ",\n")
+ g.write(str(buf[i]) + ",\n")
g.write("};\n")
g.write("#endif")
@@ -41,7 +40,7 @@ def make_splash_editor(target, source, env):
g.write('static const Color boot_splash_editor_bg_color = Color(0.14, 0.14, 0.14);\n')
g.write("static const unsigned char boot_splash_editor_png[] = {\n")
for i in range(len(buf)):
- g.write(byte_to_str(buf[i]) + ",\n")
+ g.write(str(buf[i]) + ",\n")
g.write("};\n")
g.write("#endif")
@@ -59,72 +58,10 @@ def make_app_icon(target, source, env):
g.write("#define APP_ICON_H\n")
g.write("static const unsigned char app_icon_png[] = {\n")
for i in range(len(buf)):
- g.write(byte_to_str(buf[i]) + ",\n")
+ g.write(str(buf[i]) + ",\n")
g.write("};\n")
g.write("#endif")
-def make_default_controller_mappings(target, source, env):
- dst = target[0]
- g = open(dst, "w")
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#include \"core/typedefs.h\"\n")
- g.write("#include \"main/default_controller_mappings.h\"\n")
-
- # ensure mappings have a consistent order
- platform_mappings = OrderedDict()
- for src_path in source:
- with open(src_path, "r") as f:
- # read mapping file and skip header
- mapping_file_lines = f.readlines()[2:]
-
- current_platform = None
- for line in mapping_file_lines:
- if not line:
- continue
- line = line.strip()
- if len(line) == 0:
- continue
- if line[0] == "#":
- current_platform = line[1:].strip()
- if current_platform not in platform_mappings:
- platform_mappings[current_platform] = {}
- elif current_platform:
- line_parts = line.split(",")
- guid = line_parts[0]
- if guid in platform_mappings[current_platform]:
- g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
- valid_mapping = True
- for input_map in line_parts[2:]:
- if "+" in input_map or "-" in input_map or "~" in input_map:
- g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
- valid_mapping = False
- break
- if valid_mapping:
- platform_mappings[current_platform][guid] = line
-
- platform_variables = {
- "Linux": "#if X11_ENABLED",
- "Windows": "#ifdef WINDOWS_ENABLED",
- "Mac OS X": "#ifdef OSX_ENABLED",
- "Android": "#if defined(__ANDROID__)",
- "iOS": "#ifdef IPHONE_ENABLED",
- "Javascript": "#ifdef JAVASCRIPT_ENABLED",
- "UWP": "#ifdef UWP_ENABLED",
- }
-
- g.write("const char* DefaultControllerMappings::mappings[] = {\n")
- for platform, mappings in platform_mappings.items():
- variable = platform_variables[platform]
- g.write("{}\n".format(variable))
- for mapping in mappings.values():
- g.write("\t\"{}\",\n".format(mapping))
- g.write("#endif\n")
-
- g.write("\tNULL\n};\n")
- g.close()
-
-
if __name__ == '__main__':
subprocess_main(globals())
diff --git a/main/performance.cpp b/main/performance.cpp
index c7e3a41aa6..335407c9eb 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -35,9 +35,9 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "servers/audio_server.h"
-#include "servers/physics_2d_server.h"
-#include "servers/physics_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/physics_server_3d.h"
+#include "servers/rendering_server.h"
Performance *Performance::singleton = NULL;
@@ -135,22 +135,22 @@ float Performance::get_monitor(Monitor p_monitor) const {
case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count();
case OBJECT_NODE_COUNT: return _get_node_count();
case OBJECT_ORPHAN_NODE_COUNT: return Node::orphan_node_count;
- case RENDER_OBJECTS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_OBJECTS_IN_FRAME);
- case RENDER_VERTICES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_VERTICES_IN_FRAME);
- case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);
- case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
- case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
- case RENDER_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
- case RENDER_VIDEO_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VIDEO_MEM_USED);
- case RENDER_TEXTURE_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED);
- case RENDER_VERTEX_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VERTEX_MEM_USED);
- case RENDER_USAGE_VIDEO_MEM_TOTAL: return VS::get_singleton()->get_render_info(VS::INFO_USAGE_VIDEO_MEM_TOTAL);
- case PHYSICS_2D_ACTIVE_OBJECTS: return Physics2DServer::get_singleton()->get_process_info(Physics2DServer::INFO_ACTIVE_OBJECTS);
- case PHYSICS_2D_COLLISION_PAIRS: return Physics2DServer::get_singleton()->get_process_info(Physics2DServer::INFO_COLLISION_PAIRS);
- case PHYSICS_2D_ISLAND_COUNT: return Physics2DServer::get_singleton()->get_process_info(Physics2DServer::INFO_ISLAND_COUNT);
- case PHYSICS_3D_ACTIVE_OBJECTS: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_ACTIVE_OBJECTS);
- case PHYSICS_3D_COLLISION_PAIRS: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_COLLISION_PAIRS);
- case PHYSICS_3D_ISLAND_COUNT: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_ISLAND_COUNT);
+ case RENDER_OBJECTS_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_OBJECTS_IN_FRAME);
+ case RENDER_VERTICES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_VERTICES_IN_FRAME);
+ case RENDER_MATERIAL_CHANGES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_MATERIAL_CHANGES_IN_FRAME);
+ case RENDER_SHADER_CHANGES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_SHADER_CHANGES_IN_FRAME);
+ case RENDER_SURFACE_CHANGES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_SURFACE_CHANGES_IN_FRAME);
+ case RENDER_DRAW_CALLS_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_DRAW_CALLS_IN_FRAME);
+ case RENDER_VIDEO_MEM_USED: return RS::get_singleton()->get_render_info(RS::INFO_VIDEO_MEM_USED);
+ case RENDER_TEXTURE_MEM_USED: return RS::get_singleton()->get_render_info(RS::INFO_TEXTURE_MEM_USED);
+ case RENDER_VERTEX_MEM_USED: return RS::get_singleton()->get_render_info(RS::INFO_VERTEX_MEM_USED);
+ case RENDER_USAGE_VIDEO_MEM_TOTAL: return RS::get_singleton()->get_render_info(RS::INFO_USAGE_VIDEO_MEM_TOTAL);
+ case PHYSICS_2D_ACTIVE_OBJECTS: return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ACTIVE_OBJECTS);
+ case PHYSICS_2D_COLLISION_PAIRS: return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_COLLISION_PAIRS);
+ case PHYSICS_2D_ISLAND_COUNT: return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ISLAND_COUNT);
+ case PHYSICS_3D_ACTIVE_OBJECTS: return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ACTIVE_OBJECTS);
+ case PHYSICS_3D_COLLISION_PAIRS: return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_COLLISION_PAIRS);
+ case PHYSICS_3D_ISLAND_COUNT: return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ISLAND_COUNT);
case AUDIO_OUTPUT_LATENCY: return AudioServer::get_singleton()->get_output_latency();
default: {
diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp
index f0b00aeeae..c5c8917a51 100644
--- a/main/tests/test_gui.cpp
+++ b/main/tests/test_gui.cpp
@@ -35,7 +35,7 @@
#include "core/io/image_loader.h"
#include "core/os/os.h"
#include "core/print_string.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/gui/button.h"
#include "scene/gui/control.h"
#include "scene/gui/label.h"
@@ -53,8 +53,8 @@
#include "scene/gui/tree.h"
#include "scene/main/scene_tree.h"
-#include "scene/3d/camera.h"
-#include "scene/main/viewport.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/main/window.h"
namespace TestGUI {
@@ -220,7 +220,7 @@ public:
richtext->add_text("faeries.\n");
richtext->pop();
richtext->add_text("In this new episode, we will attempt to ");
- richtext->push_font(richtext->get_font("mono_font", "Fonts"));
+ richtext->push_font(richtext->get_theme_font("mono_font", "Fonts"));
richtext->push_color(Color(0.7, 0.5, 1.0));
richtext->add_text("deliver something nice");
richtext->pop();
diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp
index 2c2e6e8b45..a9a671e2f1 100644
--- a/main/tests/test_main.cpp
+++ b/main/tests/test_main.cpp
@@ -28,8 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "test_main.h"
+
#include "core/list.h"
-#include "core/os/main_loop.h"
#ifdef DEBUG_ENABLED
@@ -39,8 +40,8 @@
#include "test_math.h"
#include "test_oa_hash_map.h"
#include "test_ordered_hash_map.h"
-#include "test_physics.h"
#include "test_physics_2d.h"
+#include "test_physics_3d.h"
#include "test_render.h"
#include "test_shader_lang.h"
#include "test_string.h"
@@ -50,8 +51,8 @@ const char **tests_get_names() {
static const char *test_names[] = {
"string",
"math",
- "physics",
"physics_2d",
+ "physics_3d",
"render",
"oa_hash_map",
"gui",
@@ -80,14 +81,14 @@ MainLoop *test_main(String p_test, const List<String> &p_args) {
return TestMath::test();
}
- if (p_test == "physics") {
+ if (p_test == "physics_2d") {
- return TestPhysics::test();
+ return TestPhysics2D::test();
}
- if (p_test == "physics_2d") {
+ if (p_test == "physics_3d") {
- return TestPhysics2D::test();
+ return TestPhysics3D::test();
}
if (p_test == "render") {
diff --git a/main/tests/test_main.h b/main/tests/test_main.h
index 56db3ea2a5..bdb1668d21 100644
--- a/main/tests/test_main.h
+++ b/main/tests/test_main.h
@@ -32,9 +32,10 @@
#define TEST_MAIN_H
#include "core/list.h"
+#include "core/os/main_loop.h"
#include "core/ustring.h"
const char **tests_get_names();
MainLoop *test_main(String p_test, const List<String> &p_args);
-#endif
+#endif // TEST_MAIN_H
diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp
index d91503501d..29fa5e73a7 100644
--- a/main/tests/test_math.cpp
+++ b/main/tests/test_math.cpp
@@ -43,7 +43,7 @@
#include "core/vmap.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/shader_language.h"
#include "core/method_ptrcall.h"
diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp
index edb57f2a9f..ac53f124d2 100644
--- a/main/tests/test_oa_hash_map.cpp
+++ b/main/tests/test_oa_hash_map.cpp
@@ -30,9 +30,8 @@
#include "test_oa_hash_map.h"
-#include "core/os/os.h"
-
#include "core/oa_hash_map.h"
+#include "core/os/os.h"
namespace TestOAHashMap {
diff --git a/main/tests/test_oa_hash_map.h b/main/tests/test_oa_hash_map.h
index 60cde961c5..eb2b3d1e99 100644
--- a/main/tests/test_oa_hash_map.h
+++ b/main/tests/test_oa_hash_map.h
@@ -37,4 +37,5 @@ namespace TestOAHashMap {
MainLoop *test();
}
+
#endif // TEST_OA_HASH_MAP_H
diff --git a/main/tests/test_ordered_hash_map.cpp b/main/tests/test_ordered_hash_map.cpp
index cc779119bc..a5553217e2 100644
--- a/main/tests/test_ordered_hash_map.cpp
+++ b/main/tests/test_ordered_hash_map.cpp
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "test_ordered_hash_map.h"
+
#include "core/ordered_hash_map.h"
#include "core/os/os.h"
#include "core/pair.h"
diff --git a/main/tests/test_ordered_hash_map.h b/main/tests/test_ordered_hash_map.h
index 03e559107e..f251da0ba2 100644
--- a/main/tests/test_ordered_hash_map.h
+++ b/main/tests/test_ordered_hash_map.h
@@ -31,9 +31,11 @@
#ifndef TEST_ORDERED_HASH_MAP_H
#define TEST_ORDERED_HASH_MAP_H
+#include "core/os/main_loop.h"
+
namespace TestOrderedHashMap {
MainLoop *test();
}
-#endif
+#endif // TEST_ORDERED_HASH_MAP_H
diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp
index 160c25f43a..6feff3b0a9 100644
--- a/main/tests/test_physics_2d.cpp
+++ b/main/tests/test_physics_2d.cpp
@@ -35,8 +35,9 @@
#include "core/os/os.h"
#include "core/print_string.h"
#include "scene/resources/texture.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/display_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
static const unsigned char convex_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x40, 0x8, 0x6, 0x0, 0x0, 0x0, 0xaa, 0x69, 0x71, 0xde, 0x0, 0x0, 0x0, 0x1, 0x73, 0x52, 0x47, 0x42, 0x0, 0xae, 0xce, 0x1c, 0xe9, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf9, 0x43, 0xbb, 0x7f, 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, 0xdb, 0x6, 0xa, 0x3, 0x13, 0x31, 0x66, 0xa7, 0xac, 0x79, 0x0, 0x0, 0x4, 0xef, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x9b, 0xdd, 0x4e, 0x2a, 0x57, 0x14, 0xc7, 0xf7, 0x1e, 0xc0, 0x19, 0x38, 0x32, 0x80, 0xa, 0x6a, 0xda, 0x18, 0xa3, 0xc6, 0x47, 0x50, 0x7b, 0xa1, 0xd9, 0x36, 0x27, 0x7e, 0x44, 0xed, 0x45, 0x4d, 0x93, 0x3e, 0x40, 0x1f, 0x64, 0x90, 0xf4, 0x1, 0xbc, 0xf0, 0xc2, 0x9c, 0x57, 0x30, 0x4d, 0xbc, 0xa8, 0x6d, 0xc, 0x69, 0x26, 0xb5, 0x68, 0x8b, 0x35, 0x7e, 0x20, 0xb4, 0xf5, 0x14, 0xbf, 0x51, 0x3c, 0x52, 0xe, 0xc, 0xe, 0xc8, 0xf0, 0xb1, 0x7a, 0x51, 0x3d, 0xb1, 0x9e, 0x19, 0x1c, 0x54, 0x70, 0x1c, 0xdc, 0x9, 0x17, 0x64, 0x8, 0xc9, 0xff, 0xb7, 0xd6, 0x7f, 0xcd, 0x3f, 0x2b, 0xd9, 0x8, 0xbd, 0x9c, 0xda, 0x3e, 0xf8, 0x31, 0xff, 0xc, 0x0, 0x8, 0x42, 0x88, 0x9c, 0x9f, 0x9f, 0xbf, 0xa, 0x87, 0xc3, 0xad, 0x7d, 0x7d, 0x7d, 0x7f, 0x23, 0x84, 0x78, 0x8c, 0x31, 0xaf, 0x55, 0x0, 0xc6, 0xc7, 0x14, 0x1e, 0x8f, 0xc7, 0xbf, 0x38, 0x3c, 0x3c, 0x6c, 0x9b, 0x9f, 0x9f, 0x6f, 0xb8, 0x82, 0x9b, 0xee, 0xe8, 0xe8, 0xf8, 0x12, 0x0, 0xbe, 0xd3, 0x2a, 0x8, 0xfc, 0x50, 0xd1, 0xf9, 0x7c, 0x9e, 0x8a, 0x46, 0xa3, 0x5f, 0x9d, 0x9e, 0x9e, 0x7e, 0xb2, 0xb0, 0xb0, 0x60, 0xe5, 0x79, 0x1e, 0xf1, 0xfc, 0x7f, 0x3a, 0x9, 0x21, 0x88, 0x10, 0x82, 0x26, 0x26, 0x26, 0xde, 0x77, 0x75, 0x75, 0x85, 0x59, 0x96, 0xfd, 0x5e, 0x6b, 0x20, 0xf0, 0x7d, 0x85, 0x4b, 0x92, 0xf4, 0xfa, 0xe0, 0xe0, 0xe0, 0xd3, 0xb9, 0xb9, 0xb9, 0x46, 0x49, 0x92, 0xea, 0x6f, 0xa, 0xbf, 0x7d, 0x8, 0x21, 0x68, 0x70, 0x70, 0xb0, 0x38, 0x39, 0x39, 0x79, 0xd6, 0xd9, 0xd9, 0xb9, 0xcf, 0x30, 0xcc, 0xa2, 0xd6, 0xad, 0x21, 0x2b, 0x1c, 0x0, 0x38, 0x41, 0x10, 0xfc, 0xdb, 0xdb, 0xdb, 0x27, 0x1e, 0x8f, 0x27, 0x4b, 0x8, 0x1, 0x84, 0x90, 0xea, 0xf, 0x21, 0x4, 0x3c, 0x1e, 0x4f, 0x76, 0x67, 0x67, 0x67, 0x3f, 0x9f, 0xcf, 0xff, 0x7c, 0x5, 0xf3, 0xd9, 0x0, 0xe0, 0x2, 0x81, 0xc0, 0xa9, 0xdb, 0xed, 0x2e, 0x94, 0x2b, 0x5c, 0xe, 0xc4, 0xca, 0xca, 0x8a, 0x18, 0x8d, 0x46, 0x3, 0x0, 0xc0, 0x69, 0x1e, 0x4, 0x0, 0x90, 0x48, 0x24, 0x12, 0xe4, 0x38, 0xee, 0x41, 0xc2, 0x6f, 0x43, 0xe0, 0x38, 0xe, 0xfc, 0x7e, 0xbf, 0x10, 0x8b, 0xc5, 0xd6, 0x35, 0xd, 0x22, 0x9b, 0xcd, 0x7a, 0x96, 0x97, 0x97, 0x33, 0xf, 0xad, 0x7c, 0x29, 0x10, 0x9b, 0x9b, 0x9b, 0xef, 0x2e, 0x2e, 0x2e, 0x7e, 0xd5, 0x1c, 0x8, 0x0, 0x20, 0xe1, 0x70, 0x38, 0xfc, 0x98, 0xd5, 0x57, 0x2, 0xe1, 0x76, 0xbb, 0xf3, 0xa1, 0x50, 0xe8, 0x38, 0x9b, 0xcd, 0xfe, 0xa2, 0x9, 0x8, 0x0, 0x40, 0x2e, 0x2f, 0x2f, 0x7d, 0x4b, 0x4b, 0x4b, 0xb9, 0x4a, 0x54, 0x5f, 0x9, 0xc4, 0xd2, 0xd2, 0x92, 0xb4, 0xb7, 0xb7, 0xf7, 0x36, 0x97, 0xcb, 0x4d, 0x3d, 0x29, 0x8, 0x0, 0xe0, 0x42, 0xa1, 0xd0, 0x71, 0xb5, 0xc4, 0xdf, 0xb6, 0xc5, 0x93, 0xe, 0x4a, 0x0, 0x20, 0xa9, 0x54, 0xea, 0x37, 0xb7, 0xdb, 0x5d, 0xa8, 0xa6, 0x78, 0x39, 0x10, 0x6b, 0x6b, 0x6b, 0xf1, 0x64, 0x32, 0xb9, 0x5a, 0x55, 0x10, 0x0, 0xc0, 0x6d, 0x6c, 0x6c, 0x9c, 0x57, 0xbb, 0xfa, 0x25, 0x40, 0x14, 0x3, 0x81, 0x40, 0x34, 0x93, 0xc9, 0x2c, 0x57, 0x1c, 0x4, 0x0, 0x90, 0x58, 0x2c, 0xb6, 0x5e, 0xe9, 0xc1, 0x77, 0x1f, 0x10, 0x53, 0x53, 0x53, 0x52, 0xc5, 0x83, 0x14, 0x0, 0x70, 0x7e, 0xbf, 0x5f, 0xd0, 0x42, 0xf5, 0x95, 0x40, 0xf8, 0x7c, 0xbe, 0xcb, 0xa3, 0xa3, 0xa3, 0x3f, 0x1e, 0xbd, 0x1b, 0x0, 0x80, 0x1c, 0x1f, 0x1f, 0x87, 0xb4, 0x56, 0xfd, 0xaa, 0x5, 0x29, 0x51, 0x14, 0xbf, 0xf5, 0xf9, 0x7c, 0x97, 0x5a, 0xad, 0xbe, 0x12, 0x88, 0xf5, 0xf5, 0xf5, 0xd8, 0x83, 0x83, 0x54, 0xb5, 0x42, 0x8f, 0x66, 0x83, 0x94, 0xd6, 0xbd, 0x5f, 0xce, 0x7c, 0x38, 0x3c, 0x3c, 0xfc, 0xb3, 0x50, 0x28, 0xb8, 0xcb, 0x2, 0x1, 0x0, 0xdc, 0xf4, 0xf4, 0xf4, 0xfe, 0x73, 0x15, 0x2f, 0x17, 0xa4, 0x22, 0x91, 0x48, 0x50, 0xb5, 0x2d, 0x0, 0x80, 0x9b, 0x99, 0x99, 0x79, 0xfb, 0xdc, 0x1, 0xc8, 0x5, 0xa9, 0x44, 0x22, 0xf1, 0xfb, 0x9d, 0x10, 0x0, 0x80, 0x9b, 0x9d, 0x9d, 0xd, 0xea, 0x5, 0xc0, 0xad, 0xfd, 0x43, 0x1a, 0x0, 0xb8, 0xdb, 0x9a, 0xa9, 0x8f, 0xb6, 0xa4, 0x46, 0xa3, 0xa4, 0xb7, 0xd5, 0x37, 0xcf, 0xf3, 0x68, 0x75, 0x75, 0xf5, 0x4c, 0xee, 0x99, 0x1c, 0x80, 0x9c, 0x1e, 0xf7, 0xff, 0x16, 0x8b, 0x45, 0x50, 0x5, 0xa0, 0xb7, 0xb7, 0xb7, 0x85, 0x10, 0xa2, 0x2b, 0xf1, 0x84, 0x10, 0xd4, 0xdf, 0xdf, 0x6f, 0x57, 0x3, 0x80, 0x37, 0x18, 0xc, 0x5, 0x3d, 0x2, 0xa0, 0x69, 0x3a, 0x8b, 0x10, 0xe2, 0x4b, 0x2, 0xc0, 0x18, 0xf3, 0xc1, 0x60, 0x70, 0x47, 0x8f, 0x16, 0x38, 0x3a, 0x3a, 0x5a, 0x93, 0x5b, 0xc3, 0x7f, 0x64, 0x81, 0xba, 0xba, 0x3a, 0x49, 0x8f, 0x0, 0x1a, 0x1a, 0x1a, 0xd4, 0xcd, 0x0, 0x93, 0xc9, 0xa4, 0xcb, 0x21, 0xe8, 0x74, 0x3a, 0xd5, 0x1, 0xa0, 0x69, 0x5a, 0x77, 0x1d, 0x80, 0x31, 0x2e, 0x38, 0x9d, 0x4e, 0xb1, 0x66, 0x1, 0x30, 0xc, 0x23, 0x28, 0x3d, 0x93, 0x9b, 0x1, 0xb9, 0x9a, 0x6, 0x60, 0x36, 0x9b, 0x75, 0xd7, 0x1, 0x4a, 0x21, 0xa8, 0x26, 0x0, 0x94, 0xa, 0x41, 0xb2, 0x0, 0x18, 0x86, 0xc9, 0xe9, 0xd, 0x80, 0x52, 0x8, 0x92, 0x5, 0x60, 0xb1, 0x58, 0x74, 0x67, 0x1, 0xa5, 0x10, 0xa4, 0x4, 0x40, 0x77, 0x43, 0xd0, 0xe1, 0x70, 0xa8, 0x9f, 0x1, 0x14, 0x45, 0x1, 0x45, 0x51, 0x79, 0x3d, 0x1, 0x68, 0x6e, 0x6e, 0x4e, 0xaa, 0x6, 0x80, 0x10, 0x42, 0x6, 0x83, 0x41, 0x37, 0x36, 0x28, 0x15, 0x82, 0x6a, 0x2, 0x0, 0x4d, 0xd3, 0xa9, 0x52, 0xcf, 0x95, 0x0, 0xe8, 0x66, 0xe, 0x98, 0xcd, 0x66, 0xa1, 0x6c, 0x0, 0x7a, 0x5a, 0x8b, 0x59, 0x2c, 0x96, 0x64, 0xcd, 0x2, 0xb8, 0x2b, 0x4, 0xe9, 0xde, 0x2, 0x77, 0x85, 0xa0, 0x9a, 0xb0, 0x40, 0xa9, 0x10, 0xa4, 0x8, 0xc0, 0x64, 0x32, 0xe9, 0x6, 0x40, 0xa9, 0x10, 0x54, 0xaa, 0x3, 0x74, 0xf3, 0x16, 0x70, 0xb9, 0x5c, 0xe5, 0x3, 0xe8, 0xe9, 0xe9, 0x69, 0xd5, 0xc3, 0x66, 0x18, 0x63, 0x5c, 0x68, 0x6a, 0x6a, 0x12, 0xcb, 0x5, 0xa0, 0x9b, 0xd5, 0x38, 0x4d, 0xd3, 0x29, 0x8a, 0xa2, 0xa0, 0x2c, 0x0, 0x18, 0x63, 0x3e, 0x14, 0xa, 0xfd, 0x55, 0xb, 0x21, 0x48, 0xd1, 0x2, 0x7a, 0x59, 0x8d, 0xdf, 0x1b, 0x80, 0x1e, 0x56, 0xe3, 0x84, 0x10, 0x34, 0x30, 0x30, 0x60, 0xbb, 0xeb, 0x77, 0x46, 0x5, 0xef, 0x48, 0xcf, 0x4d, 0xec, 0x8d, 0x99, 0x5, 0xf5, 0xf5, 0xf5, 0xef, 0x46, 0x47, 0x47, 0xb, 0x2e, 0x97, 0xeb, 0xbc, 0x54, 0x8, 0x52, 0x4, 0xc0, 0x30, 0x8c, 0xf4, 0x5c, 0x4, 0x9b, 0x4c, 0xa6, 0xf4, 0xf8, 0xf8, 0xb8, 0xc8, 0xb2, 0x6c, 0x32, 0x9d, 0x4e, 0xff, 0xd4, 0xdd, 0xdd, 0x7d, 0x66, 0x34, 0x1a, 0x8b, 0xd7, 0x3, 0xfd, 0xae, 0x5b, 0x29, 0xb2, 0x57, 0x66, 0xb6, 0xb6, 0xb6, 0xde, 0xc4, 0xe3, 0xf1, 0x6f, 0xae, 0xaf, 0xc1, 0x28, 0x5d, 0x85, 0x79, 0x2, 0xc1, 0x60, 0xb5, 0x5a, 0xa3, 0xa3, 0xa3, 0xa3, 0x45, 0xab, 0xd5, 0x9a, 0x2a, 0x16, 0x8b, 0x8b, 0x6d, 0x6d, 0x6d, 0xef, 0xd5, 0x8a, 0x55, 0xd, 0x20, 0x91, 0x48, 0xbc, 0x3e, 0x38, 0x38, 0xf8, 0xda, 0x6e, 0xb7, 0xf7, 0x5f, 0x5c, 0x5c, 0xd4, 0x7b, 0xbd, 0xde, 0xbc, 0x20, 0x8, 0xcd, 0x85, 0x42, 0x81, 0xfe, 0xf0, 0xae, 0xac, 0x10, 0x98, 0x9b, 0xd5, 0xc5, 0x18, 0x17, 0x59, 0x96, 0x3d, 0x1d, 0x19, 0x19, 0x1, 0x96, 0x65, 0x5, 0x8a, 0xa2, 0x7e, 0x6c, 0x69, 0x69, 0x49, 0x3d, 0x44, 0xb0, 0x2a, 0x0, 0x1f, 0xcc, 0x74, 0x75, 0x41, 0xea, 0xfa, 0x7b, 0x32, 0x99, 0x64, 0x76, 0x77, 0x77, 0x5d, 0xe, 0x87, 0xa3, 0x5f, 0x14, 0xc5, 0x57, 0x57, 0x60, 0x5a, 0x8b, 0xc5, 0xa2, 0xf1, 0xbe, 0x50, 0x6e, 0xa, 0x66, 0x18, 0x26, 0x31, 0x36, 0x36, 0x96, 0x65, 0x59, 0x36, 0x29, 0x49, 0x92, 0xb7, 0xbd, 0xbd, 0xfd, 0x9f, 0x72, 0xda, 0xf9, 0xd1, 0x1, 0xa8, 0x1, 0x93, 0xcf, 0xe7, 0xa9, 0x93, 0x93, 0x13, 0x1b, 0x4d, 0xd3, 0x9f, 0xb, 0x82, 0x60, 0xf5, 0x7a, 0xbd, 0xd9, 0x54, 0x2a, 0xe5, 0xcc, 0x64, 0x32, 0xe, 0xb9, 0x6e, 0xb9, 0x16, 0x8c, 0x31, 0x2e, 0xda, 0x6c, 0xb6, 0xc8, 0xd0, 0xd0, 0x10, 0x65, 0xb3, 0xd9, 0x92, 0x95, 0xa8, 0x6e, 0xc5, 0x0, 0xa8, 0xe9, 0x96, 0x68, 0x34, 0x6a, 0xdd, 0xdf, 0xdf, 0x6f, 0x76, 0xb9, 0x5c, 0x9f, 0x89, 0xa2, 0x58, 0xbf, 0xb8, 0xb8, 0x8, 0x26, 0x93, 0x29, 0x3b, 0x3c, 0x3c, 0x8c, 0xed, 0x76, 0x7b, 0xd2, 0x68, 0x34, 0xfe, 0xd0, 0xd8, 0xd8, 0x98, 0xae, 0xb6, 0xe0, 0x8a, 0x1, 0x50, 0xb, 0xe6, 0xa9, 0x5, 0xbf, 0x9c, 0x97, 0xf3, 0xff, 0xf3, 0x2f, 0x6a, 0x82, 0x7f, 0xf6, 0x4e, 0xca, 0x1b, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
@@ -65,8 +66,8 @@ class TestPhysics2DMainLoop : public MainLoop {
BodyShapeData body_shape_data[8];
void _create_body_shape_data() {
- VisualServer *vs = VisualServer::get_singleton();
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
// SEGMENT
@@ -85,13 +86,13 @@ class TestPhysics2DMainLoop : public MainLoop {
Ref<Image> image = memnew(Image(32, 2, 0, Image::FORMAT_LA8, pixels));
- body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_2d_create(image);
+ body_shape_data[PhysicsServer2D::SHAPE_SEGMENT].image = vs->texture_2d_create(image);
RID segment_shape = ps->segment_shape_create();
Rect2 sg(Point2(-16, 0), Point2(16, 0));
ps->shape_set_data(segment_shape, sg);
- body_shape_data[Physics2DServer::SHAPE_SEGMENT].shape = segment_shape;
+ body_shape_data[PhysicsServer2D::SHAPE_SEGMENT].shape = segment_shape;
}
// CIRCLE
@@ -112,12 +113,12 @@ class TestPhysics2DMainLoop : public MainLoop {
Ref<Image> image = memnew(Image(32, 32, 0, Image::FORMAT_LA8, pixels));
- body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_2d_create(image);
+ body_shape_data[PhysicsServer2D::SHAPE_CIRCLE].image = vs->texture_2d_create(image);
RID circle_shape = ps->circle_shape_create();
ps->shape_set_data(circle_shape, 16);
- body_shape_data[Physics2DServer::SHAPE_CIRCLE].shape = circle_shape;
+ body_shape_data[PhysicsServer2D::SHAPE_CIRCLE].shape = circle_shape;
}
// BOX
@@ -139,12 +140,12 @@ class TestPhysics2DMainLoop : public MainLoop {
Ref<Image> image = memnew(Image(32, 32, 0, Image::FORMAT_LA8, pixels));
- body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_2d_create(image);
+ body_shape_data[PhysicsServer2D::SHAPE_RECTANGLE].image = vs->texture_2d_create(image);
RID rectangle_shape = ps->rectangle_shape_create();
ps->shape_set_data(rectangle_shape, Vector2(16, 16));
- body_shape_data[Physics2DServer::SHAPE_RECTANGLE].shape = rectangle_shape;
+ body_shape_data[PhysicsServer2D::SHAPE_RECTANGLE].shape = rectangle_shape;
}
// CAPSULE
@@ -167,12 +168,12 @@ class TestPhysics2DMainLoop : public MainLoop {
Ref<Image> image = memnew(Image(32, 64, 0, Image::FORMAT_LA8, pixels));
- body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_2d_create(image);
+ body_shape_data[PhysicsServer2D::SHAPE_CAPSULE].image = vs->texture_2d_create(image);
RID capsule_shape = ps->capsule_shape_create();
ps->shape_set_data(capsule_shape, Vector2(16, 32));
- body_shape_data[Physics2DServer::SHAPE_CAPSULE].shape = capsule_shape;
+ body_shape_data[PhysicsServer2D::SHAPE_CAPSULE].shape = capsule_shape;
}
// CONVEX
@@ -181,7 +182,7 @@ class TestPhysics2DMainLoop : public MainLoop {
Ref<Image> image = memnew(Image(convex_png));
- body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image);
+ body_shape_data[PhysicsServer2D::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image);
RID convex_polygon_shape = ps->convex_polygon_shape_create();
@@ -196,14 +197,14 @@ class TestPhysics2DMainLoop : public MainLoop {
arr.push_back(Point2(11, 7) - sb);
ps->shape_set_data(convex_polygon_shape, arr);
- body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape;
+ body_shape_data[PhysicsServer2D::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape;
}
}
void _do_ray_query() {
/*
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
ps->query_intersection_segment(ray_query,ray_from,ray_to);
*/
}
@@ -245,16 +246,16 @@ protected:
}
}
- RID _add_body(Physics2DServer::ShapeType p_shape, const Transform2D &p_xform) {
+ RID _add_body(PhysicsServer2D::ShapeType p_shape, const Transform2D &p_xform) {
- VisualServer *vs = VisualServer::get_singleton();
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
RID body = ps->body_create();
ps->body_add_shape(body, body_shape_data[p_shape].shape);
ps->body_set_space(body, space);
- ps->body_set_continuous_collision_detection_mode(body, Physics2DServer::CCD_MODE_CAST_SHAPE);
- ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform);
+ ps->body_set_continuous_collision_detection_mode(body, PhysicsServer2D::CCD_MODE_CAST_SHAPE);
+ ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, p_xform);
//print_line("add body with xform: "+p_xform);
RID sprite = vs->canvas_item_create();
@@ -272,7 +273,7 @@ protected:
void _add_plane(const Vector2 &p_normal, real_t p_d) {
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
Array arr;
arr.push_back(p_normal);
@@ -282,23 +283,23 @@ protected:
ps->shape_set_data(plane, arr);
RID plane_body = ps->body_create();
- ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC);
+ ps->body_set_mode(plane_body, PhysicsServer2D::BODY_MODE_STATIC);
ps->body_set_space(plane_body, space);
ps->body_add_shape(plane_body, plane);
}
void _add_concave(const Vector<Vector2> &p_points, const Transform2D &p_xform = Transform2D()) {
- Physics2DServer *ps = Physics2DServer::get_singleton();
- VisualServer *vs = VisualServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
RID concave = ps->concave_polygon_shape_create();
ps->shape_set_data(concave, p_points);
RID body = ps->body_create();
- ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC);
+ ps->body_set_mode(body, PhysicsServer2D::BODY_MODE_STATIC);
ps->body_set_space(body, space);
ps->body_add_shape(body, concave);
- ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform);
+ ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, p_xform);
RID sprite = vs->canvas_item_create();
vs->canvas_item_set_parent(sprite, canvas);
@@ -309,8 +310,8 @@ protected:
}
void _body_moved(Object *p_state, RID p_sprite) {
- Physics2DDirectBodyState *state = (Physics2DDirectBodyState *)p_state;
- VisualServer::get_singleton()->canvas_item_set_transform(p_sprite, state->get_transform());
+ PhysicsDirectBodyState2D *state = (PhysicsDirectBodyState2D *)p_state;
+ RenderingServer::get_singleton()->canvas_item_set_transform(p_sprite, state->get_transform());
}
void _ray_query_callback(const RID &p_rid, ObjectID p_id, int p_shape, const Vector2 &p_point, const Vector2 &p_normal) {
@@ -323,7 +324,7 @@ protected:
ray_end = ray_to;
}
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
vs->canvas_item_clear(ray);
vs->canvas_item_add_line(ray, ray_from, ray_end, p_rid.is_valid() ? Color(0, 1, 0.4) : Color(1, 0.4, 0), 2);
@@ -340,21 +341,21 @@ protected:
public:
virtual void init() {
- VisualServer *vs = VisualServer::get_singleton();
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
space = ps->space_create();
ps->space_set_active(space, true);
ps->set_active(true);
- ps->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, Vector2(0, 1));
- ps->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY, 98);
+ ps->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, Vector2(0, 1));
+ ps->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, 98);
{
RID vp = vs->viewport_create();
canvas = vs->canvas_create();
- Size2i screen_size = OS::get_singleton()->get_window_size();
+ Size2i screen_size = DisplayServer::get_singleton()->window_get_size();
vs->viewport_attach_canvas(vp, canvas);
vs->viewport_set_size(vp, screen_size.x, screen_size.y);
vs->viewport_attach_to_screen(vp, Rect2(Vector2(), screen_size));
@@ -377,25 +378,25 @@ public:
for (int i = 0; i < 32; i++) {
- Physics2DServer::ShapeType types[4] = {
- Physics2DServer::SHAPE_CIRCLE,
- Physics2DServer::SHAPE_CAPSULE,
- Physics2DServer::SHAPE_RECTANGLE,
- Physics2DServer::SHAPE_CONVEX_POLYGON,
+ PhysicsServer2D::ShapeType types[4] = {
+ PhysicsServer2D::SHAPE_CIRCLE,
+ PhysicsServer2D::SHAPE_CAPSULE,
+ PhysicsServer2D::SHAPE_RECTANGLE,
+ PhysicsServer2D::SHAPE_CONVEX_POLYGON,
};
- Physics2DServer::ShapeType type = types[i % 4];
- //type=Physics2DServer::SHAPE_SEGMENT;
+ PhysicsServer2D::ShapeType type = types[i % 4];
+ //type=PhysicsServer2D::SHAPE_SEGMENT;
_add_body(type, Transform2D(i * 0.8, Point2(152 + i * 40, 100 - 40 * i)));
/*
if (i==0)
- ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC);
+ ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC);
*/
}
- //RID b= _add_body(Physics2DServer::SHAPE_CIRCLE,Transform2D(0,Point2(101,140)));
- //ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC);
+ //RID b= _add_body(PhysicsServer2D::SHAPE_CIRCLE,Transform2D(0,Point2(101,140)));
+ //ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC);
Point2 prev;
diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics_3d.cpp
index 4931d42674..2d208ee317 100644
--- a/main/tests/test_physics.cpp
+++ b/main/tests/test_physics_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* test_physics.cpp */
+/* test_physics_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "test_physics.h"
+#include "test_physics_3d.h"
#include "core/map.h"
#include "core/math/math_funcs.h"
@@ -36,12 +36,13 @@
#include "core/os/main_loop.h"
#include "core/os/os.h"
#include "core/print_string.h"
-#include "servers/physics_server.h"
-#include "servers/visual_server.h"
+#include "servers/display_server.h"
+#include "servers/physics_server_3d.h"
+#include "servers/rendering_server.h"
-class TestPhysicsMainLoop : public MainLoop {
+class TestPhysics3DMainLoop : public MainLoop {
- GDCLASS(TestPhysicsMainLoop, MainLoop);
+ GDCLASS(TestPhysics3DMainLoop, MainLoop);
enum {
LINK_COUNT = 20,
@@ -64,13 +65,13 @@ class TestPhysicsMainLoop : public MainLoop {
Point2 joy_direction;
List<RID> bodies;
- Map<PhysicsServer::ShapeType, RID> type_shape_map;
- Map<PhysicsServer::ShapeType, RID> type_mesh_map;
+ Map<PhysicsServer3D::ShapeType, RID> type_shape_map;
+ Map<PhysicsServer3D::ShapeType, RID> type_mesh_map;
void body_changed_transform(Object *p_state, RID p_visual_instance) {
- PhysicsDirectBodyState *state = (PhysicsDirectBodyState *)p_state;
- VisualServer *vs = VisualServer::get_singleton();
+ PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state;
+ RenderingServer *vs = RenderingServer::get_singleton();
Transform t = state->get_transform();
vs->instance_set_transform(p_visual_instance, t);
}
@@ -80,26 +81,26 @@ class TestPhysicsMainLoop : public MainLoop {
protected:
static void _bind_methods() {
- ClassDB::bind_method("body_changed_transform", &TestPhysicsMainLoop::body_changed_transform);
+ ClassDB::bind_method("body_changed_transform", &TestPhysics3DMainLoop::body_changed_transform);
}
- RID create_body(PhysicsServer::ShapeType p_shape, PhysicsServer::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) {
+ RID create_body(PhysicsServer3D::ShapeType p_shape, PhysicsServer3D::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) {
- VisualServer *vs = VisualServer::get_singleton();
- PhysicsServer *ps = PhysicsServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
RID mesh_instance = vs->instance_create2(type_mesh_map[p_shape], scenario);
RID body = ps->body_create(p_body, !p_active_default);
ps->body_set_space(body, space);
- ps->body_set_param(body, PhysicsServer::BODY_PARAM_BOUNCE, 0.0);
+ ps->body_set_param(body, PhysicsServer3D::BODY_PARAM_BOUNCE, 0.0);
//todo set space
ps->body_add_shape(body, type_shape_map[p_shape]);
ps->body_set_force_integration_callback(body, this, "body_changed_transform", mesh_instance);
- ps->body_set_state(body, PhysicsServer::BODY_STATE_TRANSFORM, p_location);
+ ps->body_set_state(body, PhysicsServer3D::BODY_STATE_TRANSFORM, p_location);
bodies.push_back(body);
- if (p_body == PhysicsServer::BODY_MODE_STATIC) {
+ if (p_body == PhysicsServer3D::BODY_MODE_STATIC) {
vs->instance_set_transform(mesh_instance, p_location);
}
@@ -108,12 +109,12 @@ protected:
RID create_static_plane(const Plane &p_plane) {
- PhysicsServer *ps = PhysicsServer::get_singleton();
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
- RID world_margin_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE);
+ RID world_margin_shape = ps->shape_create(PhysicsServer3D::SHAPE_PLANE);
ps->shape_set_data(world_margin_shape, p_plane);
- RID b = ps->body_create(PhysicsServer::BODY_MODE_STATIC);
+ RID b = ps->body_create(PhysicsServer3D::BODY_MODE_STATIC);
ps->body_set_space(b, space);
//todo set space
ps->body_add_shape(b, world_margin_shape);
@@ -122,24 +123,24 @@ protected:
void configure_body(RID p_body, float p_mass, float p_friction, float p_bounce) {
- PhysicsServer *ps = PhysicsServer::get_singleton();
- ps->body_set_param(p_body, PhysicsServer::BODY_PARAM_MASS, p_mass);
- ps->body_set_param(p_body, PhysicsServer::BODY_PARAM_FRICTION, p_friction);
- ps->body_set_param(p_body, PhysicsServer::BODY_PARAM_BOUNCE, p_bounce);
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
+ ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_MASS, p_mass);
+ ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_FRICTION, p_friction);
+ ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_BOUNCE, p_bounce);
}
void init_shapes() {
- VisualServer *vs = VisualServer::get_singleton();
- PhysicsServer *ps = PhysicsServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
/* SPHERE SHAPE */
RID sphere_mesh = vs->make_sphere_mesh(10, 20, 0.5);
- type_mesh_map[PhysicsServer::SHAPE_SPHERE] = sphere_mesh;
+ type_mesh_map[PhysicsServer3D::SHAPE_SPHERE] = sphere_mesh;
- RID sphere_shape = ps->shape_create(PhysicsServer::SHAPE_SPHERE);
+ RID sphere_shape = ps->shape_create(PhysicsServer3D::SHAPE_SPHERE);
ps->shape_set_data(sphere_shape, 0.5);
- type_shape_map[PhysicsServer::SHAPE_SPHERE] = sphere_shape;
+ type_shape_map[PhysicsServer3D::SHAPE_SPHERE] = sphere_shape;
/* BOX SHAPE */
@@ -147,11 +148,11 @@ protected:
RID box_mesh = vs->mesh_create();
Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
vs->mesh_add_surface_from_mesh_data(box_mesh, box_data);
- type_mesh_map[PhysicsServer::SHAPE_BOX] = box_mesh;
+ type_mesh_map[PhysicsServer3D::SHAPE_BOX] = box_mesh;
- RID box_shape = ps->shape_create(PhysicsServer::SHAPE_BOX);
+ RID box_shape = ps->shape_create(PhysicsServer3D::SHAPE_BOX);
ps->shape_set_data(box_shape, Vector3(0.5, 0.5, 0.5));
- type_shape_map[PhysicsServer::SHAPE_BOX] = box_shape;
+ type_shape_map[PhysicsServer3D::SHAPE_BOX] = box_shape;
/* CAPSULE SHAPE */
@@ -161,14 +162,14 @@ protected:
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data);
- type_mesh_map[PhysicsServer::SHAPE_CAPSULE] = capsule_mesh;
+ type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh;
- RID capsule_shape = ps->shape_create(PhysicsServer::SHAPE_CAPSULE);
+ RID capsule_shape = ps->shape_create(PhysicsServer3D::SHAPE_CAPSULE);
Dictionary capsule_params;
capsule_params["radius"] = 0.5;
capsule_params["height"] = 1.4;
ps->shape_set_data(capsule_shape, capsule_params);
- type_shape_map[PhysicsServer::SHAPE_CAPSULE] = capsule_shape;
+ type_shape_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_shape;
/* CONVEX SHAPE */
@@ -179,18 +180,18 @@ protected:
QuickHull::build(convex_data.vertices, convex_data);
vs->mesh_add_surface_from_mesh_data(convex_mesh, convex_data);
- type_mesh_map[PhysicsServer::SHAPE_CONVEX_POLYGON] = convex_mesh;
+ type_mesh_map[PhysicsServer3D::SHAPE_CONVEX_POLYGON] = convex_mesh;
- RID convex_shape = ps->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON);
+ RID convex_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON);
ps->shape_set_data(convex_shape, convex_data.vertices);
- type_shape_map[PhysicsServer::SHAPE_CONVEX_POLYGON] = convex_shape;
+ type_shape_map[PhysicsServer3D::SHAPE_CONVEX_POLYGON] = convex_shape;
}
void make_trimesh(Vector<Vector3> p_faces, const Transform &p_xform = Transform()) {
- VisualServer *vs = VisualServer::get_singleton();
- PhysicsServer *ps = PhysicsServer::get_singleton();
- RID trimesh_shape = ps->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON);
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
+ RID trimesh_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON);
ps->shape_set_data(trimesh_shape, p_faces);
p_faces = ps->shape_get_data(trimesh_shape); // optimized one
Vector<Vector3> normals; // for drawing
@@ -204,19 +205,19 @@ protected:
RID trimesh_mesh = vs->mesh_create();
Array d;
- d.resize(VS::ARRAY_MAX);
- d[VS::ARRAY_VERTEX] = p_faces;
- d[VS::ARRAY_NORMAL] = normals;
- vs->mesh_add_surface_from_arrays(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, d);
+ d.resize(RS::ARRAY_MAX);
+ d[RS::ARRAY_VERTEX] = p_faces;
+ d[RS::ARRAY_NORMAL] = normals;
+ vs->mesh_add_surface_from_arrays(trimesh_mesh, RS::PRIMITIVE_TRIANGLES, d);
RID triins = vs->instance_create2(trimesh_mesh, scenario);
- RID tribody = ps->body_create(PhysicsServer::BODY_MODE_STATIC);
+ RID tribody = ps->body_create(PhysicsServer3D::BODY_MODE_STATIC);
ps->body_set_space(tribody, space);
//todo set space
ps->body_add_shape(tribody, trimesh_shape);
Transform tritrans = p_xform;
- ps->body_set_state(tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans);
+ ps->body_set_state(tribody, PhysicsServer3D::BODY_STATE_TRANSFORM, tritrans);
vs->instance_set_transform(triins, tritrans);
}
@@ -275,11 +276,11 @@ public:
if (mover.is_valid()) {
- PhysicsServer *ps = PhysicsServer::get_singleton();
- Transform t = ps->body_get_state(mover, PhysicsServer::BODY_STATE_TRANSFORM);
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
+ Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM);
t.origin += Vector3(x, y, 0);
- ps->body_set_state(mover, PhysicsServer::BODY_STATE_TRANSFORM, t);
+ ps->body_set_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM, t);
}
}
}
@@ -293,11 +294,11 @@ public:
ofs_x = ofs_y = 0;
init_shapes();
- PhysicsServer *ps = PhysicsServer::get_singleton();
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
space = ps->space_create();
ps->space_set_active(space, true);
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
/* LIGHT */
RID lightaux = vs->directional_light_create();
@@ -313,7 +314,7 @@ public:
camera = vs->camera_create();
RID viewport = vs->viewport_create();
- Size2i screen_size = OS::get_singleton()->get_window_size();
+ Size2i screen_size = DisplayServer::get_singleton()->window_get_size();
vs->viewport_set_size(viewport, screen_size.x, screen_size.y);
vs->viewport_attach_to_screen(viewport, Rect2(Vector2(), screen_size));
vs->viewport_set_active(viewport, true);
@@ -334,17 +335,17 @@ public:
if (mover.is_valid()) {
static float joy_speed = 10;
- PhysicsServer *ps = PhysicsServer::get_singleton();
- Transform t = ps->body_get_state(mover, PhysicsServer::BODY_STATE_TRANSFORM);
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
+ Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM);
t.origin += Vector3(joy_speed * joy_direction.x * p_time, -joy_speed * joy_direction.y * p_time, 0);
- ps->body_set_state(mover, PhysicsServer::BODY_STATE_TRANSFORM, t);
+ ps->body_set_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM, t);
};
Transform cameratr;
cameratr.rotate(Vector3(0, 1, 0), ofs_x);
cameratr.rotate(Vector3(1, 0, 0), -ofs_y);
cameratr.translate(Vector3(0, 2, 8));
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
vs->camera_set_transform(camera, cameratr);
return quit;
@@ -360,17 +361,17 @@ public:
void test_character() {
- VisualServer *vs = VisualServer::get_singleton();
- PhysicsServer *ps = PhysicsServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
Vector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5, 1, 12, 5, Vector3::AXIS_Y);
RID capsule_mesh = vs->mesh_create();
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data);
- type_mesh_map[PhysicsServer::SHAPE_CAPSULE] = capsule_mesh;
+ type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh;
- RID capsule_shape = ps->shape_create(PhysicsServer::SHAPE_CAPSULE);
+ RID capsule_shape = ps->shape_create(PhysicsServer3D::SHAPE_CAPSULE);
Dictionary capsule_params;
capsule_params["radius"] = 0.5;
capsule_params["height"] = 1;
@@ -380,14 +381,14 @@ public:
ps->shape_set_data(capsule_shape, capsule_params);
RID mesh_instance = vs->instance_create2(capsule_mesh, scenario);
- character = ps->body_create(PhysicsServer::BODY_MODE_CHARACTER);
+ character = ps->body_create(PhysicsServer3D::BODY_MODE_CHARACTER);
ps->body_set_space(character, space);
//todo add space
ps->body_add_shape(character, capsule_shape);
ps->body_set_force_integration_callback(character, this, "body_changed_transform", mesh_instance);
- ps->body_set_state(character, PhysicsServer::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(-2, 5, -2)));
+ ps->body_set_state(character, PhysicsServer3D::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(-2, 5, -2)));
bodies.push_back(character);
}
@@ -395,21 +396,21 @@ public:
for (int i = 0; i < 35; i++) {
- static const PhysicsServer::ShapeType shape_idx[] = {
- PhysicsServer::SHAPE_CAPSULE,
- PhysicsServer::SHAPE_BOX,
- PhysicsServer::SHAPE_SPHERE,
- PhysicsServer::SHAPE_CONVEX_POLYGON
+ static const PhysicsServer3D::ShapeType shape_idx[] = {
+ PhysicsServer3D::SHAPE_CAPSULE,
+ PhysicsServer3D::SHAPE_BOX,
+ PhysicsServer3D::SHAPE_SPHERE,
+ PhysicsServer3D::SHAPE_CONVEX_POLYGON
};
- PhysicsServer::ShapeType type = shape_idx[i % 4];
+ PhysicsServer3D::ShapeType type = shape_idx[i % 4];
Transform t;
t.origin = Vector3(0.0 * i, 3.5 + 1.1 * i, 0.7 + 0.0 * i);
t.basis.rotate(Vector3(0.2, -1, 0), Math_PI / 2 * 0.6);
- create_body(type, PhysicsServer::BODY_MODE_RIGID, t);
+ create_body(type, PhysicsServer3D::BODY_MODE_RIGID, t);
}
create_static_plane(Plane(Vector3(0, 1, 0), -1));
@@ -417,7 +418,7 @@ public:
void test_activate() {
- create_body(PhysicsServer::SHAPE_BOX, PhysicsServer::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true);
+ create_body(PhysicsServer3D::SHAPE_BOX, PhysicsServer3D::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true);
create_static_plane(Plane(Vector3(0, 1, 0), -1));
}
@@ -425,14 +426,14 @@ public:
return false;
}
- TestPhysicsMainLoop() {
+ TestPhysics3DMainLoop() {
}
};
-namespace TestPhysics {
+namespace TestPhysics3D {
MainLoop *test() {
- return memnew(TestPhysicsMainLoop);
+ return memnew(TestPhysics3DMainLoop);
}
-} // namespace TestPhysics
+} // namespace TestPhysics3D
diff --git a/main/tests/test_physics.h b/main/tests/test_physics_3d.h
index fbbc59bba9..d03f2c6573 100644
--- a/main/tests/test_physics.h
+++ b/main/tests/test_physics_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* test_physics.h */
+/* test_physics_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,7 +33,7 @@
#include "core/os/main_loop.h"
-namespace TestPhysics {
+namespace TestPhysics3D {
MainLoop *test();
}
diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp
index 62239a5cb5..bcfcf61e25 100644
--- a/main/tests/test_render.cpp
+++ b/main/tests/test_render.cpp
@@ -36,7 +36,8 @@
#include "core/os/main_loop.h"
#include "core/os/os.h"
#include "core/print_string.h"
-#include "servers/visual_server.h"
+#include "servers/display_server.h"
+#include "servers/rendering_server.h"
#define OBJECT_COUNT 50
@@ -74,7 +75,7 @@ public:
virtual void init() {
print_line("INITIALIZING TEST RENDER");
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
test_cube = vs->get_test_cube();
scenario = vs->scenario_create();
@@ -125,7 +126,7 @@ public:
print_line("ERR: " + itos(err));
test_cube = vs->mesh_create();
vs->mesh_add_surface_from_mesh_data(test_cube, md);
- //vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
+ //vs->scenario_set_debug(scenario,RS::SCENARIO_DEBUG_WIREFRAME);
/*
RID sm = vs->shader_create();
@@ -163,7 +164,7 @@ public:
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
viewport = vs->viewport_create();
- Size2i screen_size = OS::get_singleton()->get_window_size();
+ Size2i screen_size = DisplayServer::get_singleton()->window_get_size();
vs->viewport_set_size(viewport, screen_size.x, screen_size.y);
vs->viewport_attach_to_screen(viewport, Rect2(Vector2(), screen_size));
vs->viewport_set_active(viewport, true);
@@ -173,16 +174,16 @@ public:
vs->camera_set_perspective(camera, 60, 0.1, 1000);
/*
- RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 );
+ RID lightaux = vs->light_create( RenderingServer::LIGHT_OMNI );
+ vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_RADIUS, 80 );
+ vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_ATTENUATION, 1 );
+ vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_ENERGY, 1.5 );
light = vs->instance_create( lightaux );
*/
RID lightaux;
lightaux = vs->directional_light_create();
- //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
+ //vs->light_set_color( lightaux, RenderingServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0));
//vs->light_set_shadow( lightaux, true );
light = vs->instance_create2(lightaux, scenario);
@@ -193,10 +194,10 @@ public:
vs->instance_set_transform(light, lla);
lightaux = vs->omni_light_create();
- //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
+ //vs->light_set_color( lightaux, RenderingServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0));
- vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RANGE, 4);
- vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8);
+ vs->light_set_param(lightaux, RenderingServer::LIGHT_PARAM_RANGE, 4);
+ vs->light_set_param(lightaux, RenderingServer::LIGHT_PARAM_ENERGY, 8);
//vs->light_set_shadow( lightaux, true );
//light = vs->instance_create( lightaux );
@@ -205,7 +206,7 @@ public:
}
virtual bool iteration(float p_time) {
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
//Transform t;
//t.rotate(Vector3(0, 1, 0), ofs);
//t.translate(Vector3(0,0,20 ));
diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp
index 941a6771bf..dd525d7653 100644
--- a/main/tests/test_shader_lang.cpp
+++ b/main/tests/test_shader_lang.cpp
@@ -37,7 +37,7 @@
#include "core/print_string.h"
#include "scene/gui/control.h"
#include "scene/gui/text_edit.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/shader_language.h"
typedef ShaderLanguage SL;
diff --git a/methods.py b/methods.py
index 56c495468d..dc82c97361 100644
--- a/methods.py
+++ b/methods.py
@@ -2,12 +2,11 @@ import os
import re
import glob
import subprocess
-from compat import iteritems, isbasestring, decode_utf8
def add_source_files(self, sources, files, warn_duplicates=True):
# Convert string to list of absolute paths (including expanding wildcard)
- if isbasestring(files):
+ if isinstance(files, (str, bytes)):
# Keep SCons project-absolute path as they are (no wildcard support)
if files.startswith('#'):
if '*' in files:
@@ -62,6 +61,9 @@ def update_version(module_version_string=""):
# NOTE: It is safe to generate this file here, since this is still executed serially
f = open("core/version_generated.gen.h", "w")
+ f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ f.write("#ifndef VERSION_GENERATED_GEN_H\n")
+ f.write("#define VERSION_GENERATED_GEN_H\n")
f.write("#define VERSION_SHORT_NAME \"" + str(version.short_name) + "\"\n")
f.write("#define VERSION_NAME \"" + str(version.name) + "\"\n")
f.write("#define VERSION_MAJOR " + str(version.major) + "\n")
@@ -72,10 +74,14 @@ def update_version(module_version_string=""):
f.write("#define VERSION_MODULE_CONFIG \"" + str(version.module_config) + module_version_string + "\"\n")
f.write("#define VERSION_YEAR " + str(version.year) + "\n")
f.write("#define VERSION_WEBSITE \"" + str(version.website) + "\"\n")
+ f.write("#endif // VERSION_GENERATED_GEN_H\n")
f.close()
# NOTE: It is safe to generate this file here, since this is still executed serially
fhash = open("core/version_hash.gen.h", "w")
+ fhash.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ fhash.write("#ifndef VERSION_HASH_GEN_H\n")
+ fhash.write("#define VERSION_HASH_GEN_H\n")
githash = ""
gitfolder = ".git"
@@ -93,7 +99,8 @@ def update_version(module_version_string=""):
else:
githash = head
- fhash.write("#define VERSION_HASH \"" + githash + "\"")
+ fhash.write("#define VERSION_HASH \"" + githash + "\"\n")
+ fhash.write("#endif // VERSION_HASH_GEN_H\n")
fhash.close()
@@ -232,7 +239,7 @@ def use_windows_spawn_fix(self, platform=None):
cmdline = cmd + " " + newargs
rv = 0
- env = {str(key): str(value) for key, value in iteritems(env)}
+ env = {str(key): str(value) for key, value in iter(env.items())}
if len(cmdline) > 32000 and cmd.endswith("ar"):
cmdline = cmd + " " + args[1] + " " + args[2] + " "
for i in range(3, len(args)):
@@ -522,7 +529,7 @@ def detect_darwin_sdk_path(platform, env):
if not env[var_name]:
try:
- sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip())
+ sdk_path = subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip().decode("utf-8")
if sdk_path:
env[var_name] = sdk_path
except (subprocess.CalledProcessError, OSError):
@@ -532,7 +539,7 @@ def detect_darwin_sdk_path(platform, env):
def is_vanilla_clang(env):
if not using_clang(env):
return False
- version = decode_utf8(subprocess.check_output([env['CXX'], '--version']).strip())
+ version = subprocess.check_output([env['CXX'], '--version']).strip().decode("utf-8")
return not version.startswith("Apple")
@@ -545,7 +552,7 @@ def get_compiler_version(env):
# Not using -dumpversion as some GCC distros only return major, and
# Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
try:
- version = decode_utf8(subprocess.check_output([env.subst(env['CXX']), '--version']).strip())
+ version = subprocess.check_output([env.subst(env['CXX']), '--version']).strip().decode("utf-8")
except (subprocess.CalledProcessError, OSError):
print("Couldn't parse CXX environment variable to infer compiler version.")
return None
diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm
index 39447e8dab..031e1e115e 100644
--- a/modules/arkit/arkit_interface.mm
+++ b/modules/arkit/arkit_interface.mm
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
#include "scene/resources/surface_tool.h"
-#include "servers/visual/visual_server_globals.h"
+#include "servers/rendering/rendering_server_globals.h"
#import <ARKit/ARKit.h>
#import <UIKit/UIKit.h>
diff --git a/modules/assimp/SCsub b/modules/assimp/SCsub
index 90cdd7f5fc..cef2396dfb 100644
--- a/modules/assimp/SCsub
+++ b/modules/assimp/SCsub
@@ -75,7 +75,7 @@ if True: # env['builtin_assimp']:
if(env['platform'] == 'windows'):
env_assimp.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
env_assimp.Append(CPPDEFINES=[('PLATFORM', 'WINDOWS')])
- elif(env['platform'] == 'x11'):
+ elif(env['platform'] == 'linuxbsd'):
env_assimp.Append(CPPDEFINES=['PLATFORM_LINUX'])
env_assimp.Append(CPPDEFINES=[('PLATFORM', 'LINUX')])
elif(env['platform'] == 'osx'):
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 682a7e33c8..d163512bb3 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -32,9 +32,9 @@
#include "core/io/image_loader.h"
#include "editor/import/resource_importer_scene.h"
#include "import_utils.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/light.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/main/node.h"
#include "scene/resources/material.h"
#include "scene/resources/surface_tool.h"
@@ -297,7 +297,7 @@ aiBone *EditorSceneImporterAssimp::get_bone_from_stack(ImportState &state, aiStr
return NULL;
}
-Spatial *
+Node3D *
EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps,
const int32_t p_max_bone_weights) {
ERR_FAIL_COND_V(scene == NULL, NULL);
@@ -343,7 +343,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
String node_name = AssimpUtils::get_assimp_string(element_assimp_node->mName);
//print_verbose("node: " + node_name);
- Spatial *spatial = NULL;
+ Node3D *spatial = NULL;
Transform transform = AssimpUtils::assimp_matrix_transform(element_assimp_node->mTransformation);
// retrieve this node bone
@@ -356,7 +356,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
} else if (state.armature_nodes.find(element_assimp_node)) {
// create skeleton
print_verbose("Making skeleton: " + node_name);
- Skeleton *skeleton = memnew(Skeleton);
+ Skeleton3D *skeleton = memnew(Skeleton3D);
spatial = skeleton;
if (!state.armature_skeletons.has(element_assimp_node)) {
state.armature_skeletons.insert(element_assimp_node, skeleton);
@@ -364,7 +364,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
} else if (bone != NULL) {
continue;
} else {
- spatial = memnew(Spatial);
+ spatial = memnew(Node3D);
}
ERR_CONTINUE_MSG(spatial == NULL, "FBX Import - are we out of ram?");
@@ -381,11 +381,11 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
// flat node map parent lookup tool
state.flat_node_map.insert(element_assimp_node, spatial);
- Map<const aiNode *, Spatial *>::Element *parent_lookup = state.flat_node_map.find(parent_assimp_node);
+ Map<const aiNode *, Node3D *>::Element *parent_lookup = state.flat_node_map.find(parent_assimp_node);
// note: this always fails on the root node :) keep that in mind this is by design
if (parent_lookup) {
- Spatial *parent_node = parent_lookup->value();
+ Node3D *parent_node = parent_lookup->value();
ERR_FAIL_COND_V_MSG(parent_node == NULL, state.root,
"Parent node invalid even though lookup successful, out of ram?");
@@ -435,7 +435,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
String bone_name = AssimpUtils::get_anim_string_from_assimp(bone->mName);
ERR_CONTINUE_MSG(armature_for_bone == NULL, "Armature for bone invalid: " + bone_name);
- Skeleton *skeleton = state.armature_skeletons[armature_for_bone];
+ Skeleton3D *skeleton = state.armature_skeletons[armature_for_bone];
state.skeleton_bone_map[bone] = skeleton;
@@ -464,11 +464,11 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
print_verbose("generating mesh phase from skeletal mesh");
- List<Spatial *> cleanup_template_nodes;
+ List<Node3D *> cleanup_template_nodes;
- for (Map<const aiNode *, Spatial *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
+ for (Map<const aiNode *, Node3D *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
const aiNode *assimp_node = key_value_pair->key();
- Spatial *mesh_template = key_value_pair->value();
+ Node3D *mesh_template = key_value_pair->value();
ERR_CONTINUE(assimp_node == NULL);
ERR_CONTINUE(mesh_template == NULL);
@@ -488,7 +488,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
Transform node_transform = AssimpUtils::assimp_matrix_transform(assimp_node->mTransformation);
if (assimp_node->mNumMeshes > 0) {
- MeshInstance *mesh = create_mesh(state, assimp_node, node_name, parent_node, node_transform);
+ MeshInstance3D *mesh = create_mesh(state, assimp_node, node_name, parent_node, node_transform);
if (mesh) {
parent_node->remove_child(mesh_template);
@@ -522,7 +522,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
}
}
- for (List<Spatial *>::Element *element = cleanup_template_nodes.front(); element; element = element->next()) {
+ for (List<Node3D *>::Element *element = cleanup_template_nodes.front(); element; element = element->next()) {
if (element->get()) {
memdelete(element->get());
}
@@ -559,7 +559,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
void EditorSceneImporterAssimp::_insert_animation_track(ImportState &scene, const aiAnimation *assimp_anim, int track_id,
int anim_fps, Ref<Animation> animation, float ticks_per_second,
- Skeleton *skeleton, const NodePath &node_path,
+ Skeleton3D *skeleton, const NodePath &node_path,
const String &node_name, aiBone *track_bone) {
const aiNodeAnim *assimp_track = assimp_anim->mChannels[track_id];
//make transform track
@@ -652,9 +652,9 @@ void EditorSceneImporterAssimp::_insert_animation_track(ImportState &scene, cons
// I really do not like this but need to figure out a better way of removing it later.
Node *EditorSceneImporterAssimp::get_node_by_name(ImportState &state, String name) {
- for (Map<const aiNode *, Spatial *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
+ for (Map<const aiNode *, Node3D *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
const aiNode *assimp_node = key_value_pair->key();
- Spatial *node = key_value_pair->value();
+ Node3D *node = key_value_pair->value();
String node_name = AssimpUtils::get_assimp_string(assimp_node->mName);
if (name == node_name && node) {
@@ -747,7 +747,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
continue; //do not bother
}
- Skeleton *skeleton = NULL;
+ Skeleton3D *skeleton = NULL;
NodePath node_path;
aiBone *bone = NULL;
@@ -805,7 +805,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
Node *item = get_node_by_name(state, mesh_name);
ERR_CONTINUE_MSG(!item, "failed to look up node by name");
- const MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(item);
+ const MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(item);
ERR_CONTINUE(mesh_instance == NULL);
String base_path = state.root->get_path_to(mesh_instance);
@@ -842,7 +842,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
Ref<Mesh>
EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &state, const Vector<int> &p_surface_indices,
const aiNode *assimp_node, Ref<Skin> &skin,
- Skeleton *&skeleton_assigned) {
+ Skeleton3D *&skeleton_assigned) {
Ref<ArrayMesh> mesh;
mesh.instance();
@@ -1208,9 +1208,9 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
}
Array array_copy;
- array_copy.resize(VisualServer::ARRAY_MAX);
+ array_copy.resize(RenderingServer::ARRAY_MAX);
- for (int l = 0; l < VisualServer::ARRAY_MAX; l++) {
+ for (int l = 0; l < RenderingServer::ARRAY_MAX; l++) {
array_copy[l] = array_mesh[l].duplicate(true);
}
@@ -1224,13 +1224,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
Vector3 position = Vector3(ai_pos.x, ai_pos.y, ai_pos.z);
vertices.ptrw()[l] = position;
}
- PackedVector3Array new_vertices = array_copy[VisualServer::ARRAY_VERTEX].duplicate(true);
+ PackedVector3Array new_vertices = array_copy[RenderingServer::ARRAY_VERTEX].duplicate(true);
ERR_CONTINUE(vertices.size() != new_vertices.size());
for (int32_t l = 0; l < new_vertices.size(); l++) {
Vector3 *w = new_vertices.ptrw();
w[l] = vertices[l];
}
- array_copy[VisualServer::ARRAY_VERTEX] = new_vertices;
+ array_copy[RenderingServer::ARRAY_VERTEX] = new_vertices;
}
int32_t color_set = 0;
@@ -1242,13 +1242,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
Color color = Color(ai_color.r, ai_color.g, ai_color.b, ai_color.a);
colors.ptrw()[l] = color;
}
- PackedColorArray new_colors = array_copy[VisualServer::ARRAY_COLOR].duplicate(true);
+ PackedColorArray new_colors = array_copy[RenderingServer::ARRAY_COLOR].duplicate(true);
ERR_CONTINUE(colors.size() != new_colors.size());
for (int32_t l = 0; l < colors.size(); l++) {
Color *w = new_colors.ptrw();
w[l] = colors[l];
}
- array_copy[VisualServer::ARRAY_COLOR] = new_colors;
+ array_copy[RenderingServer::ARRAY_COLOR] = new_colors;
}
if (ai_mesh->mAnimMeshes[j]->HasNormals()) {
@@ -1259,13 +1259,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
Vector3 normal = Vector3(ai_normal.x, ai_normal.y, ai_normal.z);
normals.ptrw()[l] = normal;
}
- PackedVector3Array new_normals = array_copy[VisualServer::ARRAY_NORMAL].duplicate(true);
+ PackedVector3Array new_normals = array_copy[RenderingServer::ARRAY_NORMAL].duplicate(true);
ERR_CONTINUE(normals.size() != new_normals.size());
for (int l = 0; l < normals.size(); l++) {
Vector3 *w = new_normals.ptrw();
w[l] = normals[l];
}
- array_copy[VisualServer::ARRAY_NORMAL] = new_normals;
+ array_copy[RenderingServer::ARRAY_NORMAL] = new_normals;
}
if (ai_mesh->mAnimMeshes[j]->HasTangentsAndBitangents()) {
@@ -1275,7 +1275,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
for (size_t l = 0; l < num_vertices; l++) {
AssimpUtils::calc_tangent_from_mesh(ai_mesh, j, l, l, w);
}
- PackedFloat32Array new_tangents = array_copy[VisualServer::ARRAY_TANGENT].duplicate(true);
+ PackedFloat32Array new_tangents = array_copy[RenderingServer::ARRAY_TANGENT].duplicate(true);
ERR_CONTINUE(new_tangents.size() != tangents.size() * 4);
for (int32_t l = 0; l < tangents.size(); l++) {
new_tangents.ptrw()[l + 0] = tangents[l].r;
@@ -1283,7 +1283,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
new_tangents.ptrw()[l + 2] = tangents[l].b;
new_tangents.ptrw()[l + 3] = tangents[l].a;
}
- array_copy[VisualServer::ARRAY_TANGENT] = new_tangents;
+ array_copy[RenderingServer::ARRAY_TANGENT] = new_tangents;
}
morphs[j] = array_copy;
@@ -1299,7 +1299,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
/**
* Create a new mesh for the node supplied
*/
-MeshInstance *
+MeshInstance3D *
EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform) {
/* MESH NODE */
Ref<Mesh> mesh;
@@ -1325,7 +1325,7 @@ EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_
mesh_key += itos(surface_indices[i]);
}
- Skeleton *skeleton = NULL;
+ Skeleton3D *skeleton = NULL;
aiNode *armature = NULL;
if (!state.mesh_cache.has(mesh_key)) {
@@ -1333,7 +1333,7 @@ EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_
state.mesh_cache[mesh_key] = mesh;
}
- MeshInstance *mesh_node = memnew(MeshInstance);
+ MeshInstance3D *mesh_node = memnew(MeshInstance3D);
mesh = state.mesh_cache[mesh_key];
mesh_node->set_mesh(mesh);
@@ -1407,20 +1407,20 @@ EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_
* Create a light for the scene
* Automatically caches lights for lookup later
*/
-Spatial *EditorSceneImporterAssimp::create_light(
+Node3D *EditorSceneImporterAssimp::create_light(
ImportState &state,
const String &node_name,
Transform &look_at_transform) {
- Light *light = NULL;
+ Light3D *light = NULL;
aiLight *assimp_light = state.assimp_scene->mLights[state.light_cache[node_name]];
ERR_FAIL_COND_V(!assimp_light, NULL);
if (assimp_light->mType == aiLightSource_DIRECTIONAL) {
- light = memnew(DirectionalLight);
+ light = memnew(DirectionalLight3D);
} else if (assimp_light->mType == aiLightSource_POINT) {
- light = memnew(OmniLight);
+ light = memnew(OmniLight3D);
} else if (assimp_light->mType == aiLightSource_SPOT) {
- light = memnew(SpotLight);
+ light = memnew(SpotLight3D);
}
ERR_FAIL_COND_V(light == NULL, NULL);
@@ -1453,14 +1453,14 @@ Spatial *EditorSceneImporterAssimp::create_light(
/**
* Create camera for the scene
*/
-Spatial *EditorSceneImporterAssimp::create_camera(
+Node3D *EditorSceneImporterAssimp::create_camera(
ImportState &state,
const String &node_name,
Transform &look_at_transform) {
aiCamera *camera = state.assimp_scene->mCameras[state.camera_cache[node_name]];
ERR_FAIL_COND_V(!camera, NULL);
- Camera *camera_node = memnew(Camera);
+ Camera3D *camera_node = memnew(Camera3D);
ERR_FAIL_COND_V(!camera_node, NULL);
float near = camera->mClipPlaneNear;
if (Math::is_equal_approx(near, 0.0f)) {
diff --git a/modules/assimp/editor_scene_importer_assimp.h b/modules/assimp/editor_scene_importer_assimp.h
index 4cd50e7681..5059138b64 100644
--- a/modules/assimp/editor_scene_importer_assimp.h
+++ b/modules/assimp/editor_scene_importer_assimp.h
@@ -37,9 +37,9 @@
#include "core/vector.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/project_settings_editor.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/surface_tool.h"
@@ -90,29 +90,29 @@ private:
Ref<Mesh> _generate_mesh_from_surface_indices(ImportState &state, const Vector<int> &p_surface_indices,
const aiNode *assimp_node, Ref<Skin> &skin,
- Skeleton *&skeleton_assigned);
+ Skeleton3D *&skeleton_assigned);
// simple object creation functions
- Spatial *create_light(ImportState &state,
+ Node3D *create_light(ImportState &state,
const String &node_name,
Transform &look_at_transform);
- Spatial *create_camera(
+ Node3D *create_camera(
ImportState &state,
const String &node_name,
Transform &look_at_transform);
// non recursive - linear so must not use recursive arguments
- MeshInstance *create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform);
+ MeshInstance3D *create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform);
// recursive node generator
void _generate_node(ImportState &state, const aiNode *assimp_node);
void _insert_animation_track(ImportState &scene, const aiAnimation *assimp_anim, int track_id,
int anim_fps, Ref<Animation> animation, float ticks_per_second,
- Skeleton *skeleton, const NodePath &node_path,
+ Skeleton3D *skeleton, const NodePath &node_path,
const String &node_name, aiBone *track_bone);
void _import_animation(ImportState &state, int p_animation_index, int p_bake_fps);
Node *get_node_by_name(ImportState &state, String name);
aiBone *get_bone_from_stack(ImportState &state, aiString name);
- Spatial *_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps, const int32_t p_max_bone_weights);
+ Node3D *_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps, const int32_t p_max_bone_weights);
template <class T>
T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, AssetImportAnimation::Interpolation p_interp);
diff --git a/modules/assimp/import_state.h b/modules/assimp/import_state.h
index fbbbe23399..b16366b38c 100644
--- a/modules/assimp/import_state.h
+++ b/modules/assimp/import_state.h
@@ -36,9 +36,9 @@
#include "core/vector.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/project_settings_editor.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/surface_tool.h"
@@ -57,7 +57,7 @@ namespace AssimpImporter {
struct ImportState {
String path;
- Spatial *root;
+ Node3D *root;
const aiScene *assimp_scene;
uint32_t max_bone_weights;
@@ -74,15 +74,15 @@ struct ImportState {
// Generation 3 - determinisitic iteration
// to lower potential recursion errors
List<const aiNode *> nodes;
- Map<const aiNode *, Spatial *> flat_node_map;
+ Map<const aiNode *, Node3D *> flat_node_map;
AnimationPlayer *animation_player;
// Generation 3 - deterministic armatures
// list of armature nodes - flat and simple to parse
// assimp node, node in godot
List<aiNode *> armature_nodes;
- Map<const aiNode *, Skeleton *> armature_skeletons;
- Map<aiBone *, Skeleton *> skeleton_bone_map;
+ Map<const aiNode *, Skeleton3D *> armature_skeletons;
+ Map<aiBone *, Skeleton3D *> skeleton_bone_map;
// Generation 3 - deterministic bone handling
// bones from the stack are popped when found
// this means we can detect
@@ -103,8 +103,8 @@ struct RecursiveState {
RecursiveState() {} // do not construct :)
RecursiveState(
Transform &_node_transform,
- Skeleton *_skeleton,
- Spatial *_new_node,
+ Skeleton3D *_skeleton,
+ Node3D *_new_node,
String &_node_name,
aiNode *_assimp_node,
Node *_parent_node,
@@ -118,8 +118,8 @@ struct RecursiveState {
bone(_bone) {}
Transform node_transform;
- Skeleton *skeleton = NULL;
- Spatial *new_node = NULL;
+ Skeleton3D *skeleton = NULL;
+ Node3D *new_node = NULL;
String node_name;
aiNode *assimp_node = NULL;
Node *parent_node = NULL;
diff --git a/modules/assimp/register_types.h b/modules/assimp/register_types.h
index f363744c0a..f399a7acc6 100644
--- a/modules/assimp/register_types.h
+++ b/modules/assimp/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef ASSIMP_REGISTER_TYPES_H
+#define ASSIMP_REGISTER_TYPES_H
+
void register_assimp_types();
void unregister_assimp_types();
+
+#endif // ASSIMP_REGISTER_TYPES_H
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index 062b5b59f8..bf6bc1debd 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -31,7 +31,7 @@
#include "register_types.h"
#include "core/os/os.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#include "texture_basisu.h"
#ifdef TOOLS_ENABLED
@@ -164,27 +164,28 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
switch (*(uint32_t *)(ptr)) {
case BASIS_DECOMPRESS_RG: {
- if (VS::get_singleton()->has_os_feature("rgtc")) {
+ if (RS::get_singleton()->has_os_feature("rgtc")) {
format = basist::transcoder_texture_format::cTFBC5; // get this from renderer
imgfmt = Image::FORMAT_RGTC_RG;
- } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ } else if (RS::get_singleton()->has_os_feature("etc2")) {
//unfortunately, basis universal does not support
//
ERR_FAIL_V(image); //unimplemented here
//format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
//imgfmt = Image::FORMAT_RGTC_RG;
} else {
- //decompress
+ // FIXME: There wasn't anything here, but then imgformat is used uninitialized.
+ ERR_FAIL_V(image);
}
} break;
case BASIS_DECOMPRESS_RGB: {
- if (VS::get_singleton()->has_os_feature("bptc")) {
+ if (RS::get_singleton()->has_os_feature("bptc")) {
format = basist::transcoder_texture_format::cTFBC7_M6_OPAQUE_ONLY; // get this from renderer
imgfmt = Image::FORMAT_BPTC_RGBA;
- } else if (VS::get_singleton()->has_os_feature("s3tc")) {
+ } else if (RS::get_singleton()->has_os_feature("s3tc")) {
format = basist::transcoder_texture_format::cTFBC1; // get this from renderer
imgfmt = Image::FORMAT_DXT1;
- } else if (VS::get_singleton()->has_os_feature("etc")) {
+ } else if (RS::get_singleton()->has_os_feature("etc")) {
format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
imgfmt = Image::FORMAT_ETC;
@@ -195,13 +196,13 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
} break;
case BASIS_DECOMPRESS_RGBA: {
- if (VS::get_singleton()->has_os_feature("bptc")) {
+ if (RS::get_singleton()->has_os_feature("bptc")) {
format = basist::transcoder_texture_format::cTFBC7_M5; // get this from renderer
imgfmt = Image::FORMAT_BPTC_RGBA;
- } else if (VS::get_singleton()->has_os_feature("s3tc")) {
+ } else if (RS::get_singleton()->has_os_feature("s3tc")) {
format = basist::transcoder_texture_format::cTFBC3; // get this from renderer
imgfmt = Image::FORMAT_DXT5;
- } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ } else if (RS::get_singleton()->has_os_feature("etc2")) {
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
imgfmt = Image::FORMAT_ETC2_RGBA8;
} else {
@@ -211,10 +212,10 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
}
} break;
case BASIS_DECOMPRESS_RG_AS_RA: {
- if (VS::get_singleton()->has_os_feature("s3tc")) {
+ if (RS::get_singleton()->has_os_feature("s3tc")) {
format = basist::transcoder_texture_format::cTFBC3; // get this from renderer
imgfmt = Image::FORMAT_DXT5_RA_AS_RG;
- } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ } else if (RS::get_singleton()->has_os_feature("etc2")) {
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
imgfmt = Image::FORMAT_ETC2_RGBA8;
} else {
diff --git a/modules/basis_universal/register_types.h b/modules/basis_universal/register_types.h
index 977374fbfc..5053dc27ce 100644
--- a/modules/basis_universal/register_types.h
+++ b/modules/basis_universal/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef BASIS_UNIVERSAL_REGISTER_TYPES_H
+#define BASIS_UNIVERSAL_REGISTER_TYPES_H
+
void register_basis_universal_types();
void unregister_basis_universal_types();
+
+#endif // BASIS_UNIVERSAL_REGISTER_TYPES_H
diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp
index 12f3241c98..9c3cdac36c 100644
--- a/modules/basis_universal/texture_basisu.cpp
+++ b/modules/basis_universal/texture_basisu.cpp
@@ -72,7 +72,7 @@ bool TextureBasisU::has_alpha() const {
void TextureBasisU::set_flags(uint32_t p_flags) {
flags = p_flags;
- VisualServer::get_singleton()->texture_set_flags(texture, p_flags);
+ RenderingServer::get_singleton()->texture_set_flags(texture, p_flags);
};
uint32_t TextureBasisU::get_flags() const {
@@ -144,8 +144,8 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
img.instance();
img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
- VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags);
- VisualServer::get_singleton()->texture_set_data(texture, img);
+ RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags);
+ RenderingServer::get_singleton()->texture_set_data(texture, img);
};
Error TextureBasisU::import(const Ref<Image>& p_img) {
@@ -221,13 +221,13 @@ Vector<uint8_t> TextureBasisU::get_basisu_data() const {
TextureBasisU::TextureBasisU() {
flags = FLAGS_DEFAULT;
- texture = VisualServer::get_singleton()->texture_create();
+ texture = RenderingServer::get_singleton()->texture_create();
};
TextureBasisU::~TextureBasisU() {
- VisualServer::get_singleton()->free(texture);
+ RenderingServer::get_singleton()->free(texture);
};
#endif
diff --git a/modules/bmp/register_types.h b/modules/bmp/register_types.h
index 398716eaa1..e7561dc32d 100644
--- a/modules/bmp/register_types.h
+++ b/modules/bmp/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef BMP_REGISTER_TYPES_H
+#define BMP_REGISTER_TYPES_H
+
void register_bmp_types();
void unregister_bmp_types();
+
+#endif // BMP_REGISTER_TYPES_H
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index e8a5c1475a..4d727529ef 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -46,7 +46,7 @@
AreaBullet::AreaBullet() :
RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA),
monitorable(true),
- spOv_mode(PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED),
+ spOv_mode(PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED),
spOv_gravityPoint(false),
spOv_gravityPointDistanceScale(0),
spOv_gravityPointAttenuation(1),
@@ -86,11 +86,11 @@ void AreaBullet::dispatch_callbacks() {
switch (otherObj.state) {
case OVERLAP_STATE_ENTER:
otherObj.state = OVERLAP_STATE_INSIDE;
- call_event(otherObj.object, PhysicsServer::AREA_BODY_ADDED);
+ call_event(otherObj.object, PhysicsServer3D::AREA_BODY_ADDED);
otherObj.object->on_enter_area(this);
break;
case OVERLAP_STATE_EXIT:
- call_event(otherObj.object, PhysicsServer::AREA_BODY_REMOVED);
+ call_event(otherObj.object, PhysicsServer3D::AREA_BODY_REMOVED);
otherObj.object->on_exit_area(this);
overlappingObjects.remove(i); // Remove after callback
break;
@@ -101,7 +101,7 @@ void AreaBullet::dispatch_callbacks() {
}
}
-void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer::AreaBodyStatus p_status) {
+void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status) {
InOutEventCallback &event = eventsCallbacks[static_cast<int>(p_otherObject->getType())];
Object *areaGodoObject = ObjectDB::get_instance(event.event_callback_id);
@@ -130,7 +130,7 @@ void AreaBullet::scratch() {
void AreaBullet::clear_overlaps(bool p_notify) {
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
if (p_notify)
- call_event(overlappingObjects[i].object, PhysicsServer::AREA_BODY_REMOVED);
+ call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED);
overlappingObjects[i].object->on_exit_area(this);
}
overlappingObjects.clear();
@@ -140,7 +140,7 @@ void AreaBullet::remove_overlap(CollisionObjectBullet *p_object, bool p_notify)
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
if (overlappingObjects[i].object == p_object) {
if (p_notify)
- call_event(overlappingObjects[i].object, PhysicsServer::AREA_BODY_REMOVED);
+ call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED);
overlappingObjects[i].object->on_exit_area(this);
overlappingObjects.remove(i);
break;
@@ -218,30 +218,30 @@ void AreaBullet::put_overlap_as_inside(int p_index) {
}
}
-void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) {
+void AreaBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
set_spOv_gravityMag(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
set_spOv_gravityVec(p_value);
break;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
set_spOv_linearDump(p_value);
break;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
set_spOv_angularDump(p_value);
break;
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
set_spOv_priority(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
set_spOv_gravityPoint(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
set_spOv_gravityPointDistanceScale(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
set_spOv_gravityPointAttenuation(p_value);
break;
default:
@@ -249,23 +249,23 @@ void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &
}
}
-Variant AreaBullet::get_param(PhysicsServer::AreaParameter p_param) const {
+Variant AreaBullet::get_param(PhysicsServer3D::AreaParameter p_param) const {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
return spOv_gravityMag;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
return spOv_gravityVec;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
return spOv_linearDump;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
return spOv_angularDump;
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
return spOv_priority;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
return spOv_gravityPoint;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
return spOv_gravityPointDistanceScale;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return spOv_gravityPointAttenuation;
default:
WARN_PRINT("Area doesn't support this parameter in the Bullet backend: " + itos(p_param));
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index 18888c6725..56977d4451 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -33,7 +33,7 @@
#include "collision_object_bullet.h"
#include "core/vector.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include "space_bullet.h"
/**
@@ -88,7 +88,7 @@ private:
Vector<OverlappingObjectData> overlappingObjects;
bool monitorable;
- PhysicsServer::AreaSpaceOverrideMode spOv_mode;
+ PhysicsServer3D::AreaSpaceOverrideMode spOv_mode;
bool spOv_gravityPoint;
real_t spOv_gravityPointDistanceScale;
real_t spOv_gravityPointAttenuation;
@@ -114,8 +114,8 @@ public:
bool is_monitoring() const;
- _FORCE_INLINE_ void set_spOv_mode(PhysicsServer::AreaSpaceOverrideMode p_mode) { spOv_mode = p_mode; }
- _FORCE_INLINE_ PhysicsServer::AreaSpaceOverrideMode get_spOv_mode() { return spOv_mode; }
+ _FORCE_INLINE_ void set_spOv_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) { spOv_mode = p_mode; }
+ _FORCE_INLINE_ PhysicsServer3D::AreaSpaceOverrideMode get_spOv_mode() { return spOv_mode; }
_FORCE_INLINE_ void set_spOv_gravityPoint(bool p_isGP) { spOv_gravityPoint = p_isGP; }
_FORCE_INLINE_ bool is_spOv_gravityPoint() { return spOv_gravityPoint; }
@@ -146,7 +146,7 @@ public:
virtual void set_space(SpaceBullet *p_space);
virtual void dispatch_callbacks();
- void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer::AreaBodyStatus p_status);
+ void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status);
void set_on_state_change(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant());
void scratch();
@@ -162,8 +162,8 @@ public:
void put_overlap_as_exit(int p_index);
void put_overlap_as_inside(int p_index);
- void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer::AreaParameter p_param) const;
+ void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PhysicsServer3D::AreaParameter p_param) const;
void set_event_callback(Type p_callbackObjectType, ObjectID p_id, const StringName &p_method);
bool has_event_callback(Type p_callbackObjectType);
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index 89868babc6..5b3fe1bfac 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -74,18 +74,18 @@
body->get_space()->add_constraint(joint, joint->is_disabled_collisions_between_bodies());
// <--------------- Joint creation asserts
-void BulletPhysicsServer::_bind_methods() {
- //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer::DoTest);
+void BulletPhysicsServer3D::_bind_methods() {
+ //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer3D::DoTest);
}
-BulletPhysicsServer::BulletPhysicsServer() :
- PhysicsServer(),
+BulletPhysicsServer3D::BulletPhysicsServer3D() :
+ PhysicsServer3D(),
active(true),
active_spaces_count(0) {}
-BulletPhysicsServer::~BulletPhysicsServer() {}
+BulletPhysicsServer3D::~BulletPhysicsServer3D() {}
-RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
+RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) {
ShapeBullet *shape = NULL;
switch (p_shape) {
@@ -133,51 +133,51 @@ RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
CreateThenReturnRID(shape_owner, shape)
}
-void BulletPhysicsServer::shape_set_data(RID p_shape, const Variant &p_data) {
+void BulletPhysicsServer3D::shape_set_data(RID p_shape, const Variant &p_data) {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
}
-void BulletPhysicsServer::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
+void BulletPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
//WARN_PRINT("Bias not supported by Bullet physics engine");
}
-PhysicsServer::ShapeType BulletPhysicsServer::shape_get_type(RID p_shape) const {
+PhysicsServer3D::ShapeType BulletPhysicsServer3D::shape_get_type(RID p_shape) const {
ShapeBullet *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND_V(!shape, PhysicsServer::SHAPE_CUSTOM);
+ ERR_FAIL_COND_V(!shape, PhysicsServer3D::SHAPE_CUSTOM);
return shape->get_type();
}
-Variant BulletPhysicsServer::shape_get_data(RID p_shape) const {
+Variant BulletPhysicsServer3D::shape_get_data(RID p_shape) const {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
return shape->get_data();
}
-void BulletPhysicsServer::shape_set_margin(RID p_shape, real_t p_margin) {
+void BulletPhysicsServer3D::shape_set_margin(RID p_shape, real_t p_margin) {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_margin(p_margin);
}
-real_t BulletPhysicsServer::shape_get_margin(RID p_shape) const {
+real_t BulletPhysicsServer3D::shape_get_margin(RID p_shape) const {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0.0);
return shape->get_margin();
}
-real_t BulletPhysicsServer::shape_get_custom_solver_bias(RID p_shape) const {
+real_t BulletPhysicsServer3D::shape_get_custom_solver_bias(RID p_shape) const {
//WARN_PRINT("Bias not supported by Bullet physics engine");
return 0.;
}
-RID BulletPhysicsServer::space_create() {
+RID BulletPhysicsServer3D::space_create() {
SpaceBullet *space = bulletnew(SpaceBullet);
CreateThenReturnRID(space_owner, space);
}
-void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) {
+void BulletPhysicsServer3D::space_set_active(RID p_space, bool p_active) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -195,61 +195,61 @@ void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) {
}
}
-bool BulletPhysicsServer::space_is_active(RID p_space) const {
+bool BulletPhysicsServer3D::space_is_active(RID p_space) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
return -1 != active_spaces.find(space);
}
-void BulletPhysicsServer::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+void BulletPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
-real_t BulletPhysicsServer::space_get_param(RID p_space, SpaceParameter p_param) const {
+real_t BulletPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
-PhysicsDirectSpaceState *BulletPhysicsServer::space_get_direct_state(RID p_space) {
+PhysicsDirectSpaceState3D *BulletPhysicsServer3D::space_get_direct_state(RID p_space) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, NULL);
return space->get_direct_state();
}
-void BulletPhysicsServer::space_set_debug_contacts(RID p_space, int p_max_contacts) {
+void BulletPhysicsServer3D::space_set_debug_contacts(RID p_space, int p_max_contacts) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
-Vector<Vector3> BulletPhysicsServer::space_get_contacts(RID p_space) const {
+Vector<Vector3> BulletPhysicsServer3D::space_get_contacts(RID p_space) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector3>());
return space->get_debug_contacts();
}
-int BulletPhysicsServer::space_get_contact_count(RID p_space) const {
+int BulletPhysicsServer3D::space_get_contact_count(RID p_space) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
-RID BulletPhysicsServer::area_create() {
+RID BulletPhysicsServer3D::area_create() {
AreaBullet *area = bulletnew(AreaBullet);
area->set_collision_layer(1);
area->set_collision_mask(1);
CreateThenReturnRID(area_owner, area)
}
-void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) {
+void BulletPhysicsServer3D::area_set_space(RID p_area, RID p_space) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
SpaceBullet *space = NULL;
@@ -260,26 +260,26 @@ void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) {
area->set_space(space);
}
-RID BulletPhysicsServer::area_get_space(RID p_area) const {
+RID BulletPhysicsServer3D::area_get_space(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
return area->get_space()->get_self();
}
-void BulletPhysicsServer::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
+void BulletPhysicsServer3D::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_spOv_mode(p_mode);
}
-PhysicsServer::AreaSpaceOverrideMode BulletPhysicsServer::area_get_space_override_mode(RID p_area) const {
+PhysicsServer3D::AreaSpaceOverrideMode BulletPhysicsServer3D::area_get_space_override_mode(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED);
+ ERR_FAIL_COND_V(!area, PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED);
return area->get_spOv_mode();
}
-void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
+void BulletPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -289,7 +289,7 @@ void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transfor
area->add_shape(shape, p_transform, p_disabled);
}
-void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
+void BulletPhysicsServer3D::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -299,41 +299,41 @@ void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shap
area->set_shape(p_shape_idx, shape);
}
-void BulletPhysicsServer::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
+void BulletPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
-int BulletPhysicsServer::area_get_shape_count(RID p_area) const {
+int BulletPhysicsServer3D::area_get_shape_count(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, 0);
return area->get_shape_count();
}
-RID BulletPhysicsServer::area_get_shape(RID p_area, int p_shape_idx) const {
+RID BulletPhysicsServer3D::area_get_shape(RID p_area, int p_shape_idx) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
return area->get_shape(p_shape_idx)->get_self();
}
-Transform BulletPhysicsServer::area_get_shape_transform(RID p_area, int p_shape_idx) const {
+Transform BulletPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
return area->get_shape_transform(p_shape_idx);
}
-void BulletPhysicsServer::area_remove_shape(RID p_area, int p_shape_idx) {
+void BulletPhysicsServer3D::area_remove_shape(RID p_area, int p_shape_idx) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
return area->remove_shape_full(p_shape_idx);
}
-void BulletPhysicsServer::area_clear_shapes(RID p_area) {
+void BulletPhysicsServer3D::area_clear_shapes(RID p_area) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -341,14 +341,14 @@ void BulletPhysicsServer::area_clear_shapes(RID p_area) {
area->remove_shape_full(0);
}
-void BulletPhysicsServer::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
+void BulletPhysicsServer3D::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_disabled(p_shape_idx, p_disabled);
}
-void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
+void BulletPhysicsServer3D::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
return;
}
@@ -357,7 +357,7 @@ void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_
area->set_instance_id(p_id);
}
-ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const {
+ObjectID BulletPhysicsServer3D::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
return ObjectID();
}
@@ -366,7 +366,7 @@ ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const {
return area->get_instance_id();
}
-void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+void BulletPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
SpaceBullet *space = space_owner.getornull(p_area);
if (space) {
@@ -381,7 +381,7 @@ void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, cons
}
}
-Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) const {
+Variant BulletPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
SpaceBullet *space = space_owner.getornull(p_area);
return space->get_param(p_param);
@@ -393,64 +393,64 @@ Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) c
}
}
-void BulletPhysicsServer::area_set_transform(RID p_area, const Transform &p_transform) {
+void BulletPhysicsServer3D::area_set_transform(RID p_area, const Transform &p_transform) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
}
-Transform BulletPhysicsServer::area_get_transform(RID p_area) const {
+Transform BulletPhysicsServer3D::area_get_transform(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
return area->get_transform();
}
-void BulletPhysicsServer::area_set_collision_mask(RID p_area, uint32_t p_mask) {
+void BulletPhysicsServer3D::area_set_collision_mask(RID p_area, uint32_t p_mask) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
-void BulletPhysicsServer::area_set_collision_layer(RID p_area, uint32_t p_layer) {
+void BulletPhysicsServer3D::area_set_collision_layer(RID p_area, uint32_t p_layer) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
-void BulletPhysicsServer::area_set_monitorable(RID p_area, bool p_monitorable) {
+void BulletPhysicsServer3D::area_set_monitorable(RID p_area, bool p_monitorable) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_monitorable(p_monitorable);
}
-void BulletPhysicsServer::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+void BulletPhysicsServer3D::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_event_callback(CollisionObjectBullet::TYPE_RIGID_BODY, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
-void BulletPhysicsServer::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+void BulletPhysicsServer3D::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
-void BulletPhysicsServer::area_set_ray_pickable(RID p_area, bool p_enable) {
+void BulletPhysicsServer3D::area_set_ray_pickable(RID p_area, bool p_enable) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_ray_pickable(p_enable);
}
-bool BulletPhysicsServer::area_is_ray_pickable(RID p_area) const {
+bool BulletPhysicsServer3D::area_is_ray_pickable(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, false);
return area->is_ray_pickable();
}
-RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) {
+RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) {
RigidBodyBullet *body = bulletnew(RigidBodyBullet);
body->set_mode(p_mode);
body->set_collision_layer(1);
@@ -460,7 +460,7 @@ RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) {
CreateThenReturnRID(rigid_body_owner, body);
}
-void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) {
+void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
SpaceBullet *space = NULL;
@@ -476,7 +476,7 @@ void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) {
body->set_space(space);
}
-RID BulletPhysicsServer::body_get_space(RID p_body) const {
+RID BulletPhysicsServer3D::body_get_space(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -486,19 +486,19 @@ RID BulletPhysicsServer::body_get_space(RID p_body) const {
return space->get_self();
}
-void BulletPhysicsServer::body_set_mode(RID p_body, PhysicsServer::BodyMode p_mode) {
+void BulletPhysicsServer3D::body_set_mode(RID p_body, PhysicsServer3D::BodyMode p_mode) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_mode(p_mode);
}
-PhysicsServer::BodyMode BulletPhysicsServer::body_get_mode(RID p_body) const {
+PhysicsServer3D::BodyMode BulletPhysicsServer3D::body_get_mode(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
}
-void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
+void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -509,7 +509,7 @@ void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transfor
body->add_shape(shape, p_transform, p_disabled);
}
-void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
+void BulletPhysicsServer3D::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -519,20 +519,20 @@ void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shap
body->set_shape(p_shape_idx, shape);
}
-void BulletPhysicsServer::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
+void BulletPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
-int BulletPhysicsServer::body_get_shape_count(RID p_body) const {
+int BulletPhysicsServer3D::body_get_shape_count(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_shape_count();
}
-RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const {
+RID BulletPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -542,113 +542,113 @@ RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const {
return shape->get_self();
}
-Transform BulletPhysicsServer::body_get_shape_transform(RID p_body, int p_shape_idx) const {
+Transform BulletPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform());
return body->get_shape_transform(p_shape_idx);
}
-void BulletPhysicsServer::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
+void BulletPhysicsServer3D::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_disabled(p_shape_idx, p_disabled);
}
-void BulletPhysicsServer::body_remove_shape(RID p_body, int p_shape_idx) {
+void BulletPhysicsServer3D::body_remove_shape(RID p_body, int p_shape_idx) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_shape_full(p_shape_idx);
}
-void BulletPhysicsServer::body_clear_shapes(RID p_body) {
+void BulletPhysicsServer3D::body_clear_shapes(RID p_body) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_all_shapes();
}
-void BulletPhysicsServer::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
+void BulletPhysicsServer3D::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
CollisionObjectBullet *body = get_collisin_object(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
}
-ObjectID BulletPhysicsServer::body_get_object_instance_id(RID p_body) const {
+ObjectID BulletPhysicsServer3D::body_get_object_instance_id(RID p_body) const {
CollisionObjectBullet *body = get_collisin_object(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
}
-void BulletPhysicsServer::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
+void BulletPhysicsServer3D::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection(p_enable);
}
-bool BulletPhysicsServer::body_is_continuous_collision_detection_enabled(RID p_body) const {
+bool BulletPhysicsServer3D::body_is_continuous_collision_detection_enabled(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_continuous_collision_detection_enabled();
}
-void BulletPhysicsServer::body_set_collision_layer(RID p_body, uint32_t p_layer) {
+void BulletPhysicsServer3D::body_set_collision_layer(RID p_body, uint32_t p_layer) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
-uint32_t BulletPhysicsServer::body_get_collision_layer(RID p_body) const {
+uint32_t BulletPhysicsServer3D::body_get_collision_layer(RID p_body) const {
const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
-void BulletPhysicsServer::body_set_collision_mask(RID p_body, uint32_t p_mask) {
+void BulletPhysicsServer3D::body_set_collision_mask(RID p_body, uint32_t p_mask) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
-uint32_t BulletPhysicsServer::body_get_collision_mask(RID p_body) const {
+uint32_t BulletPhysicsServer3D::body_get_collision_mask(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
-void BulletPhysicsServer::body_set_user_flags(RID p_body, uint32_t p_flags) {
+void BulletPhysicsServer3D::body_set_user_flags(RID p_body, uint32_t p_flags) {
// This function si not currently supported
}
-uint32_t BulletPhysicsServer::body_get_user_flags(RID p_body) const {
+uint32_t BulletPhysicsServer3D::body_get_user_flags(RID p_body) const {
// This function si not currently supported
return 0;
}
-void BulletPhysicsServer::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
+void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
}
-float BulletPhysicsServer::body_get_param(RID p_body, BodyParameter p_param) const {
+float BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
}
-void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
+void BulletPhysicsServer3D::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -658,7 +658,7 @@ void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_ma
}
}
-real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const {
+real_t BulletPhysicsServer3D::body_get_kinematic_safe_margin(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -670,90 +670,90 @@ real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const {
return 0;
}
-void BulletPhysicsServer::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void BulletPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
}
-Variant BulletPhysicsServer::body_get_state(RID p_body, BodyState p_state) const {
+Variant BulletPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
}
-void BulletPhysicsServer::body_set_applied_force(RID p_body, const Vector3 &p_force) {
+void BulletPhysicsServer3D::body_set_applied_force(RID p_body, const Vector3 &p_force) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
}
-Vector3 BulletPhysicsServer::body_get_applied_force(RID p_body) const {
+Vector3 BulletPhysicsServer3D::body_get_applied_force(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_force();
}
-void BulletPhysicsServer::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
+void BulletPhysicsServer3D::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
}
-Vector3 BulletPhysicsServer::body_get_applied_torque(RID p_body) const {
+Vector3 BulletPhysicsServer3D::body_get_applied_torque(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_torque();
}
-void BulletPhysicsServer::body_add_central_force(RID p_body, const Vector3 &p_force) {
+void BulletPhysicsServer3D::body_add_central_force(RID p_body, const Vector3 &p_force) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_force(p_force);
}
-void BulletPhysicsServer::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
+void BulletPhysicsServer3D::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_force(p_force, p_pos);
}
-void BulletPhysicsServer::body_add_torque(RID p_body, const Vector3 &p_torque) {
+void BulletPhysicsServer3D::body_add_torque(RID p_body, const Vector3 &p_torque) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_torque(p_torque);
}
-void BulletPhysicsServer::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
+void BulletPhysicsServer3D::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
}
-void BulletPhysicsServer::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
+void BulletPhysicsServer3D::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_impulse(p_pos, p_impulse);
}
-void BulletPhysicsServer::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
+void BulletPhysicsServer3D::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_torque_impulse(p_impulse);
}
-void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
+void BulletPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -764,19 +764,19 @@ void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_ax
body->set_linear_velocity(v);
}
-void BulletPhysicsServer::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
+void BulletPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_axis, p_lock);
}
-bool BulletPhysicsServer::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
+bool BulletPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->is_axis_locked(p_axis);
}
-void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::body_add_collision_exception(RID p_body, RID p_body_b) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -786,7 +786,7 @@ void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b)
body->add_collision_exception(other_body);
}
-void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_body_b) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -796,7 +796,7 @@ void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body
body->remove_collision_exception(other_body);
}
-void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
+void BulletPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -804,68 +804,68 @@ void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p
}
}
-void BulletPhysicsServer::body_set_max_contacts_reported(RID p_body, int p_contacts) {
+void BulletPhysicsServer3D::body_set_max_contacts_reported(RID p_body, int p_contacts) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_collisions_detection(p_contacts);
}
-int BulletPhysicsServer::body_get_max_contacts_reported(RID p_body) const {
+int BulletPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_max_collisions_detection();
}
-void BulletPhysicsServer::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) {
+void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) {
// Not supported by bullet and even Godot
}
-float BulletPhysicsServer::body_get_contacts_reported_depth_threshold(RID p_body) const {
+float BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const {
// Not supported by bullet and even Godot
return 0.;
}
-void BulletPhysicsServer::body_set_omit_force_integration(RID p_body, bool p_omit) {
+void BulletPhysicsServer3D::body_set_omit_force_integration(RID p_body, bool p_omit) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_omit_forces_integration(p_omit);
}
-bool BulletPhysicsServer::body_is_omitting_force_integration(RID p_body) const {
+bool BulletPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_forces_integration();
}
-void BulletPhysicsServer::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
+void BulletPhysicsServer3D::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
-void BulletPhysicsServer::body_set_ray_pickable(RID p_body, bool p_enable) {
+void BulletPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
-bool BulletPhysicsServer::body_is_ray_pickable(RID p_body) const {
+bool BulletPhysicsServer3D::body_is_ray_pickable(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
-PhysicsDirectBodyState *BulletPhysicsServer::body_get_direct_state(RID p_body) {
+PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_body) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, NULL);
return BulletPhysicsDirectBodyState::get_singleton(body);
}
-bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -873,7 +873,7 @@ bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from,
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes);
}
-int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
+int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
ERR_FAIL_COND_V(!body->get_space(), 0);
@@ -881,7 +881,7 @@ int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p
return body->get_space()->test_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
}
-RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) {
+RID BulletPhysicsServer3D::soft_body_create(bool p_init_sleeping) {
SoftBodyBullet *body = bulletnew(SoftBodyBullet);
body->set_collision_layer(1);
body->set_collision_mask(1);
@@ -890,14 +890,14 @@ RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) {
CreateThenReturnRID(soft_body_owner, body);
}
-void BulletPhysicsServer::soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) {
+void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- body->update_visual_server(p_visual_server_handler);
+ body->update_rendering_server(p_rendering_server_handler);
}
-void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) {
+void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
SpaceBullet *space = NULL;
@@ -913,7 +913,7 @@ void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) {
body->set_space(space);
}
-RID BulletPhysicsServer::soft_body_get_space(RID p_body) const {
+RID BulletPhysicsServer3D::soft_body_get_space(RID p_body) const {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -923,42 +923,42 @@ RID BulletPhysicsServer::soft_body_get_space(RID p_body) const {
return space->get_self();
}
-void BulletPhysicsServer::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
+void BulletPhysicsServer3D::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_soft_mesh(p_mesh);
}
-void BulletPhysicsServer::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
+void BulletPhysicsServer3D::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
-uint32_t BulletPhysicsServer::soft_body_get_collision_layer(RID p_body) const {
+uint32_t BulletPhysicsServer3D::soft_body_get_collision_layer(RID p_body) const {
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
-void BulletPhysicsServer::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
+void BulletPhysicsServer3D::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
-uint32_t BulletPhysicsServer::soft_body_get_collision_mask(RID p_body) const {
+uint32_t BulletPhysicsServer3D::soft_body_get_collision_mask(RID p_body) const {
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
-void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -971,7 +971,7 @@ void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_bo
body->add_collision_exception(other_body);
}
-void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -984,7 +984,7 @@ void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p
body->remove_collision_exception(other_body);
}
-void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
+void BulletPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -992,25 +992,25 @@ void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RI
}
}
-void BulletPhysicsServer::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void BulletPhysicsServer3D::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
// FIXME: Must be implemented.
WARN_PRINT("soft_body_state is not implemented yet in Bullet backend.");
}
-Variant BulletPhysicsServer::soft_body_get_state(RID p_body, BodyState p_state) const {
+Variant BulletPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state) const {
// FIXME: Must be implemented.
WARN_PRINT("soft_body_state is not implemented yet in Bullet backend.");
return Variant();
}
-void BulletPhysicsServer::soft_body_set_transform(RID p_body, const Transform &p_transform) {
+void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform &p_transform) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_soft_transform(p_transform);
}
-Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int vertex_index) const {
+Vector3 BulletPhysicsServer3D::soft_body_get_vertex_position(RID p_body, int vertex_index) const {
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
Vector3 pos;
ERR_FAIL_COND_V(!body, pos);
@@ -1019,133 +1019,133 @@ Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int verte
return pos;
}
-void BulletPhysicsServer::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
+void BulletPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
-bool BulletPhysicsServer::soft_body_is_ray_pickable(RID p_body) const {
+bool BulletPhysicsServer3D::soft_body_is_ray_pickable(RID p_body) const {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
-void BulletPhysicsServer::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
+void BulletPhysicsServer3D::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_simulation_precision(p_simulation_precision);
}
-int BulletPhysicsServer::soft_body_get_simulation_precision(RID p_body) {
+int BulletPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_simulation_precision();
}
-void BulletPhysicsServer::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
+void BulletPhysicsServer3D::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_total_mass(p_total_mass);
}
-real_t BulletPhysicsServer::soft_body_get_total_mass(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_total_mass(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_total_mass();
}
-void BulletPhysicsServer::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
+void BulletPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_linear_stiffness(p_stiffness);
}
-real_t BulletPhysicsServer::soft_body_get_linear_stiffness(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_linear_stiffness();
}
-void BulletPhysicsServer::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) {
+void BulletPhysicsServer3D::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_areaAngular_stiffness(p_stiffness);
}
-real_t BulletPhysicsServer::soft_body_get_areaAngular_stiffness(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_areaAngular_stiffness(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_areaAngular_stiffness();
}
-void BulletPhysicsServer::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {
+void BulletPhysicsServer3D::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_volume_stiffness(p_stiffness);
}
-real_t BulletPhysicsServer::soft_body_get_volume_stiffness(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_volume_stiffness(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_volume_stiffness();
}
-void BulletPhysicsServer::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_pressure_coefficient(p_pressure_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_pressure_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pressure_coefficient();
}
-void BulletPhysicsServer::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
return body->set_pose_matching_coefficient(p_pose_matching_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_pose_matching_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_pose_matching_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pose_matching_coefficient();
}
-void BulletPhysicsServer::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_damping_coefficient(p_damping_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_damping_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_damping_coefficient();
}
-void BulletPhysicsServer::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_drag_coefficient(p_drag_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_drag_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_drag_coefficient();
}
-void BulletPhysicsServer::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
+void BulletPhysicsServer3D::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_node_position(p_point_index, p_global_position);
}
-Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int p_point_index) {
+Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.));
Vector3 pos;
@@ -1153,7 +1153,7 @@ Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int
return pos;
}
-Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_index) const {
+Vector3 BulletPhysicsServer3D::soft_body_get_point_offset(RID p_body, int p_point_index) const {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
Vector3 res;
@@ -1161,54 +1161,54 @@ Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_
return res;
}
-void BulletPhysicsServer::soft_body_remove_all_pinned_points(RID p_body) {
+void BulletPhysicsServer3D::soft_body_remove_all_pinned_points(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->reset_all_node_mass();
}
-void BulletPhysicsServer::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
+void BulletPhysicsServer3D::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_node_mass(p_point_index, p_pin ? 0 : 1);
}
-bool BulletPhysicsServer::soft_body_is_point_pinned(RID p_body, int p_point_index) {
+bool BulletPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_node_mass(p_point_index);
}
-PhysicsServer::JointType BulletPhysicsServer::joint_get_type(RID p_joint) const {
+PhysicsServer3D::JointType BulletPhysicsServer3D::joint_get_type(RID p_joint) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
return joint->get_type();
}
-void BulletPhysicsServer::joint_set_solver_priority(RID p_joint, int p_priority) {
+void BulletPhysicsServer3D::joint_set_solver_priority(RID p_joint, int p_priority) {
// Joint priority not supported by bullet
}
-int BulletPhysicsServer::joint_get_solver_priority(RID p_joint) const {
+int BulletPhysicsServer3D::joint_get_solver_priority(RID p_joint) const {
// Joint priority not supported by bullet
return 0;
}
-void BulletPhysicsServer::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
+void BulletPhysicsServer3D::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
}
-bool BulletPhysicsServer::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
+bool BulletPhysicsServer3D::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
JointBullet *joint(joint_owner.getornull(p_joint));
ERR_FAIL_COND_V(!joint, false);
return joint->is_disabled_collisions_between_bodies();
}
-RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
+RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1229,7 +1229,7 @@ RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
@@ -1237,7 +1237,7 @@ void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param
pin_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+float BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
@@ -1245,7 +1245,7 @@ float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_para
return pin_joint->get_param(p_param);
}
-void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
+void BulletPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
@@ -1253,7 +1253,7 @@ void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A)
pin_joint->setPivotInA(p_A);
}
-Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const {
+Vector3 BulletPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
@@ -1261,7 +1261,7 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const {
return pin_joint->getPivotInA();
}
-void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
+void BulletPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
@@ -1269,7 +1269,7 @@ void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B)
pin_joint->setPivotInB(p_B);
}
-Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const {
+Vector3 BulletPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
@@ -1277,7 +1277,7 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const {
return pin_joint->getPivotInB();
}
-RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) {
+RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
@@ -1297,7 +1297,7 @@ RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hin
CreateThenReturnRID(joint_owner, joint);
}
-RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
+RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
@@ -1317,7 +1317,7 @@ RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
@@ -1325,7 +1325,7 @@ void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_p
hinge_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
+float BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
@@ -1333,7 +1333,7 @@ float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_
return hinge_joint->get_param(p_param);
}
-void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
+void BulletPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
@@ -1341,7 +1341,7 @@ void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_fla
hinge_joint->set_flag(p_flag, p_value);
}
-bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
+bool BulletPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
@@ -1349,7 +1349,7 @@ bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_fla
return hinge_joint->get_flag(p_flag);
}
-RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
@@ -1369,7 +1369,7 @@ RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_lo
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
@@ -1377,7 +1377,7 @@ void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p
slider_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
+float BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0);
@@ -1385,7 +1385,7 @@ float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam
return slider_joint->get_param(p_param);
}
-RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
@@ -1403,7 +1403,7 @@ RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
@@ -1411,7 +1411,7 @@ void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJoint
coneTwist_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
+float BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0.);
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.);
@@ -1419,7 +1419,7 @@ float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJoin
return coneTwist_joint->get_param(p_param);
}
-RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
@@ -1439,7 +1439,7 @@ RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) {
+void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
@@ -1447,7 +1447,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axi
generic_6dof_joint->set_param(p_axis, p_param, p_value);
}
-float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
+float BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
@@ -1455,7 +1455,7 @@ float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Ax
return generic_6dof_joint->get_param(p_axis, p_param);
}
-void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
+void BulletPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
@@ -1463,7 +1463,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis
generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
}
-bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
+bool BulletPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
@@ -1471,7 +1471,7 @@ bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis
return generic_6dof_joint->get_flag(p_axis, p_flag);
}
-void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_precision) {
+void BulletPhysicsServer3D::generic_6dof_joint_set_precision(RID p_joint, int p_precision) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
@@ -1479,7 +1479,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_pr
generic_6dof_joint->set_precision(p_precision);
}
-int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
+int BulletPhysicsServer3D::generic_6dof_joint_get_precision(RID p_joint) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
@@ -1487,7 +1487,7 @@ int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
return generic_6dof_joint->get_precision();
}
-void BulletPhysicsServer::free(RID p_rid) {
+void BulletPhysicsServer3D::free(RID p_rid) {
if (shape_owner.owns(p_rid)) {
ShapeBullet *shape = shape_owner.getornull(p_rid);
@@ -1552,11 +1552,11 @@ void BulletPhysicsServer::free(RID p_rid) {
}
}
-void BulletPhysicsServer::init() {
+void BulletPhysicsServer3D::init() {
BulletPhysicsDirectBodyState::initSingleton();
}
-void BulletPhysicsServer::step(float p_deltaTime) {
+void BulletPhysicsServer3D::step(float p_deltaTime) {
if (!active)
return;
@@ -1568,21 +1568,21 @@ void BulletPhysicsServer::step(float p_deltaTime) {
}
}
-void BulletPhysicsServer::sync() {
+void BulletPhysicsServer3D::sync() {
}
-void BulletPhysicsServer::flush_queries() {
+void BulletPhysicsServer3D::flush_queries() {
}
-void BulletPhysicsServer::finish() {
+void BulletPhysicsServer3D::finish() {
BulletPhysicsDirectBodyState::destroySingleton();
}
-int BulletPhysicsServer::get_process_info(ProcessInfo p_info) {
+int BulletPhysicsServer3D::get_process_info(ProcessInfo p_info) {
return 0;
}
-CollisionObjectBullet *BulletPhysicsServer::get_collisin_object(RID p_object) const {
+CollisionObjectBullet *BulletPhysicsServer3D::get_collisin_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
return rigid_body_owner.getornull(p_object);
}
@@ -1595,7 +1595,7 @@ CollisionObjectBullet *BulletPhysicsServer::get_collisin_object(RID p_object) co
return NULL;
}
-RigidCollisionObjectBullet *BulletPhysicsServer::get_rigid_collisin_object(RID p_object) const {
+RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collisin_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
return rigid_body_owner.getornull(p_object);
}
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 6ea9a7a974..1269dac78b 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -36,7 +36,7 @@
#include "core/rid_owner.h"
#include "joint_bullet.h"
#include "rigid_body_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include "shape_bullet.h"
#include "soft_body_bullet.h"
#include "space_bullet.h"
@@ -44,8 +44,8 @@
@author AndreaCatania
*/
-class BulletPhysicsServer : public PhysicsServer {
- GDCLASS(BulletPhysicsServer, PhysicsServer);
+class BulletPhysicsServer3D : public PhysicsServer3D {
+ GDCLASS(BulletPhysicsServer3D, PhysicsServer3D);
friend class BulletPhysicsDirectSpaceState;
@@ -64,8 +64,8 @@ protected:
static void _bind_methods();
public:
- BulletPhysicsServer();
- ~BulletPhysicsServer();
+ BulletPhysicsServer3D();
+ ~BulletPhysicsServer3D();
_FORCE_INLINE_ RID_PtrOwner<SpaceBullet> *get_space_owner() {
return &space_owner;
@@ -111,7 +111,7 @@ public:
/// Not supported
virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const;
- virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space);
+ virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space);
virtual void space_set_debug_contacts(RID p_space, int p_max_contacts);
virtual Vector<Vector3> space_get_contacts(RID p_space) const;
@@ -252,7 +252,7 @@ public:
virtual bool body_is_ray_pickable(RID p_body) const;
// this function only works on physics process, errors and returns null otherwise
- virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body);
+ virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body);
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true);
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001);
@@ -261,7 +261,7 @@ public:
virtual RID soft_body_create(bool p_init_sleeping = false);
- virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler);
+ virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler);
virtual void soft_body_set_space(RID p_body, RID p_space);
virtual RID soft_body_get_space(RID p_body) const;
@@ -387,7 +387,7 @@ public:
}
static bool singleton_isActive() {
- return static_cast<BulletPhysicsServer *>(get_singleton())->active;
+ return static_cast<BulletPhysicsServer3D *>(get_singleton())->active;
}
bool isActive() {
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 5b7e7281e4..0ce57811d7 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -60,7 +60,7 @@ void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_tra
}
btTransform CollisionObjectBullet::ShapeWrapper::get_adjusted_transform() const {
- if (shape->get_type() == PhysicsServer::SHAPE_HEIGHTMAP) {
+ if (shape->get_type() == PhysicsServer3D::SHAPE_HEIGHTMAP) {
const HeightMapShapeBullet *hm_shape = (const HeightMapShapeBullet *)shape; // should be safe to cast now
btTransform adjusted_transform;
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index 23eb39fe7e..aac51034b8 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -64,43 +64,43 @@ ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet
setup(coneConstraint);
}
-void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) {
+void ConeTwistJointBullet::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN:
coneConstraint->setLimit(5, p_value);
coneConstraint->setLimit(4, p_value);
break;
- case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN:
coneConstraint->setLimit(3, p_value);
break;
- case PhysicsServer::CONE_TWIST_JOINT_BIAS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_BIAS:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), p_value, coneConstraint->getRelaxationFactor());
break;
- case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), p_value, coneConstraint->getBiasFactor(), coneConstraint->getRelaxationFactor());
break;
- case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
+ case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), coneConstraint->getBiasFactor(), p_value);
break;
- case PhysicsServer::CONE_TWIST_MAX:
+ case PhysicsServer3D::CONE_TWIST_MAX:
// Internal size value, nothing to do.
break;
}
}
-real_t ConeTwistJointBullet::get_param(PhysicsServer::ConeTwistJointParam p_param) const {
+real_t ConeTwistJointBullet::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN:
return coneConstraint->getSwingSpan1();
- case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN:
return coneConstraint->getTwistSpan();
- case PhysicsServer::CONE_TWIST_JOINT_BIAS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_BIAS:
return coneConstraint->getBiasFactor();
- case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS:
return coneConstraint->getLimitSoftness();
- case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
+ case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION:
return coneConstraint->getRelaxationFactor();
- case PhysicsServer::CONE_TWIST_MAX:
+ case PhysicsServer3D::CONE_TWIST_MAX:
// Internal size value, nothing to do.
return 0;
}
diff --git a/modules/bullet/cone_twist_joint_bullet.h b/modules/bullet/cone_twist_joint_bullet.h
index 134706f8bb..ed4baa9d1b 100644
--- a/modules/bullet/cone_twist_joint_bullet.h
+++ b/modules/bullet/cone_twist_joint_bullet.h
@@ -45,9 +45,9 @@ class ConeTwistJointBullet : public JointBullet {
public:
ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; }
- void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const;
+ void set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::ConeTwistJointParam p_param) const;
};
#endif
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 45ab3d3bb2..a6a01ebaa8 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -118,62 +118,62 @@ void Generic6DOFJointBullet::set_angular_upper_limit(const Vector3 &angularUpper
sixDOFConstraint->setAngularUpperLimit(btVec);
}
-void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
+void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
ERR_FAIL_INDEX(p_axis, 3);
switch (p_param) {
- case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
limits_lower[0][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
limits_upper[0][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
limits_lower[1][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
limits_upper[1][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_MAX:
+ case PhysicsServer3D::G6DOF_JOINT_MAX:
// Internal size value, nothing to do.
break;
default:
@@ -182,42 +182,42 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO
}
}
-real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const {
+real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0.);
switch (p_param) {
- case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
return limits_lower[0][p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
return limits_upper[0][p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
return sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
return sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
return sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
return sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
return sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
return limits_lower[1][p_axis];
- case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
return limits_upper[1][p_axis];
- case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint;
- case PhysicsServer::G6DOF_JOINT_MAX:
+ case PhysicsServer3D::G6DOF_JOINT_MAX:
// Internal size value, nothing to do.
return 0;
default:
@@ -226,45 +226,45 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6
}
}
-void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value) {
+void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_axis, 3);
flags[p_axis][p_flag] = p_value;
switch (p_flag) {
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT:
if (flags[p_axis][p_flag]) {
sixDOFConstraint->setLimit(p_axis, limits_lower[0][p_axis], limits_upper[0][p_axis]);
} else {
sixDOFConstraint->setLimit(p_axis, 0, -1); // Free
}
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT:
if (flags[p_axis][p_flag]) {
sixDOFConstraint->setLimit(p_axis + 3, limits_lower[1][p_axis], limits_upper[1][p_axis]);
} else {
sixDOFConstraint->setLimit(p_axis + 3, 0, -1); // Free
}
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
sixDOFConstraint->getTranslationalLimitMotor()->m_enableSpring[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = flags[p_axis][p_flag];
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR:
sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = flags[p_axis][p_flag];
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_MAX:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX:
// Internal size value, nothing to do.
break;
}
}
-bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const {
+bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, false);
return flags[p_axis][p_flag];
}
diff --git a/modules/bullet/generic_6dof_joint_bullet.h b/modules/bullet/generic_6dof_joint_bullet.h
index 75c8005811..316708bb11 100644
--- a/modules/bullet/generic_6dof_joint_bullet.h
+++ b/modules/bullet/generic_6dof_joint_bullet.h
@@ -45,12 +45,12 @@ class Generic6DOFJointBullet : public JointBullet {
// First is linear second is angular
Vector3 limits_lower[2];
Vector3 limits_upper[2];
- bool flags[3][PhysicsServer::G6DOF_JOINT_FLAG_MAX];
+ bool flags[3][PhysicsServer3D::G6DOF_JOINT_FLAG_MAX];
public:
Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; }
Transform getFrameOffsetA() const;
Transform getFrameOffsetB() const;
@@ -63,11 +63,11 @@ public:
void set_angular_lower_limit(const Vector3 &angularLower);
void set_angular_upper_limit(const Vector3 &angularUpper);
- void set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value);
- real_t get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const;
+ void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value);
+ real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const;
- void set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value);
- bool get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const;
+ void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value);
+ bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const;
void set_precision(int p_precision);
int get_precision() const;
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index 20467e3ef3..ad054e3027 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -107,7 +107,7 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(convexResult.m_hitCollisionObject->getUserPointer());
- PhysicsDirectSpaceState::ShapeResult &result = m_results[count];
+ PhysicsDirectSpaceState3D::ShapeResult &result = m_results[count];
result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
result.rid = gObj->get_self();
@@ -207,7 +207,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
if (cp.getDistance() <= 0) {
- PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count];
+ PhysicsDirectSpaceState3D::ShapeResult &result = m_results[m_count];
// Penetrated
CollisionObjectBullet *colObj;
diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 4f634ed6f0..7e74a2b22e 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -31,7 +31,7 @@
#ifndef GODOT_RESULT_CALLBACKS_H
#define GODOT_RESULT_CALLBACKS_H
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
#include <btBulletDynamicsCommon.h>
@@ -85,12 +85,12 @@ public:
// store all colliding object
struct GodotAllConvexResultCallback : public btCollisionWorld::ConvexResultCallback {
public:
- PhysicsDirectSpaceState::ShapeResult *m_results;
+ PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
int count;
- GodotAllConvexResultCallback(PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) :
+ GodotAllConvexResultCallback(PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) :
m_results(p_results),
m_resultMax(p_resultMax),
m_exclude(p_exclude),
@@ -137,7 +137,7 @@ public:
struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
- PhysicsDirectSpaceState::ShapeResult *m_results;
+ PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
int m_count;
@@ -145,7 +145,7 @@ public:
bool collide_with_bodies;
bool collide_with_areas;
- GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
+ GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
m_results(p_results),
m_resultMax(p_resultMax),
@@ -188,7 +188,7 @@ public:
struct GodotRestInfoContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
- PhysicsDirectSpaceState::ShapeRestInfo *m_result;
+ PhysicsDirectSpaceState3D::ShapeRestInfo *m_result;
const Set<RID> *m_exclude;
bool m_collided;
real_t m_min_distance;
@@ -197,7 +197,7 @@ public:
bool collide_with_bodies;
bool collide_with_areas;
- GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
+ GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
m_result(p_result),
m_exclude(p_exclude),
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index 970732688a..eaac1d650d 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -93,58 +93,58 @@ real_t HingeJointBullet::get_hinge_angle() {
return hingeConstraint->getHingeAngle();
}
-void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
+void HingeJointBullet::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS:
+ case PhysicsServer3D::HINGE_JOINT_BIAS:
WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated.");
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), p_value, hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_LOWER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER:
hingeConstraint->setLimit(p_value, hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_BIAS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), p_value, hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), p_value, hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), p_value);
break;
- case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
hingeConstraint->setMotorTargetVelocity(p_value);
break;
- case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE:
hingeConstraint->setMaxMotorImpulse(p_value);
break;
- case PhysicsServer::HINGE_JOINT_MAX:
+ case PhysicsServer3D::HINGE_JOINT_MAX:
// Internal size value, nothing to do.
break;
}
}
-real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const {
+real_t HingeJointBullet::get_param(PhysicsServer3D::HingeJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS:
+ case PhysicsServer3D::HINGE_JOINT_BIAS:
WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated.");
return 0;
- case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
return hingeConstraint->getUpperLimit();
- case PhysicsServer::HINGE_JOINT_LIMIT_LOWER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER:
return hingeConstraint->getLowerLimit();
- case PhysicsServer::HINGE_JOINT_LIMIT_BIAS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS:
return hingeConstraint->getLimitBiasFactor();
- case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS:
return hingeConstraint->getLimitSoftness();
- case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION:
return hingeConstraint->getLimitRelaxationFactor();
- case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
return hingeConstraint->getMotorTargetVelocity();
- case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE:
return hingeConstraint->getMaxMotorImpulse();
- case PhysicsServer::HINGE_JOINT_MAX:
+ case PhysicsServer3D::HINGE_JOINT_MAX:
// Internal size value, nothing to do.
return 0;
}
@@ -152,25 +152,25 @@ real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const
return 0;
}
-void HingeJointBullet::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) {
+void HingeJointBullet::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) {
switch (p_flag) {
- case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
if (!p_value) {
hingeConstraint->setLimit(-Math_PI, Math_PI);
}
break;
- case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR:
hingeConstraint->enableMotor(p_value);
break;
- case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
}
}
-bool HingeJointBullet::get_flag(PhysicsServer::HingeJointFlag p_flag) const {
+bool HingeJointBullet::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
switch (p_flag) {
- case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
return true;
- case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR:
return hingeConstraint->getEnableAngularMotor();
default:
return false;
diff --git a/modules/bullet/hinge_joint_bullet.h b/modules/bullet/hinge_joint_bullet.h
index d1061fe52f..120c40e5c0 100644
--- a/modules/bullet/hinge_joint_bullet.h
+++ b/modules/bullet/hinge_joint_bullet.h
@@ -44,14 +44,14 @@ public:
HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB);
HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; }
real_t get_hinge_angle();
- void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::HingeJointParam p_param) const;
+ void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::HingeJointParam p_param) const;
- void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value);
- bool get_flag(PhysicsServer::HingeJointFlag p_flag) const;
+ void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value);
+ bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const;
};
#endif
diff --git a/modules/bullet/joint_bullet.h b/modules/bullet/joint_bullet.h
index c840eb8f14..9cb8aab276 100644
--- a/modules/bullet/joint_bullet.h
+++ b/modules/bullet/joint_bullet.h
@@ -32,7 +32,7 @@
#define JOINT_BULLET_H
#include "constraint_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
/**
@author AndreaCatania
@@ -47,6 +47,6 @@ public:
JointBullet();
virtual ~JointBullet();
- virtual PhysicsServer::JointType get_type() const = 0;
+ virtual PhysicsServer3D::JointType get_type() const = 0;
};
#endif
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index 8d109f1866..68b40d7405 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -62,27 +62,27 @@ PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a
PinJointBullet::~PinJointBullet() {}
-void PinJointBullet::set_param(PhysicsServer::PinJointParam p_param, real_t p_value) {
+void PinJointBullet::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::PIN_JOINT_BIAS:
+ case PhysicsServer3D::PIN_JOINT_BIAS:
p2pConstraint->m_setting.m_tau = p_value;
break;
- case PhysicsServer::PIN_JOINT_DAMPING:
+ case PhysicsServer3D::PIN_JOINT_DAMPING:
p2pConstraint->m_setting.m_damping = p_value;
break;
- case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
+ case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP:
p2pConstraint->m_setting.m_impulseClamp = p_value;
break;
}
}
-real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const {
+real_t PinJointBullet::get_param(PhysicsServer3D::PinJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::PIN_JOINT_BIAS:
+ case PhysicsServer3D::PIN_JOINT_BIAS:
return p2pConstraint->m_setting.m_tau;
- case PhysicsServer::PIN_JOINT_DAMPING:
+ case PhysicsServer3D::PIN_JOINT_DAMPING:
return p2pConstraint->m_setting.m_damping;
- case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
+ case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP:
return p2pConstraint->m_setting.m_impulseClamp;
}
// Compiler doesn't seem to notice that all code paths are fulfilled...
diff --git a/modules/bullet/pin_joint_bullet.h b/modules/bullet/pin_joint_bullet.h
index d6e7a945b5..e7d05f34d4 100644
--- a/modules/bullet/pin_joint_bullet.h
+++ b/modules/bullet/pin_joint_bullet.h
@@ -46,10 +46,10 @@ public:
PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b);
~PinJointBullet();
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_PIN; }
- void set_param(PhysicsServer::PinJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::PinJointParam p_param) const;
+ void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::PinJointParam p_param) const;
void setPivotInA(const Vector3 &p_pos);
void setPivotInB(const Vector3 &p_pos);
diff --git a/modules/bullet/register_types.cpp b/modules/bullet/register_types.cpp
index 7819b67cad..009d0dff63 100644
--- a/modules/bullet/register_types.cpp
+++ b/modules/bullet/register_types.cpp
@@ -39,15 +39,15 @@
*/
#ifndef _3D_DISABLED
-PhysicsServer *_createBulletPhysicsCallback() {
- return memnew(BulletPhysicsServer);
+PhysicsServer3D *_createBulletPhysicsCallback() {
+ return memnew(BulletPhysicsServer3D);
}
#endif
void register_bullet_types() {
#ifndef _3D_DISABLED
- PhysicsServerManager::register_server("Bullet", &_createBulletPhysicsCallback);
- PhysicsServerManager::set_default_server("Bullet", 1);
+ PhysicsServer3DManager::register_server("Bullet", &_createBulletPhysicsCallback);
+ PhysicsServer3DManager::set_default_server("Bullet", 1);
GLOBAL_DEF("physics/3d/active_soft_world", true);
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/active_soft_world", PropertyInfo(Variant::BOOL, "physics/3d/active_soft_world"));
diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h
index b76641ca54..3551ca05f9 100644
--- a/modules/bullet/rid_bullet.h
+++ b/modules/bullet/rid_bullet.h
@@ -37,17 +37,17 @@
@author AndreaCatania
*/
-class BulletPhysicsServer;
+class BulletPhysicsServer3D;
class RIDBullet {
RID self;
- BulletPhysicsServer *physicsServer;
+ BulletPhysicsServer3D *physicsServer;
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- _FORCE_INLINE_ void _set_physics_server(BulletPhysicsServer *p_physicsServer) { physicsServer = p_physicsServer; }
- _FORCE_INLINE_ BulletPhysicsServer *get_physics_server() const { return physicsServer; }
+ _FORCE_INLINE_ void _set_physics_server(BulletPhysicsServer3D *p_physicsServer) { physicsServer = p_physicsServer; }
+ _FORCE_INLINE_ BulletPhysicsServer3D *get_physics_server() const { return physicsServer; }
};
#endif
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 80f42c8441..b92166e653 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -194,7 +194,7 @@ Vector3 BulletPhysicsDirectBodyState::get_contact_collider_velocity_at_position(
return velocityAtPoint;
}
-PhysicsDirectSpaceState *BulletPhysicsDirectBodyState::get_space_state() {
+PhysicsDirectSpaceState3D *BulletPhysicsDirectBodyState::get_space_state() {
return body->get_space()->get_direct_state();
}
@@ -231,12 +231,12 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() {
shapes.write[i].transform = shape_wrapper->transform;
shapes.write[i].transform.getOrigin() *= owner_scale;
switch (shape_wrapper->shape->get_type()) {
- case PhysicsServer::SHAPE_SPHERE:
- case PhysicsServer::SHAPE_BOX:
- case PhysicsServer::SHAPE_CAPSULE:
- case PhysicsServer::SHAPE_CYLINDER:
- case PhysicsServer::SHAPE_CONVEX_POLYGON:
- case PhysicsServer::SHAPE_RAY: {
+ case PhysicsServer3D::SHAPE_SPHERE:
+ case PhysicsServer3D::SHAPE_BOX:
+ case PhysicsServer3D::SHAPE_CAPSULE:
+ case PhysicsServer3D::SHAPE_CYLINDER:
+ case PhysicsServer3D::SHAPE_CONVEX_POLYGON:
+ case PhysicsServer3D::SHAPE_RAY: {
shapes.write[i].shape = static_cast<btConvexShape *>(shape_wrapper->shape->create_bt_shape(owner_scale * shape_wrapper->scale, safe_margin));
} break;
default:
@@ -286,7 +286,7 @@ RigidBodyBullet::RigidBodyBullet() :
reload_shapes();
setupBulletCollisionObject(btBody);
- set_mode(PhysicsServer::BODY_MODE_RIGID);
+ set_mode(PhysicsServer3D::BODY_MODE_RIGID);
reload_axis_lock();
areasWhereIam.resize(maxAreasWhereIam);
@@ -487,29 +487,29 @@ void RigidBodyBullet::set_omit_forces_integration(bool p_omit) {
omit_forces_integration = p_omit;
}
-void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) {
+void RigidBodyBullet::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::BODY_PARAM_BOUNCE:
+ case PhysicsServer3D::BODY_PARAM_BOUNCE:
btBody->setRestitution(p_value);
break;
- case PhysicsServer::BODY_PARAM_FRICTION:
+ case PhysicsServer3D::BODY_PARAM_FRICTION:
btBody->setFriction(p_value);
break;
- case PhysicsServer::BODY_PARAM_MASS: {
+ case PhysicsServer3D::BODY_PARAM_MASS: {
ERR_FAIL_COND(p_value < 0);
mass = p_value;
_internal_set_mass(p_value);
break;
}
- case PhysicsServer::BODY_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP:
linearDamp = p_value;
btBody->setDamping(linearDamp, angularDamp);
break;
- case PhysicsServer::BODY_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP:
angularDamp = p_value;
btBody->setDamping(linearDamp, angularDamp);
break;
- case PhysicsServer::BODY_PARAM_GRAVITY_SCALE:
+ case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE:
gravity_scale = p_value;
/// The Bullet gravity will be is set by reload_space_override_modificator
scratch_space_override_modificator();
@@ -519,21 +519,21 @@ void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_v
}
}
-real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const {
+real_t RigidBodyBullet::get_param(PhysicsServer3D::BodyParameter p_param) const {
switch (p_param) {
- case PhysicsServer::BODY_PARAM_BOUNCE:
+ case PhysicsServer3D::BODY_PARAM_BOUNCE:
return btBody->getRestitution();
- case PhysicsServer::BODY_PARAM_FRICTION:
+ case PhysicsServer3D::BODY_PARAM_FRICTION:
return btBody->getFriction();
- case PhysicsServer::BODY_PARAM_MASS: {
+ case PhysicsServer3D::BODY_PARAM_MASS: {
const btScalar invMass = btBody->getInvMass();
return 0 == invMass ? 0 : 1 / invMass;
}
- case PhysicsServer::BODY_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP:
return linearDamp;
- case PhysicsServer::BODY_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP:
return angularDamp;
- case PhysicsServer::BODY_PARAM_GRAVITY_SCALE:
+ case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE:
return gravity_scale;
default:
WARN_PRINT("Parameter " + itos(p_param) + " not supported by bullet");
@@ -541,31 +541,31 @@ real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const {
}
}
-void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
+void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) {
// This is necessary to block force_integration untile next move
can_integrate_forces = false;
destroy_kinematic_utilities();
// The mode change is relevant to its mass
switch (p_mode) {
- case PhysicsServer::BODY_MODE_KINEMATIC:
- mode = PhysicsServer::BODY_MODE_KINEMATIC;
+ case PhysicsServer3D::BODY_MODE_KINEMATIC:
+ mode = PhysicsServer3D::BODY_MODE_KINEMATIC;
reload_axis_lock();
_internal_set_mass(0);
init_kinematic_utilities();
break;
- case PhysicsServer::BODY_MODE_STATIC:
- mode = PhysicsServer::BODY_MODE_STATIC;
+ case PhysicsServer3D::BODY_MODE_STATIC:
+ mode = PhysicsServer3D::BODY_MODE_STATIC;
reload_axis_lock();
_internal_set_mass(0);
break;
- case PhysicsServer::BODY_MODE_RIGID:
- mode = PhysicsServer::BODY_MODE_RIGID;
+ case PhysicsServer3D::BODY_MODE_RIGID:
+ mode = PhysicsServer3D::BODY_MODE_RIGID;
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
break;
- case PhysicsServer::BODY_MODE_CHARACTER:
- mode = PhysicsServer::BODY_MODE_CHARACTER;
+ case PhysicsServer3D::BODY_MODE_CHARACTER:
+ mode = PhysicsServer3D::BODY_MODE_CHARACTER;
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
@@ -575,26 +575,26 @@ void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
btBody->setAngularVelocity(btVector3(0, 0, 0));
btBody->setLinearVelocity(btVector3(0, 0, 0));
}
-PhysicsServer::BodyMode RigidBodyBullet::get_mode() const {
+PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const {
return mode;
}
-void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) {
+void RigidBodyBullet::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case PhysicsServer::BODY_STATE_TRANSFORM:
+ case PhysicsServer3D::BODY_STATE_TRANSFORM:
set_transform(p_variant);
break;
- case PhysicsServer::BODY_STATE_LINEAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY:
set_linear_velocity(p_variant);
break;
- case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY:
set_angular_velocity(p_variant);
break;
- case PhysicsServer::BODY_STATE_SLEEPING:
+ case PhysicsServer3D::BODY_STATE_SLEEPING:
set_activation_state(!bool(p_variant));
break;
- case PhysicsServer::BODY_STATE_CAN_SLEEP:
+ case PhysicsServer3D::BODY_STATE_CAN_SLEEP:
can_sleep = bool(p_variant);
if (!can_sleep) {
// Can't sleep
@@ -606,17 +606,17 @@ void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant
}
}
-Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const {
+Variant RigidBodyBullet::get_state(PhysicsServer3D::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer::BODY_STATE_TRANSFORM:
+ case PhysicsServer3D::BODY_STATE_TRANSFORM:
return get_transform();
- case PhysicsServer::BODY_STATE_LINEAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY:
return get_linear_velocity();
- case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY:
return get_angular_velocity();
- case PhysicsServer::BODY_STATE_SLEEPING:
+ case PhysicsServer3D::BODY_STATE_SLEEPING:
return !is_active();
- case PhysicsServer::BODY_STATE_CAN_SLEEP:
+ case PhysicsServer3D::BODY_STATE_CAN_SLEEP:
return can_sleep;
default:
WARN_PRINT("This state " + itos(p_state) + " is not supported by Bullet");
@@ -714,7 +714,7 @@ Vector3 RigidBodyBullet::get_applied_torque() const {
return gTotTorq;
}
-void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
+void RigidBodyBullet::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) {
if (lock) {
locked_axis |= p_axis;
} else {
@@ -724,18 +724,18 @@ void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
reload_axis_lock();
}
-bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const {
+bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
return locked_axis & p_axis;
}
void RigidBodyBullet::reload_axis_lock() {
- btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z))));
- if (PhysicsServer::BODY_MODE_CHARACTER == mode) {
+ btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z))));
+ if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) {
/// When character angular is always locked
btBody->setAngularFactor(btVector3(0., 0., 0.));
} else {
- btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z))));
+ btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z))));
}
}
@@ -794,7 +794,7 @@ Vector3 RigidBodyBullet::get_angular_velocity() const {
}
void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) {
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
if (space && space->get_delta_time() != 0)
btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time());
// The kinematic use MotionState class
@@ -862,7 +862,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) {
}
}
}
- if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
+ if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
scratch_space_override_modificator();
}
@@ -895,7 +895,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
--areaWhereIamCount;
areasWhereIam.write[areaWhereIamCount] = NULL; // Even if this is not required, I clear the last element to be safe
- if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
+ if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
scratch_space_override_modificator();
}
}
@@ -904,7 +904,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
void RigidBodyBullet::reload_space_override_modificator() {
// Make sure that kinematic bodies have their total gravity calculated
- if (!is_active() && PhysicsServer::BODY_MODE_KINEMATIC != mode)
+ if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode)
return;
Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude());
@@ -920,7 +920,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
currentArea = areasWhereIam[i];
- if (!currentArea || PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) {
+ if (!currentArea || PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) {
continue;
}
@@ -954,11 +954,11 @@ void RigidBodyBullet::reload_space_override_modificator() {
}
switch (currentArea->get_spOv_mode()) {
- case PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED:
/// This area does not affect gravity/damp. These are generally areas
/// that exist only to detect collisions, and objects entering or exiting them.
break;
- case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
/// This area adds its gravity/damp values to whatever has been
/// calculated so far. This way, many overlapping areas can combine
/// their physics to make interesting
@@ -967,7 +967,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
newAngularDamp += currentArea->get_spOv_angularDamp();
++countCombined;
break;
- case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE:
/// This area adds its gravity/damp values to whatever has been calculated
/// so far. Then stops taking into account the rest of the areas, even the
/// default one.
@@ -976,7 +976,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
newAngularDamp += currentArea->get_spOv_angularDamp();
++countCombined;
goto endAreasCycle;
- case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
/// This area replaces any gravity/damp, even the default one, and
/// stops taking into account the rest of the areas.
newGravity = support_gravity;
@@ -984,7 +984,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
newAngularDamp = currentArea->get_spOv_angularDamp();
countCombined = 1;
goto endAreasCycle;
- case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE:
/// This area replaces any gravity/damp calculated so far, but keeps
/// calculating the rest of the areas, down to the default one.
newGravity = support_gravity;
@@ -1032,14 +1032,14 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
const bool isDynamic = p_mass != 0.f;
if (isDynamic) {
- if (PhysicsServer::BODY_MODE_RIGID != mode && PhysicsServer::BODY_MODE_CHARACTER != mode)
+ if (PhysicsServer3D::BODY_MODE_RIGID != mode && PhysicsServer3D::BODY_MODE_CHARACTER != mode)
return;
m_isStatic = false;
if (mainShape)
mainShape->calculateLocalInertia(p_mass, localInertia);
- if (PhysicsServer::BODY_MODE_RIGID == mode) {
+ if (PhysicsServer3D::BODY_MODE_RIGID == mode) {
btBody->setCollisionFlags(clearedCurrentFlags); // Just set the flags without Kin and Static
} else {
@@ -1054,11 +1054,11 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
}
} else {
- if (PhysicsServer::BODY_MODE_STATIC != mode && PhysicsServer::BODY_MODE_KINEMATIC != mode)
+ if (PhysicsServer3D::BODY_MODE_STATIC != mode && PhysicsServer3D::BODY_MODE_KINEMATIC != mode)
return;
m_isStatic = true;
- if (PhysicsServer::BODY_MODE_STATIC == mode) {
+ if (PhysicsServer3D::BODY_MODE_STATIC == mode) {
btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_STATIC_OBJECT);
} else {
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index ca599f7a77..bce3511282 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -51,10 +51,10 @@ class BulletPhysicsDirectBodyState;
/// is set to be only in one single thread.
///
/// In the system there is only one object at a time that manage all bodies and is
-/// created by BulletPhysicsServer and is held by the "singleton" variable of this class
+/// created by BulletPhysicsServer3D and is held by the "singleton" variable of this class
/// Each time something require it, the body must be set again.
-class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState {
- GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState);
+class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState3D {
+ GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState3D);
static BulletPhysicsDirectBodyState *singleton;
@@ -138,7 +138,7 @@ public:
// Skip the execution of this function
}
- virtual PhysicsDirectSpaceState *get_space_state();
+ virtual PhysicsDirectSpaceState3D *get_space_state();
};
class RigidBodyBullet : public RigidCollisionObjectBullet {
@@ -192,7 +192,7 @@ private:
// This is required only for Kinematic movement
KinematicUtilities *kinematic_utilities;
- PhysicsServer::BodyMode mode;
+ PhysicsServer3D::BodyMode mode;
GodotMotionState *godotMotionState;
btRigidBody *btBody;
uint16_t locked_axis;
@@ -278,14 +278,14 @@ public:
void set_omit_forces_integration(bool p_omit);
_FORCE_INLINE_ bool get_omit_forces_integration() const { return omit_forces_integration; }
- void set_param(PhysicsServer::BodyParameter p_param, real_t);
- real_t get_param(PhysicsServer::BodyParameter p_param) const;
+ void set_param(PhysicsServer3D::BodyParameter p_param, real_t);
+ real_t get_param(PhysicsServer3D::BodyParameter p_param) const;
- void set_mode(PhysicsServer::BodyMode p_mode);
- PhysicsServer::BodyMode get_mode() const;
+ void set_mode(PhysicsServer3D::BodyMode p_mode);
+ PhysicsServer3D::BodyMode get_mode() const;
- void set_state(PhysicsServer::BodyState p_state, const Variant &p_variant);
- Variant get_state(PhysicsServer::BodyState p_state) const;
+ void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PhysicsServer3D::BodyState p_state) const;
void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
void apply_central_impulse(const Vector3 &p_impulse);
@@ -300,8 +300,8 @@ public:
void set_applied_torque(const Vector3 &p_torque);
Vector3 get_applied_torque() const;
- void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock);
- bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const;
+ void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock);
+ bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const;
void reload_axis_lock();
/// Doc:
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index 6780f89d9e..6b73525d10 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -150,7 +150,7 @@ btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(Vector<real_t>
btHeightfieldTerrainShape *heightfield = bulletnew(btHeightfieldTerrainShape(p_width, p_depth, heightsPtr, ignoredHeightScale, p_min_height, p_max_height, YAxis, PHY_FLOAT, flipQuadEdges));
- // The shape can be created without params when you do PhysicsServer.shape_create(PhysicsServer.SHAPE_HEIGHTMAP)
+ // The shape can be created without params when you do PhysicsServer3D.shape_create(PhysicsServer3D.SHAPE_HEIGHTMAP)
if (heightsPtr)
heightfield->buildAccelerator(16);
@@ -176,8 +176,8 @@ Variant PlaneShapeBullet::get_data() const {
return plane;
}
-PhysicsServer::ShapeType PlaneShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_PLANE;
+PhysicsServer3D::ShapeType PlaneShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_PLANE;
}
void PlaneShapeBullet::setup(const Plane &p_plane) {
@@ -204,8 +204,8 @@ Variant SphereShapeBullet::get_data() const {
return radius;
}
-PhysicsServer::ShapeType SphereShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_SPHERE;
+PhysicsServer3D::ShapeType SphereShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_SPHERE;
}
void SphereShapeBullet::setup(real_t p_radius) {
@@ -231,8 +231,8 @@ Variant BoxShapeBullet::get_data() const {
return g_half_extents;
}
-PhysicsServer::ShapeType BoxShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_BOX;
+PhysicsServer3D::ShapeType BoxShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_BOX;
}
void BoxShapeBullet::setup(const Vector3 &p_half_extents) {
@@ -263,8 +263,8 @@ Variant CapsuleShapeBullet::get_data() const {
return d;
}
-PhysicsServer::ShapeType CapsuleShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CAPSULE;
+PhysicsServer3D::ShapeType CapsuleShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CAPSULE;
}
void CapsuleShapeBullet::setup(real_t p_height, real_t p_radius) {
@@ -296,8 +296,8 @@ Variant CylinderShapeBullet::get_data() const {
return d;
}
-PhysicsServer::ShapeType CylinderShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CYLINDER;
+PhysicsServer3D::ShapeType CylinderShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CYLINDER;
}
void CylinderShapeBullet::setup(real_t p_height, real_t p_radius) {
@@ -334,8 +334,8 @@ Variant ConvexPolygonShapeBullet::get_data() const {
return out_vertices;
}
-PhysicsServer::ShapeType ConvexPolygonShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CONVEX_POLYGON;
+PhysicsServer3D::ShapeType ConvexPolygonShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CONVEX_POLYGON;
}
void ConvexPolygonShapeBullet::setup(const Vector<Vector3> &p_vertices) {
@@ -381,8 +381,8 @@ Variant ConcavePolygonShapeBullet::get_data() const {
return faces;
}
-PhysicsServer::ShapeType ConcavePolygonShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CONCAVE_POLYGON;
+PhysicsServer3D::ShapeType ConcavePolygonShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CONCAVE_POLYGON;
}
void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
@@ -536,8 +536,8 @@ Variant HeightMapShapeBullet::get_data() const {
ERR_FAIL_V(Variant());
}
-PhysicsServer::ShapeType HeightMapShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_HEIGHTMAP;
+PhysicsServer3D::ShapeType HeightMapShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_HEIGHTMAP;
}
void HeightMapShapeBullet::setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
@@ -580,8 +580,8 @@ Variant RayShapeBullet::get_data() const {
return d;
}
-PhysicsServer::ShapeType RayShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_RAY;
+PhysicsServer3D::ShapeType RayShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_RAY;
}
void RayShapeBullet::setup(real_t p_length, bool p_slips_on_slope) {
diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h
index c8b5ca102a..0dbc616fe5 100644
--- a/modules/bullet/shape_bullet.h
+++ b/modules/bullet/shape_bullet.h
@@ -34,7 +34,7 @@
#include "core/math/geometry.h"
#include "core/variant.h"
#include "rid_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include <LinearMath/btAlignedObjectArray.h>
#include <LinearMath/btScalar.h>
@@ -78,7 +78,7 @@ public:
virtual void set_data(const Variant &p_data) = 0;
virtual Variant get_data() const = 0;
- virtual PhysicsServer::ShapeType get_type() const = 0;
+ virtual PhysicsServer3D::ShapeType get_type() const = 0;
public:
static class btEmptyShape *create_shape_empty();
@@ -103,7 +103,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -120,7 +120,7 @@ public:
_FORCE_INLINE_ real_t get_radius() { return radius; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -137,7 +137,7 @@ public:
_FORCE_INLINE_ const btVector3 &get_half_extents() { return half_extents; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -156,7 +156,7 @@ public:
_FORCE_INLINE_ real_t get_radius() { return radius; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -175,7 +175,7 @@ public:
_FORCE_INLINE_ real_t get_radius() { return radius; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
@@ -192,7 +192,7 @@ public:
virtual void set_data(const Variant &p_data);
void get_vertices(Vector<Vector3> &out_vertices);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -210,7 +210,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -230,7 +230,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -247,7 +247,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp
index d9ebb9d580..f193daef39 100644
--- a/modules/bullet/slider_joint_bullet.cpp
+++ b/modules/bullet/slider_joint_bullet.cpp
@@ -342,58 +342,58 @@ real_t SliderJointBullet::getLinearPos() {
;
}
-void SliderJointBullet::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) {
+void SliderJointBullet::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: setUpperLinLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: setLowerLinLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: setSoftnessLimLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: setRestitutionLimLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: setDampingLimLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: setSoftnessDirLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: setRestitutionDirLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: setDampingDirLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: setDampingOrthoLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: setUpperAngLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: setLowerAngLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: setSoftnessLimAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: setRestitutionLimAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: setDampingLimAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: setSoftnessDirAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: setRestitutionDirAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: setDampingDirAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: setDampingOrthoAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: setUpperLinLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: setLowerLinLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: setSoftnessLimLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: setRestitutionLimLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: setDampingLimLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: setSoftnessDirLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: setRestitutionDirLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: setDampingDirLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: setDampingOrthoLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: setUpperAngLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: setLowerAngLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: setSoftnessLimAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: setRestitutionLimAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: setDampingLimAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: setSoftnessDirAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: setRestitutionDirAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: setDampingDirAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: setDampingOrthoAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
}
}
-real_t SliderJointBullet::get_param(PhysicsServer::SliderJointParam p_param) const {
+real_t SliderJointBullet::get_param(PhysicsServer3D::SliderJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return getUpperLinLimit();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return getLowerLinLimit();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return getSoftnessLimLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return getRestitutionLimLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return getDampingLimLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return getSoftnessDirLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return getRestitutionDirLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return getDampingDirLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return getDampingOrthoLin();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return getUpperAngLimit();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return getLowerAngLimit();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return getSoftnessLimAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return getRestitutionLimAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return getDampingLimAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return getSoftnessDirAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return getRestitutionDirAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return getDampingDirAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return getDampingOrthoAng();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return getUpperLinLimit();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return getLowerLinLimit();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return getSoftnessLimLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return getRestitutionLimLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return getDampingLimLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return getSoftnessDirLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return getRestitutionDirLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return getDampingDirLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return getDampingOrthoLin();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return getUpperAngLimit();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return getLowerAngLimit();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return getSoftnessLimAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return getRestitutionLimAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return getDampingLimAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return getSoftnessDirAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return getRestitutionDirAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return getDampingDirAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return getDampingOrthoAng();
default:
return 0;
}
diff --git a/modules/bullet/slider_joint_bullet.h b/modules/bullet/slider_joint_bullet.h
index d98a1b8c95..6410b952ed 100644
--- a/modules/bullet/slider_joint_bullet.h
+++ b/modules/bullet/slider_joint_bullet.h
@@ -46,7 +46,7 @@ public:
/// Reference frame is A
SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; }
const RigidBodyBullet *getRigidBodyA() const;
const RigidBodyBullet *getRigidBodyB() const;
@@ -115,7 +115,7 @@ public:
real_t getMaxAngMotorForce();
real_t getLinearPos();
- void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::SliderJointParam p_param) const;
+ void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::SliderJointParam p_param) const;
};
#endif
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index f21206dd0d..2984bf9c2b 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -32,7 +32,7 @@
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
-#include "scene/3d/soft_body.h"
+#include "scene/3d/soft_body_3d.h"
#include "space_bullet.h"
SoftBodyBullet::SoftBodyBullet() :
@@ -76,7 +76,7 @@ void SoftBodyBullet::on_enter_area(AreaBullet *p_area) {}
void SoftBodyBullet::on_exit_area(AreaBullet *p_area) {}
-void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_server_handler) {
+void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_rendering_server_handler) {
if (!bt_soft_body)
return;
@@ -96,8 +96,8 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_
const int vs_indices_size(vs_indices->size());
for (int x = 0; x < vs_indices_size; ++x) {
- p_visual_server_handler->set_vertex((*vs_indices)[x], vertex_position);
- p_visual_server_handler->set_normal((*vs_indices)[x], vertex_normal);
+ p_rendering_server_handler->set_vertex((*vs_indices)[x], vertex_position);
+ p_rendering_server_handler->set_normal((*vs_indices)[x], vertex_normal);
}
}
@@ -112,7 +112,7 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_
B_TO_G(aabb_min, aabb.position);
B_TO_G(size, aabb.size);
- p_visual_server_handler->set_aabb(aabb);
+ p_rendering_server_handler->set_aabb(aabb);
}
void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
@@ -129,8 +129,8 @@ void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
}
Array arrays = soft_mesh->surface_get_arrays(0);
- ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & VS::ARRAY_FORMAT_INDEX));
- set_trimesh_body_shape(arrays[VS::ARRAY_INDEX], arrays[VS::ARRAY_VERTEX]);
+ ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & RS::ARRAY_FORMAT_INDEX));
+ set_trimesh_body_shape(arrays[RS::ARRAY_INDEX], arrays[RS::ARRAY_VERTEX]);
}
void SoftBodyBullet::destroy_soft_body() {
@@ -184,7 +184,7 @@ void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- Vector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]);
+ Vector<Vector3> vertices(arrays[RS::ARRAY_VERTEX]);
if (0 <= p_node_index && vertices.size() > p_node_index) {
r_offset = vertices[p_node_index];
@@ -230,7 +230,7 @@ void SoftBodyBullet::reset_all_node_positions() {
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- Vector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]);
+ Vector<Vector3> vs_vertices(arrays[RS::ARRAY_VERTEX]);
const Vector3 *vs_vertices_read = vs_vertices.ptr();
for (int vertex_index = bt_soft_body->m_nodes.size() - 1; 0 <= vertex_index; --vertex_index) {
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index 05d7e6ce3f..3c6871e0d6 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -43,7 +43,7 @@
#include "BulletSoftBody/btSoftBodyHelpers.h"
#include "collision_object_bullet.h"
#include "scene/resources/mesh.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#ifdef x11_None
/// This is required to re add the macro None defined by x11 compiler
@@ -100,7 +100,7 @@ public:
_FORCE_INLINE_ btSoftBody *get_bt_soft_body() const { return bt_soft_body; }
- void update_visual_server(class SoftBodyVisualServerHandler *p_visual_server_handler);
+ void update_rendering_server(class SoftBodyRenderingServerHandler *p_rendering_server_handler);
void set_soft_mesh(const Ref<Mesh> &p_mesh);
void destroy_soft_body();
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index f6df97f11d..c40a1500f0 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -39,7 +39,7 @@
#include "godot_collision_configuration.h"
#include "godot_collision_dispatcher.h"
#include "rigid_body_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include "soft_body_bullet.h"
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
@@ -59,7 +59,7 @@
*/
BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) :
- PhysicsDirectSpaceState(),
+ PhysicsDirectSpaceState3D(),
space(p_space) {}
int BulletPhysicsDirectSpaceState::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
@@ -366,27 +366,27 @@ void SpaceBullet::step(real_t p_delta_time) {
dynamicsWorld->stepSimulation(p_delta_time, 0, 0);
}
-void SpaceBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) {
+void SpaceBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
assert(dynamicsWorld);
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
gravityMagnitude = p_value;
update_gravity();
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
gravityDirection = p_value;
update_gravity();
break;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
break; // No damp
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
// Priority is always 0, the lower
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
break;
default:
WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
@@ -394,22 +394,22 @@ void SpaceBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant
}
}
-Variant SpaceBullet::get_param(PhysicsServer::AreaParameter p_param) {
+Variant SpaceBullet::get_param(PhysicsServer3D::AreaParameter p_param) {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
return gravityMagnitude;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
return gravityDirection;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
return 0; // No damp
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
return 0; // Priority is always 0, the lower
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
return false;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
return 0;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return 0;
default:
WARN_PRINT("This get parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
@@ -417,32 +417,32 @@ Variant SpaceBullet::get_param(PhysicsServer::AreaParameter p_param) {
}
}
-void SpaceBullet::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) {
+void SpaceBullet::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
- case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION:
- case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
- case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
+ case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
default:
WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
break;
}
}
-real_t SpaceBullet::get_param(PhysicsServer::SpaceParameter p_param) {
+real_t SpaceBullet::get_param(PhysicsServer3D::SpaceParameter p_param) {
switch (p_param) {
- case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
- case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION:
- case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
- case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
+ case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
default:
WARN_PRINT("The SpaceBullet doesn't support this get parameter (" + itos(p_param) + "), 0 is returned.");
return 0.f;
@@ -891,7 +891,7 @@ static Ref<StandardMaterial3D> red_mat;
static Ref<StandardMaterial3D> blue_mat;
#endif
-bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
#if debug_test_motion
/// Yes I know this is not good, but I've used it as fast debugging hack.
@@ -1042,7 +1042,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
return has_penetration;
}
-int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, float p_margin) {
+int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin) {
btTransform body_transform;
G_TO_B(p_transform, body_transform);
@@ -1054,7 +1054,7 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p
int rays_found_this_round = 0;
for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) {
- PhysicsServer::SeparationResult *next_results = &r_results[rays_found];
+ PhysicsServer3D::SeparationResult *next_results = &r_results[rays_found];
rays_found_this_round = recover_from_penetration_ray(p_body, body_transform, RECOVERING_MOVEMENT_SCALE, p_infinite_inertia, p_result_max - rays_found, recover_motion, next_results);
rays_found += rays_found_this_round;
@@ -1333,7 +1333,7 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC
return false;
}
-int SpaceBullet::add_separation_result(PhysicsServer::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const {
+int SpaceBullet::add_separation_result(PhysicsServer3D::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const {
// optimize results (ignore non-colliding)
if (p_recover_result.penetration_distance < 0.0) {
@@ -1355,7 +1355,7 @@ int SpaceBullet::add_separation_result(PhysicsServer::SeparationResult *r_result
}
}
-int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer::SeparationResult *r_results) {
+int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results) {
// Calculate the cumulative AABB of all shapes of the kinematic body
btVector3 aabb_min, aabb_max;
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index 32372f1630..fce715b48d 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -35,7 +35,7 @@
#include "core/vector.h"
#include "godot_result_callbacks.h"
#include "rid_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
#include <BulletCollision/BroadphaseCollision/btOverlappingPairCache.h>
@@ -67,8 +67,8 @@ class btGjkEpaPenetrationDepthSolver;
extern ContactAddedCallback gContactAddedCallback;
-class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState {
- GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState);
+class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState3D {
+ GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState3D);
private:
SpaceBullet *space;
@@ -131,15 +131,15 @@ public:
/// @param p_param:
/// AREA_PARAM_GRAVITY to set the gravity magnitude of entire world
/// AREA_PARAM_GRAVITY_VECTOR to set the gravity direction of entire world
- void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value);
+ void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
/// Used to get some parameters to Bullet world
/// @param p_param:
/// AREA_PARAM_GRAVITY to get the gravity magnitude of entire world
/// AREA_PARAM_GRAVITY_VECTOR to get the gravity direction of entire world
- Variant get_param(PhysicsServer::AreaParameter p_param);
+ Variant get_param(PhysicsServer3D::AreaParameter p_param);
- void set_param(PhysicsServer::SpaceParameter p_param, real_t p_value);
- real_t get_param(PhysicsServer::SpaceParameter p_param);
+ void set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::SpaceParameter p_param);
void add_area(AreaBullet *p_area);
void remove_area(AreaBullet *p_area);
@@ -177,8 +177,8 @@ public:
void update_gravity();
- bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes);
- int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, float p_margin);
+ bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes);
+ int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin);
private:
void create_empty_world(bool p_create_soft_world);
@@ -213,7 +213,7 @@ private:
/// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm
bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
- int add_separation_result(PhysicsServer::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const;
- int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer::SeparationResult *r_results);
+ int add_separation_result(PhysicsServer3D::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const;
+ int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results);
};
#endif
diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp
index 1b63bccb06..4b27eea019 100644
--- a/modules/csg/csg_gizmos.cpp
+++ b/modules/csg/csg_gizmos.cpp
@@ -32,7 +32,7 @@
///////////
-CSGShapeSpatialGizmoPlugin::CSGShapeSpatialGizmoPlugin() {
+CSGShapeNode3DGizmoPlugin::CSGShapeNode3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/csg", Color(0.0, 0.4, 1, 0.15));
create_material("shape_union_material", gizmo_color);
@@ -49,46 +49,46 @@ CSGShapeSpatialGizmoPlugin::CSGShapeSpatialGizmoPlugin() {
create_handle_material("handles");
}
-String CSGShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String CSGShapeNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
- if (Object::cast_to<CSGSphere>(cs)) {
+ if (Object::cast_to<CSGSphere3D>(cs)) {
return "Radius";
}
- if (Object::cast_to<CSGBox>(cs)) {
+ if (Object::cast_to<CSGBox3D>(cs)) {
static const char *hname[3] = { "Width", "Height", "Depth" };
return hname[p_idx];
}
- if (Object::cast_to<CSGCylinder>(cs)) {
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
return p_idx == 0 ? "Radius" : "Height";
}
- if (Object::cast_to<CSGTorus>(cs)) {
+ if (Object::cast_to<CSGTorus3D>(cs)) {
return p_idx == 0 ? "InnerRadius" : "OuterRadius";
}
return "";
}
-Variant CSGShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant CSGShapeNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
- if (Object::cast_to<CSGSphere>(cs)) {
+ if (Object::cast_to<CSGSphere3D>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
return s->get_radius();
}
- if (Object::cast_to<CSGBox>(cs)) {
+ if (Object::cast_to<CSGBox3D>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
switch (p_idx) {
case 0: return s->get_width();
case 1: return s->get_height();
@@ -96,23 +96,23 @@ Variant CSGShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo
}
}
- if (Object::cast_to<CSGCylinder>(cs)) {
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
return p_idx == 0 ? s->get_radius() : s->get_height();
}
- if (Object::cast_to<CSGTorus>(cs)) {
+ if (Object::cast_to<CSGTorus3D>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
return p_idx == 0 ? s->get_inner_radius() : s->get_outer_radius();
}
return Variant();
}
-void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void CSGShapeNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
Transform gt = cs->get_global_transform();
//gt.orthonormalize();
@@ -123,15 +123,15 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) };
- if (Object::cast_to<CSGSphere>(cs)) {
+ if (Object::cast_to<CSGSphere3D>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -140,17 +140,17 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
s->set_radius(d);
}
- if (Object::cast_to<CSGBox>(cs)) {
+ if (Object::cast_to<CSGBox3D>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
Vector3 axis;
axis[p_idx] = 1.0;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -163,17 +163,17 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
}
}
- if (Object::cast_to<CSGCylinder>(cs)) {
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
Vector3 axis;
axis[p_idx == 0 ? 0 : 1] = 1.0;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -185,17 +185,17 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
s->set_height(d * 2.0);
}
- if (Object::cast_to<CSGTorus>(cs)) {
+ if (Object::cast_to<CSGTorus3D>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
Vector3 axis;
axis[0] = 1.0;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -207,26 +207,26 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
s->set_outer_radius(d);
}
}
-void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void CSGShapeNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
- if (Object::cast_to<CSGSphere>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ if (Object::cast_to<CSGSphere3D>(cs)) {
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
if (p_cancel) {
s->set_radius(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Sphere Shape Radius"));
ur->add_do_method(s, "set_radius", s->get_radius());
ur->add_undo_method(s, "set_radius", p_restore);
ur->commit_action();
}
- if (Object::cast_to<CSGBox>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ if (Object::cast_to<CSGBox3D>(cs)) {
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
if (p_cancel) {
switch (p_idx) {
case 0: s->set_width(p_restore); break;
@@ -236,7 +236,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Box Shape Extents"));
static const char *method[3] = { "set_width", "set_height", "set_depth" };
float current = 0;
@@ -251,8 +251,8 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
- if (Object::cast_to<CSGCylinder>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
if (p_cancel) {
if (p_idx == 0)
s->set_radius(p_restore);
@@ -261,7 +261,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx == 0) {
ur->create_action(TTR("Change Cylinder Radius"));
ur->add_do_method(s, "set_radius", s->get_radius());
@@ -275,8 +275,8 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
- if (Object::cast_to<CSGTorus>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ if (Object::cast_to<CSGTorus3D>(cs)) {
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
if (p_cancel) {
if (p_idx == 0)
s->set_inner_radius(p_restore);
@@ -285,7 +285,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx == 0) {
ur->create_action(TTR("Change Torus Inner Radius"));
ur->add_do_method(s, "set_inner_radius", s->get_inner_radius());
@@ -299,37 +299,37 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
}
-bool CSGShapeSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<CSGSphere>(p_spatial) || Object::cast_to<CSGBox>(p_spatial) || Object::cast_to<CSGCylinder>(p_spatial) || Object::cast_to<CSGTorus>(p_spatial) || Object::cast_to<CSGMesh>(p_spatial) || Object::cast_to<CSGPolygon>(p_spatial);
+bool CSGShapeNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<CSGSphere3D>(p_spatial) || Object::cast_to<CSGBox3D>(p_spatial) || Object::cast_to<CSGCylinder3D>(p_spatial) || Object::cast_to<CSGTorus3D>(p_spatial) || Object::cast_to<CSGMesh3D>(p_spatial) || Object::cast_to<CSGPolygon3D>(p_spatial);
}
-String CSGShapeSpatialGizmoPlugin::get_name() const {
+String CSGShapeNode3DGizmoPlugin::get_name() const {
return "CSGShapes";
}
-int CSGShapeSpatialGizmoPlugin::get_priority() const {
+int CSGShapeNode3DGizmoPlugin::get_priority() const {
return -1;
}
-bool CSGShapeSpatialGizmoPlugin::is_selectable_when_hidden() const {
+bool CSGShapeNode3DGizmoPlugin::is_selectable_when_hidden() const {
return true;
}
-void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void CSGShapeNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
Ref<Material> material;
switch (cs->get_operation()) {
- case CSGShape::OPERATION_UNION:
+ case CSGShape3D::OPERATION_UNION:
material = get_material("shape_union_material", p_gizmo);
break;
- case CSGShape::OPERATION_INTERSECTION:
+ case CSGShape3D::OPERATION_INTERSECTION:
material = get_material("shape_intersection_material", p_gizmo);
break;
- case CSGShape::OPERATION_SUBTRACTION:
+ case CSGShape3D::OPERATION_SUBTRACTION:
material = get_material("shape_subtraction_material", p_gizmo);
break;
}
@@ -366,13 +366,13 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Ref<Material> solid_material;
switch (cs->get_operation()) {
- case CSGShape::OPERATION_UNION:
+ case CSGShape3D::OPERATION_UNION:
solid_material = get_material("shape_union_solid_material", p_gizmo);
break;
- case CSGShape::OPERATION_INTERSECTION:
+ case CSGShape3D::OPERATION_INTERSECTION:
solid_material = get_material("shape_intersection_solid_material", p_gizmo);
break;
- case CSGShape::OPERATION_SUBTRACTION:
+ case CSGShape3D::OPERATION_SUBTRACTION:
solid_material = get_material("shape_subtraction_solid_material", p_gizmo);
break;
}
@@ -380,8 +380,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), solid_material);
}
- if (Object::cast_to<CSGSphere>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ if (Object::cast_to<CSGSphere3D>(cs)) {
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
float r = s->get_radius();
Vector<Vector3> handles;
@@ -389,8 +389,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CSGBox>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ if (Object::cast_to<CSGBox3D>(cs)) {
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
Vector<Vector3> handles;
handles.push_back(Vector3(s->get_width() * 0.5, 0, 0));
@@ -399,8 +399,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CSGCylinder>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
Vector<Vector3> handles;
handles.push_back(Vector3(s->get_radius(), 0, 0));
@@ -408,8 +408,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CSGTorus>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ if (Object::cast_to<CSGTorus3D>(cs)) {
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
Vector<Vector3> handles;
handles.push_back(Vector3(s->get_inner_radius(), 0, 0));
@@ -419,6 +419,6 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
EditorPluginCSG::EditorPluginCSG(EditorNode *p_editor) {
- Ref<CSGShapeSpatialGizmoPlugin> gizmo_plugin = Ref<CSGShapeSpatialGizmoPlugin>(memnew(CSGShapeSpatialGizmoPlugin));
- SpatialEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
+ Ref<CSGShapeNode3DGizmoPlugin> gizmo_plugin = Ref<CSGShapeNode3DGizmoPlugin>(memnew(CSGShapeNode3DGizmoPlugin));
+ Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
}
diff --git a/modules/csg/csg_gizmos.h b/modules/csg/csg_gizmos.h
index 966b654802..90a059b31c 100644
--- a/modules/csg/csg_gizmos.h
+++ b/modules/csg/csg_gizmos.h
@@ -33,25 +33,25 @@
#include "csg_shape.h"
#include "editor/editor_plugin.h"
-#include "editor/spatial_editor_gizmos.h"
+#include "editor/node_3d_editor_gizmos.h"
-class CSGShapeSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
+class CSGShapeNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
- GDCLASS(CSGShapeSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
+ GDCLASS(CSGShapeNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
- bool has_gizmo(Spatial *p_spatial);
+ bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool is_selectable_when_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
+ void redraw(EditorNode3DGizmo *p_gizmo);
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
- CSGShapeSpatialGizmoPlugin();
+ CSGShapeNode3DGizmoPlugin();
};
class EditorPluginCSG : public EditorPlugin {
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 54635ae320..848b865efb 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "csg_shape.h"
-#include "scene/3d/path.h"
+#include "scene/3d/path_3d.h"
-void CSGShape::set_use_collision(bool p_enable) {
+void CSGShape3D::set_use_collision(bool p_enable) {
if (use_collision == p_enable)
return;
@@ -43,52 +43,52 @@ void CSGShape::set_use_collision(bool p_enable) {
if (use_collision) {
root_collision_shape.instance();
- root_collision_instance = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_set_state(root_collision_instance, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
- PhysicsServer::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
- PhysicsServer::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
+ root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
+ PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
set_collision_layer(collision_layer);
set_collision_mask(collision_mask);
_make_dirty(); //force update
} else {
- PhysicsServer::get_singleton()->free(root_collision_instance);
+ PhysicsServer3D::get_singleton()->free(root_collision_instance);
root_collision_instance = RID();
root_collision_shape.unref();
}
_change_notify();
}
-bool CSGShape::is_using_collision() const {
+bool CSGShape3D::is_using_collision() const {
return use_collision;
}
-void CSGShape::set_collision_layer(uint32_t p_layer) {
+void CSGShape3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
if (root_collision_instance.is_valid()) {
- PhysicsServer::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer);
}
}
-uint32_t CSGShape::get_collision_layer() const {
+uint32_t CSGShape3D::get_collision_layer() const {
return collision_layer;
}
-void CSGShape::set_collision_mask(uint32_t p_mask) {
+void CSGShape3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
if (root_collision_instance.is_valid()) {
- PhysicsServer::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask);
}
}
-uint32_t CSGShape::get_collision_mask() const {
+uint32_t CSGShape3D::get_collision_mask() const {
return collision_mask;
}
-void CSGShape::set_collision_mask_bit(int p_bit, bool p_value) {
+void CSGShape3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
@@ -98,12 +98,12 @@ void CSGShape::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool CSGShape::get_collision_mask_bit(int p_bit) const {
+bool CSGShape3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-void CSGShape::set_collision_layer_bit(int p_bit, bool p_value) {
+void CSGShape3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_layer();
if (p_value)
@@ -113,25 +113,25 @@ void CSGShape::set_collision_layer_bit(int p_bit, bool p_value) {
set_collision_layer(mask);
}
-bool CSGShape::get_collision_layer_bit(int p_bit) const {
+bool CSGShape3D::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
-bool CSGShape::is_root_shape() const {
+bool CSGShape3D::is_root_shape() const {
return !parent;
}
-void CSGShape::set_snap(float p_snap) {
+void CSGShape3D::set_snap(float p_snap) {
snap = p_snap;
}
-float CSGShape::get_snap() const {
+float CSGShape3D::get_snap() const {
return snap;
}
-void CSGShape::_make_dirty() {
+void CSGShape3D::_make_dirty() {
if (!is_inside_tree())
return;
@@ -150,7 +150,7 @@ void CSGShape::_make_dirty() {
}
}
-CSGBrush *CSGShape::_get_brush() {
+CSGBrush *CSGShape3D::_get_brush() {
if (dirty) {
if (brush) {
@@ -162,7 +162,7 @@ CSGBrush *CSGShape::_get_brush() {
for (int i = 0; i < get_child_count(); i++) {
- CSGShape *child = Object::cast_to<CSGShape>(get_child(i));
+ CSGShape3D *child = Object::cast_to<CSGShape3D>(get_child(i));
if (!child)
continue;
if (!child->is_visible_in_tree())
@@ -185,9 +185,9 @@ CSGBrush *CSGShape::_get_brush() {
CSGBrushOperation bop;
switch (child->get_operation()) {
- case CSGShape::OPERATION_UNION: bop.merge_brushes(CSGBrushOperation::OPERATION_UNION, *n, *nn2, *nn, snap); break;
- case CSGShape::OPERATION_INTERSECTION: bop.merge_brushes(CSGBrushOperation::OPERATION_INTERSECTION, *n, *nn2, *nn, snap); break;
- case CSGShape::OPERATION_SUBTRACTION: bop.merge_brushes(CSGBrushOperation::OPERATION_SUBSTRACTION, *n, *nn2, *nn, snap); break;
+ case CSGShape3D::OPERATION_UNION: bop.merge_brushes(CSGBrushOperation::OPERATION_UNION, *n, *nn2, *nn, snap); break;
+ case CSGShape3D::OPERATION_INTERSECTION: bop.merge_brushes(CSGBrushOperation::OPERATION_INTERSECTION, *n, *nn2, *nn, snap); break;
+ case CSGShape3D::OPERATION_SUBTRACTION: bop.merge_brushes(CSGBrushOperation::OPERATION_SUBSTRACTION, *n, *nn2, *nn, snap); break;
}
memdelete(n);
memdelete(nn2);
@@ -218,18 +218,18 @@ CSGBrush *CSGShape::_get_brush() {
return brush;
}
-int CSGShape::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
+int CSGShape3D::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
return surface.vertices.size() / 3;
}
-int CSGShape::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
+int CSGShape3D::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
// always 3
return 3;
}
-void CSGShape::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
+void CSGShape3D::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
Vector3 v = surface.verticesw[iFace * 3 + iVert];
@@ -238,7 +238,7 @@ void CSGShape::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosO
fvPosOut[2] = v.z;
}
-void CSGShape::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
+void CSGShape3D::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
Vector3 n = surface.normalsw[iFace * 3 + iVert];
@@ -247,7 +247,7 @@ void CSGShape::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOu
fvNormOut[2] = n.z;
}
-void CSGShape::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
+void CSGShape3D::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
Vector2 t = surface.uvsw[iFace * 3 + iVert];
@@ -255,7 +255,7 @@ void CSGShape::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexc
fvTexcOut[1] = t.y;
}
-void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
+void CSGShape3D::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
const tbool bIsOrientationPreserving, const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
@@ -273,7 +273,7 @@ void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const f
surface.tansw[i++] = d < 0 ? -1 : 1;
}
-void CSGShape::_update_shape() {
+void CSGShape3D::_update_shape() {
if (parent)
return;
@@ -460,11 +460,11 @@ void CSGShape::_update_shape() {
set_base(root_mesh->get_rid());
}
-AABB CSGShape::get_aabb() const {
+AABB CSGShape3D::get_aabb() const {
return node_aabb;
}
-Vector<Vector3> CSGShape::get_brush_faces() {
+Vector<Vector3> CSGShape3D::get_brush_faces() {
ERR_FAIL_COND_V(!is_inside_tree(), Vector<Vector3>());
CSGBrush *b = _get_brush();
if (!b) {
@@ -486,18 +486,18 @@ Vector<Vector3> CSGShape::get_brush_faces() {
return faces;
}
-Vector<Face3> CSGShape::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> CSGShape3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-void CSGShape::_notification(int p_what) {
+void CSGShape3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
Node *parentn = get_parent();
if (parentn) {
- parent = Object::cast_to<CSGShape>(parentn);
+ parent = Object::cast_to<CSGShape3D>(parentn);
if (parent) {
set_base(RID());
root_mesh.unref();
@@ -506,11 +506,11 @@ void CSGShape::_notification(int p_what) {
if (use_collision && is_root_shape()) {
root_collision_shape.instance();
- root_collision_instance = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_set_state(root_collision_instance, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
- PhysicsServer::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
- PhysicsServer::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
+ root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
+ PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
set_collision_layer(collision_layer);
set_collision_mask(collision_mask);
}
@@ -539,7 +539,7 @@ void CSGShape::_notification(int p_what) {
parent = NULL;
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
- PhysicsServer::get_singleton()->free(root_collision_instance);
+ PhysicsServer3D::get_singleton()->free(root_collision_instance);
root_collision_instance = RID();
root_collision_shape.unref();
}
@@ -547,27 +547,27 @@ void CSGShape::_notification(int p_what) {
}
}
-void CSGShape::set_operation(Operation p_operation) {
+void CSGShape3D::set_operation(Operation p_operation) {
operation = p_operation;
_make_dirty();
update_gizmo();
}
-CSGShape::Operation CSGShape::get_operation() const {
+CSGShape3D::Operation CSGShape3D::get_operation() const {
return operation;
}
-void CSGShape::set_calculate_tangents(bool p_calculate_tangents) {
+void CSGShape3D::set_calculate_tangents(bool p_calculate_tangents) {
calculate_tangents = p_calculate_tangents;
_make_dirty();
}
-bool CSGShape::is_calculating_tangents() const {
+bool CSGShape3D::is_calculating_tangents() const {
return calculate_tangents;
}
-void CSGShape::_validate_property(PropertyInfo &property) const {
+void CSGShape3D::_validate_property(PropertyInfo &property) const {
bool is_collision_prefixed = property.name.begins_with("collision_");
if ((is_collision_prefixed || property.name.begins_with("use_collision")) && is_inside_tree() && !is_root_shape()) {
//hide collision if not root
@@ -577,7 +577,7 @@ void CSGShape::_validate_property(PropertyInfo &property) const {
}
}
-Array CSGShape::get_meshes() const {
+Array CSGShape3D::get_meshes() const {
if (root_mesh.is_valid()) {
Array arr;
@@ -589,36 +589,36 @@ Array CSGShape::get_meshes() const {
return Array();
}
-void CSGShape::_bind_methods() {
+void CSGShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape::_update_shape);
- ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape::is_root_shape);
+ ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape3D::_update_shape);
+ ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape3D::is_root_shape);
- ClassDB::bind_method(D_METHOD("set_operation", "operation"), &CSGShape::set_operation);
- ClassDB::bind_method(D_METHOD("get_operation"), &CSGShape::get_operation);
+ ClassDB::bind_method(D_METHOD("set_operation", "operation"), &CSGShape3D::set_operation);
+ ClassDB::bind_method(D_METHOD("get_operation"), &CSGShape3D::get_operation);
- ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGShape::set_snap);
- ClassDB::bind_method(D_METHOD("get_snap"), &CSGShape::get_snap);
+ ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGShape3D::set_snap);
+ ClassDB::bind_method(D_METHOD("get_snap"), &CSGShape3D::get_snap);
- ClassDB::bind_method(D_METHOD("set_use_collision", "operation"), &CSGShape::set_use_collision);
- ClassDB::bind_method(D_METHOD("is_using_collision"), &CSGShape::is_using_collision);
+ ClassDB::bind_method(D_METHOD("set_use_collision", "operation"), &CSGShape3D::set_use_collision);
+ ClassDB::bind_method(D_METHOD("is_using_collision"), &CSGShape3D::is_using_collision);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &CSGShape::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &CSGShape::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &CSGShape3D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &CSGShape3D::get_collision_layer);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &CSGShape::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &CSGShape::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &CSGShape3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &CSGShape3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &CSGShape::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &CSGShape::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &CSGShape3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &CSGShape3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &CSGShape::set_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &CSGShape::get_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &CSGShape3D::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &CSGShape3D::get_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("set_calculate_tangents", "enabled"), &CSGShape::set_calculate_tangents);
- ClassDB::bind_method(D_METHOD("is_calculating_tangents"), &CSGShape::is_calculating_tangents);
+ ClassDB::bind_method(D_METHOD("set_calculate_tangents", "enabled"), &CSGShape3D::set_calculate_tangents);
+ ClassDB::bind_method(D_METHOD("is_calculating_tangents"), &CSGShape3D::is_calculating_tangents);
- ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape::get_meshes);
+ ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape3D::get_meshes);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "Union,Intersection,Subtraction"), "set_operation", "get_operation");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001"), "set_snap", "get_snap");
@@ -634,7 +634,7 @@ void CSGShape::_bind_methods() {
BIND_ENUM_CONSTANT(OPERATION_SUBTRACTION);
}
-CSGShape::CSGShape() {
+CSGShape3D::CSGShape3D() {
operation = OPERATION_UNION;
parent = NULL;
brush = NULL;
@@ -647,7 +647,7 @@ CSGShape::CSGShape() {
set_notify_local_transform(true);
}
-CSGShape::~CSGShape() {
+CSGShape3D::~CSGShape3D() {
if (brush) {
memdelete(brush);
brush = NULL;
@@ -655,17 +655,17 @@ CSGShape::~CSGShape() {
}
//////////////////////////////////
-CSGBrush *CSGCombiner::_build_brush() {
+CSGBrush *CSGCombiner3D::_build_brush() {
return NULL; //does not build anything
}
-CSGCombiner::CSGCombiner() {
+CSGCombiner3D::CSGCombiner3D() {
}
/////////////////////
-CSGBrush *CSGPrimitive::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials) {
+CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials) {
CSGBrush *brush = memnew(CSGBrush);
@@ -683,15 +683,15 @@ CSGBrush *CSGPrimitive::_create_brush_from_arrays(const Vector<Vector3> &p_verti
return brush;
}
-void CSGPrimitive::_bind_methods() {
+void CSGPrimitive3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_invert_faces", "invert_faces"), &CSGPrimitive::set_invert_faces);
- ClassDB::bind_method(D_METHOD("is_inverting_faces"), &CSGPrimitive::is_inverting_faces);
+ ClassDB::bind_method(D_METHOD("set_invert_faces", "invert_faces"), &CSGPrimitive3D::set_invert_faces);
+ ClassDB::bind_method(D_METHOD("is_inverting_faces"), &CSGPrimitive3D::is_inverting_faces);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert_faces"), "set_invert_faces", "is_inverting_faces");
}
-void CSGPrimitive::set_invert_faces(bool p_invert) {
+void CSGPrimitive3D::set_invert_faces(bool p_invert) {
if (invert_faces == p_invert)
return;
@@ -700,17 +700,17 @@ void CSGPrimitive::set_invert_faces(bool p_invert) {
_make_dirty();
}
-bool CSGPrimitive::is_inverting_faces() {
+bool CSGPrimitive3D::is_inverting_faces() {
return invert_faces;
}
-CSGPrimitive::CSGPrimitive() {
+CSGPrimitive3D::CSGPrimitive3D() {
invert_faces = false;
}
/////////////////////
-CSGBrush *CSGMesh::_build_brush() {
+CSGBrush *CSGMesh3D::_build_brush() {
if (!mesh.is_valid())
return NULL;
@@ -741,7 +741,7 @@ CSGBrush *CSGMesh::_build_brush() {
const Vector3 *vr = avertices.ptr();
Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL];
- const Vector3 *nr;
+ const Vector3 *nr = NULL;
bool nr_used = false;
if (anormals.size()) {
nr = anormals.ptr();
@@ -749,7 +749,7 @@ CSGBrush *CSGMesh::_build_brush() {
}
Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV];
- const Vector2 *uvr;
+ const Vector2 *uvr = NULL;
bool uvr_used = false;
if (auvs.size()) {
uvr = auvs.ptr();
@@ -862,58 +862,58 @@ CSGBrush *CSGMesh::_build_brush() {
return _create_brush_from_arrays(vertices, uvs, smooth, materials);
}
-void CSGMesh::_mesh_changed() {
+void CSGMesh3D::_mesh_changed() {
_make_dirty();
update_gizmo();
}
-void CSGMesh::set_material(const Ref<Material> &p_material) {
+void CSGMesh3D::set_material(const Ref<Material> &p_material) {
if (material == p_material)
return;
material = p_material;
_make_dirty();
}
-Ref<Material> CSGMesh::get_material() const {
+Ref<Material> CSGMesh3D::get_material() const {
return material;
}
-void CSGMesh::_bind_methods() {
+void CSGMesh3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CSGMesh::set_mesh);
- ClassDB::bind_method(D_METHOD("get_mesh"), &CSGMesh::get_mesh);
+ ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CSGMesh3D::set_mesh);
+ ClassDB::bind_method(D_METHOD("get_mesh"), &CSGMesh3D::get_mesh);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGMesh::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGMesh3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGMesh::set_mesh(const Ref<Mesh> &p_mesh) {
+void CSGMesh3D::set_mesh(const Ref<Mesh> &p_mesh) {
if (mesh == p_mesh)
return;
if (mesh.is_valid()) {
- mesh->disconnect("changed", callable_mp(this, &CSGMesh::_mesh_changed));
+ mesh->disconnect("changed", callable_mp(this, &CSGMesh3D::_mesh_changed));
}
mesh = p_mesh;
if (mesh.is_valid()) {
- mesh->connect("changed", callable_mp(this, &CSGMesh::_mesh_changed));
+ mesh->connect("changed", callable_mp(this, &CSGMesh3D::_mesh_changed));
}
_make_dirty();
}
-Ref<Mesh> CSGMesh::get_mesh() {
+Ref<Mesh> CSGMesh3D::get_mesh() {
return mesh;
}
////////////////////////////////
-CSGBrush *CSGSphere::_build_brush() {
+CSGBrush *CSGSphere3D::_build_brush() {
// set our bounding box
@@ -1032,20 +1032,20 @@ CSGBrush *CSGSphere::_build_brush() {
return brush;
}
-void CSGSphere::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGSphere::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &CSGSphere::get_radius);
+void CSGSphere3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGSphere3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &CSGSphere3D::get_radius);
- ClassDB::bind_method(D_METHOD("set_radial_segments", "radial_segments"), &CSGSphere::set_radial_segments);
- ClassDB::bind_method(D_METHOD("get_radial_segments"), &CSGSphere::get_radial_segments);
- ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CSGSphere::set_rings);
- ClassDB::bind_method(D_METHOD("get_rings"), &CSGSphere::get_rings);
+ ClassDB::bind_method(D_METHOD("set_radial_segments", "radial_segments"), &CSGSphere3D::set_radial_segments);
+ ClassDB::bind_method(D_METHOD("get_radial_segments"), &CSGSphere3D::get_radial_segments);
+ ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CSGSphere3D::set_rings);
+ ClassDB::bind_method(D_METHOD("get_rings"), &CSGSphere3D::get_rings);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGSphere::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGSphere::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGSphere3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGSphere3D::get_smooth_faces);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGSphere::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGSphere::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGSphere3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGSphere3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments");
@@ -1054,7 +1054,7 @@ void CSGSphere::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGSphere::set_radius(const float p_radius) {
+void CSGSphere3D::set_radius(const float p_radius) {
ERR_FAIL_COND(p_radius <= 0);
radius = p_radius;
_make_dirty();
@@ -1062,51 +1062,51 @@ void CSGSphere::set_radius(const float p_radius) {
_change_notify("radius");
}
-float CSGSphere::get_radius() const {
+float CSGSphere3D::get_radius() const {
return radius;
}
-void CSGSphere::set_radial_segments(const int p_radial_segments) {
+void CSGSphere3D::set_radial_segments(const int p_radial_segments) {
radial_segments = p_radial_segments > 4 ? p_radial_segments : 4;
_make_dirty();
update_gizmo();
}
-int CSGSphere::get_radial_segments() const {
+int CSGSphere3D::get_radial_segments() const {
return radial_segments;
}
-void CSGSphere::set_rings(const int p_rings) {
+void CSGSphere3D::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1;
_make_dirty();
update_gizmo();
}
-int CSGSphere::get_rings() const {
+int CSGSphere3D::get_rings() const {
return rings;
}
-void CSGSphere::set_smooth_faces(const bool p_smooth_faces) {
+void CSGSphere3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGSphere::get_smooth_faces() const {
+bool CSGSphere3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGSphere::set_material(const Ref<Material> &p_material) {
+void CSGSphere3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGSphere::get_material() const {
+Ref<Material> CSGSphere3D::get_material() const {
return material;
}
-CSGSphere::CSGSphere() {
+CSGSphere3D::CSGSphere3D() {
// defaults
radius = 1.0;
radial_segments = 12;
@@ -1116,7 +1116,7 @@ CSGSphere::CSGSphere() {
///////////////
-CSGBrush *CSGBox::_build_brush() {
+CSGBrush *CSGBox3D::_build_brush() {
// set our bounding box
@@ -1221,18 +1221,18 @@ CSGBrush *CSGBox::_build_brush() {
return brush;
}
-void CSGBox::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_width", "width"), &CSGBox::set_width);
- ClassDB::bind_method(D_METHOD("get_width"), &CSGBox::get_width);
+void CSGBox3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_width", "width"), &CSGBox3D::set_width);
+ ClassDB::bind_method(D_METHOD("get_width"), &CSGBox3D::get_width);
- ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGBox::set_height);
- ClassDB::bind_method(D_METHOD("get_height"), &CSGBox::get_height);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGBox3D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"), &CSGBox3D::get_height);
- ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGBox::set_depth);
- ClassDB::bind_method(D_METHOD("get_depth"), &CSGBox::get_depth);
+ ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGBox3D::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"), &CSGBox3D::get_depth);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGBox::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGBox3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
@@ -1240,52 +1240,52 @@ void CSGBox::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGBox::set_width(const float p_width) {
+void CSGBox3D::set_width(const float p_width) {
width = p_width;
_make_dirty();
update_gizmo();
_change_notify("width");
}
-float CSGBox::get_width() const {
+float CSGBox3D::get_width() const {
return width;
}
-void CSGBox::set_height(const float p_height) {
+void CSGBox3D::set_height(const float p_height) {
height = p_height;
_make_dirty();
update_gizmo();
_change_notify("height");
}
-float CSGBox::get_height() const {
+float CSGBox3D::get_height() const {
return height;
}
-void CSGBox::set_depth(const float p_depth) {
+void CSGBox3D::set_depth(const float p_depth) {
depth = p_depth;
_make_dirty();
update_gizmo();
_change_notify("depth");
}
-float CSGBox::get_depth() const {
+float CSGBox3D::get_depth() const {
return depth;
}
-void CSGBox::set_material(const Ref<Material> &p_material) {
+void CSGBox3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
update_gizmo();
}
-Ref<Material> CSGBox::get_material() const {
+Ref<Material> CSGBox3D::get_material() const {
return material;
}
-CSGBox::CSGBox() {
+CSGBox3D::CSGBox3D() {
// defaults
width = 2.0;
height = 2.0;
@@ -1294,7 +1294,7 @@ CSGBox::CSGBox() {
///////////////
-CSGBrush *CSGCylinder::_build_brush() {
+CSGBrush *CSGCylinder3D::_build_brush() {
// set our bounding box
@@ -1430,24 +1430,24 @@ CSGBrush *CSGCylinder::_build_brush() {
return brush;
}
-void CSGCylinder::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGCylinder::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &CSGCylinder::get_radius);
+void CSGCylinder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGCylinder3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &CSGCylinder3D::get_radius);
- ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGCylinder::set_height);
- ClassDB::bind_method(D_METHOD("get_height"), &CSGCylinder::get_height);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGCylinder3D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"), &CSGCylinder3D::get_height);
- ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGCylinder::set_sides);
- ClassDB::bind_method(D_METHOD("get_sides"), &CSGCylinder::get_sides);
+ ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGCylinder3D::set_sides);
+ ClassDB::bind_method(D_METHOD("get_sides"), &CSGCylinder3D::get_sides);
- ClassDB::bind_method(D_METHOD("set_cone", "cone"), &CSGCylinder::set_cone);
- ClassDB::bind_method(D_METHOD("is_cone"), &CSGCylinder::is_cone);
+ ClassDB::bind_method(D_METHOD("set_cone", "cone"), &CSGCylinder3D::set_cone);
+ ClassDB::bind_method(D_METHOD("is_cone"), &CSGCylinder3D::is_cone);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGCylinder::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGCylinder::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGCylinder3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGCylinder3D::get_material);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGCylinder::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGCylinder::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGCylinder3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGCylinder3D::get_smooth_faces);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
@@ -1457,70 +1457,70 @@ void CSGCylinder::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGCylinder::set_radius(const float p_radius) {
+void CSGCylinder3D::set_radius(const float p_radius) {
radius = p_radius;
_make_dirty();
update_gizmo();
_change_notify("radius");
}
-float CSGCylinder::get_radius() const {
+float CSGCylinder3D::get_radius() const {
return radius;
}
-void CSGCylinder::set_height(const float p_height) {
+void CSGCylinder3D::set_height(const float p_height) {
height = p_height;
_make_dirty();
update_gizmo();
_change_notify("height");
}
-float CSGCylinder::get_height() const {
+float CSGCylinder3D::get_height() const {
return height;
}
-void CSGCylinder::set_sides(const int p_sides) {
+void CSGCylinder3D::set_sides(const int p_sides) {
ERR_FAIL_COND(p_sides < 3);
sides = p_sides;
_make_dirty();
update_gizmo();
}
-int CSGCylinder::get_sides() const {
+int CSGCylinder3D::get_sides() const {
return sides;
}
-void CSGCylinder::set_cone(const bool p_cone) {
+void CSGCylinder3D::set_cone(const bool p_cone) {
cone = p_cone;
_make_dirty();
update_gizmo();
}
-bool CSGCylinder::is_cone() const {
+bool CSGCylinder3D::is_cone() const {
return cone;
}
-void CSGCylinder::set_smooth_faces(const bool p_smooth_faces) {
+void CSGCylinder3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGCylinder::get_smooth_faces() const {
+bool CSGCylinder3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGCylinder::set_material(const Ref<Material> &p_material) {
+void CSGCylinder3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGCylinder::get_material() const {
+Ref<Material> CSGCylinder3D::get_material() const {
return material;
}
-CSGCylinder::CSGCylinder() {
+CSGCylinder3D::CSGCylinder3D() {
// defaults
radius = 1.0;
height = 1.0;
@@ -1531,7 +1531,7 @@ CSGCylinder::CSGCylinder() {
///////////////
-CSGBrush *CSGTorus::_build_brush() {
+CSGBrush *CSGTorus3D::_build_brush() {
// set our bounding box
@@ -1657,24 +1657,24 @@ CSGBrush *CSGTorus::_build_brush() {
return brush;
}
-void CSGTorus::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_inner_radius", "radius"), &CSGTorus::set_inner_radius);
- ClassDB::bind_method(D_METHOD("get_inner_radius"), &CSGTorus::get_inner_radius);
+void CSGTorus3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_inner_radius", "radius"), &CSGTorus3D::set_inner_radius);
+ ClassDB::bind_method(D_METHOD("get_inner_radius"), &CSGTorus3D::get_inner_radius);
- ClassDB::bind_method(D_METHOD("set_outer_radius", "radius"), &CSGTorus::set_outer_radius);
- ClassDB::bind_method(D_METHOD("get_outer_radius"), &CSGTorus::get_outer_radius);
+ ClassDB::bind_method(D_METHOD("set_outer_radius", "radius"), &CSGTorus3D::set_outer_radius);
+ ClassDB::bind_method(D_METHOD("get_outer_radius"), &CSGTorus3D::get_outer_radius);
- ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGTorus::set_sides);
- ClassDB::bind_method(D_METHOD("get_sides"), &CSGTorus::get_sides);
+ ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGTorus3D::set_sides);
+ ClassDB::bind_method(D_METHOD("get_sides"), &CSGTorus3D::get_sides);
- ClassDB::bind_method(D_METHOD("set_ring_sides", "sides"), &CSGTorus::set_ring_sides);
- ClassDB::bind_method(D_METHOD("get_ring_sides"), &CSGTorus::get_ring_sides);
+ ClassDB::bind_method(D_METHOD("set_ring_sides", "sides"), &CSGTorus3D::set_ring_sides);
+ ClassDB::bind_method(D_METHOD("get_ring_sides"), &CSGTorus3D::get_ring_sides);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGTorus::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGTorus::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGTorus3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGTorus3D::get_material);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGTorus::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGTorus::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGTorus3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGTorus3D::get_smooth_faces);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_inner_radius", "get_inner_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_outer_radius", "get_outer_radius");
@@ -1684,71 +1684,71 @@ void CSGTorus::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGTorus::set_inner_radius(const float p_inner_radius) {
+void CSGTorus3D::set_inner_radius(const float p_inner_radius) {
inner_radius = p_inner_radius;
_make_dirty();
update_gizmo();
_change_notify("inner_radius");
}
-float CSGTorus::get_inner_radius() const {
+float CSGTorus3D::get_inner_radius() const {
return inner_radius;
}
-void CSGTorus::set_outer_radius(const float p_outer_radius) {
+void CSGTorus3D::set_outer_radius(const float p_outer_radius) {
outer_radius = p_outer_radius;
_make_dirty();
update_gizmo();
_change_notify("outer_radius");
}
-float CSGTorus::get_outer_radius() const {
+float CSGTorus3D::get_outer_radius() const {
return outer_radius;
}
-void CSGTorus::set_sides(const int p_sides) {
+void CSGTorus3D::set_sides(const int p_sides) {
ERR_FAIL_COND(p_sides < 3);
sides = p_sides;
_make_dirty();
update_gizmo();
}
-int CSGTorus::get_sides() const {
+int CSGTorus3D::get_sides() const {
return sides;
}
-void CSGTorus::set_ring_sides(const int p_ring_sides) {
+void CSGTorus3D::set_ring_sides(const int p_ring_sides) {
ERR_FAIL_COND(p_ring_sides < 3);
ring_sides = p_ring_sides;
_make_dirty();
update_gizmo();
}
-int CSGTorus::get_ring_sides() const {
+int CSGTorus3D::get_ring_sides() const {
return ring_sides;
}
-void CSGTorus::set_smooth_faces(const bool p_smooth_faces) {
+void CSGTorus3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGTorus::get_smooth_faces() const {
+bool CSGTorus3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGTorus::set_material(const Ref<Material> &p_material) {
+void CSGTorus3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGTorus::get_material() const {
+Ref<Material> CSGTorus3D::get_material() const {
return material;
}
-CSGTorus::CSGTorus() {
+CSGTorus3D::CSGTorus3D() {
// defaults
inner_radius = 2.0;
outer_radius = 3.0;
@@ -1759,7 +1759,7 @@ CSGTorus::CSGTorus() {
///////////////
-CSGBrush *CSGPolygon::_build_brush() {
+CSGBrush *CSGPolygon3D::_build_brush() {
// set our bounding box
@@ -1777,7 +1777,7 @@ CSGBrush *CSGPolygon::_build_brush() {
if (triangles.size() < 3)
return NULL;
- Path *path = NULL;
+ Path3D *path = NULL;
Ref<Curve3D> curve;
// get bounds for our polygon
@@ -1804,21 +1804,21 @@ CSGBrush *CSGPolygon::_build_brush() {
Node *n = get_node(path_node);
if (!n)
return NULL;
- path = Object::cast_to<Path>(n);
+ path = Object::cast_to<Path3D>(n);
if (!path)
return NULL;
if (path != path_cache) {
if (path_cache) {
- path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon::_path_exited));
- path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon::_path_changed));
+ path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
+ path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
path_cache = NULL;
}
path_cache = path;
- path_cache->connect("tree_exited", callable_mp(this, &CSGPolygon::_path_exited));
- path_cache->connect("curve_changed", callable_mp(this, &CSGPolygon::_path_changed));
+ path_cache->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
+ path_cache->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
path_cache = NULL;
}
curve = path->get_curve();
@@ -2231,17 +2231,17 @@ CSGBrush *CSGPolygon::_build_brush() {
return brush;
}
-void CSGPolygon::_notification(int p_what) {
+void CSGPolygon3D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
if (path_cache) {
- path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon::_path_exited));
- path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon::_path_changed));
+ path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
+ path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
path_cache = NULL;
}
}
}
-void CSGPolygon::_validate_property(PropertyInfo &property) const {
+void CSGPolygon3D::_validate_property(PropertyInfo &property) const {
if (property.name.begins_with("spin") && mode != MODE_SPIN) {
property.usage = 0;
}
@@ -2252,60 +2252,60 @@ void CSGPolygon::_validate_property(PropertyInfo &property) const {
property.usage = 0;
}
- CSGShape::_validate_property(property);
+ CSGShape3D::_validate_property(property);
}
-void CSGPolygon::_path_changed() {
+void CSGPolygon3D::_path_changed() {
_make_dirty();
update_gizmo();
}
-void CSGPolygon::_path_exited() {
+void CSGPolygon3D::_path_exited() {
path_cache = NULL;
}
-void CSGPolygon::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CSGPolygon::set_polygon);
- ClassDB::bind_method(D_METHOD("get_polygon"), &CSGPolygon::get_polygon);
+void CSGPolygon3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CSGPolygon3D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"), &CSGPolygon3D::get_polygon);
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &CSGPolygon::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &CSGPolygon::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode", "mode"), &CSGPolygon3D::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"), &CSGPolygon3D::get_mode);
- ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGPolygon::set_depth);
- ClassDB::bind_method(D_METHOD("get_depth"), &CSGPolygon::get_depth);
+ ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGPolygon3D::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"), &CSGPolygon3D::get_depth);
- ClassDB::bind_method(D_METHOD("set_spin_degrees", "degrees"), &CSGPolygon::set_spin_degrees);
- ClassDB::bind_method(D_METHOD("get_spin_degrees"), &CSGPolygon::get_spin_degrees);
+ ClassDB::bind_method(D_METHOD("set_spin_degrees", "degrees"), &CSGPolygon3D::set_spin_degrees);
+ ClassDB::bind_method(D_METHOD("get_spin_degrees"), &CSGPolygon3D::get_spin_degrees);
- ClassDB::bind_method(D_METHOD("set_spin_sides", "spin_sides"), &CSGPolygon::set_spin_sides);
- ClassDB::bind_method(D_METHOD("get_spin_sides"), &CSGPolygon::get_spin_sides);
+ ClassDB::bind_method(D_METHOD("set_spin_sides", "spin_sides"), &CSGPolygon3D::set_spin_sides);
+ ClassDB::bind_method(D_METHOD("get_spin_sides"), &CSGPolygon3D::get_spin_sides);
- ClassDB::bind_method(D_METHOD("set_path_node", "path"), &CSGPolygon::set_path_node);
- ClassDB::bind_method(D_METHOD("get_path_node"), &CSGPolygon::get_path_node);
+ ClassDB::bind_method(D_METHOD("set_path_node", "path"), &CSGPolygon3D::set_path_node);
+ ClassDB::bind_method(D_METHOD("get_path_node"), &CSGPolygon3D::get_path_node);
- ClassDB::bind_method(D_METHOD("set_path_interval", "distance"), &CSGPolygon::set_path_interval);
- ClassDB::bind_method(D_METHOD("get_path_interval"), &CSGPolygon::get_path_interval);
+ ClassDB::bind_method(D_METHOD("set_path_interval", "distance"), &CSGPolygon3D::set_path_interval);
+ ClassDB::bind_method(D_METHOD("get_path_interval"), &CSGPolygon3D::get_path_interval);
- ClassDB::bind_method(D_METHOD("set_path_rotation", "mode"), &CSGPolygon::set_path_rotation);
- ClassDB::bind_method(D_METHOD("get_path_rotation"), &CSGPolygon::get_path_rotation);
+ ClassDB::bind_method(D_METHOD("set_path_rotation", "mode"), &CSGPolygon3D::set_path_rotation);
+ ClassDB::bind_method(D_METHOD("get_path_rotation"), &CSGPolygon3D::get_path_rotation);
- ClassDB::bind_method(D_METHOD("set_path_local", "enable"), &CSGPolygon::set_path_local);
- ClassDB::bind_method(D_METHOD("is_path_local"), &CSGPolygon::is_path_local);
+ ClassDB::bind_method(D_METHOD("set_path_local", "enable"), &CSGPolygon3D::set_path_local);
+ ClassDB::bind_method(D_METHOD("is_path_local"), &CSGPolygon3D::is_path_local);
- ClassDB::bind_method(D_METHOD("set_path_continuous_u", "enable"), &CSGPolygon::set_path_continuous_u);
- ClassDB::bind_method(D_METHOD("is_path_continuous_u"), &CSGPolygon::is_path_continuous_u);
+ ClassDB::bind_method(D_METHOD("set_path_continuous_u", "enable"), &CSGPolygon3D::set_path_continuous_u);
+ ClassDB::bind_method(D_METHOD("is_path_continuous_u"), &CSGPolygon3D::is_path_continuous_u);
- ClassDB::bind_method(D_METHOD("set_path_joined", "enable"), &CSGPolygon::set_path_joined);
- ClassDB::bind_method(D_METHOD("is_path_joined"), &CSGPolygon::is_path_joined);
+ ClassDB::bind_method(D_METHOD("set_path_joined", "enable"), &CSGPolygon3D::set_path_joined);
+ ClassDB::bind_method(D_METHOD("is_path_joined"), &CSGPolygon3D::is_path_joined);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGPolygon::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGPolygon::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGPolygon3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGPolygon3D::get_material);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGPolygon::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGPolygon::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGPolygon3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGPolygon3D::get_smooth_faces);
- ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &CSGPolygon::_is_editable_3d_polygon);
- ClassDB::bind_method(D_METHOD("_has_editable_3d_polygon_no_depth"), &CSGPolygon::_has_editable_3d_polygon_no_depth);
+ ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &CSGPolygon3D::_is_editable_3d_polygon);
+ ClassDB::bind_method(D_METHOD("_has_editable_3d_polygon_no_depth"), &CSGPolygon3D::_has_editable_3d_polygon_no_depth);
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Depth,Spin,Path"), "set_mode", "get_mode");
@@ -2330,148 +2330,148 @@ void CSGPolygon::_bind_methods() {
BIND_ENUM_CONSTANT(PATH_ROTATION_PATH_FOLLOW);
}
-void CSGPolygon::set_polygon(const Vector<Vector2> &p_polygon) {
+void CSGPolygon3D::set_polygon(const Vector<Vector2> &p_polygon) {
polygon = p_polygon;
_make_dirty();
update_gizmo();
}
-Vector<Vector2> CSGPolygon::get_polygon() const {
+Vector<Vector2> CSGPolygon3D::get_polygon() const {
return polygon;
}
-void CSGPolygon::set_mode(Mode p_mode) {
+void CSGPolygon3D::set_mode(Mode p_mode) {
mode = p_mode;
_make_dirty();
update_gizmo();
_change_notify();
}
-CSGPolygon::Mode CSGPolygon::get_mode() const {
+CSGPolygon3D::Mode CSGPolygon3D::get_mode() const {
return mode;
}
-void CSGPolygon::set_depth(const float p_depth) {
+void CSGPolygon3D::set_depth(const float p_depth) {
ERR_FAIL_COND(p_depth < 0.001);
depth = p_depth;
_make_dirty();
update_gizmo();
}
-float CSGPolygon::get_depth() const {
+float CSGPolygon3D::get_depth() const {
return depth;
}
-void CSGPolygon::set_path_continuous_u(bool p_enable) {
+void CSGPolygon3D::set_path_continuous_u(bool p_enable) {
path_continuous_u = p_enable;
_make_dirty();
}
-bool CSGPolygon::is_path_continuous_u() const {
+bool CSGPolygon3D::is_path_continuous_u() const {
return path_continuous_u;
}
-void CSGPolygon::set_spin_degrees(const float p_spin_degrees) {
+void CSGPolygon3D::set_spin_degrees(const float p_spin_degrees) {
ERR_FAIL_COND(p_spin_degrees < 0.01 || p_spin_degrees > 360);
spin_degrees = p_spin_degrees;
_make_dirty();
update_gizmo();
}
-float CSGPolygon::get_spin_degrees() const {
+float CSGPolygon3D::get_spin_degrees() const {
return spin_degrees;
}
-void CSGPolygon::set_spin_sides(const int p_spin_sides) {
+void CSGPolygon3D::set_spin_sides(const int p_spin_sides) {
ERR_FAIL_COND(p_spin_sides < 3);
spin_sides = p_spin_sides;
_make_dirty();
update_gizmo();
}
-int CSGPolygon::get_spin_sides() const {
+int CSGPolygon3D::get_spin_sides() const {
return spin_sides;
}
-void CSGPolygon::set_path_node(const NodePath &p_path) {
+void CSGPolygon3D::set_path_node(const NodePath &p_path) {
path_node = p_path;
_make_dirty();
update_gizmo();
}
-NodePath CSGPolygon::get_path_node() const {
+NodePath CSGPolygon3D::get_path_node() const {
return path_node;
}
-void CSGPolygon::set_path_interval(float p_interval) {
+void CSGPolygon3D::set_path_interval(float p_interval) {
ERR_FAIL_COND_MSG(p_interval < 0.001, "Path interval cannot be smaller than 0.001.");
path_interval = p_interval;
_make_dirty();
update_gizmo();
}
-float CSGPolygon::get_path_interval() const {
+float CSGPolygon3D::get_path_interval() const {
return path_interval;
}
-void CSGPolygon::set_path_rotation(PathRotation p_rotation) {
+void CSGPolygon3D::set_path_rotation(PathRotation p_rotation) {
path_rotation = p_rotation;
_make_dirty();
update_gizmo();
}
-CSGPolygon::PathRotation CSGPolygon::get_path_rotation() const {
+CSGPolygon3D::PathRotation CSGPolygon3D::get_path_rotation() const {
return path_rotation;
}
-void CSGPolygon::set_path_local(bool p_enable) {
+void CSGPolygon3D::set_path_local(bool p_enable) {
path_local = p_enable;
_make_dirty();
update_gizmo();
}
-bool CSGPolygon::is_path_local() const {
+bool CSGPolygon3D::is_path_local() const {
return path_local;
}
-void CSGPolygon::set_path_joined(bool p_enable) {
+void CSGPolygon3D::set_path_joined(bool p_enable) {
path_joined = p_enable;
_make_dirty();
update_gizmo();
}
-bool CSGPolygon::is_path_joined() const {
+bool CSGPolygon3D::is_path_joined() const {
return path_joined;
}
-void CSGPolygon::set_smooth_faces(const bool p_smooth_faces) {
+void CSGPolygon3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGPolygon::get_smooth_faces() const {
+bool CSGPolygon3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGPolygon::set_material(const Ref<Material> &p_material) {
+void CSGPolygon3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGPolygon::get_material() const {
+Ref<Material> CSGPolygon3D::get_material() const {
return material;
}
-bool CSGPolygon::_is_editable_3d_polygon() const {
+bool CSGPolygon3D::_is_editable_3d_polygon() const {
return true;
}
-bool CSGPolygon::_has_editable_3d_polygon_no_depth() const {
+bool CSGPolygon3D::_has_editable_3d_polygon_no_depth() const {
return true;
}
-CSGPolygon::CSGPolygon() {
+CSGPolygon3D::CSGPolygon3D() {
// defaults
mode = MODE_DEPTH;
polygon.push_back(Vector2(0, 0));
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index fdbf979fe7..abab1ded20 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -34,12 +34,12 @@
#define CSGJS_HEADER_ONLY
#include "csg.h"
-#include "scene/3d/visual_instance.h"
-#include "scene/resources/concave_polygon_shape.h"
+#include "scene/3d/visual_instance_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
#include "thirdparty/misc/mikktspace.h"
-class CSGShape : public GeometryInstance {
- GDCLASS(CSGShape, GeometryInstance);
+class CSGShape3D : public GeometryInstance3D {
+ GDCLASS(CSGShape3D, GeometryInstance3D);
public:
enum Operation {
@@ -51,7 +51,7 @@ public:
private:
Operation operation;
- CSGShape *parent;
+ CSGShape3D *parent;
CSGBrush *brush;
@@ -63,7 +63,7 @@ private:
bool use_collision;
uint32_t collision_layer;
uint32_t collision_mask;
- Ref<ConcavePolygonShape> root_collision_shape;
+ Ref<ConcavePolygonShape3D> root_collision_shape;
RID root_collision_instance;
bool calculate_tangents;
@@ -111,7 +111,7 @@ protected:
static void _bind_methods();
- friend class CSGCombiner;
+ friend class CSGCombiner3D;
CSGBrush *_get_brush();
virtual void _validate_property(PropertyInfo &property) const;
@@ -149,24 +149,24 @@ public:
bool is_calculating_tangents() const;
bool is_root_shape() const;
- CSGShape();
- ~CSGShape();
+ CSGShape3D();
+ ~CSGShape3D();
};
-VARIANT_ENUM_CAST(CSGShape::Operation)
+VARIANT_ENUM_CAST(CSGShape3D::Operation)
-class CSGCombiner : public CSGShape {
- GDCLASS(CSGCombiner, CSGShape);
+class CSGCombiner3D : public CSGShape3D {
+ GDCLASS(CSGCombiner3D, CSGShape3D);
private:
virtual CSGBrush *_build_brush();
public:
- CSGCombiner();
+ CSGCombiner3D();
};
-class CSGPrimitive : public CSGShape {
- GDCLASS(CSGPrimitive, CSGShape);
+class CSGPrimitive3D : public CSGShape3D {
+ GDCLASS(CSGPrimitive3D, CSGShape3D);
private:
bool invert_faces;
@@ -179,11 +179,11 @@ public:
void set_invert_faces(bool p_invert);
bool is_inverting_faces();
- CSGPrimitive();
+ CSGPrimitive3D();
};
-class CSGMesh : public CSGPrimitive {
- GDCLASS(CSGMesh, CSGPrimitive);
+class CSGMesh3D : public CSGPrimitive3D {
+ GDCLASS(CSGMesh3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
@@ -203,9 +203,9 @@ public:
Ref<Material> get_material() const;
};
-class CSGSphere : public CSGPrimitive {
+class CSGSphere3D : public CSGPrimitive3D {
- GDCLASS(CSGSphere, CSGPrimitive);
+ GDCLASS(CSGSphere3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -233,12 +233,12 @@ public:
void set_smooth_faces(bool p_smooth_faces);
bool get_smooth_faces() const;
- CSGSphere();
+ CSGSphere3D();
};
-class CSGBox : public CSGPrimitive {
+class CSGBox3D : public CSGPrimitive3D {
- GDCLASS(CSGBox, CSGPrimitive);
+ GDCLASS(CSGBox3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -262,12 +262,12 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGBox();
+ CSGBox3D();
};
-class CSGCylinder : public CSGPrimitive {
+class CSGCylinder3D : public CSGPrimitive3D {
- GDCLASS(CSGCylinder, CSGPrimitive);
+ GDCLASS(CSGCylinder3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -299,12 +299,12 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGCylinder();
+ CSGCylinder3D();
};
-class CSGTorus : public CSGPrimitive {
+class CSGTorus3D : public CSGPrimitive3D {
- GDCLASS(CSGTorus, CSGPrimitive);
+ GDCLASS(CSGTorus3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -336,12 +336,12 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGTorus();
+ CSGTorus3D();
};
-class CSGPolygon : public CSGPrimitive {
+class CSGPolygon3D : public CSGPrimitive3D {
- GDCLASS(CSGPolygon, CSGPrimitive);
+ GDCLASS(CSGPolygon3D, CSGPrimitive3D);
public:
enum Mode {
@@ -431,10 +431,10 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGPolygon();
+ CSGPolygon3D();
};
-VARIANT_ENUM_CAST(CSGPolygon::Mode)
-VARIANT_ENUM_CAST(CSGPolygon::PathRotation)
+VARIANT_ENUM_CAST(CSGPolygon3D::Mode)
+VARIANT_ENUM_CAST(CSGPolygon3D::PathRotation)
#endif // CSG_SHAPE_H
diff --git a/modules/csg/icons/CSGBox.svg b/modules/csg/icons/CSGBox3D.svg
index 67e34df444..67e34df444 100644
--- a/modules/csg/icons/CSGBox.svg
+++ b/modules/csg/icons/CSGBox3D.svg
diff --git a/modules/csg/icons/CSGCapsule.svg b/modules/csg/icons/CSGCapsule3D.svg
index 92a7b5a870..92a7b5a870 100644
--- a/modules/csg/icons/CSGCapsule.svg
+++ b/modules/csg/icons/CSGCapsule3D.svg
diff --git a/modules/csg/icons/CSGCombiner.svg b/modules/csg/icons/CSGCombiner3D.svg
index cce2902e24..cce2902e24 100644
--- a/modules/csg/icons/CSGCombiner.svg
+++ b/modules/csg/icons/CSGCombiner3D.svg
diff --git a/modules/csg/icons/CSGCylinder.svg b/modules/csg/icons/CSGCylinder3D.svg
index 645a74c79b..645a74c79b 100644
--- a/modules/csg/icons/CSGCylinder.svg
+++ b/modules/csg/icons/CSGCylinder3D.svg
diff --git a/modules/csg/icons/CSGMesh.svg b/modules/csg/icons/CSGMesh3D.svg
index 6e940a4aa5..6e940a4aa5 100644
--- a/modules/csg/icons/CSGMesh.svg
+++ b/modules/csg/icons/CSGMesh3D.svg
diff --git a/modules/csg/icons/CSGPolygon.svg b/modules/csg/icons/CSGPolygon3D.svg
index 71b03cb8e6..71b03cb8e6 100644
--- a/modules/csg/icons/CSGPolygon.svg
+++ b/modules/csg/icons/CSGPolygon3D.svg
diff --git a/modules/csg/icons/CSGSphere.svg b/modules/csg/icons/CSGSphere3D.svg
index f81b566993..f81b566993 100644
--- a/modules/csg/icons/CSGSphere.svg
+++ b/modules/csg/icons/CSGSphere3D.svg
diff --git a/modules/csg/icons/CSGTorus.svg b/modules/csg/icons/CSGTorus3D.svg
index 3d30aa47b2..3d30aa47b2 100644
--- a/modules/csg/icons/CSGTorus.svg
+++ b/modules/csg/icons/CSGTorus3D.svg
diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp
index 677a20df38..1a12a6706d 100644
--- a/modules/csg/register_types.cpp
+++ b/modules/csg/register_types.cpp
@@ -37,15 +37,24 @@ void register_csg_types() {
#ifndef _3D_DISABLED
- ClassDB::register_virtual_class<CSGShape>();
- ClassDB::register_virtual_class<CSGPrimitive>();
- ClassDB::register_class<CSGMesh>();
- ClassDB::register_class<CSGSphere>();
- ClassDB::register_class<CSGBox>();
- ClassDB::register_class<CSGCylinder>();
- ClassDB::register_class<CSGTorus>();
- ClassDB::register_class<CSGPolygon>();
- ClassDB::register_class<CSGCombiner>();
+ ClassDB::register_virtual_class<CSGShape3D>();
+ ClassDB::register_virtual_class<CSGPrimitive3D>();
+ ClassDB::register_class<CSGMesh3D>();
+ ClassDB::register_class<CSGSphere3D>();
+ ClassDB::register_class<CSGBox3D>();
+ ClassDB::register_class<CSGCylinder3D>();
+ ClassDB::register_class<CSGTorus3D>();
+ ClassDB::register_class<CSGPolygon3D>();
+ ClassDB::register_class<CSGCombiner3D>();
+
+ ClassDB::add_compatibility_class("CSGShape", "CSGShape3D");
+ ClassDB::add_compatibility_class("CSGMesh", "CSGMesh3D");
+ ClassDB::add_compatibility_class("CSGSphere", "CSGSphere3D");
+ ClassDB::add_compatibility_class("CSGBox", "CSGBox3D");
+ ClassDB::add_compatibility_class("CSGCylinder", "CSGCylinder3D");
+ ClassDB::add_compatibility_class("CSGTorus", "CSGTorus3D");
+ ClassDB::add_compatibility_class("CSGPolygon", "CSGPolygon3D");
+ ClassDB::add_compatibility_class("CSGCombiner", "CSGCombiner3D");
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<EditorPluginCSG>();
diff --git a/modules/csg/register_types.h b/modules/csg/register_types.h
index 4eadeea254..926e598561 100644
--- a/modules/csg/register_types.h
+++ b/modules/csg/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef CSG_REGISTER_TYPES_H
+#define CSG_REGISTER_TYPES_H
+
void register_csg_types();
void unregister_csg_types();
+
+#endif // CSG_REGISTER_TYPES_H
diff --git a/modules/cvtt/register_types.h b/modules/cvtt/register_types.h
index 93f684cdd1..8472980c6a 100644
--- a/modules/cvtt/register_types.h
+++ b/modules/cvtt/register_types.h
@@ -29,6 +29,13 @@
/*************************************************************************/
#ifdef TOOLS_ENABLED
+
+#ifndef CVTT_REGISTER_TYPES_H
+#define CVTT_REGISTER_TYPES_H
+
void register_cvtt_types();
void unregister_cvtt_types();
-#endif
+
+#endif // CVTT_REGISTER_TYPES_H
+
+#endif // TOOLS_ENABLED
diff --git a/modules/dds/register_types.h b/modules/dds/register_types.h
index 1808a4af36..3cb7b5c2a6 100644
--- a/modules/dds/register_types.h
+++ b/modules/dds/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef DDS_REGISTER_TYPES_H
+#define DDS_REGISTER_TYPES_H
+
void register_dds_types();
void unregister_dds_types();
+
+#endif // DDS_REGISTER_TYPES_H
diff --git a/modules/enet/register_types.h b/modules/enet/register_types.h
index 19f8c5a352..cac0a4f7ee 100644
--- a/modules/enet/register_types.h
+++ b/modules/enet/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef ENET_REGISTER_TYPES_H
+#define ENET_REGISTER_TYPES_H
+
void register_enet_types();
void unregister_enet_types();
+
+#endif // ENET_REGISTER_TYPES_H
diff --git a/modules/etc/register_types.h b/modules/etc/register_types.h
index fac83e7d17..247c7213af 100644
--- a/modules/etc/register_types.h
+++ b/modules/etc/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef ETC_REGISTER_TYPES_H
+#define ETC_REGISTER_TYPES_H
+
void register_etc_types();
void unregister_etc_types();
+
+#endif // ETC_REGISTER_TYPES_H
diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub
index 7b66aa1c76..9e1853c4cd 100644
--- a/modules/freetype/SCsub
+++ b/modules/freetype/SCsub
@@ -3,8 +3,6 @@
Import('env')
Import('env_modules')
-from compat import isbasestring
-
env_freetype = env_modules.Clone()
# Thirdparty source files
@@ -93,7 +91,7 @@ if env['builtin_freetype']:
# and then plain strings for system library. We insert between the two.
inserted = False
for idx, linklib in enumerate(env["LIBS"]):
- if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
+ if isinstance(linklib, (str, bytes)): # first system lib such as "X11", otherwise SCons lib object
env["LIBS"].insert(idx, lib)
inserted = True
break
diff --git a/modules/freetype/register_types.h b/modules/freetype/register_types.h
index 336969d079..aa8088d2e8 100644
--- a/modules/freetype/register_types.h
+++ b/modules/freetype/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef FREETYPE_REGISTER_TYPES_H
+#define FREETYPE_REGISTER_TYPES_H
+
void register_freetype_types();
void unregister_freetype_types();
+
+#endif // FREETYPE_REGISTER_TYPES_H
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
index a033c2b7f9..faa891e624 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "arvr_interface_gdnative.h"
-#include "main/input_default.h"
+#include "core/input/input_filter.h"
#include "servers/arvr/arvr_positional_tracker.h"
-#include "servers/visual/visual_server_globals.h"
+#include "servers/rendering/rendering_server_globals.h"
void ARVRInterfaceGDNative::_bind_methods() {
ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
@@ -292,7 +292,7 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re
#warning this needs to be redone
#endif
#if 0
- VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0);
+ RSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0);
#endif
}
@@ -302,13 +302,13 @@ godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
#if 0
RID *render_target = (RID *)p_render_target;
- RID eye_texture = VSG::storage->render_target_get_texture(*render_target);
+ RID eye_texture = RSG::storage->render_target_get_texture(*render_target);
#endif
#ifndef _MSC_VER
#warning need to obtain this ID again
#endif
- uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture);
+ uint32_t texid = 0; //RS::get_singleton()->texture_get_texid(eye_texture);
return texid;
}
@@ -317,7 +317,7 @@ godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand,
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL_V(arvr_server, 0);
- InputDefault *input = (InputDefault *)Input::get_singleton();
+ InputFilter *input = InputFilter::get_singleton();
ERR_FAIL_NULL_V(input, 0);
ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
@@ -356,7 +356,7 @@ void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
- InputDefault *input = (InputDefault *)Input::get_singleton();
+ InputFilter *input = InputFilter::get_singleton();
ERR_FAIL_NULL(input);
ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
@@ -394,7 +394,7 @@ void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
- InputDefault *input = (InputDefault *)Input::get_singleton();
+ InputFilter *input = InputFilter::get_singleton();
ERR_FAIL_NULL(input);
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
@@ -410,14 +410,14 @@ void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
- InputDefault *input = (InputDefault *)Input::get_singleton();
+ InputFilter *input = InputFilter::get_singleton();
ERR_FAIL_NULL(input);
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
if (tracker != NULL) {
int joyid = tracker->get_joy_id();
if (joyid != -1) {
- InputDefault::JoyAxis jx;
+ InputFilter::JoyAxis jx;
jx.min = p_can_be_negative ? -1 : 0;
jx.value = p_value;
input->joy_axis(joyid, p_axis, jx);
diff --git a/modules/gdnative/arvr/register_types.h b/modules/gdnative/arvr/register_types.h
index 815f112fbf..b0de6f7c14 100644
--- a/modules/gdnative/arvr/register_types.h
+++ b/modules/gdnative/arvr/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef ARVR_REGISTER_TYPES_H
+#define ARVR_REGISTER_TYPES_H
+
void register_arvr_types();
void unregister_arvr_types();
+
+#endif // ARVR_REGISTER_TYPES_H
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index db90199e63..9b4c3c794e 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -77,9 +77,9 @@ void GDNativeLibraryEditor::_update_tree() {
platform->set_text(0, E->get().name);
platform->set_metadata(0, E->get().library_extension);
- platform->set_custom_bg_color(0, get_color("prop_category", "Editor"));
- platform->set_custom_bg_color(1, get_color("prop_category", "Editor"));
- platform->set_custom_bg_color(2, get_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(0, get_theme_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(1, get_theme_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(2, get_theme_color("prop_category", "Editor"));
platform->set_selectable(0, false);
platform->set_expand_right(0, true);
@@ -91,31 +91,31 @@ void GDNativeLibraryEditor::_update_tree() {
bit->set_text(0, it->get());
bit->set_metadata(0, target);
bit->set_selectable(0, false);
- bit->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ bit->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
- bit->add_button(1, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry"));
+ bit->add_button(1, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry"));
String file = entry_configs[target].library;
if (!file.empty()) {
- bit->add_button(1, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear"));
+ bit->add_button(1, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear"));
}
bit->set_text(1, file);
- bit->add_button(2, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry"));
+ bit->add_button(2, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry"));
Array files = entry_configs[target].dependencies;
if (files.size()) {
- bit->add_button(2, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear"));
+ bit->add_button(2, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear"));
}
bit->set_text(2, Variant(files));
- bit->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up"));
- bit->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down"));
- bit->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
+ bit->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up"));
+ bit->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down"));
+ bit->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
}
TreeItem *new_arch = tree->create_item(platform);
new_arch->set_text(0, TTR("Double click to create a new entry"));
new_arch->set_text_align(0, TreeItem::ALIGN_CENTER);
- new_arch->set_custom_color(0, get_color("accent_color", "Editor"));
+ new_arch->set_custom_color(0, get_theme_color("accent_color", "Editor"));
new_arch->set_expand_right(0, true);
new_arch->set_metadata(1, E->key());
@@ -133,15 +133,15 @@ void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) {
- EditorFileDialog::Mode mode = EditorFileDialog::MODE_OPEN_FILE;
+ EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE;
if (id == BUTTON_SELECT_DEPENDENCES)
- mode = EditorFileDialog::MODE_OPEN_FILES;
+ mode = EditorFileDialog::FILE_MODE_OPEN_FILES;
file_dialog->set_meta("target", target);
file_dialog->set_meta("section", section);
file_dialog->clear_filters();
file_dialog->add_filter(Object::cast_to<TreeItem>(item)->get_parent()->get_metadata(0));
- file_dialog->set_mode(mode);
+ file_dialog->set_file_mode(mode);
file_dialog->popup_centered_ratio();
} else if (id == BUTTON_CLEAR_LIBRARY) {
@@ -372,7 +372,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
file_dialog = memnew(EditorFileDialog);
file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
- file_dialog->set_resizable(true);
+ //file_dialog->set_resizable(true);
add_child(file_dialog);
file_dialog->connect("file_selected", callable_mp(this, &GDNativeLibraryEditor::_on_library_selected));
file_dialog->connect("files_selected", callable_mp(this, &GDNativeLibraryEditor::_on_dependencies_selected));
@@ -382,7 +382,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
new_architecture_dialog->set_title(TTR("Add an architecture entry"));
new_architecture_input = memnew(LineEdit);
new_architecture_dialog->add_child(new_architecture_input);
- new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
+ // new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
new_architecture_input->set_anchors_and_margins_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE);
new_architecture_dialog->get_ok()->connect("pressed", callable_mp(this, &GDNativeLibraryEditor::_on_create_new_entry));
}
diff --git a/modules/gdnative/nativescript/SCsub b/modules/gdnative/nativescript/SCsub
index 92c9d6630d..c28a1c8659 100644
--- a/modules/gdnative/nativescript/SCsub
+++ b/modules/gdnative/nativescript/SCsub
@@ -5,5 +5,5 @@ Import('env_gdnative')
env_gdnative.add_source_files(env.modules_sources, '*.cpp')
-if "platform" in env and env["platform"] in ["x11", "iphone"]:
+if "platform" in env and env["platform"] in ["linuxbsd", "iphone"]:
env.Append(LINKFLAGS=["-rdynamic"])
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index fb88479ca3..80aebaccd1 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -1827,7 +1827,7 @@ void NativeReloadNode::_notification(int p_what) {
#ifdef TOOLS_ENABLED
switch (p_what) {
- case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_WM_FOCUS_OUT: {
if (unloaded)
break;
@@ -1862,7 +1862,7 @@ void NativeReloadNode::_notification(int p_what) {
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
if (!unloaded)
break;
diff --git a/modules/gdnative/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h
index 8fcecb9836..088bf38dd5 100644
--- a/modules/gdnative/nativescript/register_types.h
+++ b/modules/gdnative/nativescript/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef NATIVESCRIPT_REGISTER_TYPES_H
+#define NATIVESCRIPT_REGISTER_TYPES_H
+
void register_nativescript_types();
void unregister_nativescript_types();
+
+#endif // NATIVESCRIPT_REGISTER_TYPES_H
diff --git a/modules/gdnative/net/register_types.h b/modules/gdnative/net/register_types.h
index 526bc49deb..70b266f9b9 100644
--- a/modules/gdnative/net/register_types.h
+++ b/modules/gdnative/net/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef NET_REGISTER_TYPES_H
+#define NET_REGISTER_TYPES_H
+
void register_net_types();
void unregister_net_types();
+
+#endif // NET_REGISTER_TYPES_H
diff --git a/modules/gdnative/pluginscript/register_types.h b/modules/gdnative/pluginscript/register_types.h
index a4f7284b54..c6a64b4f40 100644
--- a/modules/gdnative/pluginscript/register_types.h
+++ b/modules/gdnative/pluginscript/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef PLUGINSCRIPT_REGISTER_TYPES_H
+#define PLUGINSCRIPT_REGISTER_TYPES_H
+
void register_pluginscript_types();
void unregister_pluginscript_types();
+
+#endif // PLUGINSCRIPT_REGISTER_TYPES_H
diff --git a/modules/gdnative/register_types.h b/modules/gdnative/register_types.h
index 0091ef3f96..b5c182f8b7 100644
--- a/modules/gdnative/register_types.h
+++ b/modules/gdnative/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef GDNATIVE_REGISTER_TYPES_H
+#define GDNATIVE_REGISTER_TYPES_H
+
void register_gdnative_types();
void unregister_gdnative_types();
+
+#endif // GDNATIVE_REGISTER_TYPES_H
diff --git a/modules/gdnative/videodecoder/register_types.h b/modules/gdnative/videodecoder/register_types.h
index d81d5c497b..b1a83d4071 100644
--- a/modules/gdnative/videodecoder/register_types.h
+++ b/modules/gdnative/videodecoder/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef VIDEODECODER_REGISTER_TYPES_H
+#define VIDEODECODER_REGISTER_TYPES_H
+
void register_videodecoder_types();
void unregister_videodecoder_types();
+
+#endif // VIDEODECODER_REGISTER_TYPES_H
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp
index a1f6ddfedc..cade6c8a6d 100644
--- a/modules/gdnavigation/gd_navigation_server.cpp
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -114,7 +114,7 @@
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
GdNavigationServer::GdNavigationServer() :
- NavigationServer(),
+ NavigationServer3D(),
active(true) {
}
diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h
index e9f5c1ffe6..01d1a4fba9 100644
--- a/modules/gdnavigation/gd_navigation_server.h
+++ b/modules/gdnavigation/gd_navigation_server.h
@@ -33,7 +33,7 @@
#include "core/rid.h"
#include "core/rid_owner.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#include "nav_map.h"
#include "nav_region.h"
@@ -67,7 +67,7 @@ struct SetCommand {
virtual void exec(GdNavigationServer *server) = 0;
};
-class GdNavigationServer : public NavigationServer {
+class GdNavigationServer : public NavigationServer3D {
Mutex commands_mutex;
/// Mutex used to make any operation threadsafe.
Mutex operations_mutex;
diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h
index d99254d1ad..f35ee4bea0 100644
--- a/modules/gdnavigation/nav_region.h
+++ b/modules/gdnavigation/nav_region.h
@@ -34,7 +34,7 @@
#include "nav_rid.h"
#include "nav_utils.h"
-#include "scene/3d/navigation.h"
+#include "scene/3d/navigation_3d.h"
#include <vector>
/**
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
index e6ff7a7afa..6238acfdc5 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
@@ -34,7 +34,7 @@
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
#include "navigation_mesh_generator.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h"
void NavigationMeshEditor::_node_removed(Node *p_node) {
@@ -50,8 +50,8 @@ void NavigationMeshEditor::_notification(int p_option) {
if (p_option == NOTIFICATION_ENTER_TREE) {
- button_bake->set_icon(get_icon("Bake", "EditorIcons"));
- button_reset->set_icon(get_icon("Reload", "EditorIcons"));
+ button_bake->set_icon(get_theme_icon("Bake", "EditorIcons"));
+ button_reset->set_icon(get_theme_icon("Reload", "EditorIcons"));
}
}
@@ -61,7 +61,7 @@ void NavigationMeshEditor::_bake_pressed() {
ERR_FAIL_COND(!node);
if (!node->get_navigation_mesh().is_valid()) {
err_dialog->set_text(TTR("A NavigationMesh resource must be set or created for this node to work."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -84,7 +84,7 @@ void NavigationMeshEditor::_clear_pressed() {
}
}
-void NavigationMeshEditor::edit(NavigationRegion *p_nav_region) {
+void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) {
if (p_nav_region == NULL || node == p_nav_region) {
return;
@@ -125,12 +125,12 @@ NavigationMeshEditor::~NavigationMeshEditor() {
void NavigationMeshEditorPlugin::edit(Object *p_object) {
- navigation_mesh_editor->edit(Object::cast_to<NavigationRegion>(p_object));
+ navigation_mesh_editor->edit(Object::cast_to<NavigationRegion3D>(p_object));
}
bool NavigationMeshEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("NavigationRegion");
+ return p_object->is_class("NavigationRegion3D");
}
void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h
index 847ad4f63d..434981c9e0 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.h
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h
@@ -36,7 +36,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-class NavigationRegion;
+class NavigationRegion3D;
class NavigationMeshEditor : public Control {
friend class NavigationMeshEditorPlugin;
@@ -50,7 +50,7 @@ class NavigationMeshEditor : public Control {
ToolButton *button_reset;
Label *bake_info;
- NavigationRegion *node;
+ NavigationRegion3D *node;
void _bake_pressed();
void _clear_pressed();
@@ -61,7 +61,7 @@ protected:
void _notification(int p_option);
public:
- void edit(NavigationRegion *p_nav_region);
+ void edit(NavigationRegion3D *p_nav_region);
NavigationMeshEditor();
~NavigationMeshEditor();
};
diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index e7038b38a2..ec19c7b8a3 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -34,18 +34,18 @@
#include "core/math/quick_hull.h"
#include "core/os/thread.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/physics_body.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/cylinder_shape.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/resources/box_shape_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/cylinder_shape_3d.h"
#include "scene/resources/primitive_meshes.h"
-#include "scene/resources/shape.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/world_margin_shape.h"
+#include "scene/resources/shape_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
+#include "scene/resources/world_margin_shape_3d.h"
#include "modules/modules_enabled.gen.h"
#ifdef TOOLS_ENABLED
@@ -140,9 +140,9 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
- if (Object::cast_to<MeshInstance>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
- MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh();
if (mesh.is_valid()) {
_add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_verticies, p_indices);
@@ -150,9 +150,9 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#ifdef MODULE_CSG_ENABLED
- if (Object::cast_to<CSGShape>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
- CSGShape *csg_shape = Object::cast_to<CSGShape>(p_node);
+ CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);
Array meshes = csg_shape->get_meshes();
if (!meshes.empty()) {
Ref<Mesh> mesh = meshes[1];
@@ -163,22 +163,22 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#endif
- if (Object::cast_to<StaticBody>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
- StaticBody *static_body = Object::cast_to<StaticBody>(p_node);
+ if (Object::cast_to<StaticBody3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
+ StaticBody3D *static_body = Object::cast_to<StaticBody3D>(p_node);
if (static_body->get_collision_layer() & p_collision_mask) {
for (int i = 0; i < p_node->get_child_count(); ++i) {
Node *child = p_node->get_child(i);
- if (Object::cast_to<CollisionShape>(child)) {
- CollisionShape *col_shape = Object::cast_to<CollisionShape>(child);
+ if (Object::cast_to<CollisionShape3D>(child)) {
+ CollisionShape3D *col_shape = Object::cast_to<CollisionShape3D>(child);
Transform transform = p_accumulated_transform * static_body->get_transform() * col_shape->get_transform();
Ref<Mesh> mesh;
- Ref<Shape> s = col_shape->get_shape();
+ Ref<Shape3D> s = col_shape->get_shape();
- BoxShape *box = Object::cast_to<BoxShape>(*s);
+ BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) {
Ref<CubeMesh> cube_mesh;
cube_mesh.instance();
@@ -186,7 +186,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = cube_mesh;
}
- CapsuleShape *capsule = Object::cast_to<CapsuleShape>(*s);
+ CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s);
if (capsule) {
Ref<CapsuleMesh> capsule_mesh;
capsule_mesh.instance();
@@ -195,7 +195,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = capsule_mesh;
}
- CylinderShape *cylinder = Object::cast_to<CylinderShape>(*s);
+ CylinderShape3D *cylinder = Object::cast_to<CylinderShape3D>(*s);
if (cylinder) {
Ref<CylinderMesh> cylinder_mesh;
cylinder_mesh.instance();
@@ -205,7 +205,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = cylinder_mesh;
}
- SphereShape *sphere = Object::cast_to<SphereShape>(*s);
+ SphereShape3D *sphere = Object::cast_to<SphereShape3D>(*s);
if (sphere) {
Ref<SphereMesh> sphere_mesh;
sphere_mesh.instance();
@@ -214,12 +214,12 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = sphere_mesh;
}
- ConcavePolygonShape *concave_polygon = Object::cast_to<ConcavePolygonShape>(*s);
+ ConcavePolygonShape3D *concave_polygon = Object::cast_to<ConcavePolygonShape3D>(*s);
if (concave_polygon) {
_add_faces(concave_polygon->get_faces(), transform, p_verticies, p_indices);
}
- ConvexPolygonShape *convex_polygon = Object::cast_to<ConvexPolygonShape>(*s);
+ ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s);
if (convex_polygon) {
Vector<Vector3> varr = Variant(convex_polygon->get_points());
Geometry::MeshData md;
@@ -265,8 +265,8 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#endif
- if (Object::cast_to<Spatial>(p_node)) {
- Spatial *spatial = Object::cast_to<Spatial>(p_node);
+ if (Object::cast_to<Node3D>(p_node)) {
+ Node3D *spatial = Object::cast_to<Node3D>(p_node);
p_accumulated_transform = p_accumulated_transform * spatial->get_transform();
}
@@ -505,7 +505,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
p_node->get_tree()->get_nodes_in_group(p_nav_mesh->get_source_group_name(), &parse_nodes);
}
- Transform navmesh_xform = Object::cast_to<Spatial>(p_node)->get_transform().affine_inverse();
+ Transform navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse();
for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) {
int geometry_type = p_nav_mesh->get_parsed_geometry_type();
uint32_t collision_mask = p_nav_mesh->get_collision_mask();
diff --git a/modules/gdnavigation/navigation_mesh_generator.h b/modules/gdnavigation/navigation_mesh_generator.h
index d1f2e4b56f..c5f7b2ab81 100644
--- a/modules/gdnavigation/navigation_mesh_generator.h
+++ b/modules/gdnavigation/navigation_mesh_generator.h
@@ -33,7 +33,7 @@
#ifndef _3D_DISABLED
-#include "scene/3d/navigation_region.h"
+#include "scene/3d/navigation_region_3d.h"
#include <Recast.h>
diff --git a/modules/gdnavigation/register_types.cpp b/modules/gdnavigation/register_types.cpp
index d717733787..9965a89fde 100644
--- a/modules/gdnavigation/register_types.cpp
+++ b/modules/gdnavigation/register_types.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "gd_navigation_server.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#ifndef _3D_DISABLED
#include "navigation_mesh_generator.h"
@@ -50,12 +50,12 @@
NavigationMeshGenerator *_nav_mesh_generator = NULL;
#endif
-NavigationServer *new_server() {
+NavigationServer3D *new_server() {
return memnew(GdNavigationServer);
}
void register_gdnavigation_types() {
- NavigationServerManager::set_default_server(new_server);
+ NavigationServer3DManager::set_default_server(new_server);
#ifndef _3D_DISABLED
_nav_mesh_generator = memnew(NavigationMeshGenerator);
diff --git a/modules/gdnavigation/register_types.h b/modules/gdnavigation/register_types.h
index bd15eaaada..cdbff1b937 100644
--- a/modules/gdnavigation/register_types.h
+++ b/modules/gdnavigation/register_types.h
@@ -32,5 +32,10 @@
@author AndreaCatania
*/
+#ifndef GDNAVIGATION_REGISTER_TYPES_H
+#define GDNAVIGATION_REGISTER_TYPES_H
+
void register_gdnavigation_types();
void unregister_gdnavigation_types();
+
+#endif // GDNAVIGATION_REGISTER_TYPES_H
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index 687e1785be..0aca4dbc5e 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -358,11 +358,11 @@ List<String> GDScriptSyntaxHighlighter::get_supported_languages() {
}
void GDScriptSyntaxHighlighter::_update_cache() {
- font_color = text_editor->get_color("font_color");
- symbol_color = text_editor->get_color("symbol_color");
- function_color = text_editor->get_color("function_color");
- number_color = text_editor->get_color("number_color");
- member_color = text_editor->get_color("member_variable_color");
+ font_color = text_editor->get_theme_color("font_color");
+ symbol_color = text_editor->get_theme_color("symbol_color");
+ function_color = text_editor->get_theme_color("function_color");
+ number_color = text_editor->get_theme_color("number_color");
+ member_color = text_editor->get_theme_color("member_variable_color");
const String text_editor_color_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme");
const bool default_theme = text_editor_color_theme == "Default";
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index d5723fd20f..fbf8ef2f8f 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -35,6 +35,7 @@
#include "editor/plugins/script_text_editor.h"
#include "gdscript_extend_parser.h"
#include "gdscript_language_protocol.h"
+#include "servers/display_server.h"
void GDScriptTextDocument::_bind_methods() {
ClassDB::bind_method(D_METHOD("didOpen"), &GDScriptTextDocument::didOpen);
@@ -419,7 +420,8 @@ void GDScriptTextDocument::sync_script_content(const String &p_path, const Strin
void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) {
ScriptEditor::get_singleton()->call_deferred("_help_class_goto", p_symbol_id);
- OS::get_singleton()->move_window_to_foreground();
+
+ DisplayServer::get_singleton()->window_move_to_foreground();
}
Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams &p_location, List<const lsp::DocumentSymbol *> &r_list) {
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index a2dcc48820..914c9742e1 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -33,7 +33,7 @@
#include "core/class_db.h"
#include "core/list.h"
-#include "editor/doc/doc_data.h"
+#include "editor/doc_data.h"
namespace lsp {
diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h
index 55920e8b97..18e57c1211 100644
--- a/modules/gdscript/register_types.h
+++ b/modules/gdscript/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef GDSCRIPT_REGISTER_TYPES_H
+#define GDSCRIPT_REGISTER_TYPES_H
+
void register_gdscript_types();
void unregister_gdscript_types();
+
+#endif // GDSCRIPT_REGISTER_TYPES_H
diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp
index d2b4a18fc7..2540ba476c 100644
--- a/modules/glslang/register_types.cpp
+++ b/modules/glslang/register_types.cpp
@@ -30,7 +30,7 @@
#include "register_types.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rendering_device.h"
#include <SPIRV/GlslangToSpv.h>
#include <glslang/Include/Types.h>
diff --git a/modules/glslang/register_types.h b/modules/glslang/register_types.h
index 37a1ef67f2..2437e2b27a 100644
--- a/modules/glslang/register_types.h
+++ b/modules/glslang/register_types.h
@@ -28,7 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef GLSLANG_REGISTER_TYPES_H
+#define GLSLANG_REGISTER_TYPES_H
+
#define MODULE_GLSLANG_HAS_PREREGISTER
+
void preregister_glslang_types();
void register_glslang_types();
void unregister_glslang_types();
+
+#endif // GLSLANG_REGISTER_TYPES_H
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 7273a014f0..35c214d3cf 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -32,12 +32,12 @@
#include "core/io/marshalls.h"
#include "core/message_queue.h"
-#include "scene/3d/light.h"
+#include "scene/3d/light_3d.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/surface_tool.h"
#include "scene/scene_string_names.h"
-#include "servers/navigation_server.h"
-#include "servers/visual_server.h"
+#include "servers/navigation_server_3d.h"
+#include "servers/rendering_server.h"
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
@@ -76,12 +76,12 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
BakedMesh bm;
bm.mesh = meshes[i];
ERR_CONTINUE(!bm.mesh.is_valid());
- bm.instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
- VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
+ bm.instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
+ RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
}
baked_meshes.push_back(bm);
}
@@ -306,17 +306,17 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
//create octant because it does not exist
Octant *g = memnew(Octant);
g->dirty = true;
- g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
- PhysicsServer::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
- PhysicsServer::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
+ g->static_body = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_collisions_hint()) {
- g->collision_debug = VisualServer::get_singleton()->mesh_create();
- g->collision_debug_instance = VisualServer::get_singleton()->instance_create();
- VisualServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
+ g->collision_debug = RenderingServer::get_singleton()->mesh_create();
+ g->collision_debug_instance = RenderingServer::get_singleton()->instance_create();
+ RenderingServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
}
octant_map[octantkey] = g;
@@ -392,14 +392,14 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
+ RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
}
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
}
@@ -410,17 +410,17 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
return false;
//erase body shapes
- PhysicsServer::get_singleton()->body_clear_shapes(g.static_body);
+ PhysicsServer3D::get_singleton()->body_clear_shapes(g.static_body);
//erase body shapes debug
if (g.collision_debug.is_valid()) {
- VS::get_singleton()->mesh_clear(g.collision_debug);
+ RS::get_singleton()->mesh_clear(g.collision_debug);
}
//erase navigation
for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- NavigationServer::get_singleton()->free(E->get().region);
+ NavigationServer3D::get_singleton()->free(E->get().region);
}
g.navmesh_ids.clear();
@@ -428,8 +428,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->free(g.multimesh_instances[i].instance);
- VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ RS::get_singleton()->free(g.multimesh_instances[i].instance);
+ RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
g.multimesh_instances.clear();
@@ -484,7 +484,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
// add the item's shape
if (!shapes[i].shape.is_valid())
continue;
- PhysicsServer::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
+ PhysicsServer3D::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
if (g.collision_debug.is_valid()) {
shapes.write[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform);
}
@@ -497,10 +497,10 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item);
if (navigation) {
- RID region = NavigationServer::get_singleton()->region_create();
- NavigationServer::get_singleton()->region_set_navmesh(region, navmesh);
- NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform);
- NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ RID region = NavigationServer3D::get_singleton()->region_create();
+ NavigationServer3D::get_singleton()->region_set_navmesh(region, navmesh);
+ NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform);
+ NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
nm.region = region;
}
g.navmesh_ids[E->get()] = nm;
@@ -513,13 +513,13 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
for (Map<int, List<Pair<Transform, IndexKey>>>::Element *E = multimesh_items.front(); E; E = E->next()) {
Octant::MultimeshInstance mmi;
- RID mm = VS::get_singleton()->multimesh_create();
- VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D);
- VS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid());
+ RID mm = RS::get_singleton()->multimesh_create();
+ RS::get_singleton()->multimesh_allocate(mm, E->get().size(), RS::MULTIMESH_TRANSFORM_3D);
+ RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid());
int idx = 0;
for (List<Pair<Transform, IndexKey>>::Element *F = E->get().front(); F; F = F->next()) {
- VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
+ RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
#ifdef TOOLS_ENABLED
Octant::MultimeshInstance::Item it;
@@ -532,12 +532,12 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
idx++;
}
- RID instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(instance, mm);
+ RID instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(instance, mm);
if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(instance, get_global_transform());
}
mmi.multimesh = mm;
@@ -550,13 +550,13 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
if (col_debug.size()) {
Array arr;
- arr.resize(VS::ARRAY_MAX);
- arr[VS::ARRAY_VERTEX] = col_debug;
+ arr.resize(RS::ARRAY_MAX);
+ arr[RS::ARRAY_VERTEX] = col_debug;
- VS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, VS::PRIMITIVE_LINES, arr);
+ RS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, RS::PRIMITIVE_LINES, arr);
SceneTree *st = SceneTree::get_singleton();
if (st) {
- VS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid());
+ RS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid());
}
}
@@ -567,8 +567,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
void GridMap::_reset_physic_bodies_collision_filters() {
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- PhysicsServer::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer);
- PhysicsServer::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask);
}
}
@@ -576,17 +576,17 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
}
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
if (navigation && mesh_library.is_valid()) {
@@ -595,10 +595,10 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (cell_map.has(F->key()) && F->get().region.is_valid() == false) {
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item);
if (nm.is_valid()) {
- RID region = NavigationServer::get_singleton()->region_create();
- NavigationServer::get_singleton()->region_set_navmesh(region, nm);
- NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform);
- NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ RID region = NavigationServer3D::get_singleton()->region_create();
+ NavigationServer3D::get_singleton()->region_set_navmesh(region, nm);
+ NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform);
+ NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
F->get().region = region;
}
}
@@ -610,23 +610,23 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_set_space(g.static_body, RID());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_space(g.static_body, RID());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
+ RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
+ RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
}
if (navigation) {
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
if (F->get().region.is_valid()) {
- NavigationServer::get_singleton()->free(F->get().region);
+ NavigationServer3D::get_singleton()->free(F->get().region);
F->get().region = RID();
}
}
@@ -639,15 +639,15 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
Octant &g = *octant_map[p_key];
if (g.collision_debug.is_valid())
- VS::get_singleton()->free(g.collision_debug);
+ RS::get_singleton()->free(g.collision_debug);
if (g.collision_debug_instance.is_valid())
- VS::get_singleton()->free(g.collision_debug_instance);
+ RS::get_singleton()->free(g.collision_debug_instance);
- PhysicsServer::get_singleton()->free(g.static_body);
+ PhysicsServer3D::get_singleton()->free(g.static_body);
// Erase navigation
for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- NavigationServer::get_singleton()->free(E->get().region);
+ NavigationServer3D::get_singleton()->free(E->get().region);
}
g.navmesh_ids.clear();
@@ -655,8 +655,8 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->free(g.multimesh_instances[i].instance);
- VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ RS::get_singleton()->free(g.multimesh_instances[i].instance);
+ RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
g.multimesh_instances.clear();
}
@@ -667,14 +667,14 @@ void GridMap::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- Spatial *c = this;
+ Node3D *c = this;
while (c) {
- navigation = Object::cast_to<Navigation>(c);
+ navigation = Object::cast_to<Navigation3D>(c);
if (navigation) {
break;
}
- c = Object::cast_to<Spatial>(c->get_parent());
+ c = Object::cast_to<Node3D>(c->get_parent());
}
last_transform = get_global_transform();
@@ -684,8 +684,8 @@ void GridMap::_notification(int p_what) {
}
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
}
} break;
@@ -702,7 +702,7 @@ void GridMap::_notification(int p_what) {
last_transform = new_xform;
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
}
} break;
@@ -718,7 +718,7 @@ void GridMap::_notification(int p_what) {
//_update_octants_callback();
//_update_area_instances();
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
+ RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
}
} break;
@@ -738,7 +738,7 @@ void GridMap::_update_visibility() {
Octant *octant = e->value();
for (int i = 0; i < octant->multimesh_instances.size(); i++) {
const Octant::MultimeshInstance &mi = octant->multimesh_instances[i];
- VS::get_singleton()->instance_set_visible(mi.instance, is_visible());
+ RS::get_singleton()->instance_set_visible(mi.instance, is_visible());
}
}
}
@@ -975,7 +975,7 @@ Vector3 GridMap::_get_offset() const {
void GridMap::clear_baked_meshes() {
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->free(baked_meshes[i].instance);
+ RS::get_singleton()->free(baked_meshes[i].instance);
}
baked_meshes.clear();
@@ -1050,12 +1050,12 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
BakedMesh bm;
bm.mesh = mesh;
- bm.instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
- VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
+ bm.instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
+ RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
}
if (p_gen_lightmap_uv) {
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index cc1c8c2923..3f3da09fe9 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -31,17 +31,17 @@
#ifndef GRID_MAP_H
#define GRID_MAP_H
-#include "scene/3d/navigation.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/navigation_3d.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/multimesh.h"
//heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done..
//should scale better with hardware that supports instancing
-class GridMap : public Spatial {
+class GridMap : public Node3D {
- GDCLASS(GridMap, Spatial);
+ GDCLASS(GridMap, Node3D);
enum {
MAP_DIRTY_TRANSFORMS = 1,
@@ -147,7 +147,7 @@ class GridMap : public Spatial {
int octant_size;
bool center_x, center_y, center_z;
float cell_scale;
- Navigation *navigation;
+ Navigation3D *navigation;
bool clip;
bool clip_above;
@@ -166,10 +166,10 @@ class GridMap : public Spatial {
struct BakeLight {
- VS::LightType type;
+ RS::LightType type;
Vector3 pos;
Vector3 dir;
- float param[VS::LIGHT_PARAM_MAX];
+ float param[RS::LIGHT_PARAM_MAX];
};
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index a656ee8b63..4a6cb8762f 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -29,14 +29,15 @@
/*************************************************************************/
#include "grid_map_editor_plugin.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/3d/camera.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
+#include "scene/3d/camera_3d.h"
#include "core/math/geometry.h"
#include "core/os/keyboard.h"
+#include "scene/main/window.h"
void GridMapEditor::_node_removed(Node *p_node) {
@@ -280,8 +281,8 @@ void GridMapEditor::_update_cursor_transform() {
cursor_transform = node->get_global_transform() * cursor_transform;
if (cursor_instance.is_valid()) {
- VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
- VisualServer::get_singleton()->instance_set_visible(cursor_instance, cursor_visible);
+ RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
+ RenderingServer::get_singleton()->instance_set_visible(cursor_instance, cursor_visible);
}
}
@@ -291,9 +292,9 @@ void GridMapEditor::_update_selection_transform() {
if (!selection.active) {
- VisualServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
+ RenderingServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
}
return;
}
@@ -302,11 +303,11 @@ void GridMapEditor::_update_selection_transform() {
xf.scale((Vector3(1, 1, 1) + (selection.end - selection.begin)) * node->get_cell_size());
xf.origin = selection.begin * node->get_cell_size();
- VisualServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf);
+ RenderingServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf);
for (int i = 0; i < 3; i++) {
if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) {
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
} else {
Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1));
@@ -321,7 +322,7 @@ void GridMapEditor::_update_selection_transform() {
xf2.basis.scale(scale);
xf2.origin = pos;
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
+ RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
}
}
}
@@ -361,7 +362,7 @@ void GridMapEditor::_set_selection(bool p_active, const Vector3 &p_begin, const
options->get_popup()->set_item_disabled(options->get_popup()->get_item_index(MENU_OPTION_SELECTION_FILL), !selection.active);
}
-bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
+bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, bool p_click) {
if (!spatial_editor)
return false;
@@ -374,7 +375,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
if (input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE && !mesh_library->has_item(selected_palette))
return false;
- Camera *camera = p_camera;
+ Camera3D *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point);
Vector3 normal = camera->project_ray_normal(p_point);
Transform local_xform = node->get_global_transform().affine_inverse();
@@ -415,7 +416,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
}
}
- VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
+ RS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
if (cursor_instance.is_valid()) {
@@ -527,7 +528,7 @@ void GridMapEditor::_clear_clipboard_data() {
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
- VisualServer::get_singleton()->free(E->get().instance);
+ RenderingServer::get_singleton()->free(E->get().instance);
}
clipboard_items.clear();
@@ -555,7 +556,7 @@ void GridMapEditor::_set_clipboard_data() {
item.cell_item = itm;
item.grid_offset = Vector3(i, j, k) - selection.begin;
item.orientation = node->get_cell_item_orientation(i, j, k);
- item.instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
+ item.instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
clipboard_items.push_back(item);
}
@@ -569,7 +570,7 @@ void GridMapEditor::_update_paste_indicator() {
Transform xf;
xf.basis.set_zero();
- VisualServer::get_singleton()->instance_set_transform(paste_instance, xf);
+ RenderingServer::get_singleton()->instance_set_transform(paste_instance, xf);
return;
}
@@ -583,7 +584,7 @@ void GridMapEditor::_update_paste_indicator() {
xf.basis = rot * xf.basis;
xf.translate((-center * node->get_cell_size()) / scale);
- VisualServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf);
+ RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf);
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
@@ -598,7 +599,7 @@ void GridMapEditor::_update_paste_indicator() {
item_rot.set_orthogonal_index(item.orientation);
xf.basis = item_rot * xf.basis * node->get_cell_scale();
- VisualServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf);
+ RenderingServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf);
}
}
@@ -638,7 +639,7 @@ void GridMapEditor::_do_paste() {
_clear_clipboard_data();
}
-bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!node) {
return false;
}
@@ -659,8 +660,8 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
}
if (mb->is_pressed()) {
- SpatialEditorViewport::NavigationScheme nav_scheme = (SpatialEditorViewport::NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
- if ((nav_scheme == SpatialEditorViewport::NAVIGATION_MAYA || nav_scheme == SpatialEditorViewport::NAVIGATION_MODO) && mb->get_alt()) {
+ Node3DEditorViewport::NavigationScheme nav_scheme = (Node3DEditorViewport::NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
+ if ((nav_scheme == Node3DEditorViewport::NAVIGATION_MAYA || nav_scheme == Node3DEditorViewport::NAVIGATION_MODO) && mb->get_alt()) {
input_action = INPUT_NONE;
} else if (mb->get_button_index() == BUTTON_LEFT) {
@@ -963,16 +964,16 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_update_selection_transform();
_update_paste_indicator();
- spatial_editor = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
+ spatial_editor = Object::cast_to<Node3DEditorPlugin>(editor->get_editor_plugin_screen());
if (!node) {
set_process(false);
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], false);
}
if (cursor_instance.is_valid()) {
- VisualServer::get_singleton()->instance_set_visible(cursor_instance, false);
+ RenderingServer::get_singleton()->instance_set_visible(cursor_instance, false);
}
return;
@@ -1010,7 +1011,7 @@ void GridMapEditor::update_grid() {
edit_grid_xform.basis = Basis();
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis);
}
updating = true;
@@ -1022,7 +1023,7 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
Vector3 edited_floor = node->has_meta("_editor_floor_") ? node->get_meta("_editor_floor_") : Variant();
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->mesh_clear(grid[i]);
+ RS::get_singleton()->mesh_clear(grid[i]);
edit_floor[i] = edited_floor[i];
}
@@ -1064,11 +1065,11 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
}
Array d;
- d.resize(VS::ARRAY_MAX);
- d[VS::ARRAY_VERTEX] = grid_points[i];
- d[VS::ARRAY_COLOR] = grid_colors[i];
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
+ d.resize(RS::ARRAY_MAX);
+ d[RS::ARRAY_VERTEX] = grid_points[i];
+ d[RS::ARRAY_COLOR] = grid_colors[i];
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
}
}
@@ -1081,13 +1082,13 @@ void GridMapEditor::_notification(int p_what) {
mesh_library_palette->connect("item_selected", callable_mp(this, &GridMapEditor::_item_selected_cbk));
for (int i = 0; i < 3; i++) {
- grid[i] = VS::get_singleton()->mesh_create();
- grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
- selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario());
+ grid[i] = RS::get_singleton()->mesh_create();
+ grid_instance[i] = RS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
+ selection_level_instance[i] = RenderingServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario());
}
- selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario());
- paste_instance = VisualServer::get_singleton()->instance_create2(paste_mesh, get_tree()->get_root()->get_world()->get_scenario());
+ selection_instance = RenderingServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario());
+ paste_instance = RenderingServer::get_singleton()->instance_create2(paste_mesh, get_tree()->get_root()->get_world()->get_scenario());
_update_selection_transform();
_update_paste_indicator();
@@ -1099,15 +1100,15 @@ void GridMapEditor::_notification(int p_what) {
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->free(grid_instance[i]);
- VS::get_singleton()->free(grid[i]);
+ RS::get_singleton()->free(grid_instance[i]);
+ RS::get_singleton()->free(grid[i]);
grid_instance[i] = RID();
grid[i] = RID();
- VisualServer::get_singleton()->free(selection_level_instance[i]);
+ RenderingServer::get_singleton()->free(selection_level_instance[i]);
}
- VisualServer::get_singleton()->free(selection_instance);
- VisualServer::get_singleton()->free(paste_instance);
+ RenderingServer::get_singleton()->free(selection_instance);
+ RenderingServer::get_singleton()->free(paste_instance);
selection_instance = RID();
paste_instance = RID();
} break;
@@ -1122,7 +1123,7 @@ void GridMapEditor::_notification(int p_what) {
if (xf != grid_xform) {
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
+ RS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
}
grid_xform = xf;
}
@@ -1139,15 +1140,15 @@ void GridMapEditor::_notification(int p_what) {
p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
p = node->get_transform().xform(p); // plane to snap
- SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
+ Node3DEditorPlugin *sep = Object::cast_to<Node3DEditorPlugin>(editor->get_editor_plugin_screen());
if (sep)
sep->snap_cursor_to_plane(p);
}
} break;
case NOTIFICATION_THEME_CHANGED: {
- options->set_icon(get_icon("GridMap", "EditorIcons"));
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ options->set_icon(get_theme_icon("GridMap", "EditorIcons"));
+ search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
} break;
}
}
@@ -1158,7 +1159,7 @@ void GridMapEditor::_update_cursor_instance() {
}
if (cursor_instance.is_valid())
- VisualServer::get_singleton()->free(cursor_instance);
+ RenderingServer::get_singleton()->free(cursor_instance);
cursor_instance = RID();
if (selected_palette >= 0) {
@@ -1167,8 +1168,8 @@ void GridMapEditor::_update_cursor_instance() {
Ref<Mesh> mesh = node->get_mesh_library()->get_item_mesh(selected_palette);
if (!mesh.is_null() && mesh->get_rid().is_valid()) {
- cursor_instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
+ cursor_instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
+ RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
}
}
}
@@ -1216,7 +1217,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
spatial_editor_hb = memnew(HBoxContainer);
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_END);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
spin_box_label = memnew(Label);
spin_box_label->set_text(TTR("Floor:"));
@@ -1226,7 +1227,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
floor->set_min(-32767);
floor->set_max(32767);
floor->set_step(1);
- floor->get_line_edit()->add_constant_override("minimum_spaces", 16);
+ floor->get_line_edit()->add_theme_constant_override("minimum_spaces", 16);
spatial_editor_hb->add_child(floor);
floor->connect("value_changed", callable_mp(this, &GridMapEditor::_floor_changed));
@@ -1304,14 +1305,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
- mode_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail", "EditorIcons"));
+ mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon("FileThumbnail", "EditorIcons"));
hb->add_child(mode_thumbnail);
mode_thumbnail->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_THUMBNAIL));
mode_list = memnew(ToolButton);
mode_list->set_toggle_mode(true);
mode_list->set_pressed(false);
- mode_list->set_icon(p_editor->get_gui_base()->get_icon("FileList", "EditorIcons"));
+ mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon("FileList", "EditorIcons"));
hb->add_child(mode_list);
mode_list->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_LIST));
@@ -1352,8 +1353,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
lock_view = false;
cursor_rot = 0;
- selection_mesh = VisualServer::get_singleton()->mesh_create();
- paste_mesh = VisualServer::get_singleton()->mesh_create();
+ selection_mesh = RenderingServer::get_singleton()->mesh_create();
+ paste_mesh = RenderingServer::get_singleton()->mesh_create();
{
// Selection mesh create.
@@ -1430,16 +1431,16 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
}
Array d;
- d.resize(VS::ARRAY_MAX);
+ d.resize(RS::ARRAY_MAX);
inner_mat.instance();
inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
- d[VS::ARRAY_VERTEX] = triangles;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = triangles;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_TRIANGLES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
outer_mat.instance();
outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
@@ -1453,23 +1454,23 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
selection_floor_mat->set_on_top_of_alpha();
selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
- d[VS::ARRAY_VERTEX] = lines;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = lines;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
- d[VS::ARRAY_VERTEX] = triangles;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, VS::PRIMITIVE_TRIANGLES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = triangles;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_TRIANGLES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid());
- d[VS::ARRAY_VERTEX] = lines;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, VS::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = lines;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid());
for (int i = 0; i < 3; i++) {
- d[VS::ARRAY_VERTEX] = square[i];
- selection_level_mesh[i] = VS::get_singleton()->mesh_create();
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], VS::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = square[i];
+ selection_level_mesh[i] = RS::get_singleton()->mesh_create();
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], RS::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
}
}
@@ -1492,24 +1493,24 @@ GridMapEditor::~GridMapEditor() {
for (int i = 0; i < 3; i++) {
if (grid[i].is_valid())
- VisualServer::get_singleton()->free(grid[i]);
+ RenderingServer::get_singleton()->free(grid[i]);
if (grid_instance[i].is_valid())
- VisualServer::get_singleton()->free(grid_instance[i]);
+ RenderingServer::get_singleton()->free(grid_instance[i]);
if (cursor_instance.is_valid())
- VisualServer::get_singleton()->free(cursor_instance);
+ RenderingServer::get_singleton()->free(cursor_instance);
if (selection_level_instance[i].is_valid())
- VisualServer::get_singleton()->free(selection_level_instance[i]);
+ RenderingServer::get_singleton()->free(selection_level_instance[i]);
if (selection_level_mesh[i].is_valid())
- VisualServer::get_singleton()->free(selection_level_mesh[i]);
+ RenderingServer::get_singleton()->free(selection_level_mesh[i]);
}
- VisualServer::get_singleton()->free(selection_mesh);
+ RenderingServer::get_singleton()->free(selection_mesh);
if (selection_instance.is_valid())
- VisualServer::get_singleton()->free(selection_instance);
+ RenderingServer::get_singleton()->free(selection_instance);
- VisualServer::get_singleton()->free(paste_mesh);
+ RenderingServer::get_singleton()->free(paste_mesh);
if (paste_instance.is_valid())
- VisualServer::get_singleton()->free(paste_instance);
+ RenderingServer::get_singleton()->free(paste_instance);
}
void GridMapEditorPlugin::_notification(int p_what) {
@@ -1518,10 +1519,10 @@ void GridMapEditorPlugin::_notification(int p_what) {
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
case 0: { // Left.
- SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0);
+ Node3DEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0);
} break;
case 1: { // Right.
- SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 1);
+ Node3DEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 1);
} break;
}
}
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index d6459cee0a..fd880e8b7b 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -36,7 +36,7 @@
#include "editor/pane_drag.h"
#include "grid_map.h"
-class SpatialEditorPlugin;
+class Node3DEditorPlugin;
class GridMapEditor : public VBoxContainer {
GDCLASS(GridMapEditor, VBoxContainer);
@@ -188,7 +188,7 @@ class GridMapEditor : public VBoxContainer {
};
- SpatialEditorPlugin *spatial_editor;
+ Node3DEditorPlugin *spatial_editor;
struct AreaDisplay {
@@ -232,7 +232,7 @@ class GridMapEditor : public VBoxContainer {
void _delete_selection();
void _fill_selection();
- bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
+ bool do_input_action(Camera3D *p_camera, const Point2 &p_point, bool p_click);
friend class GridMapEditorPlugin;
@@ -242,7 +242,7 @@ protected:
static void _bind_methods();
public:
- bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
+ bool forward_spatial_input_event(Camera3D *p_camera, const Ref<InputEvent> &p_event);
void edit(GridMap *p_gridmap);
GridMapEditor() {}
@@ -261,7 +261,7 @@ protected:
void _notification(int p_what);
public:
- virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); }
+ virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "GridMap"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h
index bc720f460c..c0e3c39ca8 100644
--- a/modules/gridmap/register_types.h
+++ b/modules/gridmap/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef GRIDMAP_REGISTER_TYPES_H
+#define GRIDMAP_REGISTER_TYPES_H
+
void register_gridmap_types();
void unregister_gridmap_types();
+
+#endif // GRIDMAP_REGISTER_TYPES_H
diff --git a/modules/hdr/register_types.h b/modules/hdr/register_types.h
index c1c69a1e27..02441516ec 100644
--- a/modules/hdr/register_types.h
+++ b/modules/hdr/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef HDR_REGISTER_TYPES_H
+#define HDR_REGISTER_TYPES_H
+
void register_hdr_types();
void unregister_hdr_types();
+
+#endif // HDR_REGISTER_TYPES_H
diff --git a/modules/jpg/register_types.h b/modules/jpg/register_types.h
index 291098fae2..52cd378b3a 100644
--- a/modules/jpg/register_types.h
+++ b/modules/jpg/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef JPG_REGISTER_TYPES_H
+#define JPG_REGISTER_TYPES_H
+
void register_jpg_types();
void unregister_jpg_types();
+
+#endif // JPG_REGISTER_TYPES_H
diff --git a/modules/jsonrpc/register_types.h b/modules/jsonrpc/register_types.h
index 958f16344a..854d73a21f 100644
--- a/modules/jsonrpc/register_types.h
+++ b/modules/jsonrpc/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef JSONRPC_REGISTER_TYPES_H
+#define JSONRPC_REGISTER_TYPES_H
+
void register_jsonrpc_types();
void unregister_jsonrpc_types();
+
+#endif // JSONRPC_REGISTER_TYPES_H
diff --git a/modules/mbedtls/register_types.h b/modules/mbedtls/register_types.h
index f179d39438..90c81b1682 100755
--- a/modules/mbedtls/register_types.h
+++ b/modules/mbedtls/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef MBEDTLS_REGISTER_TYPES_H
+#define MBEDTLS_REGISTER_TYPES_H
+
void register_mbedtls_types();
void unregister_mbedtls_types();
+
+#endif // MBEDTLS_REGISTER_TYPES_H
diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp
index 2f1d95cd42..c82a521a43 100644
--- a/modules/mobile_vr/mobile_vr_interface.cpp
+++ b/modules/mobile_vr/mobile_vr_interface.cpp
@@ -29,9 +29,10 @@
/*************************************************************************/
#include "mobile_vr_interface.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
-#include "servers/visual/visual_server_globals.h"
+#include "servers/display_server.h"
+#include "servers/rendering/rendering_server_globals.h"
StringName MobileVRInterface::get_name() const {
return "Native mobile";
@@ -117,7 +118,7 @@ void MobileVRInterface::set_position_from_sensors() {
float delta_time = (double)ticks_elapsed / 1000000.0;
// few things we need
- Input *input = Input::get_singleton();
+ InputFilter *input = InputFilter::get_singleton();
Vector3 down(0.0, -1.0, 0.0); // Down is Y negative
Vector3 north(0.0, 0.0, 1.0); // North is Z positive
@@ -339,7 +340,7 @@ Size2 MobileVRInterface::get_render_targetsize() {
_THREAD_SAFE_METHOD_
// we use half our window size
- Size2 target_size = OS::get_singleton()->get_window_size();
+ Size2 target_size = DisplayServer::get_singleton()->window_get_size();
target_size.x *= 0.5 * oversample;
target_size.y *= oversample;
diff --git a/modules/mobile_vr/register_types.h b/modules/mobile_vr/register_types.h
index 602fae1f4e..33f608b6ed 100644
--- a/modules/mobile_vr/register_types.h
+++ b/modules/mobile_vr/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef MOBILE_VR_REGISTER_TYPES_H
+#define MOBILE_VR_REGISTER_TYPES_H
+
void register_mobile_vr_types();
void unregister_mobile_vr_types();
+
+#endif // MOBILE_VR_REGISTER_TYPES_H
diff --git a/modules/mono/build_scripts/make_android_mono_config.py b/modules/mono/build_scripts/make_android_mono_config.py
index 0afd939c57..4f5a496891 100644
--- a/modules/mono/build_scripts/make_android_mono_config.py
+++ b/modules/mono/build_scripts/make_android_mono_config.py
@@ -1,7 +1,6 @@
def generate_compressed_config(config_src, output_dir):
import os.path
- from compat import byte_to_str
# Source file
with open(os.path.join(output_dir, 'android_mono_config.gen.cpp'), 'w') as cpp:
@@ -16,7 +15,7 @@ def generate_compressed_config(config_src, output_dir):
for i, buf_idx in enumerate(range(compr_size)):
if i > 0:
bytes_seq_str += ', '
- bytes_seq_str += byte_to_str(buf[buf_idx])
+ bytes_seq_str += str(buf[buf_idx])
cpp.write('''/* THIS FILE IS GENERATED DO NOT EDIT */
#include "android_mono_config.h"
diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py
index 9a6198f13a..4e101583ef 100644
--- a/modules/mono/build_scripts/mono_configure.py
+++ b/modules/mono/build_scripts/mono_configure.py
@@ -45,11 +45,11 @@ def copy_file(src_dir, dst_dir, name):
def is_desktop(platform):
- return platform in ['windows', 'osx', 'x11', 'server', 'uwp', 'haiku']
+ return platform in ['windows', 'osx', 'linuxbsd', 'server', 'uwp', 'haiku']
def is_unix_like(platform):
- return platform in ['osx', 'x11', 'server', 'android', 'haiku']
+ return platform in ['osx', 'linuxbsd', 'server', 'android', 'haiku']
def module_supports_tools_on(platform):
diff --git a/modules/mono/build_scripts/mono_reg_utils.py b/modules/mono/build_scripts/mono_reg_utils.py
index b2c48f0a61..3bae11b167 100644
--- a/modules/mono/build_scripts/mono_reg_utils.py
+++ b/modules/mono/build_scripts/mono_reg_utils.py
@@ -1,14 +1,9 @@
import os
import platform
-from compat import decode_utf8
-
if os.name == 'nt':
import sys
- if sys.version_info < (3,):
- import _winreg as winreg
- else:
- import winreg
+ import winreg
def _reg_open_key(key, subkey):
@@ -81,7 +76,7 @@ def find_msbuild_tools_path_reg():
lines = subprocess.check_output([vswhere] + vswhere_args).splitlines()
for line in lines:
- parts = decode_utf8(line).split(':', 1)
+ parts = line.decode("utf-8").split(':', 1)
if len(parts) < 2 or parts[0] != 'installationPath':
continue
diff --git a/modules/mono/config.py b/modules/mono/config.py
index a5d3059ecc..3ee1618366 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -3,7 +3,7 @@ def can_build(env, platform):
def configure(env):
- if env['platform'] not in ['windows', 'osx', 'x11', 'server', 'android', 'haiku', 'javascript']:
+ if env['platform'] not in ['windows', 'osx', 'linuxbsd', 'server', 'android', 'haiku', 'javascript']:
raise RuntimeError('This module does not currently support building for this platform')
env.use_ptrcall = True
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index 279e67b3eb..11a4109d97 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
@@ -33,7 +33,7 @@ namespace GodotTools.Utils
{
public const string Windows = "windows";
public const string OSX = "osx";
- public const string X11 = "x11";
+ public const string X11 = "linuxbsd";
public const string Server = "server";
public const string UWP = "uwp";
public const string Haiku = "haiku";
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index b133923c25..bebe489d02 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -33,7 +33,7 @@
#include "core/class_db.h"
#include "core/string_builder.h"
-#include "editor/doc/doc_data.h"
+#include "editor/doc_data.h"
#include "editor/editor_help.h"
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp
index be0b846702..e493098211 100644
--- a/modules/mono/mono_gd/gd_mono_cache.cpp
+++ b/modules/mono/mono_gd/gd_mono_cache.cpp
@@ -122,7 +122,7 @@ void CachedData::clear_godot_api_cache() {
class_GodotResource = NULL;
class_Node = NULL;
class_Control = NULL;
- class_Spatial = NULL;
+ class_Node3D = NULL;
class_WeakRef = NULL;
class_Callable = NULL;
class_SignalInfo = NULL;
@@ -251,7 +251,7 @@ void update_godot_api_cache() {
CACHE_CLASS_AND_CHECK(GodotResource, GODOT_API_CLASS(Resource));
CACHE_CLASS_AND_CHECK(Node, GODOT_API_CLASS(Node));
CACHE_CLASS_AND_CHECK(Control, GODOT_API_CLASS(Control));
- CACHE_CLASS_AND_CHECK(Spatial, GODOT_API_CLASS(Spatial));
+ CACHE_CLASS_AND_CHECK(Node3D, GODOT_API_CLASS(Node3Dshou));
CACHE_CLASS_AND_CHECK(WeakRef, GODOT_API_CLASS(WeakRef));
CACHE_CLASS_AND_CHECK(Callable, GODOT_API_CLASS(Callable));
CACHE_CLASS_AND_CHECK(SignalInfo, GODOT_API_CLASS(SignalInfo));
diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h
index b2dacee67c..21c8ed4efe 100644
--- a/modules/mono/mono_gd/gd_mono_cache.h
+++ b/modules/mono/mono_gd/gd_mono_cache.h
@@ -92,7 +92,7 @@ struct CachedData {
GDMonoClass *class_GodotResource;
GDMonoClass *class_Node;
GDMonoClass *class_Control;
- GDMonoClass *class_Spatial;
+ GDMonoClass *class_Node3D;
GDMonoClass *class_WeakRef;
GDMonoClass *class_Callable;
GDMonoClass *class_SignalInfo;
diff --git a/modules/ogg/register_types.h b/modules/ogg/register_types.h
index 09095c9b62..849d27bb06 100644
--- a/modules/ogg/register_types.h
+++ b/modules/ogg/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef OGG_REGISTER_TYPES_H
+#define OGG_REGISTER_TYPES_H
+
void register_ogg_types();
void unregister_ogg_types();
+
+#endif // OGG_REGISTER_TYPES_H
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 8e5b04f995..1a08ec416f 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -50,7 +50,7 @@ NoiseTexture::NoiseTexture() {
NoiseTexture::~NoiseTexture() {
if (texture.is_valid()) {
- VS::get_singleton()->free(texture);
+ RS::get_singleton()->free(texture);
}
if (noise_thread) {
Thread::wait_to_finish(noise_thread);
@@ -100,10 +100,10 @@ void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) {
data = p_image;
if (data.is_valid()) {
if (texture.is_valid()) {
- RID new_texture = VS::get_singleton()->texture_2d_create(p_image);
- VS::get_singleton()->texture_replace(texture, new_texture);
+ RID new_texture = RS::get_singleton()->texture_2d_create(p_image);
+ RS::get_singleton()->texture_replace(texture, new_texture);
} else {
- texture = VS::get_singleton()->texture_2d_create(p_image);
+ texture = RS::get_singleton()->texture_2d_create(p_image);
}
}
emit_changed();
@@ -254,7 +254,7 @@ int NoiseTexture::get_height() const {
RID NoiseTexture::get_rid() const {
if (!texture.is_valid()) {
- texture = VS::get_singleton()->texture_2d_placeholder_create();
+ texture = RS::get_singleton()->texture_2d_placeholder_create();
}
return texture;
diff --git a/modules/opensimplex/register_types.h b/modules/opensimplex/register_types.h
index 56e128f09e..51c6815eae 100644
--- a/modules/opensimplex/register_types.h
+++ b/modules/opensimplex/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef OPENSIMPLEX_REGISTER_TYPES_H
+#define OPENSIMPLEX_REGISTER_TYPES_H
+
void register_opensimplex_types();
void unregister_opensimplex_types();
+
+#endif // OPENSIMPLEX_REGISTER_TYPES_H
diff --git a/modules/opus/register_types.h b/modules/opus/register_types.h
index 445be4e166..ad6e083c82 100644
--- a/modules/opus/register_types.h
+++ b/modules/opus/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef OPUS_REGISTER_TYPES_H
+#define OPUS_REGISTER_TYPES_H
+
void register_opus_types();
void unregister_opus_types();
+
+#endif // OPUS_REGISTER_TYPES_H
diff --git a/modules/pvr/register_types.h b/modules/pvr/register_types.h
index 06c54f50b1..8318996a46 100644
--- a/modules/pvr/register_types.h
+++ b/modules/pvr/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef PVR_REGISTER_TYPES_H
+#define PVR_REGISTER_TYPES_H
+
void register_pvr_types();
void unregister_pvr_types();
+
+#endif // PVR_REGISTER_TYPES_H
diff --git a/modules/regex/register_types.h b/modules/regex/register_types.h
index 99a6bbeb2c..cf377cdf5f 100644
--- a/modules/regex/register_types.h
+++ b/modules/regex/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef REGEX_REGISTER_TYPES_H
+#define REGEX_REGISTER_TYPES_H
+
void register_regex_types();
void unregister_regex_types();
+
+#endif // REGEX_REGISTER_TYPES_H
diff --git a/modules/squish/register_types.h b/modules/squish/register_types.h
index 0845e2b500..ab56c54d4a 100644
--- a/modules/squish/register_types.h
+++ b/modules/squish/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef SQUISH_REGISTER_TYPES_H
+#define SQUISH_REGISTER_TYPES_H
+
void register_squish_types();
void unregister_squish_types();
+
+#endif // SQUISH_REGISTER_TYPES_H
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 42f341cef7..e5d0e0b12d 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -122,7 +122,7 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
if (ogg_alloc.alloc_buffer) {
stb_vorbis_close(ogg_stream);
- AudioServer::get_singleton()->audio_data_free(ogg_alloc.alloc_buffer);
+ memfree(ogg_alloc.alloc_buffer);
}
}
@@ -134,7 +134,7 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
ovs.instance();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this);
- ovs->ogg_alloc.alloc_buffer = (char *)AudioServer::get_singleton()->audio_data_alloc(decode_mem_size);
+ ovs->ogg_alloc.alloc_buffer = (char *)memalloc(decode_mem_size);
ovs->ogg_alloc.alloc_buffer_length_in_bytes = decode_mem_size;
ovs->frames_mixed = 0;
ovs->active = false;
@@ -143,7 +143,7 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
ovs->ogg_stream = stb_vorbis_open_memory((const unsigned char *)data, data_len, &error, &ovs->ogg_alloc);
if (!ovs->ogg_stream) {
- AudioServer::get_singleton()->audio_data_free(ovs->ogg_alloc.alloc_buffer);
+ memfree(ovs->ogg_alloc.alloc_buffer);
ovs->ogg_alloc.alloc_buffer = NULL;
ERR_FAIL_COND_V(!ovs->ogg_stream, Ref<AudioStreamPlaybackOGGVorbis>());
}
@@ -158,7 +158,7 @@ String AudioStreamOGGVorbis::get_stream_name() const {
void AudioStreamOGGVorbis::clear_data() {
if (data) {
- AudioServer::get_singleton()->audio_data_free(data);
+ memfree(data);
data = NULL;
data_len = 0;
}
@@ -210,7 +210,8 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
// free any existing data
clear_data();
- data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar);
+ data = memalloc(src_data_len);
+ copymem(data, src_datar, src_data_len);
data_len = src_data_len;
break;
diff --git a/modules/stb_vorbis/register_types.h b/modules/stb_vorbis/register_types.h
index f6147abd01..f5a1dd31bc 100644
--- a/modules/stb_vorbis/register_types.h
+++ b/modules/stb_vorbis/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef STB_VORBIS_REGISTER_TYPES_H
+#define STB_VORBIS_REGISTER_TYPES_H
+
void register_stb_vorbis_types();
void unregister_stb_vorbis_types();
+
+#endif // STB_VORBIS_REGISTER_TYPES_H
diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h
index aa50540552..a3d914e0cb 100644
--- a/modules/svg/register_types.h
+++ b/modules/svg/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef SVG_REGISTER_TYPES_H
+#define SVG_REGISTER_TYPES_H
+
void register_svg_types();
void unregister_svg_types();
+
+#endif // SVG_REGISTER_TYPES_H
diff --git a/modules/tga/register_types.h b/modules/tga/register_types.h
index beef05a590..94a77d295e 100644
--- a/modules/tga/register_types.h
+++ b/modules/tga/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef TGA_REGISTER_TYPES_H
+#define TGA_REGISTER_TYPES_H
+
void register_tga_types();
void unregister_tga_types();
+
+#endif // TGA_REGISTER_TYPES_H
diff --git a/modules/theora/register_types.h b/modules/theora/register_types.h
index 66eb49aed1..4f0670b2c7 100644
--- a/modules/theora/register_types.h
+++ b/modules/theora/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef THEORA_REGISTER_TYPES_H
+#define THEORA_REGISTER_TYPES_H
+
void register_theora_types();
void unregister_theora_types();
+
+#endif // THEORA_REGISTER_TYPES_H
diff --git a/modules/tinyexr/register_types.h b/modules/tinyexr/register_types.h
index 2028cd4a33..9739488312 100644
--- a/modules/tinyexr/register_types.h
+++ b/modules/tinyexr/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef TINYEXR_REGISTER_TYPES_H
+#define TINYEXR_REGISTER_TYPES_H
+
void register_tinyexr_types();
void unregister_tinyexr_types();
+
+#endif // TINYEXR_REGISTER_TYPES_H
diff --git a/modules/upnp/register_types.h b/modules/upnp/register_types.h
index 4d752e4a94..0c71db9ffa 100644
--- a/modules/upnp/register_types.h
+++ b/modules/upnp/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef UPNP_REGISTER_TYPES_H
+#define UPNP_REGISTER_TYPES_H
+
void register_upnp_types();
void unregister_upnp_types();
+
+#endif // UPNP_REGISTER_TYPES_H
diff --git a/modules/vhacd/register_types.h b/modules/vhacd/register_types.h
index de56620813..d02a990901 100644
--- a/modules/vhacd/register_types.h
+++ b/modules/vhacd/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef VHACD_REGISTER_TYPES_H
+#define VHACD_REGISTER_TYPES_H
+
void register_vhacd_types();
void unregister_vhacd_types();
+
+#endif // VHACD_REGISTER_TYPES_H
diff --git a/modules/visual_script/register_types.h b/modules/visual_script/register_types.h
index 546c2fbff3..c18c2930b1 100644
--- a/modules/visual_script/register_types.h
+++ b/modules/visual_script/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef VISUAL_SCRIPT_REGISTER_TYPES_H
+#define VISUAL_SCRIPT_REGISTER_TYPES_H
+
void register_visual_script_types();
void unregister_visual_script_types();
+
+#endif // VISUAL_SCRIPT_REGISTER_TYPES_H
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index ca255ebf82..19771ef373 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -30,15 +30,15 @@
#include "visual_script_editor.h"
+#include "core/input/input_filter.h"
#include "core/object.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/script_language.h"
#include "core/variant.h"
#include "editor/editor_node.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "visual_script_expression.h"
#include "visual_script_flow_control.h"
#include "visual_script_func_nodes.h"
@@ -504,36 +504,36 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
select_func_text->hide();
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("NodePath", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("MiniObject", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ Control::get_theme_icon("Variant", "EditorIcons"),
+ Control::get_theme_icon("bool", "EditorIcons"),
+ Control::get_theme_icon("int", "EditorIcons"),
+ Control::get_theme_icon("float", "EditorIcons"),
+ Control::get_theme_icon("String", "EditorIcons"),
+ Control::get_theme_icon("Vector2", "EditorIcons"),
+ Control::get_theme_icon("Rect2", "EditorIcons"),
+ Control::get_theme_icon("Vector3", "EditorIcons"),
+ Control::get_theme_icon("Transform2D", "EditorIcons"),
+ Control::get_theme_icon("Plane", "EditorIcons"),
+ Control::get_theme_icon("Quat", "EditorIcons"),
+ Control::get_theme_icon("AABB", "EditorIcons"),
+ Control::get_theme_icon("Basis", "EditorIcons"),
+ Control::get_theme_icon("Transform", "EditorIcons"),
+ Control::get_theme_icon("Color", "EditorIcons"),
+ Control::get_theme_icon("NodePath", "EditorIcons"),
+ Control::get_theme_icon("RID", "EditorIcons"),
+ Control::get_theme_icon("MiniObject", "EditorIcons"),
+ Control::get_theme_icon("Dictionary", "EditorIcons"),
+ Control::get_theme_icon("Array", "EditorIcons"),
+ Control::get_theme_icon("PackedByteArray", "EditorIcons"),
+ Control::get_theme_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedStringArray", "EditorIcons"),
+ Control::get_theme_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_theme_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_theme_icon("PackedColorArray", "EditorIcons")
};
- Ref<Texture2D> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons");
+ Ref<Texture2D> seq_port = Control::get_theme_icon("VisualShaderPort", "EditorIcons");
for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions
@@ -596,7 +596,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text());
line_edit->set_expand_to_text_length(true);
- line_edit->add_font_override("font", get_font("source", "EditorFonts"));
+ line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
gnode->add_child(line_edit);
line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get()));
} else {
@@ -637,14 +637,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
mono_color.a = 0.85;
c = mono_color;
}
- gnode->add_color_override("title_color", c);
+ gnode->add_theme_color_override("title_color", c);
c.a = 0.7;
- gnode->add_color_override("close_color", c);
- gnode->add_color_override("resizer_color", ic);
- gnode->add_style_override("frame", sbf);
+ gnode->add_theme_color_override("close_color", c);
+ gnode->add_theme_color_override("resizer_color", ic);
+ gnode->add_theme_style_override("frame", sbf);
}
- const Color mono_color = get_color("mono_color", "Editor");
+ const Color mono_color = get_theme_color("mono_color", "Editor");
int slot_idx = 0;
@@ -750,7 +750,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
hbc->add_child(rmbtn);
rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED);
} else {
@@ -812,7 +812,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (is_vslist) {
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
hbc->add_child(rmbtn);
rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED);
@@ -856,7 +856,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_child(vbc);
- bool dark_theme = get_constant("dark_theme", "Editor");
+ bool dark_theme = get_theme_constant("dark_theme", "Editor");
if (i < mixed_seq_ports) {
gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port);
} else {
@@ -940,9 +940,9 @@ void VisualScriptEditor::_update_members() {
TreeItem *functions = members->create_item(root);
functions->set_selectable(0, false);
functions->set_text(0, TTR("Functions:"));
- functions->add_button(0, Control::get_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function."));
- functions->add_button(0, Control::get_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function."));
- functions->set_custom_color(0, Control::get_color("mono_color", "Editor"));
+ functions->add_button(0, Control::get_theme_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function."));
+ functions->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function."));
+ functions->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
List<StringName> func_names;
script->get_function_list(&func_names);
@@ -956,7 +956,7 @@ void VisualScriptEditor::_update_members() {
ti->set_text(0, E->get());
ti->set_selectable(0, true);
ti->set_metadata(0, E->get());
- ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0);
+ ti->add_button(0, Control::get_theme_icon("Edit", "EditorIcons"), 0);
if (selected == E->get())
ti->select(0);
}
@@ -964,37 +964,37 @@ void VisualScriptEditor::_update_members() {
TreeItem *variables = members->create_item(root);
variables->set_selectable(0, false);
variables->set_text(0, TTR("Variables:"));
- variables->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable."));
- variables->set_custom_color(0, Control::get_color("mono_color", "Editor"));
+ variables->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable."));
+ variables->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("NodePath", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("MiniObject", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ Control::get_theme_icon("Variant", "EditorIcons"),
+ Control::get_theme_icon("bool", "EditorIcons"),
+ Control::get_theme_icon("int", "EditorIcons"),
+ Control::get_theme_icon("float", "EditorIcons"),
+ Control::get_theme_icon("String", "EditorIcons"),
+ Control::get_theme_icon("Vector2", "EditorIcons"),
+ Control::get_theme_icon("Rect2", "EditorIcons"),
+ Control::get_theme_icon("Vector3", "EditorIcons"),
+ Control::get_theme_icon("Transform2D", "EditorIcons"),
+ Control::get_theme_icon("Plane", "EditorIcons"),
+ Control::get_theme_icon("Quat", "EditorIcons"),
+ Control::get_theme_icon("AABB", "EditorIcons"),
+ Control::get_theme_icon("Basis", "EditorIcons"),
+ Control::get_theme_icon("Transform", "EditorIcons"),
+ Control::get_theme_icon("Color", "EditorIcons"),
+ Control::get_theme_icon("NodePath", "EditorIcons"),
+ Control::get_theme_icon("RID", "EditorIcons"),
+ Control::get_theme_icon("MiniObject", "EditorIcons"),
+ Control::get_theme_icon("Dictionary", "EditorIcons"),
+ Control::get_theme_icon("Array", "EditorIcons"),
+ Control::get_theme_icon("PackedByteArray", "EditorIcons"),
+ Control::get_theme_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedStringArray", "EditorIcons"),
+ Control::get_theme_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_theme_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_theme_icon("PackedColorArray", "EditorIcons")
};
List<StringName> var_names;
@@ -1017,8 +1017,8 @@ void VisualScriptEditor::_update_members() {
TreeItem *_signals = members->create_item(root);
_signals->set_selectable(0, false);
_signals->set_text(0, TTR("Signals:"));
- _signals->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal."));
- _signals->set_custom_color(0, Control::get_color("mono_color", "Editor"));
+ _signals->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal."));
+ _signals->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
List<StringName> signal_names;
script->get_custom_signal_list(&signal_names);
@@ -1034,12 +1034,12 @@ void VisualScriptEditor::_update_members() {
String base_type = script->get_instance_base_type();
String icon_type = base_type;
- if (!Control::has_icon(base_type, "EditorIcons")) {
+ if (!Control::has_theme_icon(base_type, "EditorIcons")) {
icon_type = "Object";
}
base_type_select->set_text(base_type);
- base_type_select->set_icon(Control::get_icon(icon_type, "EditorIcons"));
+ base_type_select->set_icon(Control::get_theme_icon(icon_type, "EditorIcons"));
updating_members = false;
}
@@ -1057,9 +1057,9 @@ void VisualScriptEditor::_member_selected() {
if (ti->get_parent() == members->get_root()->get_children()) {
#ifdef OSX_ENABLED
- bool held_ctrl = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool held_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_META);
#else
- bool held_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool held_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
if (held_ctrl) {
ERR_FAIL_COND(!script->has_function(selected));
@@ -1252,7 +1252,7 @@ void VisualScriptEditor::_add_func_input() {
hbox->add_child(type_box);
Button *delete_button = memnew(Button);
- delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
delete_button->set_tooltip(vformat(TTR("Delete input port")));
hbox->add_child(delete_button);
@@ -1360,7 +1360,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
}
} else if (ti->get_parent() == root->get_children()) {
selected = ti->get_text(0);
- function_name_edit->set_position(Input::get_singleton()->get_mouse_position() - Vector2(60, -10));
+ function_name_edit->set_position(InputFilter::get_singleton()->get_mouse_position() - Vector2(60, -10));
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
@@ -1722,7 +1722,7 @@ void VisualScriptEditor::_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> key = p_event;
if (key.is_valid() && !key->is_pressed()) {
- mouse_up_position = Input::get_singleton()->get_mouse_position();
+ mouse_up_position = InputFilter::get_singleton()->get_mouse_position();
}
}
@@ -1732,7 +1732,7 @@ void VisualScriptEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (key.is_valid() && key->is_pressed() && key->get_button_mask() == BUTTON_RIGHT) {
saved_position = graph->get_local_mouse_position();
- Point2 gpos = Input::get_singleton()->get_mouse_position();
+ Point2 gpos = InputFilter::get_singleton()->get_mouse_position();
_generic_search(script->get_instance_base_type(), gpos);
}
}
@@ -1986,9 +1986,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (String(d["type"]) == "visual_script_variable_drag") {
#ifdef OSX_ENABLED
- bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool use_set = InputFilter::get_singleton()->is_key_pressed(KEY_META);
#else
- bool use_set = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool use_set = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
@@ -2181,9 +2181,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
#ifdef OSX_ENABLED
- bool use_node = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool use_node = InputFilter::get_singleton()->is_key_pressed(KEY_META);
#else
- bool use_node = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool use_node = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
Array nodes = d["nodes"];
@@ -2245,7 +2245,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
- if (!sn && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (!sn && !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Can't drop properties because script '%s' is not used in this scene.\nDrop holding 'Shift' to just copy the signature."), get_name()));
return;
}
@@ -2265,12 +2265,12 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
ofs /= EDSCALE;
#ifdef OSX_ENABLED
- bool use_get = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool use_get = InputFilter::get_singleton()->is_key_pressed(KEY_META);
#else
- bool use_get = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool use_get = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
- if (!node || Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (!node || InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
if (use_get)
undo_redo->create_action(TTR("Add Getter Property"));
@@ -2377,7 +2377,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
if (!button)
return;
- Ref<StyleBox> normal = get_stylebox("normal", "Button");
+ Ref<StyleBox> normal = get_theme_stylebox("normal", "Button");
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
@@ -2459,9 +2459,9 @@ String VisualScriptEditor::get_name() {
return name;
}
-Ref<Texture2D> VisualScriptEditor::get_icon() {
+Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
- return Control::get_icon("VisualScript", "EditorIcons");
+ return Control::get_theme_icon("VisualScript", "EditorIcons");
}
bool VisualScriptEditor::is_unsaved() {
@@ -3925,9 +3925,9 @@ void VisualScriptEditor::_notification(int p_what) {
return;
}
- edit_variable_edit->add_style_override("bg", get_stylebox("bg", "Tree"));
- edit_signal_edit->add_style_override("bg", get_stylebox("bg", "Tree"));
- func_input_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
+ edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ func_input_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme();
@@ -4479,9 +4479,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
TreeItem *root = members->get_root();
- Ref<Texture2D> del_icon = Control::get_icon("Remove", "EditorIcons");
+ Ref<Texture2D> del_icon = Control::get_theme_icon("Remove", "EditorIcons");
- Ref<Texture2D> edit_icon = Control::get_icon("Edit", "EditorIcons");
+ Ref<Texture2D> edit_icon = Control::get_theme_icon("Edit", "EditorIcons");
if (ti->get_parent() == root->get_children()) {
@@ -4578,7 +4578,7 @@ void VisualScriptEditor::_member_option(int p_option) {
} else if (p_option == MEMBER_EDIT) {
variable_editor->edit(name);
edit_variable_dialog->set_title(TTR("Editing Variable:") + " " + name);
- edit_variable_dialog->popup_centered_minsize(Size2(400, 200) * EDSCALE);
+ edit_variable_dialog->popup_centered(Size2(400, 200) * EDSCALE);
}
} break;
case MEMBER_SIGNAL: {
@@ -4599,7 +4599,7 @@ void VisualScriptEditor::_member_option(int p_option) {
} else if (p_option == MEMBER_EDIT) {
signal_editor->edit(name);
edit_signal_dialog->set_title(TTR("Editing Signal:") + " " + name);
- edit_signal_dialog->popup_centered_minsize(Size2(400, 300) * EDSCALE);
+ edit_signal_dialog->popup_centered(Size2(400, 300) * EDSCALE);
}
} break;
}
@@ -4687,10 +4687,9 @@ VisualScriptEditor::VisualScriptEditor() {
add_child(member_popup);
member_popup->connect("id_pressed", callable_mp(this, &VisualScriptEditor::_member_option));
- function_name_edit = memnew(PopupDialog);
+ function_name_edit = memnew(AcceptDialog);
function_name_box = memnew(LineEdit);
function_name_edit->add_child(function_name_box);
- function_name_edit->set_h_size_flags(SIZE_EXPAND);
function_name_box->connect("gui_input", callable_mp(this, &VisualScriptEditor::_fn_name_box_input));
function_name_box->set_expand_to_text_length(true);
add_child(function_name_edit);
@@ -4770,7 +4769,6 @@ VisualScriptEditor::VisualScriptEditor() {
func_input_scroll->add_child(func_input_vbox);
function_create_dialog = memnew(ConfirmationDialog);
- function_create_dialog->set_v_size_flags(SIZE_EXPAND_FILL);
function_create_dialog->set_title(TTR("Create Function"));
function_create_dialog->add_child(function_vb);
function_create_dialog->get_ok()->set_text(TTR("Create"));
@@ -4859,7 +4857,6 @@ VisualScriptEditor::VisualScriptEditor() {
new_connect_node_select = memnew(VisualScriptPropertySelector);
add_child(new_connect_node_select);
- new_connect_node_select->set_resizable(true);
new_connect_node_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_connect_node));
new_connect_node_select->get_cancel()->connect("pressed", callable_mp(this, &VisualScriptEditor::_cancel_connect_node));
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 6ff00cf0a6..d9494e4d04 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -114,7 +114,7 @@ class VisualScriptEditor : public ScriptEditorBase {
UndoRedo *undo_redo;
Tree *members;
- PopupDialog *function_name_edit;
+ AcceptDialog *function_name_edit;
LineEdit *function_name_box;
Label *hint_text;
@@ -298,7 +298,7 @@ public:
virtual Vector<String> get_functions();
virtual void reload_text();
virtual String get_name();
- virtual Ref<Texture2D> get_icon();
+ virtual Ref<Texture2D> get_theme_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 41c1ea4ca2..1b496dad32 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "core/global_constants.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "scene/main/node.h"
@@ -3870,16 +3870,16 @@ public:
switch (mode) {
case VisualScriptInputAction::MODE_PRESSED: {
- *p_outputs[0] = Input::get_singleton()->is_action_pressed(action);
+ *p_outputs[0] = InputFilter::get_singleton()->is_action_pressed(action);
} break;
case VisualScriptInputAction::MODE_RELEASED: {
- *p_outputs[0] = !Input::get_singleton()->is_action_pressed(action);
+ *p_outputs[0] = !InputFilter::get_singleton()->is_action_pressed(action);
} break;
case VisualScriptInputAction::MODE_JUST_PRESSED: {
- *p_outputs[0] = Input::get_singleton()->is_action_just_pressed(action);
+ *p_outputs[0] = InputFilter::get_singleton()->is_action_just_pressed(action);
} break;
case VisualScriptInputAction::MODE_JUST_RELEASED: {
- *p_outputs[0] = Input::get_singleton()->is_action_just_released(action);
+ *p_outputs[0] = InputFilter::get_singleton()->is_action_just_released(action);
} break;
}
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index d799f19143..d749e3257a 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -39,7 +39,7 @@
#include "modules/visual_script/visual_script_func_nodes.h"
#include "modules/visual_script/visual_script_nodes.h"
#include "scene/main/node.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void VisualScriptPropertySelector::_text_changed(const String &p_newtext) {
_update_search();
@@ -99,35 +99,35 @@ void VisualScriptPropertySelector::_update_search() {
List<PropertyInfo> props;
TreeItem *category = NULL;
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("Path", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("Object", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedInt64Array", "EditorIcons"),
- Control::get_icon("PackedFloat64Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ vbc->get_theme_icon("Variant", "EditorIcons"),
+ vbc->get_theme_icon("bool", "EditorIcons"),
+ vbc->get_theme_icon("int", "EditorIcons"),
+ vbc->get_theme_icon("float", "EditorIcons"),
+ vbc->get_theme_icon("String", "EditorIcons"),
+ vbc->get_theme_icon("Vector2", "EditorIcons"),
+ vbc->get_theme_icon("Rect2", "EditorIcons"),
+ vbc->get_theme_icon("Vector3", "EditorIcons"),
+ vbc->get_theme_icon("Transform2D", "EditorIcons"),
+ vbc->get_theme_icon("Plane", "EditorIcons"),
+ vbc->get_theme_icon("Quat", "EditorIcons"),
+ vbc->get_theme_icon("AABB", "EditorIcons"),
+ vbc->get_theme_icon("Basis", "EditorIcons"),
+ vbc->get_theme_icon("Transform", "EditorIcons"),
+ vbc->get_theme_icon("Color", "EditorIcons"),
+ vbc->get_theme_icon("Path", "EditorIcons"),
+ vbc->get_theme_icon("RID", "EditorIcons"),
+ vbc->get_theme_icon("Object", "EditorIcons"),
+ vbc->get_theme_icon("Dictionary", "EditorIcons"),
+ vbc->get_theme_icon("Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedByteArray", "EditorIcons"),
+ vbc->get_theme_icon("PackedInt32Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedInt64Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedFloat64Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedStringArray", "EditorIcons"),
+ vbc->get_theme_icon("PackedVector2Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedVector3Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedColorArray", "EditorIcons")
};
{
String b = String(E->get());
@@ -252,7 +252,7 @@ void VisualScriptPropertySelector::_update_search() {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, desc);
- item->set_icon(0, get_icon("MemberMethod", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon("MemberMethod", "EditorIcons"));
item->set_metadata(0, name);
item->set_selectable(0, true);
@@ -316,7 +316,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name,
if (search_input == String() || text.findn(search_input) != -1) {
TreeItem *item = search_options->create_item(root);
item->set_text(0, text);
- item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
item->set_metadata(0, name);
item->set_metadata(1, "action");
item->set_selectable(0, true);
@@ -399,7 +399,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
}
item->set_text(0, type_name + String("").join(desc));
- item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
item->set_selectable(0, true);
item->set_metadata(0, E->get());
item->set_selectable(0, true);
@@ -416,7 +416,7 @@ void VisualScriptPropertySelector::_confirmed() {
if (!ti)
return;
emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
- hide();
+ set_visible(false);
}
void VisualScriptPropertySelector::_item_selected() {
@@ -519,7 +519,7 @@ void VisualScriptPropertySelector::_item_selected() {
}
void VisualScriptPropertySelector::_hide_requested() {
- _closed(); // From WindowDialog.
+ _cancel_pressed(); // From AcceptDialog.
}
void VisualScriptPropertySelector::_notification(int p_what) {
@@ -684,12 +684,8 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas
}
void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
- Rect2 rect;
- Point2 window_size = get_viewport_rect().size;
- rect.size = (window_size * p_screen_ratio).floor();
- rect.size.x = rect.size.x / 2.2f;
- rect.position = ((window_size - rect.size) / 2.0f).floor();
- popup(rect);
+
+ popup_centered_ratio(p_screen_ratio);
}
void VisualScriptPropertySelector::_bind_methods() {
@@ -699,7 +695,7 @@ void VisualScriptPropertySelector::_bind_methods() {
VisualScriptPropertySelector::VisualScriptPropertySelector() {
- VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
search_box = memnew(LineEdit);
diff --git a/modules/visual_script/visual_script_property_selector.h b/modules/visual_script/visual_script_property_selector.h
index f438ca1f5b..cc49b2863d 100644
--- a/modules/visual_script/visual_script_property_selector.h
+++ b/modules/visual_script/visual_script_property_selector.h
@@ -64,6 +64,7 @@ class VisualScriptPropertySelector : public ConfirmationDialog {
Object *instance;
bool virtuals_only;
bool seq_connect;
+ VBoxContainer *vbc;
Vector<Variant::Type> type_filter;
diff --git a/modules/vorbis/register_types.h b/modules/vorbis/register_types.h
index 83d4904a87..7fa0dfdeef 100644
--- a/modules/vorbis/register_types.h
+++ b/modules/vorbis/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef VORBIS_REGISTER_TYPES_H
+#define VORBIS_REGISTER_TYPES_H
+
void register_vorbis_types();
void unregister_vorbis_types();
+
+#endif // VORBIS_REGISTER_TYPES_H
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index 14fa6c1268..6aed8a16f5 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -270,12 +270,12 @@ if env["platform"] == 'uwp':
webm_cpu_x86 = True
else:
import platform
- is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
+ is_x11_or_server_arm = ((env["platform"] == 'linuxbsd' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
is_ios_x86 = (env["platform"] == 'iphone' and ("arch" in env and env["arch"].startswith('x86')))
is_android_x86 = (env["platform"] == 'android' and env["android_arch"].startswith('x86'))
if is_android_x86:
cpu_bits = '32' if env["android_arch"] == 'x86' else '64'
- webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
+ webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'linuxbsd' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
webm_cpu_arm = is_x11_or_server_arm or (not is_ios_x86 and env["platform"] == 'iphone') or (not is_android_x86 and env["platform"] == 'android')
if webm_cpu_x86:
@@ -330,7 +330,7 @@ if webm_cpu_x86:
if webm_cpu_arm:
if env["platform"] == 'iphone':
env_libvpx["ASFLAGS"] = '-arch armv7'
- elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'x11' or env["platform"] == 'server':
+ elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'linuxbsd' or env["platform"] == 'server':
env_libvpx["ASFLAGS"] = '-mfpu=neon'
elif env["platform"] == 'uwp':
env_libvpx["AS"] = 'armasm'
diff --git a/modules/webm/register_types.h b/modules/webm/register_types.h
index 962a0dab4e..6a02e3a87a 100644
--- a/modules/webm/register_types.h
+++ b/modules/webm/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef WEBM_REGISTER_TYPES_H
+#define WEBM_REGISTER_TYPES_H
+
void register_webm_types();
void unregister_webm_types();
+
+#endif // WEBM_REGISTER_TYPES_H
diff --git a/modules/webp/register_types.h b/modules/webp/register_types.h
index 9591b91558..d574d7be1d 100644
--- a/modules/webp/register_types.h
+++ b/modules/webp/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef WEBP_REGISTER_TYPES_H
+#define WEBP_REGISTER_TYPES_H
+
void register_webp_types();
void unregister_webp_types();
+
+#endif // WEBP_REGISTER_TYPES_H
diff --git a/modules/webrtc/register_types.h b/modules/webrtc/register_types.h
index e6b50506e5..8f5b9e8452 100644
--- a/modules/webrtc/register_types.h
+++ b/modules/webrtc/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef WEBRTC_REGISTER_TYPES_H
+#define WEBRTC_REGISTER_TYPES_H
+
void register_webrtc_types();
void unregister_webrtc_types();
+
+#endif // WEBRTC_REGISTER_TYPES_H
diff --git a/modules/websocket/register_types.h b/modules/websocket/register_types.h
index b254b9dae8..bb7be57ab3 100644
--- a/modules/websocket/register_types.h
+++ b/modules/websocket/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef WEBSOCKET_REGISTER_TYPES_H
+#define WEBSOCKET_REGISTER_TYPES_H
+
void register_websocket_types();
void unregister_websocket_types();
+
+#endif // WEBSOCKET_REGISTER_TYPES_H
diff --git a/modules/xatlas_unwrap/register_types.h b/modules/xatlas_unwrap/register_types.h
index 3f2181fa63..fe924bab96 100644
--- a/modules/xatlas_unwrap/register_types.h
+++ b/modules/xatlas_unwrap/register_types.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef XATLAS_UNWRAP_REGISTER_TYPES_H
+#define XATLAS_UNWRAP_REGISTER_TYPES_H
+
void register_xatlas_unwrap_types();
void unregister_xatlas_unwrap_types();
+
+#endif // XATLAS_UNWRAP_REGISTER_TYPES_H
diff --git a/platform/SCsub b/platform/SCsub
index 38bab59d74..40cacce674 100644
--- a/platform/SCsub
+++ b/platform/SCsub
@@ -1,7 +1,5 @@
#!/usr/bin/env python
-from compat import open_utf8
-
Import('env')
env.platform_sources = []
@@ -21,7 +19,7 @@ reg_apis += '}\n\n'
unreg_apis += '}\n'
# NOTE: It is safe to generate this file here, since this is still execute serially
-with open_utf8('register_platform_apis.gen.cpp', 'w') as f:
+with open('register_platform_apis.gen.cpp', 'w', encoding="utf-8") as f:
f.write(reg_apis_inc)
f.write(reg_apis)
f.write(unreg_apis)
diff --git a/platform/android/api/api.h b/platform/android/api/api.h
index c7296d92a7..5e951b9c88 100644
--- a/platform/android/api/api.h
+++ b/platform/android/api/api.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef ANDROID_API_H
+#define ANDROID_API_H
+
void register_android_api();
void unregister_android_api();
+
+#endif // ANDROID_API_H
diff --git a/platform/android/export/export.h b/platform/android/export/export.h
index ce786cc8b6..d11ab9f49e 100644
--- a/platform/android/export/export.h
+++ b/platform/android/export/export.h
@@ -28,4 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef ANDROID_EXPORT_H
+#define ANDROID_EXPORT_H
+
void register_android_exporter();
+
+#endif // ANDROID_EXPORT_H
diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java
index e745cdd0a5..e3683704e1 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
index b6d949b7bf..e13a9c15d8 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 8bbf41d82d..e018ee69f0 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "java_godot_lib_jni.h"
+
#include "java_godot_io_wrapper.h"
#include "java_godot_wrapper.h"
@@ -37,17 +38,18 @@
#include "api/java_class_wrapper.h"
#include "audio_driver_jandroid.h"
#include "core/engine.h"
+#include "core/input/input_filter.h"
#include "core/project_settings.h"
#include "dir_access_jandroid.h"
#include "file_access_android.h"
#include "file_access_jandroid.h"
#include "jni_utils.h"
-#include "main/input_default.h"
#include "main/main.h"
#include "net_socket_android.h"
#include "os_android.h"
#include "string_android.h"
#include "thread_jandroid.h"
+
#include <unistd.h>
static JavaClassWrapper *java_class_wrapper = NULL;
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 8021d6dd07..537230826c 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -39,8 +39,8 @@
#include "drivers/unix/file_access_unix.h"
#include "file_access_android.h"
#include "main/main.h"
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_wrap_mt.h"
#include "dir_access_jandroid.h"
#include "file_access_jandroid.h"
@@ -146,12 +146,12 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
video_driver_index = p_video_driver;
- visual_server = memnew(VisualServerRaster);
+ rendering_server = memnew(RenderingServerRaster);
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, false));
+ rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
}
- visual_server->init();
+ rendering_server->init();
AudioDriverManager::initialize(p_audio_driver);
@@ -306,14 +306,14 @@ void OS_Android::main_loop_end() {
void OS_Android::main_loop_focusout() {
if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+ main_loop->notification(NOTIFICATION_WM_FOCUS_OUT);
audio_driver_android.set_pause(true);
}
void OS_Android::main_loop_focusin() {
if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+ main_loop->notification(NOTIFICATION_WM_FOCUS_IN);
audio_driver_android.set_pause(false);
}
@@ -568,7 +568,7 @@ void OS_Android::init_video_mode(int p_video_width, int p_video_height) {
void OS_Android::main_loop_request_go_back() {
if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST);
+ main_loop->notification(NOTIFICATION_WM_GO_BACK_REQUEST);
}
void OS_Android::set_display_size(Size2 p_size) {
@@ -759,7 +759,7 @@ OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_god
//rasterizer = NULL;
use_gl2 = false;
- visual_server = NULL;
+ rendering_server = NULL;
godot_java = p_godot_java;
godot_io_java = p_godot_io_java;
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index ec6ffe5438..8a91412ef6 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -33,12 +33,11 @@
#include "audio_driver_jandroid.h"
#include "audio_driver_opensl.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/main_loop.h"
#include "drivers/unix/os_unix.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
+#include "servers/rendering/rasterizer.h"
class GodotJavaWrapper;
class GodotIOJavaWrapper;
@@ -76,7 +75,7 @@ private:
bool use_16bits_fbo;
- VisualServer *visual_server;
+ RenderingServer *rendering_server;
mutable String data_dir_cache;
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index 2d7efe6b61..18e1862d33 100644
--- a/platform/haiku/haiku_direct_window.cpp
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -74,7 +74,7 @@ void HaikuDirectWindow::SetMainLoop(MainLoop *p_main_loop) {
bool HaikuDirectWindow::QuitRequested() {
StopMessageRunner();
- main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
+ main_loop->notification(NOTIFICATION_WM_CLOSE_REQUEST);
return false;
}
diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h
index ccc9542f0e..925bb9ac5d 100644
--- a/platform/haiku/haiku_direct_window.h
+++ b/platform/haiku/haiku_direct_window.h
@@ -35,8 +35,8 @@
#include <DirectWindow.h>
+#include "core/input/input_filter.h"
#include "core/os/os.h"
-#include "main/input_default.h"
#include "haiku_gl_view.h"
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index a082ba53f9..7939ea0a1e 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -32,9 +32,9 @@
#include "drivers/gles2/rasterizer_gles2.h"
#include "main/main.h"
-#include "servers/physics/physics_server_sw.h"
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+#include "servers/physics_3d/physics_server_3d_sw.h"
+#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_wrap_mt.h"
#include <Screen.h>
@@ -116,13 +116,13 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p
RasterizerGLES2::make_current();
#endif
- visual_server = memnew(VisualServerRaster);
+ rendering_server = memnew(RenderingServerRaster);
// FIXME: Reimplement threaded rendering
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, false));
+ rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
}
- ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(!rendering_server, ERR_UNAVAILABLE);
video_driver_index = p_video_driver;
@@ -130,7 +130,7 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p
window->SetInput(input);
window->Show();
- visual_server->init();
+ rendering_server->init();
AudioDriverManager::initialize(p_audio_driver);
@@ -144,8 +144,8 @@ void OS_Haiku::finalize() {
main_loop = NULL;
- visual_server->finish();
- memdelete(visual_server);
+ rendering_server->finish();
+ memdelete(rendering_server);
memdelete(input);
@@ -267,7 +267,7 @@ void OS_Haiku::set_window_position(const Point2 &p_position) {
void OS_Haiku::set_window_fullscreen(bool p_enabled) {
window->SetFullScreen(p_enabled);
current_video_mode.fullscreen = p_enabled;
- visual_server->init();
+ rendering_server->init();
}
bool OS_Haiku::is_window_fullscreen() const {
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
index fc8cb77a91..64f5690dd1 100644
--- a/platform/haiku/os_haiku.h
+++ b/platform/haiku/os_haiku.h
@@ -33,12 +33,12 @@
#include "audio_driver_media_kit.h"
#include "context_gl_haiku.h"
+#include "core/input/input_filter.h"
#include "drivers/unix/os_unix.h"
#include "haiku_application.h"
#include "haiku_direct_window.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
class OS_Haiku : public OS_Unix {
private:
@@ -46,7 +46,7 @@ private:
HaikuDirectWindow *window;
MainLoop *main_loop;
InputDefault *input;
- VisualServer *visual_server;
+ RenderingServer *rendering_server;
VideoMode current_video_mode;
int video_driver_index;
diff --git a/platform/iphone/export/export.h b/platform/iphone/export/export.h
index 77b2a07bd1..043d21f533 100644
--- a/platform/iphone/export/export.h
+++ b/platform/iphone/export/export.h
@@ -28,4 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef IPHONE_EXPORT_H
+#define IPHONE_EXPORT_H
+
void register_iphone_exporter();
+
+#endif // IPHONE_EXPORT_H
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 497f2f747d..fe912621bb 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -37,13 +37,13 @@
#endif
#if defined(VULKAN_ENABLED)
-#include "servers/visual/rasterizer_rd/rasterizer_rd.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_rd.h"
// #import <QuartzCore/CAMetalLayer.h>
#include <vulkan/vulkan_metal.h>
#endif
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_wrap_mt.h"
#include "main/main.h"
@@ -134,16 +134,16 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p
RasterizerRD::make_current();
#endif
- visual_server = memnew(VisualServerRaster);
+ rendering_server = memnew(RenderingServerRaster);
// FIXME: Reimplement threaded rendering
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, false));
+ rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
}
- visual_server->init();
- //visual_server->cursor_set_visible(false, 0);
+ rendering_server->init();
+ //rendering_server->cursor_set_visible(false, 0);
#if defined(OPENGL_ENABLED)
- // reset this to what it should be, it will have been set to 0 after visual_server->init() is called
+ // reset this to what it should be, it will have been set to 0 after rendering_server->init() is called
RasterizerStorageGLES2::system_fbo = gl_view_base_fb;
#endif
@@ -361,8 +361,8 @@ void OSIPhone::finalize() {
memdelete(icloud);
#endif
- visual_server->finish();
- memdelete(visual_server);
+ rendering_server->finish();
+ memdelete(rendering_server);
// memdelete(rasterizer);
// Free unhandled events before close
@@ -636,7 +636,7 @@ OSIPhone::OSIPhone(int width, int height, String p_data_dir) {
ios_init_callbacks_capacity = 0;
main_loop = NULL;
- visual_server = NULL;
+ rendering_server = NULL;
VideoMode vm;
vm.fullscreen = true;
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index f42679e754..96cf041c37 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -33,18 +33,16 @@
#ifndef OS_IPHONE_H
#define OS_IPHONE_H
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "drivers/unix/os_unix.h"
-
#include "game_center.h"
#include "icloud.h"
#include "in_app_store.h"
#include "ios.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
#if defined(VULKAN_ENABLED)
#include "drivers/vulkan/rendering_device_vulkan.h"
@@ -62,7 +60,7 @@ private:
static HashMap<String, void *> dynamic_symbol_lookup_table;
friend void register_dynamic_symbol(char *name, void *address);
- VisualServer *visual_server;
+ RenderingServer *rendering_server;
AudioDriverCoreAudio audio_driver;
diff --git a/platform/iphone/vulkan_context_iphone.h b/platform/iphone/vulkan_context_iphone.h
index 200057e14d..625e41f4b9 100644
--- a/platform/iphone/vulkan_context_iphone.h
+++ b/platform/iphone/vulkan_context_iphone.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* vulkan_context_osx.h */
+/* vulkan_context_iphone.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/platform/iphone/vulkan_context_iphone.mm b/platform/iphone/vulkan_context_iphone.mm
index f49b85c097..701ac0d9bb 100644
--- a/platform/iphone/vulkan_context_iphone.mm
+++ b/platform/iphone/vulkan_context_iphone.mm
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* vulkan_context_osx.mm */
+/* vulkan_context_iphone.mm */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/platform/javascript/api/api.h b/platform/javascript/api/api.h
index 164d679205..8afe0f33ce 100644
--- a/platform/javascript/api/api.h
+++ b/platform/javascript/api/api.h
@@ -28,5 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef JAVASCRIPT_API_H
+#define JAVASCRIPT_API_H
+
void register_javascript_api();
void unregister_javascript_api();
+
+#endif // JAVASCRIPT_API_H
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index db90b01f8f..40c42a5c03 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -36,7 +36,7 @@
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
#include "main/main.h"
-#include "servers/visual/visual_server_raster.h"
+#include "servers/rendering/rendering_server_raster.h"
#include <emscripten.h>
#include <png.h>
@@ -962,7 +962,7 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
setenv("LANG", locale_ptr, true);
AudioDriverManager::initialize(p_audio_driver);
- VisualServer *visual_server = memnew(VisualServerRaster());
+ RenderingServer *rendering_server = memnew(RenderingServerRaster());
input = memnew(InputDefault);
EMSCRIPTEN_RESULT result;
@@ -1009,14 +1009,14 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
update_clipboard(evt.clipboardData.getData('text'));
}, true);
},
- MainLoop::NOTIFICATION_WM_MOUSE_ENTER,
- MainLoop::NOTIFICATION_WM_MOUSE_EXIT,
- MainLoop::NOTIFICATION_WM_FOCUS_IN,
- MainLoop::NOTIFICATION_WM_FOCUS_OUT
+ NOTIFICATION_WM_MOUSE_ENTER,
+ NOTIFICATION_WM_MOUSE_EXIT,
+ NOTIFICATION_WM_FOCUS_IN,
+ NOTIFICATION_WM_FOCUS_OUT
);
/* clang-format on */
- visual_server->init();
+ rendering_server->init();
return OK;
}
@@ -1121,8 +1121,8 @@ int OS_JavaScript::get_process_id() const {
extern "C" EMSCRIPTEN_KEEPALIVE void send_notification(int p_notification) {
- if (p_notification == MainLoop::NOTIFICATION_WM_MOUSE_ENTER || p_notification == MainLoop::NOTIFICATION_WM_MOUSE_EXIT) {
- cursor_inside_canvas = p_notification == MainLoop::NOTIFICATION_WM_MOUSE_ENTER;
+ if (p_notification == NOTIFICATION_WM_MOUSE_ENTER || p_notification == NOTIFICATION_WM_MOUSE_EXIT) {
+ cursor_inside_canvas = p_notification == NOTIFICATION_WM_MOUSE_ENTER;
}
OS_JavaScript::get_singleton()->get_main_loop()->notification(p_notification);
}
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index ed59477914..368e9a2155 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -32,10 +32,10 @@
#define OS_JAVASCRIPT_H
#include "audio_driver_javascript.h"
+#include "core/input/input_filter.h"
#include "drivers/unix/os_unix.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
+#include "servers/rendering/rasterizer.h"
#include <emscripten/html5.h>
diff --git a/platform/linuxbsd/SCsub b/platform/linuxbsd/SCsub
new file mode 100644
index 0000000000..f3f65e216e
--- /dev/null
+++ b/platform/linuxbsd/SCsub
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+Import('env')
+
+from platform_methods import run_in_subprocess
+import platform_linuxbsd_builders
+
+common_x11 = [
+ "crash_handler_linuxbsd.cpp",
+ "os_linuxbsd.cpp",
+ "joypad_linux.cpp",
+ "context_gl_x11.cpp",
+ "detect_prime_x11.cpp",
+ "display_server_x11.cpp",
+ "vulkan_context_x11.cpp",
+ "key_mapping_x11.cpp",
+
+]
+
+prog = env.add_program('#bin/godot', ['godot_linuxbsd.cpp'] + common_x11)
+
+if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]:
+ env.AddPostAction(prog, run_in_subprocess(platform_linuxbsd_builders.make_debug_linuxbsd))
diff --git a/platform/x11/context_gl_x11.cpp b/platform/linuxbsd/context_gl_x11.cpp
index 5442af3bef..5442af3bef 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/linuxbsd/context_gl_x11.cpp
diff --git a/platform/x11/context_gl_x11.h b/platform/linuxbsd/context_gl_x11.h
index 2c0643c95a..2c0643c95a 100644
--- a/platform/x11/context_gl_x11.h
+++ b/platform/linuxbsd/context_gl_x11.h
diff --git a/platform/x11/crash_handler_x11.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp
index 19c8f71d0e..1b3804e3ed 100644
--- a/platform/x11/crash_handler_x11.cpp
+++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* crash_handler_x11.cpp */
+/* crash_handler_linuxbsd.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "crash_handler_x11.h"
+#include "crash_handler_linuxbsd.h"
#include "core/os/os.h"
#include "core/project_settings.h"
diff --git a/platform/x11/crash_handler_x11.h b/platform/linuxbsd/crash_handler_linuxbsd.h
index 98620cc789..94b4649690 100644
--- a/platform/x11/crash_handler_x11.h
+++ b/platform/linuxbsd/crash_handler_linuxbsd.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* crash_handler_x11.h */
+/* crash_handler_linuxbsd.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/platform/x11/detect.py b/platform/linuxbsd/detect.py
index 9a9ab86068..1a395efffe 100644
--- a/platform/x11/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -8,7 +8,7 @@ def is_active():
def get_name():
- return "X11"
+ return "LinuxBSD"
def can_build():
@@ -317,7 +317,7 @@ def configure(env):
if not env['builtin_zlib']:
env.ParseConfig('pkg-config zlib --cflags --libs')
- env.Prepend(CPPPATH=['#platform/x11'])
+ env.Prepend(CPPPATH=['#platform/linuxbsd'])
env.Append(CPPDEFINES=['X11_ENABLED', 'UNIX_ENABLED'])
env.Append(CPPDEFINES=['VULKAN_ENABLED'])
@@ -350,9 +350,9 @@ def configure(env):
print("Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld")
else:
if float(gnu_ld_version.group(1)) >= 2.30:
- env.Append(LINKFLAGS=['-T', 'platform/x11/pck_embed.ld'])
+ env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.ld'])
else:
- env.Append(LINKFLAGS=['-T', 'platform/x11/pck_embed.legacy.ld'])
+ env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.legacy.ld'])
## Cross-compilation
diff --git a/platform/x11/detect_prime.cpp b/platform/linuxbsd/detect_prime_x11.cpp
index a0e5f835c0..69b0837e6c 100644
--- a/platform/x11/detect_prime.cpp
+++ b/platform/linuxbsd/detect_prime_x11.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* detect_prime.cpp */
+/* detect_prime_x11.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,6 +31,8 @@
#ifdef X11_ENABLED
#if defined(OPENGL_ENABLED)
+#include "detect_prime.h"
+
#include "core/print_string.h"
#include "core/ustring.h"
diff --git a/platform/x11/detect_prime.h b/platform/linuxbsd/detect_prime_x11.h
index df636449f4..039bdee76b 100644
--- a/platform/x11/detect_prime.h
+++ b/platform/linuxbsd/detect_prime_x11.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* detect_prime.h */
+/* detect_prime_x11.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/platform/x11/os_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index e1f7691cf6..c2b5657081 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* os_x11.cpp */
+/* display_server_x11.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "os_x11.h"
-#include "detect_prime.h"
+#include "display_server_x11.h"
+
+#ifdef X11_ENABLED
+
+#include "detect_prime_x11.h"
#include "core/os/dir_access.h"
#include "core/print_string.h"
@@ -41,11 +44,10 @@
#endif
#if defined(VULKAN_ENABLED)
-#include "servers/visual/rasterizer_rd/rasterizer_rd.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_rd.h"
#endif
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+#include "scene/resources/texture.h"
#ifdef HAVE_MNTENT
#include <mntent.h>
@@ -86,6 +88,8 @@
#include <X11/XKBlib.h>
+#include "core/project_settings.h"
+
// 2.2 is the first release with multitouch
#define XINPUT_CLIENT_VERSION_MAJOR 2
#define XINPUT_CLIENT_VERSION_MINOR 2
@@ -99,584 +103,117 @@
static const double abs_resolution_mult = 10000.0;
static const double abs_resolution_range_mult = 10.0;
-void OS_X11::initialize_core() {
-
- crash_handler.initialize();
-
- OS_Unix::initialize_core();
-}
-
-int OS_X11::get_current_video_driver() const {
- return video_driver_index;
-}
-
-Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
-
- long im_event_mask = 0;
- last_button_state = 0;
-
- xmbstring = NULL;
- x11_window = 0;
- last_click_ms = 0;
- last_click_button_index = -1;
- last_click_pos = Point2(-100, -100);
- args = OS::get_singleton()->get_cmdline_args();
- current_videomode = p_desired;
- main_loop = NULL;
- last_timestamp = 0;
- last_mouse_pos_valid = false;
- last_keyrelease_time = 0;
- xdnd_version = 0;
-
- if (get_render_thread_mode() == RENDER_SEPARATE_THREAD) {
- XInitThreads();
- }
-
- /** XLIB INITIALIZATION **/
- x11_display = XOpenDisplay(NULL);
-
- if (!x11_display) {
- ERR_PRINT("X11 Display is not available");
- return ERR_UNAVAILABLE;
- }
-
- char *modifiers = NULL;
- Bool xkb_dar = False;
- XAutoRepeatOn(x11_display);
- xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL);
-
- // Try to support IME if detectable auto-repeat is supported
- if (xkb_dar == True) {
-
-#ifdef X_HAVE_UTF8_STRING
- // Xutf8LookupString will be used later instead of XmbLookupString before
- // the multibyte sequences can be converted to unicode string.
- modifiers = XSetLocaleModifiers("");
+bool DisplayServerX11::has_feature(Feature p_feature) const {
+ switch (p_feature) {
+ case FEATURE_SUBWINDOWS:
+#ifdef TOUCH_ENABLED
+ case FEATURE_TOUCHSCREEN:
#endif
- }
-
- if (modifiers == NULL) {
- if (is_stdout_verbose()) {
- WARN_PRINT("IME is disabled");
- }
- XSetLocaleModifiers("@im=none");
- WARN_PRINT("Error setting locale modifiers");
- }
-
- const char *err;
- xrr_get_monitors = NULL;
- xrr_free_monitors = NULL;
- int xrandr_major = 0;
- int xrandr_minor = 0;
- int event_base, error_base;
- xrandr_ext_ok = XRRQueryExtension(x11_display, &event_base, &error_base);
- xrandr_handle = dlopen("libXrandr.so.2", RTLD_LAZY);
- if (!xrandr_handle) {
- err = dlerror();
- fprintf(stderr, "could not load libXrandr.so.2, Error: %s\n", err);
- } else {
- XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor);
- if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) {
- xrr_get_monitors = (xrr_get_monitors_t)dlsym(xrandr_handle, "XRRGetMonitors");
- if (!xrr_get_monitors) {
- err = dlerror();
- fprintf(stderr, "could not find symbol XRRGetMonitors\nError: %s\n", err);
- } else {
- xrr_free_monitors = (xrr_free_monitors_t)dlsym(xrandr_handle, "XRRFreeMonitors");
- if (!xrr_free_monitors) {
- err = dlerror();
- fprintf(stderr, "could not find XRRFreeMonitors\nError: %s\n", err);
- xrr_get_monitors = NULL;
- }
- }
- }
- }
-
- if (!refresh_device_info()) {
- OS::get_singleton()->alert("Your system does not support XInput 2.\n"
- "Please upgrade your distribution.",
- "Unable to initialize XInput");
- return ERR_UNAVAILABLE;
- }
-
- xim = XOpenIM(x11_display, NULL, NULL, NULL);
-
- if (xim == NULL) {
- WARN_PRINT("XOpenIM failed");
- xim_style = 0L;
- } else {
- ::XIMCallback im_destroy_callback;
- im_destroy_callback.client_data = (::XPointer)(this);
- im_destroy_callback.callback = (::XIMProc)(xim_destroy_callback);
- if (XSetIMValues(xim, XNDestroyCallback, &im_destroy_callback,
- NULL) != NULL) {
- WARN_PRINT("Error setting XIM destroy callback");
- }
-
- ::XIMStyles *xim_styles = NULL;
- xim_style = 0L;
- char *imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
- if (imvalret != NULL || xim_styles == NULL) {
- fprintf(stderr, "Input method doesn't support any styles\n");
- }
-
- if (xim_styles) {
- xim_style = 0L;
- for (int i = 0; i < xim_styles->count_styles; i++) {
-
- if (xim_styles->supported_styles[i] ==
- (XIMPreeditNothing | XIMStatusNothing)) {
-
- xim_style = xim_styles->supported_styles[i];
- break;
- }
- }
-
- XFree(xim_styles);
+ case FEATURE_MOUSE:
+ case FEATURE_MOUSE_WARP:
+ case FEATURE_CLIPBOARD:
+ case FEATURE_CURSOR_SHAPE:
+ case FEATURE_CUSTOM_CURSOR_SHAPE:
+ case FEATURE_IME:
+ case FEATURE_WINDOW_TRANSPARENCY:
+ //case FEATURE_HIDPI:
+ case FEATURE_ICON:
+ case FEATURE_NATIVE_ICON:
+ case FEATURE_SWAP_BUFFERS:
+ return true;
+ default: {
}
- XFree(imvalret);
}
- //!!!!!!!!!!!!!!!!!!!!!!!!!!
- //TODO - do Vulkan and GLES2 support checks, driver selection and fallback
- video_driver_index = p_video_driver;
-#ifndef _MSC_VER
-#warning Forcing vulkan video driver because OpenGL not implemented yet
-#endif
- video_driver_index = VIDEO_DRIVER_VULKAN;
-
- print_verbose("Driver: " + String(get_video_driver_name(video_driver_index)) + " [" + itos(video_driver_index) + "]");
- //!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- //Create window
-
- long visualMask = VisualScreenMask;
- int numberOfVisuals;
- XVisualInfo vInfoTemplate = {};
- vInfoTemplate.screen = DefaultScreen(x11_display);
- XVisualInfo *visualInfo = XGetVisualInfo(x11_display, visualMask, &vInfoTemplate, &numberOfVisuals);
-
- Colormap colormap = XCreateColormap(x11_display, RootWindow(x11_display, vInfoTemplate.screen), visualInfo->visual, AllocNone);
-
- XSetWindowAttributes windowAttributes = {};
- windowAttributes.colormap = colormap;
- windowAttributes.background_pixel = 0xFFFFFFFF;
- windowAttributes.border_pixel = 0;
- windowAttributes.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask | ExposureMask;
-
- unsigned long valuemask = CWBorderPixel | CWColormap | CWEventMask;
- x11_window = XCreateWindow(x11_display, RootWindow(x11_display, visualInfo->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, visualInfo->depth, InputOutput, visualInfo->visual, valuemask, &windowAttributes);
-
- //set_class_hint(x11_display, x11_window);
- XMapWindow(x11_display, x11_window);
- XFlush(x11_display);
-
- XSync(x11_display, False);
- //XSetErrorHandler(oldHandler);
-
- XFree(visualInfo);
-
- // Init context and rendering device
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- if (getenv("DRI_PRIME") == NULL) {
- int use_prime = -1;
-
- if (getenv("PRIMUS_DISPLAY") ||
- getenv("PRIMUS_libGLd") ||
- getenv("PRIMUS_libGLa") ||
- getenv("PRIMUS_libGL") ||
- getenv("PRIMUS_LOAD_GLOBAL") ||
- getenv("BUMBLEBEE_SOCKET")) {
-
- print_verbose("Optirun/primusrun detected. Skipping GPU detection");
- use_prime = 0;
- }
-
- if (getenv("LD_LIBRARY_PATH")) {
- String ld_library_path(getenv("LD_LIBRARY_PATH"));
- Vector<String> libraries = ld_library_path.split(":");
+ return false;
+}
+String DisplayServerX11::get_name() const {
+ return "X11";
+}
- for (int i = 0; i < libraries.size(); ++i) {
- if (FileAccess::exists(libraries[i] + "/libGL.so.1") ||
- FileAccess::exists(libraries[i] + "/libGL.so")) {
+void DisplayServerX11::alert(const String &p_alert, const String &p_title) {
+ const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" };
- print_verbose("Custom libGL override detected. Skipping GPU detection");
- use_prime = 0;
- }
- }
- }
+ String path = OS::get_singleton()->get_environment("PATH");
+ Vector<String> path_elems = path.split(":", false);
+ String program;
- if (use_prime == -1) {
- print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
- use_prime = detect_prime();
- }
+ for (int i = 0; i < path_elems.size(); i++) {
+ for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) {
+ String tested_path = path_elems[i].plus_file(message_programs[k]);
- if (use_prime) {
- print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");
- print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
- setenv("DRI_PRIME", "1", 1);
+ if (FileAccess::exists(tested_path)) {
+ program = tested_path;
+ break;
}
}
- ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
-
- context_gles2 = memnew(ContextGL_X11(x11_display, x11_window, current_videomode, opengl_api_type));
-
- if (context_gles2->initialize() != OK) {
- memdelete(context_gles2);
- context_gles2 = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- context_gles2->set_use_vsync(current_videomode.use_vsync);
-
- if (RasterizerGLES2::is_viable() == OK) {
- RasterizerGLES2::register_config();
- RasterizerGLES2::make_current();
- } else {
- memdelete(context_gles2);
- context_gles2 = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
-
- context_vulkan = memnew(VulkanContextX11);
- if (context_vulkan->initialize() != OK) {
- memdelete(context_vulkan);
- context_vulkan = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- if (context_vulkan->window_create(x11_window, x11_display, get_video_mode().width, get_video_mode().height) == -1) {
- memdelete(context_vulkan);
- context_vulkan = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- //temporary
- rendering_device_vulkan = memnew(RenderingDeviceVulkan);
- rendering_device_vulkan->initialize(context_vulkan);
-
- RasterizerRD::make_current();
- }
-#endif
-
- visual_server = memnew(VisualServerRaster);
- if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
+ if (program.length())
+ break;
}
- if (current_videomode.maximized) {
- current_videomode.maximized = false;
- set_window_maximized(true);
- // borderless fullscreen window mode
- } else if (current_videomode.fullscreen) {
- current_videomode.fullscreen = false;
- set_window_fullscreen(true);
- } else if (current_videomode.borderless_window) {
- Hints hints;
- Atom property;
- hints.flags = 2;
- hints.decorations = 0;
- property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
- XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
- }
+ List<String> args;
- // make PID known to X11
- {
- const long pid = this->get_process_id();
- Atom net_wm_pid = XInternAtom(x11_display, "_NET_WM_PID", False);
- XChangeProperty(x11_display, x11_window, net_wm_pid, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1);
+ if (program.ends_with("zenity")) {
+ args.push_back("--error");
+ args.push_back("--width");
+ args.push_back("500");
+ args.push_back("--title");
+ args.push_back(p_title);
+ args.push_back("--text");
+ args.push_back(p_alert);
}
- // disable resizable window
- if (!current_videomode.resizable && !current_videomode.fullscreen) {
- XSizeHints *xsh;
- xsh = XAllocSizeHints();
- xsh->flags = PMinSize | PMaxSize;
- XWindowAttributes xwa;
- if (current_videomode.fullscreen) {
- XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa);
- } else {
- XGetWindowAttributes(x11_display, x11_window, &xwa);
- }
- xsh->min_width = xwa.width;
- xsh->max_width = xwa.width;
- xsh->min_height = xwa.height;
- xsh->max_height = xwa.height;
- XSetWMNormalHints(x11_display, x11_window, xsh);
- XFree(xsh);
+ if (program.ends_with("kdialog")) {
+ args.push_back("--error");
+ args.push_back(p_alert);
+ args.push_back("--title");
+ args.push_back(p_title);
}
- if (current_videomode.always_on_top) {
- current_videomode.always_on_top = false;
- set_window_always_on_top(true);
+ if (program.ends_with("Xdialog")) {
+ args.push_back("--title");
+ args.push_back(p_title);
+ args.push_back("--msgbox");
+ args.push_back(p_alert);
+ args.push_back("0");
+ args.push_back("0");
}
- ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
- ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE);
-
- XSetWindowAttributes new_attr;
-
- new_attr.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask | EnterWindowMask |
- LeaveWindowMask | PointerMotionMask |
- Button1MotionMask |
- Button2MotionMask | Button3MotionMask |
- Button4MotionMask | Button5MotionMask |
- ButtonMotionMask | KeymapStateMask |
- ExposureMask | VisibilityChangeMask |
- StructureNotifyMask |
- SubstructureNotifyMask | SubstructureRedirectMask |
- FocusChangeMask | PropertyChangeMask |
- ColormapChangeMask | OwnerGrabButtonMask |
- im_event_mask;
-
- XChangeWindowAttributes(x11_display, x11_window, CWEventMask, &new_attr);
-
- static unsigned char all_mask_data[XIMaskLen(XI_LASTEVENT)] = {};
- static unsigned char all_master_mask_data[XIMaskLen(XI_LASTEVENT)] = {};
-
- xi.all_event_mask.deviceid = XIAllDevices;
- xi.all_event_mask.mask_len = sizeof(all_mask_data);
- xi.all_event_mask.mask = all_mask_data;
-
- xi.all_master_event_mask.deviceid = XIAllMasterDevices;
- xi.all_master_event_mask.mask_len = sizeof(all_master_mask_data);
- xi.all_master_event_mask.mask = all_master_mask_data;
-
- XISetMask(xi.all_event_mask.mask, XI_HierarchyChanged);
- XISetMask(xi.all_master_event_mask.mask, XI_DeviceChanged);
- XISetMask(xi.all_master_event_mask.mask, XI_RawMotion);
-
-#ifdef TOUCH_ENABLED
- if (xi.touch_devices.size()) {
- XISetMask(xi.all_event_mask.mask, XI_TouchBegin);
- XISetMask(xi.all_event_mask.mask, XI_TouchUpdate);
- XISetMask(xi.all_event_mask.mask, XI_TouchEnd);
- XISetMask(xi.all_event_mask.mask, XI_TouchOwnership);
+ if (program.ends_with("xmessage")) {
+ args.push_back("-center");
+ args.push_back("-title");
+ args.push_back(p_title);
+ args.push_back(p_alert);
}
-#endif
-
- XISelectEvents(x11_display, x11_window, &xi.all_event_mask, 1);
- XISelectEvents(x11_display, DefaultRootWindow(x11_display), &xi.all_master_event_mask, 1);
- // Disabled by now since grabbing also blocks mouse events
- // (they are received as extended events instead of standard events)
- /*XIClearMask(xi.touch_event_mask.mask, XI_TouchOwnership);
-
- // Grab touch devices to avoid OS gesture interference
- for (int i = 0; i < xi.touch_devices.size(); ++i) {
- XIGrabDevice(x11_display, xi.touch_devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &xi.touch_event_mask);
- }*/
-
- /* set the titlebar name */
- XStoreName(x11_display, x11_window, "Godot");
-
- wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
- XSetWMProtocols(x11_display, x11_window, &wm_delete, 1);
-
- im_active = false;
- im_position = Vector2();
-
- if (xim && xim_style) {
-
- xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, x11_window, XNFocusWindow, x11_window, (char *)NULL);
- if (XGetICValues(xic, XNFilterEvents, &im_event_mask, NULL) != NULL) {
- WARN_PRINT("XGetICValues couldn't obtain XNFilterEvents value");
- XDestroyIC(xic);
- xic = NULL;
- }
- if (xic) {
- XUnsetICFocus(xic);
- } else {
- WARN_PRINT("XCreateIC couldn't create xic");
- }
+ if (program.length()) {
+ OS::get_singleton()->execute(program, args, true);
} else {
-
- xic = NULL;
- WARN_PRINT("XCreateIC couldn't create xic");
- }
-
- cursor_size = XcursorGetDefaultSize(x11_display);
- cursor_theme = XcursorGetTheme(x11_display);
-
- if (!cursor_theme) {
- print_verbose("XcursorGetTheme could not get cursor theme");
- cursor_theme = "default";
- }
-
- for (int i = 0; i < CURSOR_MAX; i++) {
-
- cursors[i] = None;
- img[i] = NULL;
- }
-
- current_cursor = CURSOR_ARROW;
-
- for (int i = 0; i < CURSOR_MAX; i++) {
-
- static const char *cursor_file[] = {
- "left_ptr",
- "xterm",
- "hand2",
- "cross",
- "watch",
- "left_ptr_watch",
- "fleur",
- "dnd-move",
- "crossed_circle",
- "v_double_arrow",
- "h_double_arrow",
- "size_bdiag",
- "size_fdiag",
- "move",
- "row_resize",
- "col_resize",
- "question_arrow"
- };
-
- img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size);
- if (!img[i]) {
- const char *fallback = NULL;
-
- switch (i) {
- case CURSOR_POINTING_HAND:
- fallback = "pointer";
- break;
- case CURSOR_CROSS:
- fallback = "crosshair";
- break;
- case CURSOR_WAIT:
- fallback = "wait";
- break;
- case CURSOR_BUSY:
- fallback = "progress";
- break;
- case CURSOR_DRAG:
- fallback = "grabbing";
- break;
- case CURSOR_CAN_DROP:
- fallback = "hand1";
- break;
- case CURSOR_FORBIDDEN:
- fallback = "forbidden";
- break;
- case CURSOR_VSIZE:
- fallback = "ns-resize";
- break;
- case CURSOR_HSIZE:
- fallback = "ew-resize";
- break;
- case CURSOR_BDIAGSIZE:
- fallback = "fd_double_arrow";
- break;
- case CURSOR_FDIAGSIZE:
- fallback = "bd_double_arrow";
- break;
- case CURSOR_MOVE:
- img[i] = img[CURSOR_DRAG];
- break;
- case CURSOR_VSPLIT:
- fallback = "sb_v_double_arrow";
- break;
- case CURSOR_HSPLIT:
- fallback = "sb_h_double_arrow";
- break;
- case CURSOR_HELP:
- fallback = "help";
- break;
- }
- if (fallback != NULL) {
- img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size);
- }
- }
- if (img[i]) {
- cursors[i] = XcursorImageLoadCursor(x11_display, img[i]);
- } else {
- print_verbose("Failed loading custom cursor: " + String(cursor_file[i]));
- }
- }
-
- {
- // Creating an empty/transparent cursor
-
- // Create 1x1 bitmap
- Pixmap cursormask = XCreatePixmap(x11_display,
- RootWindow(x11_display, DefaultScreen(x11_display)), 1, 1, 1);
-
- // Fill with zero
- XGCValues xgc;
- xgc.function = GXclear;
- GC gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc);
- XFillRectangle(x11_display, cursormask, gc, 0, 0, 1, 1);
-
- // Color value doesn't matter. Mask zero means no foreground or background will be drawn
- XColor col = {};
-
- Cursor cursor = XCreatePixmapCursor(x11_display,
- cursormask, // source (using cursor mask as placeholder, since it'll all be ignored)
- cursormask, // mask
- &col, &col, 0, 0);
-
- XFreePixmap(x11_display, cursormask);
- XFreeGC(x11_display, gc);
-
- if (cursor == None) {
- ERR_PRINT("FAILED CREATING CURSOR");
- }
-
- null_cursor = cursor;
+ print_line(p_alert);
}
- set_cursor_shape(CURSOR_BUSY);
-
- //Set Xdnd (drag & drop) support
- Atom XdndAware = XInternAtom(x11_display, "XdndAware", False);
- Atom version = 5;
- XChangeProperty(x11_display, x11_window, XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char *)&version, 1);
-
- xdnd_enter = XInternAtom(x11_display, "XdndEnter", False);
- xdnd_position = XInternAtom(x11_display, "XdndPosition", False);
- xdnd_status = XInternAtom(x11_display, "XdndStatus", False);
- xdnd_action_copy = XInternAtom(x11_display, "XdndActionCopy", False);
- xdnd_drop = XInternAtom(x11_display, "XdndDrop", False);
- xdnd_finished = XInternAtom(x11_display, "XdndFinished", False);
- xdnd_selection = XInternAtom(x11_display, "XdndSelection", False);
- requested = None;
-
- visual_server->init();
-
- AudioDriverManager::initialize(p_audio_driver);
+}
- input = memnew(InputDefault);
+void DisplayServerX11::_update_real_mouse_position(const WindowData &wd) {
+ Window root_return, child_return;
+ int root_x, root_y, win_x, win_y;
+ unsigned int mask_return;
- window_has_focus = true; // Set focus to true at init
-#ifdef JOYDEV_ENABLED
- joypad = memnew(JoypadLinux(input));
-#endif
- _ensure_user_data_dir();
+ Bool xquerypointer_result = XQueryPointer(x11_display, wd.x11_window, &root_return, &child_return, &root_x, &root_y,
+ &win_x, &win_y, &mask_return);
- if (p_desired.layered) {
- set_window_per_pixel_transparency_enabled(true);
- }
+ if (xquerypointer_result) {
+ if (win_x > 0 && win_y > 0 && win_x <= wd.size.width && win_y <= wd.size.height) {
- XEvent xevent;
- while (XPending(x11_display) > 0) {
- XNextEvent(x11_display, &xevent);
- if (xevent.type == ConfigureNotify) {
- _window_changed(&xevent);
+ last_mouse_pos.x = win_x;
+ last_mouse_pos.y = win_y;
+ last_mouse_pos_valid = true;
+ InputFilter::get_singleton()->set_mouse_position(last_mouse_pos);
}
}
-
- update_real_mouse_position();
-
- return OK;
}
-bool OS_X11::refresh_device_info() {
+bool DisplayServerX11::_refresh_device_info() {
int event_base, error_base;
print_verbose("XInput: Refreshing devices.");
@@ -786,136 +323,35 @@ bool OS_X11::refresh_device_info() {
return true;
}
-void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
- ::XPointer call_data) {
-
- WARN_PRINT("Input method stopped");
- OS_X11 *os = reinterpret_cast<OS_X11 *>(client_data);
- os->xim = NULL;
- os->xic = NULL;
-}
-
-void OS_X11::set_ime_active(const bool p_active) {
-
- im_active = p_active;
-
- if (!xic)
- return;
-
- if (p_active) {
- XSetICFocus(xic);
- set_ime_position(im_position);
- } else {
- XUnsetICFocus(xic);
- }
-}
-
-void OS_X11::set_ime_position(const Point2 &p_pos) {
-
- im_position = p_pos;
-
- if (!xic)
- return;
-
- ::XPoint spot;
- spot.x = short(p_pos.x);
- spot.y = short(p_pos.y);
- XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
- XSetICValues(xic, XNPreeditAttributes, preedit_attr, NULL);
- XFree(preedit_attr);
-}
+void DisplayServerX11::_flush_mouse_motion() {
+ while (true) {
+ if (XPending(x11_display) > 0) {
+ XEvent event;
+ XPeekEvent(x11_display, &event);
-String OS_X11::get_unique_id() const {
+ if (XGetEventData(x11_display, &event.xcookie) && event.xcookie.type == GenericEvent && event.xcookie.extension == xi.opcode) {
+ XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data;
- static String machine_id;
- if (machine_id.empty()) {
- if (FileAccess *f = FileAccess::open("/etc/machine-id", FileAccess::READ)) {
- while (machine_id.empty() && !f->eof_reached()) {
- machine_id = f->get_line().strip_edges();
+ if (event_data->evtype == XI_RawMotion) {
+ XNextEvent(x11_display, &event);
+ } else {
+ break;
+ }
+ } else {
+ break;
}
- f->close();
- memdelete(f);
- }
- }
- return machine_id;
-}
-
-void OS_X11::finalize() {
-
- if (main_loop)
- memdelete(main_loop);
- main_loop = NULL;
-
- /*
- if (debugger_connection_console) {
- memdelete(debugger_connection_console);
- }
- */
-#ifdef ALSAMIDI_ENABLED
- driver_alsamidi.close();
-#endif
-
-#ifdef JOYDEV_ENABLED
- memdelete(joypad);
-#endif
-
- xi.touch_devices.clear();
- xi.state.clear();
-
- memdelete(input);
-
- cursors_cache.clear();
- visual_server->finish();
- memdelete(visual_server);
-
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
-
- if (context_gles2)
- memdelete(context_gles2);
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
-
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
+ } else {
+ break;
}
-
- if (context_vulkan)
- memdelete(context_vulkan);
- }
-#endif
-
- if (xrandr_handle)
- dlclose(xrandr_handle);
-
- XUnmapWindow(x11_display, x11_window);
- XDestroyWindow(x11_display, x11_window);
-
- for (int i = 0; i < CURSOR_MAX; i++) {
- if (cursors[i] != None)
- XFreeCursor(x11_display, cursors[i]);
- if (img[i] != NULL)
- XcursorImageDestroy(img[i]);
- };
-
- if (xic) {
- XDestroyIC(xic);
- }
- if (xim) {
- XCloseIM(xim);
}
- XCloseDisplay(x11_display);
- if (xmbstring)
- memfree(xmbstring);
-
- args.clear();
+ xi.relative_motion.x = 0;
+ xi.relative_motion.y = 0;
}
-void OS_X11::set_mouse_mode(MouseMode p_mode) {
+void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
+
+ _THREAD_SAFE_METHOD_
if (p_mode == mouse_mode)
return;
@@ -926,34 +362,37 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
// The only modes that show a cursor are VISIBLE and CONFINED
bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
- if (showCursor) {
- XDefineCursor(x11_display, x11_window, cursors[current_cursor]); // show cursor
- } else {
- XDefineCursor(x11_display, x11_window, null_cursor); // hide cursor
- }
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (showCursor) {
+ XDefineCursor(x11_display, E->get().x11_window, cursors[current_cursor]); // show cursor
+ } else {
+ XDefineCursor(x11_display, E->get().x11_window, null_cursor); // hide cursor
+ }
+ }
mouse_mode = p_mode;
if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) {
//flush pending motion events
- flush_mouse_motion();
+ _flush_mouse_motion();
+ WindowData &main_window = windows[MAIN_WINDOW_ID];
if (XGrabPointer(
- x11_display, x11_window, True,
+ x11_display, main_window.x11_window, True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
- GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime) != GrabSuccess) {
+ GrabModeAsync, GrabModeAsync, windows[MAIN_WINDOW_ID].x11_window, None, CurrentTime) != GrabSuccess) {
ERR_PRINT("NO GRAB");
}
if (mouse_mode == MOUSE_MODE_CAPTURED) {
- center.x = current_videomode.width / 2;
- center.y = current_videomode.height / 2;
+ center.x = main_window.size.width / 2;
+ center.y = main_window.size.height / 2;
- XWarpPointer(x11_display, None, x11_window,
+ XWarpPointer(x11_display, None, main_window.x11_window,
0, 0, 0, 0, (int)center.x, (int)center.y);
- input->set_mouse_position(center);
+ InputFilter::get_singleton()->set_mouse_position(center);
}
} else {
do_mouse_warp = false;
@@ -961,8 +400,13 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
XFlush(x11_display);
}
+DisplayServerX11::MouseMode DisplayServerX11::mouse_get_mode() const {
+ return mouse_mode;
+}
+
+void DisplayServerX11::mouse_warp_to_position(const Point2i &p_to) {
-void OS_X11::warp_mouse_position(const Point2 &p_to) {
+ _THREAD_SAFE_METHOD_
if (mouse_mode == MOUSE_MODE_CAPTURED) {
@@ -973,184 +417,133 @@ void OS_X11::warp_mouse_position(const Point2 &p_to) {
XGetWindowAttributes(x11_display, x11_window, &xwa);
printf("%d %d\n", xwa.x, xwa.y); needed? */
- XWarpPointer(x11_display, None, x11_window,
+ XWarpPointer(x11_display, None, windows[MAIN_WINDOW_ID].x11_window,
0, 0, 0, 0, (int)p_to.x, (int)p_to.y);
}
}
-void OS_X11::flush_mouse_motion() {
- while (true) {
- if (XPending(x11_display) > 0) {
- XEvent event;
- XPeekEvent(x11_display, &event);
+Point2i DisplayServerX11::mouse_get_position() const {
+ return last_mouse_pos;
+}
- if (XGetEventData(x11_display, &event.xcookie) && event.xcookie.type == GenericEvent && event.xcookie.extension == xi.opcode) {
- XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data;
+Point2i DisplayServerX11::mouse_get_absolute_position() const {
+ int number_of_screens = XScreenCount(x11_display);
+ for (int i = 0; i < number_of_screens; i++) {
+ Window root, child;
+ int root_x, root_y, win_x, win_y;
+ unsigned int mask;
+ if (XQueryPointer(x11_display, XRootWindow(x11_display, i), &root, &child, &root_x, &root_y, &win_x, &win_y, &mask)) {
+ XWindowAttributes root_attrs;
+ XGetWindowAttributes(x11_display, root, &root_attrs);
- if (event_data->evtype == XI_RawMotion) {
- XNextEvent(x11_display, &event);
- } else {
- break;
- }
- } else {
- break;
- }
- } else {
- break;
+ return Vector2i(root_attrs.x + root_x, root_attrs.y + root_y);
}
}
-
- xi.relative_motion.x = 0;
- xi.relative_motion.y = 0;
-}
-
-OS::MouseMode OS_X11::get_mouse_mode() const {
- return mouse_mode;
+ return Vector2i();
}
-int OS_X11::get_mouse_button_state() const {
+int DisplayServerX11::mouse_get_button_state() const {
return last_button_state;
}
-Point2 OS_X11::get_mouse_position() const {
- return last_mouse_pos;
-}
+void DisplayServerX11::clipboard_set(const String &p_text) {
-bool OS_X11::get_window_per_pixel_transparency_enabled() const {
+ _THREAD_SAFE_METHOD_
- if (!is_layered_allowed()) return false;
- return layered_window;
+ internal_clipboard = p_text;
+ XSetSelectionOwner(x11_display, XA_PRIMARY, windows[MAIN_WINDOW_ID].x11_window, CurrentTime);
+ XSetSelectionOwner(x11_display, XInternAtom(x11_display, "CLIPBOARD", 0), windows[MAIN_WINDOW_ID].x11_window, CurrentTime);
}
-void OS_X11::set_window_per_pixel_transparency_enabled(bool p_enabled) {
+static String _clipboard_get_impl(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard, Atom target) {
- if (!is_layered_allowed()) return;
- if (layered_window != p_enabled) {
- if (p_enabled) {
- set_borderless_window(true);
- layered_window = true;
- } else {
- layered_window = false;
- }
- }
-}
-
-void OS_X11::set_window_title(const String &p_title) {
- XStoreName(x11_display, x11_window, p_title.utf8().get_data());
+ String ret;
- Atom _net_wm_name = XInternAtom(x11_display, "_NET_WM_NAME", false);
- Atom utf8_string = XInternAtom(x11_display, "UTF8_STRING", false);
- XChangeProperty(x11_display, x11_window, _net_wm_name, utf8_string, 8, PropModeReplace, (unsigned char *)p_title.utf8().get_data(), p_title.utf8().length());
-}
+ Atom type;
+ Atom selection = XA_PRIMARY;
+ int format, result;
+ unsigned long len, bytes_left, dummy;
+ unsigned char *data;
+ Window Sown = XGetSelectionOwner(x11_display, p_source);
-void OS_X11::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
-}
+ if (Sown == x11_window) {
-OS::VideoMode OS_X11::get_video_mode(int p_screen) const {
- return current_videomode;
-}
+ return p_internal_clipboard;
+ };
-void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
-}
+ if (Sown != None) {
+ XConvertSelection(x11_display, p_source, target, selection,
+ x11_window, CurrentTime);
+ XFlush(x11_display);
+ while (true) {
+ XEvent event;
+ XNextEvent(x11_display, &event);
+ if (event.type == SelectionNotify && event.xselection.requestor == x11_window) {
+ break;
+ };
+ };
-void OS_X11::set_wm_fullscreen(bool p_enabled) {
- if (p_enabled && !get_borderless_window()) {
- // remove decorations if the window is not already borderless
- Hints hints;
- Atom property;
- hints.flags = 2;
- hints.decorations = 0;
- property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
- XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+ //
+ // Do not get any data, see how much data is there
+ //
+ XGetWindowProperty(x11_display, x11_window,
+ selection, // Tricky..
+ 0, 0, // offset - len
+ 0, // Delete 0==FALSE
+ AnyPropertyType, //flag
+ &type, // return type
+ &format, // return format
+ &len, &bytes_left, //that
+ &data);
+ // DATA is There
+ if (bytes_left > 0) {
+ result = XGetWindowProperty(x11_display, x11_window,
+ selection, 0, bytes_left, 0,
+ AnyPropertyType, &type, &format,
+ &len, &dummy, &data);
+ if (result == Success) {
+ ret.parse_utf8((const char *)data);
+ } else
+ printf("FAIL\n");
+ if (data) {
+ XFree(data);
+ }
+ }
}
- if (p_enabled && !is_window_resizable()) {
- // Set the window as resizable to prevent window managers to ignore the fullscreen state flag.
- XSizeHints *xsh;
+ return ret;
+}
- xsh = XAllocSizeHints();
- xsh->flags = 0L;
- XSetWMNormalHints(x11_display, x11_window, xsh);
- XFree(xsh);
+static String _clipboard_get(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard) {
+ String ret;
+ Atom utf8_atom = XInternAtom(x11_display, "UTF8_STRING", True);
+ if (utf8_atom != None) {
+ ret = _clipboard_get_impl(p_source, x11_window, x11_display, p_internal_clipboard, utf8_atom);
}
+ if (ret == "") {
+ ret = _clipboard_get_impl(p_source, x11_window, x11_display, p_internal_clipboard, XA_STRING);
+ }
+ return ret;
+}
- // Using EWMH -- Extended Window Manager Hints
- XEvent xev;
- Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
- Atom wm_fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False);
-
- memset(&xev, 0, sizeof(xev));
- xev.type = ClientMessage;
- xev.xclient.window = x11_window;
- xev.xclient.message_type = wm_state;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = p_enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
- xev.xclient.data.l[1] = wm_fullscreen;
- xev.xclient.data.l[2] = 0;
-
- XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+String DisplayServerX11::clipboard_get() const {
- // set bypass compositor hint
- Atom bypass_compositor = XInternAtom(x11_display, "_NET_WM_BYPASS_COMPOSITOR", False);
- unsigned long compositing_disable_on = p_enabled ? 1 : 0;
- XChangeProperty(x11_display, x11_window, bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&compositing_disable_on, 1);
+ _THREAD_SAFE_METHOD_
- XFlush(x11_display);
+ String ret;
+ ret = _clipboard_get(XInternAtom(x11_display, "CLIPBOARD", 0), windows[MAIN_WINDOW_ID].x11_window, x11_display, internal_clipboard);
- if (!p_enabled) {
- // Reset the non-resizable flags if we un-set these before.
- Size2 size = get_window_size();
- XSizeHints *xsh;
- xsh = XAllocSizeHints();
- if (!is_window_resizable()) {
- xsh->flags = PMinSize | PMaxSize;
- xsh->min_width = size.x;
- xsh->max_width = size.x;
- xsh->min_height = size.y;
- xsh->max_height = size.y;
- } else {
- xsh->flags = 0L;
- if (min_size != Size2()) {
- xsh->flags |= PMinSize;
- xsh->min_width = min_size.x;
- xsh->min_height = min_size.y;
- }
- if (max_size != Size2()) {
- xsh->flags |= PMaxSize;
- xsh->max_width = max_size.x;
- xsh->max_height = max_size.y;
- }
- }
- XSetWMNormalHints(x11_display, x11_window, xsh);
- XFree(xsh);
+ if (ret == "") {
+ ret = _clipboard_get(XA_PRIMARY, windows[MAIN_WINDOW_ID].x11_window, x11_display, internal_clipboard);
+ };
- // put back or remove decorations according to the last set borderless state
- Hints hints;
- Atom property;
- hints.flags = 2;
- hints.decorations = current_videomode.borderless_window ? 0 : 1;
- property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
- XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
- }
+ return ret;
}
-void OS_X11::set_wm_above(bool p_enabled) {
- Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
- Atom wm_above = XInternAtom(x11_display, "_NET_WM_STATE_ABOVE", False);
+int DisplayServerX11::get_screen_count() const {
- XClientMessageEvent xev;
- memset(&xev, 0, sizeof(xev));
- xev.type = ClientMessage;
- xev.window = x11_window;
- xev.message_type = wm_state;
- xev.format = 32;
- xev.data.l[0] = p_enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
- xev.data.l[1] = wm_above;
- xev.data.l[3] = 1;
- XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xev);
-}
+ _THREAD_SAFE_METHOD_
-int OS_X11::get_screen_count() const {
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
@@ -1161,42 +554,12 @@ int OS_X11::get_screen_count() const {
XFree(xsi);
return count;
}
+Point2i DisplayServerX11::screen_get_position(int p_screen) const {
-int OS_X11::get_current_screen() const {
- int x, y;
- Window child;
- XTranslateCoordinates(x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child);
+ _THREAD_SAFE_METHOD_
- int count = get_screen_count();
- for (int i = 0; i < count; i++) {
- Point2i pos = get_screen_position(i);
- Size2i size = get_screen_size(i);
- if ((x >= pos.x && x < pos.x + size.width) && (y >= pos.y && y < pos.y + size.height))
- return i;
- }
- return 0;
-}
-
-void OS_X11::set_current_screen(int p_screen) {
- int count = get_screen_count();
- if (p_screen >= count) return;
-
- if (current_videomode.fullscreen) {
- Point2i position = get_screen_position(p_screen);
- Size2i size = get_screen_size(p_screen);
-
- XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y);
- } else {
- if (p_screen != get_current_screen()) {
- Point2i position = get_screen_position(p_screen);
- XMoveWindow(x11_display, x11_window, position.x, position.y);
- }
- }
-}
-
-Point2 OS_X11::get_screen_position(int p_screen) const {
- if (p_screen == -1) {
- p_screen = get_current_screen();
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
}
// Using Xinerama Extension
@@ -1219,39 +582,48 @@ Point2 OS_X11::get_screen_position(int p_screen) const {
return position;
}
-Size2 OS_X11::get_screen_size(int p_screen) const {
- if (p_screen == -1) {
- p_screen = get_current_screen();
+Size2i DisplayServerX11::screen_get_size(int p_screen) const {
+ return screen_get_usable_rect(p_screen).size;
+}
+
+Rect2i DisplayServerX11::screen_get_usable_rect(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
}
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
- if (!ext_okay) return Size2i(0, 0);
+ if (!ext_okay) return Rect2i(0, 0, 0, 0);
int count;
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
- if (p_screen >= count) return Size2i(0, 0);
+ if (p_screen >= count) return Rect2i(0, 0, 0, 0);
- Size2i size = Point2i(xsi[p_screen].width, xsi[p_screen].height);
+ Rect2i rect = Rect2i(xsi[p_screen].x_org, xsi[p_screen].y_org, xsi[p_screen].width, xsi[p_screen].height);
XFree(xsi);
- return size;
+ return rect;
}
-int OS_X11::get_screen_dpi(int p_screen) const {
- if (p_screen == -1) {
- p_screen = get_current_screen();
+int DisplayServerX11::screen_get_dpi(int p_screen) const {
+
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
}
//invalid screen?
ERR_FAIL_INDEX_V(p_screen, get_screen_count(), 0);
//Get physical monitor Dimensions through XRandR and calculate dpi
- Size2 sc = get_screen_size(p_screen);
+ Size2i sc = screen_get_size(p_screen);
if (xrandr_ext_ok) {
int count = 0;
if (xrr_get_monitors) {
- xrr_monitor_info *monitors = xrr_get_monitors(x11_display, x11_window, true, &count);
+ xrr_monitor_info *monitors = xrr_get_monitors(x11_display, windows[MAIN_WINDOW_ID].x11_window, true, &count);
if (p_screen < count) {
double xdpi = sc.width / (double)monitors[p_screen].mwidth * 25.4;
double ydpi = sc.height / (double)monitors[p_screen].mheight * 25.4;
@@ -1279,18 +651,249 @@ int OS_X11::get_screen_dpi(int p_screen) const {
//could not get dpi
return 96;
}
+bool DisplayServerX11::screen_is_touchscreen(int p_screen) const {
+
+ _THREAD_SAFE_METHOD_
+
+#ifndef _MSC_VER
+#warning Need to get from proper window
+#endif
+
+ return DisplayServer::screen_is_touchscreen(p_screen);
+}
+
+Vector<DisplayServer::WindowID> DisplayServerX11::get_window_list() const {
+ _THREAD_SAFE_METHOD_
+
+ Vector<int> ret;
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ ret.push_back(E->key());
+ }
+ return ret;
+}
+
+DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
+
+ _THREAD_SAFE_METHOD_
+
+ WindowID id = _create_window(p_mode, p_flags, p_rect);
+ for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
+ if (p_flags & (1 << i)) {
+ window_set_flag(WindowFlags(i), true, id);
+ }
+ }
+
+ return id;
+}
+
+void DisplayServerX11::delete_sub_window(WindowID p_id) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_id));
+ ERR_FAIL_COND_MSG(p_id == MAIN_WINDOW_ID, "Main window can't be deleted"); //ma
+
+ WindowData &wd = windows[p_id];
+
+ while (wd.transient_children.size()) {
+ window_set_transient(wd.transient_children.front()->get(), INVALID_WINDOW_ID);
+ }
+
+ if (wd.transient_parent != INVALID_WINDOW_ID) {
+ window_set_transient(p_id, INVALID_WINDOW_ID);
+ }
+
+#ifdef VULKAN_ENABLED
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_destroy(p_id);
+ }
+#endif
+ XUnmapWindow(x11_display, wd.x11_window);
+ XDestroyWindow(x11_display, wd.x11_window);
+ if (wd.xic) {
+ XDestroyIC(wd.xic);
+ }
+
+ windows.erase(p_id);
+}
+
+void DisplayServerX11::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ wd.instance_id = p_instance;
+}
+
+ObjectID DisplayServerX11::window_get_attached_instance_id(WindowID p_window) const {
+
+ ERR_FAIL_COND_V(!windows.has(p_window), ObjectID());
+ const WindowData &wd = windows[p_window];
+ return wd.instance_id;
+}
+
+DisplayServerX11::WindowID DisplayServerX11::get_window_at_screen_position(const Point2i &p_position) const {
+
+ return INVALID_WINDOW_ID;
+}
+
+void DisplayServerX11::window_set_title(const String &p_title, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ XStoreName(x11_display, wd.x11_window, p_title.utf8().get_data());
+
+ Atom _net_wm_name = XInternAtom(x11_display, "_NET_WM_NAME", false);
+ Atom utf8_string = XInternAtom(x11_display, "UTF8_STRING", false);
+ XChangeProperty(x11_display, wd.x11_window, _net_wm_name, utf8_string, 8, PropModeReplace, (unsigned char *)p_title.utf8().get_data(), p_title.utf8().length());
+}
+
+void DisplayServerX11::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.rect_changed_callback = p_callable;
+}
+
+void DisplayServerX11::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.event_callback = p_callable;
+}
+
+void DisplayServerX11::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.input_event_callback = p_callable;
+}
+void DisplayServerX11::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.input_text_callback = p_callable;
+}
+
+void DisplayServerX11::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.drop_files_callback = p_callable;
+}
+
+int DisplayServerX11::window_get_current_screen(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), -1);
+ const WindowData &wd = windows[p_window];
-Point2 OS_X11::get_window_position() const {
int x, y;
Window child;
- XTranslateCoordinates(x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child);
- return Point2i(x, y);
+ XTranslateCoordinates(x11_display, wd.x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child);
+
+ int count = get_screen_count();
+ for (int i = 0; i < count; i++) {
+ Point2i pos = screen_get_position(i);
+ Size2i size = screen_get_size(i);
+ if ((x >= pos.x && x < pos.x + size.width) && (y >= pos.y && y < pos.y + size.height))
+ return i;
+ }
+ return 0;
+}
+void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ int count = get_screen_count();
+ if (p_screen >= count) return;
+
+ if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN) {
+ Point2i position = screen_get_position(p_screen);
+ Size2i size = screen_get_size(p_screen);
+
+ XMoveResizeWindow(x11_display, wd.x11_window, position.x, position.y, size.x, size.y);
+ } else {
+ if (p_screen != window_get_current_screen(p_window)) {
+ Point2i position = screen_get_position(p_screen);
+ XMoveWindow(x11_display, wd.x11_window, position.x, position.y);
+ }
+ }
+}
+
+void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(p_window == p_parent);
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd_window = windows[p_window];
+
+ ERR_FAIL_COND(wd_window.transient_parent == p_parent);
+
+ ERR_FAIL_COND_MSG(wd_window.on_top, "Windows with the 'on top' can't become transient.");
+ if (p_parent == INVALID_WINDOW_ID) {
+ //remove transient
+
+ ERR_FAIL_COND(wd_window.transient_parent == INVALID_WINDOW_ID);
+ ERR_FAIL_COND(!windows.has(wd_window.transient_parent));
+
+ WindowData &wd_parent = windows[wd_window.transient_parent];
+
+ wd_window.transient_parent = INVALID_WINDOW_ID;
+ wd_parent.transient_children.erase(p_window);
+
+ XSetTransientForHint(x11_display, wd_window.x11_window, None);
+ } else {
+ ERR_FAIL_COND(!windows.has(p_parent));
+ ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent");
+ WindowData &wd_parent = windows[p_parent];
+
+ wd_window.transient_parent = p_parent;
+ wd_parent.transient_children.insert(p_window);
+
+ XSetTransientForHint(x11_display, wd_window.x11_window, wd_parent.x11_window);
+ }
+}
+
+Point2i DisplayServerX11::window_get_position(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
+ const WindowData &wd = windows[p_window];
+
+ return wd.position;
}
-void OS_X11::set_window_position(const Point2 &p_position) {
+void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
int x = 0;
int y = 0;
- if (!get_borderless_window()) {
+ if (!window_get_flag(WINDOW_FLAG_BORDERLESS, p_window)) {
//exclude window decorations
XSync(x11_display, False);
Atom prop = XInternAtom(x11_display, "_NET_FRAME_EXTENTS", True);
@@ -1300,8 +903,8 @@ void OS_X11::set_window_position(const Point2 &p_position) {
unsigned long len;
unsigned long remaining;
unsigned char *data = NULL;
- if (XGetWindowProperty(x11_display, x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
- if (format == 32 && len == 4) {
+ if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
+ if (format == 32 && len == 4 && data) {
long *extents = (long *)data;
x = extents[0];
y = extents[2];
@@ -1310,153 +913,151 @@ void OS_X11::set_window_position(const Point2 &p_position) {
}
}
}
- XMoveWindow(x11_display, x11_window, p_position.x - x, p_position.y - y);
- update_real_mouse_position();
+ XMoveWindow(x11_display, wd.x11_window, p_position.x - x, p_position.y - y);
+ _update_real_mouse_position(wd);
}
-Size2 OS_X11::get_window_size() const {
- // Use current_videomode width and height instead of XGetWindowAttributes
- // since right after a XResizeWindow the attributes may not be updated yet
- return Size2i(current_videomode.width, current_videomode.height);
-}
+void DisplayServerX11::window_set_max_size(const Size2i p_size, WindowID p_window) {
-Size2 OS_X11::get_real_window_size() const {
- XWindowAttributes xwa;
- XSync(x11_display, False);
- XGetWindowAttributes(x11_display, x11_window, &xwa);
- int w = xwa.width;
- int h = xwa.height;
- Atom prop = XInternAtom(x11_display, "_NET_FRAME_EXTENTS", True);
- if (prop != None) {
- Atom type;
- int format;
- unsigned long len;
- unsigned long remaining;
- unsigned char *data = NULL;
- if (XGetWindowProperty(x11_display, x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
- if (format == 32 && len == 4) {
- long *extents = (long *)data;
- w += extents[0] + extents[1]; // left, right
- h += extents[2] + extents[3]; // top, bottom
- }
- XFree(data);
- }
- }
- return Size2(w, h);
-}
-
-Size2 OS_X11::get_max_window_size() const {
- return max_size;
-}
-
-Size2 OS_X11::get_min_window_size() const {
- return min_size;
-}
+ _THREAD_SAFE_METHOD_
-void OS_X11::set_min_window_size(const Size2 p_size) {
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
- if ((p_size != Size2()) && (max_size != Size2()) && ((p_size.x > max_size.x) || (p_size.y > max_size.y))) {
- ERR_PRINT("Minimum window size can't be larger than maximum window size!");
+ if ((p_size != Size2i()) && ((p_size.x < wd.min_size.x) || (p_size.y < wd.min_size.y))) {
+ ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
return;
}
- min_size = p_size;
+ wd.max_size = p_size;
- if (is_window_resizable()) {
+ if (!window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
XSizeHints *xsh;
xsh = XAllocSizeHints();
xsh->flags = 0L;
- if (min_size != Size2()) {
+ if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize;
- xsh->min_width = min_size.x;
- xsh->min_height = min_size.y;
+ xsh->min_width = wd.min_size.x;
+ xsh->min_height = wd.min_size.y;
}
- if (max_size != Size2()) {
+ if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize;
- xsh->max_width = max_size.x;
- xsh->max_height = max_size.y;
+ xsh->max_width = wd.max_size.x;
+ xsh->max_height = wd.max_size.y;
}
- XSetWMNormalHints(x11_display, x11_window, xsh);
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
XFree(xsh);
XFlush(x11_display);
}
}
+Size2i DisplayServerX11::window_get_max_size(WindowID p_window) const {
-void OS_X11::set_max_window_size(const Size2 p_size) {
+ _THREAD_SAFE_METHOD_
- if ((p_size != Size2()) && ((p_size.x < min_size.x) || (p_size.y < min_size.y))) {
- ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+
+ return wd.max_size;
+}
+
+void DisplayServerX11::window_set_min_size(const Size2i p_size, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if ((p_size != Size2i()) && (wd.max_size != Size2i()) && ((p_size.x > wd.max_size.x) || (p_size.y > wd.max_size.y))) {
+ ERR_PRINT("Minimum window size can't be larger than maximum window size!");
return;
}
- max_size = p_size;
+ wd.min_size = p_size;
- if (is_window_resizable()) {
+ if (!window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
XSizeHints *xsh;
xsh = XAllocSizeHints();
xsh->flags = 0L;
- if (min_size != Size2()) {
+ if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize;
- xsh->min_width = min_size.x;
- xsh->min_height = min_size.y;
+ xsh->min_width = wd.min_size.x;
+ xsh->min_height = wd.min_size.y;
}
- if (max_size != Size2()) {
+ if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize;
- xsh->max_width = max_size.x;
- xsh->max_height = max_size.y;
+ xsh->max_width = wd.max_size.x;
+ xsh->max_height = wd.max_size.y;
}
- XSetWMNormalHints(x11_display, x11_window, xsh);
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
XFree(xsh);
XFlush(x11_display);
}
}
+Size2i DisplayServerX11::window_get_min_size(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+
+ return wd.min_size;
+}
-void OS_X11::set_window_size(const Size2 p_size) {
+void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
- if (current_videomode.width == p_size.width && current_videomode.height == p_size.height)
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+
+ Size2i size = p_size;
+ size.x = MAX(1, size.x);
+ size.y = MAX(1, size.y);
+
+ WindowData &wd = windows[p_window];
+
+ if (wd.size.width == size.width && wd.size.height == size.height)
return;
XWindowAttributes xwa;
XSync(x11_display, False);
- XGetWindowAttributes(x11_display, x11_window, &xwa);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
int old_w = xwa.width;
int old_h = xwa.height;
// If window resizable is disabled we need to update the attributes first
XSizeHints *xsh;
xsh = XAllocSizeHints();
- if (!is_window_resizable()) {
+ if (!window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
xsh->flags = PMinSize | PMaxSize;
- xsh->min_width = p_size.x;
- xsh->max_width = p_size.x;
- xsh->min_height = p_size.y;
- xsh->max_height = p_size.y;
+ xsh->min_width = size.x;
+ xsh->max_width = size.x;
+ xsh->min_height = size.y;
+ xsh->max_height = size.y;
} else {
xsh->flags = 0L;
- if (min_size != Size2()) {
+ if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize;
- xsh->min_width = min_size.x;
- xsh->min_height = min_size.y;
+ xsh->min_width = wd.min_size.x;
+ xsh->min_height = wd.min_size.y;
}
- if (max_size != Size2()) {
+ if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize;
- xsh->max_width = max_size.x;
- xsh->max_height = max_size.y;
+ xsh->max_width = wd.max_size.x;
+ xsh->max_height = wd.max_size.y;
}
}
- XSetWMNormalHints(x11_display, x11_window, xsh);
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
XFree(xsh);
// Resize the window
- XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
+ XResizeWindow(x11_display, wd.x11_window, size.x, size.y);
// Update our videomode width and height
- current_videomode.width = p_size.x;
- current_videomode.height = p_size.y;
+ wd.size = size;
for (int timeout = 0; timeout < 50; ++timeout) {
XSync(x11_display, False);
- XGetWindowAttributes(x11_display, x11_window, &xwa);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
if (old_w != xwa.width || old_h != xwa.height)
break;
@@ -1464,105 +1065,53 @@ void OS_X11::set_window_size(const Size2 p_size) {
usleep(10000);
}
}
+Size2i DisplayServerX11::window_get_size(WindowID p_window) const {
-void OS_X11::set_window_fullscreen(bool p_enabled) {
+ _THREAD_SAFE_METHOD_
- if (current_videomode.fullscreen == p_enabled)
- return;
-
- if (layered_window)
- set_window_per_pixel_transparency_enabled(false);
-
- if (p_enabled && current_videomode.always_on_top) {
- // Fullscreen + Always-on-top requires a maximized window on some window managers (Metacity)
- set_window_maximized(true);
- }
- set_wm_fullscreen(p_enabled);
- if (!p_enabled && current_videomode.always_on_top) {
- // Restore
- set_window_maximized(false);
- }
- if (!p_enabled) {
- set_window_position(last_position_before_fs);
- } else {
- last_position_before_fs = get_window_position();
- }
- current_videomode.fullscreen = p_enabled;
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+ return wd.size;
}
+Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
-bool OS_X11::is_window_fullscreen() const {
- return current_videomode.fullscreen;
-}
+ _THREAD_SAFE_METHOD_
-void OS_X11::set_window_resizable(bool p_enabled) {
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
- XSizeHints *xsh;
- xsh = XAllocSizeHints();
- if (!p_enabled) {
- Size2 size = get_window_size();
-
- xsh->flags = PMinSize | PMaxSize;
- xsh->min_width = size.x;
- xsh->max_width = size.x;
- xsh->min_height = size.y;
- xsh->max_height = size.y;
- } else {
- xsh->flags = 0L;
- if (min_size != Size2()) {
- xsh->flags |= PMinSize;
- xsh->min_width = min_size.x;
- xsh->min_height = min_size.y;
- }
- if (max_size != Size2()) {
- xsh->flags |= PMaxSize;
- xsh->max_width = max_size.x;
- xsh->max_height = max_size.y;
+ XWindowAttributes xwa;
+ XSync(x11_display, False);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
+ int w = xwa.width;
+ int h = xwa.height;
+ Atom prop = XInternAtom(x11_display, "_NET_FRAME_EXTENTS", True);
+ if (prop != None) {
+ Atom type;
+ int format;
+ unsigned long len;
+ unsigned long remaining;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
+ if (format == 32 && len == 4 && data) {
+ long *extents = (long *)data;
+ w += extents[0] + extents[1]; // left, right
+ h += extents[2] + extents[3]; // top, bottom
+ }
+ XFree(data);
}
}
-
- XSetWMNormalHints(x11_display, x11_window, xsh);
- XFree(xsh);
-
- current_videomode.resizable = p_enabled;
-
- XFlush(x11_display);
-}
-
-bool OS_X11::is_window_resizable() const {
- return current_videomode.resizable;
+ return Size2i(w, h);
}
-void OS_X11::set_window_minimized(bool p_enabled) {
- // Using ICCCM -- Inter-Client Communication Conventions Manual
- XEvent xev;
- Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
-
- memset(&xev, 0, sizeof(xev));
- xev.type = ClientMessage;
- xev.xclient.window = x11_window;
- xev.xclient.message_type = wm_change;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState;
+bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const {
- XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ _THREAD_SAFE_METHOD_
- Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
- Atom wm_hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", False);
+ ERR_FAIL_COND_V(!windows.has(p_window), false);
+ const WindowData &wd = windows[p_window];
- memset(&xev, 0, sizeof(xev));
- xev.type = ClientMessage;
- xev.xclient.window = x11_window;
- xev.xclient.message_type = wm_state;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
- xev.xclient.data.l[1] = wm_hidden;
-
- XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
-}
-
-bool OS_X11::is_window_minimized() const {
- // Using ICCCM -- Inter-Client Communication Conventions Manual
- Atom property = XInternAtom(x11_display, "WM_STATE", True);
+ Atom property = XInternAtom(x11_display, "_NET_WM_ALLOWED_ACTIONS", False);
Atom type;
int format;
unsigned long len;
@@ -1571,29 +1120,44 @@ bool OS_X11::is_window_minimized() const {
int result = XGetWindowProperty(
x11_display,
- x11_window,
+ wd.x11_window,
property,
0,
- 32,
+ 1024,
False,
- AnyPropertyType,
+ XA_ATOM,
&type,
&format,
&len,
&remaining,
&data);
- if (result == Success) {
- long *state = (long *)data;
- if (state[0] == WM_IconicState)
- return true;
+ if (result == Success && data) {
+ Atom *atoms = (Atom *)data;
+ Atom wm_act_max_horz = XInternAtom(x11_display, "_NET_WM_ACTION_MAXIMIZE_HORZ", False);
+ Atom wm_act_max_vert = XInternAtom(x11_display, "_NET_WM_ACTION_MAXIMIZE_VERT", False);
+ bool found_wm_act_max_horz = false;
+ bool found_wm_act_max_vert = false;
+
+ for (uint64_t i = 0; i < len; i++) {
+ if (atoms[i] == wm_act_max_horz)
+ found_wm_act_max_horz = true;
+ if (atoms[i] == wm_act_max_vert)
+ found_wm_act_max_vert = true;
+
+ if (found_wm_act_max_horz || found_wm_act_max_vert)
+ return true;
+ }
+ XFree(atoms);
}
+
return false;
}
-void OS_X11::set_window_maximized(bool p_enabled) {
- if (is_window_maximized() == p_enabled)
- return;
+void DisplayServerX11::_set_wm_maximized(WindowID p_window, bool p_enabled) {
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
// Using EWMH -- Extended Window Manager Hints
XEvent xev;
@@ -1603,7 +1167,7 @@ void OS_X11::set_window_maximized(bool p_enabled) {
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
- xev.xclient.window = x11_window;
+ xev.xclient.window = wd.x11_window;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = p_enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
@@ -1612,178 +1176,454 @@ void OS_X11::set_window_maximized(bool p_enabled) {
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
- if (p_enabled && is_window_maximize_allowed()) {
+ if (p_enabled && window_is_maximize_allowed(p_window)) {
// Wait for effective resizing (so the GLX context is too).
// Give up after 0.5s, it's not going to happen on this WM.
// https://github.com/godotengine/godot/issues/19978
- for (int attempt = 0; !is_window_maximized() && attempt < 50; attempt++) {
+ for (int attempt = 0; window_get_mode(p_window) != WINDOW_MODE_MAXIMIZED && attempt < 50; attempt++) {
usleep(10000);
}
}
-
- maximized = p_enabled;
}
-bool OS_X11::is_window_maximize_allowed() {
- Atom property = XInternAtom(x11_display, "_NET_WM_ALLOWED_ACTIONS", False);
- Atom type;
- int format;
- unsigned long len;
- unsigned long remaining;
- unsigned char *data = NULL;
+void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
- int result = XGetWindowProperty(
- x11_display,
- x11_window,
- property,
- 0,
- 1024,
- False,
- XA_ATOM,
- &type,
- &format,
- &len,
- &remaining,
- &data);
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
- if (result == Success) {
- Atom *atoms = (Atom *)data;
- Atom wm_act_max_horz = XInternAtom(x11_display, "_NET_WM_ACTION_MAXIMIZE_HORZ", False);
- Atom wm_act_max_vert = XInternAtom(x11_display, "_NET_WM_ACTION_MAXIMIZE_VERT", False);
- bool found_wm_act_max_horz = false;
- bool found_wm_act_max_vert = false;
+ if (p_enabled && !window_get_flag(WINDOW_FLAG_BORDERLESS, p_window)) {
+ // remove decorations if the window is not already borderless
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ hints.decorations = 0;
+ property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ XChangeProperty(x11_display, wd.x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+ }
- for (uint64_t i = 0; i < len; i++) {
- if (atoms[i] == wm_act_max_horz)
- found_wm_act_max_horz = true;
- if (atoms[i] == wm_act_max_vert)
- found_wm_act_max_vert = true;
+ if (p_enabled && window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
+ // Set the window as resizable to prevent window managers to ignore the fullscreen state flag.
+ XSizeHints *xsh;
- if (found_wm_act_max_horz || found_wm_act_max_vert)
- return true;
- }
- XFree(atoms);
+ xsh = XAllocSizeHints();
+ xsh->flags = 0L;
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
+ XFree(xsh);
}
- return false;
-}
-
-bool OS_X11::is_window_maximized() const {
// Using EWMH -- Extended Window Manager Hints
- Atom property = XInternAtom(x11_display, "_NET_WM_STATE", False);
- Atom type;
- int format;
- unsigned long len;
- unsigned long remaining;
- unsigned char *data = NULL;
- bool retval = false;
+ XEvent xev;
+ Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
+ Atom wm_fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False);
- int result = XGetWindowProperty(
- x11_display,
- x11_window,
- property,
- 0,
- 1024,
- False,
- XA_ATOM,
- &type,
- &format,
- &len,
- &remaining,
- &data);
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = p_enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+ xev.xclient.data.l[1] = wm_fullscreen;
+ xev.xclient.data.l[2] = 0;
- if (result == Success) {
- Atom *atoms = (Atom *)data;
- Atom wm_max_horz = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
- Atom wm_max_vert = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
- bool found_wm_max_horz = false;
- bool found_wm_max_vert = false;
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
- for (uint64_t i = 0; i < len; i++) {
- if (atoms[i] == wm_max_horz)
- found_wm_max_horz = true;
- if (atoms[i] == wm_max_vert)
- found_wm_max_vert = true;
+ // set bypass compositor hint
+ Atom bypass_compositor = XInternAtom(x11_display, "_NET_WM_BYPASS_COMPOSITOR", False);
+ unsigned long compositing_disable_on = p_enabled ? 1 : 0;
+ XChangeProperty(x11_display, wd.x11_window, bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&compositing_disable_on, 1);
- if (found_wm_max_horz && found_wm_max_vert) {
- retval = true;
- break;
+ XFlush(x11_display);
+
+ if (!p_enabled) {
+ // Reset the non-resizable flags if we un-set these before.
+ Size2i size = window_get_size(p_window);
+ XSizeHints *xsh;
+ xsh = XAllocSizeHints();
+ if (window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
+ xsh->flags = PMinSize | PMaxSize;
+ xsh->min_width = size.x;
+ xsh->max_width = size.x;
+ xsh->min_height = size.y;
+ xsh->max_height = size.y;
+ } else {
+ xsh->flags = 0L;
+ if (wd.min_size != Size2i()) {
+ xsh->flags |= PMinSize;
+ xsh->min_width = wd.min_size.x;
+ xsh->min_height = wd.min_size.y;
+ }
+ if (wd.max_size != Size2i()) {
+ xsh->flags |= PMaxSize;
+ xsh->max_width = wd.max_size.x;
+ xsh->max_height = wd.max_size.y;
}
}
- }
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
+ XFree(xsh);
- XFree(data);
- return retval;
+ // put back or remove decorations according to the last set borderless state
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ hints.decorations = window_get_flag(WINDOW_FLAG_BORDERLESS, p_window) ? 0 : 1;
+ property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ XChangeProperty(x11_display, wd.x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+ }
}
-void OS_X11::set_window_always_on_top(bool p_enabled) {
- if (is_window_always_on_top() == p_enabled)
- return;
+void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
- if (p_enabled && current_videomode.fullscreen) {
- // Fullscreen + Always-on-top requires a maximized window on some window managers (Metacity)
- set_window_maximized(true);
- }
- set_wm_above(p_enabled);
- if (!p_enabled && !current_videomode.fullscreen) {
- // Restore
- set_window_maximized(false);
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ WindowMode old_mode = window_get_mode(p_window);
+ if (old_mode == p_mode) {
+ return; // do nothing
}
+ //remove all "extra" modes
- current_videomode.always_on_top = p_enabled;
-}
+ switch (old_mode) {
+ case WINDOW_MODE_WINDOWED: {
+ //do nothing
+ } break;
+ case WINDOW_MODE_MINIMIZED: {
+ //Un-Minimize
+ // Using ICCCM -- Inter-Client Communication Conventions Manual
+ XEvent xev;
+ Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = wm_change;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = WM_NormalState;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+
+ Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
+ Atom wm_hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
+ xev.xclient.data.l[1] = wm_hidden;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ } break;
+ case WINDOW_MODE_FULLSCREEN: {
+ //Remove full-screen
+ _set_wm_fullscreen(p_window, false);
-bool OS_X11::is_window_always_on_top() const {
- return current_videomode.always_on_top;
-}
+ //un-maximize required for always on top
+ bool on_top = window_get_flag(WINDOW_FLAG_ALWAYS_ON_TOP, p_window);
-bool OS_X11::is_window_focused() const {
- return window_focused;
-}
+ wd.fullscreen = false;
-void OS_X11::set_borderless_window(bool p_borderless) {
+ window_set_position(wd.last_position_before_fs, p_window);
- if (get_borderless_window() == p_borderless)
- return;
+ if (on_top) {
+ _set_wm_maximized(p_window, false);
+ }
- if (!p_borderless && layered_window)
- set_window_per_pixel_transparency_enabled(false);
+ } break;
+ case WINDOW_MODE_MAXIMIZED: {
- current_videomode.borderless_window = p_borderless;
+ _set_wm_maximized(p_window, false);
+ } break;
+ }
- Hints hints;
- Atom property;
- hints.flags = 2;
- hints.decorations = current_videomode.borderless_window ? 0 : 1;
- property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
- XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+ switch (p_mode) {
+ case WINDOW_MODE_WINDOWED: {
+ //do nothing
+ } break;
+ case WINDOW_MODE_MINIMIZED: {
+ // Using ICCCM -- Inter-Client Communication Conventions Manual
+ XEvent xev;
+ Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = wm_change;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = WM_IconicState;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+
+ Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
+ Atom wm_hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
+ xev.xclient.data.l[1] = wm_hidden;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ } break;
+ case WINDOW_MODE_FULLSCREEN: {
+ wd.last_position_before_fs = wd.position;
+ if (window_get_flag(WINDOW_FLAG_ALWAYS_ON_TOP, p_window)) {
+ _set_wm_maximized(p_window, true);
+ }
+ _set_wm_fullscreen(p_window, true);
+ wd.fullscreen = true;
+ } break;
+ case WINDOW_MODE_MAXIMIZED: {
+
+ _set_wm_maximized(p_window, true);
- // Preserve window size
- set_window_size(Size2(current_videomode.width, current_videomode.height));
+ } break;
+ }
}
-bool OS_X11::get_borderless_window() {
+DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) const {
- bool borderless = current_videomode.borderless_window;
- Atom prop = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
- if (prop != None) {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED);
+ const WindowData &wd = windows[p_window];
+
+ if (wd.fullscreen) { //if fullscreen, it's not in another mode
+ return WINDOW_MODE_FULLSCREEN;
+ }
+ { //test maximized
+ // Using EWMH -- Extended Window Manager Hints
+ Atom property = XInternAtom(x11_display, "_NET_WM_STATE", False);
Atom type;
int format;
unsigned long len;
unsigned long remaining;
unsigned char *data = NULL;
- if (XGetWindowProperty(x11_display, x11_window, prop, 0, sizeof(Hints), False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
- if (data && (format == 32) && (len >= 5)) {
- borderless = !((Hints *)data)->decorations;
+ bool retval = false;
+
+ int result = XGetWindowProperty(
+ x11_display,
+ wd.x11_window,
+ property,
+ 0,
+ 1024,
+ False,
+ XA_ATOM,
+ &type,
+ &format,
+ &len,
+ &remaining,
+ &data);
+
+ if (result == Success && data) {
+ Atom *atoms = (Atom *)data;
+ Atom wm_max_horz = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+ Atom wm_max_vert = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+ bool found_wm_max_horz = false;
+ bool found_wm_max_vert = false;
+
+ for (uint64_t i = 0; i < len; i++) {
+ if (atoms[i] == wm_max_horz)
+ found_wm_max_horz = true;
+ if (atoms[i] == wm_max_vert)
+ found_wm_max_vert = true;
+
+ if (found_wm_max_horz && found_wm_max_vert) {
+ retval = true;
+ break;
+ }
}
+
XFree(data);
}
+
+ if (retval) {
+ return WINDOW_MODE_MAXIMIZED;
+ }
+ }
+
+ { // test minimzed
+ // Using ICCCM -- Inter-Client Communication Conventions Manual
+ Atom property = XInternAtom(x11_display, "WM_STATE", True);
+ Atom type;
+ int format;
+ unsigned long len;
+ unsigned long remaining;
+ unsigned char *data = NULL;
+
+ int result = XGetWindowProperty(
+ x11_display,
+ wd.x11_window,
+ property,
+ 0,
+ 32,
+ False,
+ AnyPropertyType,
+ &type,
+ &format,
+ &len,
+ &remaining,
+ &data);
+
+ if (result == Success && data) {
+ long *state = (long *)data;
+ if (state[0] == WM_IconicState)
+ return WINDOW_MODE_MINIMIZED;
+ }
+ }
+
+ // all other discarded, return windowed.
+
+ return WINDOW_MODE_WINDOWED;
+}
+
+void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ switch (p_flag) {
+ case WINDOW_FLAG_RESIZE_DISABLED: {
+ XSizeHints *xsh;
+ xsh = XAllocSizeHints();
+ if (p_enabled) {
+ Size2i size = window_get_size(p_window);
+
+ xsh->flags = PMinSize | PMaxSize;
+ xsh->min_width = size.x;
+ xsh->max_width = size.x;
+ xsh->min_height = size.y;
+ xsh->max_height = size.y;
+ } else {
+ xsh->flags = 0L;
+ if (wd.min_size != Size2i()) {
+ xsh->flags |= PMinSize;
+ xsh->min_width = wd.min_size.x;
+ xsh->min_height = wd.min_size.y;
+ }
+ if (wd.max_size != Size2i()) {
+ xsh->flags |= PMaxSize;
+ xsh->max_width = wd.max_size.x;
+ xsh->max_height = wd.max_size.y;
+ }
+ }
+
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
+ XFree(xsh);
+
+ wd.resize_disabled = p_enabled;
+
+ XFlush(x11_display);
+
+ } break;
+ case WINDOW_FLAG_BORDERLESS: {
+
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ hints.decorations = p_enabled ? 0 : 1;
+ property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ XChangeProperty(x11_display, wd.x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
+
+ // Preserve window size
+ window_set_size(window_get_size(p_window), p_window);
+
+ wd.borderless = p_enabled;
+ } break;
+ case WINDOW_FLAG_ALWAYS_ON_TOP: {
+
+ ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID, "Can't make a window transient if the 'on top' flag is active.");
+ if (p_enabled && wd.fullscreen) {
+ _set_wm_maximized(p_window, true);
+ }
+
+ Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
+ Atom wm_above = XInternAtom(x11_display, "_NET_WM_STATE_ABOVE", False);
+
+ XClientMessageEvent xev;
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.window = wd.x11_window;
+ xev.message_type = wm_state;
+ xev.format = 32;
+ xev.data.l[0] = p_enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+ xev.data.l[1] = wm_above;
+ xev.data.l[3] = 1;
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xev);
+
+ if (!p_enabled && !wd.fullscreen) {
+ _set_wm_maximized(p_window, false);
+ }
+ wd.on_top = p_enabled;
+
+ } break;
+ case WINDOW_FLAG_TRANSPARENT: {
+ //todo reimplement
+ } break;
+ default: {
+ }
}
- return borderless;
}
+bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), false);
+ const WindowData &wd = windows[p_window];
+
+ switch (p_flag) {
+ case WINDOW_FLAG_RESIZE_DISABLED: {
+
+ return wd.resize_disabled;
+ } break;
+ case WINDOW_FLAG_BORDERLESS: {
+
+ bool borderless = wd.borderless;
+ Atom prop = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ if (prop != None) {
+
+ Atom type;
+ int format;
+ unsigned long len;
+ unsigned long remaining;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, sizeof(Hints), False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
+ if (data && (format == 32) && (len >= 5)) {
+ borderless = !((Hints *)data)->decorations;
+ }
+ if (data) {
+ XFree(data);
+ }
+ }
+ }
+ return borderless;
+ } break;
+ case WINDOW_FLAG_ALWAYS_ON_TOP: {
-void OS_X11::request_attention() {
+ return wd.on_top;
+ } break;
+ case WINDOW_FLAG_TRANSPARENT: {
+ //todo reimplement
+ } break;
+ default: {
+ }
+ }
+
+ return false;
+}
+
+void DisplayServerX11::window_request_attention(WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
// Using EWMH -- Extended Window Manager Hints
//
// Sets the _NET_WM_STATE_DEMANDS_ATTENTION atom for WM_STATE
@@ -1795,7 +1635,7 @@ void OS_X11::request_attention() {
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
- xev.xclient.window = x11_window;
+ xev.xclient.window = wd.x11_window;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
@@ -1805,7 +1645,314 @@ void OS_X11::request_attention() {
XFlush(x11_display);
}
-void OS_X11::get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state) {
+void DisplayServerX11::window_move_to_foreground(WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ XEvent xev;
+ Atom net_active_window = XInternAtom(x11_display, "_NET_ACTIVE_WINDOW", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = net_active_window;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = CurrentTime;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ XFlush(x11_display);
+}
+
+bool DisplayServerX11::window_can_draw(WindowID p_window) const {
+
+ //this seems to be all that is provided by X11
+ return window_get_mode(p_window) != WINDOW_MODE_MINIMIZED;
+}
+bool DisplayServerX11::can_any_window_draw() const {
+
+ _THREAD_SAFE_METHOD_
+
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (window_get_mode(E->key()) != WINDOW_MODE_MINIMIZED) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void DisplayServerX11::window_set_ime_active(const bool p_active, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ wd.im_active = p_active;
+
+ if (!wd.xic)
+ return;
+
+ if (p_active) {
+ XSetICFocus(wd.xic);
+ window_set_ime_position(wd.im_position, p_window);
+ } else {
+ XUnsetICFocus(wd.xic);
+ }
+}
+void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ wd.im_position = p_pos;
+
+ if (!wd.xic)
+ return;
+
+ ::XPoint spot;
+ spot.x = short(p_pos.x);
+ spot.y = short(p_pos.y);
+ XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
+ XSetICValues(wd.xic, XNPreeditAttributes, preedit_attr, NULL);
+ XFree(preedit_attr);
+}
+
+void DisplayServerX11::cursor_set_shape(CursorShape p_shape) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
+
+ if (p_shape == current_cursor) {
+ return;
+ }
+
+ if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
+ if (cursors[p_shape] != None) {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ XDefineCursor(x11_display, E->get().x11_window, cursors[p_shape]);
+ }
+ } else if (cursors[CURSOR_ARROW] != None) {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ XDefineCursor(x11_display, E->get().x11_window, cursors[CURSOR_ARROW]);
+ }
+ }
+ }
+
+ current_cursor = p_shape;
+}
+DisplayServerX11::CursorShape DisplayServerX11::cursor_get_shape() const {
+ return current_cursor;
+}
+void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+
+ _THREAD_SAFE_METHOD_
+
+ if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ cursor_set_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
+ Ref<Texture2D> texture = p_cursor;
+ Ref<AtlasTexture> atlas_texture = p_cursor;
+ Ref<Image> image;
+ Size2i texture_size;
+ Rect2i atlas_rect;
+
+ if (texture.is_valid()) {
+ image = texture->get_data();
+ }
+
+ if (!image.is_valid() && atlas_texture.is_valid()) {
+ texture = atlas_texture->get_atlas();
+
+ atlas_rect.size.width = texture->get_width();
+ atlas_rect.size.height = texture->get_height();
+ atlas_rect.position.x = atlas_texture->get_region().position.x;
+ atlas_rect.position.y = atlas_texture->get_region().position.y;
+
+ texture_size.width = atlas_texture->get_region().size.x;
+ texture_size.height = atlas_texture->get_region().size.y;
+ } else if (image.is_valid()) {
+ texture_size.width = texture->get_width();
+ texture_size.height = texture->get_height();
+ }
+
+ ERR_FAIL_COND(!texture.is_valid());
+ ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0);
+ ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256);
+ ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height);
+
+ image = texture->get_data();
+
+ ERR_FAIL_COND(!image.is_valid());
+
+ // Create the cursor structure
+ XcursorImage *cursor_image = XcursorImageCreate(texture_size.width, texture_size.height);
+ XcursorUInt image_size = texture_size.width * texture_size.height;
+ XcursorDim size = sizeof(XcursorPixel) * image_size;
+
+ cursor_image->version = 1;
+ cursor_image->size = size;
+ cursor_image->xhot = p_hotspot.x;
+ cursor_image->yhot = p_hotspot.y;
+
+ // allocate memory to contain the whole file
+ cursor_image->pixels = (XcursorPixel *)memalloc(size);
+
+ for (XcursorPixel index = 0; index < image_size; index++) {
+ int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
+ int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
+
+ if (atlas_texture.is_valid()) {
+ column_index = MIN(column_index, atlas_rect.size.width - 1);
+ row_index = MIN(row_index, atlas_rect.size.height - 1);
+ }
+
+ *(cursor_image->pixels + index) = image->get_pixel(column_index, row_index).to_argb32();
+ }
+
+ ERR_FAIL_COND(cursor_image->pixels == NULL);
+
+ // Save it for a further usage
+ cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image);
+
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
+ if (p_shape == current_cursor) {
+ if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ XDefineCursor(x11_display, E->get().x11_window, cursors[p_shape]);
+ }
+ }
+ }
+
+ memfree(cursor_image->pixels);
+ XcursorImageDestroy(cursor_image);
+ } else {
+ // Reset to default system cursor
+ if (img[p_shape]) {
+ cursors[p_shape] = XcursorImageLoadCursor(x11_display, img[p_shape]);
+ }
+
+ CursorShape c = current_cursor;
+ current_cursor = CURSOR_MAX;
+ cursor_set_shape(c);
+
+ cursors_cache.erase(p_shape);
+ }
+}
+
+DisplayServerX11::LatinKeyboardVariant DisplayServerX11::get_latin_keyboard_variant() const {
+ _THREAD_SAFE_METHOD_
+
+ XkbDescRec *xkbdesc = XkbAllocKeyboard();
+ ERR_FAIL_COND_V(!xkbdesc, LATIN_KEYBOARD_QWERTY);
+
+ XkbGetNames(x11_display, XkbSymbolsNameMask, xkbdesc);
+ ERR_FAIL_COND_V(!xkbdesc->names, LATIN_KEYBOARD_QWERTY);
+ ERR_FAIL_COND_V(!xkbdesc->names->symbols, LATIN_KEYBOARD_QWERTY);
+
+ char *layout = XGetAtomName(x11_display, xkbdesc->names->symbols);
+ ERR_FAIL_COND_V(!layout, LATIN_KEYBOARD_QWERTY);
+
+ Vector<String> info = String(layout).split("+");
+ ERR_FAIL_INDEX_V(1, info.size(), LATIN_KEYBOARD_QWERTY);
+
+ if (info[1].find("colemak") != -1) {
+ return LATIN_KEYBOARD_COLEMAK;
+ } else if (info[1].find("qwertz") != -1) {
+ return LATIN_KEYBOARD_QWERTZ;
+ } else if (info[1].find("azerty") != -1) {
+ return LATIN_KEYBOARD_AZERTY;
+ } else if (info[1].find("qzerty") != -1) {
+ return LATIN_KEYBOARD_QZERTY;
+ } else if (info[1].find("dvorak") != -1) {
+ return LATIN_KEYBOARD_DVORAK;
+ } else if (info[1].find("neo") != -1) {
+ return LATIN_KEYBOARD_NEO;
+ }
+
+ return LATIN_KEYBOARD_QWERTY;
+}
+
+DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display, Window p_window, Atom p_property) {
+
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *ret = 0;
+
+ int read_bytes = 1024;
+
+ //Keep trying to read the property until there are no
+ //bytes unread.
+ do {
+ if (ret != 0)
+ XFree(ret);
+
+ XGetWindowProperty(p_display, p_window, p_property, 0, read_bytes, False, AnyPropertyType,
+ &actual_type, &actual_format, &nitems, &bytes_after,
+ &ret);
+
+ read_bytes *= 2;
+
+ } while (bytes_after != 0);
+
+ Property p = { ret, actual_format, (int)nitems, actual_type };
+
+ return p;
+}
+
+static Atom pick_target_from_list(Display *p_display, Atom *p_list, int p_count) {
+
+ static const char *target_type = "text/uri-list";
+
+ for (int i = 0; i < p_count; i++) {
+
+ Atom atom = p_list[i];
+
+ if (atom != None && String(XGetAtomName(p_display, atom)) == target_type)
+ return atom;
+ }
+ return None;
+}
+
+static Atom pick_target_from_atoms(Display *p_disp, Atom p_t1, Atom p_t2, Atom p_t3) {
+
+ static const char *target_type = "text/uri-list";
+ if (p_t1 != None && String(XGetAtomName(p_disp, p_t1)) == target_type)
+ return p_t1;
+
+ if (p_t2 != None && String(XGetAtomName(p_disp, p_t2)) == target_type)
+ return p_t2;
+
+ if (p_t3 != None && String(XGetAtomName(p_disp, p_t3)) == target_type)
+ return p_t3;
+
+ return None;
+}
+
+void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state) {
state->set_shift((p_x11_state & ShiftMask));
state->set_control((p_x11_state & ControlMask));
@@ -1813,7 +1960,7 @@ void OS_X11::get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWith
state->set_metakey((p_x11_state & Mod4Mask));
}
-unsigned int OS_X11::get_mouse_button_state(unsigned int p_x11_button, int p_x11_type) {
+unsigned int DisplayServerX11::_get_mouse_button_state(unsigned int p_x11_button, int p_x11_type) {
unsigned int mask = 1 << (p_x11_button - 1);
@@ -1826,8 +1973,9 @@ unsigned int OS_X11::get_mouse_button_state(unsigned int p_x11_button, int p_x11
return last_button_state;
}
-void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
+void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, bool p_echo) {
+ WindowData wd = windows[p_window];
// X11 functions don't know what const is
XKeyEvent *xkeyevent = p_event;
@@ -1853,7 +2001,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
KeySym keysym_keycode = 0; // keysym used to find a keycode
KeySym keysym_unicode = 0; // keysym used to find unicode
- // XLookupString returns keysyms usable as nice scancodes/
+ // XLookupString returns keysyms usable as nice keycodes.
char str[256 + 1];
XKeyEvent xkeyevent_no_mod = *xkeyevent;
xkeyevent_no_mod.state &= ~ShiftMask;
@@ -1869,18 +2017,18 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
xmblen = 8;
}
- if (xkeyevent->type == KeyPress && xic) {
+ if (xkeyevent->type == KeyPress && wd.xic) {
Status status;
#ifdef X_HAVE_UTF8_STRING
int utf8len = 8;
char *utf8string = (char *)memalloc(sizeof(char) * utf8len);
- int utf8bytes = Xutf8LookupString(xic, xkeyevent, utf8string,
+ int utf8bytes = Xutf8LookupString(wd.xic, xkeyevent, utf8string,
utf8len - 1, &keysym_unicode, &status);
if (status == XBufferOverflow) {
utf8len = utf8bytes + 1;
utf8string = (char *)memrealloc(utf8string, utf8len);
- utf8bytes = Xutf8LookupString(xic, xkeyevent, utf8string,
+ utf8bytes = Xutf8LookupString(wd.xic, xkeyevent, utf8string,
utf8len - 1, &keysym_unicode, &status);
}
utf8string[utf8bytes] = '\0';
@@ -1902,11 +2050,13 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
continue;
}
- if (keycode == 0)
+ if (keycode == 0) {
keycode = physical_keycode;
+ }
- get_key_modifier_state(xkeyevent->state, k);
+ _get_key_modifier_state(xkeyevent->state, k);
+ k->set_window_id(p_window);
k->set_unicode(tmp[i]);
k->set_pressed(keypress);
@@ -1924,7 +2074,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
k->set_shift(true);
}
- input->accumulate_input_event(k);
+ InputFilter::get_singleton()->accumulate_input_event(k);
}
memfree(utf8string);
return;
@@ -1944,7 +2094,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
#endif
}
- /* Phase 2, obtain a pigui keycode from the keysym */
+ /* Phase 2, obtain a Godot keycode from the keysym */
// KeyMappingX11 just translated the X11 keysym to a PIGUI
// keysym, so it works in all platforms the same.
@@ -1970,11 +2120,13 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
bool keypress = xkeyevent->type == KeyPress;
- if (physical_keycode == 0 && keycode == 0 && unicode == 0)
+ if (physical_keycode == 0 && keycode == 0 && unicode == 0) {
return;
+ }
- if (keycode == 0)
+ if (keycode == 0) {
keycode = physical_keycode;
+ }
/* Phase 5, determine modifier mask */
@@ -1986,8 +2138,9 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
Ref<InputEventKey> k;
k.instance();
+ k->set_window_id(p_window);
- get_key_modifier_state(xkeyevent->state, k);
+ _get_key_modifier_state(xkeyevent->state, k);
/* Phase 6, determine echo character */
@@ -2021,7 +2174,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
if (rk == keysym_keycode) {
XEvent event;
XNextEvent(x11_display, &event); //erase next event
- handle_key_event((XKeyEvent *)&event, true);
+ _handle_key_event(p_window, (XKeyEvent *)&event, true);
return; //ignore current, echo next
}
}
@@ -2064,104 +2217,133 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
k->set_metakey(false);
}
- bool last_is_pressed = Input::get_singleton()->is_key_pressed(k->get_keycode());
+ bool last_is_pressed = InputFilter::get_singleton()->is_key_pressed(k->get_keycode());
if (k->is_pressed()) {
if (last_is_pressed) {
k->set_echo(true);
}
}
- //printf("key: %x\n",k->get_keycode());
- input->accumulate_input_event(k);
+ InputFilter::get_singleton()->accumulate_input_event(k);
}
-struct Property {
- unsigned char *data;
- int format, nitems;
- Atom type;
-};
-
-static Property read_property(Display *p_display, Window p_window, Atom p_property) {
-
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *ret = 0;
-
- int read_bytes = 1024;
-
- //Keep trying to read the property until there are no
- //bytes unread.
- do {
- if (ret != 0)
- XFree(ret);
+void DisplayServerX11::_xim_destroy_callback(::XIM im, ::XPointer client_data,
+ ::XPointer call_data) {
- XGetWindowProperty(p_display, p_window, p_property, 0, read_bytes, False, AnyPropertyType,
- &actual_type, &actual_format, &nitems, &bytes_after,
- &ret);
+ WARN_PRINT("Input method stopped");
+ DisplayServerX11 *ds = reinterpret_cast<DisplayServerX11 *>(client_data);
+ ds->xim = NULL;
- read_bytes *= 2;
+ for (Map<WindowID, WindowData>::Element *E = ds->windows.front(); E; E = E->next()) {
+ E->get().xic = NULL;
+ }
+}
- } while (bytes_after != 0);
+void DisplayServerX11::_window_changed(XEvent *event) {
- Property p = { ret, actual_format, (int)nitems, actual_type };
+ WindowID window_id = MAIN_WINDOW_ID;
- return p;
-}
+ // Assign the event to the relevant window
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (event->xany.window == E->get().x11_window) {
+ window_id = E->key();
+ break;
+ }
+ }
-static Atom pick_target_from_list(Display *p_display, Atom *p_list, int p_count) {
+ Rect2i new_rect;
- static const char *target_type = "text/uri-list";
+ WindowData &wd = windows[window_id];
+ if (wd.x11_window != event->xany.window) { // Check if the correct window, in case it was not main window or anything else
+ return;
+ }
- for (int i = 0; i < p_count; i++) {
+ {
+ //the position in xconfigure is not useful here, obtain it manually
+ int x, y;
+ Window child;
+ XTranslateCoordinates(x11_display, wd.x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child);
+ new_rect.position.x = x;
+ new_rect.position.y = y;
- Atom atom = p_list[i];
+ new_rect.size.width = event->xconfigure.width;
+ new_rect.size.height = event->xconfigure.height;
+ }
- if (atom != None && String(XGetAtomName(p_display, atom)) == target_type)
- return atom;
+ if (new_rect == Rect2i(wd.position, wd.size)) {
+ return;
+ }
+ if (wd.xic) {
+ // Not portable.
+ window_set_ime_position(Point2(0, 1));
}
- return None;
-}
-static Atom pick_target_from_atoms(Display *p_disp, Atom p_t1, Atom p_t2, Atom p_t3) {
+ wd.position = new_rect.position;
+ wd.size = new_rect.size;
- static const char *target_type = "text/uri-list";
- if (p_t1 != None && String(XGetAtomName(p_disp, p_t1)) == target_type)
- return p_t1;
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
+ }
+#endif
- if (p_t2 != None && String(XGetAtomName(p_disp, p_t2)) == target_type)
- return p_t2;
+ print_line("DisplayServer::_window_changed: " + itos(window_id) + " rect: " + new_rect);
+ if (!wd.rect_changed_callback.is_null()) {
+ Rect2i r = new_rect;
- if (p_t3 != None && String(XGetAtomName(p_disp, p_t3)) == target_type)
- return p_t3;
+ Variant rect = r;
- return None;
+ Variant *rectp = &rect;
+ Variant ret;
+ Callable::CallError ce;
+ wd.rect_changed_callback.call((const Variant **)&rectp, 1, ret, ce);
+ }
}
-void OS_X11::_window_changed(XEvent *event) {
+void DisplayServerX11::_dispatch_input_events(const Ref<InputEvent> &p_event) {
+ ((DisplayServerX11 *)(get_singleton()))->_dispatch_input_event(p_event);
+}
- if (xic) {
- // Not portable.
- set_ime_position(Point2(0, 1));
- }
- if ((event->xconfigure.width == current_videomode.width) &&
- (event->xconfigure.height == current_videomode.height))
- return;
+void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
- current_videomode.width = event->xconfigure.width;
- current_videomode.height = event->xconfigure.height;
+ Variant ev = p_event;
+ Variant *evp = &ev;
+ Variant ret;
+ Callable::CallError ce;
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- context_vulkan->window_resize(0, current_videomode.width, current_videomode.height);
+ Ref<InputEventFromWindow> event_from_window = p_event;
+ if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
+ //send to a window
+ ERR_FAIL_COND(!windows.has(event_from_window->get_window_id()));
+ Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
+ if (callable.is_null()) {
+ return;
+ }
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ } else {
+ //send to all windows
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ Callable callable = E->get().input_event_callback;
+ if (callable.is_null()) {
+ continue;
+ }
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
}
-#endif
}
-void OS_X11::process_xevents() {
+void DisplayServerX11::_send_window_event(const WindowData &wd, WindowEvent p_event) {
+ if (!wd.event_callback.is_null()) {
+ Variant event = int(p_event);
+ Variant *eventp = &event;
+ Variant ret;
+ Callable::CallError ce;
+ wd.event_callback.call((const Variant **)&eventp, 1, ret, ce);
+ }
+}
+void DisplayServerX11::process_events() {
- //printf("checking events %i\n", XPending(x11_display));
+ _THREAD_SAFE_METHOD_
do_mouse_warp = false;
@@ -2172,6 +2354,16 @@ void OS_X11::process_xevents() {
XEvent event;
XNextEvent(x11_display, &event);
+ WindowID window_id = MAIN_WINDOW_ID;
+
+ // Assign the event to the relevant window
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (event.xany.window == E->get().x11_window) {
+ window_id = E->key();
+ break;
+ }
+ }
+
if (XFilterEvent(&event, None)) {
continue;
}
@@ -2187,7 +2379,7 @@ void OS_X11::process_xevents() {
switch (event_data->evtype) {
case XI_HierarchyChanged:
case XI_DeviceChanged: {
- refresh_device_info();
+ _refresh_device_info();
} break;
case XI_RawMotion: {
XIRawEvent *raw_event = (XIRawEvent *)event_data;
@@ -2277,6 +2469,7 @@ void OS_X11::process_xevents() {
Ref<InputEventScreenTouch> st;
st.instance();
+ st->set_window_id(window_id);
st->set_index(index);
st->set_position(pos);
st->set_pressed(is_begin);
@@ -2290,12 +2483,12 @@ void OS_X11::process_xevents() {
// in a spurious mouse motion event being sent to Godot; remember it to be able to filter it out
xi.mouse_pos_to_filter = pos;
}
- input->accumulate_input_event(st);
+ InputFilter::get_singleton()->accumulate_input_event(st);
} else {
if (!xi.state.has(index)) // Defensive
break;
xi.state.erase(index);
- input->accumulate_input_event(st);
+ InputFilter::get_singleton()->accumulate_input_event(st);
}
} break;
@@ -2310,10 +2503,11 @@ void OS_X11::process_xevents() {
Ref<InputEventScreenDrag> sd;
sd.instance();
+ sd->set_window_id(window_id);
sd->set_index(index);
sd->set_position(pos);
sd->set_relative(pos - curr_pos_elem->value());
- input->accumulate_input_event(sd);
+ InputFilter::get_singleton()->accumulate_input_event(sd);
curr_pos_elem->value() = pos;
}
@@ -2338,31 +2532,37 @@ void OS_X11::process_xevents() {
minimized = (visibility->state == VisibilityFullyObscured);
} break;
case LeaveNotify: {
- if (main_loop && !mouse_mode_grab)
- main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
+ if (!mouse_mode_grab) {
+ _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT);
+ }
} break;
case EnterNotify: {
- if (main_loop && !mouse_mode_grab)
- main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
+ if (!mouse_mode_grab) {
+ _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
+ }
} break;
case FocusIn:
minimized = false;
window_has_focus = true;
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+ _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN);
window_focused = true;
if (mouse_mode_grab) {
// Show and update the cursor if confined and the window regained focus.
- if (mouse_mode == MOUSE_MODE_CONFINED)
- XUndefineCursor(x11_display, x11_window);
- else if (mouse_mode == MOUSE_MODE_CAPTURED) // or re-hide it in captured mode
- XDefineCursor(x11_display, x11_window, null_cursor);
-
- XGrabPointer(
- x11_display, x11_window, True,
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
- GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime);
+
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+
+ if (mouse_mode == MOUSE_MODE_CONFINED)
+ XUndefineCursor(x11_display, E->get().x11_window);
+ else if (mouse_mode == MOUSE_MODE_CAPTURED) // or re-hide it in captured mode
+ XDefineCursor(x11_display, E->get().x11_window, null_cursor);
+
+ XGrabPointer(
+ x11_display, E->get().x11_window, True,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+ GrabModeAsync, GrabModeAsync, E->get().x11_window, None, CurrentTime);
+ }
}
#ifdef TOUCH_ENABLED
// Grab touch devices to avoid OS gesture interference
@@ -2370,22 +2570,25 @@ void OS_X11::process_xevents() {
XIGrabDevice(x11_display, xi.touch_devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &xi.touch_event_mask);
}*/
#endif
- if (xic) {
- XSetICFocus(xic);
+ if (windows[window_id].xic) {
+ XSetICFocus(windows[window_id].xic);
}
break;
case FocusOut:
window_has_focus = false;
- input->release_pressed_events();
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+ InputFilter::get_singleton()->release_pressed_events();
+ _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_OUT);
window_focused = false;
if (mouse_mode_grab) {
- //dear X11, I try, I really try, but you never work, you do whathever you want.
- if (mouse_mode == MOUSE_MODE_CAPTURED) {
- // Show the cursor if we're in captured mode so it doesn't look weird.
- XUndefineCursor(x11_display, x11_window);
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+
+ //dear X11, I try, I really try, but you never work, you do whathever you want.
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ // Show the cursor if we're in captured mode so it doesn't look weird.
+ XUndefineCursor(x11_display, E->get().x11_window);
+ }
}
XUngrabPointer(x11_display, CurrentTime);
}
@@ -2401,13 +2604,14 @@ void OS_X11::process_xevents() {
Ref<InputEventScreenTouch> st;
st.instance();
st->set_index(E->key());
+ st->set_window_id(window_id);
st->set_position(E->get());
- input->accumulate_input_event(st);
+ InputFilter::get_singleton()->accumulate_input_event(st);
}
xi.state.clear();
#endif
- if (xic) {
- XUnsetICFocus(xic);
+ if (windows[window_id].xic) {
+ XSetICFocus(windows[window_id].xic);
}
break;
@@ -2427,13 +2631,14 @@ void OS_X11::process_xevents() {
Ref<InputEventMouseButton> mb;
mb.instance();
- get_key_modifier_state(event.xbutton.state, mb);
+ mb->set_window_id(window_id);
+ _get_key_modifier_state(event.xbutton.state, mb);
mb->set_button_index(event.xbutton.button);
if (mb->get_button_index() == 2)
mb->set_button_index(3);
else if (mb->get_button_index() == 3)
mb->set_button_index(2);
- mb->set_button_mask(get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
+ mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
mb->set_position(Vector2(event.xbutton.x, event.xbutton.y));
mb->set_global_position(mb->get_position());
@@ -2441,14 +2646,14 @@ void OS_X11::process_xevents() {
if (event.type == ButtonPress) {
- uint64_t diff = get_ticks_usec() / 1000 - last_click_ms;
+ uint64_t diff = OS::get_singleton()->get_ticks_usec() / 1000 - last_click_ms;
if (mb->get_button_index() == last_click_button_index) {
- if (diff < 400 && Point2(last_click_pos).distance_to(Point2(event.xbutton.x, event.xbutton.y)) < 5) {
+ if (diff < 400 && Vector2(last_click_pos).distance_to(Vector2(event.xbutton.x, event.xbutton.y)) < 5) {
last_click_ms = 0;
- last_click_pos = Point2(-100, -100);
+ last_click_pos = Point2i(-100, -100);
last_click_button_index = -1;
mb->set_doubleclick(true);
}
@@ -2459,11 +2664,11 @@ void OS_X11::process_xevents() {
if (!mb->is_doubleclick()) {
last_click_ms += diff;
- last_click_pos = Point2(event.xbutton.x, event.xbutton.y);
+ last_click_pos = Point2i(event.xbutton.x, event.xbutton.y);
}
}
- input->accumulate_input_event(mb);
+ InputFilter::get_singleton()->accumulate_input_event(mb);
} break;
case MotionNotify: {
@@ -2473,7 +2678,7 @@ void OS_X11::process_xevents() {
// generated by warping the mouse pointer.
while (true) {
- if (mouse_mode == MOUSE_MODE_CAPTURED && event.xmotion.x == current_videomode.width / 2 && event.xmotion.y == current_videomode.height / 2) {
+ if (mouse_mode == MOUSE_MODE_CAPTURED && event.xmotion.x == windows[MAIN_WINDOW_ID].size.width / 2 && event.xmotion.y == windows[MAIN_WINDOW_ID].size.height / 2) {
//this is likely the warp event since it was warped here
center = Vector2(event.xmotion.x, event.xmotion.y);
break;
@@ -2497,7 +2702,7 @@ void OS_X11::process_xevents() {
// Motion is also simple.
// A little hack is in order
// to be able to send relative motion events.
- Point2 pos(event.xmotion.x, event.xmotion.y);
+ Point2i pos(event.xmotion.x, event.xmotion.y);
// Avoidance of spurious mouse motion (see handling of touch)
bool filter = false;
@@ -2534,7 +2739,7 @@ void OS_X11::process_xevents() {
// RawMotion provides more precision than MotionNotify, which doesn't sense subpixel motion.
// Therefore, MotionNotify cannot be the authority on relative mouse motion.
// This means we need to take a combined approach...
- Point2 rel;
+ Point2i rel;
// Only use raw input if in capture mode. Otherwise use the classic behavior.
if (mouse_mode == MOUSE_MODE_CAPTURED) {
@@ -2548,24 +2753,25 @@ void OS_X11::process_xevents() {
xi.relative_motion.y = 0;
if (mouse_mode == MOUSE_MODE_CAPTURED) {
- pos = Point2i(current_videomode.width / 2, current_videomode.height / 2);
+ pos = Point2i(windows[MAIN_WINDOW_ID].size.width / 2, windows[MAIN_WINDOW_ID].size.height / 2);
}
Ref<InputEventMouseMotion> mm;
mm.instance();
+ mm->set_window_id(window_id);
mm->set_pressure(xi.pressure);
mm->set_tilt(xi.tilt);
// Make the absolute position integral so it doesn't look _too_ weird :)
Point2i posi(pos);
- get_key_modifier_state(event.xmotion.state, mm);
- mm->set_button_mask(get_mouse_button_state());
+ _get_key_modifier_state(event.xmotion.state, mm);
+ mm->set_button_mask(mouse_get_button_state());
mm->set_position(posi);
mm->set_global_position(posi);
- input->set_mouse_position(posi);
- mm->set_speed(input->get_last_mouse_speed());
+ InputFilter::get_singleton()->set_mouse_position(posi);
+ mm->set_speed(InputFilter::get_singleton()->get_last_mouse_speed());
mm->set_relative(rel);
@@ -2576,7 +2782,7 @@ void OS_X11::process_xevents() {
// this is so that the relative motion doesn't get messed up
// after we regain focus.
if (window_has_focus || !mouse_mode_grab)
- input->accumulate_input_event(mm);
+ InputFilter::get_singleton()->accumulate_input_event(mm);
} break;
case KeyPress:
@@ -2586,7 +2792,7 @@ void OS_X11::process_xevents() {
// key event is a little complex, so
// it will be handled in its own function.
- handle_key_event((XKeyEvent *)&event);
+ _handle_key_event(window_id, (XKeyEvent *)&event);
} break;
case SelectionRequest: {
@@ -2601,7 +2807,7 @@ void OS_X11::process_xevents() {
req->target == XA_STRING ||
req->target == XInternAtom(x11_display, "text/plain;charset=utf-8", 0) ||
req->target == XInternAtom(x11_display, "text/plain", 0)) {
- CharString clip = OS::get_clipboard().utf8();
+ CharString clip = clipboard_get().utf8();
XChangeProperty(x11_display,
req->requestor,
req->property,
@@ -2654,13 +2860,20 @@ void OS_X11::process_xevents() {
if (event.xselection.target == requested) {
- Property p = read_property(x11_display, x11_window, XInternAtom(x11_display, "PRIMARY", 0));
+ Property p = _read_property(x11_display, windows[window_id].x11_window, XInternAtom(x11_display, "PRIMARY", 0));
Vector<String> files = String((char *)p.data).split("\n", false);
for (int i = 0; i < files.size(); i++) {
files.write[i] = files[i].replace("file://", "").http_unescape().strip_edges();
}
- main_loop->drop_files(files);
+
+ if (!windows[window_id].drop_files_callback.is_null()) {
+ Variant v = files;
+ Variant *vp = &v;
+ Variant ret;
+ Callable::CallError ce;
+ windows[window_id].drop_files_callback.call((const Variant **)&vp, 1, ret, ce);
+ }
//Reply that all is well.
XClientMessageEvent m;
@@ -2670,7 +2883,7 @@ void OS_X11::process_xevents() {
m.window = xdnd_source_window;
m.message_type = xdnd_finished;
m.format = 32;
- m.data.l[0] = x11_window;
+ m.data.l[0] = windows[window_id].x11_window;
m.data.l[1] = 1;
m.data.l[2] = xdnd_action_copy; //We only ever copy.
@@ -2680,8 +2893,9 @@ void OS_X11::process_xevents() {
case ClientMessage:
- if ((unsigned int)event.xclient.data.l[0] == (unsigned int)wm_delete)
- main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
+ if ((unsigned int)event.xclient.data.l[0] == (unsigned int)wm_delete) {
+ _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST);
+ }
else if ((unsigned int)event.xclient.message_type == (unsigned int)xdnd_enter) {
@@ -2690,7 +2904,7 @@ void OS_X11::process_xevents() {
Window source = event.xclient.data.l[0];
bool more_than_3 = event.xclient.data.l[1] & 1;
if (more_than_3) {
- Property p = read_property(x11_display, source, XInternAtom(x11_display, "XdndTypeList", False));
+ Property p = _read_property(x11_display, source, XInternAtom(x11_display, "XdndTypeList", False));
requested = pick_target_from_list(x11_display, (Atom *)p.data, p.nitems);
} else
requested = pick_target_from_atoms(x11_display, event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
@@ -2705,7 +2919,7 @@ void OS_X11::process_xevents() {
m.window = event.xclient.data.l[0];
m.message_type = xdnd_status;
m.format = 32;
- m.data.l[0] = x11_window;
+ m.data.l[0] = windows[window_id].x11_window;
m.data.l[1] = (requested != None);
m.data.l[2] = 0; //empty rectangle
m.data.l[3] = 0;
@@ -2718,9 +2932,9 @@ void OS_X11::process_xevents() {
if (requested != None) {
xdnd_source_window = event.xclient.data.l[0];
if (xdnd_version >= 1)
- XConvertSelection(x11_display, xdnd_selection, requested, XInternAtom(x11_display, "PRIMARY", 0), x11_window, event.xclient.data.l[2]);
+ XConvertSelection(x11_display, xdnd_selection, requested, XInternAtom(x11_display, "PRIMARY", 0), windows[window_id].x11_window, event.xclient.data.l[2]);
else
- XConvertSelection(x11_display, xdnd_selection, requested, XInternAtom(x11_display, "PRIMARY", 0), x11_window, CurrentTime);
+ XConvertSelection(x11_display, xdnd_selection, requested, XInternAtom(x11_display, "PRIMARY", 0), windows[window_id].x11_window, CurrentTime);
} else {
//Reply that we're not interested.
XClientMessageEvent m;
@@ -2730,7 +2944,7 @@ void OS_X11::process_xevents() {
m.window = event.xclient.data.l[0];
m.message_type = xdnd_finished;
m.format = 32;
- m.data.l[0] = x11_window;
+ m.data.l[0] = windows[window_id].x11_window;
m.data.l[1] = 0;
m.data.l[2] = None; //Failed.
XSendEvent(x11_display, event.xclient.data.l[0], False, NoEventMask, (XEvent *)&m);
@@ -2746,8 +2960,8 @@ void OS_X11::process_xevents() {
if (do_mouse_warp) {
- XWarpPointer(x11_display, None, x11_window,
- 0, 0, 0, 0, (int)current_videomode.width / 2, (int)current_videomode.height / 2);
+ XWarpPointer(x11_display, None, windows[MAIN_WINDOW_ID].x11_window,
+ 0, 0, 0, 0, (int)windows[MAIN_WINDOW_ID].size.width / 2, (int)windows[MAIN_WINDOW_ID].size.height / 2);
/*
Window root, child;
@@ -2761,808 +2975,878 @@ void OS_X11::process_xevents() {
*/
}
- input->flush_accumulated_events();
+ InputFilter::get_singleton()->flush_accumulated_events();
}
-MainLoop *OS_X11::get_main_loop() const {
-
- return main_loop;
+void DisplayServerX11::release_rendering_thread() {
}
-void OS_X11::delete_main_loop() {
-
- if (main_loop)
- memdelete(main_loop);
- main_loop = NULL;
+void DisplayServerX11::make_rendering_thread() {
}
-void OS_X11::set_main_loop(MainLoop *p_main_loop) {
-
- main_loop = p_main_loop;
- input->set_main_loop(p_main_loop);
+void DisplayServerX11::swap_buffers() {
}
-bool OS_X11::can_draw() const {
+void DisplayServerX11::_update_context(WindowData &wd) {
+ XClassHint *classHint = XAllocClassHint();
- return !minimized;
-};
+ if (classHint) {
-void OS_X11::set_clipboard(const String &p_text) {
+ CharString name_str;
+ switch (context) {
+ case CONTEXT_EDITOR:
+ name_str = "Godot_Editor";
+ break;
+ case CONTEXT_PROJECTMAN:
+ name_str = "Godot_ProjectList";
+ break;
+ case CONTEXT_ENGINE:
+ name_str = "Godot_Engine";
+ break;
+ }
- OS::set_clipboard(p_text);
+ CharString class_str;
+ if (context == CONTEXT_ENGINE) {
+ String config_name = GLOBAL_GET("application/config/name");
+ if (config_name.length() == 0) {
+ class_str = "Godot_Engine";
+ } else {
+ class_str = config_name.utf8();
+ }
+ } else {
+ class_str = "Godot";
+ }
- XSetSelectionOwner(x11_display, XA_PRIMARY, x11_window, CurrentTime);
- XSetSelectionOwner(x11_display, XInternAtom(x11_display, "CLIPBOARD", 0), x11_window, CurrentTime);
-};
+ classHint->res_class = class_str.ptrw();
+ classHint->res_name = name_str.ptrw();
-static String _get_clipboard_impl(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard, Atom target) {
+ XSetClassHint(x11_display, wd.x11_window, classHint);
+ XFree(classHint);
+ }
+}
+void DisplayServerX11::set_context(Context p_context) {
- String ret;
+ _THREAD_SAFE_METHOD_
- Atom type;
- Atom selection = XA_PRIMARY;
- int format, result;
- unsigned long len, bytes_left, dummy;
- unsigned char *data;
- Window Sown = XGetSelectionOwner(x11_display, p_source);
+ context = p_context;
- if (Sown == x11_window) {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ _update_context(E->get());
+ }
+}
+void DisplayServerX11::set_native_icon(const String &p_filename) {
+ WARN_PRINT("Native icon not supported by this display server.");
+}
- return p_internal_clipboard;
- };
+bool g_set_icon_error = false;
+int set_icon_errorhandler(Display *dpy, XErrorEvent *ev) {
+ g_set_icon_error = true;
+ return 0;
+}
- if (Sown != None) {
- XConvertSelection(x11_display, p_source, target, selection,
- x11_window, CurrentTime);
- XFlush(x11_display);
- while (true) {
- XEvent event;
- XNextEvent(x11_display, &event);
- if (event.type == SelectionNotify && event.xselection.requestor == x11_window) {
- break;
- };
- };
+void DisplayServerX11::set_icon(const Ref<Image> &p_icon) {
+ _THREAD_SAFE_METHOD_
- //
- // Do not get any data, see how much data is there
- //
- XGetWindowProperty(x11_display, x11_window,
- selection, // Tricky..
- 0, 0, // offset - len
- 0, // Delete 0==FALSE
- AnyPropertyType, //flag
- &type, // return type
- &format, // return format
- &len, &bytes_left, //that
- &data);
- // DATA is There
- if (bytes_left > 0) {
- result = XGetWindowProperty(x11_display, x11_window,
- selection, 0, bytes_left, 0,
- AnyPropertyType, &type, &format,
- &len, &dummy, &data);
- if (result == Success) {
- ret.parse_utf8((const char *)data);
- } else
- printf("FAIL\n");
- XFree(data);
- }
- }
+ WindowData &wd = windows[MAIN_WINDOW_ID];
- return ret;
-}
+ int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&set_icon_errorhandler);
-static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard) {
- String ret;
- Atom utf8_atom = XInternAtom(x11_display, "UTF8_STRING", True);
- if (utf8_atom != None) {
- ret = _get_clipboard_impl(p_source, x11_window, x11_display, p_internal_clipboard, utf8_atom);
- }
- if (ret == "") {
- ret = _get_clipboard_impl(p_source, x11_window, x11_display, p_internal_clipboard, XA_STRING);
- }
- return ret;
-}
+ Atom net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False);
-String OS_X11::get_clipboard() const {
+ if (p_icon.is_valid()) {
+ Ref<Image> img = p_icon->duplicate();
+ img->convert(Image::FORMAT_RGBA8);
- String ret;
- ret = _get_clipboard(XInternAtom(x11_display, "CLIPBOARD", 0), x11_window, x11_display, OS::get_clipboard());
+ while (true) {
+ int w = img->get_width();
+ int h = img->get_height();
- if (ret == "") {
- ret = _get_clipboard(XA_PRIMARY, x11_window, x11_display, OS::get_clipboard());
- };
+ if (g_set_icon_error) {
+ g_set_icon_error = false;
- return ret;
-}
+ WARN_PRINT("Icon too large, attempting to resize icon.");
-String OS_X11::get_name() const {
+ int new_width, new_height;
+ if (w > h) {
+ new_width = w / 2;
+ new_height = h * new_width / w;
+ } else {
+ new_height = h / 2;
+ new_width = w * new_height / h;
+ }
- return "X11";
-}
+ w = new_width;
+ h = new_height;
-Error OS_X11::shell_open(String p_uri) {
+ if (!w || !h) {
+ WARN_PRINT("Unable to set icon.");
+ break;
+ }
- Error ok;
- List<String> args;
- args.push_back(p_uri);
- ok = execute("xdg-open", args, false);
- if (ok == OK)
- return OK;
- ok = execute("gnome-open", args, false);
- if (ok == OK)
- return OK;
- ok = execute("kde-open", args, false);
- return ok;
-}
+ img->resize(w, h, Image::INTERPOLATE_CUBIC);
+ }
-bool OS_X11::_check_internal_feature_support(const String &p_feature) {
+ // We're using long to have wordsize (32Bit build -> 32 Bits, 64 Bit build -> 64 Bits
+ Vector<long> pd;
- return p_feature == "pc";
-}
+ pd.resize(2 + w * h);
-String OS_X11::get_config_path() const {
+ pd.write[0] = w;
+ pd.write[1] = h;
- if (has_environment("XDG_CONFIG_HOME")) {
- return get_environment("XDG_CONFIG_HOME");
- } else if (has_environment("HOME")) {
- return get_environment("HOME").plus_file(".config");
- } else {
- return ".";
- }
-}
+ const uint8_t *r = img->get_data().ptr();
-String OS_X11::get_data_path() const {
+ long *wr = &pd.write[2];
+ uint8_t const *pr = r;
- if (has_environment("XDG_DATA_HOME")) {
- return get_environment("XDG_DATA_HOME");
- } else if (has_environment("HOME")) {
- return get_environment("HOME").plus_file(".local/share");
- } else {
- return get_config_path();
- }
-}
+ for (int i = 0; i < w * h; i++) {
+ long v = 0;
+ // A R G B
+ v |= pr[3] << 24 | pr[0] << 16 | pr[1] << 8 | pr[2];
+ *wr++ = v;
+ pr += 4;
+ }
-String OS_X11::get_cache_path() const {
+ XChangeProperty(x11_display, wd.x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pd.ptr(), pd.size());
- if (has_environment("XDG_CACHE_HOME")) {
- return get_environment("XDG_CACHE_HOME");
- } else if (has_environment("HOME")) {
- return get_environment("HOME").plus_file(".cache");
+ if (!g_set_icon_error)
+ break;
+ }
} else {
- return get_config_path();
+ XDeleteProperty(x11_display, wd.x11_window, net_wm_icon);
}
+
+ XFlush(x11_display);
+ XSetErrorHandler(oldHandler);
}
-String OS_X11::get_system_dir(SystemDir p_dir) const {
+Vector<String> DisplayServerX11::get_rendering_drivers_func() {
+ Vector<String> drivers;
- String xdgparam;
+#ifdef VULKAN_ENABLED
+ drivers.push_back("vulkan");
+#endif
+#ifdef OPENGL_ENABLED
+ drivers.push_back("opengl");
+#endif
- switch (p_dir) {
- case SYSTEM_DIR_DESKTOP: {
+ return drivers;
+}
- xdgparam = "DESKTOP";
- } break;
- case SYSTEM_DIR_DCIM: {
+DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
- xdgparam = "PICTURES";
+ return memnew(DisplayServerX11(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
+}
- } break;
- case SYSTEM_DIR_DOCUMENTS: {
+DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
- xdgparam = "DOCUMENTS";
+ //Create window
- } break;
- case SYSTEM_DIR_DOWNLOADS: {
+ long visualMask = VisualScreenMask;
+ int numberOfVisuals;
+ XVisualInfo vInfoTemplate = {};
+ vInfoTemplate.screen = DefaultScreen(x11_display);
+ XVisualInfo *visualInfo = XGetVisualInfo(x11_display, visualMask, &vInfoTemplate, &numberOfVisuals);
- xdgparam = "DOWNLOAD";
+ Colormap colormap = XCreateColormap(x11_display, RootWindow(x11_display, vInfoTemplate.screen), visualInfo->visual, AllocNone);
- } break;
- case SYSTEM_DIR_MOVIES: {
+ XSetWindowAttributes windowAttributes = {};
+ windowAttributes.colormap = colormap;
+ windowAttributes.background_pixel = 0xFFFFFFFF;
+ windowAttributes.border_pixel = 0;
+ windowAttributes.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask | ExposureMask;
- xdgparam = "VIDEOS";
+ unsigned long valuemask = CWBorderPixel | CWColormap | CWEventMask;
- } break;
- case SYSTEM_DIR_MUSIC: {
+ WindowID id;
+ {
+ WindowData wd;
+ wd.x11_window = XCreateWindow(x11_display, RootWindow(x11_display, visualInfo->screen), p_rect.position.x, p_rect.position.y, p_rect.size.width > 0 ? p_rect.size.width : 1, p_rect.size.height > 0 ? p_rect.size.height : 1, 0, visualInfo->depth, InputOutput, visualInfo->visual, valuemask, &windowAttributes);
- xdgparam = "MUSIC";
+ XMapWindow(x11_display, wd.x11_window);
- } break;
- case SYSTEM_DIR_PICTURES: {
+ //associate PID
+ // make PID known to X11
+ {
+ const long pid = OS::get_singleton()->get_process_id();
+ Atom net_wm_pid = XInternAtom(x11_display, "_NET_WM_PID", False);
+ XChangeProperty(x11_display, wd.x11_window, net_wm_pid, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1);
+ }
- xdgparam = "PICTURES";
+ long im_event_mask = 0;
- } break;
- case SYSTEM_DIR_RINGTONES: {
+ {
+ XIEventMask all_event_mask;
+ XSetWindowAttributes new_attr;
- xdgparam = "MUSIC";
+ new_attr.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
+ ButtonReleaseMask | EnterWindowMask |
+ LeaveWindowMask | PointerMotionMask |
+ Button1MotionMask |
+ Button2MotionMask | Button3MotionMask |
+ Button4MotionMask | Button5MotionMask |
+ ButtonMotionMask | KeymapStateMask |
+ ExposureMask | VisibilityChangeMask |
+ StructureNotifyMask |
+ SubstructureNotifyMask | SubstructureRedirectMask |
+ FocusChangeMask | PropertyChangeMask |
+ ColormapChangeMask | OwnerGrabButtonMask |
+ im_event_mask;
- } break;
- }
+ XChangeWindowAttributes(x11_display, wd.x11_window, CWEventMask, &new_attr);
- String pipe;
- List<String> arg;
- arg.push_back(xdgparam);
- Error err = const_cast<OS_X11 *>(this)->execute("xdg-user-dir", arg, true, NULL, &pipe);
- if (err != OK)
- return ".";
- return pipe.strip_edges();
-}
+ static unsigned char all_mask_data[XIMaskLen(XI_LASTEVENT)] = {};
-void OS_X11::move_window_to_foreground() {
+ all_event_mask.deviceid = XIAllDevices;
+ all_event_mask.mask_len = sizeof(all_mask_data);
+ all_event_mask.mask = all_mask_data;
- XEvent xev;
- Atom net_active_window = XInternAtom(x11_display, "_NET_ACTIVE_WINDOW", False);
+ XISetMask(all_event_mask.mask, XI_HierarchyChanged);
- memset(&xev, 0, sizeof(xev));
- xev.type = ClientMessage;
- xev.xclient.window = x11_window;
- xev.xclient.message_type = net_active_window;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = 1;
- xev.xclient.data.l[1] = CurrentTime;
+#ifdef TOUCH_ENABLED
+ if (xi.touch_devices.size()) {
+ XISetMask(all_event_mask.mask, XI_TouchBegin);
+ XISetMask(all_event_mask.mask, XI_TouchUpdate);
+ XISetMask(all_event_mask.mask, XI_TouchEnd);
+ XISetMask(all_event_mask.mask, XI_TouchOwnership);
+ }
+#endif
- XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
- XFlush(x11_display);
-}
+ XISelectEvents(x11_display, wd.x11_window, &all_event_mask, 1);
+ }
-void OS_X11::set_cursor_shape(CursorShape p_shape) {
+ /* set the titlebar name */
+ XStoreName(x11_display, wd.x11_window, "Godot");
+ XSetWMProtocols(x11_display, wd.x11_window, &wm_delete, 1);
+ XChangeProperty(x11_display, wd.x11_window, xdnd_aware, XA_ATOM, 32, PropModeReplace, (unsigned char *)&xdnd_version, 1);
- ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
+ if (xim && xim_style) {
- if (p_shape == current_cursor) {
- return;
- }
+ wd.xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, wd.x11_window, XNFocusWindow, wd.x11_window, (char *)NULL);
+ if (XGetICValues(wd.xic, XNFilterEvents, &im_event_mask, NULL) != NULL) {
+ WARN_PRINT("XGetICValues couldn't obtain XNFilterEvents value");
+ XDestroyIC(wd.xic);
+ wd.xic = NULL;
+ }
+ if (wd.xic) {
+ XUnsetICFocus(wd.xic);
+ } else {
+ WARN_PRINT("XCreateIC couldn't create wd.xic");
+ }
+ } else {
- if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
- if (cursors[p_shape] != None) {
- XDefineCursor(x11_display, x11_window, cursors[p_shape]);
- } else if (cursors[CURSOR_ARROW] != None) {
- XDefineCursor(x11_display, x11_window, cursors[CURSOR_ARROW]);
+ wd.xic = NULL;
+ WARN_PRINT("XCreateIC couldn't create wd.xic");
}
- }
- current_cursor = p_shape;
-}
+ _update_context(wd);
-OS::CursorShape OS_X11::get_cursor_shape() const {
+ id = window_id_counter++;
- return current_cursor;
-}
+ windows[id] = wd;
-void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+ {
- if (p_cursor.is_valid()) {
+ if (p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT) {
- Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
+ XSizeHints *xsh;
+ xsh = XAllocSizeHints();
- if (cursor_c) {
- if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
- set_cursor_shape(p_shape);
- return;
+ xsh->flags = PMinSize | PMaxSize;
+ xsh->min_width = p_rect.size.width;
+ xsh->max_width = p_rect.size.width;
+ xsh->min_height = p_rect.size.height;
+ xsh->max_height = p_rect.size.height;
+
+ XSetWMNormalHints(x11_display, wd.x11_window, xsh);
+ XFree(xsh);
}
- cursors_cache.erase(p_shape);
- }
+ bool make_utility = false;
- Ref<Texture2D> texture = p_cursor;
- Ref<AtlasTexture> atlas_texture = p_cursor;
- Ref<Image> image;
- Size2 texture_size;
- Rect2 atlas_rect;
+ if (p_flags & WINDOW_FLAG_BORDERLESS_BIT) {
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ hints.decorations = 0;
+ property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
+ XChangeProperty(x11_display, wd.x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
- if (texture.is_valid()) {
- image = texture->get_data();
- }
+ make_utility = true;
+ }
+ if (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) {
+ make_utility = true;
+ }
- if (!image.is_valid() && atlas_texture.is_valid()) {
- texture = atlas_texture->get_atlas();
+ if (make_utility) {
+ //this one seems to disable the fade animations for regular windows
+ //but has the drawback that will not get focus by default, so
+ //we need fo force it, unless no focus requested
- atlas_rect.size.width = texture->get_width();
- atlas_rect.size.height = texture->get_height();
- atlas_rect.position.x = atlas_texture->get_region().position.x;
- atlas_rect.position.y = atlas_texture->get_region().position.y;
+ Atom type_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE_UTILITY", False);
+ Atom wt_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE", False);
- texture_size.width = atlas_texture->get_region().size.x;
- texture_size.height = atlas_texture->get_region().size.y;
- } else if (image.is_valid()) {
- texture_size.width = texture->get_width();
- texture_size.height = texture->get_height();
- }
+ XChangeProperty(x11_display, wd.x11_window, wt_atom, XA_ATOM, 32, PropModeReplace, (unsigned char *)&type_atom, 1);
- ERR_FAIL_COND(!texture.is_valid());
- ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0);
- ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256);
- ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height);
+ if (!(p_flags & WINDOW_FLAG_NO_FOCUS_BIT)) {
+ //but as utility appears unfocused, it needs to be forcefuly focused, unless no focus requested
+ XEvent xev;
+ Atom net_active_window = XInternAtom(x11_display, "_NET_ACTIVE_WINDOW", False);
- image = texture->get_data();
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = wd.x11_window;
+ xev.xclient.message_type = net_active_window;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = CurrentTime;
- ERR_FAIL_COND(!image.is_valid());
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ }
+ } else {
+ Atom type_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
+ Atom wt_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE", False);
- // Create the cursor structure
- XcursorImage *cursor_image = XcursorImageCreate(texture_size.width, texture_size.height);
- XcursorUInt image_size = texture_size.width * texture_size.height;
- XcursorDim size = sizeof(XcursorPixel) * image_size;
+ XChangeProperty(x11_display, wd.x11_window, wt_atom, XA_ATOM, 32, PropModeReplace, (unsigned char *)&type_atom, 1);
+ }
+ }
- cursor_image->version = 1;
- cursor_image->size = size;
- cursor_image->xhot = p_hotspot.x;
- cursor_image->yhot = p_hotspot.y;
+ if (id != MAIN_WINDOW_ID) {
- // allocate memory to contain the whole file
- cursor_image->pixels = (XcursorPixel *)memalloc(size);
+ XSizeHints my_hints = XSizeHints();
- for (XcursorPixel index = 0; index < image_size; index++) {
- int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
- int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
+ my_hints.flags = PPosition | PSize; /* I want to specify position and size */
+ my_hints.x = p_rect.position.x; /* The origin and size coords I want */
+ my_hints.y = p_rect.position.y;
+ my_hints.width = p_rect.size.width;
+ my_hints.height = p_rect.size.height;
- if (atlas_texture.is_valid()) {
- column_index = MIN(column_index, atlas_rect.size.width - 1);
- row_index = MIN(row_index, atlas_rect.size.height - 1);
- }
+ XSetNormalHints(x11_display, wd.x11_window, &my_hints);
+ XMoveWindow(x11_display, wd.x11_window, p_rect.position.x, p_rect.position.y);
+ }
- *(cursor_image->pixels + index) = image->get_pixel(column_index, row_index).to_argb32();
+#if defined(VULKAN_ENABLED)
+ if (context_vulkan) {
+ Error err = context_vulkan->window_create(id, wd.x11_window, x11_display, p_rect.size.width, p_rect.size.height);
+ ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window");
}
+#endif
- ERR_FAIL_COND(cursor_image->pixels == NULL);
+ //set_class_hint(x11_display, wd.x11_window);
+ XFlush(x11_display);
- // Save it for a further usage
- cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image);
+ XSync(x11_display, False);
+ //XSetErrorHandler(oldHandler);
- Vector<Variant> params;
- params.push_back(p_cursor);
- params.push_back(p_hotspot);
- cursors_cache.insert(p_shape, params);
+ XFree(visualInfo);
+ }
- if (p_shape == current_cursor) {
- if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
- XDefineCursor(x11_display, x11_window, cursors[p_shape]);
- }
- }
+ WindowData &wd = windows[id];
- memfree(cursor_image->pixels);
- XcursorImageDestroy(cursor_image);
- } else {
- // Reset to default system cursor
- if (img[p_shape]) {
- cursors[p_shape] = XcursorImageLoadCursor(x11_display, img[p_shape]);
- }
+ window_set_mode(p_mode, id);
- CursorShape c = current_cursor;
- current_cursor = CURSOR_MAX;
- set_cursor_shape(c);
+ //sync size
+ {
+ XWindowAttributes xwa;
- cursors_cache.erase(p_shape);
- }
-}
+ XSync(x11_display, False);
+ XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
-void OS_X11::release_rendering_thread() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->release_current();
- }
-#endif
-}
+ wd.position.x = xwa.x;
+ wd.position.y = xwa.y;
+ wd.size.width = xwa.width;
+ wd.size.height = xwa.height;
-void OS_X11::make_rendering_thread() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->make_current();
+ print_line("DisplayServer::_create_window " + itos(id) + " want rect: " + p_rect + " got rect " + Rect2i(xwa.x, xwa.y, xwa.width, xwa.height));
}
-#endif
-}
-void OS_X11::swap_buffers() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->swap_buffers();
- }
-#endif
- /* not needed for now
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- context_vulkan->swap_buffers();
+ //set cursor
+ if (cursors[current_cursor] != None) {
+
+ XDefineCursor(x11_display, wd.x11_window, cursors[current_cursor]);
}
-#endif*/
+ return id;
}
-void OS_X11::alert(const String &p_alert, const String &p_title) {
- const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" };
+DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
- String path = get_environment("PATH");
- Vector<String> path_elems = path.split(":", false);
- String program;
+ InputFilter::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
- for (int i = 0; i < path_elems.size(); i++) {
- for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) {
- String tested_path = path_elems[i].plus_file(message_programs[k]);
+ r_error = OK;
- if (FileAccess::exists(tested_path)) {
- program = tested_path;
- break;
- }
- }
+ last_button_state = 0;
- if (program.length())
- break;
- }
+ xmbstring = NULL;
- List<String> args;
+ last_click_ms = 0;
+ last_click_button_index = -1;
+ last_click_pos = Point2i(-100, -100);
- if (program.ends_with("zenity")) {
- args.push_back("--error");
- args.push_back("--width");
- args.push_back("500");
- args.push_back("--title");
- args.push_back(p_title);
- args.push_back("--text");
- args.push_back(p_alert);
- }
+ last_timestamp = 0;
+ last_mouse_pos_valid = false;
+ last_keyrelease_time = 0;
- if (program.ends_with("kdialog")) {
- args.push_back("--error");
- args.push_back(p_alert);
- args.push_back("--title");
- args.push_back(p_title);
+ XInitThreads(); //always use threads
+
+ /** XLIB INITIALIZATION **/
+ x11_display = XOpenDisplay(NULL);
+
+ if (!x11_display) {
+ ERR_PRINT("X11 Display is not available");
+ r_error = ERR_UNAVAILABLE;
+ return;
}
- if (program.ends_with("Xdialog")) {
- args.push_back("--title");
- args.push_back(p_title);
- args.push_back("--msgbox");
- args.push_back(p_alert);
- args.push_back("0");
- args.push_back("0");
+ char *modifiers = NULL;
+ Bool xkb_dar = False;
+ XAutoRepeatOn(x11_display);
+ xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL);
+
+ // Try to support IME if detectable auto-repeat is supported
+ if (xkb_dar == True) {
+
+#ifdef X_HAVE_UTF8_STRING
+ // Xutf8LookupString will be used later instead of XmbLookupString before
+ // the multibyte sequences can be converted to unicode string.
+ modifiers = XSetLocaleModifiers("");
+#endif
}
- if (program.ends_with("xmessage")) {
- args.push_back("-center");
- args.push_back("-title");
- args.push_back(p_title);
- args.push_back(p_alert);
+ if (modifiers == NULL) {
+ if (OS::get_singleton()->is_stdout_verbose()) {
+ WARN_PRINT("IME is disabled");
+ }
+ XSetLocaleModifiers("@im=none");
+ WARN_PRINT("Error setting locale modifiers");
}
- if (program.length()) {
- execute(program, args, true);
+ const char *err;
+ xrr_get_monitors = NULL;
+ xrr_free_monitors = NULL;
+ int xrandr_major = 0;
+ int xrandr_minor = 0;
+ int event_base, error_base;
+ xrandr_ext_ok = XRRQueryExtension(x11_display, &event_base, &error_base);
+ xrandr_handle = dlopen("libXrandr.so.2", RTLD_LAZY);
+ if (!xrandr_handle) {
+ err = dlerror();
+ fprintf(stderr, "could not load libXrandr.so.2, Error: %s\n", err);
} else {
- print_line(p_alert);
+ XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor);
+ if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) {
+ xrr_get_monitors = (xrr_get_monitors_t)dlsym(xrandr_handle, "XRRGetMonitors");
+ if (!xrr_get_monitors) {
+ err = dlerror();
+ fprintf(stderr, "could not find symbol XRRGetMonitors\nError: %s\n", err);
+ } else {
+ xrr_free_monitors = (xrr_free_monitors_t)dlsym(xrandr_handle, "XRRFreeMonitors");
+ if (!xrr_free_monitors) {
+ err = dlerror();
+ fprintf(stderr, "could not find XRRFreeMonitors\nError: %s\n", err);
+ xrr_get_monitors = NULL;
+ }
+ }
+ }
}
-}
-
-bool g_set_icon_error = false;
-int set_icon_errorhandler(Display *dpy, XErrorEvent *ev) {
- g_set_icon_error = true;
- return 0;
-}
-void OS_X11::set_icon(const Ref<Image> &p_icon) {
- int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&set_icon_errorhandler);
-
- Atom net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False);
-
- if (p_icon.is_valid()) {
- Ref<Image> img = p_icon->duplicate();
- img->convert(Image::FORMAT_RGBA8);
+ if (!_refresh_device_info()) {
+ alert("Your system does not support XInput 2.\n"
+ "Please upgrade your distribution.",
+ "Unable to initialize XInput");
+ r_error = ERR_UNAVAILABLE;
+ return;
+ }
- while (true) {
- int w = img->get_width();
- int h = img->get_height();
+ xim = XOpenIM(x11_display, NULL, NULL, NULL);
- if (g_set_icon_error) {
- g_set_icon_error = false;
+ if (xim == NULL) {
+ WARN_PRINT("XOpenIM failed");
+ xim_style = 0L;
+ } else {
+ ::XIMCallback im_destroy_callback;
+ im_destroy_callback.client_data = (::XPointer)(this);
+ im_destroy_callback.callback = (::XIMProc)(_xim_destroy_callback);
+ if (XSetIMValues(xim, XNDestroyCallback, &im_destroy_callback,
+ NULL) != NULL) {
+ WARN_PRINT("Error setting XIM destroy callback");
+ }
- WARN_PRINT("Icon too large, attempting to resize icon.");
+ ::XIMStyles *xim_styles = NULL;
+ xim_style = 0L;
+ char *imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
+ if (imvalret != NULL || xim_styles == NULL) {
+ fprintf(stderr, "Input method doesn't support any styles\n");
+ }
- int new_width, new_height;
- if (w > h) {
- new_width = w / 2;
- new_height = h * new_width / w;
- } else {
- new_height = h / 2;
- new_width = w * new_height / h;
- }
+ if (xim_styles) {
+ xim_style = 0L;
+ for (int i = 0; i < xim_styles->count_styles; i++) {
- w = new_width;
- h = new_height;
+ if (xim_styles->supported_styles[i] ==
+ (XIMPreeditNothing | XIMStatusNothing)) {
- if (!w || !h) {
- WARN_PRINT("Unable to set icon.");
+ xim_style = xim_styles->supported_styles[i];
break;
}
-
- img->resize(w, h, Image::INTERPOLATE_CUBIC);
}
- // We're using long to have wordsize (32Bit build -> 32 Bits, 64 Bit build -> 64 Bits
- Vector<long> pd;
-
- pd.resize(2 + w * h);
-
- pd.write[0] = w;
- pd.write[1] = h;
+ XFree(xim_styles);
+ }
+ XFree(imvalret);
+ }
- const uint8_t *r = img->get_data().ptr();
+ /* Atorm internment */
+ wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
+ //Set Xdnd (drag & drop) support
+ xdnd_aware = XInternAtom(x11_display, "XdndAware", False);
+ xdnd_version = 5;
+ xdnd_enter = XInternAtom(x11_display, "XdndEnter", False);
+ xdnd_position = XInternAtom(x11_display, "XdndPosition", False);
+ xdnd_status = XInternAtom(x11_display, "XdndStatus", False);
+ xdnd_action_copy = XInternAtom(x11_display, "XdndActionCopy", False);
+ xdnd_drop = XInternAtom(x11_display, "XdndDrop", False);
+ xdnd_finished = XInternAtom(x11_display, "XdndFinished", False);
+ xdnd_selection = XInternAtom(x11_display, "XdndSelection", False);
- long *wr = &pd.write[2];
- uint8_t const *pr = r;
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //TODO - do Vulkan and GLES2 support checks, driver selection and fallback
+ rendering_driver = p_rendering_driver;
- for (int i = 0; i < w * h; i++) {
- long v = 0;
- // A R G B
- v |= pr[3] << 24 | pr[0] << 16 | pr[1] << 8 | pr[2];
- *wr++ = v;
- pr += 4;
- }
+#ifndef _MSC_VER
+#warning Forcing vulkan rendering driver because OpenGL not implemented yet
+#endif
+ rendering_driver = "vulkan";
- XChangeProperty(x11_display, x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pd.ptr(), pd.size());
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
- if (!g_set_icon_error)
- break;
+ context_vulkan = memnew(VulkanContextX11);
+ if (context_vulkan->initialize() != OK) {
+ memdelete(context_vulkan);
+ context_vulkan = NULL;
+ r_error = ERR_CANT_CREATE;
+ ERR_FAIL_MSG("Could not initialize Vulkan");
}
- } else {
- XDeleteProperty(x11_display, x11_window, net_wm_icon);
}
-
- XFlush(x11_display);
- XSetErrorHandler(oldHandler);
-}
-
-void OS_X11::force_process_input() {
- process_xevents(); // get rid of pending events
-#ifdef JOYDEV_ENABLED
- joypad->process_joypads();
#endif
-}
+ // Init context and rendering device
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ if (getenv("DRI_PRIME") == NULL) {
+ int use_prime = -1;
-void OS_X11::run() {
+ if (getenv("PRIMUS_DISPLAY") ||
+ getenv("PRIMUS_libGLd") ||
+ getenv("PRIMUS_libGLa") ||
+ getenv("PRIMUS_libGL") ||
+ getenv("PRIMUS_LOAD_GLOBAL") ||
+ getenv("BUMBLEBEE_SOCKET")) {
- force_quit = false;
+ print_verbose("Optirun/primusrun detected. Skipping GPU detection");
+ use_prime = 0;
+ }
- if (!main_loop)
- return;
+ if (getenv("LD_LIBRARY_PATH")) {
+ String ld_library_path(getenv("LD_LIBRARY_PATH"));
+ Vector<String> libraries = ld_library_path.split(":");
- main_loop->init();
+ for (int i = 0; i < libraries.size(); ++i) {
+ if (FileAccess::exists(libraries[i] + "/libGL.so.1") ||
+ FileAccess::exists(libraries[i] + "/libGL.so")) {
- //uint64_t last_ticks=get_ticks_usec();
+ print_verbose("Custom libGL override detected. Skipping GPU detection");
+ use_prime = 0;
+ }
+ }
+ }
- //int frames=0;
- //uint64_t frame=0;
+ if (use_prime == -1) {
+ print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
+ use_prime = detect_prime();
+ }
- while (!force_quit) {
+ if (use_prime) {
+ print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");
+ print_line("Note: Set DRI_PRIME=0 in the environment to disable Godot from using the discrete GPU.");
+ setenv("DRI_PRIME", "1", 1);
+ }
+ }
- process_xevents(); // get rid of pending events
-#ifdef JOYDEV_ENABLED
- joypad->process_joypads();
-#endif
- if (Main::iteration())
- break;
- };
+ ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
- main_loop->finish();
-}
+ context_gles2 = memnew(ContextGL_X11(x11_display, x11_window, current_videomode, opengl_api_type));
-bool OS_X11::is_joy_known(int p_device) {
- return input->is_joy_mapped(p_device);
-}
+ if (context_gles2->initialize() != OK) {
+ memdelete(context_gles2);
+ context_gles2 = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
-String OS_X11::get_joy_guid(int p_device) const {
- return input->get_joy_guid_remapped(p_device);
-}
+ context_gles2->set_use_vsync(current_videomode.use_vsync);
-void OS_X11::_set_use_vsync(bool p_enable) {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- if (context_gles2)
- context_gles2->set_use_vsync(p_enable);
+ if (RasterizerGLES2::is_viable() == OK) {
+ RasterizerGLES2::register_config();
+ RasterizerGLES2::make_current();
+ } else {
+ memdelete(context_gles2);
+ context_gles2 = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
}
#endif
-}
-
-void OS_X11::set_context(int p_context) {
- XClassHint *classHint = XAllocClassHint();
+ WindowID main_window = _create_window(p_mode, p_flags, Rect2i(Point2(), p_resolution));
+ for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
+ if (p_flags & (1 << i)) {
+ window_set_flag(WindowFlags(i), true, main_window);
+ }
+ }
- if (classHint) {
+//create RenderingDevice if used
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
- CharString name_str;
- switch (p_context) {
- case CONTEXT_EDITOR:
- name_str = "Godot_Editor";
- break;
- case CONTEXT_PROJECTMAN:
- name_str = "Godot_ProjectList";
- break;
- case CONTEXT_ENGINE:
- name_str = "Godot_Engine";
- break;
- }
+ //temporary
+ rendering_device_vulkan = memnew(RenderingDeviceVulkan);
+ rendering_device_vulkan->initialize(context_vulkan);
- CharString class_str;
- if (p_context == CONTEXT_ENGINE) {
- String config_name = GLOBAL_GET("application/config/name");
- if (config_name.length() == 0) {
- class_str = "Godot_Engine";
- } else {
- class_str = config_name.utf8();
- }
- } else {
- class_str = "Godot";
- }
+ RasterizerRD::make_current();
+ }
+#endif
- classHint->res_class = class_str.ptrw();
- classHint->res_name = name_str.ptrw();
+ /*
+ rendering_server = memnew(RenderingServerRaster);
+ if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
+ rendering_server = memnew(RenderingServerWrapMT(rendering_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
+ }
+ */
- XSetClassHint(x11_display, x11_window, classHint);
- XFree(classHint);
+ {
+ //set all event master mask
+ XIEventMask all_master_event_mask;
+ static unsigned char all_master_mask_data[XIMaskLen(XI_LASTEVENT)] = {};
+ all_master_event_mask.deviceid = XIAllMasterDevices;
+ all_master_event_mask.mask_len = sizeof(all_master_mask_data);
+ all_master_event_mask.mask = all_master_mask_data;
+ XISetMask(all_master_event_mask.mask, XI_DeviceChanged);
+ XISetMask(all_master_event_mask.mask, XI_RawMotion);
+ XISelectEvents(x11_display, DefaultRootWindow(x11_display), &all_master_event_mask, 1);
}
-}
-void OS_X11::disable_crash_handler() {
- crash_handler.disable();
-}
+ // Disabled by now since grabbing also blocks mouse events
+ // (they are received as extended events instead of standard events)
+ /*XIClearMask(xi.touch_event_mask.mask, XI_TouchOwnership);
-bool OS_X11::is_disable_crash_handler() const {
- return crash_handler.is_disabled();
-}
+ // Grab touch devices to avoid OS gesture interference
+ for (int i = 0; i < xi.touch_devices.size(); ++i) {
+ XIGrabDevice(x11_display, xi.touch_devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &xi.touch_event_mask);
+ }*/
-static String get_mountpoint(const String &p_path) {
- struct stat s;
- if (stat(p_path.utf8().get_data(), &s)) {
- return "";
- }
+ cursor_size = XcursorGetDefaultSize(x11_display);
+ cursor_theme = XcursorGetTheme(x11_display);
-#ifdef HAVE_MNTENT
- dev_t dev = s.st_dev;
- FILE *fd = setmntent("/proc/mounts", "r");
- if (!fd) {
- return "";
+ if (!cursor_theme) {
+ print_verbose("XcursorGetTheme could not get cursor theme");
+ cursor_theme = "default";
}
- struct mntent mnt;
- char buf[1024];
- size_t buflen = 1024;
- while (getmntent_r(fd, &mnt, buf, buflen)) {
- if (!stat(mnt.mnt_dir, &s) && s.st_dev == dev) {
- endmntent(fd);
- return String(mnt.mnt_dir);
- }
+ for (int i = 0; i < CURSOR_MAX; i++) {
+
+ cursors[i] = None;
+ img[i] = NULL;
}
- endmntent(fd);
-#endif
- return "";
-}
+ current_cursor = CURSOR_ARROW;
-Error OS_X11::move_to_trash(const String &p_path) {
- String trash_can = "";
- String mnt = get_mountpoint(p_path);
+ for (int i = 0; i < CURSOR_MAX; i++) {
- // If there is a directory "[Mountpoint]/.Trash-[UID]/files", use it as the trash can.
- if (mnt != "") {
- String path(mnt + "/.Trash-" + itos(getuid()) + "/files");
- struct stat s;
- if (!stat(path.utf8().get_data(), &s)) {
- trash_can = path;
- }
- }
+ static const char *cursor_file[] = {
+ "left_ptr",
+ "xterm",
+ "hand2",
+ "cross",
+ "watch",
+ "left_ptr_watch",
+ "fleur",
+ "dnd-move",
+ "crossed_circle",
+ "v_double_arrow",
+ "h_double_arrow",
+ "size_bdiag",
+ "size_fdiag",
+ "move",
+ "row_resize",
+ "col_resize",
+ "question_arrow"
+ };
- // Otherwise, if ${XDG_DATA_HOME} is defined, use "${XDG_DATA_HOME}/Trash/files" as the trash can.
- if (trash_can == "") {
- char *dhome = getenv("XDG_DATA_HOME");
- if (dhome) {
- trash_can = String(dhome) + "/Trash/files";
- }
- }
+ img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size);
+ if (!img[i]) {
+ const char *fallback = NULL;
- // Otherwise, if ${HOME} is defined, use "${HOME}/.local/share/Trash/files" as the trash can.
- if (trash_can == "") {
- char *home = getenv("HOME");
- if (home) {
- trash_can = String(home) + "/.local/share/Trash/files";
+ switch (i) {
+ case CURSOR_POINTING_HAND:
+ fallback = "pointer";
+ break;
+ case CURSOR_CROSS:
+ fallback = "crosshair";
+ break;
+ case CURSOR_WAIT:
+ fallback = "wait";
+ break;
+ case CURSOR_BUSY:
+ fallback = "progress";
+ break;
+ case CURSOR_DRAG:
+ fallback = "grabbing";
+ break;
+ case CURSOR_CAN_DROP:
+ fallback = "hand1";
+ break;
+ case CURSOR_FORBIDDEN:
+ fallback = "forbidden";
+ break;
+ case CURSOR_VSIZE:
+ fallback = "ns-resize";
+ break;
+ case CURSOR_HSIZE:
+ fallback = "ew-resize";
+ break;
+ case CURSOR_BDIAGSIZE:
+ fallback = "fd_double_arrow";
+ break;
+ case CURSOR_FDIAGSIZE:
+ fallback = "bd_double_arrow";
+ break;
+ case CURSOR_MOVE:
+ img[i] = img[CURSOR_DRAG];
+ break;
+ case CURSOR_VSPLIT:
+ fallback = "sb_v_double_arrow";
+ break;
+ case CURSOR_HSPLIT:
+ fallback = "sb_h_double_arrow";
+ break;
+ case CURSOR_HELP:
+ fallback = "help";
+ break;
+ }
+ if (fallback != NULL) {
+ img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size);
+ }
+ }
+ if (img[i]) {
+ cursors[i] = XcursorImageLoadCursor(x11_display, img[i]);
+ } else {
+ print_verbose("Failed loading custom cursor: " + String(cursor_file[i]));
}
}
- // Issue an error if none of the previous locations is appropriate for the trash can.
- if (trash_can == "") {
- ERR_PRINT("move_to_trash: Could not determine the trash can location");
- return FAILED;
- }
+ {
+ // Creating an empty/transparent cursor
- // Create needed directories for decided trash can location.
- DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- Error err = dir_access->make_dir_recursive(trash_can);
- memdelete(dir_access);
+ // Create 1x1 bitmap
+ Pixmap cursormask = XCreatePixmap(x11_display,
+ RootWindow(x11_display, DefaultScreen(x11_display)), 1, 1, 1);
- // Issue an error if trash can is not created proprely.
- if (err != OK) {
- ERR_PRINT("move_to_trash: Could not create the trash can \"" + trash_can + "\"");
- return err;
- }
+ // Fill with zero
+ XGCValues xgc;
+ xgc.function = GXclear;
+ GC gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc);
+ XFillRectangle(x11_display, cursormask, gc, 0, 0, 1, 1);
- // The trash can is successfully created, now move the given resource to it.
- // Do not use DirAccess:rename() because it can't move files across multiple mountpoints.
- List<String> mv_args;
- mv_args.push_back(p_path);
- mv_args.push_back(trash_can);
- int retval;
- err = execute("mv", mv_args, true, NULL, NULL, &retval);
+ // Color value doesn't matter. Mask zero means no foreground or background will be drawn
+ XColor col = {};
- // Issue an error if "mv" failed to move the given resource to the trash can.
- if (err != OK || retval != 0) {
- ERR_PRINT("move_to_trash: Could not move the resource \"" + p_path + "\" to the trash can \"" + trash_can + "\"");
- return FAILED;
- }
+ Cursor cursor = XCreatePixmapCursor(x11_display,
+ cursormask, // source (using cursor mask as placeholder, since it'll all be ignored)
+ cursormask, // mask
+ &col, &col, 0, 0);
- return OK;
-}
+ XFreePixmap(x11_display, cursormask);
+ XFreeGC(x11_display, gc);
-OS::LatinKeyboardVariant OS_X11::get_latin_keyboard_variant() const {
+ if (cursor == None) {
+ ERR_PRINT("FAILED CREATING CURSOR");
+ }
- XkbDescRec *xkbdesc = XkbAllocKeyboard();
- ERR_FAIL_COND_V(!xkbdesc, LATIN_KEYBOARD_QWERTY);
+ null_cursor = cursor;
+ }
+ cursor_set_shape(CURSOR_BUSY);
- XkbGetNames(x11_display, XkbSymbolsNameMask, xkbdesc);
- ERR_FAIL_COND_V(!xkbdesc->names, LATIN_KEYBOARD_QWERTY);
- ERR_FAIL_COND_V(!xkbdesc->names->symbols, LATIN_KEYBOARD_QWERTY);
+ requested = None;
- char *layout = XGetAtomName(x11_display, xkbdesc->names->symbols);
- ERR_FAIL_COND_V(!layout, LATIN_KEYBOARD_QWERTY);
+ window_has_focus = true; // Set focus to true at init
- Vector<String> info = String(layout).split("+");
- ERR_FAIL_INDEX_V(1, info.size(), LATIN_KEYBOARD_QWERTY);
+ /*if (p_desired.layered) {
+ set_window_per_pixel_transparency_enabled(true);
+ }*/
- if (info[1].find("colemak") != -1) {
- return LATIN_KEYBOARD_COLEMAK;
- } else if (info[1].find("qwertz") != -1) {
- return LATIN_KEYBOARD_QWERTZ;
- } else if (info[1].find("azerty") != -1) {
- return LATIN_KEYBOARD_AZERTY;
- } else if (info[1].find("qzerty") != -1) {
- return LATIN_KEYBOARD_QZERTY;
- } else if (info[1].find("dvorak") != -1) {
- return LATIN_KEYBOARD_DVORAK;
- } else if (info[1].find("neo") != -1) {
- return LATIN_KEYBOARD_NEO;
+ XEvent xevent;
+ while (XPending(x11_display) > 0) {
+ XNextEvent(x11_display, &xevent);
+ if (xevent.type == ConfigureNotify) {
+ _window_changed(&xevent);
+ }
}
- return LATIN_KEYBOARD_QWERTY;
+ _update_real_mouse_position(windows[MAIN_WINDOW_ID]);
+
+ r_error = OK;
}
+DisplayServerX11::~DisplayServerX11() {
-void OS_X11::update_real_mouse_position() {
- Window root_return, child_return;
- int root_x, root_y, win_x, win_y;
- unsigned int mask_return;
+ //destroy all windows
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+#ifdef VULKAN_ENABLED
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_destroy(E->key());
+ }
+#endif
- Bool xquerypointer_result = XQueryPointer(x11_display, x11_window, &root_return, &child_return, &root_x, &root_y,
- &win_x, &win_y, &mask_return);
+ if (E->get().xic) {
+ XDestroyIC(E->get().xic);
+ }
+ XUnmapWindow(x11_display, E->get().x11_window);
+ XDestroyWindow(x11_display, E->get().x11_window);
+ }
- if (xquerypointer_result) {
- if (win_x > 0 && win_y > 0 && win_x <= current_videomode.width && win_y <= current_videomode.height) {
+ //destroy drivers
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
- last_mouse_pos.x = win_x;
- last_mouse_pos.y = win_y;
- last_mouse_pos_valid = true;
- input->set_mouse_position(last_mouse_pos);
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
}
+
+ if (context_vulkan)
+ memdelete(context_vulkan);
}
-}
+#endif
-OS_X11::OS_X11() {
+ if (xrandr_handle)
+ dlclose(xrandr_handle);
-#ifdef PULSEAUDIO_ENABLED
- AudioDriverManager::add_driver(&driver_pulseaudio);
-#endif
+ for (int i = 0; i < CURSOR_MAX; i++) {
+ if (cursors[i] != None)
+ XFreeCursor(x11_display, cursors[i]);
+ if (img[i] != NULL)
+ XcursorImageDestroy(img[i]);
+ };
-#ifdef ALSA_ENABLED
- AudioDriverManager::add_driver(&driver_alsa);
-#endif
+ if (xim) {
+ XCloseIM(xim);
+ }
- xi.opcode = 0;
- xi.last_relative_time = 0;
- layered_window = false;
- minimized = false;
- window_focused = true;
- xim_style = 0L;
- mouse_mode = MOUSE_MODE_VISIBLE;
- last_position_before_fs = Vector2();
+ XCloseDisplay(x11_display);
+ if (xmbstring)
+ memfree(xmbstring);
}
+
+void DisplayServerX11::register_x11_driver() {
+
+ register_create_function("x11", create_func, get_rendering_drivers_func);
+}
+
+#endif // X11 enabled
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
new file mode 100644
index 0000000000..aa10be555c
--- /dev/null
+++ b/platform/linuxbsd/display_server_x11.h
@@ -0,0 +1,352 @@
+/*************************************************************************/
+/* display_server_x11.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef DISPLAY_SERVER_X11_H
+#define DISPLAY_SERVER_X11_H
+
+#ifdef X11_ENABLED
+
+#include "servers/display_server.h"
+
+#include "core/input/input_filter.h"
+
+#include "drivers/alsa/audio_driver_alsa.h"
+#include "drivers/alsamidi/midi_driver_alsamidi.h"
+#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
+#include "drivers/unix/os_unix.h"
+#include "joypad_linux.h"
+#include "servers/audio_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
+
+#if defined(OPENGL_ENABLED)
+#include "context_gl_x11.h"
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "drivers/vulkan/rendering_device_vulkan.h"
+#include "platform/linuxbsd/vulkan_context_x11.h"
+#endif
+
+#include <X11/Xcursor/Xcursor.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XInput2.h>
+#include <X11/extensions/Xrandr.h>
+#include <X11/keysym.h>
+
+// Hints for X11 fullscreen
+typedef struct {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+ long inputMode;
+ unsigned long status;
+} Hints;
+
+typedef struct _xrr_monitor_info {
+ Atom name;
+ Bool primary;
+ Bool automatic;
+ int noutput;
+ int x;
+ int y;
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+ RROutput *outputs;
+} xrr_monitor_info;
+
+#undef CursorShape
+
+class DisplayServerX11 : public DisplayServer {
+ //No need to register, it's platform-specific and nothing is added
+ //GDCLASS(DisplayServerX11, DisplayServer)
+
+ _THREAD_SAFE_CLASS_
+
+ Atom wm_delete;
+ Atom xdnd_enter;
+ Atom xdnd_position;
+ Atom xdnd_status;
+ Atom xdnd_action_copy;
+ Atom xdnd_drop;
+ Atom xdnd_finished;
+ Atom xdnd_selection;
+ Atom xdnd_aware;
+ Atom requested;
+ int xdnd_version;
+
+#if defined(OPENGL_ENABLED)
+ ContextGL_X11 *context_gles2;
+#endif
+#if defined(VULKAN_ENABLED)
+ VulkanContextX11 *context_vulkan;
+ RenderingDeviceVulkan *rendering_device_vulkan;
+#endif
+
+ struct WindowData {
+ Window x11_window;
+ ::XIC xic;
+
+ Size2i min_size;
+ Size2i max_size;
+ Point2i position;
+ Size2i size;
+ Point2i im_position;
+ bool im_active = false;
+ Callable rect_changed_callback;
+ Callable event_callback;
+ Callable input_event_callback;
+ Callable input_text_callback;
+ Callable drop_files_callback;
+
+ WindowID transient_parent = INVALID_WINDOW_ID;
+ Set<WindowID> transient_children;
+
+ ObjectID instance_id;
+
+ //better to guess on the fly, given WM can change it
+ //WindowMode mode;
+ bool fullscreen = false; //OS can't exit from this mode
+ bool on_top = false;
+ bool borderless = false;
+ bool resize_disabled = false;
+ Vector2i last_position_before_fs;
+ };
+
+ Map<WindowID, WindowData> windows;
+
+ WindowID window_id_counter = MAIN_WINDOW_ID;
+ WindowID _create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect);
+
+ String internal_clipboard;
+ Window xdnd_source_window;
+ ::Display *x11_display;
+ char *xmbstring;
+ int xmblen;
+ unsigned long last_timestamp;
+ ::Time last_keyrelease_time;
+ ::XIM xim;
+ ::XIMStyle xim_style;
+ static void _xim_destroy_callback(::XIM im, ::XPointer client_data,
+ ::XPointer call_data);
+
+ Point2i last_mouse_pos;
+ bool last_mouse_pos_valid;
+ Point2i last_click_pos;
+ uint64_t last_click_ms;
+ int last_click_button_index;
+ uint32_t last_button_state;
+
+ struct {
+ int opcode;
+ Vector<int> touch_devices;
+ Map<int, Vector2> absolute_devices;
+ Map<int, Vector3> pen_devices;
+ XIEventMask all_event_mask;
+ Map<int, Vector2> state;
+ double pressure;
+ Vector2 tilt;
+ Vector2 mouse_pos_to_filter;
+ Vector2 relative_motion;
+ Vector2 raw_pos;
+ Vector2 old_raw_pos;
+ ::Time last_relative_time;
+ } xi;
+
+ bool _refresh_device_info();
+
+ unsigned int _get_mouse_button_state(unsigned int p_x11_button, int p_x11_type);
+ void _get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
+ void _flush_mouse_motion();
+
+ MouseMode mouse_mode;
+ Point2i center;
+
+ void _handle_key_event(WindowID p_window, XKeyEvent *p_event, bool p_echo = false);
+
+ bool force_quit;
+ bool minimized;
+ bool window_has_focus;
+ bool do_mouse_warp;
+
+ const char *cursor_theme;
+ int cursor_size;
+ XcursorImage *img[CURSOR_MAX];
+ Cursor cursors[CURSOR_MAX];
+ Cursor null_cursor;
+ CursorShape current_cursor;
+ Map<CursorShape, Vector<Variant>> cursors_cache;
+
+ bool layered_window;
+
+ String rendering_driver;
+ bool window_focused;
+ //void set_wm_border(bool p_enabled);
+ void set_wm_fullscreen(bool p_enabled);
+ void set_wm_above(bool p_enabled);
+
+ typedef xrr_monitor_info *(*xrr_get_monitors_t)(Display *dpy, Window window, Bool get_active, int *nmonitors);
+ typedef void (*xrr_free_monitors_t)(xrr_monitor_info *monitors);
+ xrr_get_monitors_t xrr_get_monitors;
+ xrr_free_monitors_t xrr_free_monitors;
+ void *xrandr_handle;
+ Bool xrandr_ext_ok;
+
+ struct Property {
+ unsigned char *data;
+ int format, nitems;
+ Atom type;
+ };
+ static Property _read_property(Display *p_display, Window p_window, Atom p_property);
+
+ void _update_real_mouse_position(const WindowData &wd);
+ void _set_wm_fullscreen(WindowID p_window, bool p_enabled);
+ void _set_wm_maximized(WindowID p_window, bool p_enabled);
+
+ void _update_context(WindowData &wd);
+
+ Context context = CONTEXT_ENGINE;
+
+ void _send_window_event(const WindowData &wd, WindowEvent p_event);
+ static void _dispatch_input_events(const Ref<InputEvent> &p_event);
+ void _dispatch_input_event(const Ref<InputEvent> &p_event);
+
+protected:
+ void _window_changed(XEvent *event);
+
+public:
+ virtual bool has_feature(Feature p_feature) const;
+ virtual String get_name() const;
+
+ virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+
+ virtual void mouse_set_mode(MouseMode p_mode);
+ virtual MouseMode mouse_get_mode() const;
+
+ virtual void mouse_warp_to_position(const Point2i &p_to);
+ virtual Point2i mouse_get_position() const;
+ virtual Point2i mouse_get_absolute_position() const;
+ virtual int mouse_get_button_state() const;
+
+ virtual void clipboard_set(const String &p_text);
+ virtual String clipboard_get() const;
+
+ virtual int get_screen_count() const;
+ virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+
+ virtual Vector<DisplayServer::WindowID> get_window_list() const;
+
+ virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i());
+ virtual void delete_sub_window(WindowID p_id);
+
+ virtual WindowID get_window_at_screen_position(const Point2i &p_position) const;
+
+ virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID);
+ virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_transient(WindowID p_window, WindowID p_parent);
+
+ virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
+ virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
+ virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual bool can_any_window_draw() const;
+
+ virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void cursor_set_shape(CursorShape p_shape);
+ virtual CursorShape cursor_get_shape() const;
+ virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
+
+ virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+
+ virtual void process_events();
+
+ virtual void release_rendering_thread();
+ virtual void make_rendering_thread();
+ virtual void swap_buffers();
+
+ virtual void set_context(Context p_context);
+
+ virtual void set_native_icon(const String &p_filename);
+ virtual void set_icon(const Ref<Image> &p_icon);
+
+ static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+ static Vector<String> get_rendering_drivers_func();
+
+ static void register_x11_driver();
+
+ DisplayServerX11(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+ ~DisplayServerX11();
+};
+
+#endif // X11 enabled
+
+#endif // DISPLAY_SERVER_X11_H
diff --git a/platform/x11/export/export.cpp b/platform/linuxbsd/export/export.cpp
index 1c0c6ec096..53e3ce8f85 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/linuxbsd/export/export.cpp
@@ -32,17 +32,17 @@
#include "core/os/file_access.h"
#include "editor/editor_export.h"
-#include "platform/x11/logo.gen.h"
+#include "platform/linuxbsd/logo.gen.h"
#include "scene/resources/texture.h"
static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size);
-void register_x11_exporter() {
+void register_linuxbsd_exporter() {
Ref<EditorExportPlatformPC> platform;
platform.instance();
- Ref<Image> img = memnew(Image(_x11_logo));
+ Ref<Image> img = memnew(Image(_linuxbsd_logo));
Ref<ImageTexture> logo;
logo.instance();
logo->create_from_image(img);
diff --git a/platform/x11/export/export.h b/platform/linuxbsd/export/export.h
index d94ea114a8..5ee81f485e 100644
--- a/platform/x11/export/export.h
+++ b/platform/linuxbsd/export/export.h
@@ -28,4 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-void register_x11_exporter();
+#ifndef LINUXBSD_EXPORT_H
+#define LINUXBSD_EXPORT_H
+
+void register_linuxbsd_exporter();
+
+#endif // LINUXBSD_EXPORT_H
diff --git a/platform/x11/godot_x11.cpp b/platform/linuxbsd/godot_linuxbsd.cpp
index 77b74184ad..710ba3ca40 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/linuxbsd/godot_linuxbsd.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_x11.cpp */
+/* godot_linuxbsd.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,11 +34,11 @@
#include <unistd.h>
#include "main/main.h"
-#include "os_x11.h"
+#include "os_linuxbsd.h"
int main(int argc, char *argv[]) {
- OS_X11 os;
+ OS_LinuxBSD os;
setlocale(LC_CTYPE, "");
diff --git a/platform/x11/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index a9fe7275c2..c4c793093d 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -71,7 +71,7 @@ void JoypadLinux::Joypad::reset() {
dpad = 0;
fd = -1;
- InputDefault::JoyAxis jx;
+ InputFilter::JoyAxis jx;
jx.min = -1;
jx.value = 0.0f;
for (int i = 0; i < MAX_ABS; i++) {
@@ -80,7 +80,7 @@ void JoypadLinux::Joypad::reset() {
}
}
-JoypadLinux::JoypadLinux(InputDefault *in) {
+JoypadLinux::JoypadLinux(InputFilter *in) {
exit_udev = false;
input = in;
joy_thread = Thread::create(joy_thread_func, this);
@@ -340,7 +340,10 @@ void JoypadLinux::open_joypad(const char *p_path) {
(test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit) || test_bit(ABS_HAT0X, absbit) ||
test_bit(ABS_GAS, absbit) || test_bit(ABS_RUDDER, absbit)) &&
(test_bit(BTN_A, keybit) || test_bit(BTN_THUMBL, keybit) ||
- test_bit(BTN_TRIGGER, keybit) || test_bit(BTN_1, keybit)))) {
+ test_bit(BTN_TRIGGER, keybit) || test_bit(BTN_1, keybit))) &&
+ !(test_bit(EV_ABS, evbit) &&
+ test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) &&
+ test_bit(ABS_RX, absbit) && test_bit(ABS_RY, absbit))) {
close(fd);
return;
}
@@ -433,11 +436,11 @@ void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
joy.ff_effect_timestamp = p_timestamp;
}
-InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
+InputFilter::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
int min = p_abs->minimum;
int max = p_abs->maximum;
- InputDefault::JoyAxis jx;
+ InputFilter::JoyAxis jx;
if (min < 0) {
jx.min = -1;
@@ -489,11 +492,11 @@ void JoypadLinux::process_joypads() {
case ABS_HAT0X:
if (ev.value != 0) {
if (ev.value < 0)
- joy->dpad |= InputDefault::HAT_MASK_LEFT;
+ joy->dpad |= InputFilter::HAT_MASK_LEFT;
else
- joy->dpad |= InputDefault::HAT_MASK_RIGHT;
+ joy->dpad |= InputFilter::HAT_MASK_RIGHT;
} else
- joy->dpad &= ~(InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_RIGHT);
+ joy->dpad &= ~(InputFilter::HAT_MASK_LEFT | InputFilter::HAT_MASK_RIGHT);
input->joy_hat(i, joy->dpad);
break;
@@ -501,11 +504,11 @@ void JoypadLinux::process_joypads() {
case ABS_HAT0Y:
if (ev.value != 0) {
if (ev.value < 0)
- joy->dpad |= InputDefault::HAT_MASK_UP;
+ joy->dpad |= InputFilter::HAT_MASK_UP;
else
- joy->dpad |= InputDefault::HAT_MASK_DOWN;
+ joy->dpad |= InputFilter::HAT_MASK_DOWN;
} else
- joy->dpad &= ~(InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_DOWN);
+ joy->dpad &= ~(InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_DOWN);
input->joy_hat(i, joy->dpad);
break;
@@ -514,7 +517,7 @@ void JoypadLinux::process_joypads() {
if (ev.code >= MAX_ABS)
return;
if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) {
- InputDefault::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value);
+ InputFilter::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value);
joy->curr_axis[joy->abs_map[ev.code]] = value;
}
break;
diff --git a/platform/x11/joypad_linux.h b/platform/linuxbsd/joypad_linux.h
index d5719b6dbe..1d2ed5bbc1 100644
--- a/platform/x11/joypad_linux.h
+++ b/platform/linuxbsd/joypad_linux.h
@@ -33,15 +33,15 @@
#define JOYPAD_LINUX_H
#ifdef JOYDEV_ENABLED
+#include "core/input/input_filter.h"
#include "core/os/mutex.h"
#include "core/os/thread.h"
-#include "main/input_default.h"
struct input_absinfo;
class JoypadLinux {
public:
- JoypadLinux(InputDefault *in);
+ JoypadLinux(InputFilter *in);
~JoypadLinux();
void process_joypads();
@@ -53,7 +53,7 @@ private:
};
struct Joypad {
- InputDefault::JoyAxis curr_axis[MAX_ABS];
+ InputFilter::JoyAxis curr_axis[MAX_ABS];
int key_map[MAX_KEY];
int abs_map[MAX_ABS];
int dpad;
@@ -74,7 +74,7 @@ private:
bool exit_udev;
Mutex joy_mutex;
Thread *joy_thread;
- InputDefault *input;
+ InputFilter *input;
Joypad joypads[JOYPADS_MAX];
Vector<String> attached_devices;
@@ -95,7 +95,7 @@ private:
void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop(int p_id, uint64_t p_timestamp);
- InputDefault::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const;
+ InputFilter::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const;
};
#endif
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/linuxbsd/key_mapping_x11.cpp
index 78bd2b71a0..78bd2b71a0 100644
--- a/platform/x11/key_mapping_x11.cpp
+++ b/platform/linuxbsd/key_mapping_x11.cpp
diff --git a/platform/x11/key_mapping_x11.h b/platform/linuxbsd/key_mapping_x11.h
index 10db43bcc4..10db43bcc4 100644
--- a/platform/x11/key_mapping_x11.h
+++ b/platform/linuxbsd/key_mapping_x11.h
diff --git a/platform/x11/logo.png b/platform/linuxbsd/logo.png
index 078654b757..078654b757 100644
--- a/platform/x11/logo.png
+++ b/platform/linuxbsd/logo.png
Binary files differ
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
new file mode 100644
index 0000000000..084453bdc6
--- /dev/null
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -0,0 +1,381 @@
+/*************************************************************************/
+/* os_linuxbsd.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "os_linuxbsd.h"
+
+#include "core/os/dir_access.h"
+#include "core/print_string.h"
+#include "errno.h"
+
+#ifdef HAVE_MNTENT
+#include <mntent.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "main/main.h"
+
+#ifdef X11_ENABLED
+#include "display_server_x11.h"
+#endif
+
+void OS_LinuxBSD::initialize() {
+
+ crash_handler.initialize();
+
+ OS_Unix::initialize_core();
+}
+
+void OS_LinuxBSD::initialize_joypads() {
+
+#ifdef JOYDEV_ENABLED
+ joypad = memnew(JoypadLinux(InputFilter::get_singleton()));
+#endif
+}
+
+String OS_LinuxBSD::get_unique_id() const {
+
+ static String machine_id;
+ if (machine_id.empty()) {
+ if (FileAccess *f = FileAccess::open("/etc/machine-id", FileAccess::READ)) {
+ while (machine_id.empty() && !f->eof_reached()) {
+ machine_id = f->get_line().strip_edges();
+ }
+ f->close();
+ memdelete(f);
+ }
+ }
+ return machine_id;
+}
+
+void OS_LinuxBSD::finalize() {
+
+ if (main_loop)
+ memdelete(main_loop);
+ main_loop = NULL;
+
+#ifdef ALSAMIDI_ENABLED
+ driver_alsamidi.close();
+#endif
+
+#ifdef JOYDEV_ENABLED
+ memdelete(joypad);
+#endif
+}
+
+MainLoop *OS_LinuxBSD::get_main_loop() const {
+
+ return main_loop;
+}
+
+void OS_LinuxBSD::delete_main_loop() {
+
+ if (main_loop)
+ memdelete(main_loop);
+ main_loop = NULL;
+}
+
+void OS_LinuxBSD::set_main_loop(MainLoop *p_main_loop) {
+
+ main_loop = p_main_loop;
+}
+
+String OS_LinuxBSD::get_name() const {
+
+#ifdef __linux__
+ return "Linux";
+#elif defined(__FreeBSD__)
+ return "FreeBSD";
+#elif defined(__NetBSD__)
+ return "NetBSD";
+#else
+ return "BSD";
+#endif
+}
+
+Error OS_LinuxBSD::shell_open(String p_uri) {
+
+ Error ok;
+ List<String> args;
+ args.push_back(p_uri);
+ ok = execute("xdg-open", args, false);
+ if (ok == OK)
+ return OK;
+ ok = execute("gnome-open", args, false);
+ if (ok == OK)
+ return OK;
+ ok = execute("kde-open", args, false);
+ return ok;
+}
+
+bool OS_LinuxBSD::_check_internal_feature_support(const String &p_feature) {
+
+ return p_feature == "pc";
+}
+
+String OS_LinuxBSD::get_config_path() const {
+
+ if (has_environment("XDG_CONFIG_HOME")) {
+ return get_environment("XDG_CONFIG_HOME");
+ } else if (has_environment("HOME")) {
+ return get_environment("HOME").plus_file(".config");
+ } else {
+ return ".";
+ }
+}
+
+String OS_LinuxBSD::get_data_path() const {
+
+ if (has_environment("XDG_DATA_HOME")) {
+ return get_environment("XDG_DATA_HOME");
+ } else if (has_environment("HOME")) {
+ return get_environment("HOME").plus_file(".local/share");
+ } else {
+ return get_config_path();
+ }
+}
+
+String OS_LinuxBSD::get_cache_path() const {
+
+ if (has_environment("XDG_CACHE_HOME")) {
+ return get_environment("XDG_CACHE_HOME");
+ } else if (has_environment("HOME")) {
+ return get_environment("HOME").plus_file(".cache");
+ } else {
+ return get_config_path();
+ }
+}
+
+String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const {
+
+ String xdgparam;
+
+ switch (p_dir) {
+ case SYSTEM_DIR_DESKTOP: {
+
+ xdgparam = "DESKTOP";
+ } break;
+ case SYSTEM_DIR_DCIM: {
+
+ xdgparam = "PICTURES";
+
+ } break;
+ case SYSTEM_DIR_DOCUMENTS: {
+
+ xdgparam = "DOCUMENTS";
+
+ } break;
+ case SYSTEM_DIR_DOWNLOADS: {
+
+ xdgparam = "DOWNLOAD";
+
+ } break;
+ case SYSTEM_DIR_MOVIES: {
+
+ xdgparam = "VIDEOS";
+
+ } break;
+ case SYSTEM_DIR_MUSIC: {
+
+ xdgparam = "MUSIC";
+
+ } break;
+ case SYSTEM_DIR_PICTURES: {
+
+ xdgparam = "PICTURES";
+
+ } break;
+ case SYSTEM_DIR_RINGTONES: {
+
+ xdgparam = "MUSIC";
+
+ } break;
+ }
+
+ String pipe;
+ List<String> arg;
+ arg.push_back(xdgparam);
+ Error err = const_cast<OS_LinuxBSD *>(this)->execute("xdg-user-dir", arg, true, NULL, &pipe);
+ if (err != OK)
+ return ".";
+ return pipe.strip_edges();
+}
+
+void OS_LinuxBSD::run() {
+
+ force_quit = false;
+
+ if (!main_loop)
+ return;
+
+ main_loop->init();
+
+ //uint64_t last_ticks=get_ticks_usec();
+
+ //int frames=0;
+ //uint64_t frame=0;
+
+ while (!force_quit) {
+
+ DisplayServer::get_singleton()->process_events(); // get rid of pending events
+#ifdef JOYDEV_ENABLED
+ joypad->process_joypads();
+#endif
+ if (Main::iteration())
+ break;
+ };
+
+ main_loop->finish();
+}
+
+void OS_LinuxBSD::disable_crash_handler() {
+ crash_handler.disable();
+}
+
+bool OS_LinuxBSD::is_disable_crash_handler() const {
+ return crash_handler.is_disabled();
+}
+
+static String get_mountpoint(const String &p_path) {
+ struct stat s;
+ if (stat(p_path.utf8().get_data(), &s)) {
+ return "";
+ }
+
+#ifdef HAVE_MNTENT
+ dev_t dev = s.st_dev;
+ FILE *fd = setmntent("/proc/mounts", "r");
+ if (!fd) {
+ return "";
+ }
+
+ struct mntent mnt;
+ char buf[1024];
+ size_t buflen = 1024;
+ while (getmntent_r(fd, &mnt, buf, buflen)) {
+ if (!stat(mnt.mnt_dir, &s) && s.st_dev == dev) {
+ endmntent(fd);
+ return String(mnt.mnt_dir);
+ }
+ }
+
+ endmntent(fd);
+#endif
+ return "";
+}
+
+Error OS_LinuxBSD::move_to_trash(const String &p_path) {
+ String trash_can = "";
+ String mnt = get_mountpoint(p_path);
+
+ // If there is a directory "[Mountpoint]/.Trash-[UID]/files", use it as the trash can.
+ if (mnt != "") {
+ String path(mnt + "/.Trash-" + itos(getuid()) + "/files");
+ struct stat s;
+ if (!stat(path.utf8().get_data(), &s)) {
+ trash_can = path;
+ }
+ }
+
+ // Otherwise, if ${XDG_DATA_HOME} is defined, use "${XDG_DATA_HOME}/Trash/files" as the trash can.
+ if (trash_can == "") {
+ char *dhome = getenv("XDG_DATA_HOME");
+ if (dhome) {
+ trash_can = String(dhome) + "/Trash/files";
+ }
+ }
+
+ // Otherwise, if ${HOME} is defined, use "${HOME}/.local/share/Trash/files" as the trash can.
+ if (trash_can == "") {
+ char *home = getenv("HOME");
+ if (home) {
+ trash_can = String(home) + "/.local/share/Trash/files";
+ }
+ }
+
+ // Issue an error if none of the previous locations is appropriate for the trash can.
+ if (trash_can == "") {
+ ERR_PRINT("move_to_trash: Could not determine the trash can location");
+ return FAILED;
+ }
+
+ // Create needed directories for decided trash can location.
+ DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Error err = dir_access->make_dir_recursive(trash_can);
+ memdelete(dir_access);
+
+ // Issue an error if trash can is not created proprely.
+ if (err != OK) {
+ ERR_PRINT("move_to_trash: Could not create the trash can \"" + trash_can + "\"");
+ return err;
+ }
+
+ // The trash can is successfully created, now move the given resource to it.
+ // Do not use DirAccess:rename() because it can't move files across multiple mountpoints.
+ List<String> mv_args;
+ mv_args.push_back(p_path);
+ mv_args.push_back(trash_can);
+ int retval;
+ err = execute("mv", mv_args, true, NULL, NULL, &retval);
+
+ // Issue an error if "mv" failed to move the given resource to the trash can.
+ if (err != OK || retval != 0) {
+ ERR_PRINT("move_to_trash: Could not move the resource \"" + p_path + "\" to the trash can \"" + trash_can + "\"");
+ return FAILED;
+ }
+
+ return OK;
+}
+
+OS_LinuxBSD::OS_LinuxBSD() {
+
+ main_loop = NULL;
+ force_quit = false;
+
+#ifdef PULSEAUDIO_ENABLED
+ AudioDriverManager::add_driver(&driver_pulseaudio);
+#endif
+
+#ifdef ALSA_ENABLED
+ AudioDriverManager::add_driver(&driver_alsa);
+#endif
+
+#ifdef X11_ENABLED
+ DisplayServerX11::register_x11_driver();
+#endif
+}
diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h
new file mode 100644
index 0000000000..100cb53ba3
--- /dev/null
+++ b/platform/linuxbsd/os_linuxbsd.h
@@ -0,0 +1,106 @@
+/*************************************************************************/
+/* os_linuxbsd.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef OS_LINUXBSD_H
+#define OS_LINUXBSD_H
+
+#include "core/input/input_filter.h"
+#include "crash_handler_linuxbsd.h"
+#include "drivers/alsa/audio_driver_alsa.h"
+#include "drivers/alsamidi/midi_driver_alsamidi.h"
+#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
+#include "drivers/unix/os_unix.h"
+#include "joypad_linux.h"
+#include "servers/audio_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
+
+class OS_LinuxBSD : public OS_Unix {
+
+ virtual void delete_main_loop();
+
+ bool force_quit;
+
+#ifdef JOYDEV_ENABLED
+ JoypadLinux *joypad;
+#endif
+
+#ifdef ALSA_ENABLED
+ AudioDriverALSA driver_alsa;
+#endif
+
+#ifdef ALSAMIDI_ENABLED
+ MIDIDriverALSAMidi driver_alsamidi;
+#endif
+
+#ifdef PULSEAUDIO_ENABLED
+ AudioDriverPulseAudio driver_pulseaudio;
+#endif
+
+ CrashHandler crash_handler;
+
+ MainLoop *main_loop;
+
+protected:
+ virtual void initialize();
+ virtual void finalize();
+
+ virtual void initialize_joypads();
+
+ virtual void set_main_loop(MainLoop *p_main_loop);
+
+public:
+ virtual String get_name() const;
+
+ virtual MainLoop *get_main_loop() const;
+
+ virtual String get_config_path() const;
+ virtual String get_data_path() const;
+ virtual String get_cache_path() const;
+
+ virtual String get_system_dir(SystemDir p_dir) const;
+
+ virtual Error shell_open(String p_uri);
+
+ virtual String get_unique_id() const;
+
+ virtual bool _check_internal_feature_support(const String &p_feature);
+
+ void run();
+
+ void disable_crash_handler();
+ bool is_disable_crash_handler() const;
+
+ virtual Error move_to_trash(const String &p_path);
+
+ OS_LinuxBSD();
+};
+
+#endif
diff --git a/platform/x11/pck_embed.ld b/platform/linuxbsd/pck_embed.ld
index 57a1994043..57a1994043 100644
--- a/platform/x11/pck_embed.ld
+++ b/platform/linuxbsd/pck_embed.ld
diff --git a/platform/x11/pck_embed.legacy.ld b/platform/linuxbsd/pck_embed.legacy.ld
index a23013ba7a..a23013ba7a 100644
--- a/platform/x11/pck_embed.legacy.ld
+++ b/platform/linuxbsd/pck_embed.legacy.ld
diff --git a/platform/x11/platform_config.h b/platform/linuxbsd/platform_config.h
index ac30519132..ac30519132 100644
--- a/platform/x11/platform_config.h
+++ b/platform/linuxbsd/platform_config.h
diff --git a/platform/x11/platform_x11_builders.py b/platform/linuxbsd/platform_linuxbsd_builders.py
index 5ff0c6fb14..a72306a9c0 100644
--- a/platform/x11/platform_x11_builders.py
+++ b/platform/linuxbsd/platform_linuxbsd_builders.py
@@ -7,7 +7,7 @@ import os
from platform_methods import subprocess_main
-def make_debug_x11(target, source, env):
+def make_debug_linuxbsd(target, source, env):
os.system('objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0]))
os.system('strip --strip-debug --strip-unneeded {0}'.format(target[0]))
os.system('objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0]))
diff --git a/platform/x11/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp
index 602dbc77a2..d0e1b1678c 100644
--- a/platform/x11/vulkan_context_x11.cpp
+++ b/platform/linuxbsd/vulkan_context_x11.cpp
@@ -35,7 +35,7 @@ const char *VulkanContextX11::_get_platform_surface_extension() const {
return VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
}
-int VulkanContextX11::window_create(::Window p_window, Display *p_display, int p_width, int p_height) {
+Error VulkanContextX11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) {
VkXlibSurfaceCreateInfoKHR createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
@@ -46,8 +46,8 @@ int VulkanContextX11::window_create(::Window p_window, Display *p_display, int p
VkSurfaceKHR surface;
VkResult err = vkCreateXlibSurfaceKHR(_get_instance(), &createInfo, NULL, &surface);
- ERR_FAIL_COND_V(err, -1);
- return _window_create(surface, p_width, p_height);
+ ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
+ return _window_create(p_window_id, surface, p_width, p_height);
}
VulkanContextX11::VulkanContextX11() {
diff --git a/platform/x11/vulkan_context_x11.h b/platform/linuxbsd/vulkan_context_x11.h
index 573f994ea6..6e144ab2d9 100644
--- a/platform/x11/vulkan_context_x11.h
+++ b/platform/linuxbsd/vulkan_context_x11.h
@@ -39,7 +39,7 @@ class VulkanContextX11 : public VulkanContext {
virtual const char *_get_platform_surface_extension() const;
public:
- int window_create(::Window p_window, Display *p_display, int p_width, int p_height);
+ Error window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height);
VulkanContextX11();
~VulkanContextX11();
diff --git a/platform/osx/SCsub b/platform/osx/SCsub
index 0a4e0a45e1..4ec8aeab6d 100644
--- a/platform/osx/SCsub
+++ b/platform/osx/SCsub
@@ -8,6 +8,7 @@ import platform_osx_builders
files = [
'crash_handler_osx.mm',
'os_osx.mm',
+ 'display_server_osx.mm',
'godot_main_osx.mm',
'dir_access_osx.mm',
'joypad_osx.cpp',
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
new file mode 100644
index 0000000000..33f483bd0e
--- /dev/null
+++ b/platform/osx/display_server_osx.h
@@ -0,0 +1,308 @@
+/*************************************************************************/
+/* display_server_osx.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef DISPLAY_SERVER_OSX_H
+#define DISPLAY_SERVER_OSX_H
+
+#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
+
+#include "core/input/input_filter.h"
+#include "servers/display_server.h"
+
+#if defined(OPENGL_ENABLED)
+#include "context_gl_osx.h"
+//TODO - reimplement OpenGLES
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "drivers/vulkan/rendering_device_vulkan.h"
+#include "platform/osx/vulkan_context_osx.h"
+#endif
+
+#include <AppKit/AppKit.h>
+#include <AppKit/NSCursor.h>
+#include <ApplicationServices/ApplicationServices.h>
+#include <CoreVideo/CoreVideo.h>
+
+#undef BitMap
+#undef CursorShape
+
+class DisplayServerOSX : public DisplayServer {
+ GDCLASS(DisplayServerOSX, DisplayServer)
+
+ _THREAD_SAFE_CLASS_
+
+public:
+#if defined(OPENGL_ENABLED)
+ ContextGL_OSX *context_gles2;
+#endif
+#if defined(VULKAN_ENABLED)
+ VulkanContextOSX *context_vulkan;
+ RenderingDeviceVulkan *rendering_device_vulkan;
+#endif
+
+ const NSMenu *_get_menu_root(const String &p_menu_root) const;
+ NSMenu *_get_menu_root(const String &p_menu_root);
+
+ NSMenu *apple_menu = NULL;
+ NSMenu *dock_menu = NULL;
+ Map<String, NSMenu *> submenu;
+
+ struct KeyEvent {
+ WindowID window_id;
+ unsigned int osx_state;
+ bool pressed;
+ bool echo;
+ bool raw;
+ uint32_t keycode;
+ uint32_t physical_keycode;
+ uint32_t unicode;
+ };
+
+ Vector<KeyEvent> key_event_buffer;
+ int key_event_pos;
+
+ struct WindowData {
+ id window_delegate;
+ id window_object;
+ id window_view;
+
+#if defined(OPENGL_ENABLED)
+ ContextGL_OSX *context_gles2 = NULL;
+#endif
+ Point2i mouse_pos;
+
+ Size2i min_size;
+ Size2i max_size;
+ Size2i size;
+
+ bool mouse_down_control = false;
+
+ bool im_active = false;
+ Size2i im_position;
+
+ Callable rect_changed_callback;
+ Callable event_callback;
+ Callable input_event_callback;
+ Callable input_text_callback;
+ Callable drop_files_callback;
+
+ ObjectID instance_id;
+
+ WindowID transient_parent = INVALID_WINDOW_ID;
+ Set<WindowID> transient_children;
+
+ bool layered_window = false;
+ bool fullscreen = false;
+ bool on_top = false;
+ bool borderless = false;
+ bool resize_disabled = false;
+ };
+
+ Point2i im_selection;
+ String im_text;
+
+ Map<WindowID, WindowData> windows;
+
+ WindowID window_id_counter = MAIN_WINDOW_ID;
+
+ WindowID _create_window(WindowMode p_mode, const Rect2i &p_rect);
+ void _update_window(WindowData p_wd);
+ void _send_window_event(const WindowData &wd, WindowEvent p_event);
+ static void _dispatch_input_events(const Ref<InputEvent> &p_event);
+ void _dispatch_input_event(const Ref<InputEvent> &p_event);
+ WindowID _find_window_id(id p_window);
+
+ void _set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window);
+
+ float _display_scale(id screen) const;
+ Point2i _get_screens_origin() const;
+ Point2i _get_native_screen_position(int p_screen) const;
+
+ void _push_input(const Ref<InputEvent> &p_event);
+ void _process_key_events();
+ void _release_pressed_events();
+
+ String rendering_driver;
+
+ id delegate;
+ id autoreleasePool;
+ CGEventSourceRef eventSource;
+
+ CursorShape cursor_shape;
+ NSCursor *cursors[CURSOR_MAX];
+ Map<CursorShape, Vector<Variant>> cursors_cache;
+
+ MouseMode mouse_mode;
+ Point2i last_mouse_pos;
+ uint32_t last_button_state;
+
+ bool window_focused;
+ bool drop_events;
+ bool in_dispatch_input_event = false;
+
+public:
+ virtual bool has_feature(Feature p_feature) const;
+ virtual String get_name() const;
+
+ virtual void global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
+ virtual void global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
+ virtual void global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu);
+ virtual void global_menu_add_separator(const String &p_menu_root);
+
+ virtual bool global_menu_is_item_checked(const String &p_menu_root, int p_idx) const;
+ virtual bool global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const;
+ virtual Callable global_menu_get_item_callback(const String &p_menu_root, int p_idx);
+ virtual Variant global_menu_get_item_tag(const String &p_menu_root, int p_idx);
+ virtual String global_menu_get_item_text(const String &p_menu_root, int p_idx);
+ virtual String global_menu_get_item_submenu(const String &p_menu_root, int p_idx);
+
+ virtual void global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked);
+ virtual void global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable);
+ virtual void global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback);
+ virtual void global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag);
+ virtual void global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text);
+ virtual void global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu);
+
+ virtual int global_menu_get_item_count(const String &p_menu_root) const;
+
+ virtual void global_menu_remove_item(const String &p_menu_root, int p_idx);
+ virtual void global_menu_clear(const String &p_menu_root);
+
+ virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+ virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback);
+ virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback);
+
+ virtual void mouse_set_mode(MouseMode p_mode);
+ virtual MouseMode mouse_get_mode() const;
+
+ virtual void mouse_warp_to_position(const Point2i &p_to);
+ virtual Point2i mouse_get_position() const;
+ virtual Point2i mouse_get_absolute_position() const;
+ virtual int mouse_get_button_state() const;
+
+ virtual void clipboard_set(const String &p_text);
+ virtual String clipboard_get() const;
+
+ virtual int get_screen_count() const;
+ virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+
+ virtual Vector<int> get_window_list() const;
+
+ virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i & = Rect2i());
+ virtual void delete_sub_window(WindowID p_id);
+
+ virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_transient(WindowID p_window, WindowID p_parent);
+
+ virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
+ virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
+ virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual bool can_any_window_draw() const;
+
+ virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual WindowID get_window_at_screen_position(const Point2i &p_position) const;
+
+ virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID);
+ virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual Point2i ime_get_selection() const;
+ virtual String ime_get_text() const;
+
+ virtual void cursor_set_shape(CursorShape p_shape);
+ virtual CursorShape cursor_get_shape() const;
+ virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
+
+ virtual bool get_swap_ok_cancel();
+
+ virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+
+ virtual void process_events();
+ virtual void force_process_and_drop_events();
+
+ virtual void release_rendering_thread();
+ virtual void make_rendering_thread();
+ virtual void swap_buffers();
+
+ virtual void set_native_icon(const String &p_filename);
+ virtual void set_icon(const Ref<Image> &p_icon);
+
+ virtual void console_set_visible(bool p_enabled);
+ virtual bool is_console_visible() const;
+
+ static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+ static Vector<String> get_rendering_drivers_func();
+
+ static void register_osx_driver();
+
+ DisplayServerOSX(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+ ~DisplayServerOSX();
+};
+
+#endif // DISPLAY_SERVER_OSX_H
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
new file mode 100644
index 0000000000..074fc3be0d
--- /dev/null
+++ b/platform/osx/display_server_osx.mm
@@ -0,0 +1,3595 @@
+/*************************************************************************/
+/* display_server_osx.mm */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "display_server_osx.h"
+
+#include "os_osx.h"
+
+#include "core/io/marshalls.h"
+#include "core/os/keyboard.h"
+#include "main/main.h"
+#include "scene/resources/texture.h"
+
+#include <Carbon/Carbon.h>
+#include <Cocoa/Cocoa.h>
+#include <IOKit/IOCFPlugIn.h>
+#include <IOKit/IOKitLib.h>
+#include <IOKit/hid/IOHIDKeys.h>
+#include <IOKit/hid/IOHIDLib.h>
+
+#if defined(OPENGL_ENABLED)
+#include "drivers/gles2/rasterizer_gles2.h"
+//TODO - reimplement OpenGLES
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "servers/rendering/rasterizer_rd/rasterizer_rd.h"
+
+#include <QuartzCore/CAMetalLayer.h>
+#endif
+
+#define DS_OSX ((DisplayServerOSX *)(DisplayServerOSX::get_singleton()))
+
+static void _get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> r_state) {
+ r_state->set_shift((p_osx_state & NSEventModifierFlagShift));
+ r_state->set_control((p_osx_state & NSEventModifierFlagControl));
+ r_state->set_alt((p_osx_state & NSEventModifierFlagOption));
+ r_state->set_metakey((p_osx_state & NSEventModifierFlagCommand));
+}
+
+static Vector2i _get_mouse_pos(DisplayServerOSX::WindowData &p_wd, NSPoint p_locationInWindow, CGFloat p_backingScaleFactor) {
+ const NSRect contentRect = [p_wd.window_view frame];
+ const NSPoint p = p_locationInWindow;
+ p_wd.mouse_pos.x = p.x * p_backingScaleFactor;
+ p_wd.mouse_pos.y = (contentRect.size.height - p.y) * p_backingScaleFactor;
+ DS_OSX->last_mouse_pos = p_wd.mouse_pos;
+ InputFilter::get_singleton()->set_mouse_position(p_wd.mouse_pos);
+ return p_wd.mouse_pos;
+}
+
+static void _push_to_key_event_buffer(const DisplayServerOSX::KeyEvent &p_event) {
+ Vector<DisplayServerOSX::KeyEvent> &buffer = DS_OSX->key_event_buffer;
+ if (DS_OSX->key_event_pos >= buffer.size()) {
+ buffer.resize(1 + DS_OSX->key_event_pos);
+ }
+ buffer.write[DS_OSX->key_event_pos++] = p_event;
+}
+
+static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
+ if ([NSCursor respondsToSelector:selector]) {
+ id object = [NSCursor performSelector:selector];
+ if ([object isKindOfClass:[NSCursor class]]) {
+ return object;
+ }
+ }
+ if (fallback) {
+ // Fallback should be a reasonable default, no need to check.
+ return [NSCursor performSelector:fallback];
+ }
+ return [NSCursor arrowCursor];
+}
+
+/*************************************************************************/
+/* GodotApplication */
+/*************************************************************************/
+
+@interface GodotApplication : NSApplication
+@end
+
+@implementation GodotApplication
+
+- (void)sendEvent:(NSEvent *)event {
+ // special case handling of command-period, which is traditionally a special
+ // shortcut in macOS and doesn't arrive at our regular keyDown handler.
+ if ([event type] == NSEventTypeKeyDown) {
+ if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
+ Ref<InputEventKey> k;
+ k.instance();
+
+ _get_key_modifier_state([event modifierFlags], k);
+ k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID);
+ k->set_pressed(true);
+ k->set_keycode(KEY_PERIOD);
+ k->set_physical_keycode(KEY_PERIOD);
+ k->set_echo([event isARepeat]);
+
+ InputFilter::get_singleton()->accumulate_input_event(k);
+ }
+ }
+
+ // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
+ // This works around an AppKit bug, where key up events while holding
+ // down the command key don't get sent to the key window.
+ if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand))
+ [[self keyWindow] sendEvent:event];
+ else
+ [super sendEvent:event];
+}
+
+@end
+
+/*************************************************************************/
+/* GlobalMenuItem */
+/*************************************************************************/
+
+@interface GlobalMenuItem : NSObject {
+@public
+ Callable callback;
+ Variant meta;
+ bool checkable;
+}
+@end
+
+@implementation GlobalMenuItem
+@end
+
+/*************************************************************************/
+/* GodotApplicationDelegate */
+/*************************************************************************/
+
+@interface GodotApplicationDelegate : NSObject
+- (void)forceUnbundledWindowActivationHackStep1;
+- (void)forceUnbundledWindowActivationHackStep2;
+- (void)forceUnbundledWindowActivationHackStep3;
+@end
+
+@implementation GodotApplicationDelegate
+
+- (void)forceUnbundledWindowActivationHackStep1 {
+ // Step1: Switch focus to macOS Dock.
+ // Required to perform step 2, TransformProcessType will fail if app is already the in focus.
+ for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
+ [app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
+ break;
+ }
+ [self performSelector:@selector(forceUnbundledWindowActivationHackStep2) withObject:nil afterDelay:0.02];
+}
+
+- (void)forceUnbundledWindowActivationHackStep2 {
+ // Step 2: Register app as foreground process.
+ ProcessSerialNumber psn = { 0, kCurrentProcess };
+ (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02];
+}
+
+- (void)forceUnbundledWindowActivationHackStep3 {
+ // Step 3: Switch focus back to app window.
+ [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)notice {
+ NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
+ if (nsappname == nil) {
+ // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored).
+ [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02];
+ }
+}
+
+- (void)globalMenuCallback:(id)sender {
+ if (![sender representedObject])
+ return;
+
+ GlobalMenuItem *value = [sender representedObject];
+
+ if (value) {
+ if (value->checkable) {
+ if ([sender state] == NSControlStateValueOff) {
+ [sender setState:NSControlStateValueOn];
+ } else {
+ [sender setState:NSControlStateValueOff];
+ }
+ }
+
+ if (value->callback != Callable()) {
+ Variant tag = value->meta;
+ Variant *tagp = &tag;
+ Variant ret;
+ Callable::CallError ce;
+ value->callback.call((const Variant **)&tagp, 1, ret, ce);
+ }
+ }
+}
+
+- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
+ return DS_OSX->dock_menu;
+}
+
+- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
+ // Note: may be called called before main loop init!
+ char *utfs = strdup([filename UTF8String]);
+ ((OS_OSX *)(OS_OSX::get_singleton()))->open_with_filename.parse_utf8(utfs);
+ free(utfs);
+
+#ifdef TOOLS_ENABLED
+ // Open new instance
+ if (OS_OSX::get_singleton()->get_main_loop()) {
+ List<String> args;
+ args.push_back(((OS_OSX *)(OS_OSX::get_singleton()))->open_with_filename);
+ String exec = OS::get_singleton()->get_executable_path();
+
+ OS::ProcessID pid = 0;
+ OS::get_singleton()->execute(exec, args, false, &pid);
+ }
+#endif
+ return YES;
+}
+
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
+ DS_OSX->_send_window_event(DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
+ return NSTerminateCancel;
+}
+
+- (void)showAbout:(id)sender {
+ if (OS_OSX::get_singleton()->get_main_loop())
+ OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT);
+}
+
+@end
+
+/*************************************************************************/
+/* GodotWindowDelegate */
+/*************************************************************************/
+
+@interface GodotWindowDelegate : NSObject {
+ DisplayServerOSX::WindowID window_id;
+}
+
+- (void)windowWillClose:(NSNotification *)notification;
+- (void)setWindowID:(DisplayServerOSX::WindowID)wid;
+
+@end
+
+@implementation GodotWindowDelegate
+
+- (void)setWindowID:(DisplayServerOSX::WindowID)wid {
+ window_id = wid;
+}
+
+- (BOOL)windowShouldClose:(id)sender {
+ ERR_FAIL_COND_V(!DS_OSX->windows.has(window_id), YES);
+ DS_OSX->_send_window_event(DS_OSX->windows[window_id], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
+ return NO;
+}
+
+- (void)windowWillClose:(NSNotification *)notification {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ while (wd.transient_children.size()) {
+ DS_OSX->window_set_transient(wd.transient_children.front()->get(), DisplayServerOSX::INVALID_WINDOW_ID);
+ }
+
+ DS_OSX->windows.erase(window_id);
+
+ if (wd.transient_parent != DisplayServerOSX::INVALID_WINDOW_ID) {
+ DisplayServerOSX::WindowData &pwd = DS_OSX->windows[wd.transient_parent];
+ [pwd.window_object makeKeyAndOrderFront:nil]; // Move focus back to parent.
+ DS_OSX->window_set_transient(window_id, DisplayServerOSX::INVALID_WINDOW_ID);
+ } else if ((window_id != DisplayServerOSX::MAIN_WINDOW_ID) && (DS_OSX->windows.size() == 1)) {
+ DisplayServerOSX::WindowData &pwd = DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID];
+ [pwd.window_object makeKeyAndOrderFront:nil]; // Move focus back to main window if there is no parent or other windows left.
+ }
+
+#ifdef VULKAN_ENABLED
+ if (DS_OSX->rendering_driver == "vulkan") {
+ DS_OSX->context_vulkan->window_destroy(window_id);
+ }
+#endif
+}
+
+- (void)windowDidEnterFullScreen:(NSNotification *)notification {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ wd.fullscreen = true;
+
+ [wd.window_object setContentMinSize:NSMakeSize(0, 0)];
+ [wd.window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
+}
+
+- (void)windowDidExitFullScreen:(NSNotification *)notification {
+ if (!DS_OSX || !DS_OSX->windows.has(window_id))
+ return;
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ wd.fullscreen = false;
+
+ if (wd.min_size != Size2i()) {
+ Size2i size = wd.min_size / DS_OSX->_display_scale([wd.window_object screen]);
+ [wd.window_object setContentMinSize:NSMakeSize(size.x, size.y)];
+ }
+ if (wd.max_size != Size2i()) {
+ Size2i size = wd.max_size / DS_OSX->_display_scale([wd.window_object screen]);
+ [wd.window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
+ }
+
+ if (wd.resize_disabled)
+ [wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
+}
+
+- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
+ if (!DisplayServerOSX::get_singleton())
+ return;
+
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ CGFloat newBackingScaleFactor = [wd.window_object backingScaleFactor];
+ CGFloat oldBackingScaleFactor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue];
+
+#if defined(OPENGL_ENABLED)
+ if (DS_OSX->rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ if (OS_OSX::get_singleton()->is_hidpi_allowed()) {
+ [wd.window_view setWantsBestResolutionOpenGLSurface:YES];
+ } else {
+ [wd.window_view setWantsBestResolutionOpenGLSurface:NO];
+ }
+ }
+#endif
+
+ if (newBackingScaleFactor != oldBackingScaleFactor) {
+ //Set new display scale and window size
+ float newDisplayScale = OS_OSX::get_singleton()->is_hidpi_allowed() ? newBackingScaleFactor : 1.0;
+
+ const NSRect contentRect = [wd.window_view frame];
+
+ wd.size.width = contentRect.size.width * newDisplayScale;
+ wd.size.height = contentRect.size.height * newDisplayScale;
+
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_DPI_CHANGE);
+
+#if defined(VULKAN_ENABLED)
+ if (DS_OSX->rendering_driver == "vulkan") {
+ CALayer *layer = [wd.window_view layer];
+ layer.contentsScale = DS_OSX->_display_scale([wd.window_object screen]);
+ }
+#endif
+ //Force window resize event
+ [self windowDidResize:notification];
+ }
+}
+
+- (void)windowDidResize:(NSNotification *)notification {
+ if (!DS_OSX || !DS_OSX->windows.has(window_id))
+ return;
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+#if defined(OPENGL_ENABLED)
+ if (DS_OSX->rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ wd.context_gles2->update();
+ }
+#endif
+ const NSRect contentRect = [wd.window_view frame];
+
+ float displayScale = DS_OSX->_display_scale([wd.window_object screen]);
+ wd.size.width = contentRect.size.width * displayScale;
+ wd.size.height = contentRect.size.height * displayScale;
+
+#if defined(VULKAN_ENABLED)
+ if (DS_OSX->rendering_driver == "vulkan") {
+ CALayer *layer = [wd.window_view layer];
+ layer.contentsScale = displayScale;
+ DS_OSX->context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
+ }
+#endif
+
+ if (!wd.rect_changed_callback.is_null()) {
+ Variant size = Rect2i(DS_OSX->window_get_position(window_id), DS_OSX->window_get_size(window_id));
+ Variant *sizep = &size;
+ Variant ret;
+ Callable::CallError ce;
+ wd.rect_changed_callback.call((const Variant **)&sizep, 1, ret, ce);
+ }
+
+ if (OS_OSX::get_singleton()->get_main_loop()) {
+ Main::force_redraw();
+ //Event retrieval blocks until resize is over. Call Main::iteration() directly.
+ if (!Main::is_iterating()) { //avoid cyclic loop
+ Main::iteration();
+ }
+ }
+}
+
+- (void)windowDidMove:(NSNotification *)notification {
+ DS_OSX->_release_pressed_events();
+}
+
+- (void)windowDidBecomeKey:(NSNotification *)notification {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ const CGFloat backingScaleFactor = (OS::get_singleton()->is_hidpi_allowed()) ? [wd.window_view backingScaleFactor] : 1.0;
+ _get_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream], backingScaleFactor);
+ InputFilter::get_singleton()->set_mouse_position(wd.mouse_pos);
+
+ DS_OSX->window_focused = true;
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_IN);
+}
+
+- (void)windowDidResignKey:(NSNotification *)notification {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ DS_OSX->window_focused = false;
+
+ DS_OSX->_release_pressed_events();
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_OUT);
+}
+
+- (void)windowDidMiniaturize:(NSNotification *)notification {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ DS_OSX->window_focused = false;
+
+ DS_OSX->_release_pressed_events();
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_OUT);
+}
+
+- (void)windowDidDeminiaturize:(NSNotification *)notification {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ DS_OSX->window_focused = true;
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_FOCUS_IN);
+}
+
+@end
+
+/*************************************************************************/
+/* GodotContentView */
+/*************************************************************************/
+
+@interface GodotContentView : NSView <NSTextInputClient> {
+ DisplayServerOSX::WindowID window_id;
+ NSTrackingArea *trackingArea;
+ NSMutableAttributedString *markedText;
+ bool imeInputEventInProgress;
+}
+
+- (void)cancelComposition;
+- (CALayer *)makeBackingLayer;
+- (BOOL)wantsUpdateLayer;
+- (void)updateLayer;
+- (void)setWindowID:(DisplayServerOSX::WindowID)wid;
+
+@end
+
+@implementation GodotContentView
+
+- (void)setWindowID:(DisplayServerOSX::WindowID)wid {
+ window_id = wid;
+}
+
++ (void)initialize {
+ if (self == [GodotContentView class]) {
+ // nothing left to do here at the moment..
+ }
+}
+
+- (CALayer *)makeBackingLayer {
+#if defined(VULKAN_ENABLED)
+ if (DS_OSX->rendering_driver == "vulkan") {
+ CALayer *layer = [[CAMetalLayer class] layer];
+ return layer;
+ }
+#endif
+ return [super makeBackingLayer];
+}
+
+- (void)updateLayer {
+#if defined(VULKAN_ENABLED)
+ if (DS_OSX->rendering_driver == "vulkan") {
+ [super updateLayer];
+ }
+#endif
+#if defined(OPENGL_ENABLED)
+ if (DS_OSX->rendering_driver == "opengl_es") {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ wd.context_gles2->update();
+ //TODO - reimplement OpenGLES
+ }
+#endif
+}
+
+- (BOOL)wantsUpdateLayer {
+ return YES;
+}
+
+- (id)init {
+ self = [super init];
+ trackingArea = nil;
+ imeInputEventInProgress = false;
+ [self updateTrackingAreas];
+ [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
+ markedText = [[NSMutableAttributedString alloc] init];
+ return self;
+}
+
+- (void)dealloc {
+ [trackingArea release];
+ [markedText release];
+ [super dealloc];
+}
+
+static const NSRange kEmptyRange = { NSNotFound, 0 };
+
+- (BOOL)hasMarkedText {
+ return (markedText.length > 0);
+}
+
+- (NSRange)markedRange {
+ return NSMakeRange(0, markedText.length);
+}
+
+- (NSRange)selectedRange {
+ return kEmptyRange;
+}
+
+- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange {
+ if ([aString isKindOfClass:[NSAttributedString class]]) {
+ [markedText initWithAttributedString:aString];
+ } else {
+ [markedText initWithString:aString];
+ }
+ if (markedText.length == 0) {
+ [self unmarkText];
+ return;
+ }
+
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (wd.im_active) {
+ imeInputEventInProgress = true;
+ DS_OSX->im_text.parse_utf8([[markedText mutableString] UTF8String]);
+ DS_OSX->im_selection = Point2i(selectedRange.location, selectedRange.length);
+
+ OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE);
+ }
+}
+
+- (void)doCommandBySelector:(SEL)aSelector {
+ if ([self respondsToSelector:aSelector])
+ [self performSelector:aSelector];
+}
+
+- (void)unmarkText {
+ imeInputEventInProgress = false;
+ [[markedText mutableString] setString:@""];
+
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (wd.im_active) {
+ DS_OSX->im_text = String();
+ DS_OSX->im_selection = Point2i();
+
+ OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE);
+ }
+}
+
+- (NSArray *)validAttributesForMarkedText {
+ return [NSArray array];
+}
+
+- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange {
+ return nil;
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)aPoint {
+ return 0;
+}
+
+- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange {
+ ERR_FAIL_COND_V(!DS_OSX->windows.has(window_id), NSMakeRect(0, 0, 0, 0));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ const NSRect contentRect = [wd.window_view frame];
+ float displayScale = DS_OSX->_display_scale([wd.window_object screen]);
+ NSRect pointInWindowRect = NSMakeRect(wd.im_position.x / displayScale, contentRect.size.height - (wd.im_position.y / displayScale) - 1, 0, 0);
+ NSPoint pointOnScreen = [wd.window_object convertRectToScreen:pointInWindowRect].origin;
+
+ return NSMakeRect(pointOnScreen.x, pointOnScreen.y, 0, 0);
+}
+
+- (void)cancelComposition {
+ [self unmarkText];
+ NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
+ [currentInputContext discardMarkedText];
+}
+
+- (void)insertText:(id)aString {
+ [self insertText:aString replacementRange:NSMakeRange(0, 0)];
+}
+
+- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange {
+ NSEvent *event = [NSApp currentEvent];
+
+ NSString *characters;
+ if ([aString isKindOfClass:[NSAttributedString class]]) {
+ characters = [aString string];
+ } else {
+ characters = (NSString *)aString;
+ }
+
+ NSUInteger i, length = [characters length];
+
+ NSCharacterSet *ctrlChars = [NSCharacterSet controlCharacterSet];
+ NSCharacterSet *wsnlChars = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+ if ([characters rangeOfCharacterFromSet:ctrlChars].length && [characters rangeOfCharacterFromSet:wsnlChars].length == 0) {
+ NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
+ [currentInputContext discardMarkedText];
+ [self cancelComposition];
+ return;
+ }
+
+ for (i = 0; i < length; i++) {
+ const unichar codepoint = [characters characterAtIndex:i];
+ if ((codepoint & 0xFF00) == 0xF700)
+ continue;
+
+ DisplayServerOSX::KeyEvent ke;
+
+ ke.window_id = window_id;
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = true;
+ ke.echo = false;
+ ke.raw = false; // IME input event
+ ke.keycode = 0;
+ ke.physical_keycode = 0;
+ ke.unicode = codepoint;
+
+ _push_to_key_event_buffer(ke);
+ }
+ [self cancelComposition];
+}
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
+ return NSDragOperationCopy;
+}
+
+- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
+ return NSDragOperationCopy;
+}
+
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
+ ERR_FAIL_COND_V(!DS_OSX->windows.has(window_id), NO);
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ NSPasteboard *pboard = [sender draggingPasteboard];
+ NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
+
+ Vector<String> files;
+ for (NSUInteger i = 0; i < filenames.count; i++) {
+ NSString *ns = [filenames objectAtIndex:i];
+ char *utfs = strdup([ns UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+ files.push_back(ret);
+ }
+
+ if (!wd.drop_files_callback.is_null()) {
+ Variant v = files;
+ Variant *vp = &v;
+ Variant ret;
+ Callable::CallError ce;
+ wd.drop_files_callback.call((const Variant **)&vp, 1, ret, ce);
+ }
+
+ return NO;
+}
+
+- (BOOL)isOpaque {
+ return YES;
+}
+
+- (BOOL)canBecomeKeyView {
+ return YES;
+}
+
+- (BOOL)acceptsFirstResponder {
+ return YES;
+}
+
+- (void)cursorUpdate:(NSEvent *)event {
+ DisplayServer::CursorShape p_shape = DS_OSX->cursor_shape;
+ DS_OSX->cursor_shape = DisplayServer::CURSOR_MAX;
+ DS_OSX->cursor_set_shape(p_shape);
+}
+
+static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, int index, int mask, bool pressed) {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (pressed) {
+ DS_OSX->last_button_state |= mask;
+ } else {
+ DS_OSX->last_button_state &= ~mask;
+ }
+
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
+ mb->set_window_id(window_id);
+ const CGFloat backingScaleFactor = (OS::get_singleton()->is_hidpi_allowed()) ? [[event window] backingScaleFactor] : 1.0;
+ const Vector2 pos = _get_mouse_pos(wd, [event locationInWindow], backingScaleFactor);
+ _get_key_modifier_state([event modifierFlags], mb);
+ mb->set_button_index(index);
+ mb->set_pressed(pressed);
+ mb->set_position(pos);
+ mb->set_global_position(pos);
+ mb->set_button_mask(DS_OSX->last_button_state);
+ if (index == BUTTON_LEFT && pressed) {
+ mb->set_doubleclick([event clickCount] == 2);
+ }
+
+ InputFilter::get_singleton()->accumulate_input_event(mb);
+}
+
+- (void)mouseDown:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (([event modifierFlags] & NSEventModifierFlagControl)) {
+ wd.mouse_down_control = true;
+ _mouseDownEvent(window_id, event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
+ } else {
+ wd.mouse_down_control = false;
+ _mouseDownEvent(window_id, event, BUTTON_LEFT, BUTTON_MASK_LEFT, true);
+ }
+}
+
+- (void)mouseDragged:(NSEvent *)event {
+ [self mouseMoved:event];
+}
+
+- (void)mouseUp:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (wd.mouse_down_control) {
+ _mouseDownEvent(window_id, event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
+ } else {
+ _mouseDownEvent(window_id, event, BUTTON_LEFT, BUTTON_MASK_LEFT, false);
+ }
+}
+
+- (void)mouseMoved:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ Ref<InputEventMouseMotion> mm;
+ mm.instance();
+
+ mm->set_window_id(window_id);
+ mm->set_button_mask(DS_OSX->last_button_state);
+ const CGFloat backingScaleFactor = (OS::get_singleton()->is_hidpi_allowed()) ? [[event window] backingScaleFactor] : 1.0;
+ const Vector2i pos = _get_mouse_pos(wd, [event locationInWindow], backingScaleFactor);
+ mm->set_position(pos);
+ mm->set_pressure([event pressure]);
+ if ([event subtype] == NSEventSubtypeTabletPoint) {
+ const NSPoint p = [event tilt];
+ mm->set_tilt(Vector2(p.x, p.y));
+ }
+ mm->set_global_position(pos);
+ mm->set_speed(InputFilter::get_singleton()->get_last_mouse_speed());
+ Vector2i relativeMotion = Vector2i();
+ relativeMotion.x = [event deltaX] * backingScaleFactor;
+ relativeMotion.y = [event deltaY] * backingScaleFactor;
+ mm->set_relative(relativeMotion);
+ _get_key_modifier_state([event modifierFlags], mm);
+
+ InputFilter::get_singleton()->set_mouse_position(wd.mouse_pos);
+ InputFilter::get_singleton()->accumulate_input_event(mm);
+}
+
+- (void)rightMouseDown:(NSEvent *)event {
+ _mouseDownEvent(window_id, event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
+}
+
+- (void)rightMouseDragged:(NSEvent *)event {
+ [self mouseMoved:event];
+}
+
+- (void)rightMouseUp:(NSEvent *)event {
+ _mouseDownEvent(window_id, event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
+}
+
+- (void)otherMouseDown:(NSEvent *)event {
+ if ((int)[event buttonNumber] == 2) {
+ _mouseDownEvent(window_id, event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, true);
+ } else if ((int)[event buttonNumber] == 3) {
+ _mouseDownEvent(window_id, event, BUTTON_XBUTTON1, BUTTON_MASK_XBUTTON1, true);
+ } else if ((int)[event buttonNumber] == 4) {
+ _mouseDownEvent(window_id, event, BUTTON_XBUTTON2, BUTTON_MASK_XBUTTON2, true);
+ } else {
+ return;
+ }
+}
+
+- (void)otherMouseDragged:(NSEvent *)event {
+ [self mouseMoved:event];
+}
+
+- (void)otherMouseUp:(NSEvent *)event {
+ if ((int)[event buttonNumber] == 2) {
+ _mouseDownEvent(window_id, event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, false);
+ } else if ((int)[event buttonNumber] == 3) {
+ _mouseDownEvent(window_id, event, BUTTON_XBUTTON1, BUTTON_MASK_XBUTTON1, false);
+ } else if ((int)[event buttonNumber] == 4) {
+ _mouseDownEvent(window_id, event, BUTTON_XBUTTON2, BUTTON_MASK_XBUTTON2, false);
+ } else {
+ return;
+ }
+}
+
+- (void)mouseExited:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (DS_OSX->mouse_mode != DisplayServer::MOUSE_MODE_CAPTURED)
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_MOUSE_EXIT);
+}
+
+- (void)mouseEntered:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ if (DS_OSX->mouse_mode != DisplayServer::MOUSE_MODE_CAPTURED)
+ DS_OSX->_send_window_event(wd, DisplayServerOSX::WINDOW_EVENT_MOUSE_ENTER);
+
+ DisplayServer::CursorShape p_shape = DS_OSX->cursor_shape;
+ DS_OSX->cursor_shape = DisplayServer::CURSOR_MAX;
+ DS_OSX->cursor_set_shape(p_shape);
+}
+
+- (void)magnifyWithEvent:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ Ref<InputEventMagnifyGesture> ev;
+ ev.instance();
+ ev->set_window_id(window_id);
+ _get_key_modifier_state([event modifierFlags], ev);
+ const CGFloat backingScaleFactor = (OS::get_singleton()->is_hidpi_allowed()) ? [[event window] backingScaleFactor] : 1.0;
+ ev->set_position(_get_mouse_pos(wd, [event locationInWindow], backingScaleFactor));
+ ev->set_factor([event magnification] + 1.0);
+
+ InputFilter::get_singleton()->accumulate_input_event(ev);
+}
+
+- (void)viewDidChangeBackingProperties {
+ // nothing left to do here
+}
+
+- (void)updateTrackingAreas {
+ if (trackingArea != nil) {
+ [self removeTrackingArea:trackingArea];
+ [trackingArea release];
+ }
+
+ NSTrackingAreaOptions options =
+ NSTrackingMouseEnteredAndExited |
+ NSTrackingActiveInKeyWindow |
+ NSTrackingCursorUpdate |
+ NSTrackingInVisibleRect;
+
+ trackingArea = [[NSTrackingArea alloc]
+ initWithRect:[self bounds]
+ options:options
+ owner:self
+ userInfo:nil];
+
+ [self addTrackingArea:trackingArea];
+ [super updateTrackingAreas];
+}
+
+static bool isNumpadKey(unsigned int key) {
+
+ static const unsigned int table[] = {
+ 0x41, /* kVK_ANSI_KeypadDecimal */
+ 0x43, /* kVK_ANSI_KeypadMultiply */
+ 0x45, /* kVK_ANSI_KeypadPlus */
+ 0x47, /* kVK_ANSI_KeypadClear */
+ 0x4b, /* kVK_ANSI_KeypadDivide */
+ 0x4c, /* kVK_ANSI_KeypadEnter */
+ 0x4e, /* kVK_ANSI_KeypadMinus */
+ 0x51, /* kVK_ANSI_KeypadEquals */
+ 0x52, /* kVK_ANSI_Keypad0 */
+ 0x53, /* kVK_ANSI_Keypad1 */
+ 0x54, /* kVK_ANSI_Keypad2 */
+ 0x55, /* kVK_ANSI_Keypad3 */
+ 0x56, /* kVK_ANSI_Keypad4 */
+ 0x57, /* kVK_ANSI_Keypad5 */
+ 0x58, /* kVK_ANSI_Keypad6 */
+ 0x59, /* kVK_ANSI_Keypad7 */
+ 0x5b, /* kVK_ANSI_Keypad8 */
+ 0x5c, /* kVK_ANSI_Keypad9 */
+ 0x5f, /* kVK_JIS_KeypadComma */
+ 0x00
+ };
+ for (int i = 0; table[i] != 0; i++) {
+ if (key == table[i])
+ return true;
+ }
+ return false;
+}
+
+// Translates a OS X keycode to a Godot keycode
+//
+static int translateKey(unsigned int key) {
+
+ // Keyboard symbol translation table
+ static const unsigned int table[128] = {
+ /* 00 */ KEY_A,
+ /* 01 */ KEY_S,
+ /* 02 */ KEY_D,
+ /* 03 */ KEY_F,
+ /* 04 */ KEY_H,
+ /* 05 */ KEY_G,
+ /* 06 */ KEY_Z,
+ /* 07 */ KEY_X,
+ /* 08 */ KEY_C,
+ /* 09 */ KEY_V,
+ /* 0a */ KEY_SECTION, /* ISO Section */
+ /* 0b */ KEY_B,
+ /* 0c */ KEY_Q,
+ /* 0d */ KEY_W,
+ /* 0e */ KEY_E,
+ /* 0f */ KEY_R,
+ /* 10 */ KEY_Y,
+ /* 11 */ KEY_T,
+ /* 12 */ KEY_1,
+ /* 13 */ KEY_2,
+ /* 14 */ KEY_3,
+ /* 15 */ KEY_4,
+ /* 16 */ KEY_6,
+ /* 17 */ KEY_5,
+ /* 18 */ KEY_EQUAL,
+ /* 19 */ KEY_9,
+ /* 1a */ KEY_7,
+ /* 1b */ KEY_MINUS,
+ /* 1c */ KEY_8,
+ /* 1d */ KEY_0,
+ /* 1e */ KEY_BRACERIGHT,
+ /* 1f */ KEY_O,
+ /* 20 */ KEY_U,
+ /* 21 */ KEY_BRACELEFT,
+ /* 22 */ KEY_I,
+ /* 23 */ KEY_P,
+ /* 24 */ KEY_ENTER,
+ /* 25 */ KEY_L,
+ /* 26 */ KEY_J,
+ /* 27 */ KEY_APOSTROPHE,
+ /* 28 */ KEY_K,
+ /* 29 */ KEY_SEMICOLON,
+ /* 2a */ KEY_BACKSLASH,
+ /* 2b */ KEY_COMMA,
+ /* 2c */ KEY_SLASH,
+ /* 2d */ KEY_N,
+ /* 2e */ KEY_M,
+ /* 2f */ KEY_PERIOD,
+ /* 30 */ KEY_TAB,
+ /* 31 */ KEY_SPACE,
+ /* 32 */ KEY_QUOTELEFT,
+ /* 33 */ KEY_BACKSPACE,
+ /* 34 */ KEY_UNKNOWN,
+ /* 35 */ KEY_ESCAPE,
+ /* 36 */ KEY_META,
+ /* 37 */ KEY_META,
+ /* 38 */ KEY_SHIFT,
+ /* 39 */ KEY_CAPSLOCK,
+ /* 3a */ KEY_ALT,
+ /* 3b */ KEY_CONTROL,
+ /* 3c */ KEY_SHIFT,
+ /* 3d */ KEY_ALT,
+ /* 3e */ KEY_CONTROL,
+ /* 3f */ KEY_UNKNOWN, /* Function */
+ /* 40 */ KEY_UNKNOWN, /* F17 */
+ /* 41 */ KEY_KP_PERIOD,
+ /* 42 */ KEY_UNKNOWN,
+ /* 43 */ KEY_KP_MULTIPLY,
+ /* 44 */ KEY_UNKNOWN,
+ /* 45 */ KEY_KP_ADD,
+ /* 46 */ KEY_UNKNOWN,
+ /* 47 */ KEY_NUMLOCK, /* Really KeypadClear... */
+ /* 48 */ KEY_VOLUMEUP, /* VolumeUp */
+ /* 49 */ KEY_VOLUMEDOWN, /* VolumeDown */
+ /* 4a */ KEY_VOLUMEMUTE, /* Mute */
+ /* 4b */ KEY_KP_DIVIDE,
+ /* 4c */ KEY_KP_ENTER,
+ /* 4d */ KEY_UNKNOWN,
+ /* 4e */ KEY_KP_SUBTRACT,
+ /* 4f */ KEY_UNKNOWN, /* F18 */
+ /* 50 */ KEY_UNKNOWN, /* F19 */
+ /* 51 */ KEY_EQUAL, /* KeypadEqual */
+ /* 52 */ KEY_KP_0,
+ /* 53 */ KEY_KP_1,
+ /* 54 */ KEY_KP_2,
+ /* 55 */ KEY_KP_3,
+ /* 56 */ KEY_KP_4,
+ /* 57 */ KEY_KP_5,
+ /* 58 */ KEY_KP_6,
+ /* 59 */ KEY_KP_7,
+ /* 5a */ KEY_UNKNOWN, /* F20 */
+ /* 5b */ KEY_KP_8,
+ /* 5c */ KEY_KP_9,
+ /* 5d */ KEY_YEN, /* JIS Yen */
+ /* 5e */ KEY_UNDERSCORE, /* JIS Underscore */
+ /* 5f */ KEY_COMMA, /* JIS KeypadComma */
+ /* 60 */ KEY_F5,
+ /* 61 */ KEY_F6,
+ /* 62 */ KEY_F7,
+ /* 63 */ KEY_F3,
+ /* 64 */ KEY_F8,
+ /* 65 */ KEY_F9,
+ /* 66 */ KEY_UNKNOWN, /* JIS Eisu */
+ /* 67 */ KEY_F11,
+ /* 68 */ KEY_UNKNOWN, /* JIS Kana */
+ /* 69 */ KEY_F13,
+ /* 6a */ KEY_F16,
+ /* 6b */ KEY_F14,
+ /* 6c */ KEY_UNKNOWN,
+ /* 6d */ KEY_F10,
+ /* 6e */ KEY_MENU,
+ /* 6f */ KEY_F12,
+ /* 70 */ KEY_UNKNOWN,
+ /* 71 */ KEY_F15,
+ /* 72 */ KEY_INSERT, /* Really Help... */
+ /* 73 */ KEY_HOME,
+ /* 74 */ KEY_PAGEUP,
+ /* 75 */ KEY_DELETE,
+ /* 76 */ KEY_F4,
+ /* 77 */ KEY_END,
+ /* 78 */ KEY_F2,
+ /* 79 */ KEY_PAGEDOWN,
+ /* 7a */ KEY_F1,
+ /* 7b */ KEY_LEFT,
+ /* 7c */ KEY_RIGHT,
+ /* 7d */ KEY_DOWN,
+ /* 7e */ KEY_UP,
+ /* 7f */ KEY_UNKNOWN,
+ };
+
+ if (key >= 128)
+ return KEY_UNKNOWN;
+
+ return table[key];
+}
+
+struct _KeyCodeMap {
+ UniChar kchar;
+ int kcode;
+};
+
+static const _KeyCodeMap _keycodes[55] = {
+ { '`', KEY_QUOTELEFT },
+ { '~', KEY_ASCIITILDE },
+ { '0', KEY_0 },
+ { '1', KEY_1 },
+ { '2', KEY_2 },
+ { '3', KEY_3 },
+ { '4', KEY_4 },
+ { '5', KEY_5 },
+ { '6', KEY_6 },
+ { '7', KEY_7 },
+ { '8', KEY_8 },
+ { '9', KEY_9 },
+ { '-', KEY_MINUS },
+ { '_', KEY_UNDERSCORE },
+ { '=', KEY_EQUAL },
+ { '+', KEY_PLUS },
+ { 'q', KEY_Q },
+ { 'w', KEY_W },
+ { 'e', KEY_E },
+ { 'r', KEY_R },
+ { 't', KEY_T },
+ { 'y', KEY_Y },
+ { 'u', KEY_U },
+ { 'i', KEY_I },
+ { 'o', KEY_O },
+ { 'p', KEY_P },
+ { '[', KEY_BRACELEFT },
+ { ']', KEY_BRACERIGHT },
+ { '{', KEY_BRACELEFT },
+ { '}', KEY_BRACERIGHT },
+ { 'a', KEY_A },
+ { 's', KEY_S },
+ { 'd', KEY_D },
+ { 'f', KEY_F },
+ { 'g', KEY_G },
+ { 'h', KEY_H },
+ { 'j', KEY_J },
+ { 'k', KEY_K },
+ { 'l', KEY_L },
+ { ';', KEY_SEMICOLON },
+ { ':', KEY_COLON },
+ { '\'', KEY_APOSTROPHE },
+ { '\"', KEY_QUOTEDBL },
+ { '\\', KEY_BACKSLASH },
+ { '#', KEY_NUMBERSIGN },
+ { 'z', KEY_Z },
+ { 'x', KEY_X },
+ { 'c', KEY_C },
+ { 'v', KEY_V },
+ { 'b', KEY_B },
+ { 'n', KEY_N },
+ { 'm', KEY_M },
+ { ',', KEY_COMMA },
+ { '.', KEY_PERIOD },
+ { '/', KEY_SLASH }
+};
+
+static int remapKey(unsigned int key, unsigned int state) {
+ if (isNumpadKey(key))
+ return translateKey(key);
+
+ TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
+ if (!currentKeyboard)
+ return translateKey(key);
+
+ CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
+ if (!layoutData)
+ return translateKey(key);
+
+ const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
+
+ UInt32 keysDown = 0;
+ UniChar chars[4];
+ UniCharCount realLength;
+
+ OSStatus err = UCKeyTranslate(keyboardLayout,
+ key,
+ kUCKeyActionDisplay,
+ (state >> 8) & 0xFF,
+ LMGetKbdType(),
+ kUCKeyTranslateNoDeadKeysBit,
+ &keysDown,
+ sizeof(chars) / sizeof(chars[0]),
+ &realLength,
+ chars);
+
+ if (err != noErr) {
+ return translateKey(key);
+ }
+
+ for (unsigned int i = 0; i < 55; i++) {
+ if (_keycodes[i].kchar == chars[0]) {
+ return _keycodes[i].kcode;
+ }
+ }
+ return translateKey(key);
+}
+
+- (void)keyDown:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ // Ignore all input if IME input is in progress
+ if (!imeInputEventInProgress) {
+ NSString *characters = [event characters];
+ NSUInteger length = [characters length];
+
+ if (!wd.im_active && length > 0 && keycode_has_unicode(remapKey([event keyCode], [event modifierFlags]))) {
+ // Fallback unicode character handler used if IME is not active
+ for (NSUInteger i = 0; i < length; i++) {
+ DisplayServerOSX::KeyEvent ke;
+
+ ke.window_id = window_id;
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = true;
+ ke.echo = [event isARepeat];
+ ke.keycode = remapKey([event keyCode], [event modifierFlags]);
+ ke.physical_keycode = translateKey([event keyCode]);
+ ke.raw = true;
+ ke.unicode = [characters characterAtIndex:i];
+
+ _push_to_key_event_buffer(ke);
+ }
+ } else {
+ DisplayServerOSX::KeyEvent ke;
+
+ ke.window_id = window_id;
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = true;
+ ke.echo = [event isARepeat];
+ ke.keycode = remapKey([event keyCode], [event modifierFlags]);
+ ke.physical_keycode = translateKey([event keyCode]);
+ ke.raw = false;
+ ke.unicode = 0;
+
+ _push_to_key_event_buffer(ke);
+ }
+ }
+
+ // Pass events to IME handler
+ if (wd.im_active)
+ [self interpretKeyEvents:[NSArray arrayWithObject:event]];
+}
+
+- (void)flagsChanged:(NSEvent *)event {
+ // Ignore all input if IME input is in progress
+ if (!imeInputEventInProgress) {
+ DisplayServerOSX::KeyEvent ke;
+
+ ke.window_id = window_id;
+ ke.echo = false;
+ ke.raw = true;
+
+ int key = [event keyCode];
+ int mod = [event modifierFlags];
+
+ if (key == 0x36 || key == 0x37) {
+ if (mod & NSEventModifierFlagCommand) {
+ mod &= ~NSEventModifierFlagCommand;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else if (key == 0x38 || key == 0x3c) {
+ if (mod & NSEventModifierFlagShift) {
+ mod &= ~NSEventModifierFlagShift;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else if (key == 0x3a || key == 0x3d) {
+ if (mod & NSEventModifierFlagOption) {
+ mod &= ~NSEventModifierFlagOption;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else if (key == 0x3b || key == 0x3e) {
+ if (mod & NSEventModifierFlagControl) {
+ mod &= ~NSEventModifierFlagControl;
+ ke.pressed = true;
+ } else {
+ ke.pressed = false;
+ }
+ } else {
+ return;
+ }
+
+ ke.osx_state = mod;
+ ke.keycode = remapKey(key, mod);
+ ke.physical_keycode = translateKey(key);
+ ke.unicode = 0;
+
+ _push_to_key_event_buffer(ke);
+ }
+}
+
+- (void)keyUp:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ // Ignore all input if IME input is in progress
+ if (!imeInputEventInProgress) {
+ NSString *characters = [event characters];
+ NSUInteger length = [characters length];
+
+ // Fallback unicode character handler used if IME is not active
+ if (!wd.im_active && length > 0 && keycode_has_unicode(remapKey([event keyCode], [event modifierFlags]))) {
+ for (NSUInteger i = 0; i < length; i++) {
+ DisplayServerOSX::KeyEvent ke;
+
+ ke.window_id = window_id;
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = false;
+ ke.echo = [event isARepeat];
+ ke.keycode = remapKey([event keyCode], [event modifierFlags]);
+ ke.physical_keycode = translateKey([event keyCode]);
+ ke.raw = true;
+ ke.unicode = [characters characterAtIndex:i];
+
+ _push_to_key_event_buffer(ke);
+ }
+ } else {
+ DisplayServerOSX::KeyEvent ke;
+
+ ke.window_id = window_id;
+ ke.osx_state = [event modifierFlags];
+ ke.pressed = false;
+ ke.echo = [event isARepeat];
+ ke.keycode = remapKey([event keyCode], [event modifierFlags]);
+ ke.physical_keycode = translateKey([event keyCode]);
+ ke.raw = true;
+ ke.unicode = 0;
+
+ _push_to_key_event_buffer(ke);
+ }
+ }
+}
+
+inline void sendScrollEvent(DisplayServer::WindowID window_id, int button, double factor, int modifierFlags) {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ unsigned int mask = 1 << (button - 1);
+
+ Ref<InputEventMouseButton> sc;
+ sc.instance();
+
+ sc->set_window_id(window_id);
+ _get_key_modifier_state(modifierFlags, sc);
+ sc->set_button_index(button);
+ sc->set_factor(factor);
+ sc->set_pressed(true);
+ sc->set_position(wd.mouse_pos);
+ sc->set_global_position(wd.mouse_pos);
+ DS_OSX->last_button_state |= mask;
+ sc->set_button_mask(DS_OSX->last_button_state);
+
+ InputFilter::get_singleton()->accumulate_input_event(sc);
+
+ sc.instance();
+ sc->set_window_id(window_id);
+ sc->set_button_index(button);
+ sc->set_factor(factor);
+ sc->set_pressed(false);
+ sc->set_position(wd.mouse_pos);
+ sc->set_global_position(wd.mouse_pos);
+ DS_OSX->last_button_state &= ~mask;
+ sc->set_button_mask(DS_OSX->last_button_state);
+
+ InputFilter::get_singleton()->accumulate_input_event(sc);
+}
+
+inline void sendPanEvent(DisplayServer::WindowID window_id, double dx, double dy, int modifierFlags) {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ Ref<InputEventPanGesture> pg;
+ pg.instance();
+
+ pg->set_window_id(window_id);
+ _get_key_modifier_state(modifierFlags, pg);
+ pg->set_position(wd.mouse_pos);
+ pg->set_delta(Vector2(-dx, -dy));
+
+ InputFilter::get_singleton()->accumulate_input_event(pg);
+}
+
+- (void)scrollWheel:(NSEvent *)event {
+ ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
+ double deltaX, deltaY;
+
+ const CGFloat backingScaleFactor = (OS::get_singleton()->is_hidpi_allowed()) ? [[event window] backingScaleFactor] : 1.0;
+ _get_mouse_pos(wd, [event locationInWindow], backingScaleFactor);
+
+ deltaX = [event scrollingDeltaX];
+ deltaY = [event scrollingDeltaY];
+
+ if ([event hasPreciseScrollingDeltas]) {
+ deltaX *= 0.03;
+ deltaY *= 0.03;
+ }
+
+ if ([event phase] != NSEventPhaseNone || [event momentumPhase] != NSEventPhaseNone) {
+ sendPanEvent(window_id, deltaX, deltaY, [event modifierFlags]);
+ } else {
+ if (fabs(deltaX)) {
+ sendScrollEvent(window_id, 0 > deltaX ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT, fabs(deltaX * 0.3), [event modifierFlags]);
+ }
+ if (fabs(deltaY)) {
+ sendScrollEvent(window_id, 0 < deltaY ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN, fabs(deltaY * 0.3), [event modifierFlags]);
+ }
+ }
+}
+
+@end
+
+/*************************************************************************/
+/* GodotWindow */
+/*************************************************************************/
+
+@interface GodotWindow : NSWindow {
+}
+@end
+
+@implementation GodotWindow
+
+- (BOOL)canBecomeKeyWindow {
+ // Required for NSBorderlessWindowMask windows
+ return YES;
+}
+
+@end
+
+/*************************************************************************/
+/* DisplayServerOSX */
+/*************************************************************************/
+
+bool DisplayServerOSX::has_feature(Feature p_feature) const {
+ switch (p_feature) {
+ case FEATURE_GLOBAL_MENU:
+ case FEATURE_SUBWINDOWS:
+ //case FEATURE_TOUCHSCREEN:
+ case FEATURE_MOUSE:
+ case FEATURE_MOUSE_WARP:
+ case FEATURE_CLIPBOARD:
+ case FEATURE_CURSOR_SHAPE:
+ case FEATURE_CUSTOM_CURSOR_SHAPE:
+ case FEATURE_NATIVE_DIALOG:
+ //case FEATURE_CONSOLE_WINDOW:
+ case FEATURE_IME:
+ case FEATURE_WINDOW_TRANSPARENCY:
+ case FEATURE_HIDPI:
+ case FEATURE_ICON:
+ case FEATURE_NATIVE_ICON:
+ case FEATURE_SWAP_BUFFERS:
+ return true;
+ default: {
+ }
+ }
+ return false;
+}
+
+String DisplayServerOSX::get_name() const {
+ return "OSX";
+}
+
+const NSMenu *DisplayServerOSX::_get_menu_root(const String &p_menu_root) const {
+ const NSMenu *menu = NULL;
+ if (p_menu_root == "") {
+ // Main menu.x
+ menu = [NSApp mainMenu];
+ } else if (p_menu_root.to_lower() == "_dock") {
+ // macOS dock menu.
+ menu = dock_menu;
+ } else {
+ // Submenu.
+ if (submenu.has(p_menu_root)) {
+ menu = submenu[p_menu_root];
+ }
+ }
+ if (menu == apple_menu) {
+ // Do not allow to change Apple menu.
+ return NULL;
+ }
+ return menu;
+}
+
+NSMenu *DisplayServerOSX::_get_menu_root(const String &p_menu_root) {
+ NSMenu *menu = NULL;
+ if (p_menu_root == "") {
+ // Main menu.
+ menu = [NSApp mainMenu];
+ } else if (p_menu_root.to_lower() == "_dock") {
+ // macOS dock menu.
+ menu = dock_menu;
+ } else {
+ // Submenu.
+ if (!submenu.has(p_menu_root)) {
+ NSMenu *n_menu = [[NSMenu alloc] initWithTitle:[NSString stringWithUTF8String:p_menu_root.utf8().get_data()]];
+ submenu[p_menu_root] = n_menu;
+ }
+ menu = submenu[p_menu_root];
+ }
+ if (menu == apple_menu) {
+ // Do not allow to change Apple menu.
+ return NULL;
+ }
+ return menu;
+}
+
+void DisplayServerOSX::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""];
+ GlobalMenuItem *obj = [[[GlobalMenuItem alloc] init] autorelease];
+ obj->callback = p_callback;
+ obj->meta = p_tag;
+ obj->checkable = false;
+ [menu_item setRepresentedObject:obj];
+ }
+}
+
+void DisplayServerOSX::global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""];
+ GlobalMenuItem *obj = [[[GlobalMenuItem alloc] init] autorelease];
+ obj->callback = p_callback;
+ obj->meta = p_tag;
+ obj->checkable = true;
+ [menu_item setRepresentedObject:obj];
+ }
+}
+
+void DisplayServerOSX::global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ NSMenu *sub_menu = _get_menu_root(p_submenu);
+ if (menu && sub_menu) {
+ if (sub_menu == menu) {
+ ERR_PRINT("Can't set submenu to self!");
+ return;
+ }
+ if ([sub_menu supermenu]) {
+ ERR_PRINT("Can't set submenu to menu that is already a submenu of some other menu!");
+ return;
+ }
+ NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:nil keyEquivalent:@""];
+ [menu setSubmenu:sub_menu forItem:menu_item];
+ }
+}
+
+void DisplayServerOSX::global_menu_add_separator(const String &p_menu_root) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ [menu addItem:[NSMenuItem separatorItem]];
+ }
+}
+
+bool DisplayServerOSX::global_menu_is_item_checked(const String &p_menu_root, int p_idx) const {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ const NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ return ([menu_item state] == NSControlStateValueOn);
+ }
+ }
+ return false;
+}
+
+bool DisplayServerOSX::global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ const NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ GlobalMenuItem *obj = [menu_item representedObject];
+ if (obj) {
+ return obj->checkable;
+ }
+ }
+ }
+ return false;
+}
+
+Callable DisplayServerOSX::global_menu_get_item_callback(const String &p_menu_root, int p_idx) {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ const NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ GlobalMenuItem *obj = [menu_item representedObject];
+ if (obj) {
+ return obj->callback;
+ }
+ }
+ }
+ return Callable();
+}
+
+Variant DisplayServerOSX::global_menu_get_item_tag(const String &p_menu_root, int p_idx) {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ const NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ GlobalMenuItem *obj = [menu_item representedObject];
+ if (obj) {
+ return obj->meta;
+ }
+ }
+ }
+ return Variant();
+}
+
+String DisplayServerOSX::global_menu_get_item_text(const String &p_menu_root, int p_idx) {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ const NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ char *utfs = strdup([[menu_item title] UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+ return ret;
+ }
+ }
+ return String();
+}
+
+String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root, int p_idx) {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ const NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ const NSMenu *sub_menu = [menu_item submenu];
+ if (sub_menu) {
+ for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) {
+ if (E->get() == sub_menu) return E->key();
+ }
+ }
+ }
+ }
+ return String();
+}
+
+void DisplayServerOSX::global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not edit Apple menu.
+ return;
+ }
+ NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ if (p_checked) {
+ [menu_item setState:NSControlStateValueOn];
+ } else {
+ [menu_item setState:NSControlStateValueOff];
+ }
+ }
+ }
+}
+
+void DisplayServerOSX::global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not edit Apple menu.
+ return;
+ }
+ NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ GlobalMenuItem *obj = [menu_item representedObject];
+ obj->checkable = p_checkable;
+ }
+ }
+}
+
+void DisplayServerOSX::global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not edit Apple menu.
+ return;
+ }
+ NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ GlobalMenuItem *obj = [menu_item representedObject];
+ obj->callback = p_callback;
+ }
+ }
+}
+
+void DisplayServerOSX::global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not edit Apple menu.
+ return;
+ }
+ NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ GlobalMenuItem *obj = [menu_item representedObject];
+ obj->meta = p_tag;
+ }
+ }
+}
+
+void DisplayServerOSX::global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not edit Apple menu.
+ return;
+ }
+ NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ [menu_item setTitle:[NSString stringWithUTF8String:p_text.utf8().get_data()]];
+ }
+ }
+}
+
+void DisplayServerOSX::global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ NSMenu *sub_menu = _get_menu_root(p_submenu);
+ if (menu && sub_menu) {
+ if (sub_menu == menu) {
+ ERR_PRINT("Can't set submenu to self!");
+ return;
+ }
+ if ([sub_menu supermenu]) {
+ ERR_PRINT("Can't set submenu to menu that is already a submenu of some other menu!");
+ return;
+ }
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not edit Apple menu.
+ return;
+ }
+ NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
+ if (menu_item) {
+ [menu setSubmenu:sub_menu forItem:menu_item];
+ }
+ }
+}
+
+int DisplayServerOSX::global_menu_get_item_count(const String &p_menu_root) const {
+ _THREAD_SAFE_METHOD_
+
+ const NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ return [menu numberOfItems];
+ } else {
+ return 0;
+ }
+}
+
+void DisplayServerOSX::global_menu_remove_item(const String &p_menu_root, int p_idx) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ if ((menu == [NSApp mainMenu]) && (p_idx == 0)) { // Do not delete Apple menu.
+ return;
+ }
+ [menu removeItemAtIndex:p_idx];
+ }
+}
+
+void DisplayServerOSX::global_menu_clear(const String &p_menu_root) {
+ _THREAD_SAFE_METHOD_
+
+ NSMenu *menu = _get_menu_root(p_menu_root);
+ if (menu) {
+ [menu removeAllItems];
+ // Restore Apple menu.
+ if (menu == [NSApp mainMenu]) {
+ NSMenuItem *menu_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
+ [menu setSubmenu:apple_menu forItem:menu_item];
+ }
+ }
+}
+
+void DisplayServerOSX::alert(const String &p_alert, const String &p_title) {
+ _THREAD_SAFE_METHOD_
+
+ NSAlert *window = [[NSAlert alloc] init];
+ NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
+ NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()];
+
+ [window addButtonWithTitle:@"OK"];
+ [window setMessageText:ns_title];
+ [window setInformativeText:ns_alert];
+ [window setAlertStyle:NSAlertStyleWarning];
+
+ [window runModal];
+ [window release];
+}
+
+Error DisplayServerOSX::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
+ _THREAD_SAFE_METHOD_
+
+ NSAlert *window = [[NSAlert alloc] init];
+ NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
+ NSString *ns_description = [NSString stringWithUTF8String:p_description.utf8().get_data()];
+
+ for (int i = 0; i < p_buttons.size(); i++) {
+ NSString *ns_button = [NSString stringWithUTF8String:p_buttons[i].utf8().get_data()];
+ [window addButtonWithTitle:ns_button];
+ }
+ [window setMessageText:ns_title];
+ [window setInformativeText:ns_description];
+ [window setAlertStyle:NSAlertStyleInformational];
+
+ int button_pressed;
+ NSInteger ret = [window runModal];
+ if (ret == NSAlertFirstButtonReturn) {
+ button_pressed = 0;
+ } else if (ret == NSAlertSecondButtonReturn) {
+ button_pressed = 1;
+ } else if (ret == NSAlertThirdButtonReturn) {
+ button_pressed = 2;
+ } else {
+ button_pressed = 2 + (ret - NSAlertThirdButtonReturn);
+ }
+
+ if (!p_callback.is_null()) {
+ Variant button = button_pressed;
+ Variant *buttonp = &button;
+ Variant ret;
+ Callable::CallError ce;
+ p_callback.call((const Variant **)&buttonp, 1, ret, ce);
+ }
+
+ [window release];
+ return OK;
+}
+
+Error DisplayServerOSX::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
+ _THREAD_SAFE_METHOD_
+
+ NSAlert *window = [[NSAlert alloc] init];
+ NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
+ NSString *ns_description = [NSString stringWithUTF8String:p_description.utf8().get_data()];
+ NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 250, 30)];
+
+ [window addButtonWithTitle:@"OK"];
+ [window setMessageText:ns_title];
+ [window setInformativeText:ns_description];
+ [window setAlertStyle:NSAlertStyleInformational];
+
+ [input setStringValue:[NSString stringWithUTF8String:p_partial.utf8().get_data()]];
+ [window setAccessoryView:input];
+
+ [window runModal];
+
+ char *utfs = strdup([[input stringValue] UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+
+ if (!p_callback.is_null()) {
+ Variant text = ret;
+ Variant *textp = &text;
+ Variant ret;
+ Callable::CallError ce;
+ p_callback.call((const Variant **)&textp, 1, ret, ce);
+ }
+
+ [window release];
+ return OK;
+}
+
+void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) {
+ _THREAD_SAFE_METHOD_
+
+ if (p_mode == mouse_mode)
+ return;
+
+ if (p_mode == MOUSE_MODE_CAPTURED) {
+ // Apple Docs state that the display parameter is not used.
+ // "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
+ // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ } else if (p_mode == MOUSE_MODE_HIDDEN) {
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ } else {
+ CGDisplayShowCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
+
+ mouse_mode = p_mode;
+}
+
+DisplayServer::MouseMode DisplayServerOSX::mouse_get_mode() const {
+ return mouse_mode;
+}
+
+void DisplayServerOSX::mouse_warp_to_position(const Point2i &p_to) {
+ _THREAD_SAFE_METHOD_
+
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ last_mouse_pos = p_to;
+ } else {
+ WindowData &wd = windows[MAIN_WINDOW_ID];
+
+ //local point in window coords
+ const NSRect contentRect = [wd.window_view frame];
+ float displayScale = _display_scale([wd.window_object screen]);
+ NSRect pointInWindowRect = NSMakeRect(p_to.x / displayScale, contentRect.size.height - (p_to.y / displayScale) - 1, 0, 0);
+ NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin;
+
+ //point in scren coords
+ CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
+
+ //do the warping
+ CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
+ CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ CGWarpMouseCursorPosition(lMouseWarpPos);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
+}
+
+Point2i DisplayServerOSX::mouse_get_position() const {
+ return last_mouse_pos;
+}
+
+Point2i DisplayServerOSX::mouse_get_absolute_position() const {
+ _THREAD_SAFE_METHOD_
+
+ const NSPoint mouse_pos = [NSEvent mouseLocation];
+
+ for (NSScreen *screen in [NSScreen screens]) {
+ NSRect frame = [screen frame];
+ if (NSMouseInRect(mouse_pos, frame, NO)) {
+ return Vector2i((int)mouse_pos.x, (int)-mouse_pos.y) + _get_screens_origin();
+ }
+ }
+ return Vector2i();
+}
+
+int DisplayServerOSX::mouse_get_button_state() const {
+ return last_button_state;
+}
+
+void DisplayServerOSX::clipboard_set(const String &p_text) {
+ _THREAD_SAFE_METHOD_
+
+ NSString *copiedString = [NSString stringWithUTF8String:p_text.utf8().get_data()];
+ NSArray *copiedStringArray = [NSArray arrayWithObject:copiedString];
+
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ [pasteboard clearContents];
+ [pasteboard writeObjects:copiedStringArray];
+}
+
+String DisplayServerOSX::clipboard_get() const {
+ _THREAD_SAFE_METHOD_
+
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
+ NSDictionary *options = [NSDictionary dictionary];
+
+ BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
+
+ if (!ok) {
+ return "";
+ }
+
+ NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
+ NSString *string = [objectsToPaste objectAtIndex:0];
+
+ char *utfs = strdup([string UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+
+ return ret;
+}
+
+int DisplayServerOSX::get_screen_count() const {
+ _THREAD_SAFE_METHOD_
+
+ NSArray *screenArray = [NSScreen screens];
+ return [screenArray count];
+}
+
+// Returns the native top-left screen coordinate of the smallest rectangle
+// that encompasses all screens. Needed in get_screen_position(),
+// window_get_position, and window_set_position()
+// to convert between OS X native screen coordinates and the ones expected by Godot
+
+static bool displays_arrangement_dirty = true;
+static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) {
+ displays_arrangement_dirty = true;
+}
+
+float DisplayServerOSX::_display_scale(id screen) const {
+ if (OS_OSX::get_singleton()->is_hidpi_allowed()) {
+ if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
+ return fmax(1.0, [screen backingScaleFactor]);
+ }
+ }
+ return 1.0;
+}
+
+Point2i DisplayServerOSX::_get_screens_origin() const {
+ static Point2i origin;
+
+ if (displays_arrangement_dirty) {
+ origin = Point2i();
+
+ for (int i = 0; i < get_screen_count(); i++) {
+ Point2i position = _get_native_screen_position(i);
+ if (position.x < origin.x) {
+ origin.x = position.x;
+ }
+ if (position.y > origin.y) {
+ origin.y = position.y;
+ }
+ }
+ displays_arrangement_dirty = false;
+ }
+
+ return origin;
+}
+
+Point2i DisplayServerOSX::_get_native_screen_position(int p_screen) const {
+ NSArray *screenArray = [NSScreen screens];
+ if ((NSUInteger)p_screen < [screenArray count]) {
+ float display_scale = _display_scale([screenArray objectAtIndex:p_screen]);
+ NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
+ // Return the top-left corner of the screen, for OS X the y starts at the bottom
+ return Point2i(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * display_scale;
+ }
+
+ return Point2i();
+}
+
+Point2i DisplayServerOSX::screen_get_position(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
+ }
+
+ Point2i position = _get_native_screen_position(p_screen) - _get_screens_origin();
+ // OS X native y-coordinate relative to _get_screens_origin() is negative,
+ // Godot expects a positive value
+ position.y *= -1;
+ return position;
+}
+
+Size2i DisplayServerOSX::screen_get_size(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
+ }
+
+ NSArray *screenArray = [NSScreen screens];
+ if ((NSUInteger)p_screen < [screenArray count]) {
+ float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
+ // Note: Use frame to get the whole screen size
+ NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
+ return Size2i(nsrect.size.width, nsrect.size.height) * displayScale;
+ }
+
+ return Size2i();
+}
+
+int DisplayServerOSX::screen_get_dpi(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
+ }
+
+ NSArray *screenArray = [NSScreen screens];
+ if ((NSUInteger)p_screen < [screenArray count]) {
+ float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
+ NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
+ NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
+ CGSize displayPhysicalSize = CGDisplayScreenSize(
+ [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
+
+ return (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
+ }
+
+ return 96;
+}
+
+float DisplayServerOSX::screen_get_scale(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
+ }
+ NSArray *screenArray = [NSScreen screens];
+ if ((NSUInteger)p_screen < [screenArray count]) {
+ return _display_scale([screenArray objectAtIndex:p_screen]);
+ }
+
+ return 1.f;
+}
+
+Rect2i DisplayServerOSX::screen_get_usable_rect(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ if (p_screen == SCREEN_OF_MAIN_WINDOW) {
+ p_screen = window_get_current_screen();
+ }
+
+ NSArray *screenArray = [NSScreen screens];
+ if ((NSUInteger)p_screen < [screenArray count]) {
+ float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
+ NSRect nsrect = [[screenArray objectAtIndex:p_screen] visibleFrame];
+
+ Point2i position = Point2i(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * displayScale - _get_screens_origin();
+ position.y *= -1;
+ Size2i size = Size2i(nsrect.size.width, nsrect.size.height) / displayScale;
+
+ return Rect2i(position, size);
+ }
+
+ return Rect2i();
+}
+
+Vector<DisplayServer::WindowID> DisplayServerOSX::get_window_list() const {
+ _THREAD_SAFE_METHOD_
+
+ Vector<int> ret;
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ ret.push_back(E->key());
+ }
+ return ret;
+}
+
+DisplayServer::WindowID DisplayServerOSX::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
+ _THREAD_SAFE_METHOD_
+
+ WindowID id = _create_window(p_mode, p_rect);
+ WindowData &wd = windows[id];
+ for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
+ if (p_flags & (1 << i)) {
+ window_set_flag(WindowFlags(i), true, id);
+ }
+ }
+ [wd.window_object makeKeyAndOrderFront:nil];
+ return id;
+}
+
+void DisplayServerOSX::_send_window_event(const WindowData &wd, WindowEvent p_event) {
+ _THREAD_SAFE_METHOD_
+
+ if (!wd.event_callback.is_null()) {
+ Variant event = int(p_event);
+ Variant *eventp = &event;
+ Variant ret;
+ Callable::CallError ce;
+ wd.event_callback.call((const Variant **)&eventp, 1, ret, ce);
+ }
+}
+
+DisplayServerOSX::WindowID DisplayServerOSX::_find_window_id(id p_window) {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (E->get().window_object == p_window)
+ return E->key();
+ }
+ return INVALID_WINDOW_ID;
+}
+
+void DisplayServerOSX::_update_window(WindowData p_wd) {
+ bool borderless_full = false;
+
+ if (p_wd.borderless) {
+ NSRect frameRect = [p_wd.window_object frame];
+ NSRect screenRect = [[p_wd.window_object screen] frame];
+
+ // Check if our window covers up the screen
+ if (frameRect.origin.x <= screenRect.origin.x && frameRect.origin.y <= frameRect.origin.y &&
+ frameRect.size.width >= screenRect.size.width && frameRect.size.height >= screenRect.size.height) {
+ borderless_full = true;
+ }
+ }
+
+ if (borderless_full) {
+ // If the window covers up the screen set the level to above the main menu and hide on deactivate
+ [p_wd.window_object setLevel:NSMainMenuWindowLevel + 1];
+ [p_wd.window_object setHidesOnDeactivate:YES];
+ } else {
+ // Reset these when our window is not a borderless window that covers up the screen
+ [p_wd.window_object setLevel:NSNormalWindowLevel];
+ [p_wd.window_object setHidesOnDeactivate:NO];
+ }
+}
+
+void DisplayServerOSX::delete_sub_window(WindowID p_id) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_id));
+ ERR_FAIL_COND_MSG(p_id == MAIN_WINDOW_ID, "Main window can't be deleted");
+
+ WindowData &wd = windows[p_id];
+
+ [wd.window_object setContentView:nil];
+ [wd.window_object close];
+}
+
+void DisplayServerOSX::window_set_title(const String &p_title, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ [wd.window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
+}
+
+void DisplayServerOSX::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.rect_changed_callback = p_callable;
+}
+
+void DisplayServerOSX::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.event_callback = p_callable;
+}
+
+void DisplayServerOSX::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.input_event_callback = p_callable;
+}
+
+void DisplayServerOSX::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.input_text_callback = p_callable;
+}
+
+void DisplayServerOSX::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ wd.drop_files_callback = p_callable;
+}
+
+int DisplayServerOSX::window_get_current_screen(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND_V(!windows.has(p_window), -1);
+ const WindowData &wd = windows[p_window];
+
+ const NSUInteger index = [[NSScreen screens] indexOfObject:[wd.window_object screen]];
+ return (index == NSNotFound) ? 0 : index;
+}
+
+void DisplayServerOSX::window_set_current_screen(int p_screen, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+ Point2i wpos = window_get_position(p_window) - screen_get_position(window_get_current_screen(p_window));
+ window_set_position(wpos + screen_get_position(p_screen), p_window);
+}
+
+void DisplayServerOSX::window_set_transient(WindowID p_window, WindowID p_parent) {
+ _THREAD_SAFE_METHOD_
+ ERR_FAIL_COND(p_window == p_parent);
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd_window = windows[p_window];
+
+ ERR_FAIL_COND(wd_window.transient_parent == p_parent);
+
+ ERR_FAIL_COND_MSG(wd_window.on_top, "Windows with the 'on top' can't become transient.");
+ if (p_parent == INVALID_WINDOW_ID) {
+ //remove transient
+ ERR_FAIL_COND(wd_window.transient_parent == INVALID_WINDOW_ID);
+ ERR_FAIL_COND(!windows.has(wd_window.transient_parent));
+
+ WindowData &wd_parent = windows[wd_window.transient_parent];
+
+ wd_window.transient_parent = INVALID_WINDOW_ID;
+ wd_parent.transient_children.erase(p_window);
+
+ [wd_window.window_object setParentWindow:nil];
+ } else {
+ ERR_FAIL_COND(!windows.has(p_parent));
+ ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent");
+ WindowData &wd_parent = windows[p_parent];
+
+ wd_window.transient_parent = p_parent;
+ wd_parent.transient_children.insert(p_window);
+
+ [wd_window.window_object setParentWindow:wd_parent.window_object];
+ }
+}
+
+Point2i DisplayServerOSX::window_get_position(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
+ const WindowData &wd = windows[p_window];
+
+ NSRect nsrect = [wd.window_object frame];
+ Point2i pos;
+ float display_scale = _display_scale([wd.window_object screen]);
+
+ // Return the position of the top-left corner, for OS X the y starts at the bottom
+ pos.x = nsrect.origin.x * display_scale;
+ pos.y = (nsrect.origin.y + nsrect.size.height) * display_scale;
+ pos -= _get_screens_origin();
+ // OS X native y-coordinate relative to _get_screens_origin() is negative,
+ // Godot expects a positive value
+ pos.y *= -1;
+ return pos;
+}
+
+void DisplayServerOSX::window_set_position(const Point2i &p_position, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ Point2i position = p_position;
+ // OS X native y-coordinate relative to _get_screens_origin() is negative,
+ // Godot passes a positive value
+ position.y *= -1;
+ position += _get_screens_origin();
+
+ NSPoint pos;
+ float displayScale = _display_scale([wd.window_object screen]);
+
+ pos.x = position.x / displayScale;
+ pos.y = position.y / displayScale;
+
+ [wd.window_object setFrameTopLeftPoint:pos];
+
+ _update_window(wd);
+ _get_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream], displayScale);
+}
+
+void DisplayServerOSX::window_set_max_size(const Size2i p_size, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if ((p_size != Size2i()) && ((p_size.x < wd.min_size.x) || (p_size.y < wd.min_size.y))) {
+ ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
+ return;
+ }
+ wd.max_size = p_size;
+
+ if ((wd.max_size != Size2i()) && !wd.fullscreen) {
+ Size2i size = wd.max_size / _display_scale([wd.window_object screen]);
+ [wd.window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
+ } else {
+ [wd.window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
+ }
+}
+
+Size2i DisplayServerOSX::window_get_max_size(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+ return wd.max_size;
+}
+
+void DisplayServerOSX::window_set_min_size(const Size2i p_size, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if ((p_size != Size2i()) && (wd.max_size != Size2i()) && ((p_size.x > wd.max_size.x) || (p_size.y > wd.max_size.y))) {
+ ERR_PRINT("Minimum window size can't be larger than maximum window size!");
+ return;
+ }
+ wd.min_size = p_size;
+
+ if ((wd.min_size != Size2i()) && !wd.fullscreen) {
+ Size2i size = wd.min_size / _display_scale([wd.window_object screen]);
+ [wd.window_object setContentMinSize:NSMakeSize(size.x, size.y)];
+ } else {
+ [wd.window_object setContentMinSize:NSMakeSize(0, 0)];
+ }
+}
+
+Size2i DisplayServerOSX::window_get_min_size(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+
+ return wd.min_size;
+}
+
+void DisplayServerOSX::window_set_size(const Size2i p_size, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ Size2i size = p_size / _display_scale([wd.window_object screen]);
+
+ if (!wd.borderless) {
+ // NSRect used by setFrame includes the title bar, so add it to our size.y
+ CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ if (menuBarHeight != 0.f) {
+ size.y += menuBarHeight;
+ }
+ }
+
+ NSRect frame = [wd.window_object frame];
+ [wd.window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
+
+ _update_window(wd);
+}
+
+Size2i DisplayServerOSX::window_get_size(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+ return wd.size;
+}
+
+Size2i DisplayServerOSX::window_get_real_size(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+ NSRect frame = [wd.window_object frame];
+ return Size2i(frame.size.width, frame.size.height) * _display_scale([wd.window_object screen]);
+}
+
+bool DisplayServerOSX::window_is_maximize_allowed(WindowID p_window) const {
+ return true;
+}
+
+void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window) {
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if (!OS_OSX::get_singleton()->is_layered_allowed()) return;
+ if (wd.layered_window != p_enabled) {
+ if (p_enabled) {
+ [wd.window_object setBackgroundColor:[NSColor clearColor]];
+ [wd.window_object setOpaque:NO];
+ [wd.window_object setHasShadow:NO];
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ CALayer *layer = [wd.window_view layer];
+ [layer setOpaque:NO];
+ //TODO - implement transparency for Vulkan
+ }
+#endif
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ wd.context_gles2->set_opacity(0);
+ }
+#endif
+ wd.layered_window = true;
+ } else {
+ [wd.window_object setBackgroundColor:[NSColor colorWithCalibratedWhite:1 alpha:1]];
+ [wd.window_object setOpaque:YES];
+ [wd.window_object setHasShadow:YES];
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ CALayer *layer = [wd.window_view layer];
+ [layer setOpaque:YES];
+ //TODO - implement transparency for Vulkan
+ }
+#endif
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ wd.context_gles2->set_opacity(1);
+ }
+#endif
+ wd.layered_window = false;
+ }
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ wd.context_gles2->update();
+ }
+#endif
+ NSRect frameRect = [wd.window_object frame];
+ [wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:YES];
+ [wd.window_object setFrame:frameRect display:YES];
+ }
+}
+
+void DisplayServerOSX::window_set_mode(WindowMode p_mode, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ WindowMode old_mode = window_get_mode(p_window);
+ if (old_mode == p_mode) {
+ return; // do nothing
+ }
+
+ switch (old_mode) {
+ case WINDOW_MODE_WINDOWED: {
+ //do nothing
+ } break;
+ case WINDOW_MODE_MINIMIZED: {
+ [wd.window_object deminiaturize:nil];
+ } break;
+ case WINDOW_MODE_FULLSCREEN: {
+ if (wd.layered_window)
+ _set_window_per_pixel_transparency_enabled(true, p_window);
+ if (wd.resize_disabled) //restore resize disabled
+ [wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
+ if (wd.min_size != Size2i()) {
+ Size2i size = wd.min_size / _display_scale([wd.window_object screen]);
+ [wd.window_object setContentMinSize:NSMakeSize(size.x, size.y)];
+ }
+ if (wd.max_size != Size2i()) {
+ Size2i size = wd.max_size / _display_scale([wd.window_object screen]);
+ [wd.window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
+ }
+ [wd.window_object toggleFullScreen:nil];
+ wd.fullscreen = false;
+ } break;
+ case WINDOW_MODE_MAXIMIZED: {
+ if ([wd.window_object isZoomed]) {
+ [wd.window_object zoom:nil];
+ }
+ } break;
+ }
+
+ switch (p_mode) {
+ case WINDOW_MODE_WINDOWED: {
+ //do nothing
+ } break;
+ case WINDOW_MODE_MINIMIZED: {
+ [wd.window_object performMiniaturize:nil];
+ } break;
+ case WINDOW_MODE_FULLSCREEN: {
+ if (wd.layered_window)
+ _set_window_per_pixel_transparency_enabled(false, p_window);
+ if (wd.resize_disabled) //fullscreen window should be resizable to work
+ [wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskResizable];
+ [wd.window_object setContentMinSize:NSMakeSize(0, 0)];
+ [wd.window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
+ [wd.window_object toggleFullScreen:nil];
+ wd.fullscreen = true;
+ } break;
+ case WINDOW_MODE_MAXIMIZED: {
+ if (![wd.window_object isZoomed]) {
+ [wd.window_object zoom:nil];
+ }
+ } break;
+ }
+}
+
+DisplayServer::WindowMode DisplayServerOSX::window_get_mode(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED);
+ const WindowData &wd = windows[p_window];
+
+ if (wd.fullscreen) { //if fullscreen, it's not in another mode
+ return WINDOW_MODE_FULLSCREEN;
+ }
+ if ([wd.window_object isZoomed] && !wd.resize_disabled) {
+ return WINDOW_MODE_MAXIMIZED;
+ }
+ if ([wd.window_object respondsToSelector:@selector(isMiniaturized)]) {
+ if ([wd.window_object isMiniaturized]) {
+ return WINDOW_MODE_MINIMIZED;
+ }
+ }
+
+ // all other discarded, return windowed.
+ return WINDOW_MODE_WINDOWED;
+}
+
+void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ switch (p_flag) {
+ case WINDOW_FLAG_RESIZE_DISABLED: {
+ wd.resize_disabled = p_enabled;
+ if (wd.fullscreen) //fullscreen window should be resizable, style will be applyed on exiting fs
+ return;
+ if (p_enabled) {
+ [wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
+ } else {
+ [wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskResizable];
+ }
+ } break;
+ case WINDOW_FLAG_BORDERLESS: {
+ // OrderOut prevents a lose focus bug with the window
+ [wd.window_object orderOut:nil];
+ wd.borderless = p_enabled;
+ if (p_enabled) {
+ [wd.window_object setStyleMask:NSWindowStyleMaskBorderless];
+ } else {
+ if (wd.layered_window)
+ _set_window_per_pixel_transparency_enabled(false, p_window);
+ [wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
+ // Force update of the window styles
+ NSRect frameRect = [wd.window_object frame];
+ [wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
+ [wd.window_object setFrame:frameRect display:NO];
+ }
+ _update_window(wd);
+ [wd.window_object makeKeyAndOrderFront:nil];
+ } break;
+ case WINDOW_FLAG_ALWAYS_ON_TOP: {
+ wd.on_top = p_enabled;
+ if (p_enabled) {
+ [wd.window_object setLevel:NSFloatingWindowLevel];
+ } else {
+ [wd.window_object setLevel:NSNormalWindowLevel];
+ }
+ } break;
+ case WINDOW_FLAG_TRANSPARENT: {
+ wd.layered_window = p_enabled;
+ if (p_enabled) {
+ [wd.window_object setStyleMask:NSWindowStyleMaskBorderless]; // force borderless
+ } else if (!wd.borderless) {
+ [wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
+ }
+ _set_window_per_pixel_transparency_enabled(p_enabled, p_window);
+
+ } break;
+ default: {
+ }
+ }
+}
+
+bool DisplayServerOSX::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), false);
+ const WindowData &wd = windows[p_window];
+
+ switch (p_flag) {
+ case WINDOW_FLAG_RESIZE_DISABLED: {
+ return wd.resize_disabled;
+ } break;
+ case WINDOW_FLAG_BORDERLESS: {
+ return [wd.window_object styleMask] == NSWindowStyleMaskBorderless;
+ } break;
+ case WINDOW_FLAG_ALWAYS_ON_TOP: {
+ return [wd.window_object level] == NSFloatingWindowLevel;
+ } break;
+ case WINDOW_FLAG_TRANSPARENT: {
+ return wd.layered_window;
+ } break;
+ default: {
+ }
+ }
+
+ return false;
+}
+
+void DisplayServerOSX::window_request_attention(WindowID p_window) {
+ // It's app global, ignore window id.
+ [NSApp requestUserAttention:NSCriticalRequest];
+}
+
+void DisplayServerOSX::window_move_to_foreground(WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ const WindowData &wd = windows[p_window];
+
+ [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
+ [wd.window_object makeKeyAndOrderFront:nil];
+}
+
+bool DisplayServerOSX::window_can_draw(WindowID p_window) const {
+ return window_get_mode(p_window) != WINDOW_MODE_MINIMIZED;
+}
+
+bool DisplayServerOSX::can_any_window_draw() const {
+ _THREAD_SAFE_METHOD_
+
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (window_get_mode(E->key()) != WINDOW_MODE_MINIMIZED) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void DisplayServerOSX::window_set_ime_active(const bool p_active, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ wd.im_active = p_active;
+
+ if (!p_active)
+ [wd.window_view cancelComposition];
+}
+
+void DisplayServerOSX::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ wd.im_position = p_pos;
+}
+
+bool DisplayServerOSX::get_swap_ok_cancel() {
+ return true;
+}
+
+void DisplayServerOSX::cursor_set_shape(CursorShape p_shape) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
+
+ if (cursor_shape == p_shape)
+ return;
+
+ if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
+ cursor_shape = p_shape;
+ return;
+ }
+
+ if (cursors[p_shape] != NULL) {
+ [cursors[p_shape] set];
+ } else {
+ switch (p_shape) {
+ case CURSOR_ARROW: [[NSCursor arrowCursor] set]; break;
+ case CURSOR_IBEAM: [[NSCursor IBeamCursor] set]; break;
+ case CURSOR_POINTING_HAND: [[NSCursor pointingHandCursor] set]; break;
+ case CURSOR_CROSS: [[NSCursor crosshairCursor] set]; break;
+ case CURSOR_WAIT: [[NSCursor arrowCursor] set]; break;
+ case CURSOR_BUSY: [[NSCursor arrowCursor] set]; break;
+ case CURSOR_DRAG: [[NSCursor closedHandCursor] set]; break;
+ case CURSOR_CAN_DROP: [[NSCursor openHandCursor] set]; break;
+ case CURSOR_FORBIDDEN: [[NSCursor operationNotAllowedCursor] set]; break;
+ case CURSOR_VSIZE: [_cursorFromSelector(@selector(_windowResizeNorthSouthCursor), @selector(resizeUpDownCursor)) set]; break;
+ case CURSOR_HSIZE: [_cursorFromSelector(@selector(_windowResizeEastWestCursor), @selector(resizeLeftRightCursor)) set]; break;
+ case CURSOR_BDIAGSIZE: [_cursorFromSelector(@selector(_windowResizeNorthEastSouthWestCursor)) set]; break;
+ case CURSOR_FDIAGSIZE: [_cursorFromSelector(@selector(_windowResizeNorthWestSouthEastCursor)) set]; break;
+ case CURSOR_MOVE: [[NSCursor arrowCursor] set]; break;
+ case CURSOR_VSPLIT: [[NSCursor resizeUpDownCursor] set]; break;
+ case CURSOR_HSPLIT: [[NSCursor resizeLeftRightCursor] set]; break;
+ case CURSOR_HELP: [_cursorFromSelector(@selector(_helpCursor)) set]; break;
+ default: {
+ }
+ }
+ }
+
+ cursor_shape = p_shape;
+}
+
+DisplayServerOSX::CursorShape DisplayServerOSX::cursor_get_shape() const {
+ return cursor_shape;
+}
+
+void DisplayServerOSX::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+ _THREAD_SAFE_METHOD_
+
+ if (p_cursor.is_valid()) {
+ Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ cursor_set_shape(p_shape);
+ return;
+ }
+ cursors_cache.erase(p_shape);
+ }
+
+ Ref<Texture2D> texture = p_cursor;
+ Ref<AtlasTexture> atlas_texture = p_cursor;
+ Ref<Image> image;
+ Size2 texture_size;
+ Rect2 atlas_rect;
+
+ if (texture.is_valid()) {
+ image = texture->get_data();
+ }
+
+ if (!image.is_valid() && atlas_texture.is_valid()) {
+ texture = atlas_texture->get_atlas();
+
+ atlas_rect.size.width = texture->get_width();
+ atlas_rect.size.height = texture->get_height();
+ atlas_rect.position.x = atlas_texture->get_region().position.x;
+ atlas_rect.position.y = atlas_texture->get_region().position.y;
+
+ texture_size.width = atlas_texture->get_region().size.x;
+ texture_size.height = atlas_texture->get_region().size.y;
+ } else if (image.is_valid()) {
+ texture_size.width = texture->get_width();
+ texture_size.height = texture->get_height();
+ }
+
+ ERR_FAIL_COND(!texture.is_valid());
+ ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0);
+ ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256);
+ ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height);
+
+ image = texture->get_data();
+
+ ERR_FAIL_COND(!image.is_valid());
+
+ NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:NULL
+ pixelsWide:int(texture_size.width)
+ pixelsHigh:int(texture_size.height)
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:int(texture_size.width) * 4
+ bitsPerPixel:32];
+
+ ERR_FAIL_COND(imgrep == nil);
+ uint8_t *pixels = [imgrep bitmapData];
+
+ int len = int(texture_size.width * texture_size.height);
+
+ for (int i = 0; i < len; i++) {
+ int row_index = floor(i / texture_size.width) + atlas_rect.position.y;
+ int column_index = (i % int(texture_size.width)) + atlas_rect.position.x;
+
+ if (atlas_texture.is_valid()) {
+ column_index = MIN(column_index, atlas_rect.size.width - 1);
+ row_index = MIN(row_index, atlas_rect.size.height - 1);
+ }
+
+ uint32_t color = image->get_pixel(column_index, row_index).to_argb32();
+
+ uint8_t alpha = (color >> 24) & 0xFF;
+ pixels[i * 4 + 0] = ((color >> 16) & 0xFF) * alpha / 255;
+ pixels[i * 4 + 1] = ((color >> 8) & 0xFF) * alpha / 255;
+ pixels[i * 4 + 2] = ((color)&0xFF) * alpha / 255;
+ pixels[i * 4 + 3] = alpha;
+ }
+
+ NSImage *nsimage = [[NSImage alloc] initWithSize:NSMakeSize(texture_size.width, texture_size.height)];
+ [nsimage addRepresentation:imgrep];
+
+ NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)];
+
+ [cursors[p_shape] release];
+ cursors[p_shape] = cursor;
+
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
+ if (p_shape == cursor_shape) {
+ if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
+ [cursor set];
+ }
+ }
+
+ [imgrep release];
+ [nsimage release];
+ } else {
+ // Reset to default system cursor
+ if (cursors[p_shape] != NULL) {
+ [cursors[p_shape] release];
+ cursors[p_shape] = NULL;
+ }
+
+ CursorShape c = cursor_shape;
+ cursor_shape = CURSOR_MAX;
+ cursor_set_shape(c);
+
+ cursors_cache.erase(p_shape);
+ }
+}
+
+static bool keyboard_layout_dirty = true;
+static void keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) {
+ keyboard_layout_dirty = true;
+}
+
+// Returns string representation of keys, if they are printable.
+static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
+ TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
+ if (!currentKeyboard)
+ return nil;
+
+ CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
+ if (!layoutData)
+ return nil;
+
+ const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
+
+ OSStatus err;
+ CFMutableStringRef output = CFStringCreateMutable(NULL, 0);
+
+ for (int i = 0; i < length; ++i) {
+ UInt32 keysDown = 0;
+ UniChar chars[4];
+ UniCharCount realLength;
+
+ err = UCKeyTranslate(keyboardLayout,
+ keyCode[i],
+ kUCKeyActionDisplay,
+ 0,
+ LMGetKbdType(),
+ kUCKeyTranslateNoDeadKeysBit,
+ &keysDown,
+ sizeof(chars) / sizeof(chars[0]),
+ &realLength,
+ chars);
+
+ if (err != noErr) {
+ CFRelease(output);
+ return nil;
+ }
+
+ CFStringAppendCharacters(output, chars, 1);
+ }
+
+ return (NSString *)output;
+}
+
+DisplayServerOSX::LatinKeyboardVariant DisplayServerOSX::get_latin_keyboard_variant() const {
+ _THREAD_SAFE_METHOD_
+
+ static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
+
+ if (keyboard_layout_dirty) {
+
+ layout = LATIN_KEYBOARD_QWERTY;
+
+ CGKeyCode keys[] = { kVK_ANSI_Q, kVK_ANSI_W, kVK_ANSI_E, kVK_ANSI_R, kVK_ANSI_T, kVK_ANSI_Y };
+ NSString *test = createStringForKeys(keys, 6);
+
+ if ([test isEqualToString:@"qwertz"]) {
+ layout = LATIN_KEYBOARD_QWERTZ;
+ } else if ([test isEqualToString:@"azerty"]) {
+ layout = LATIN_KEYBOARD_AZERTY;
+ } else if ([test isEqualToString:@"qzerty"]) {
+ layout = LATIN_KEYBOARD_QZERTY;
+ } else if ([test isEqualToString:@"',.pyf"]) {
+ layout = LATIN_KEYBOARD_DVORAK;
+ } else if ([test isEqualToString:@"xvlcwk"]) {
+ layout = LATIN_KEYBOARD_NEO;
+ } else if ([test isEqualToString:@"qwfpgj"]) {
+ layout = LATIN_KEYBOARD_COLEMAK;
+ }
+
+ [test release];
+
+ keyboard_layout_dirty = false;
+ return layout;
+ }
+
+ return layout;
+}
+
+void DisplayServerOSX::_push_input(const Ref<InputEvent> &p_event) {
+ Ref<InputEvent> ev = p_event;
+ InputFilter::get_singleton()->accumulate_input_event(ev);
+}
+
+void DisplayServerOSX::_release_pressed_events() {
+ _THREAD_SAFE_METHOD_
+ if (InputFilter::get_singleton()) {
+ InputFilter::get_singleton()->release_pressed_events();
+ }
+}
+
+void DisplayServerOSX::_process_key_events() {
+ Ref<InputEventKey> k;
+ for (int i = 0; i < key_event_pos; i++) {
+ const KeyEvent &ke = key_event_buffer[i];
+ if (ke.raw) {
+ // Non IME input - no composite characters, pass events as is
+ k.instance();
+
+ k->set_window_id(ke.window_id);
+ _get_key_modifier_state(ke.osx_state, k);
+ k->set_pressed(ke.pressed);
+ k->set_echo(ke.echo);
+ k->set_keycode(ke.keycode);
+ k->set_physical_keycode(ke.physical_keycode);
+ k->set_unicode(ke.unicode);
+
+ _push_input(k);
+ } else {
+ // IME input
+ if ((i == 0 && ke.keycode == 0) || (i > 0 && key_event_buffer[i - 1].keycode == 0)) {
+ k.instance();
+
+ k->set_window_id(ke.window_id);
+ _get_key_modifier_state(ke.osx_state, k);
+ k->set_pressed(ke.pressed);
+ k->set_echo(ke.echo);
+ k->set_keycode(0);
+ k->set_physical_keycode(0);
+ k->set_unicode(ke.unicode);
+
+ _push_input(k);
+ }
+ if (ke.keycode != 0) {
+ k.instance();
+
+ k->set_window_id(ke.window_id);
+ _get_key_modifier_state(ke.osx_state, k);
+ k->set_pressed(ke.pressed);
+ k->set_echo(ke.echo);
+ k->set_keycode(ke.keycode);
+ k->set_physical_keycode(ke.physical_keycode);
+
+ if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) {
+ k->set_unicode(key_event_buffer[i + 1].unicode);
+ }
+
+ _push_input(k);
+ }
+ }
+ }
+
+ key_event_pos = 0;
+}
+
+void DisplayServerOSX::process_events() {
+ _THREAD_SAFE_METHOD_
+
+ while (true) {
+ NSEvent *event = [NSApp
+ nextEventMatchingMask:NSEventMaskAny
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+
+ if (event == nil)
+ break;
+
+ [NSApp sendEvent:event];
+ }
+
+ if (!drop_events) {
+ _process_key_events();
+ InputFilter::get_singleton()->flush_accumulated_events();
+ }
+
+ [autoreleasePool drain];
+ autoreleasePool = [[NSAutoreleasePool alloc] init];
+}
+
+void DisplayServerOSX::force_process_and_drop_events() {
+ _THREAD_SAFE_METHOD_
+
+ drop_events = true;
+ process_events();
+ drop_events = false;
+}
+
+void DisplayServerOSX::set_native_icon(const String &p_filename) {
+ _THREAD_SAFE_METHOD_
+
+ FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
+ ERR_FAIL_COND(!f);
+
+ Vector<uint8_t> data;
+ uint32_t len = f->get_len();
+ data.resize(len);
+ f->get_buffer((uint8_t *)&data.write[0], len);
+ memdelete(f);
+
+ NSData *icon_data = [[[NSData alloc] initWithBytes:&data.write[0] length:len] autorelease];
+ ERR_FAIL_COND_MSG(!icon_data, "Error reading icon data.");
+
+ NSImage *icon = [[[NSImage alloc] initWithData:icon_data] autorelease];
+ ERR_FAIL_COND_MSG(!icon, "Error loading icon.");
+
+ [NSApp setApplicationIconImage:icon];
+}
+
+void DisplayServerOSX::set_icon(const Ref<Image> &p_icon) {
+ _THREAD_SAFE_METHOD_
+
+ Ref<Image> img = p_icon;
+ img = img->duplicate();
+ img->convert(Image::FORMAT_RGBA8);
+ NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:NULL
+ pixelsWide:img->get_width()
+ pixelsHigh:img->get_height()
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:img->get_width() * 4
+ bitsPerPixel:32];
+ ERR_FAIL_COND(imgrep == nil);
+ uint8_t *pixels = [imgrep bitmapData];
+
+ int len = img->get_width() * img->get_height();
+ const uint8_t *r = img->get_data().ptr();
+
+ /* Premultiply the alpha channel */
+ for (int i = 0; i < len; i++) {
+ uint8_t alpha = r[i * 4 + 3];
+ pixels[i * 4 + 0] = (uint8_t)(((uint16_t)r[i * 4 + 0] * alpha) / 255);
+ pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
+ pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
+ pixels[i * 4 + 3] = alpha;
+ }
+
+ NSImage *nsimg = [[NSImage alloc] initWithSize:NSMakeSize(img->get_width(), img->get_height())];
+ ERR_FAIL_COND(nsimg == nil);
+
+ [nsimg addRepresentation:imgrep];
+ [NSApp setApplicationIconImage:nsimg];
+
+ [imgrep release];
+ [nsimg release];
+}
+
+Vector<String> DisplayServerOSX::get_rendering_drivers_func() {
+ Vector<String> drivers;
+
+#ifdef VULKAN_ENABLED
+ drivers.push_back("vulkan");
+#endif
+#ifdef OPENGL_ENABLED
+ drivers.push_back("opengl");
+#endif
+
+ return drivers;
+}
+
+Point2i DisplayServerOSX::ime_get_selection() const {
+ return im_selection;
+}
+
+String DisplayServerOSX::ime_get_text() const {
+ return im_text;
+}
+
+DisplayServer::WindowID DisplayServerOSX::get_window_at_screen_position(const Point2i &p_position) const {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ Rect2i win_rect = Rect2i(window_get_position(E->key()), window_get_size(E->key()));
+ if (win_rect.has_point(p_position)) {
+ return E->key();
+ }
+ }
+ return INVALID_WINDOW_ID;
+}
+
+void DisplayServerOSX::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].instance_id = p_instance;
+}
+
+ObjectID DisplayServerOSX::window_get_attached_instance_id(WindowID p_window) const {
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), ObjectID());
+ return windows[p_window].instance_id;
+}
+
+DisplayServer *DisplayServerOSX::create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
+ return memnew(DisplayServerOSX(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
+}
+
+DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, const Rect2i &p_rect) {
+ WindowID id;
+ {
+ WindowData wd;
+
+ float displayScale = 1.0;
+ if (OS_OSX::get_singleton()->is_hidpi_allowed()) {
+ // note that mainScreen is not screen #0 but the one with the keyboard focus.
+ NSScreen *screen = [NSScreen mainScreen];
+ if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = fmax(displayScale, [screen backingScaleFactor]);
+ }
+ }
+
+ wd.window_delegate = [[GodotWindowDelegate alloc] init];
+ ERR_FAIL_COND_V_MSG(wd.window_delegate == nil, INVALID_WINDOW_ID, "Can't create a window delegate");
+ [wd.window_delegate setWindowID:window_id_counter];
+
+ Point2i position = p_rect.position;
+ // OS X native y-coordinate relative to _get_screens_origin() is negative,
+ // Godot passes a positive value
+ position.y *= -1;
+ position += _get_screens_origin();
+
+ // initWithContentRect uses bottom-left corner of the window’s frame as origin.
+ wd.window_object = [[GodotWindow alloc]
+ initWithContentRect:NSMakeRect(position.x / displayScale, (position.y - p_rect.size.height) / displayScale, p_rect.size.width / displayScale, p_rect.size.height / displayScale)
+ styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
+ backing:NSBackingStoreBuffered
+ defer:NO];
+ ERR_FAIL_COND_V_MSG(wd.window_object == nil, INVALID_WINDOW_ID, "Can't create a window");
+
+ wd.window_view = [[GodotContentView alloc] init];
+ ERR_FAIL_COND_V_MSG(wd.window_view == nil, INVALID_WINDOW_ID, "Can't create a window view");
+ [wd.window_view setWindowID:window_id_counter];
+ if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) {
+ [wd.window_view setWantsLayer:TRUE];
+ }
+
+ if (displayScale > 1.0) {
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ [wd.window_view setWantsBestResolutionOpenGLSurface:YES];
+ }
+#endif
+ [wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ } else {
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ [wd.window_view setWantsBestResolutionOpenGLSurface:NO];
+ }
+#endif
+ }
+
+ [wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ [wd.window_object setContentView:wd.window_view];
+ [wd.window_object setDelegate:wd.window_delegate];
+ [wd.window_object setAcceptsMouseMovedEvents:YES];
+ [wd.window_object setRestorable:NO];
+
+ if ([wd.window_object respondsToSelector:@selector(setTabbingMode:)])
+ [wd.window_object setTabbingMode:NSWindowTabbingModeDisallowed];
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
+ CALayer *layer = [wd.window_view layer];
+ layer.contentsScale = displayScale;
+ Error err = context_vulkan->window_create(window_id_counter, wd.window_view, p_rect.size.width, p_rect.size.height);
+ ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan context");
+ }
+ }
+#endif
+#ifdef OPENGL_ENABLED
+ if (rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ wd.context_gles2 = memnew(ContextGL_OSX(wd.window_view, false));
+
+ if (wd.context_gles2->initialize() != OK) {
+ memdelete(wd.context_gles2);
+ ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a OpenGL context");
+ }
+
+ //if (RasterizerGLES2::is_viable() == OK) {
+ // RasterizerGLES2::register_config();
+ // RasterizerGLES2::make_current();
+ //}
+ }
+#endif
+ id = window_id_counter++;
+ windows[id] = wd;
+ }
+
+ WindowData &wd = windows[id];
+ window_set_mode(p_mode, id);
+
+ float displayScale = _display_scale([wd.window_object screen]);
+ const NSRect contentRect = [wd.window_view frame];
+ wd.size.width = contentRect.size.width * displayScale;
+ wd.size.height = contentRect.size.height * displayScale;
+
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ if (OS_OSX::singleton->is_hidpi_allowed()) {
+ [wd.window_view setWantsBestResolutionOpenGLSurface:YES];
+ } else {
+ [wd.window_view setWantsBestResolutionOpenGLSurface:NO];
+ }
+ wd.context_gles2->update();
+ }
+#endif
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ CALayer *layer = [wd.window_view layer];
+ layer.contentsScale = displayScale;
+ context_vulkan->window_resize(id, wd.size.width, wd.size.height);
+ }
+#endif
+
+ return id;
+}
+
+void DisplayServerOSX::_dispatch_input_events(const Ref<InputEvent> &p_event) {
+ ((DisplayServerOSX *)(get_singleton()))->_dispatch_input_event(p_event);
+}
+
+void DisplayServerOSX::_dispatch_input_event(const Ref<InputEvent> &p_event) {
+ _THREAD_SAFE_METHOD_
+ if (!in_dispatch_input_event) {
+ in_dispatch_input_event = true;
+
+ Variant ev = p_event;
+ Variant *evp = &ev;
+ Variant ret;
+ Callable::CallError ce;
+
+ Ref<InputEventFromWindow> event_from_window = p_event;
+ if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
+ //send to a window
+ if (windows.has(event_from_window->get_window_id())) {
+ Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
+ if (callable.is_null()) {
+ return;
+ }
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
+ } else {
+ //send to all windows
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ Callable callable = E->get().input_event_callback;
+ if (callable.is_null()) {
+ continue;
+ }
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
+ }
+
+ in_dispatch_input_event = false;
+ }
+}
+
+void DisplayServerOSX::release_rendering_thread() {
+ //TODO - reimplement OpenGLES
+}
+
+void DisplayServerOSX::make_rendering_thread() {
+ //TODO - reimplement OpenGLES
+}
+
+void DisplayServerOSX::swap_buffers() {
+ //TODO - reimplement OpenGLES
+}
+
+void DisplayServerOSX::console_set_visible(bool p_enabled) {
+ //TODO - open terminal and redirect
+}
+
+bool DisplayServerOSX::is_console_visible() const {
+ return isatty(STDIN_FILENO);
+}
+
+DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
+ InputFilter::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
+
+ r_error = OK;
+ drop_events = false;
+
+ memset(cursors, 0, sizeof(cursors));
+ cursor_shape = CURSOR_ARROW;
+
+ key_event_pos = 0;
+ mouse_mode = MOUSE_MODE_VISIBLE;
+ last_button_state = 0;
+
+ autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+ eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
+ ERR_FAIL_COND(!eventSource);
+
+ CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0);
+
+ // Implicitly create shared NSApplication instance
+ [GodotApplication sharedApplication];
+
+ // In case we are unbundled, make us a proper UI application
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ keyboard_layout_dirty = true;
+ displays_arrangement_dirty = true;
+
+ // Register to be notified on keyboard layout changes
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
+ NULL, keyboard_layout_changed,
+ kTISNotifySelectedKeyboardInputSourceChanged, NULL,
+ CFNotificationSuspensionBehaviorDeliverImmediately);
+
+ // Register to be notified on displays arrangement changes
+ CGDisplayRegisterReconfigurationCallback(displays_arrangement_changed, NULL);
+
+ // Menu bar setup must go between sharedApplication above and
+ // finishLaunching below, in order to properly emulate the behavior
+ // of NSApplicationMain
+ NSMenuItem *menu_item;
+ NSString *title;
+
+ NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
+ if (nsappname == nil)
+ nsappname = [[NSProcessInfo processInfo] processName];
+
+ // Setup Dock menu
+ dock_menu = [[NSMenu alloc] initWithTitle:@"_dock"];
+
+ // Setup Apple menu
+ apple_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
+ title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
+ [apple_menu addItemWithTitle:title action:@selector(showAbout:) keyEquivalent:@""];
+
+ [apple_menu addItem:[NSMenuItem separatorItem]];
+
+ NSMenu *services = [[NSMenu alloc] initWithTitle:@""];
+ menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Services", nil) action:nil keyEquivalent:@""];
+ [apple_menu setSubmenu:services forItem:menu_item];
+ [NSApp setServicesMenu:services];
+ [services release];
+
+ [apple_menu addItem:[NSMenuItem separatorItem]];
+
+ title = [NSString stringWithFormat:NSLocalizedString(@"Hide %@", nil), nsappname];
+ [apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
+
+ menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
+ [menu_item setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)];
+
+ [apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
+
+ [apple_menu addItem:[NSMenuItem separatorItem]];
+
+ title = [NSString stringWithFormat:NSLocalizedString(@"Quit %@", nil), nsappname];
+ [apple_menu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+
+ // Setup menu bar
+ NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
+ menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
+ [main_menu setSubmenu:apple_menu forItem:menu_item];
+ [NSApp setMainMenu:main_menu];
+
+ [NSApp finishLaunching];
+
+ delegate = [[GodotApplicationDelegate alloc] init];
+ ERR_FAIL_COND(!delegate);
+ [NSApp setDelegate:delegate];
+
+ //process application:openFile: event
+ while (true) {
+ NSEvent *event = [NSApp
+ nextEventMatchingMask:NSEventMaskAny
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+
+ if (event == nil)
+ break;
+
+ [NSApp sendEvent:event];
+ }
+
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!
+ //TODO - do Vulkan and GLES2 support checks, driver selection and fallback
+ rendering_driver = p_rendering_driver;
+
+#ifndef _MSC_VER
+#warning Forcing vulkan rendering driver because OpenGL not implemented yet
+#endif
+ rendering_driver = "vulkan";
+
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver == "opengl_es") {
+ //TODO - reimplement OpenGLES
+ }
+#endif
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+
+ context_vulkan = memnew(VulkanContextOSX);
+ if (context_vulkan->initialize() != OK) {
+ memdelete(context_vulkan);
+ context_vulkan = NULL;
+ r_error = ERR_CANT_CREATE;
+ ERR_FAIL_MSG("Could not initialize Vulkan");
+ }
+ }
+#endif
+
+ WindowID main_window = _create_window(p_mode, Rect2i(Point2i(), p_resolution));
+ for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
+ if (p_flags & (1 << i)) {
+ window_set_flag(WindowFlags(i), true, main_window);
+ }
+ }
+ [windows[main_window].window_object makeKeyAndOrderFront:nil];
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ rendering_device_vulkan = memnew(RenderingDeviceVulkan);
+ rendering_device_vulkan->initialize(context_vulkan);
+
+ RasterizerRD::make_current();
+ }
+#endif
+
+ [NSApp activateIgnoringOtherApps:YES];
+
+ /*
+ visual_server = memnew(VisualServerRaster);
+ if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
+ visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
+ }
+ visual_server->init();
+ */
+}
+
+DisplayServerOSX::~DisplayServerOSX() {
+ if (dock_menu) {
+ [dock_menu release];
+ }
+
+ for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) {
+ [E->get() release];
+ }
+
+ //destroy all windows
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ [E->get().window_object setContentView:nil];
+ [E->get().window_object close];
+ }
+
+ //destroy drivers
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ }
+
+ if (context_vulkan)
+ memdelete(context_vulkan);
+ }
+#endif
+
+ CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
+ CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
+
+ cursors_cache.clear();
+
+ //visual_server->finish();
+ //memdelete(visual_server);
+}
+
+void DisplayServerOSX::register_osx_driver() {
+ register_create_function("osx", create_func, get_rendering_drivers_func);
+}
diff --git a/platform/osx/export/export.h b/platform/osx/export/export.h
index 7b8832cb01..4ddcec09fb 100644
--- a/platform/osx/export/export.h
+++ b/platform/osx/export/export.h
@@ -28,4 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef OSX_EXPORT_H
+#define OSX_EXPORT_H
+
void register_osx_exporter();
+
+#endif // OSX_EXPORT_H
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index e9f46fb5a4..f2d9de6fbd 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -395,38 +395,38 @@ bool joypad::check_ff_features() {
static int process_hat_value(int p_min, int p_max, int p_value) {
int range = (p_max - p_min + 1);
int value = p_value - p_min;
- int hat_value = InputDefault::HAT_MASK_CENTER;
+ int hat_value = InputFilter::HAT_MASK_CENTER;
if (range == 4) {
value *= 2;
}
switch (value) {
case 0:
- hat_value = InputDefault::HAT_MASK_UP;
+ hat_value = InputFilter::HAT_MASK_UP;
break;
case 1:
- hat_value = InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_RIGHT;
+ hat_value = InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_RIGHT;
break;
case 2:
- hat_value = InputDefault::HAT_MASK_RIGHT;
+ hat_value = InputFilter::HAT_MASK_RIGHT;
break;
case 3:
- hat_value = InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_RIGHT;
+ hat_value = InputFilter::HAT_MASK_DOWN | InputFilter::HAT_MASK_RIGHT;
break;
case 4:
- hat_value = InputDefault::HAT_MASK_DOWN;
+ hat_value = InputFilter::HAT_MASK_DOWN;
break;
case 5:
- hat_value = InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_LEFT;
+ hat_value = InputFilter::HAT_MASK_DOWN | InputFilter::HAT_MASK_LEFT;
break;
case 6:
- hat_value = InputDefault::HAT_MASK_LEFT;
+ hat_value = InputFilter::HAT_MASK_LEFT;
break;
case 7:
- hat_value = InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_LEFT;
+ hat_value = InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_LEFT;
break;
default:
- hat_value = InputDefault::HAT_MASK_CENTER;
+ hat_value = InputFilter::HAT_MASK_CENTER;
break;
}
return hat_value;
@@ -438,8 +438,8 @@ void JoypadOSX::poll_joypads() const {
}
}
-static const InputDefault::JoyAxis axis_correct(int p_value, int p_min, int p_max) {
- InputDefault::JoyAxis jx;
+static const InputFilter::JoyAxis axis_correct(int p_value, int p_min, int p_max) {
+ InputFilter::JoyAxis jx;
if (p_min < 0) {
jx.min = -1;
if (p_value < 0) {
@@ -571,9 +571,9 @@ void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const {
}
}
-JoypadOSX::JoypadOSX() {
+JoypadOSX::JoypadOSX(InputFilter *in) {
self = this;
- input = (InputDefault *)Input::get_singleton();
+ input = in;
int okay = 1;
const void *vals[] = {
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h
index 2c076b3680..62027c6a30 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -40,7 +40,7 @@
#include <ForceFeedback/ForceFeedbackConstants.h>
#include <IOKit/hid/IOHIDLib.h>
-#include "main/input_default.h"
+#include "core/input/input_filter.h"
struct rec_element {
IOHIDElementRef ref;
@@ -94,7 +94,7 @@ class JoypadOSX {
};
private:
- InputDefault *input;
+ InputFilter *input;
IOHIDManagerRef hid_manager;
Vector<joypad> device_list;
@@ -118,7 +118,7 @@ public:
void _device_added(IOReturn p_res, IOHIDDeviceRef p_device);
void _device_removed(IOReturn p_res, IOHIDDeviceRef p_device);
- JoypadOSX();
+ JoypadOSX(InputFilter *in);
~JoypadOSX();
};
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index e865c3078f..d2c67cff9f 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -31,57 +31,20 @@
#ifndef OS_OSX_H
#define OS_OSX_H
-#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
-
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "crash_handler_osx.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "drivers/coremidi/midi_driver_coremidi.h"
#include "drivers/unix/os_unix.h"
#include "joypad_osx.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual/visual_server_wrap_mt.h"
-#include "servers/visual_server.h"
-
-#if defined(OPENGL_ENABLED)
-#include "context_gl_osx.h"
-#endif
-
-#if defined(VULKAN_ENABLED)
-#include "drivers/vulkan/rendering_device_vulkan.h"
-#include "platform/osx/vulkan_context_osx.h"
-#endif
-
-#include <AppKit/AppKit.h>
-#include <AppKit/NSCursor.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include <CoreVideo/CoreVideo.h>
-
-#undef BitMap
-#undef CursorShape
class OS_OSX : public OS_Unix {
-public:
- struct KeyEvent {
- unsigned int osx_state;
- bool pressed;
- bool echo;
- bool raw;
- uint32_t keycode;
- uint32_t physical_keycode;
- uint32_t unicode;
- };
-
- Vector<KeyEvent> key_event_buffer;
- int key_event_pos;
+ virtual void delete_main_loop();
bool force_quit;
- VisualServer *visual_server;
- List<String> args;
- MainLoop *main_loop;
+ JoypadOSX *joypad_osx;
#ifdef COREAUDIO_ENABLED
AudioDriverCoreAudio audio_driver;
@@ -90,143 +53,27 @@ public:
MIDIDriverCoreMidi midi_driver;
#endif
- InputDefault *input;
- JoypadOSX *joypad_osx;
-
- /* objc */
-
- CGEventSourceRef eventSource;
-
- void process_events();
- void process_key_events();
-
- // pthread_key_t current;
- bool mouse_grab;
- Point2 mouse_pos;
-
- id delegate;
- id window_delegate;
- id window_object;
- id window_view;
- id autoreleasePool;
- id cursor;
-
-#if defined(OPENGL_ENABLED)
- ContextGL_OSX *context_gles2;
-#endif
-
-#if defined(VULKAN_ENABLED)
- VulkanContextOSX *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
-#endif
-
- bool layered_window;
-
- CursorShape cursor_shape;
- NSCursor *cursors[CURSOR_MAX];
- Map<CursorShape, Vector<Variant>> cursors_cache;
- MouseMode mouse_mode;
-
- String title;
- bool minimized;
- bool maximized;
- bool zoomed;
- bool resizable;
- bool window_focused;
-
- Size2 window_size;
- Rect2 restore_rect;
-
- String open_with_filename;
-
- Point2 im_position;
- bool im_active;
- String im_text;
- Point2 im_selection;
-
- Size2 min_size;
- Size2 max_size;
-
CrashHandler crash_handler;
- float _mouse_scale(float p_scale) {
- if (_display_scale() > 1.0)
- return p_scale;
- else
- return 1.0;
- }
-
- float _display_scale() const;
- float _display_scale(id screen) const;
-
- void _update_window();
-
- int video_driver_index;
- virtual int get_current_video_driver() const;
-
- struct GlobalMenuItem {
- String label;
- Variant signal;
- Variant meta;
-
- GlobalMenuItem() {
- //NOP
- }
-
- GlobalMenuItem(const String &p_label, const Variant &p_signal, const Variant &p_meta) {
- label = p_label;
- signal = p_signal;
- meta = p_meta;
- }
- };
-
- Map<String, Vector<GlobalMenuItem>> global_menus;
+ MainLoop *main_loop;
- void _update_global_menu();
+public:
+ String open_with_filename;
protected:
virtual void initialize_core();
- virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
+ virtual void initialize();
virtual void finalize();
+ virtual void initialize_joypads();
+
virtual void set_main_loop(MainLoop *p_main_loop);
- virtual void delete_main_loop();
public:
- static OS_OSX *singleton;
-
- void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
- void global_menu_add_separator(const String &p_menu);
- void global_menu_remove_item(const String &p_menu, int p_idx);
- void global_menu_clear(const String &p_menu);
-
- void wm_minimized(bool p_minimized);
-
virtual String get_name() const;
- virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
-
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
- virtual void set_cursor_shape(CursorShape p_shape);
- virtual CursorShape get_cursor_shape() const;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
-
- virtual void set_mouse_show(bool p_show);
- virtual void set_mouse_grab(bool p_grab);
- virtual bool is_mouse_grab_enabled() const;
- virtual void warp_mouse_position(const Point2 &p_to);
- virtual Point2 get_mouse_position() const;
- virtual int get_mouse_button_state() const;
- void update_real_mouse_position();
- virtual void set_window_title(const String &p_title);
-
- virtual Size2 get_window_size() const;
- virtual Size2 get_real_window_size() const;
-
- virtual void set_native_icon(const String &p_filename);
- virtual void set_icon(const Ref<Image> &p_icon);
-
virtual MainLoop *get_main_loop() const;
virtual String get_config_path() const;
@@ -237,95 +84,24 @@ public:
virtual String get_system_dir(SystemDir p_dir) const;
- virtual bool can_draw() const;
-
- virtual void set_clipboard(const String &p_text);
- virtual String get_clipboard() const;
-
- virtual void release_rendering_thread();
- virtual void make_rendering_thread();
- virtual void swap_buffers();
-
Error shell_open(String p_uri);
- void push_input(const Ref<InputEvent> &p_event);
String get_locale() const;
- virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
- virtual VideoMode get_video_mode(int p_screen = 0) const;
- virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
-
virtual String get_executable_path() const;
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
-
- virtual void move_window_to_foreground();
-
- virtual int get_screen_count() const;
- virtual int get_current_screen() const;
- virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = -1) const;
- virtual Size2 get_screen_size(int p_screen = -1) const;
- virtual int get_screen_dpi(int p_screen = -1) const;
-
- virtual Point2 get_window_position() const;
- virtual void set_window_position(const Point2 &p_position);
- virtual Size2 get_max_window_size() const;
- virtual Size2 get_min_window_size() const;
- virtual void set_min_window_size(const Size2 p_size);
- virtual void set_max_window_size(const Size2 p_size);
- virtual void set_window_size(const Size2 p_size);
- virtual void set_window_fullscreen(bool p_enabled);
- virtual bool is_window_fullscreen() const;
- virtual void set_window_resizable(bool p_enabled);
- virtual bool is_window_resizable() const;
- virtual void set_window_minimized(bool p_enabled);
- virtual bool is_window_minimized() const;
- virtual void set_window_maximized(bool p_enabled);
- virtual bool is_window_maximized() const;
- virtual void set_window_always_on_top(bool p_enabled);
- virtual bool is_window_always_on_top() const;
- virtual bool is_window_focused() const;
- virtual void request_attention();
- virtual String get_joy_guid(int p_device) const;
-
- virtual void set_borderless_window(bool p_borderless);
- virtual bool get_borderless_window();
-
- virtual bool get_window_per_pixel_transparency_enabled() const;
- virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
-
- virtual void set_ime_active(const bool p_active);
- virtual void set_ime_position(const Point2 &p_pos);
- virtual Point2 get_ime_selection() const;
- virtual String get_ime_text() const;
-
- virtual String get_unique_id() const;
+ virtual String get_unique_id() const; //++
virtual bool _check_internal_feature_support(const String &p_feature);
- virtual void _set_use_vsync(bool p_enable);
- //virtual bool is_vsync_enabled() const;
-
void run();
- void set_mouse_mode(MouseMode p_mode);
- MouseMode get_mouse_mode() const;
-
void disable_crash_handler();
bool is_disable_crash_handler() const;
virtual Error move_to_trash(const String &p_path);
- void force_process_input();
-
OS_OSX();
-
-private:
- Point2 get_native_screen_position(int p_screen) const;
- Point2 get_native_window_position() const;
- void set_native_window_position(const Point2 &p_position);
- Point2 get_screens_origin() const;
};
#endif
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 8ba8ca8a33..49cb056c9f 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -30,1668 +30,21 @@
#include "os_osx.h"
-#include "core/os/keyboard.h"
-#include "core/print_string.h"
#include "core/version_generated.gen.h"
-#include "dir_access_osx.h"
-
-#if defined(OPENGL_ENABLED)
-#include "drivers/gles2/rasterizer_gles2.h"
-#endif
-
-#if defined(VULKAN_ENABLED)
-#include "servers/visual/rasterizer_rd/rasterizer_rd.h"
-#endif
+#include "dir_access_osx.h"
+#include "display_server_osx.h"
#include "main/main.h"
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
-
-#include <mach-o/dyld.h>
-
-#include <Carbon/Carbon.h>
-#import <Cocoa/Cocoa.h>
-#include <IOKit/IOCFPlugIn.h>
-#include <IOKit/IOKitLib.h>
-#include <IOKit/hid/IOHIDKeys.h>
-#include <IOKit/hid/IOHIDLib.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-#include <os/log.h>
-#endif
-
-#import <QuartzCore/CAMetalLayer.h>
-#include <vulkan/vulkan_metal.h>
#include <dlfcn.h>
-#include <fcntl.h>
#include <libproc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
-#define NSEventMaskAny NSAnyEventMask
-#define NSEventTypeKeyDown NSKeyDown
-#define NSEventTypeKeyUp NSKeyUp
-#define NSEventModifierFlagShift NSShiftKeyMask
-#define NSEventModifierFlagCommand NSCommandKeyMask
-#define NSEventModifierFlagControl NSControlKeyMask
-#define NSEventModifierFlagOption NSAlternateKeyMask
-#define NSWindowStyleMaskTitled NSTitledWindowMask
-#define NSWindowStyleMaskResizable NSResizableWindowMask
-#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
-#define NSWindowStyleMaskClosable NSClosableWindowMask
-#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
-#endif
-
-#ifndef NSAppKitVersionNumber10_12
-#define NSAppKitVersionNumber10_12 1504
-#endif
-#ifndef NSAppKitVersionNumber10_14
-#define NSAppKitVersionNumber10_14 1671
-#endif
-
-static void get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> state) {
-
- state->set_shift((p_osx_state & NSEventModifierFlagShift));
- state->set_control((p_osx_state & NSEventModifierFlagControl));
- state->set_alt((p_osx_state & NSEventModifierFlagOption));
- state->set_metakey((p_osx_state & NSEventModifierFlagCommand));
-}
-
-static void push_to_key_event_buffer(const OS_OSX::KeyEvent &p_event) {
-
- Vector<OS_OSX::KeyEvent> &buffer = OS_OSX::singleton->key_event_buffer;
- if (OS_OSX::singleton->key_event_pos >= buffer.size()) {
- buffer.resize(1 + OS_OSX::singleton->key_event_pos);
- }
- buffer.write[OS_OSX::singleton->key_event_pos++] = p_event;
-}
-
-static int mouse_x = 0;
-static int mouse_y = 0;
-static int button_mask = 0;
-static bool mouse_down_control = false;
-
-static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFactor) {
-
- const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSPoint p = locationInWindow;
- const float s = OS_OSX::singleton->_mouse_scale(backingScaleFactor);
- mouse_x = p.x * s;
- mouse_y = (contentRect.size.height - p.y) * s;
- return Vector2(mouse_x, mouse_y);
-}
-
-static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
- if ([NSCursor respondsToSelector:selector]) {
- id object = [NSCursor performSelector:selector];
- if ([object isKindOfClass:[NSCursor class]]) {
- return object;
- }
- }
- if (fallback) {
- // Fallback should be a reasonable default, no need to check.
- return [NSCursor performSelector:fallback];
- }
- return [NSCursor arrowCursor];
-}
-
-@interface GodotApplication : NSApplication
-@end
-
-@implementation GodotApplication
-
-- (void)sendEvent:(NSEvent *)event {
-
- // special case handling of command-period, which is traditionally a special
- // shortcut in macOS and doesn't arrive at our regular keyDown handler.
- if ([event type] == NSEventTypeKeyDown) {
- if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
-
- Ref<InputEventKey> k;
- k.instance();
-
- get_key_modifier_state([event modifierFlags], k);
- k->set_pressed(true);
- k->set_keycode(KEY_PERIOD);
- k->set_physical_keycode(KEY_PERIOD);
- k->set_echo([event isARepeat]);
-
- OS_OSX::singleton->push_input(k);
- }
- }
-
- // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
- // This works around an AppKit bug, where key up events while holding
- // down the command key don't get sent to the key window.
- if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand))
- [[self keyWindow] sendEvent:event];
- else
- [super sendEvent:event];
-}
-
-@end
-
-@interface GodotApplicationDelegate : NSObject
-- (void)forceUnbundledWindowActivationHackStep1;
-- (void)forceUnbundledWindowActivationHackStep2;
-- (void)forceUnbundledWindowActivationHackStep3;
-@end
-
-@implementation GodotApplicationDelegate
-
-- (void)forceUnbundledWindowActivationHackStep1 {
- // Step1: Switch focus to macOS Dock.
- // Required to perform step 2, TransformProcessType will fail if app is already the in focus.
- for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
- [app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
- break;
- }
- [self performSelector:@selector(forceUnbundledWindowActivationHackStep2) withObject:nil afterDelay:0.02];
-}
-
-- (void)forceUnbundledWindowActivationHackStep2 {
- // Step 2: Register app as foreground process.
- ProcessSerialNumber psn = { 0, kCurrentProcess };
- (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication);
-
- [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02];
-}
-
-- (void)forceUnbundledWindowActivationHackStep3 {
- // Step 3: Switch focus back to app window.
- [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
-}
-
-- (void)applicationDidFinishLaunching:(NSNotification *)notice {
- NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
- if (nsappname == nil) {
- // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored).
- [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02];
- }
-}
-
-- (void)globalMenuCallback:(id)sender {
-
- if (![sender representedObject])
- return;
-
- OS_OSX::GlobalMenuItem *item = (OS_OSX::GlobalMenuItem *)[[sender representedObject] pointerValue];
-
- if (!item)
- return;
-
- OS_OSX::singleton->main_loop->global_menu_action(item->signal, item->meta);
-}
-
-- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
-
- NSMenu *menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
-
- Vector<OS_OSX::GlobalMenuItem> &E = OS_OSX::singleton->global_menus["_dock"];
- for (int i = 0; i < E.size(); i++) {
- if (E[i].label == String()) {
- [menu addItem:[NSMenuItem separatorItem]];
- } else {
- NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:E[i].label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""];
- [menu_item setRepresentedObject:[NSValue valueWithPointer:&(E[i])]];
- }
- }
-
- return menu;
-}
-
-- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
- // Note: may be called called before main loop init!
- char *utfs = strdup([filename UTF8String]);
- OS_OSX::singleton->open_with_filename.parse_utf8(utfs);
- free(utfs);
-
-#ifdef TOOLS_ENABLED
- // Open new instance
- if (OS_OSX::singleton->get_main_loop()) {
- List<String> args;
- args.push_back(OS_OSX::singleton->open_with_filename);
- String exec = OS::get_singleton()->get_executable_path();
-
- OS::ProcessID pid = 0;
- OS::get_singleton()->execute(exec, args, false, &pid);
- }
-#endif
- return YES;
-}
-
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
-
- return NSTerminateCancel;
-}
-
-- (void)showAbout:(id)sender {
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT);
-}
-
-@end
-
-@interface GodotWindowDelegate : NSObject {
- //_Godotwindow* window;
-}
-
-- (void)windowWillClose:(NSNotification *)notification;
-
-@end
-
-@implementation GodotWindowDelegate
-
-- (BOOL)windowShouldClose:(id)sender {
- //_GodotInputWindowCloseRequest(window);
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
-
- return NO;
-}
-
-- (void)windowWillClose:(NSNotification *)notification {
-#if defined(VULKAN_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
-
- if (OS_OSX::singleton->rendering_device_vulkan) {
- OS_OSX::singleton->rendering_device_vulkan->finalize();
- memdelete(OS_OSX::singleton->rendering_device_vulkan);
- OS_OSX::singleton->rendering_device_vulkan = NULL;
- }
-
- if (OS_OSX::singleton->context_vulkan) {
- memdelete(OS_OSX::singleton->context_vulkan);
- OS_OSX::singleton->context_vulkan = NULL;
- }
- }
-#endif
-}
-
-- (void)windowDidEnterFullScreen:(NSNotification *)notification {
- OS_OSX::singleton->zoomed = true;
-
- [OS_OSX::singleton->window_object setContentMinSize:NSMakeSize(0, 0)];
- [OS_OSX::singleton->window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
-}
-
-- (void)windowDidExitFullScreen:(NSNotification *)notification {
- OS_OSX::singleton->zoomed = false;
-
- if (OS_OSX::singleton->min_size != Size2()) {
- Size2 size = OS_OSX::singleton->min_size / OS_OSX::singleton->_display_scale();
- [OS_OSX::singleton->window_object setContentMinSize:NSMakeSize(size.x, size.y)];
- }
- if (OS_OSX::singleton->max_size != Size2()) {
- Size2 size = OS_OSX::singleton->max_size / OS_OSX::singleton->_display_scale();
- [OS_OSX::singleton->window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
- }
-
- if (!OS_OSX::singleton->resizable)
- [OS_OSX::singleton->window_object setStyleMask:[OS_OSX::singleton->window_object styleMask] & ~NSWindowStyleMaskResizable];
-}
-
-- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
- if (!OS_OSX::singleton)
- return;
-
- NSWindow *window = (NSWindow *)[notification object];
- CGFloat newBackingScaleFactor = [window backingScaleFactor];
- CGFloat oldBackingScaleFactor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue];
-
-#if defined(OPENGL_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_GLES2) {
- if (OS_OSX::singleton->is_hidpi_allowed()) {
- [OS_OSX::singleton->window_view setWantsBestResolutionOpenGLSurface:YES];
- } else {
- [OS_OSX::singleton->window_view setWantsBestResolutionOpenGLSurface:NO];
- }
- }
-#endif
-
- if (newBackingScaleFactor != oldBackingScaleFactor) {
- //Set new display scale and window size
- float newDisplayScale = OS_OSX::singleton->is_hidpi_allowed() ? newBackingScaleFactor : 1.0;
-
- const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect;
-
- OS_OSX::singleton->window_size.width = fbRect.size.width * newDisplayScale;
- OS_OSX::singleton->window_size.height = fbRect.size.height * newDisplayScale;
-
-#if defined(VULKAN_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
- CALayer *layer = [OS_OSX::singleton->window_view layer];
- layer.contentsScale = OS_OSX::singleton->_display_scale();
- }
-#endif
- //Update context
- if (OS_OSX::singleton->main_loop) {
- //Force window resize event
- [self windowDidResize:notification];
- }
- }
-}
-
-- (void)windowDidResize:(NSNotification *)notification {
-
-#if defined(OPENGL_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_GLES2) {
- OS_OSX::singleton->context_gles2->update();
- }
-#endif
- const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect;
-
- float displayScale = OS_OSX::singleton->_display_scale();
- OS_OSX::singleton->window_size.width = fbRect.size.width * displayScale;
- OS_OSX::singleton->window_size.height = fbRect.size.height * displayScale;
-
-#if defined(VULKAN_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
- CALayer *layer = [OS_OSX::singleton->window_view layer];
- layer.contentsScale = OS_OSX::singleton->_display_scale();
- OS_OSX::singleton->context_vulkan->window_resize(0, OS_OSX::singleton->window_size.width, OS_OSX::singleton->window_size.height);
- }
-#endif
-
- if (OS_OSX::singleton->main_loop) {
- Main::force_redraw();
- //Event retrieval blocks until resize is over. Call Main::iteration() directly.
- if (!Main::is_iterating()) { //avoid cyclic loop
- Main::iteration();
- }
- }
-}
-
-- (void)windowDidMove:(NSNotification *)notification {
-
- if (OS_OSX::singleton->get_main_loop()) {
- OS_OSX::singleton->input->release_pressed_events();
- }
-}
-
-- (void)windowDidBecomeKey:(NSNotification *)notification {
- if (OS_OSX::singleton->get_main_loop()) {
- get_mouse_pos(
- [OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream],
- [OS_OSX::singleton->window_view backingScaleFactor]);
- OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
-
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
- }
-
- OS_OSX::singleton->window_focused = true;
-}
-
-- (void)windowDidResignKey:(NSNotification *)notification {
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
-
- OS_OSX::singleton->window_focused = false;
-}
-
-- (void)windowDidMiniaturize:(NSNotification *)notification {
- OS_OSX::singleton->wm_minimized(true);
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
-
- OS_OSX::singleton->window_focused = false;
-};
-
-- (void)windowDidDeminiaturize:(NSNotification *)notification {
- OS_OSX::singleton->wm_minimized(false);
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
-
- OS_OSX::singleton->window_focused = true;
-};
-
-@end
-
-@interface GodotContentView : NSView <NSTextInputClient> {
- NSTrackingArea *trackingArea;
- NSMutableAttributedString *markedText;
- bool imeInputEventInProgress;
-}
-- (void)cancelComposition;
-
-- (CALayer *)makeBackingLayer;
-
-- (BOOL)wantsUpdateLayer;
-- (void)updateLayer;
-
-@end
-
-@implementation GodotContentView
-
-+ (void)initialize {
- if (self == [GodotContentView class]) {
- // nothing left to do here at the moment..
- }
-}
-
-- (CALayer *)makeBackingLayer {
-#if defined(VULKAN_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
- CALayer *layer = [[CAMetalLayer class] layer];
- layer.contentsScale = OS_OSX::singleton->_display_scale();
- return layer;
- }
-#endif
- return [super makeBackingLayer];
-}
-
-- (void)updateLayer {
-#if defined(VULKAN_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_VULKAN) {
- [super updateLayer];
- }
-#endif
-#if defined(OPENGL_ENABLED)
- if (OS_OSX::singleton->video_driver_index == OS::VIDEO_DRIVER_GLES2) {
- OS_OSX::singleton->context_gles2->update();
- }
-#endif
-}
-
-- (BOOL)wantsUpdateLayer {
- return YES;
-}
-
-- (id)init {
- self = [super init];
- trackingArea = nil;
- imeInputEventInProgress = false;
- [self updateTrackingAreas];
- [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
- markedText = [[NSMutableAttributedString alloc] init];
- return self;
-}
-
-- (void)dealloc {
- [trackingArea release];
- [markedText release];
- [super dealloc];
-}
-
-static const NSRange kEmptyRange = { NSNotFound, 0 };
-
-- (BOOL)hasMarkedText {
- return (markedText.length > 0);
-}
-
-- (NSRange)markedRange {
- return NSMakeRange(0, markedText.length);
-}
-
-- (NSRange)selectedRange {
- return kEmptyRange;
-}
-
-- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange {
- if ([aString isKindOfClass:[NSAttributedString class]]) {
- [markedText initWithAttributedString:aString];
- } else {
- [markedText initWithString:aString];
- }
- if (markedText.length == 0) {
- [self unmarkText];
- return;
- }
- if (OS_OSX::singleton->im_active) {
- imeInputEventInProgress = true;
- OS_OSX::singleton->im_text.parse_utf8([[markedText mutableString] UTF8String]);
- OS_OSX::singleton->im_selection = Point2(selectedRange.location, selectedRange.length);
-
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE);
- }
-}
-
-- (void)doCommandBySelector:(SEL)aSelector {
- if ([self respondsToSelector:aSelector])
- [self performSelector:aSelector];
-}
-
-- (void)unmarkText {
- imeInputEventInProgress = false;
- [[markedText mutableString] setString:@""];
- if (OS_OSX::singleton->im_active) {
- OS_OSX::singleton->im_text = String();
- OS_OSX::singleton->im_selection = Point2();
-
- if (OS_OSX::singleton->get_main_loop())
- OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE);
- }
-}
-
-- (NSArray *)validAttributesForMarkedText {
- return [NSArray array];
-}
-
-- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange {
- return nil;
-}
-
-- (NSUInteger)characterIndexForPoint:(NSPoint)aPoint {
- return 0;
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange {
- const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- float displayScale = OS_OSX::singleton->_display_scale();
- NSRect pointInWindowRect = NSMakeRect(OS_OSX::singleton->im_position.x / displayScale, contentRect.size.height - (OS_OSX::singleton->im_position.y / displayScale) - 1, 0, 0);
- NSPoint pointOnScreen = [[OS_OSX::singleton->window_view window] convertRectToScreen:pointInWindowRect].origin;
-
- return NSMakeRect(pointOnScreen.x, pointOnScreen.y, 0, 0);
-}
-
-- (void)cancelComposition {
- [self unmarkText];
- NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
- [currentInputContext discardMarkedText];
-}
-
-- (void)insertText:(id)aString {
- [self insertText:aString replacementRange:NSMakeRange(0, 0)];
-}
-
-- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange {
- NSEvent *event = [NSApp currentEvent];
-
- NSString *characters;
- if ([aString isKindOfClass:[NSAttributedString class]]) {
- characters = [aString string];
- } else {
- characters = (NSString *)aString;
- }
-
- NSUInteger i, length = [characters length];
-
- NSCharacterSet *ctrlChars = [NSCharacterSet controlCharacterSet];
- NSCharacterSet *wsnlChars = [NSCharacterSet whitespaceAndNewlineCharacterSet];
- if ([characters rangeOfCharacterFromSet:ctrlChars].length && [characters rangeOfCharacterFromSet:wsnlChars].length == 0) {
- NSTextInputContext *currentInputContext = [NSTextInputContext currentInputContext];
- [currentInputContext discardMarkedText];
- [self cancelComposition];
- return;
- }
-
- for (i = 0; i < length; i++) {
- const unichar codepoint = [characters characterAtIndex:i];
- if ((codepoint & 0xFF00) == 0xF700)
- continue;
-
- OS_OSX::KeyEvent ke;
-
- ke.osx_state = [event modifierFlags];
- ke.pressed = true;
- ke.echo = false;
- ke.raw = false; // IME input event
- ke.keycode = 0;
- ke.physical_keycode = 0;
- ke.unicode = codepoint;
-
- push_to_key_event_buffer(ke);
- }
- [self cancelComposition];
-}
-
-- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
- return NSDragOperationCopy;
-}
-
-- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
- return NSDragOperationCopy;
-}
-
-- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
-
- NSPasteboard *pboard = [sender draggingPasteboard];
- NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
-
- Vector<String> files;
- for (NSUInteger i = 0; i < filenames.count; i++) {
- NSString *ns = [filenames objectAtIndex:i];
- char *utfs = strdup([ns UTF8String]);
- String ret;
- ret.parse_utf8(utfs);
- free(utfs);
- files.push_back(ret);
- }
-
- if (files.size()) {
- OS_OSX::singleton->main_loop->drop_files(files, 0);
- OS_OSX::singleton->move_window_to_foreground();
- }
-
- return NO;
-}
-
-- (BOOL)isOpaque {
- return YES;
-}
-
-- (BOOL)canBecomeKeyView {
- return YES;
-}
-
-- (BOOL)acceptsFirstResponder {
- return YES;
-}
-
-- (void)cursorUpdate:(NSEvent *)event {
- OS::CursorShape p_shape = OS_OSX::singleton->cursor_shape;
- OS_OSX::singleton->cursor_shape = OS::CURSOR_MAX;
- OS_OSX::singleton->set_cursor_shape(p_shape);
-}
-
-static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
- if (pressed) {
- button_mask |= mask;
- } else {
- button_mask &= ~mask;
- }
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
- const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
- const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
- get_key_modifier_state([event modifierFlags], mb);
- mb->set_button_index(index);
- mb->set_pressed(pressed);
- mb->set_position(pos);
- mb->set_global_position(pos);
- mb->set_button_mask(button_mask);
- if (index == BUTTON_LEFT && pressed) {
- mb->set_doubleclick([event clickCount] == 2);
- }
- OS_OSX::singleton->push_input(mb);
-}
-
-- (void)mouseDown:(NSEvent *)event {
- if (([event modifierFlags] & NSEventModifierFlagControl)) {
- mouse_down_control = true;
- _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
- } else {
- mouse_down_control = false;
- _mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, true);
- }
-}
-
-- (void)mouseDragged:(NSEvent *)event {
- [self mouseMoved:event];
-}
-
-- (void)mouseUp:(NSEvent *)event {
- if (mouse_down_control) {
- _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
- } else {
- _mouseDownEvent(event, BUTTON_LEFT, BUTTON_MASK_LEFT, false);
- }
-}
-
-- (void)mouseMoved:(NSEvent *)event {
-
- Ref<InputEventMouseMotion> mm;
- mm.instance();
-
- mm->set_button_mask(button_mask);
- const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
- const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
- mm->set_position(pos);
- mm->set_pressure([event pressure]);
- if ([event subtype] == NSEventSubtypeTabletPoint) {
- const NSPoint p = [event tilt];
- mm->set_tilt(Vector2(p.x, p.y));
- }
- mm->set_global_position(pos);
- mm->set_speed(OS_OSX::singleton->input->get_last_mouse_speed());
- Vector2 relativeMotion = Vector2();
- relativeMotion.x = [event deltaX] * OS_OSX::singleton -> _mouse_scale(backingScaleFactor);
- relativeMotion.y = [event deltaY] * OS_OSX::singleton -> _mouse_scale(backingScaleFactor);
- mm->set_relative(relativeMotion);
- get_key_modifier_state([event modifierFlags], mm);
-
- OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
- OS_OSX::singleton->push_input(mm);
-}
-
-- (void)rightMouseDown:(NSEvent *)event {
- _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, true);
-}
-
-- (void)rightMouseDragged:(NSEvent *)event {
- [self mouseMoved:event];
-}
-
-- (void)rightMouseUp:(NSEvent *)event {
- _mouseDownEvent(event, BUTTON_RIGHT, BUTTON_MASK_RIGHT, false);
-}
-
-- (void)otherMouseDown:(NSEvent *)event {
-
- if ((int)[event buttonNumber] == 2) {
- _mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, true);
-
- } else if ((int)[event buttonNumber] == 3) {
- _mouseDownEvent(event, BUTTON_XBUTTON1, BUTTON_MASK_XBUTTON1, true);
-
- } else if ((int)[event buttonNumber] == 4) {
- _mouseDownEvent(event, BUTTON_XBUTTON2, BUTTON_MASK_XBUTTON2, true);
-
- } else {
- return;
- }
-}
-
-- (void)otherMouseDragged:(NSEvent *)event {
- [self mouseMoved:event];
-}
-
-- (void)otherMouseUp:(NSEvent *)event {
-
- if ((int)[event buttonNumber] == 2) {
- _mouseDownEvent(event, BUTTON_MIDDLE, BUTTON_MASK_MIDDLE, false);
-
- } else if ((int)[event buttonNumber] == 3) {
- _mouseDownEvent(event, BUTTON_XBUTTON1, BUTTON_MASK_XBUTTON1, false);
-
- } else if ((int)[event buttonNumber] == 4) {
- _mouseDownEvent(event, BUTTON_XBUTTON2, BUTTON_MASK_XBUTTON2, false);
-
- } else {
- return;
- }
-}
-
-- (void)mouseExited:(NSEvent *)event {
- if (!OS_OSX::singleton)
- return;
-
- if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode != OS::MOUSE_MODE_CAPTURED)
- OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
-}
-
-- (void)mouseEntered:(NSEvent *)event {
- if (!OS_OSX::singleton)
- return;
- if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode != OS::MOUSE_MODE_CAPTURED)
- OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
-
- OS::CursorShape p_shape = OS_OSX::singleton->cursor_shape;
- OS_OSX::singleton->cursor_shape = OS::CURSOR_MAX;
- OS_OSX::singleton->set_cursor_shape(p_shape);
-}
-
-- (void)magnifyWithEvent:(NSEvent *)event {
- Ref<InputEventMagnifyGesture> ev;
- ev.instance();
- get_key_modifier_state([event modifierFlags], ev);
- ev->set_position(get_mouse_pos([event locationInWindow], [[event window] backingScaleFactor]));
- ev->set_factor([event magnification] + 1.0);
- OS_OSX::singleton->push_input(ev);
-}
-
-- (void)viewDidChangeBackingProperties {
- // nothing left to do here
-}
-
-- (void)updateTrackingAreas {
- if (trackingArea != nil) {
- [self removeTrackingArea:trackingArea];
- [trackingArea release];
- }
-
- NSTrackingAreaOptions options =
- NSTrackingMouseEnteredAndExited |
- NSTrackingActiveInKeyWindow |
- NSTrackingCursorUpdate |
- NSTrackingInVisibleRect;
-
- trackingArea = [[NSTrackingArea alloc]
- initWithRect:[self bounds]
- options:options
- owner:self
- userInfo:nil];
-
- [self addTrackingArea:trackingArea];
- [super updateTrackingAreas];
-}
-
-static bool isNumpadKey(unsigned int key) {
-
- static const unsigned int table[] = {
- 0x41, /* kVK_ANSI_KeypadDecimal */
- 0x43, /* kVK_ANSI_KeypadMultiply */
- 0x45, /* kVK_ANSI_KeypadPlus */
- 0x47, /* kVK_ANSI_KeypadClear */
- 0x4b, /* kVK_ANSI_KeypadDivide */
- 0x4c, /* kVK_ANSI_KeypadEnter */
- 0x4e, /* kVK_ANSI_KeypadMinus */
- 0x51, /* kVK_ANSI_KeypadEquals */
- 0x52, /* kVK_ANSI_Keypad0 */
- 0x53, /* kVK_ANSI_Keypad1 */
- 0x54, /* kVK_ANSI_Keypad2 */
- 0x55, /* kVK_ANSI_Keypad3 */
- 0x56, /* kVK_ANSI_Keypad4 */
- 0x57, /* kVK_ANSI_Keypad5 */
- 0x58, /* kVK_ANSI_Keypad6 */
- 0x59, /* kVK_ANSI_Keypad7 */
- 0x5b, /* kVK_ANSI_Keypad8 */
- 0x5c, /* kVK_ANSI_Keypad9 */
- 0x5f, /* kVK_JIS_KeypadComma */
- 0x00
- };
- for (int i = 0; table[i] != 0; i++) {
- if (key == table[i])
- return true;
- }
- return false;
-}
-
-// Translates a OS X keycode to a Godot keycode
-//
-static int translateKey(unsigned int key) {
-
- // Keyboard symbol translation table
- static const unsigned int table[128] = {
- /* 00 */ KEY_A,
- /* 01 */ KEY_S,
- /* 02 */ KEY_D,
- /* 03 */ KEY_F,
- /* 04 */ KEY_H,
- /* 05 */ KEY_G,
- /* 06 */ KEY_Z,
- /* 07 */ KEY_X,
- /* 08 */ KEY_C,
- /* 09 */ KEY_V,
- /* 0a */ KEY_SECTION, /* ISO Section */
- /* 0b */ KEY_B,
- /* 0c */ KEY_Q,
- /* 0d */ KEY_W,
- /* 0e */ KEY_E,
- /* 0f */ KEY_R,
- /* 10 */ KEY_Y,
- /* 11 */ KEY_T,
- /* 12 */ KEY_1,
- /* 13 */ KEY_2,
- /* 14 */ KEY_3,
- /* 15 */ KEY_4,
- /* 16 */ KEY_6,
- /* 17 */ KEY_5,
- /* 18 */ KEY_EQUAL,
- /* 19 */ KEY_9,
- /* 1a */ KEY_7,
- /* 1b */ KEY_MINUS,
- /* 1c */ KEY_8,
- /* 1d */ KEY_0,
- /* 1e */ KEY_BRACERIGHT,
- /* 1f */ KEY_O,
- /* 20 */ KEY_U,
- /* 21 */ KEY_BRACELEFT,
- /* 22 */ KEY_I,
- /* 23 */ KEY_P,
- /* 24 */ KEY_ENTER,
- /* 25 */ KEY_L,
- /* 26 */ KEY_J,
- /* 27 */ KEY_APOSTROPHE,
- /* 28 */ KEY_K,
- /* 29 */ KEY_SEMICOLON,
- /* 2a */ KEY_BACKSLASH,
- /* 2b */ KEY_COMMA,
- /* 2c */ KEY_SLASH,
- /* 2d */ KEY_N,
- /* 2e */ KEY_M,
- /* 2f */ KEY_PERIOD,
- /* 30 */ KEY_TAB,
- /* 31 */ KEY_SPACE,
- /* 32 */ KEY_QUOTELEFT,
- /* 33 */ KEY_BACKSPACE,
- /* 34 */ KEY_UNKNOWN,
- /* 35 */ KEY_ESCAPE,
- /* 36 */ KEY_META,
- /* 37 */ KEY_META,
- /* 38 */ KEY_SHIFT,
- /* 39 */ KEY_CAPSLOCK,
- /* 3a */ KEY_ALT,
- /* 3b */ KEY_CONTROL,
- /* 3c */ KEY_SHIFT,
- /* 3d */ KEY_ALT,
- /* 3e */ KEY_CONTROL,
- /* 3f */ KEY_UNKNOWN, /* Function */
- /* 40 */ KEY_UNKNOWN, /* F17 */
- /* 41 */ KEY_KP_PERIOD,
- /* 42 */ KEY_UNKNOWN,
- /* 43 */ KEY_KP_MULTIPLY,
- /* 44 */ KEY_UNKNOWN,
- /* 45 */ KEY_KP_ADD,
- /* 46 */ KEY_UNKNOWN,
- /* 47 */ KEY_NUMLOCK, /* Really KeypadClear... */
- /* 48 */ KEY_VOLUMEUP, /* VolumeUp */
- /* 49 */ KEY_VOLUMEDOWN, /* VolumeDown */
- /* 4a */ KEY_VOLUMEMUTE, /* Mute */
- /* 4b */ KEY_KP_DIVIDE,
- /* 4c */ KEY_KP_ENTER,
- /* 4d */ KEY_UNKNOWN,
- /* 4e */ KEY_KP_SUBTRACT,
- /* 4f */ KEY_UNKNOWN, /* F18 */
- /* 50 */ KEY_UNKNOWN, /* F19 */
- /* 51 */ KEY_EQUAL, /* KeypadEqual */
- /* 52 */ KEY_KP_0,
- /* 53 */ KEY_KP_1,
- /* 54 */ KEY_KP_2,
- /* 55 */ KEY_KP_3,
- /* 56 */ KEY_KP_4,
- /* 57 */ KEY_KP_5,
- /* 58 */ KEY_KP_6,
- /* 59 */ KEY_KP_7,
- /* 5a */ KEY_UNKNOWN, /* F20 */
- /* 5b */ KEY_KP_8,
- /* 5c */ KEY_KP_9,
- /* 5d */ KEY_YEN, /* JIS Yen */
- /* 5e */ KEY_UNDERSCORE, /* JIS Underscore */
- /* 5f */ KEY_COMMA, /* JIS KeypadComma */
- /* 60 */ KEY_F5,
- /* 61 */ KEY_F6,
- /* 62 */ KEY_F7,
- /* 63 */ KEY_F3,
- /* 64 */ KEY_F8,
- /* 65 */ KEY_F9,
- /* 66 */ KEY_UNKNOWN, /* JIS Eisu */
- /* 67 */ KEY_F11,
- /* 68 */ KEY_UNKNOWN, /* JIS Kana */
- /* 69 */ KEY_F13,
- /* 6a */ KEY_F16,
- /* 6b */ KEY_F14,
- /* 6c */ KEY_UNKNOWN,
- /* 6d */ KEY_F10,
- /* 6e */ KEY_MENU,
- /* 6f */ KEY_F12,
- /* 70 */ KEY_UNKNOWN,
- /* 71 */ KEY_F15,
- /* 72 */ KEY_INSERT, /* Really Help... */
- /* 73 */ KEY_HOME,
- /* 74 */ KEY_PAGEUP,
- /* 75 */ KEY_DELETE,
- /* 76 */ KEY_F4,
- /* 77 */ KEY_END,
- /* 78 */ KEY_F2,
- /* 79 */ KEY_PAGEDOWN,
- /* 7a */ KEY_F1,
- /* 7b */ KEY_LEFT,
- /* 7c */ KEY_RIGHT,
- /* 7d */ KEY_DOWN,
- /* 7e */ KEY_UP,
- /* 7f */ KEY_UNKNOWN,
- };
-
- if (key >= 128)
- return KEY_UNKNOWN;
-
- return table[key];
-}
-
-struct _KeyCodeMap {
- UniChar kchar;
- int kcode;
-};
-
-static const _KeyCodeMap _keycodes[55] = {
- { '`', KEY_QUOTELEFT },
- { '~', KEY_ASCIITILDE },
- { '0', KEY_0 },
- { '1', KEY_1 },
- { '2', KEY_2 },
- { '3', KEY_3 },
- { '4', KEY_4 },
- { '5', KEY_5 },
- { '6', KEY_6 },
- { '7', KEY_7 },
- { '8', KEY_8 },
- { '9', KEY_9 },
- { '-', KEY_MINUS },
- { '_', KEY_UNDERSCORE },
- { '=', KEY_EQUAL },
- { '+', KEY_PLUS },
- { 'q', KEY_Q },
- { 'w', KEY_W },
- { 'e', KEY_E },
- { 'r', KEY_R },
- { 't', KEY_T },
- { 'y', KEY_Y },
- { 'u', KEY_U },
- { 'i', KEY_I },
- { 'o', KEY_O },
- { 'p', KEY_P },
- { '[', KEY_BRACELEFT },
- { ']', KEY_BRACERIGHT },
- { '{', KEY_BRACELEFT },
- { '}', KEY_BRACERIGHT },
- { 'a', KEY_A },
- { 's', KEY_S },
- { 'd', KEY_D },
- { 'f', KEY_F },
- { 'g', KEY_G },
- { 'h', KEY_H },
- { 'j', KEY_J },
- { 'k', KEY_K },
- { 'l', KEY_L },
- { ';', KEY_SEMICOLON },
- { ':', KEY_COLON },
- { '\'', KEY_APOSTROPHE },
- { '\"', KEY_QUOTEDBL },
- { '\\', KEY_BACKSLASH },
- { '#', KEY_NUMBERSIGN },
- { 'z', KEY_Z },
- { 'x', KEY_X },
- { 'c', KEY_C },
- { 'v', KEY_V },
- { 'b', KEY_B },
- { 'n', KEY_N },
- { 'm', KEY_M },
- { ',', KEY_COMMA },
- { '.', KEY_PERIOD },
- { '/', KEY_SLASH }
-};
-
-static int remapKey(unsigned int key, unsigned int state) {
-
- if (isNumpadKey(key))
- return translateKey(key);
-
- TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
- if (!currentKeyboard)
- return translateKey(key);
-
- CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
- if (!layoutData)
- return translateKey(key);
-
- const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
-
- UInt32 keysDown = 0;
- UniChar chars[4];
- UniCharCount realLength;
-
- OSStatus err = UCKeyTranslate(keyboardLayout,
- key,
- kUCKeyActionDisplay,
- (state >> 8) & 0xFF,
- LMGetKbdType(),
- kUCKeyTranslateNoDeadKeysBit,
- &keysDown,
- sizeof(chars) / sizeof(chars[0]),
- &realLength,
- chars);
-
- if (err != noErr) {
- return translateKey(key);
- }
-
- for (unsigned int i = 0; i < 55; i++) {
- if (_keycodes[i].kchar == chars[0]) {
- return _keycodes[i].kcode;
- }
- }
- return translateKey(key);
-}
-
-- (void)keyDown:(NSEvent *)event {
-
- // Ignore all input if IME input is in progress
- if (!imeInputEventInProgress) {
- NSString *characters = [event characters];
- NSUInteger length = [characters length];
-
- if (!OS_OSX::singleton->im_active && length > 0 && keycode_has_unicode(remapKey([event keyCode], [event modifierFlags]))) {
- // Fallback unicode character handler used if IME is not active
- for (NSUInteger i = 0; i < length; i++) {
- OS_OSX::KeyEvent ke;
-
- ke.osx_state = [event modifierFlags];
- ke.pressed = true;
- ke.echo = [event isARepeat];
- ke.keycode = remapKey([event keyCode], [event modifierFlags]);
- ke.physical_keycode = translateKey([event keyCode]);
- ke.raw = true;
- ke.unicode = [characters characterAtIndex:i];
-
- push_to_key_event_buffer(ke);
- }
- } else {
- OS_OSX::KeyEvent ke;
-
- ke.osx_state = [event modifierFlags];
- ke.pressed = true;
- ke.echo = [event isARepeat];
- ke.keycode = remapKey([event keyCode], [event modifierFlags]);
- ke.physical_keycode = translateKey([event keyCode]);
- ke.raw = false;
- ke.unicode = 0;
-
- push_to_key_event_buffer(ke);
- }
- }
-
- // Pass events to IME handler
- if (OS_OSX::singleton->im_active)
- [self interpretKeyEvents:[NSArray arrayWithObject:event]];
-}
-
-- (void)flagsChanged:(NSEvent *)event {
-
- // Ignore all input if IME input is in progress
- if (!imeInputEventInProgress) {
- OS_OSX::KeyEvent ke;
-
- ke.echo = false;
- ke.raw = true;
-
- int key = [event keyCode];
- int mod = [event modifierFlags];
-
- if (key == 0x36 || key == 0x37) {
- if (mod & NSEventModifierFlagCommand) {
- mod &= ~NSEventModifierFlagCommand;
- ke.pressed = true;
- } else {
- ke.pressed = false;
- }
- } else if (key == 0x38 || key == 0x3c) {
- if (mod & NSEventModifierFlagShift) {
- mod &= ~NSEventModifierFlagShift;
- ke.pressed = true;
- } else {
- ke.pressed = false;
- }
- } else if (key == 0x3a || key == 0x3d) {
- if (mod & NSEventModifierFlagOption) {
- mod &= ~NSEventModifierFlagOption;
- ke.pressed = true;
- } else {
- ke.pressed = false;
- }
- } else if (key == 0x3b || key == 0x3e) {
- if (mod & NSEventModifierFlagControl) {
- mod &= ~NSEventModifierFlagControl;
- ke.pressed = true;
- } else {
- ke.pressed = false;
- }
- } else {
- return;
- }
-
- ke.osx_state = mod;
- ke.keycode = remapKey(key, mod);
- ke.physical_keycode = translateKey(key);
- ke.unicode = 0;
-
- push_to_key_event_buffer(ke);
- }
-}
-
-- (void)keyUp:(NSEvent *)event {
-
- // Ignore all input if IME input is in progress
- if (!imeInputEventInProgress) {
- NSString *characters = [event characters];
- NSUInteger length = [characters length];
-
- // Fallback unicode character handler used if IME is not active
- if (!OS_OSX::singleton->im_active && length > 0 && keycode_has_unicode(remapKey([event keyCode], [event modifierFlags]))) {
- for (NSUInteger i = 0; i < length; i++) {
- OS_OSX::KeyEvent ke;
-
- ke.osx_state = [event modifierFlags];
- ke.pressed = false;
- ke.echo = [event isARepeat];
- ke.keycode = remapKey([event keyCode], [event modifierFlags]);
- ke.physical_keycode = translateKey([event keyCode]);
- ke.raw = true;
- ke.unicode = [characters characterAtIndex:i];
-
- push_to_key_event_buffer(ke);
- }
- } else {
- OS_OSX::KeyEvent ke;
-
- ke.osx_state = [event modifierFlags];
- ke.pressed = false;
- ke.echo = [event isARepeat];
- ke.keycode = remapKey([event keyCode], [event modifierFlags]);
- ke.physical_keycode = translateKey([event keyCode]);
- ke.raw = true;
- ke.unicode = 0;
-
- push_to_key_event_buffer(ke);
- }
- }
-}
-
-inline void sendScrollEvent(int button, double factor, int modifierFlags) {
-
- unsigned int mask = 1 << (button - 1);
- Vector2 mouse_pos = Vector2(mouse_x, mouse_y);
-
- Ref<InputEventMouseButton> sc;
- sc.instance();
-
- get_key_modifier_state(modifierFlags, sc);
- sc->set_button_index(button);
- sc->set_factor(factor);
- sc->set_pressed(true);
- sc->set_position(mouse_pos);
- sc->set_global_position(mouse_pos);
- button_mask |= mask;
- sc->set_button_mask(button_mask);
- OS_OSX::singleton->push_input(sc);
-
- sc.instance();
- sc->set_button_index(button);
- sc->set_factor(factor);
- sc->set_pressed(false);
- sc->set_position(mouse_pos);
- sc->set_global_position(mouse_pos);
- button_mask &= ~mask;
- sc->set_button_mask(button_mask);
- OS_OSX::singleton->push_input(sc);
-}
-
-inline void sendPanEvent(double dx, double dy, int modifierFlags) {
-
- Ref<InputEventPanGesture> pg;
- pg.instance();
-
- get_key_modifier_state(modifierFlags, pg);
- Vector2 mouse_pos = Vector2(mouse_x, mouse_y);
- pg->set_position(mouse_pos);
- pg->set_delta(Vector2(-dx, -dy));
- OS_OSX::singleton->push_input(pg);
-}
-
-- (void)scrollWheel:(NSEvent *)event {
- double deltaX, deltaY;
-
- get_mouse_pos([event locationInWindow], [[event window] backingScaleFactor]);
-
- deltaX = [event scrollingDeltaX];
- deltaY = [event scrollingDeltaY];
-
- if ([event hasPreciseScrollingDeltas]) {
- deltaX *= 0.03;
- deltaY *= 0.03;
- }
-
- if ([event phase] != NSEventPhaseNone || [event momentumPhase] != NSEventPhaseNone) {
- sendPanEvent(deltaX, deltaY, [event modifierFlags]);
- } else {
- if (fabs(deltaX)) {
- sendScrollEvent(0 > deltaX ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT, fabs(deltaX * 0.3), [event modifierFlags]);
- }
- if (fabs(deltaY)) {
- sendScrollEvent(0 < deltaY ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN, fabs(deltaY * 0.3), [event modifierFlags]);
- }
- }
-}
-
-@end
-
-@interface GodotWindow : NSWindow {
-}
-@end
-
-@implementation GodotWindow
-
-- (BOOL)canBecomeKeyWindow {
- // Required for NSBorderlessWindowMask windows
- return YES;
-}
-
-@end
-
-void OS_OSX::_update_global_menu() {
-
- NSMenu *main_menu = [NSApp mainMenu];
-
- for (int i = 1; i < [main_menu numberOfItems]; i++) {
- [main_menu removeItemAtIndex:i];
- }
- for (Map<String, Vector<GlobalMenuItem>>::Element *E = global_menus.front(); E; E = E->next()) {
- if (E->key() != "_dock") {
- NSMenu *menu = [[[NSMenu alloc] initWithTitle:[NSString stringWithUTF8String:E->key().utf8().get_data()]] autorelease];
- for (int i = 0; i < E->get().size(); i++) {
- if (E->get()[i].label == String()) {
- [menu addItem:[NSMenuItem separatorItem]];
- } else {
- NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:E->get()[i].label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""];
- [menu_item setRepresentedObject:[NSValue valueWithPointer:&(E->get()[i])]];
- }
- }
- NSMenuItem *menu_item = [main_menu addItemWithTitle:[NSString stringWithUTF8String:E->key().utf8().get_data()] action:nil keyEquivalent:@""];
- [main_menu setSubmenu:menu forItem:menu_item];
- }
- }
-}
-
-void OS_OSX::global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta) {
-
- global_menus[p_menu].push_back(GlobalMenuItem(p_label, p_signal, p_meta));
- _update_global_menu();
-}
-
-void OS_OSX::global_menu_add_separator(const String &p_menu) {
-
- global_menus[p_menu].push_back(GlobalMenuItem());
- _update_global_menu();
-}
-
-void OS_OSX::global_menu_remove_item(const String &p_menu, int p_idx) {
-
- ERR_FAIL_INDEX(p_idx, global_menus[p_menu].size());
-
- global_menus[p_menu].remove(p_idx);
- _update_global_menu();
-}
-
-void OS_OSX::global_menu_clear(const String &p_menu) {
-
- global_menus[p_menu].clear();
- _update_global_menu();
-}
-
-Point2 OS_OSX::get_ime_selection() const {
-
- return im_selection;
-}
-
-String OS_OSX::get_ime_text() const {
-
- return im_text;
-}
-
-String OS_OSX::get_unique_id() const {
-
- static String serial_number;
-
- if (serial_number.empty()) {
- io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
- CFStringRef serialNumberAsCFString = NULL;
- if (platformExpert) {
- serialNumberAsCFString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
- IOObjectRelease(platformExpert);
- }
-
- NSString *serialNumberAsNSString = nil;
- if (serialNumberAsCFString) {
- serialNumberAsNSString = [NSString stringWithString:(NSString *)serialNumberAsCFString];
- CFRelease(serialNumberAsCFString);
- }
-
- serial_number = [serialNumberAsNSString UTF8String];
- }
-
- return serial_number;
-}
-
-void OS_OSX::set_ime_active(const bool p_active) {
-
- im_active = p_active;
- if (!im_active)
- [window_view cancelComposition];
-}
-
-void OS_OSX::set_ime_position(const Point2 &p_pos) {
-
- im_position = p_pos;
-}
-
-void OS_OSX::initialize_core() {
-
- crash_handler.initialize();
-
- OS_Unix::initialize_core();
-
- DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES);
- DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA);
- DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
-}
-
-static bool keyboard_layout_dirty = true;
-static void keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) {
- keyboard_layout_dirty = true;
-}
-
-static bool displays_arrangement_dirty = true;
-static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) {
- displays_arrangement_dirty = true;
-}
-
-int OS_OSX::get_current_video_driver() const {
- return video_driver_index;
-}
-
-Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
-
- /*** OSX INITIALIZATION ***/
- /*** OSX INITIALIZATION ***/
- /*** OSX INITIALIZATION ***/
-
- keyboard_layout_dirty = true;
- displays_arrangement_dirty = true;
-
- // Register to be notified on keyboard layout changes
- CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
- NULL, keyboard_layout_changed,
- kTISNotifySelectedKeyboardInputSourceChanged, NULL,
- CFNotificationSuspensionBehaviorDeliverImmediately);
-
- // Register to be notified on displays arrangement changes
- CGDisplayRegisterReconfigurationCallback(displays_arrangement_changed, NULL);
-
- //!!!!!!!!!!!!!!!!!!!!!!!!!!
- //TODO - do Vulkan and GLES2 support checks, driver selection and fallback
- video_driver_index = p_video_driver;
- print_verbose("Driver: " + String(get_video_driver_name(video_driver_index)) + " [" + itos(video_driver_index) + "]");
- //!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- //Create window
-
- window_delegate = [[GodotWindowDelegate alloc] init];
-
- // Don't use accumulation buffer support; it's not accelerated
- // Aux buffers probably aren't accelerated either
-
- unsigned int styleMask;
-
- if (p_desired.borderless_window) {
- styleMask = NSWindowStyleMaskBorderless;
- } else {
- resizable = p_desired.resizable;
- styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (p_desired.resizable ? NSWindowStyleMaskResizable : 0);
- }
-
- window_object = [[GodotWindow alloc]
- initWithContentRect:NSMakeRect(0, 0, p_desired.width, p_desired.height)
- styleMask:styleMask
- backing:NSBackingStoreBuffered
- defer:NO];
-
- ERR_FAIL_COND_V(window_object == nil, ERR_UNAVAILABLE);
-
- window_view = [[GodotContentView alloc] init];
- if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) {
- [window_view setWantsLayer:TRUE];
- }
-
- float displayScale = 1.0;
- if (is_hidpi_allowed()) {
- // note that mainScreen is not screen #0 but the one with the keyboard focus.
- NSScreen *screen = [NSScreen mainScreen];
- if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
- displayScale = fmax(displayScale, [screen backingScaleFactor]);
- }
- }
-
- window_size.width = p_desired.width * displayScale;
- window_size.height = p_desired.height * displayScale;
-
- if (displayScale > 1.0) {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- [window_view setWantsBestResolutionOpenGLSurface:YES];
- }
-#endif
- [window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
- } else {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- [window_view setWantsBestResolutionOpenGLSurface:NO];
- }
-#endif
- }
-
- [window_object setContentView:window_view];
- [window_object setDelegate:window_delegate];
- [window_object setAcceptsMouseMovedEvents:YES];
- [(NSWindow *)window_object center];
-
- [window_object setRestorable:NO];
-
- // Init context and rendering device
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
-
- context_gles2 = memnew(ContextGL_OSX(window_view, false));
-
- if (context_gles2->initialize() != OK) {
- memdelete(context_gles2);
- context_gles2 = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- context_gles2->set_use_vsync(p_desired.use_vsync);
-
- if (RasterizerGLES2::is_viable() == OK) {
- RasterizerGLES2::register_config();
- RasterizerGLES2::make_current();
- } else {
- memdelete(context_gles2);
- context_gles2 = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
-
- context_vulkan = memnew(VulkanContextOSX);
- if (context_vulkan->initialize() != OK) {
- memdelete(context_vulkan);
- context_vulkan = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- if (context_vulkan->window_create(window_view, get_video_mode().width, get_video_mode().height) == -1) {
- memdelete(context_vulkan);
- context_vulkan = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- rendering_device_vulkan = memnew(RenderingDeviceVulkan);
- rendering_device_vulkan->initialize(context_vulkan);
-
- RasterizerRD::make_current();
- }
-#endif
-
- [NSApp activateIgnoringOtherApps:YES];
-
- _update_window();
-
- [window_object makeKeyAndOrderFront:nil];
-
- if (p_desired.fullscreen)
- zoomed = true;
-
- visual_server = memnew(VisualServerRaster);
- if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
- }
-
- visual_server->init();
- AudioDriverManager::initialize(p_audio_driver);
-
- input = memnew(InputDefault);
- joypad_osx = memnew(JoypadOSX);
-
- _ensure_user_data_dir();
-
- restore_rect = Rect2(get_window_position(), get_window_size());
-
- if (p_desired.layered) {
- set_window_per_pixel_transparency_enabled(true);
- }
-
- update_real_mouse_position();
-
- return OK;
-}
-
-void OS_OSX::finalize() {
-
-#ifdef COREMIDI_ENABLED
- midi_driver.close();
-#endif
-
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
-
- if (context_gles2)
- memdelete(context_gles2);
- }
-#endif
-
- CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
- CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
-
- delete_main_loop();
-
- memdelete(joypad_osx);
- memdelete(input);
-
- cursors_cache.clear();
- visual_server->finish();
- memdelete(visual_server);
-}
-
-void OS_OSX::set_main_loop(MainLoop *p_main_loop) {
-
- main_loop = p_main_loop;
- input->set_main_loop(p_main_loop);
-}
-
-void OS_OSX::delete_main_loop() {
-
- if (!main_loop)
- return;
- memdelete(main_loop);
- main_loop = NULL;
-}
-
-String OS_OSX::get_name() const {
+#include <mach-o/dyld.h>
+#include <os/log.h>
- return "OSX";
-}
+/*************************************************************************/
+/* OSXTerminalLogger */
+/*************************************************************************/
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
class OSXTerminalLogger : public StdLogger {
public:
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR) {
@@ -1747,333 +100,101 @@ public:
}
};
-#else
-
-typedef UnixTerminalLogger OSXTerminalLogger;
-#endif
-
-void OS_OSX::alert(const String &p_alert, const String &p_title) {
- // Set OS X-compliant variables
- NSAlert *window = [[NSAlert alloc] init];
- NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
- NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()];
-
- [window addButtonWithTitle:@"OK"];
- [window setMessageText:ns_title];
- [window setInformativeText:ns_alert];
- [window setAlertStyle:NSAlertStyleWarning];
-
- // Display it, then release
- [window runModal];
- [window release];
-}
+/*************************************************************************/
+/* OS_OSX */
+/*************************************************************************/
-Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
+String OS_OSX::get_unique_id() const {
+ static String serial_number;
- String path = p_path;
+ if (serial_number.empty()) {
+ io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
+ CFStringRef serialNumberAsCFString = NULL;
+ if (platformExpert) {
+ serialNumberAsCFString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
+ IOObjectRelease(platformExpert);
+ }
- if (!FileAccess::exists(path)) {
- //this code exists so gdnative can load .dylib files from within the executable path
- path = get_executable_path().get_base_dir().plus_file(p_path.get_file());
- }
+ NSString *serialNumberAsNSString = nil;
+ if (serialNumberAsCFString) {
+ serialNumberAsNSString = [NSString stringWithString:(NSString *)serialNumberAsCFString];
+ CFRelease(serialNumberAsCFString);
+ }
- if (!FileAccess::exists(path)) {
- //this code exists so gdnative can load .dylib files from a standard macOS location
- path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file());
+ serial_number = [serialNumberAsNSString UTF8String];
}
- p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
- ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ", error: " + dlerror() + ".");
- return OK;
+ return serial_number;
}
-void OS_OSX::set_cursor_shape(CursorShape p_shape) {
-
- if (cursor_shape == p_shape)
- return;
-
- if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
- cursor_shape = p_shape;
- return;
- }
-
- if (cursors[p_shape] != NULL) {
- [cursors[p_shape] set];
- } else {
- switch (p_shape) {
- case CURSOR_ARROW: [[NSCursor arrowCursor] set]; break;
- case CURSOR_IBEAM: [[NSCursor IBeamCursor] set]; break;
- case CURSOR_POINTING_HAND: [[NSCursor pointingHandCursor] set]; break;
- case CURSOR_CROSS: [[NSCursor crosshairCursor] set]; break;
- case CURSOR_WAIT: [[NSCursor arrowCursor] set]; break;
- case CURSOR_BUSY: [[NSCursor arrowCursor] set]; break;
- case CURSOR_DRAG: [[NSCursor closedHandCursor] set]; break;
- case CURSOR_CAN_DROP: [[NSCursor openHandCursor] set]; break;
- case CURSOR_FORBIDDEN: [[NSCursor operationNotAllowedCursor] set]; break;
- case CURSOR_VSIZE: [cursorFromSelector(@selector(_windowResizeNorthSouthCursor), @selector(resizeUpDownCursor)) set]; break;
- case CURSOR_HSIZE: [cursorFromSelector(@selector(_windowResizeEastWestCursor), @selector(resizeLeftRightCursor)) set]; break;
- case CURSOR_BDIAGSIZE: [cursorFromSelector(@selector(_windowResizeNorthEastSouthWestCursor)) set]; break;
- case CURSOR_FDIAGSIZE: [cursorFromSelector(@selector(_windowResizeNorthWestSouthEastCursor)) set]; break;
- case CURSOR_MOVE: [[NSCursor arrowCursor] set]; break;
- case CURSOR_VSPLIT: [[NSCursor resizeUpDownCursor] set]; break;
- case CURSOR_HSPLIT: [[NSCursor resizeLeftRightCursor] set]; break;
- case CURSOR_HELP: [cursorFromSelector(@selector(_helpCursor)) set]; break;
- default: {
- };
- }
- }
+void OS_OSX::initialize_core() {
+ OS_Unix::initialize_core();
- cursor_shape = p_shape;
+ DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES);
+ DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA);
+ DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
}
-OS::CursorShape OS_OSX::get_cursor_shape() const {
-
- return cursor_shape;
+void OS_OSX::initialize_joypads() {
+ joypad_osx = memnew(JoypadOSX(InputFilter::get_singleton()));
}
-void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
-
- if (p_cursor.is_valid()) {
-
- Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
-
- if (cursor_c) {
- if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
- set_cursor_shape(p_shape);
- return;
- }
-
- cursors_cache.erase(p_shape);
- }
-
- Ref<Texture2D> texture = p_cursor;
- Ref<AtlasTexture> atlas_texture = p_cursor;
- Ref<Image> image;
- Size2 texture_size;
- Rect2 atlas_rect;
-
- if (texture.is_valid()) {
- image = texture->get_data();
- }
-
- if (!image.is_valid() && atlas_texture.is_valid()) {
- texture = atlas_texture->get_atlas();
-
- atlas_rect.size.width = texture->get_width();
- atlas_rect.size.height = texture->get_height();
- atlas_rect.position.x = atlas_texture->get_region().position.x;
- atlas_rect.position.y = atlas_texture->get_region().position.y;
-
- texture_size.width = atlas_texture->get_region().size.x;
- texture_size.height = atlas_texture->get_region().size.y;
- } else if (image.is_valid()) {
- texture_size.width = texture->get_width();
- texture_size.height = texture->get_height();
- }
-
- ERR_FAIL_COND(!texture.is_valid());
- ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0);
- ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256);
- ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height);
-
- image = texture->get_data();
-
- ERR_FAIL_COND(!image.is_valid());
-
- NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc]
- initWithBitmapDataPlanes:NULL
- pixelsWide:int(texture_size.width)
- pixelsHigh:int(texture_size.height)
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:int(texture_size.width) * 4
- bitsPerPixel:32];
-
- ERR_FAIL_COND(imgrep == nil);
- uint8_t *pixels = [imgrep bitmapData];
-
- int len = int(texture_size.width * texture_size.height);
-
- for (int i = 0; i < len; i++) {
- int row_index = floor(i / texture_size.width) + atlas_rect.position.y;
- int column_index = (i % int(texture_size.width)) + atlas_rect.position.x;
-
- if (atlas_texture.is_valid()) {
- column_index = MIN(column_index, atlas_rect.size.width - 1);
- row_index = MIN(row_index, atlas_rect.size.height - 1);
- }
-
- uint32_t color = image->get_pixel(column_index, row_index).to_argb32();
-
- uint8_t alpha = (color >> 24) & 0xFF;
- pixels[i * 4 + 0] = ((color >> 16) & 0xFF) * alpha / 255;
- pixels[i * 4 + 1] = ((color >> 8) & 0xFF) * alpha / 255;
- pixels[i * 4 + 2] = ((color)&0xFF) * alpha / 255;
- pixels[i * 4 + 3] = alpha;
- }
-
- NSImage *nsimage = [[NSImage alloc] initWithSize:NSMakeSize(texture_size.width, texture_size.height)];
- [nsimage addRepresentation:imgrep];
-
- NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)];
-
- [cursors[p_shape] release];
- cursors[p_shape] = cursor;
-
- Vector<Variant> params;
- params.push_back(p_cursor);
- params.push_back(p_hotspot);
- cursors_cache.insert(p_shape, params);
-
- if (p_shape == cursor_shape) {
- if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
- [cursor set];
- }
- }
-
- [imgrep release];
- [nsimage release];
- } else {
- // Reset to default system cursor
- if (cursors[p_shape] != NULL) {
- [cursors[p_shape] release];
- cursors[p_shape] = NULL;
- }
-
- CursorShape c = cursor_shape;
- cursor_shape = CURSOR_MAX;
- set_cursor_shape(c);
-
- cursors_cache.erase(p_shape);
- }
-}
-
-void OS_OSX::set_mouse_show(bool p_show) {
-}
+void OS_OSX::initialize() {
+ crash_handler.initialize();
-void OS_OSX::set_mouse_grab(bool p_grab) {
+ initialize_core();
+ //ensure_user_data_dir();
}
-bool OS_OSX::is_mouse_grab_enabled() const {
-
- return mouse_grab;
-}
+void OS_OSX::finalize() {
-void OS_OSX::warp_mouse_position(const Point2 &p_to) {
-
- //copied from windows impl with osx native calls
- if (mouse_mode == MOUSE_MODE_CAPTURED) {
- mouse_x = p_to.x;
- mouse_y = p_to.y;
- } else { //set OS position
-
- //local point in window coords
- const NSRect contentRect = [window_view frame];
- float displayScale = _display_scale();
- NSRect pointInWindowRect = NSMakeRect(p_to.x / displayScale, contentRect.size.height - (p_to.y / displayScale) - 1, 0, 0);
- NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin;
-
- //point in scren coords
- CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
-
- //do the warping
- CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
- CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0);
- CGAssociateMouseAndMouseCursorPosition(false);
- CGWarpMouseCursorPosition(lMouseWarpPos);
- CGAssociateMouseAndMouseCursorPosition(true);
- }
-}
+#ifdef COREMIDI_ENABLED
+ midi_driver.close();
+#endif
-void OS_OSX::update_real_mouse_position() {
+ delete_main_loop();
- get_mouse_pos([window_object mouseLocationOutsideOfEventStream], [window_view backingScaleFactor]);
- input->set_mouse_position(Point2(mouse_x, mouse_y));
+ memdelete(joypad_osx);
}
-Point2 OS_OSX::get_mouse_position() const {
-
- return Vector2(mouse_x, mouse_y);
+void OS_OSX::set_main_loop(MainLoop *p_main_loop) {
+ main_loop = p_main_loop;
}
-int OS_OSX::get_mouse_button_state() const {
- return button_mask;
+void OS_OSX::delete_main_loop() {
+ if (!main_loop)
+ return;
+ memdelete(main_loop);
+ main_loop = NULL;
}
-void OS_OSX::set_window_title(const String &p_title) {
- title = p_title;
-
- [window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
+String OS_OSX::get_name() const {
+ return "macOS";
}
-void OS_OSX::set_native_icon(const String &p_filename) {
-
- FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
- ERR_FAIL_COND(!f);
-
- Vector<uint8_t> data;
- uint32_t len = f->get_len();
- data.resize(len);
- f->get_buffer((uint8_t *)&data.write[0], len);
- memdelete(f);
-
- NSData *icon_data = [[[NSData alloc] initWithBytes:&data.write[0] length:len] autorelease];
- ERR_FAIL_COND_MSG(!icon_data, "Error reading icon data.");
-
- NSImage *icon = [[[NSImage alloc] initWithData:icon_data] autorelease];
- ERR_FAIL_COND_MSG(!icon, "Error loading icon.");
-
- [NSApp setApplicationIconImage:icon];
-}
+Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
+ String path = p_path;
-void OS_OSX::set_icon(const Ref<Image> &p_icon) {
-
- Ref<Image> img = p_icon;
- img = img->duplicate();
- img->convert(Image::FORMAT_RGBA8);
- NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
- initWithBitmapDataPlanes:NULL
- pixelsWide:img->get_width()
- pixelsHigh:img->get_height()
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:img->get_width() * 4
- bitsPerPixel:32] autorelease];
- ERR_FAIL_COND(imgrep == nil);
- uint8_t *pixels = [imgrep bitmapData];
-
- int len = img->get_width() * img->get_height();
- const uint8_t *r = img->get_data().ptr();
-
- /* Premultiply the alpha channel */
- for (int i = 0; i < len; i++) {
- uint8_t alpha = r[i * 4 + 3];
- pixels[i * 4 + 0] = (uint8_t)(((uint16_t)r[i * 4 + 0] * alpha) / 255);
- pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
- pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
- pixels[i * 4 + 3] = alpha;
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .dylib files from within the executable path
+ path = get_executable_path().get_base_dir().plus_file(p_path.get_file());
}
- NSImage *nsimg = [[[NSImage alloc] initWithSize:NSMakeSize(img->get_width(), img->get_height())] autorelease];
- ERR_FAIL_COND(nsimg == nil);
- [nsimg addRepresentation:imgrep];
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .dylib files from a standard macOS location
+ path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file());
+ }
- [NSApp setApplicationIconImage:nsimg];
+ p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
+ ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ", error: " + dlerror() + ".");
+ return OK;
}
MainLoop *OS_OSX::get_main_loop() const {
-
return main_loop;
}
String OS_OSX::get_config_path() const {
-
if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
@@ -2084,7 +205,6 @@ String OS_OSX::get_config_path() const {
}
String OS_OSX::get_data_path() const {
-
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else {
@@ -2093,7 +213,6 @@ String OS_OSX::get_data_path() const {
}
String OS_OSX::get_cache_path() const {
-
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
@@ -2104,7 +223,6 @@ String OS_OSX::get_cache_path() const {
}
String OS_OSX::get_bundle_resource_dir() const {
-
NSBundle *main = [NSBundle mainBundle];
NSString *resourcePath = [main resourcePath];
@@ -2118,12 +236,10 @@ String OS_OSX::get_bundle_resource_dir() const {
// Get properly capitalized engine name for system paths
String OS_OSX::get_godot_dir_name() const {
-
return String(VERSION_SHORT_NAME).capitalize();
}
String OS_OSX::get_system_dir(SystemDir p_dir) const {
-
NSSearchPathDirectory id;
bool found = true;
@@ -2166,62 +282,7 @@ String OS_OSX::get_system_dir(SystemDir p_dir) const {
return ret;
}
-bool OS_OSX::can_draw() const {
-
- return true;
-}
-
-void OS_OSX::set_clipboard(const String &p_text) {
-
- NSString *copiedString = [NSString stringWithUTF8String:p_text.utf8().get_data()];
- NSArray *copiedStringArray = [NSArray arrayWithObject:copiedString];
-
- NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
- [pasteboard clearContents];
- [pasteboard writeObjects:copiedStringArray];
-}
-
-String OS_OSX::get_clipboard() const {
-
- NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
- NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
- NSDictionary *options = [NSDictionary dictionary];
-
- BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
-
- if (!ok) {
- return "";
- }
-
- NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
- NSString *string = [objectsToPaste objectAtIndex:0];
-
- char *utfs = strdup([string UTF8String]);
- String ret;
- ret.parse_utf8(utfs);
- free(utfs);
-
- return ret;
-}
-
-void OS_OSX::release_rendering_thread() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->release_current();
- }
-#endif
-}
-
-void OS_OSX::make_rendering_thread() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->make_current();
- }
-#endif
-}
-
Error OS_OSX::shell_open(String p_uri) {
-
[[NSWorkspace sharedWorkspace] openURL:[[NSURL alloc] initWithString:[[NSString stringWithUTF8String:p_uri.utf8().get_data()] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]];
return OK;
}
@@ -2231,491 +292,7 @@ String OS_OSX::get_locale() const {
return [locale_code UTF8String];
}
-void OS_OSX::swap_buffers() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->swap_buffers();
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- context_vulkan->swap_buffers();
- }
-#endif
-}
-
-void OS_OSX::wm_minimized(bool p_minimized) {
-
- minimized = p_minimized;
-};
-
-void OS_OSX::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
-}
-
-OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
-
- VideoMode vm;
- vm.width = window_size.width;
- vm.height = window_size.height;
-
- return vm;
-}
-
-void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
-}
-
-int OS_OSX::get_screen_count() const {
- NSArray *screenArray = [NSScreen screens];
- return [screenArray count];
-};
-
-// Returns the native top-left screen coordinate of the smallest rectangle
-// that encompasses all screens. Needed in get_screen_position(),
-// get_window_position, and set_window_position()
-// to convert between OS X native screen coordinates and the ones expected by Godot
-Point2 OS_OSX::get_screens_origin() const {
- static Point2 origin;
-
- if (displays_arrangement_dirty) {
- origin = Point2();
-
- for (int i = 0; i < get_screen_count(); i++) {
- Point2 position = get_native_screen_position(i);
- if (position.x < origin.x) {
- origin.x = position.x;
- }
- if (position.y > origin.y) {
- origin.y = position.y;
- }
- }
-
- displays_arrangement_dirty = false;
- }
-
- return origin;
-}
-
-static int get_screen_index(NSScreen *screen) {
- const NSUInteger index = [[NSScreen screens] indexOfObject:screen];
- return index == NSNotFound ? 0 : index;
-}
-
-int OS_OSX::get_current_screen() const {
- if (window_object) {
- return get_screen_index([window_object screen]);
- } else {
- return get_screen_index([NSScreen mainScreen]);
- }
-};
-
-void OS_OSX::set_current_screen(int p_screen) {
- Vector2 wpos = get_window_position() - get_screen_position(get_current_screen());
- set_window_position(wpos + get_screen_position(p_screen));
-};
-
-Point2 OS_OSX::get_native_screen_position(int p_screen) const {
- if (p_screen < 0) {
- p_screen = get_current_screen();
- }
-
- NSArray *screenArray = [NSScreen screens];
- if ((NSUInteger)p_screen < [screenArray count]) {
- float display_scale = _display_scale([screenArray objectAtIndex:p_screen]);
- NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
- // Return the top-left corner of the screen, for OS X the y starts at the bottom
- return Point2(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * display_scale;
- }
-
- return Point2();
-}
-
-Point2 OS_OSX::get_screen_position(int p_screen) const {
- Point2 position = get_native_screen_position(p_screen) - get_screens_origin();
- // OS X native y-coordinate relative to get_screens_origin() is negative,
- // Godot expects a positive value
- position.y *= -1;
- return position;
-}
-
-int OS_OSX::get_screen_dpi(int p_screen) const {
- if (p_screen < 0) {
- p_screen = get_current_screen();
- }
-
- NSArray *screenArray = [NSScreen screens];
- if ((NSUInteger)p_screen < [screenArray count]) {
- float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
- NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
- NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
- CGSize displayPhysicalSize = CGDisplayScreenSize(
- [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
-
- return (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
- }
-
- return 72;
-}
-
-Size2 OS_OSX::get_screen_size(int p_screen) const {
- if (p_screen < 0) {
- p_screen = get_current_screen();
- }
-
- NSArray *screenArray = [NSScreen screens];
- if ((NSUInteger)p_screen < [screenArray count]) {
- float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
- // Note: Use frame to get the whole screen size
- NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
- return Size2(nsrect.size.width, nsrect.size.height) * displayScale;
- }
-
- return Size2();
-}
-
-void OS_OSX::_update_window() {
- bool borderless_full = false;
-
- if (get_borderless_window()) {
- NSRect frameRect = [window_object frame];
- NSRect screenRect = [[window_object screen] frame];
-
- // Check if our window covers up the screen
- if (frameRect.origin.x <= screenRect.origin.x && frameRect.origin.y <= frameRect.origin.y &&
- frameRect.size.width >= screenRect.size.width && frameRect.size.height >= screenRect.size.height) {
- borderless_full = true;
- }
- }
-
- if (borderless_full) {
- // If the window covers up the screen set the level to above the main menu and hide on deactivate
- [window_object setLevel:NSMainMenuWindowLevel + 1];
- [window_object setHidesOnDeactivate:YES];
- } else {
- // Reset these when our window is not a borderless window that covers up the screen
- [window_object setLevel:NSNormalWindowLevel];
- [window_object setHidesOnDeactivate:NO];
- }
-}
-
-float OS_OSX::_display_scale() const {
- if (window_object) {
- return _display_scale([window_object screen]);
- } else {
- return _display_scale([NSScreen mainScreen]);
- }
-}
-
-float OS_OSX::_display_scale(id screen) const {
- if (is_hidpi_allowed()) {
- if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
- return fmax(1.0, [screen backingScaleFactor]);
- }
- }
- return 1.0;
-}
-
-Point2 OS_OSX::get_native_window_position() const {
-
- NSRect nsrect = [window_object frame];
- Point2 pos;
- float display_scale = _display_scale();
-
- // Return the position of the top-left corner, for OS X the y starts at the bottom
- pos.x = nsrect.origin.x * display_scale;
- pos.y = (nsrect.origin.y + nsrect.size.height) * display_scale;
-
- return pos;
-};
-
-Point2 OS_OSX::get_window_position() const {
- Point2 position = get_native_window_position() - get_screens_origin();
- // OS X native y-coordinate relative to get_screens_origin() is negative,
- // Godot expects a positive value
- position.y *= -1;
- return position;
-}
-
-void OS_OSX::set_native_window_position(const Point2 &p_position) {
-
- NSPoint pos;
- float displayScale = _display_scale();
-
- pos.x = p_position.x / displayScale;
- pos.y = p_position.y / displayScale;
-
- [window_object setFrameTopLeftPoint:pos];
-
- _update_window();
-};
-
-void OS_OSX::set_window_position(const Point2 &p_position) {
- Point2 position = p_position;
- // OS X native y-coordinate relative to get_screens_origin() is negative,
- // Godot passes a positive value
- position.y *= -1;
- set_native_window_position(get_screens_origin() + position);
-
- update_real_mouse_position();
-};
-
-Size2 OS_OSX::get_window_size() const {
-
- return window_size;
-};
-
-Size2 OS_OSX::get_real_window_size() const {
-
- NSRect frame = [window_object frame];
- return Size2(frame.size.width, frame.size.height) * _display_scale();
-}
-
-Size2 OS_OSX::get_max_window_size() const {
- return max_size;
-}
-
-Size2 OS_OSX::get_min_window_size() const {
- return min_size;
-}
-
-void OS_OSX::set_min_window_size(const Size2 p_size) {
-
- if ((p_size != Size2()) && (max_size != Size2()) && ((p_size.x > max_size.x) || (p_size.y > max_size.y))) {
- ERR_PRINT("Minimum window size can't be larger than maximum window size!");
- return;
- }
- min_size = p_size;
-
- if ((min_size != Size2()) && !zoomed) {
- Size2 size = min_size / _display_scale();
- [window_object setContentMinSize:NSMakeSize(size.x, size.y)];
- } else {
- [window_object setContentMinSize:NSMakeSize(0, 0)];
- }
-}
-
-void OS_OSX::set_max_window_size(const Size2 p_size) {
-
- if ((p_size != Size2()) && ((p_size.x < min_size.x) || (p_size.y < min_size.y))) {
- ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
- return;
- }
- max_size = p_size;
-
- if ((max_size != Size2()) && !zoomed) {
- Size2 size = max_size / _display_scale();
- [window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
- } else {
- [window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
- }
-}
-
-void OS_OSX::set_window_size(const Size2 p_size) {
-
- Size2 size = p_size / _display_scale();
-
- if (get_borderless_window() == false) {
- // NSRect used by setFrame includes the title bar, so add it to our size.y
- CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- if (menuBarHeight != 0.f) {
- size.y += menuBarHeight;
- } else {
- if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_12) {
- size.y += [[NSStatusBar systemStatusBar] thickness];
- }
- }
- }
-
- NSRect frame = [window_object frame];
- [window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
-
- _update_window();
-};
-
-void OS_OSX::set_window_fullscreen(bool p_enabled) {
-
- if (zoomed != p_enabled) {
- if (layered_window)
- set_window_per_pixel_transparency_enabled(false);
- if (!resizable)
- [window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable];
- if (p_enabled) {
- [window_object setContentMinSize:NSMakeSize(0, 0)];
- [window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
- } else {
- if (min_size != Size2()) {
- Size2 size = min_size / _display_scale();
- [window_object setContentMinSize:NSMakeSize(size.x, size.y)];
- }
- if (max_size != Size2()) {
- Size2 size = max_size / _display_scale();
- [window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
- }
- }
- [window_object toggleFullScreen:nil];
- }
- zoomed = p_enabled;
-};
-
-bool OS_OSX::is_window_fullscreen() const {
-
- return zoomed;
-};
-
-void OS_OSX::set_window_resizable(bool p_enabled) {
-
- if (p_enabled)
- [window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable];
- else if (!zoomed)
- [window_object setStyleMask:[window_object styleMask] & ~NSWindowStyleMaskResizable];
-
- resizable = p_enabled;
-};
-
-bool OS_OSX::is_window_resizable() const {
-
- return [window_object styleMask] & NSWindowStyleMaskResizable;
-};
-
-void OS_OSX::set_window_minimized(bool p_enabled) {
-
- if (p_enabled)
- [window_object performMiniaturize:nil];
- else
- [window_object deminiaturize:nil];
-};
-
-bool OS_OSX::is_window_minimized() const {
-
- if ([window_object respondsToSelector:@selector(isMiniaturized)])
- return [window_object isMiniaturized];
-
- return minimized;
-};
-
-void OS_OSX::set_window_maximized(bool p_enabled) {
-
- if (p_enabled) {
- restore_rect = Rect2(get_window_position(), get_window_size());
- [window_object setFrame:[[[NSScreen screens] objectAtIndex:get_current_screen()] visibleFrame] display:YES];
- } else {
- set_window_size(restore_rect.size);
- set_window_position(restore_rect.position);
- };
- maximized = p_enabled;
-};
-
-bool OS_OSX::is_window_maximized() const {
-
- // don't know
- return maximized;
-};
-
-void OS_OSX::move_window_to_foreground() {
-
- [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
- [window_object makeKeyAndOrderFront:nil];
-}
-
-void OS_OSX::set_window_always_on_top(bool p_enabled) {
- if (is_window_always_on_top() == p_enabled)
- return;
-
- if (p_enabled)
- [window_object setLevel:NSFloatingWindowLevel];
- else
- [window_object setLevel:NSNormalWindowLevel];
-}
-
-bool OS_OSX::is_window_always_on_top() const {
- return [window_object level] == NSFloatingWindowLevel;
-}
-
-bool OS_OSX::is_window_focused() const {
- return window_focused;
-}
-
-void OS_OSX::request_attention() {
-
- [NSApp requestUserAttention:NSCriticalRequest];
-}
-
-bool OS_OSX::get_window_per_pixel_transparency_enabled() const {
-
- if (!is_layered_allowed()) return false;
- return layered_window;
-}
-
-void OS_OSX::set_window_per_pixel_transparency_enabled(bool p_enabled) {
-
- if (!is_layered_allowed()) return;
- if (layered_window != p_enabled) {
- if (p_enabled) {
- set_borderless_window(true);
- [window_object setBackgroundColor:[NSColor clearColor]];
- [window_object setOpaque:NO];
- [window_object setHasShadow:NO];
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->set_opacity(0);
- }
-#endif
- layered_window = true;
- } else {
- [window_object setBackgroundColor:[NSColor colorWithCalibratedWhite:1 alpha:1]];
- [window_object setOpaque:YES];
- [window_object setHasShadow:YES];
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->set_opacity(1);
- }
-#endif
- layered_window = false;
- }
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->update();
- }
-#endif
- NSRect frame = [window_object frame];
- [window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, 1, 1) display:YES];
- [window_object setFrame:frame display:YES];
- }
-}
-
-void OS_OSX::set_borderless_window(bool p_borderless) {
-
- // OrderOut prevents a lose focus bug with the window
- [window_object orderOut:nil];
-
- if (p_borderless) {
- [window_object setStyleMask:NSWindowStyleMaskBorderless];
- } else {
- if (layered_window)
- set_window_per_pixel_transparency_enabled(false);
-
- [window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (resizable ? NSWindowStyleMaskResizable : 0)];
-
- // Force update of the window styles
- NSRect frameRect = [window_object frame];
- [window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
- [window_object setFrame:frameRect display:NO];
-
- // Restore the window title
- [window_object setTitle:[NSString stringWithUTF8String:title.utf8().get_data()]];
- }
-
- _update_window();
-
- [window_object makeKeyAndOrderFront:nil];
-}
-
-bool OS_OSX::get_borderless_window() {
-
- return [window_object styleMask] == NSWindowStyleMaskBorderless;
-}
-
String OS_OSX::get_executable_path() const {
-
int ret;
pid_t pid;
char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
@@ -2732,177 +309,7 @@ String OS_OSX::get_executable_path() const {
}
}
-// Returns string representation of keys, if they are printable.
-//
-static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
-
- TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
- if (!currentKeyboard)
- return nil;
-
- CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
- if (!layoutData)
- return nil;
-
- const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
-
- OSStatus err;
- CFMutableStringRef output = CFStringCreateMutable(NULL, 0);
-
- for (int i = 0; i < length; ++i) {
-
- UInt32 keysDown = 0;
- UniChar chars[4];
- UniCharCount realLength;
-
- err = UCKeyTranslate(keyboardLayout,
- keyCode[i],
- kUCKeyActionDisplay,
- 0,
- LMGetKbdType(),
- kUCKeyTranslateNoDeadKeysBit,
- &keysDown,
- sizeof(chars) / sizeof(chars[0]),
- &realLength,
- chars);
-
- if (err != noErr) {
- CFRelease(output);
- return nil;
- }
-
- CFStringAppendCharacters(output, chars, 1);
- }
-
- //CFStringUppercase(output, NULL);
-
- return (NSString *)output;
-}
-
-OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
-
- static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
-
- if (keyboard_layout_dirty) {
-
- layout = LATIN_KEYBOARD_QWERTY;
-
- CGKeyCode keys[] = { kVK_ANSI_Q, kVK_ANSI_W, kVK_ANSI_E, kVK_ANSI_R, kVK_ANSI_T, kVK_ANSI_Y };
- NSString *test = createStringForKeys(keys, 6);
-
- if ([test isEqualToString:@"qwertz"]) {
- layout = LATIN_KEYBOARD_QWERTZ;
- } else if ([test isEqualToString:@"azerty"]) {
- layout = LATIN_KEYBOARD_AZERTY;
- } else if ([test isEqualToString:@"qzerty"]) {
- layout = LATIN_KEYBOARD_QZERTY;
- } else if ([test isEqualToString:@"',.pyf"]) {
- layout = LATIN_KEYBOARD_DVORAK;
- } else if ([test isEqualToString:@"xvlcwk"]) {
- layout = LATIN_KEYBOARD_NEO;
- } else if ([test isEqualToString:@"qwfpgj"]) {
- layout = LATIN_KEYBOARD_COLEMAK;
- }
-
- [test release];
-
- keyboard_layout_dirty = false;
- return layout;
- }
-
- return layout;
-}
-
-void OS_OSX::process_events() {
-
- while (true) {
- NSEvent *event = [NSApp
- nextEventMatchingMask:NSEventMaskAny
- untilDate:[NSDate distantPast]
- inMode:NSDefaultRunLoopMode
- dequeue:YES];
-
- if (event == nil)
- break;
-
- [NSApp sendEvent:event];
- }
- process_key_events();
-
- [autoreleasePool drain];
- autoreleasePool = [[NSAutoreleasePool alloc] init];
-
- input->flush_accumulated_events();
-}
-
-void OS_OSX::process_key_events() {
-
- Ref<InputEventKey> k;
- for (int i = 0; i < key_event_pos; i++) {
-
- const KeyEvent &ke = key_event_buffer[i];
-
- if (ke.raw) {
- // Non IME input - no composite characters, pass events as is
- k.instance();
-
- get_key_modifier_state(ke.osx_state, k);
- k->set_pressed(ke.pressed);
- k->set_echo(ke.echo);
- k->set_keycode(ke.keycode);
- k->set_physical_keycode(ke.physical_keycode);
- k->set_unicode(ke.unicode);
-
- push_input(k);
- } else {
- // IME input
- if ((i == 0 && ke.keycode == 0) || (i > 0 && key_event_buffer[i - 1].keycode == 0)) {
- k.instance();
-
- get_key_modifier_state(ke.osx_state, k);
- k->set_pressed(ke.pressed);
- k->set_echo(ke.echo);
- k->set_keycode(0);
- k->set_physical_keycode(0);
- k->set_unicode(ke.unicode);
-
- push_input(k);
- }
- if (ke.keycode != 0) {
- k.instance();
-
- get_key_modifier_state(ke.osx_state, k);
- k->set_pressed(ke.pressed);
- k->set_echo(ke.echo);
- k->set_keycode(ke.keycode);
- k->set_physical_keycode(ke.physical_keycode);
-
- if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) {
- k->set_unicode(key_event_buffer[i + 1].unicode);
- }
-
- push_input(k);
- }
- }
- }
-
- key_event_pos = 0;
-}
-
-void OS_OSX::push_input(const Ref<InputEvent> &p_event) {
-
- Ref<InputEvent> ev = p_event;
- input->accumulate_input_event(ev);
-}
-
-void OS_OSX::force_process_input() {
-
- process_events(); // get rid of pending events
- joypad_osx->process_joypads();
-}
-
void OS_OSX::run() {
-
force_quit = false;
if (!main_loop)
@@ -2910,23 +317,12 @@ void OS_OSX::run() {
main_loop->init();
- if (zoomed) {
- zoomed = false;
- set_window_fullscreen(true);
- }
-
- //uint64_t last_ticks=get_ticks_usec();
-
- //int frames=0;
- //uint64_t frame=0;
-
bool quit = false;
-
while (!force_quit && !quit) {
-
@try {
-
- process_events(); // get rid of pending events
+ if (DisplayServer::get_singleton()) {
+ DisplayServer::get_singleton()->process_events(); // get rid of pending events
+ }
joypad_osx->process_joypads();
if (Main::iteration() == true) {
@@ -2936,41 +332,9 @@ void OS_OSX::run() {
ERR_PRINT("NSException: " + String([exception reason].UTF8String));
}
};
-
main_loop->finish();
}
-void OS_OSX::set_mouse_mode(MouseMode p_mode) {
-
- if (p_mode == mouse_mode)
- return;
-
- if (p_mode == MOUSE_MODE_CAPTURED) {
- // Apple Docs state that the display parameter is not used.
- // "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
- // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
- CGDisplayHideCursor(kCGDirectMainDisplay);
- CGAssociateMouseAndMouseCursorPosition(false);
- } else if (p_mode == MOUSE_MODE_HIDDEN) {
- CGDisplayHideCursor(kCGDirectMainDisplay);
- CGAssociateMouseAndMouseCursorPosition(true);
- } else {
- CGDisplayShowCursor(kCGDirectMainDisplay);
- CGAssociateMouseAndMouseCursorPosition(true);
- }
-
- mouse_mode = p_mode;
-}
-
-OS::MouseMode OS_OSX::get_mouse_mode() const {
-
- return mouse_mode;
-}
-
-String OS_OSX::get_joy_guid(int p_device) const {
- return input->get_joy_guid_remapped(p_device);
-}
-
Error OS_OSX::move_to_trash(const String &p_path) {
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *url = [NSURL fileURLWithPath:@(p_path.utf8().get_data())];
@@ -2984,123 +348,19 @@ Error OS_OSX::move_to_trash(const String &p_path) {
return OK;
}
-void OS_OSX::_set_use_vsync(bool p_enable) {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- if (context_gles2)
- context_gles2->set_use_vsync(p_enable);
- }
-#endif
-}
-
-OS_OSX *OS_OSX::singleton = NULL;
-
OS_OSX::OS_OSX() {
-
- memset(cursors, 0, sizeof(cursors));
- key_event_pos = 0;
- mouse_mode = OS::MOUSE_MODE_VISIBLE;
main_loop = NULL;
- singleton = this;
- im_active = false;
- im_position = Point2();
- layered_window = false;
- autoreleasePool = [[NSAutoreleasePool alloc] init];
-
- eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
- ERR_FAIL_COND(!eventSource);
-
- CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0);
-
- // Implicitly create shared NSApplication instance
- [GodotApplication sharedApplication];
-
- // In case we are unbundled, make us a proper UI application
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-
- // Menu bar setup must go between sharedApplication above and
- // finishLaunching below, in order to properly emulate the behavior
- // of NSApplicationMain
- NSMenuItem *menu_item;
- NSString *title;
-
- NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
- if (nsappname == nil)
- nsappname = [[NSProcessInfo processInfo] processName];
-
- // Setup Apple menu
- NSMenu *apple_menu = [[NSMenu alloc] initWithTitle:@""];
- title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
- [apple_menu addItemWithTitle:title action:@selector(showAbout:) keyEquivalent:@""];
-
- [apple_menu addItem:[NSMenuItem separatorItem]];
-
- NSMenu *services = [[NSMenu alloc] initWithTitle:@""];
- menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Services", nil) action:nil keyEquivalent:@""];
- [apple_menu setSubmenu:services forItem:menu_item];
- [NSApp setServicesMenu:services];
- [services release];
-
- [apple_menu addItem:[NSMenuItem separatorItem]];
-
- title = [NSString stringWithFormat:NSLocalizedString(@"Hide %@", nil), nsappname];
- [apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
-
- menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menu_item setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)];
-
- [apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
- [apple_menu addItem:[NSMenuItem separatorItem]];
-
- title = [NSString stringWithFormat:NSLocalizedString(@"Quit %@", nil), nsappname];
- [apple_menu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
- // Setup menu bar
- NSMenu *main_menu = [[NSMenu alloc] initWithTitle:@""];
- menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
- [main_menu setSubmenu:apple_menu forItem:menu_item];
- [NSApp setMainMenu:main_menu];
-
- [main_menu release];
- [apple_menu release];
-
- [NSApp finishLaunching];
-
- delegate = [[GodotApplicationDelegate alloc] init];
- ERR_FAIL_COND(!delegate);
- [NSApp setDelegate:delegate];
-
- cursor_shape = CURSOR_ARROW;
-
- maximized = false;
- minimized = false;
- window_size = Vector2(1024, 600);
- zoomed = false;
- resizable = false;
- window_focused = true;
+ force_quit = false;
Vector<Logger *> loggers;
loggers.push_back(memnew(OSXTerminalLogger));
_set_logger(memnew(CompositeLogger(loggers)));
- //process application:openFile: event
- while (true) {
- NSEvent *event = [NSApp
- nextEventMatchingMask:NSEventMaskAny
- untilDate:[NSDate distantPast]
- inMode:NSDefaultRunLoopMode
- dequeue:YES];
-
- if (event == nil)
- break;
-
- [NSApp sendEvent:event];
- }
-
#ifdef COREAUDIO_ENABLED
AudioDriverManager::add_driver(&audio_driver);
#endif
+
+ DisplayServerOSX::register_osx_driver();
}
bool OS_OSX::_check_internal_feature_support(const String &p_feature) {
diff --git a/platform/osx/vulkan_context_osx.h b/platform/osx/vulkan_context_osx.h
index 619e91d1f6..09a5494ae8 100644
--- a/platform/osx/vulkan_context_osx.h
+++ b/platform/osx/vulkan_context_osx.h
@@ -39,7 +39,7 @@ class VulkanContextOSX : public VulkanContext {
virtual const char *_get_platform_surface_extension() const;
public:
- int window_create(id p_window, int p_width, int p_height);
+ Error window_create(DisplayServer::WindowID p_window_id, id p_window, int p_width, int p_height);
VulkanContextOSX();
~VulkanContextOSX();
diff --git a/platform/osx/vulkan_context_osx.mm b/platform/osx/vulkan_context_osx.mm
index c132bd334a..320401cdcb 100644
--- a/platform/osx/vulkan_context_osx.mm
+++ b/platform/osx/vulkan_context_osx.mm
@@ -35,7 +35,7 @@ const char *VulkanContextOSX::_get_platform_surface_extension() const {
return VK_MVK_MACOS_SURFACE_EXTENSION_NAME;
}
-int VulkanContextOSX::window_create(id p_window, int p_width, int p_height) {
+Error VulkanContextOSX::window_create(DisplayServer::WindowID p_window_id, id p_window, int p_width, int p_height) {
VkMacOSSurfaceCreateInfoMVK createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
@@ -45,8 +45,8 @@ int VulkanContextOSX::window_create(id p_window, int p_width, int p_height) {
VkSurfaceKHR surface;
VkResult err = vkCreateMacOSSurfaceMVK(_get_instance(), &createInfo, NULL, &surface);
- ERR_FAIL_COND_V(err, -1);
- return _window_create(surface, p_width, p_height);
+ ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
+ return _window_create(p_window_id, surface, p_width, p_height);
}
VulkanContextOSX::VulkanContextOSX() {
diff --git a/platform/server/detect.py b/platform/server/detect.py
index db9ba8d036..4ea4bddddd 100644
--- a/platform/server/detect.py
+++ b/platform/server/detect.py
@@ -16,7 +16,7 @@ def get_name():
def get_program_suffix():
if (sys.platform == "darwin"):
return "osx"
- return "x11"
+ return "linuxbsd"
def can_build():
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index 3257ec261c..6b26ceed57 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -33,7 +33,7 @@
#include "core/print_string.h"
#include "drivers/dummy/rasterizer_dummy.h"
#include "drivers/dummy/texture_loader_dummy.h"
-#include "servers/visual/visual_server_raster.h"
+#include "servers/rendering/rendering_server_raster.h"
#include "main/main.h"
@@ -80,8 +80,8 @@ Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int
video_driver_index = p_video_driver; // unused in server platform, but should still be initialized
- visual_server = memnew(VisualServerRaster);
- visual_server->init();
+ rendering_server = memnew(RenderingServerRaster);
+ rendering_server->init();
AudioDriverManager::initialize(p_audio_driver);
@@ -101,8 +101,8 @@ void OS_Server::finalize() {
memdelete(main_loop);
main_loop = NULL;
- visual_server->finish();
- memdelete(visual_server);
+ rendering_server->finish();
+ memdelete(rendering_server);
memdelete(input);
diff --git a/platform/server/os_server.h b/platform/server/os_server.h
index 7584293722..62028b26e4 100644
--- a/platform/server/os_server.h
+++ b/platform/server/os_server.h
@@ -31,24 +31,24 @@
#ifndef OS_SERVER_H
#define OS_SERVER_H
+#include "core/input/input_filter.h"
#include "drivers/dummy/texture_loader_dummy.h"
#include "drivers/unix/os_unix.h"
-#include "main/input_default.h"
#ifdef __APPLE__
#include "platform/osx/crash_handler_osx.h"
#include "platform/osx/semaphore_osx.h"
#else
-#include "platform/x11/crash_handler_x11.h"
+#include "platform/x11/crash_handler_linuxbsd.h"
#endif
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
#undef CursorShape
class OS_Server : public OS_Unix {
- VisualServer *visual_server;
+ RenderingServer *rendering_server;
VideoMode current_videomode;
List<String> args;
MainLoop *main_loop;
diff --git a/platform/uwp/export/export.h b/platform/uwp/export/export.h
index ce03bc0aeb..1a1555d8ee 100644
--- a/platform/uwp/export/export.h
+++ b/platform/uwp/export/export.h
@@ -28,4 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef UWP_EXPORT_H
+#define UWP_EXPORT_H
+
void register_uwp_exporter();
+
+#endif // UWP_EXPORT_H
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index f2a721f3dd..054b67ddc8 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -31,7 +31,7 @@
#ifndef JOYPAD_UWP_H
#define JOYPAD_UWP_H
-#include "main/input_default.h"
+#include "core/input/input_filter.h"
ref class JoypadUWP sealed {
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 4ddb5463d0..85719d13ae 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -45,8 +45,8 @@
#include "main/main.h"
#include "platform/windows/windows_terminal_logger.h"
#include "servers/audio_server.h"
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_wrap_mt.h"
#include "thread_uwp.h"
#include <ppltasks.h>
@@ -254,13 +254,13 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
set_video_mode(vm);
- visual_server = memnew(VisualServerRaster);
+ rendering_server = memnew(RenderingServerRaster);
// FIXME: Reimplement threaded rendering
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, false));
+ rendering_server = memnew(RenderingServerWrapMT(rendering_server, false));
}
- visual_server->init();
+ rendering_server->init();
input = memnew(InputDefault);
@@ -349,8 +349,8 @@ void OS_UWP::finalize() {
main_loop = NULL;
- visual_server->finish();
- memdelete(visual_server);
+ rendering_server->finish();
+ memdelete(rendering_server);
#ifdef OPENGL_ENABLED
if (gl_context)
memdelete(gl_context);
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index ac6e0f3dd5..de3b094ef4 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -32,16 +32,15 @@
#define OS_UWP_H
#include "context_egl_uwp.h"
+#include "core/input/input_filter.h"
#include "core/math/transform_2d.h"
-#include "core/os/input.h"
#include "core/os/os.h"
#include "core/ustring.h"
#include "drivers/xaudio2/audio_driver_xaudio2.h"
#include "joypad_uwp.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
#include <fcntl.h>
#include <io.h>
@@ -89,7 +88,7 @@ private:
bool outside;
int old_x, old_y;
Point2i center;
- VisualServer *visual_server;
+ RenderingServer *rendering_server;
int pressrc;
ContextEGL_UWP *gl_context;
diff --git a/platform/windows/SCsub b/platform/windows/SCsub
index 8e94c7b35d..89ee4dfa7a 100644
--- a/platform/windows/SCsub
+++ b/platform/windows/SCsub
@@ -10,6 +10,7 @@ common_win = [
"godot_windows.cpp",
"crash_handler_windows.cpp",
"os_windows.cpp",
+ "display_server_windows.cpp",
"key_mapping_windows.cpp",
"joypad_windows.cpp",
"windows_terminal_logger.cpp",
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
new file mode 100644
index 0000000000..836fa5946a
--- /dev/null
+++ b/platform/windows/display_server_windows.cpp
@@ -0,0 +1,2998 @@
+/*************************************************************************/
+/* display_server_windows.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "display_server_windows.h"
+#include "core/io/marshalls.h"
+#include "main/main.h"
+#include "os_windows.h"
+#include "scene/resources/texture.h"
+
+#include <avrt.h>
+
+#ifndef WM_POINTERUPDATE
+#define WM_POINTERUPDATE 0x0245
+#endif
+
+#ifdef DEBUG_ENABLED
+static String format_error_message(DWORD id) {
+
+ LPWSTR messageBuffer = NULL;
+ size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL);
+
+ String msg = "Error " + itos(id) + ": " + String(messageBuffer, size);
+
+ LocalFree(messageBuffer);
+
+ return msg;
+}
+#endif // DEBUG_ENABLED
+
+bool DisplayServerWindows::has_feature(Feature p_feature) const {
+ switch (p_feature) {
+ case FEATURE_SUBWINDOWS:
+ case FEATURE_TOUCHSCREEN:
+ case FEATURE_MOUSE:
+ case FEATURE_MOUSE_WARP:
+ case FEATURE_CLIPBOARD:
+ case FEATURE_CURSOR_SHAPE:
+ case FEATURE_CUSTOM_CURSOR_SHAPE:
+ case FEATURE_CONSOLE_WINDOW:
+ case FEATURE_IME:
+ case FEATURE_WINDOW_TRANSPARENCY:
+ case FEATURE_HIDPI:
+ case FEATURE_ICON:
+ case FEATURE_NATIVE_ICON:
+ case FEATURE_SWAP_BUFFERS:
+ case FEATURE_KEEP_SCREEN_ON:
+ return true;
+ default:
+ return false;
+ }
+}
+
+String DisplayServerWindows::get_name() const {
+ return "Windows";
+}
+
+void DisplayServerWindows::alert(const String &p_alert, const String &p_title) {
+ MessageBoxW(NULL, p_alert.c_str(), p_title.c_str(), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
+}
+
+void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) {
+
+ if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED) {
+ WindowData &wd = windows[MAIN_WINDOW_ID];
+
+ RECT clipRect;
+ GetClientRect(wd.hWnd, &clipRect);
+ ClientToScreen(wd.hWnd, (POINT *)&clipRect.left);
+ ClientToScreen(wd.hWnd, (POINT *)&clipRect.right);
+ ClipCursor(&clipRect);
+ if (p_mode == MOUSE_MODE_CAPTURED) {
+
+ center = window_get_size() / 2;
+ POINT pos = { (int)center.x, (int)center.y };
+ ClientToScreen(wd.hWnd, &pos);
+ SetCursorPos(pos.x, pos.y);
+ SetCapture(wd.hWnd);
+ }
+ } else {
+ ReleaseCapture();
+ ClipCursor(NULL);
+ }
+
+ if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) {
+ hCursor = SetCursor(NULL);
+ } else {
+ CursorShape c = cursor_shape;
+ cursor_shape = CURSOR_MAX;
+ cursor_set_shape(c);
+ }
+}
+void DisplayServerWindows::mouse_set_mode(MouseMode p_mode) {
+
+ _THREAD_SAFE_METHOD_
+
+ if (mouse_mode == p_mode)
+ return;
+
+ _set_mouse_mode_impl(p_mode);
+
+ mouse_mode = p_mode;
+}
+DisplayServer::MouseMode DisplayServerWindows::mouse_get_mode() const {
+ return mouse_mode;
+}
+
+void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
+
+ _THREAD_SAFE_METHOD_
+
+ if (!windows.has(last_focused_window)) {
+ return; //no window focused?
+ }
+
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+
+ old_x = p_to.x;
+ old_y = p_to.y;
+ } else {
+
+ POINT p;
+ p.x = p_to.x;
+ p.y = p_to.y;
+ ClientToScreen(windows[last_focused_window].hWnd, &p);
+
+ SetCursorPos(p.x, p.y);
+ }
+}
+Point2i DisplayServerWindows::mouse_get_position() const {
+ POINT p;
+ GetCursorPos(&p);
+ return Point2i(p.x, p.y);
+ //return Point2(old_x, old_y);
+}
+int DisplayServerWindows::mouse_get_button_state() const {
+ return last_button_state;
+}
+
+void DisplayServerWindows::clipboard_set(const String &p_text) {
+
+ _THREAD_SAFE_METHOD_
+
+ if (!windows.has(last_focused_window)) {
+ return; //no window focused?
+ }
+
+ // Convert LF line endings to CRLF in clipboard content
+ // Otherwise, line endings won't be visible when pasted in other software
+ String text = p_text.replace("\n", "\r\n");
+
+ if (!OpenClipboard(windows[last_focused_window].hWnd)) {
+ ERR_FAIL_MSG("Unable to open clipboard.");
+ }
+ EmptyClipboard();
+
+ HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * sizeof(CharType));
+ ERR_FAIL_COND_MSG(mem == NULL, "Unable to allocate memory for clipboard contents.");
+
+ LPWSTR lptstrCopy = (LPWSTR)GlobalLock(mem);
+ memcpy(lptstrCopy, text.c_str(), (text.length() + 1) * sizeof(CharType));
+ GlobalUnlock(mem);
+
+ SetClipboardData(CF_UNICODETEXT, mem);
+
+ // set the CF_TEXT version (not needed?)
+ CharString utf8 = text.utf8();
+ mem = GlobalAlloc(GMEM_MOVEABLE, utf8.length() + 1);
+ ERR_FAIL_COND_MSG(mem == NULL, "Unable to allocate memory for clipboard contents.");
+
+ LPTSTR ptr = (LPTSTR)GlobalLock(mem);
+ memcpy(ptr, utf8.get_data(), utf8.length());
+ ptr[utf8.length()] = 0;
+ GlobalUnlock(mem);
+
+ SetClipboardData(CF_TEXT, mem);
+
+ CloseClipboard();
+}
+String DisplayServerWindows::clipboard_get() const {
+
+ _THREAD_SAFE_METHOD_
+
+ if (!windows.has(last_focused_window)) {
+ return String(); //no window focused?
+ }
+
+ String ret;
+ if (!OpenClipboard(windows[last_focused_window].hWnd)) {
+ ERR_FAIL_V_MSG("", "Unable to open clipboard.");
+ };
+
+ if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
+
+ HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
+ if (mem != NULL) {
+
+ LPWSTR ptr = (LPWSTR)GlobalLock(mem);
+ if (ptr != NULL) {
+
+ ret = String((CharType *)ptr);
+ GlobalUnlock(mem);
+ };
+ };
+
+ } else if (IsClipboardFormatAvailable(CF_TEXT)) {
+
+ HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
+ if (mem != NULL) {
+
+ LPTSTR ptr = (LPTSTR)GlobalLock(mem);
+ if (ptr != NULL) {
+
+ ret.parse_utf8((const char *)ptr);
+ GlobalUnlock(mem);
+ };
+ };
+ };
+
+ CloseClipboard();
+
+ return ret;
+}
+
+typedef struct {
+ int count;
+ int screen;
+ HMONITOR monitor;
+} EnumScreenData;
+
+static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumScreenData *data = (EnumScreenData *)dwData;
+ if (data->monitor == hMonitor) {
+ data->screen = data->count;
+ }
+
+ data->count++;
+ return TRUE;
+}
+
+static BOOL CALLBACK _MonitorEnumProcCount(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ int *data = (int *)dwData;
+ (*data)++;
+ return TRUE;
+}
+
+int DisplayServerWindows::get_screen_count() const {
+ _THREAD_SAFE_METHOD_
+
+ int data = 0;
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcCount, (LPARAM)&data);
+ return data;
+}
+
+typedef struct {
+ int count;
+ int screen;
+ Point2 pos;
+} EnumPosData;
+
+static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumPosData *data = (EnumPosData *)dwData;
+ if (data->count == data->screen) {
+ data->pos.x = lprcMonitor->left;
+ data->pos.y = lprcMonitor->top;
+ }
+
+ data->count++;
+ return TRUE;
+}
+Point2i DisplayServerWindows::screen_get_position(int p_screen) const {
+
+ _THREAD_SAFE_METHOD_
+
+ EnumPosData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Point2() };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcPos, (LPARAM)&data);
+ return data.pos;
+}
+
+typedef struct {
+ int count;
+ int screen;
+ Size2 size;
+} EnumSizeData;
+
+typedef struct {
+ int count;
+ int screen;
+ Rect2i rect;
+} EnumRectData;
+
+static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumSizeData *data = (EnumSizeData *)dwData;
+ if (data->count == data->screen) {
+ data->size.x = lprcMonitor->right - lprcMonitor->left;
+ data->size.y = lprcMonitor->bottom - lprcMonitor->top;
+ }
+
+ data->count++;
+ return TRUE;
+}
+
+Size2i DisplayServerWindows::screen_get_size(int p_screen) const {
+
+ _THREAD_SAFE_METHOD_
+
+ EnumSizeData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Size2() };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
+ return data.size;
+}
+
+static BOOL CALLBACK _MonitorEnumProcUsableSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumRectData *data = (EnumRectData *)dwData;
+ if (data->count == data->screen) {
+ MONITORINFO minfo;
+ zeromem(&minfo, sizeof(MONITORINFO));
+ minfo.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfoA(hMonitor, &minfo);
+
+ data->rect.position.x = minfo.rcWork.left;
+ data->rect.position.y = minfo.rcWork.top;
+ data->rect.size.x = minfo.rcWork.right - minfo.rcWork.left;
+ data->rect.size.y = minfo.rcWork.bottom - minfo.rcWork.top;
+ }
+
+ data->count++;
+ return TRUE;
+}
+
+Rect2i DisplayServerWindows::screen_get_usable_rect(int p_screen) const {
+
+ _THREAD_SAFE_METHOD_
+
+ EnumRectData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Rect2i() };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcUsableSize, (LPARAM)&data);
+ return data.rect;
+}
+
+typedef struct {
+ int count;
+ int screen;
+ int dpi;
+} EnumDpiData;
+
+enum _MonitorDpiType {
+ MDT_Effective_DPI = 0,
+ MDT_Angular_DPI = 1,
+ MDT_Raw_DPI = 2,
+ MDT_Default = MDT_Effective_DPI
+};
+
+static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Default) {
+
+ int dpiX = 96, dpiY = 96;
+
+ static HMODULE Shcore = NULL;
+ typedef HRESULT(WINAPI * GetDPIForMonitor_t)(HMONITOR hmonitor, _MonitorDpiType dpiType, UINT * dpiX, UINT * dpiY);
+ static GetDPIForMonitor_t getDPIForMonitor = NULL;
+
+ if (Shcore == NULL) {
+ Shcore = LoadLibraryW(L"Shcore.dll");
+ getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : NULL;
+
+ if ((Shcore == NULL) || (getDPIForMonitor == NULL)) {
+ if (Shcore)
+ FreeLibrary(Shcore);
+ Shcore = (HMODULE)INVALID_HANDLE_VALUE;
+ }
+ }
+
+ UINT x = 0, y = 0;
+ HRESULT hr = E_FAIL;
+ if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE)) {
+ hr = getDPIForMonitor(hmon, dpiType /*MDT_Effective_DPI*/, &x, &y);
+ if (SUCCEEDED(hr) && (x > 0) && (y > 0)) {
+
+ dpiX = (int)x;
+ dpiY = (int)y;
+ }
+ } else {
+ static int overallX = 0, overallY = 0;
+ if (overallX <= 0 || overallY <= 0) {
+ HDC hdc = GetDC(NULL);
+ if (hdc) {
+ overallX = GetDeviceCaps(hdc, LOGPIXELSX);
+ overallY = GetDeviceCaps(hdc, LOGPIXELSY);
+ ReleaseDC(NULL, hdc);
+ }
+ }
+ if (overallX > 0 && overallY > 0) {
+ dpiX = overallX;
+ dpiY = overallY;
+ }
+ }
+
+ return (dpiX + dpiY) / 2;
+}
+
+static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumDpiData *data = (EnumDpiData *)dwData;
+ if (data->count == data->screen) {
+ data->dpi = QueryDpiForMonitor(hMonitor);
+ }
+
+ data->count++;
+ return TRUE;
+}
+
+int DisplayServerWindows::screen_get_dpi(int p_screen) const {
+ _THREAD_SAFE_METHOD_
+
+ EnumDpiData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, 72 };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcDpi, (LPARAM)&data);
+ return data.dpi;
+}
+bool DisplayServerWindows::screen_is_touchscreen(int p_screen) const {
+#ifndef _MSC_VER
+#warning touchscreen not working
+#endif
+ return false;
+}
+
+void DisplayServerWindows::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
+}
+DisplayServer::ScreenOrientation DisplayServerWindows::screen_get_orientation(int p_screen) const {
+ return SCREEN_LANDSCAPE;
+}
+
+void DisplayServerWindows::screen_set_keep_on(bool p_enable) {
+}
+bool DisplayServerWindows::screen_is_kept_on() const {
+ return false;
+}
+
+Vector<DisplayServer::WindowID> DisplayServerWindows::get_window_list() const {
+
+ _THREAD_SAFE_METHOD_
+
+ Vector<DisplayServer::WindowID> ret;
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ ret.push_back(E->key());
+ }
+ return ret;
+}
+
+DisplayServer::WindowID DisplayServerWindows::get_window_at_screen_position(const Point2i &p_position) const {
+
+ POINT p;
+ p.x = p_position.x;
+ p.y = p_position.y;
+ HWND hwnd = WindowFromPoint(p);
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (E->get().hWnd == hwnd) {
+ return E->key();
+ }
+ }
+
+ return INVALID_WINDOW_ID;
+}
+
+DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
+
+ _THREAD_SAFE_METHOD_
+
+ WindowID window_id = _create_window(p_mode, p_flags, p_rect);
+
+ WindowData &wd = windows[window_id];
+
+ if (p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT) {
+ wd.resizable = false;
+ }
+ if (p_flags & WINDOW_FLAG_BORDERLESS_BIT) {
+ wd.borderless = true;
+ }
+ if (p_flags & WINDOW_FLAG_ALWAYS_ON_TOP_BIT && p_mode != WINDOW_MODE_FULLSCREEN) {
+ wd.always_on_top = true;
+ }
+ if (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) {
+ wd.no_focus = true;
+ }
+
+ _update_window_style(window_id);
+
+ ShowWindow(wd.hWnd, (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) ? SW_SHOWNOACTIVATE : SW_SHOW); // Show The Window
+ if (!(p_flags & WINDOW_FLAG_NO_FOCUS_BIT)) {
+ SetForegroundWindow(wd.hWnd); // Slightly Higher Priority
+ SetFocus(wd.hWnd); // Sets Keyboard Focus To
+ }
+
+ return window_id;
+}
+void DisplayServerWindows::delete_sub_window(WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window cannot be deleted.");
+
+ WindowData &wd = windows[p_window];
+
+ while (wd.transient_children.size()) {
+ window_set_transient(wd.transient_children.front()->get(), INVALID_WINDOW_ID);
+ }
+
+ if (wd.transient_parent != INVALID_WINDOW_ID) {
+ window_set_transient(p_window, INVALID_WINDOW_ID);
+ }
+
+#ifdef VULKAN_ENABLED
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_destroy(p_window);
+ }
+#endif
+
+ DestroyWindow(windows[p_window].hWnd);
+ windows.erase(p_window);
+}
+
+void DisplayServerWindows::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].instance_id = p_instance;
+}
+
+ObjectID DisplayServerWindows::window_get_attached_instance_id(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), ObjectID());
+ return windows[p_window].instance_id;
+}
+
+void DisplayServerWindows::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].rect_changed_callback = p_callable;
+}
+
+void DisplayServerWindows::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].event_callback = p_callable;
+}
+void DisplayServerWindows::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].input_event_callback = p_callable;
+}
+void DisplayServerWindows::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].input_text_callback = p_callable;
+}
+
+void DisplayServerWindows::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ windows[p_window].drop_files_callback = p_callable;
+}
+
+void DisplayServerWindows::window_set_title(const String &p_title, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ SetWindowTextW(windows[p_window].hWnd, p_title.c_str());
+}
+
+int DisplayServerWindows::window_get_current_screen(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), -1);
+
+ EnumScreenData data = { 0, 0, MonitorFromWindow(windows[p_window].hWnd, MONITOR_DEFAULTTONEAREST) };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&data);
+ return data.screen;
+}
+void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ ERR_FAIL_INDEX(p_screen, get_screen_count());
+
+ Vector2 ofs = window_get_position(p_window) - screen_get_position(window_get_current_screen(p_window));
+ window_set_position(ofs + screen_get_position(p_screen), p_window);
+}
+
+Point2i DisplayServerWindows::window_get_position(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
+ const WindowData &wd = windows[p_window];
+
+ if (wd.minimized) {
+ return wd.last_pos;
+ }
+
+ POINT point;
+ point.x = 0;
+ point.y = 0;
+
+ ClientToScreen(wd.hWnd, &point);
+
+ return Point2i(point.x, point.y);
+
+#if 0
+ //do not use this method, as it includes windows decorations
+ RECT r;
+ GetWindowRect(wd.hWnd, &r);
+ return Point2(r.left, r.top);
+#endif
+}
+void DisplayServerWindows::_update_real_mouse_position(WindowID p_window) {
+
+ POINT mouse_pos;
+ if (GetCursorPos(&mouse_pos) && ScreenToClient(windows[p_window].hWnd, &mouse_pos)) {
+ if (mouse_pos.x > 0 && mouse_pos.y > 0 && mouse_pos.x <= windows[p_window].width && mouse_pos.y <= windows[p_window].height) {
+ old_x = mouse_pos.x;
+ old_y = mouse_pos.y;
+ old_invalid = false;
+ InputFilter::get_singleton()->set_mouse_position(Point2i(mouse_pos.x, mouse_pos.y));
+ }
+ }
+}
+void DisplayServerWindows::window_set_position(const Point2i &p_position, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if (wd.fullscreen) return;
+#if 0
+ //wrong needs to account properly for decorations
+ RECT r;
+ GetWindowRect(wd.hWnd, &r);
+ MoveWindow(wd.hWnd, p_position.x, p_position.y, r.right - r.left, r.bottom - r.top, TRUE);
+#else
+
+ RECT rc;
+ rc.left = p_position.x;
+ rc.right = p_position.x + wd.width;
+ rc.bottom = p_position.y + wd.height;
+ rc.top = p_position.y;
+
+ const DWORD style = GetWindowLongPtr(wd.hWnd, GWL_STYLE);
+ const DWORD exStyle = GetWindowLongPtr(wd.hWnd, GWL_EXSTYLE);
+
+ AdjustWindowRectEx(&rc, style, false, exStyle);
+ MoveWindow(wd.hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
+#endif
+ // Don't let the mouse leave the window when moved
+ if (mouse_mode == MOUSE_MODE_CONFINED) {
+ RECT rect;
+ GetClientRect(wd.hWnd, &rect);
+ ClientToScreen(wd.hWnd, (POINT *)&rect.left);
+ ClientToScreen(wd.hWnd, (POINT *)&rect.right);
+ ClipCursor(&rect);
+ }
+
+ wd.last_pos = p_position;
+ _update_real_mouse_position(p_window);
+}
+
+void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_parent) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(p_window == p_parent);
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd_window = windows[p_window];
+
+ ERR_FAIL_COND(wd_window.transient_parent == p_parent);
+
+ ERR_FAIL_COND_MSG(wd_window.always_on_top, "Windows with the 'on top' can't become transient.");
+
+ if (p_parent == INVALID_WINDOW_ID) {
+ //remove transient
+
+ ERR_FAIL_COND(wd_window.transient_parent == INVALID_WINDOW_ID);
+ ERR_FAIL_COND(!windows.has(wd_window.transient_parent));
+
+ WindowData &wd_parent = windows[wd_window.transient_parent];
+
+ wd_window.transient_parent = INVALID_WINDOW_ID;
+ wd_parent.transient_children.erase(p_window);
+
+ SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, NULL);
+ } else {
+ ERR_FAIL_COND(!windows.has(p_parent));
+ ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent");
+ WindowData &wd_parent = windows[p_parent];
+
+ wd_window.transient_parent = p_parent;
+ wd_parent.transient_children.insert(p_window);
+
+ SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, (LONG_PTR)wd_parent.hWnd);
+ }
+}
+
+void DisplayServerWindows::window_set_max_size(const Size2i p_size, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if ((p_size != Size2()) && ((p_size.x < wd.min_size.x) || (p_size.y < wd.min_size.y))) {
+ ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
+ return;
+ }
+ wd.max_size = p_size;
+}
+Size2i DisplayServerWindows::window_get_max_size(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+ return wd.max_size;
+}
+
+void DisplayServerWindows::window_set_min_size(const Size2i p_size, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if ((p_size != Size2()) && (wd.max_size != Size2()) && ((p_size.x > wd.max_size.x) || (p_size.y > wd.max_size.y))) {
+ ERR_PRINT("Minimum window size can't be larger than maximum window size!");
+ return;
+ }
+ wd.min_size = p_size;
+}
+Size2i DisplayServerWindows::window_get_min_size(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+ return wd.min_size;
+}
+
+void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ int w = p_size.width;
+ int h = p_size.height;
+
+ wd.width = w;
+ wd.height = h;
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_resize(p_window, w, h);
+ }
+#endif
+
+ if (wd.fullscreen) {
+ return;
+ }
+
+ RECT rect;
+ GetWindowRect(wd.hWnd, &rect);
+
+ if (!wd.borderless) {
+ RECT crect;
+ GetClientRect(wd.hWnd, &crect);
+
+ w += (rect.right - rect.left) - (crect.right - crect.left);
+ h += (rect.bottom - rect.top) - (crect.bottom - crect.top);
+ }
+
+ MoveWindow(wd.hWnd, rect.left, rect.top, w, h, TRUE);
+
+ // Don't let the mouse leave the window when resizing to a smaller resolution
+ if (mouse_mode == MOUSE_MODE_CONFINED) {
+ RECT crect;
+ GetClientRect(wd.hWnd, &crect);
+ ClientToScreen(wd.hWnd, (POINT *)&crect.left);
+ ClientToScreen(wd.hWnd, (POINT *)&crect.right);
+ ClipCursor(&crect);
+ }
+}
+Size2i DisplayServerWindows::window_get_size(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+
+ if (wd.minimized) {
+ return Size2(wd.width, wd.height);
+ }
+
+ RECT r;
+ if (GetClientRect(wd.hWnd, &r)) { // Only area inside of window border
+ return Size2(r.right - r.left, r.bottom - r.top);
+ }
+ return Size2();
+}
+Size2i DisplayServerWindows::window_get_real_size(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
+ const WindowData &wd = windows[p_window];
+
+ RECT r;
+ if (GetWindowRect(wd.hWnd, &r)) { // Includes area of the window border
+ return Size2(r.right - r.left, r.bottom - r.top);
+ }
+ return Size2();
+}
+
+void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscreen, bool p_borderless, bool p_resizable, bool p_maximized, bool p_no_activate_focus, DWORD &r_style, DWORD &r_style_ex) {
+
+ r_style = 0;
+ r_style_ex = WS_EX_WINDOWEDGE;
+ if (p_main_window) {
+ r_style_ex |= WS_EX_APPWINDOW;
+ }
+
+ if (p_fullscreen || p_borderless) {
+ r_style |= WS_POPUP;
+ //if (p_borderless) {
+ // r_style_ex |= WS_EX_TOOLWINDOW;
+ //}
+ } else {
+
+ if (p_resizable) {
+ if (p_maximized) {
+ r_style = WS_OVERLAPPEDWINDOW | WS_MAXIMIZE;
+ } else {
+ r_style = WS_OVERLAPPEDWINDOW;
+ }
+ } else {
+ r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU;
+ }
+ }
+
+ if (p_no_activate_focus) {
+ r_style_ex |= WS_EX_TOPMOST | WS_EX_NOACTIVATE;
+ }
+ r_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+}
+
+void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint, bool p_maximized) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ DWORD style = 0;
+ DWORD style_ex = 0;
+
+ _get_window_style(p_window == MAIN_WINDOW_ID, wd.fullscreen, wd.borderless, wd.resizable, wd.maximized, wd.no_focus, style, style_ex);
+
+ SetWindowLongPtr(wd.hWnd, GWL_STYLE, style);
+ SetWindowLongPtr(wd.hWnd, GWL_EXSTYLE, style_ex);
+
+ SetWindowPos(wd.hWnd, wd.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | (wd.no_focus ? SWP_NOACTIVATE : 0));
+
+ if (p_repaint) {
+ RECT rect;
+ GetWindowRect(wd.hWnd, &rect);
+ MoveWindow(wd.hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
+ }
+}
+
+void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if (wd.fullscreen && p_mode != WINDOW_MODE_FULLSCREEN) {
+
+ RECT rect;
+
+ wd.fullscreen = false;
+
+ if (wd.pre_fs_valid) {
+ rect = wd.pre_fs_rect;
+ } else {
+ rect.left = 0;
+ rect.right = wd.width;
+ rect.top = 0;
+ rect.bottom = wd.height;
+ }
+
+ _update_window_style(p_window, false, wd.was_maximized);
+
+ MoveWindow(wd.hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
+
+ wd.pre_fs_valid = true;
+ }
+
+ if (p_mode == WINDOW_MODE_MAXIMIZED) {
+
+ ShowWindow(wd.hWnd, SW_MAXIMIZE);
+ wd.maximized = true;
+ wd.minimized = false;
+ }
+
+ if (p_mode == WINDOW_MODE_WINDOWED) {
+
+ ShowWindow(wd.hWnd, SW_RESTORE);
+ wd.maximized = false;
+ wd.minimized = false;
+ }
+
+ if (p_mode == WINDOW_MODE_MINIMIZED) {
+
+ ShowWindow(wd.hWnd, SW_MINIMIZE);
+ wd.maximized = false;
+ wd.minimized = true;
+ }
+
+ if (p_mode == WINDOW_MODE_FULLSCREEN && !wd.fullscreen) {
+ if (wd.minimized) {
+ ShowWindow(wd.hWnd, SW_RESTORE);
+ }
+ wd.was_maximized = wd.maximized;
+
+ if (wd.pre_fs_valid) {
+ GetWindowRect(wd.hWnd, &wd.pre_fs_rect);
+ }
+
+ int cs = window_get_current_screen(p_window);
+ Point2 pos = screen_get_position(cs);
+ Size2 size = screen_get_size(cs);
+
+ wd.fullscreen = true;
+ wd.maximized = false;
+ wd.minimized = false;
+
+ _update_window_style(false);
+
+ MoveWindow(wd.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
+ }
+}
+DisplayServer::WindowMode DisplayServerWindows::window_get_mode(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED);
+ const WindowData &wd = windows[p_window];
+
+ if (wd.fullscreen) {
+ return WINDOW_MODE_FULLSCREEN;
+ } else if (wd.minimized) {
+ return WINDOW_MODE_MINIMIZED;
+ } else if (wd.maximized) {
+ return WINDOW_MODE_MAXIMIZED;
+ } else {
+ return WINDOW_MODE_WINDOWED;
+ }
+}
+
+bool DisplayServerWindows::window_is_maximize_allowed(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), false);
+ const WindowData &wd = windows[p_window];
+
+ return true; //no idea
+}
+
+void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+ switch (p_flag) {
+ case WINDOW_FLAG_RESIZE_DISABLED: {
+
+ wd.resizable = !p_enabled;
+ _update_window_style(p_window);
+ } break;
+ case WINDOW_FLAG_BORDERLESS: {
+
+ wd.borderless = p_enabled;
+ _update_window_style(p_window);
+ } break;
+ case WINDOW_FLAG_ALWAYS_ON_TOP: {
+
+ ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID && p_enabled, "Transient windows can't become on top");
+ wd.always_on_top = p_enabled;
+ _update_window_style(p_window);
+ } break;
+ case WINDOW_FLAG_TRANSPARENT: {
+
+ } break;
+ case WINDOW_FLAG_NO_FOCUS: {
+
+ wd.no_focus = p_enabled;
+ _update_window_style(p_window);
+ } break;
+ }
+}
+bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), false);
+ const WindowData &wd = windows[p_window];
+ switch (p_flag) {
+ case WINDOW_FLAG_RESIZE_DISABLED: {
+
+ return !wd.resizable;
+ } break;
+ case WINDOW_FLAG_BORDERLESS: {
+
+ return wd.borderless;
+ } break;
+ case WINDOW_FLAG_ALWAYS_ON_TOP: {
+
+ return wd.always_on_top;
+ } break;
+ case WINDOW_FLAG_TRANSPARENT: {
+
+ } break;
+ }
+
+ return false;
+}
+
+void DisplayServerWindows::window_request_attention(WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ FLASHWINFO info;
+ info.cbSize = sizeof(FLASHWINFO);
+ info.hwnd = wd.hWnd;
+ info.dwFlags = FLASHW_TRAY;
+ info.dwTimeout = 0;
+ info.uCount = 2;
+ FlashWindowEx(&info);
+}
+void DisplayServerWindows::window_move_to_foreground(WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ SetForegroundWindow(wd.hWnd);
+}
+
+bool DisplayServerWindows::window_can_draw(WindowID p_window) const {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND_V(!windows.has(p_window), false);
+ const WindowData &wd = windows[p_window];
+ return wd.minimized;
+}
+
+bool DisplayServerWindows::can_any_window_draw() const {
+
+ _THREAD_SAFE_METHOD_
+
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (!E->get().minimized) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void DisplayServerWindows::window_set_ime_active(const bool p_active, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ if (p_active) {
+ ImmAssociateContext(wd.hWnd, wd.im_himc);
+
+ window_set_ime_position(wd.im_position, p_window);
+ } else {
+ ImmAssociateContext(wd.hWnd, (HIMC)0);
+ }
+}
+void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!windows.has(p_window));
+ WindowData &wd = windows[p_window];
+
+ wd.im_position = p_pos;
+
+ HIMC himc = ImmGetContext(wd.hWnd);
+ if (himc == (HIMC)0)
+ return;
+
+ COMPOSITIONFORM cps;
+ cps.dwStyle = CFS_FORCE_POSITION;
+ cps.ptCurrentPos.x = wd.im_position.x;
+ cps.ptCurrentPos.y = wd.im_position.y;
+ ImmSetCompositionWindow(himc, &cps);
+ ImmReleaseContext(wd.hWnd, himc);
+}
+
+void DisplayServerWindows::console_set_visible(bool p_enabled) {
+
+ _THREAD_SAFE_METHOD_
+
+ if (console_visible == p_enabled)
+ return;
+ ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE);
+ console_visible = p_enabled;
+}
+bool DisplayServerWindows::is_console_visible() const {
+ return console_visible;
+}
+
+void DisplayServerWindows::cursor_set_shape(CursorShape p_shape) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
+
+ if (cursor_shape == p_shape)
+ return;
+
+ if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
+ cursor_shape = p_shape;
+ return;
+ }
+
+ static const LPCTSTR win_cursors[CURSOR_MAX] = {
+ IDC_ARROW,
+ IDC_IBEAM,
+ IDC_HAND, //finger
+ IDC_CROSS,
+ IDC_WAIT,
+ IDC_APPSTARTING,
+ IDC_ARROW,
+ IDC_ARROW,
+ IDC_NO,
+ IDC_SIZENS,
+ IDC_SIZEWE,
+ IDC_SIZENESW,
+ IDC_SIZENWSE,
+ IDC_SIZEALL,
+ IDC_SIZENS,
+ IDC_SIZEWE,
+ IDC_HELP
+ };
+
+ if (cursors[p_shape] != NULL) {
+ SetCursor(cursors[p_shape]);
+ } else {
+ SetCursor(LoadCursor(hInstance, win_cursors[p_shape]));
+ }
+
+ cursor_shape = p_shape;
+}
+DisplayServer::CursorShape DisplayServerWindows::cursor_get_shape() const {
+ return cursor_shape;
+}
+
+void DisplayServerWindows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap) {
+
+ // Get the system display DC
+ HDC hDC = GetDC(NULL);
+
+ // Create helper DC
+ HDC hMainDC = CreateCompatibleDC(hDC);
+ HDC hAndMaskDC = CreateCompatibleDC(hDC);
+ HDC hXorMaskDC = CreateCompatibleDC(hDC);
+
+ // Get the dimensions of the source bitmap
+ BITMAP bm;
+ GetObject(hSourceBitmap, sizeof(BITMAP), &bm);
+
+ // Create the mask bitmaps
+ hAndMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // color
+ hXorMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // color
+
+ // Release the system display DC
+ ReleaseDC(NULL, hDC);
+
+ // Select the bitmaps to helper DC
+ HBITMAP hOldMainBitmap = (HBITMAP)SelectObject(hMainDC, hSourceBitmap);
+ HBITMAP hOldAndMaskBitmap = (HBITMAP)SelectObject(hAndMaskDC, hAndMaskBitmap);
+ HBITMAP hOldXorMaskBitmap = (HBITMAP)SelectObject(hXorMaskDC, hXorMaskBitmap);
+
+ // Assign the monochrome AND mask bitmap pixels so that a pixels of the source bitmap
+ // with 'clrTransparent' will be white pixels of the monochrome bitmap
+ SetBkColor(hMainDC, clrTransparent);
+ BitBlt(hAndMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCCOPY);
+
+ // Assign the color XOR mask bitmap pixels so that a pixels of the source bitmap
+ // with 'clrTransparent' will be black and rest the pixels same as corresponding
+ // pixels of the source bitmap
+ SetBkColor(hXorMaskDC, RGB(0, 0, 0));
+ SetTextColor(hXorMaskDC, RGB(255, 255, 255));
+ BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hAndMaskDC, 0, 0, SRCCOPY);
+ BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCAND);
+
+ // Deselect bitmaps from the helper DC
+ SelectObject(hMainDC, hOldMainBitmap);
+ SelectObject(hAndMaskDC, hOldAndMaskBitmap);
+ SelectObject(hXorMaskDC, hOldXorMaskBitmap);
+
+ // Delete the helper DC
+ DeleteDC(hXorMaskDC);
+ DeleteDC(hAndMaskDC);
+ DeleteDC(hMainDC);
+}
+
+void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+
+ _THREAD_SAFE_METHOD_
+
+ if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ cursor_set_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
+ Ref<Texture2D> texture = p_cursor;
+ Ref<AtlasTexture> atlas_texture = p_cursor;
+ Ref<Image> image;
+ Size2 texture_size;
+ Rect2 atlas_rect;
+
+ if (texture.is_valid()) {
+ image = texture->get_data();
+ }
+
+ if (!image.is_valid() && atlas_texture.is_valid()) {
+ texture = atlas_texture->get_atlas();
+
+ atlas_rect.size.width = texture->get_width();
+ atlas_rect.size.height = texture->get_height();
+ atlas_rect.position.x = atlas_texture->get_region().position.x;
+ atlas_rect.position.y = atlas_texture->get_region().position.y;
+
+ texture_size.width = atlas_texture->get_region().size.x;
+ texture_size.height = atlas_texture->get_region().size.y;
+ } else if (image.is_valid()) {
+ texture_size.width = texture->get_width();
+ texture_size.height = texture->get_height();
+ }
+
+ ERR_FAIL_COND(!texture.is_valid());
+ ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0);
+ ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256);
+ ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height);
+
+ image = texture->get_data();
+
+ ERR_FAIL_COND(!image.is_valid());
+
+ UINT image_size = texture_size.width * texture_size.height;
+
+ // Create the BITMAP with alpha channel
+ COLORREF *buffer = (COLORREF *)memalloc(sizeof(COLORREF) * image_size);
+
+ for (UINT index = 0; index < image_size; index++) {
+ int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
+ int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
+
+ if (atlas_texture.is_valid()) {
+ column_index = MIN(column_index, atlas_rect.size.width - 1);
+ row_index = MIN(row_index, atlas_rect.size.height - 1);
+ }
+
+ *(buffer + index) = image->get_pixel(column_index, row_index).to_argb32();
+ }
+
+ // Using 4 channels, so 4 * 8 bits
+ HBITMAP bitmap = CreateBitmap(texture_size.width, texture_size.height, 1, 4 * 8, buffer);
+ COLORREF clrTransparent = -1;
+
+ // Create the AND and XOR masks for the bitmap
+ HBITMAP hAndMask = NULL;
+ HBITMAP hXorMask = NULL;
+
+ GetMaskBitmaps(bitmap, clrTransparent, hAndMask, hXorMask);
+
+ if (NULL == hAndMask || NULL == hXorMask) {
+ memfree(buffer);
+ DeleteObject(bitmap);
+ return;
+ }
+
+ // Finally, create the icon
+ ICONINFO iconinfo;
+ iconinfo.fIcon = FALSE;
+ iconinfo.xHotspot = p_hotspot.x;
+ iconinfo.yHotspot = p_hotspot.y;
+ iconinfo.hbmMask = hAndMask;
+ iconinfo.hbmColor = hXorMask;
+
+ if (cursors[p_shape])
+ DestroyIcon(cursors[p_shape]);
+
+ cursors[p_shape] = CreateIconIndirect(&iconinfo);
+
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
+ if (p_shape == cursor_shape) {
+ if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
+ SetCursor(cursors[p_shape]);
+ }
+ }
+
+ if (hAndMask != NULL) {
+ DeleteObject(hAndMask);
+ }
+
+ if (hXorMask != NULL) {
+ DeleteObject(hXorMask);
+ }
+
+ memfree(buffer);
+ DeleteObject(bitmap);
+ } else {
+ // Reset to default system cursor
+ if (cursors[p_shape]) {
+ DestroyIcon(cursors[p_shape]);
+ cursors[p_shape] = NULL;
+ }
+
+ CursorShape c = cursor_shape;
+ cursor_shape = CURSOR_MAX;
+ cursor_set_shape(c);
+
+ cursors_cache.erase(p_shape);
+ }
+}
+
+bool DisplayServerWindows::get_swap_ok_cancel() {
+ return true;
+}
+
+void DisplayServerWindows::enable_for_stealing_focus(OS::ProcessID pid) {
+ _THREAD_SAFE_METHOD_
+
+ AllowSetForegroundWindow(pid);
+}
+
+DisplayServer::LatinKeyboardVariant DisplayServerWindows::get_latin_keyboard_variant() const {
+
+ _THREAD_SAFE_METHOD_
+
+ unsigned long azerty[] = {
+ 0x00020401, // Arabic (102) AZERTY
+ 0x0001080c, // Belgian (Comma)
+ 0x0000080c, // Belgian French
+ 0x0000040c, // French
+ 0 // <--- STOP MARK
+ };
+ unsigned long qwertz[] = {
+ 0x0000041a, // Croation
+ 0x00000405, // Czech
+ 0x00000407, // German
+ 0x00010407, // German (IBM)
+ 0x0000040e, // Hungarian
+ 0x0000046e, // Luxembourgish
+ 0x00010415, // Polish (214)
+ 0x00000418, // Romanian (Legacy)
+ 0x0000081a, // Serbian (Latin)
+ 0x0000041b, // Slovak
+ 0x00000424, // Slovenian
+ 0x0001042e, // Sorbian Extended
+ 0x0002042e, // Sorbian Standard
+ 0x0000042e, // Sorbian Standard (Legacy)
+ 0x0000100c, // Swiss French
+ 0x00000807, // Swiss German
+ 0 // <--- STOP MARK
+ };
+ unsigned long dvorak[] = {
+ 0x00010409, // US-Dvorak
+ 0x00030409, // US-Dvorak for left hand
+ 0x00040409, // US-Dvorak for right hand
+ 0 // <--- STOP MARK
+ };
+
+ char name[KL_NAMELENGTH + 1];
+ name[0] = 0;
+ GetKeyboardLayoutNameA(name);
+
+ unsigned long hex = strtoul(name, NULL, 16);
+
+ int i = 0;
+ while (azerty[i] != 0) {
+ if (azerty[i] == hex) return LATIN_KEYBOARD_AZERTY;
+ i++;
+ }
+
+ i = 0;
+ while (qwertz[i] != 0) {
+ if (qwertz[i] == hex) return LATIN_KEYBOARD_QWERTZ;
+ i++;
+ }
+
+ i = 0;
+ while (dvorak[i] != 0) {
+ if (dvorak[i] == hex) return LATIN_KEYBOARD_DVORAK;
+ i++;
+ }
+
+ return LATIN_KEYBOARD_QWERTY;
+}
+
+void DisplayServerWindows::process_events() {
+
+ _THREAD_SAFE_METHOD_
+
+ MSG msg;
+
+ if (!drop_events) {
+ joypad->process_joypads();
+ }
+
+ while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
+
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+
+ if (!drop_events) {
+ _process_key_events();
+ InputFilter::get_singleton()->flush_accumulated_events();
+ }
+}
+
+void DisplayServerWindows::force_process_and_drop_events() {
+
+ _THREAD_SAFE_METHOD_
+
+ drop_events = true;
+ process_events();
+ drop_events = false;
+}
+
+void DisplayServerWindows::release_rendering_thread() {
+}
+void DisplayServerWindows::make_rendering_thread() {
+}
+void DisplayServerWindows::swap_buffers() {
+}
+
+void DisplayServerWindows::set_native_icon(const String &p_filename) {
+
+ _THREAD_SAFE_METHOD_
+
+ FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
+ ERR_FAIL_COND_MSG(!f, "Cannot open file with icon '" + p_filename + "'.");
+
+ ICONDIR *icon_dir = (ICONDIR *)memalloc(sizeof(ICONDIR));
+ int pos = 0;
+
+ icon_dir->idReserved = f->get_32();
+ pos += sizeof(WORD);
+ f->seek(pos);
+
+ icon_dir->idType = f->get_32();
+ pos += sizeof(WORD);
+ f->seek(pos);
+
+ ERR_FAIL_COND_MSG(icon_dir->idType != 1, "Invalid icon file format!");
+
+ icon_dir->idCount = f->get_32();
+ pos += sizeof(WORD);
+ f->seek(pos);
+
+ icon_dir = (ICONDIR *)memrealloc(icon_dir, 3 * sizeof(WORD) + icon_dir->idCount * sizeof(ICONDIRENTRY));
+ f->get_buffer((uint8_t *)&icon_dir->idEntries[0], icon_dir->idCount * sizeof(ICONDIRENTRY));
+
+ int small_icon_index = -1; // Select 16x16 with largest color count
+ int small_icon_cc = 0;
+ int big_icon_index = -1; // Select largest
+ int big_icon_width = 16;
+ int big_icon_cc = 0;
+
+ for (int i = 0; i < icon_dir->idCount; i++) {
+ int colors = (icon_dir->idEntries[i].bColorCount == 0) ? 32768 : icon_dir->idEntries[i].bColorCount;
+ int width = (icon_dir->idEntries[i].bWidth == 0) ? 256 : icon_dir->idEntries[i].bWidth;
+ if (width == 16) {
+ if (colors >= small_icon_cc) {
+ small_icon_index = i;
+ small_icon_cc = colors;
+ }
+ }
+ if (width >= big_icon_width) {
+ if (colors >= big_icon_cc) {
+ big_icon_index = i;
+ big_icon_width = width;
+ big_icon_cc = colors;
+ }
+ }
+ }
+
+ ERR_FAIL_COND_MSG(big_icon_index == -1, "No valid icons found!");
+
+ if (small_icon_index == -1) {
+ WARN_PRINT("No small icon found, reusing " + itos(big_icon_width) + "x" + itos(big_icon_width) + " @" + itos(big_icon_cc) + " icon!");
+ small_icon_index = big_icon_index;
+ small_icon_cc = big_icon_cc;
+ }
+
+ // Read the big icon
+ DWORD bytecount_big = icon_dir->idEntries[big_icon_index].dwBytesInRes;
+ Vector<uint8_t> data_big;
+ data_big.resize(bytecount_big);
+ pos = icon_dir->idEntries[big_icon_index].dwImageOffset;
+ f->seek(pos);
+ f->get_buffer((uint8_t *)&data_big.write[0], bytecount_big);
+ HICON icon_big = CreateIconFromResource((PBYTE)&data_big.write[0], bytecount_big, TRUE, 0x00030000);
+ ERR_FAIL_COND_MSG(!icon_big, "Could not create " + itos(big_icon_width) + "x" + itos(big_icon_width) + " @" + itos(big_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
+
+ // Read the small icon
+ DWORD bytecount_small = icon_dir->idEntries[small_icon_index].dwBytesInRes;
+ Vector<uint8_t> data_small;
+ data_small.resize(bytecount_small);
+ pos = icon_dir->idEntries[small_icon_index].dwImageOffset;
+ f->seek(pos);
+ f->get_buffer((uint8_t *)&data_small.write[0], bytecount_small);
+ HICON icon_small = CreateIconFromResource((PBYTE)&data_small.write[0], bytecount_small, TRUE, 0x00030000);
+ ERR_FAIL_COND_MSG(!icon_small, "Could not create 16x16 @" + itos(small_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
+
+ // Online tradition says to be sure last error is cleared and set the small icon first
+ int err = 0;
+ SetLastError(err);
+
+ SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon_small);
+ err = GetLastError();
+ ERR_FAIL_COND_MSG(err, "Error setting ICON_SMALL: " + format_error_message(err) + ".");
+
+ SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon_big);
+ err = GetLastError();
+ ERR_FAIL_COND_MSG(err, "Error setting ICON_BIG: " + format_error_message(err) + ".");
+
+ memdelete(f);
+ memdelete(icon_dir);
+}
+void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
+
+ _THREAD_SAFE_METHOD_
+
+ ERR_FAIL_COND(!p_icon.is_valid());
+ Ref<Image> icon = p_icon->duplicate();
+ if (icon->get_format() != Image::FORMAT_RGBA8)
+ icon->convert(Image::FORMAT_RGBA8);
+ int w = icon->get_width();
+ int h = icon->get_height();
+
+ /* Create temporary bitmap buffer */
+ int icon_len = 40 + h * w * 4;
+ Vector<BYTE> v;
+ v.resize(icon_len);
+ BYTE *icon_bmp = v.ptrw();
+
+ encode_uint32(40, &icon_bmp[0]);
+ encode_uint32(w, &icon_bmp[4]);
+ encode_uint32(h * 2, &icon_bmp[8]);
+ encode_uint16(1, &icon_bmp[12]);
+ encode_uint16(32, &icon_bmp[14]);
+ encode_uint32(BI_RGB, &icon_bmp[16]);
+ encode_uint32(w * h * 4, &icon_bmp[20]);
+ encode_uint32(0, &icon_bmp[24]);
+ encode_uint32(0, &icon_bmp[28]);
+ encode_uint32(0, &icon_bmp[32]);
+ encode_uint32(0, &icon_bmp[36]);
+
+ uint8_t *wr = &icon_bmp[40];
+ const uint8_t *r = icon->get_data().ptr();
+
+ for (int i = 0; i < h; i++) {
+
+ for (int j = 0; j < w; j++) {
+
+ const uint8_t *rpx = &r[((h - i - 1) * w + j) * 4];
+ uint8_t *wpx = &wr[(i * w + j) * 4];
+ wpx[0] = rpx[2];
+ wpx[1] = rpx[1];
+ wpx[2] = rpx[0];
+ wpx[3] = rpx[3];
+ }
+ }
+
+ HICON hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
+
+ /* Set the icon for the window */
+ SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon);
+
+ /* Set the icon in the task manager (should we do this?) */
+ SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_SETICON, ICON_BIG, (LPARAM)hicon);
+}
+
+void DisplayServerWindows::vsync_set_use_via_compositor(bool p_enable) {
+}
+bool DisplayServerWindows::vsync_is_using_via_compositor() const {
+ return false;
+}
+
+void DisplayServerWindows::set_context(Context p_context) {
+}
+
+#define MI_WP_SIGNATURE 0xFF515700
+#define SIGNATURE_MASK 0xFFFFFF00
+// Keeping the name suggested by Microsoft, but this macro really answers:
+// Is this mouse event emulated from touch or pen input?
+#define IsPenEvent(dw) (((dw)&SIGNATURE_MASK) == MI_WP_SIGNATURE)
+// This one tells whether the event comes from touchscreen (and not from pen)
+#define IsTouchEvent(dw) (IsPenEvent(dw) && ((dw)&0x80))
+
+void DisplayServerWindows::_touch_event(WindowID p_window, bool p_pressed, float p_x, float p_y, int idx) {
+
+ // Defensive
+ if (touch_state.has(idx) == p_pressed)
+ return;
+
+ if (p_pressed) {
+ touch_state.insert(idx, Vector2(p_x, p_y));
+ } else {
+ touch_state.erase(idx);
+ }
+
+ Ref<InputEventScreenTouch> event;
+ event.instance();
+ event->set_index(idx);
+ event->set_window_id(p_window);
+ event->set_pressed(p_pressed);
+ event->set_position(Vector2(p_x, p_y));
+
+ InputFilter::get_singleton()->accumulate_input_event(event);
+}
+
+void DisplayServerWindows::_drag_event(WindowID p_window, float p_x, float p_y, int idx) {
+
+ Map<int, Vector2>::Element *curr = touch_state.find(idx);
+ // Defensive
+ if (!curr)
+ return;
+
+ if (curr->get() == Vector2(p_x, p_y))
+ return;
+
+ Ref<InputEventScreenDrag> event;
+ event.instance();
+ event->set_window_id(p_window);
+ event->set_index(idx);
+ event->set_position(Vector2(p_x, p_y));
+ event->set_relative(Vector2(p_x, p_y) - curr->get());
+
+ InputFilter::get_singleton()->accumulate_input_event(event);
+
+ curr->get() = Vector2(p_x, p_y);
+}
+
+void DisplayServerWindows::_send_window_event(const WindowData &wd, WindowEvent p_event) {
+
+ if (!wd.event_callback.is_null()) {
+ Variant event = int(p_event);
+ Variant *eventp = &event;
+ Variant ret;
+ Callable::CallError ce;
+ wd.event_callback.call((const Variant **)&eventp, 1, ret, ce);
+ }
+}
+
+void DisplayServerWindows::_dispatch_input_events(const Ref<InputEvent> &p_event) {
+ ((DisplayServerWindows *)(get_singleton()))->_dispatch_input_event(p_event);
+}
+
+void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event) {
+
+ Variant ev = p_event;
+ Variant *evp = &ev;
+ Variant ret;
+ Callable::CallError ce;
+
+ Ref<InputEventFromWindow> event_from_window = p_event;
+ if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
+ //send to a window
+ ERR_FAIL_COND(!windows.has(event_from_window->get_window_id()));
+ Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
+ if (callable.is_null()) {
+ return;
+ }
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ } else {
+ //send to all windows
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ Callable callable = E->get().input_event_callback;
+ if (callable.is_null()) {
+ continue;
+ }
+ callable.call((const Variant **)&evp, 1, ret, ce);
+ }
+ }
+}
+
+LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+
+ if (drop_events) {
+
+ if (user_proc) {
+
+ return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
+ } else {
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+ }
+ };
+
+ WindowID window_id = INVALID_WINDOW_ID;
+
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ if (E->get().hWnd == hWnd) {
+ window_id = E->key();
+ break;
+ }
+ }
+
+ switch (uMsg) // Check For Windows Messages
+ {
+ case WM_SETFOCUS: {
+
+ windows[window_id].window_has_focus = true;
+ last_focused_window = window_id;
+
+ // Restore mouse mode
+ _set_mouse_mode_impl(mouse_mode);
+
+ break;
+ }
+ case WM_KILLFOCUS: {
+ windows[window_id].window_has_focus = false;
+ last_focused_window = window_id;
+
+ // Release capture unconditionally because it can be set due to dragging, in addition to captured mode
+ ReleaseCapture();
+
+ // Release every touch to avoid sticky points
+ for (Map<int, Vector2>::Element *E = touch_state.front(); E; E = E->next()) {
+ _touch_event(window_id, false, E->get().x, E->get().y, E->key());
+ }
+ touch_state.clear();
+
+ break;
+ }
+ case WM_ACTIVATE: // Watch For Window Activate Message
+ {
+ windows[window_id].minimized = HIWORD(wParam) != 0;
+
+ if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) {
+
+ _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN);
+ windows[window_id].window_focused = true;
+ alt_mem = false;
+ control_mem = false;
+ shift_mem = false;
+ } else { // WM_INACTIVE
+ InputFilter::get_singleton()->release_pressed_events();
+ _send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_OUT);
+ windows[window_id].window_focused = false;
+ alt_mem = false;
+ };
+
+ return 0; // Return To The Message Loop
+ }
+ case WM_GETMINMAXINFO: {
+ if (windows[window_id].resizable && !windows[window_id].fullscreen) {
+ Size2 decor = window_get_size(window_id) - window_get_real_size(window_id); // Size of window decorations
+ MINMAXINFO *min_max_info = (MINMAXINFO *)lParam;
+ if (windows[window_id].min_size != Size2()) {
+ min_max_info->ptMinTrackSize.x = windows[window_id].min_size.x + decor.x;
+ min_max_info->ptMinTrackSize.y = windows[window_id].min_size.y + decor.y;
+ }
+ if (windows[window_id].max_size != Size2()) {
+ min_max_info->ptMaxTrackSize.x = windows[window_id].max_size.x + decor.x;
+ min_max_info->ptMaxTrackSize.y = windows[window_id].max_size.y + decor.y;
+ }
+ return 0;
+ } else {
+ break;
+ }
+ }
+ case WM_PAINT:
+
+ Main::force_redraw();
+ break;
+
+ case WM_SYSCOMMAND: // Intercept System Commands
+ {
+ switch (wParam) // Check System Calls
+ {
+ case SC_SCREENSAVE: // Screensaver Trying To Start?
+ case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
+ return 0; // Prevent From Happening
+ case SC_KEYMENU:
+ if ((lParam >> 16) <= 0)
+ return 0;
+ }
+ break; // Exit
+ }
+
+ case WM_CLOSE: // Did We Receive A Close Message?
+ {
+
+ _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST);
+
+ //force_quit=true;
+ return 0; // Jump Back
+ }
+ case WM_MOUSELEAVE: {
+
+ old_invalid = true;
+ outside = true;
+
+ _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT);
+
+ } break;
+ case WM_INPUT: {
+ if (mouse_mode != MOUSE_MODE_CAPTURED || !use_raw_input) {
+ break;
+ }
+
+ UINT dwSize;
+
+ GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
+ LPBYTE lpb = new BYTE[dwSize];
+ if (lpb == NULL) {
+ return 0;
+ }
+
+ if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
+ OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
+
+ RAWINPUT *raw = (RAWINPUT *)lpb;
+
+ if (raw->header.dwType == RIM_TYPEMOUSE) {
+ Ref<InputEventMouseMotion> mm;
+ mm.instance();
+
+ mm->set_window_id(window_id);
+ mm->set_control(control_mem);
+ mm->set_shift(shift_mem);
+ mm->set_alt(alt_mem);
+
+ mm->set_button_mask(last_button_state);
+
+ Point2i c(windows[window_id].width / 2, windows[window_id].height / 2);
+
+ // centering just so it works as before
+ POINT pos = { (int)c.x, (int)c.y };
+ ClientToScreen(windows[window_id].hWnd, &pos);
+ SetCursorPos(pos.x, pos.y);
+
+ mm->set_position(c);
+ mm->set_global_position(c);
+ InputFilter::get_singleton()->set_mouse_position(c);
+ mm->set_speed(Vector2(0, 0));
+
+ if (raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE) {
+ mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY));
+
+ } else if (raw->data.mouse.usFlags == MOUSE_MOVE_ABSOLUTE) {
+
+ int nScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ int nScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ int nScreenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
+ int nScreenTop = GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ Vector2 abs_pos(
+ (double(raw->data.mouse.lLastX) - 65536.0 / (nScreenWidth)) * nScreenWidth / 65536.0 + nScreenLeft,
+ (double(raw->data.mouse.lLastY) - 65536.0 / (nScreenHeight)) * nScreenHeight / 65536.0 + nScreenTop);
+
+ POINT coords; //client coords
+ coords.x = abs_pos.x;
+ coords.y = abs_pos.y;
+
+ ScreenToClient(hWnd, &coords);
+
+ mm->set_relative(Vector2(coords.x - old_x, coords.y - old_y));
+ old_x = coords.x;
+ old_y = coords.y;
+
+ /*Input.mi.dx = (int)((((double)(pos.x)-nScreenLeft) * 65536) / nScreenWidth + 65536 / (nScreenWidth));
+ Input.mi.dy = (int)((((double)(pos.y)-nScreenTop) * 65536) / nScreenHeight + 65536 / (nScreenHeight));
+ */
+ }
+
+ if (windows[window_id].window_has_focus && mm->get_relative() != Vector2())
+ InputFilter::get_singleton()->accumulate_input_event(mm);
+ }
+ delete[] lpb;
+ } break;
+ case WM_POINTERUPDATE: {
+ if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
+ break;
+ }
+
+ if (!win8p_GetPointerType || !win8p_GetPointerPenInfo) {
+ break;
+ }
+
+ uint32_t pointer_id = LOWORD(wParam);
+ POINTER_INPUT_TYPE pointer_type = PT_POINTER;
+ if (!win8p_GetPointerType(pointer_id, &pointer_type)) {
+ break;
+ }
+
+ if (pointer_type != PT_PEN) {
+ break;
+ }
+
+ POINTER_PEN_INFO pen_info;
+ if (!win8p_GetPointerPenInfo(pointer_id, &pen_info)) {
+ break;
+ }
+
+ if (InputFilter::get_singleton()->is_emulating_mouse_from_touch()) {
+ // Universal translation enabled; ignore OS translation
+ LPARAM extra = GetMessageExtraInfo();
+ if (IsTouchEvent(extra)) {
+ break;
+ }
+ }
+
+ if (outside) {
+ //mouse enter
+
+ if (mouse_mode != MOUSE_MODE_CAPTURED) {
+ _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
+ }
+
+ CursorShape c = cursor_shape;
+ cursor_shape = CURSOR_MAX;
+ cursor_set_shape(c);
+ outside = false;
+
+ //Once-Off notification, must call again....
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hWnd;
+ tme.dwHoverTime = HOVER_DEFAULT;
+ TrackMouseEvent(&tme);
+ }
+
+ // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
+ if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED)
+ break;
+
+ Ref<InputEventMouseMotion> mm;
+ mm.instance();
+
+ mm->set_window_id(window_id);
+ mm->set_pressure(pen_info.pressure ? (float)pen_info.pressure / 1024 : 0);
+ mm->set_tilt(Vector2(pen_info.tiltX ? (float)pen_info.tiltX / 90 : 0, pen_info.tiltY ? (float)pen_info.tiltY / 90 : 0));
+
+ mm->set_control((wParam & MK_CONTROL) != 0);
+ mm->set_shift((wParam & MK_SHIFT) != 0);
+ mm->set_alt(alt_mem);
+
+ mm->set_button_mask(last_button_state);
+
+ POINT coords; //client coords
+ coords.x = GET_X_LPARAM(lParam);
+ coords.y = GET_Y_LPARAM(lParam);
+
+ ScreenToClient(windows[window_id].hWnd, &coords);
+
+ mm->set_position(Vector2(coords.x, coords.y));
+ mm->set_global_position(Vector2(coords.x, coords.y));
+
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+
+ Point2i c(windows[window_id].width / 2, windows[window_id].height / 2);
+ old_x = c.x;
+ old_y = c.y;
+
+ if (mm->get_position() == c) {
+ center = c;
+ return 0;
+ }
+
+ Point2i ncenter = mm->get_position();
+ center = ncenter;
+ POINT pos = { (int)c.x, (int)c.y };
+ ClientToScreen(hWnd, &pos);
+ SetCursorPos(pos.x, pos.y);
+ }
+
+ InputFilter::get_singleton()->set_mouse_position(mm->get_position());
+ mm->set_speed(InputFilter::get_singleton()->get_last_mouse_speed());
+
+ if (old_invalid) {
+
+ old_x = mm->get_position().x;
+ old_y = mm->get_position().y;
+ old_invalid = false;
+ }
+
+ mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
+ old_x = mm->get_position().x;
+ old_y = mm->get_position().y;
+ if (windows[window_id].window_has_focus) {
+ InputFilter::get_singleton()->parse_input_event(mm);
+ }
+
+ return 0; //Pointer event handled return 0 to avoid duplicate WM_MOUSEMOVE event
+ } break;
+ case WM_MOUSEMOVE: {
+ if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
+ break;
+ }
+
+ if (InputFilter::get_singleton()->is_emulating_mouse_from_touch()) {
+ // Universal translation enabled; ignore OS translation
+ LPARAM extra = GetMessageExtraInfo();
+ if (IsTouchEvent(extra)) {
+ break;
+ }
+ }
+
+ if (outside) {
+ //mouse enter
+
+ if (mouse_mode != MOUSE_MODE_CAPTURED) {
+ _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER);
+ }
+
+ CursorShape c = cursor_shape;
+ cursor_shape = CURSOR_MAX;
+ cursor_set_shape(c);
+ outside = false;
+
+ //Once-Off notification, must call again....
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hWnd;
+ tme.dwHoverTime = HOVER_DEFAULT;
+ TrackMouseEvent(&tme);
+ }
+
+ // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
+ if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED)
+ break;
+
+ Ref<InputEventMouseMotion> mm;
+ mm.instance();
+ mm->set_window_id(window_id);
+ mm->set_control((wParam & MK_CONTROL) != 0);
+ mm->set_shift((wParam & MK_SHIFT) != 0);
+ mm->set_alt(alt_mem);
+
+ mm->set_button_mask(last_button_state);
+
+ mm->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
+ mm->set_global_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
+
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+
+ Point2i c(windows[window_id].width / 2, windows[window_id].height / 2);
+ old_x = c.x;
+ old_y = c.y;
+
+ if (mm->get_position() == c) {
+ center = c;
+ return 0;
+ }
+
+ Point2i ncenter = mm->get_position();
+ center = ncenter;
+ POINT pos = { (int)c.x, (int)c.y };
+ ClientToScreen(windows[window_id].hWnd, &pos);
+ SetCursorPos(pos.x, pos.y);
+ }
+
+ InputFilter::get_singleton()->set_mouse_position(mm->get_position());
+ mm->set_speed(InputFilter::get_singleton()->get_last_mouse_speed());
+
+ if (old_invalid) {
+
+ old_x = mm->get_position().x;
+ old_y = mm->get_position().y;
+ old_invalid = false;
+ }
+
+ mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
+ old_x = mm->get_position().x;
+ old_y = mm->get_position().y;
+ if (windows[window_id].window_has_focus)
+ InputFilter::get_singleton()->accumulate_input_event(mm);
+
+ } break;
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONUP:
+ if (InputFilter::get_singleton()->is_emulating_mouse_from_touch()) {
+ // Universal translation enabled; ignore OS translations for left button
+ LPARAM extra = GetMessageExtraInfo();
+ if (IsTouchEvent(extra)) {
+ break;
+ }
+ }
+ [[fallthrough]];
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
+ case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
+ case WM_RBUTTONDBLCLK:
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ case WM_XBUTTONUP: {
+
+ Ref<InputEventMouseButton> mb;
+ mb.instance();
+ mb->set_window_id(window_id);
+
+ switch (uMsg) {
+ case WM_LBUTTONDOWN: {
+ mb->set_pressed(true);
+ mb->set_button_index(1);
+ } break;
+ case WM_LBUTTONUP: {
+ mb->set_pressed(false);
+ mb->set_button_index(1);
+ } break;
+ case WM_MBUTTONDOWN: {
+ mb->set_pressed(true);
+ mb->set_button_index(3);
+ } break;
+ case WM_MBUTTONUP: {
+ mb->set_pressed(false);
+ mb->set_button_index(3);
+ } break;
+ case WM_RBUTTONDOWN: {
+ mb->set_pressed(true);
+ mb->set_button_index(2);
+ } break;
+ case WM_RBUTTONUP: {
+ mb->set_pressed(false);
+ mb->set_button_index(2);
+ } break;
+ case WM_LBUTTONDBLCLK: {
+ mb->set_pressed(true);
+ mb->set_button_index(1);
+ mb->set_doubleclick(true);
+ } break;
+ case WM_RBUTTONDBLCLK: {
+ mb->set_pressed(true);
+ mb->set_button_index(2);
+ mb->set_doubleclick(true);
+ } break;
+ case WM_MBUTTONDBLCLK: {
+ mb->set_pressed(true);
+ mb->set_button_index(3);
+ mb->set_doubleclick(true);
+ } break;
+ case WM_MOUSEWHEEL: {
+
+ mb->set_pressed(true);
+ int motion = (short)HIWORD(wParam);
+ if (!motion)
+ return 0;
+
+ if (motion > 0)
+ mb->set_button_index(BUTTON_WHEEL_UP);
+ else
+ mb->set_button_index(BUTTON_WHEEL_DOWN);
+
+ } break;
+ case WM_MOUSEHWHEEL: {
+
+ mb->set_pressed(true);
+ int motion = (short)HIWORD(wParam);
+ if (!motion)
+ return 0;
+
+ if (motion < 0) {
+ mb->set_button_index(BUTTON_WHEEL_LEFT);
+ mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
+ } else {
+ mb->set_button_index(BUTTON_WHEEL_RIGHT);
+ mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
+ }
+ } break;
+ case WM_XBUTTONDOWN: {
+
+ mb->set_pressed(true);
+ if (HIWORD(wParam) == XBUTTON1)
+ mb->set_button_index(BUTTON_XBUTTON1);
+ else
+ mb->set_button_index(BUTTON_XBUTTON2);
+ } break;
+ case WM_XBUTTONUP: {
+
+ mb->set_pressed(false);
+ if (HIWORD(wParam) == XBUTTON1)
+ mb->set_button_index(BUTTON_XBUTTON1);
+ else
+ mb->set_button_index(BUTTON_XBUTTON2);
+ } break;
+ case WM_XBUTTONDBLCLK: {
+
+ mb->set_pressed(true);
+ if (HIWORD(wParam) == XBUTTON1)
+ mb->set_button_index(BUTTON_XBUTTON1);
+ else
+ mb->set_button_index(BUTTON_XBUTTON2);
+ mb->set_doubleclick(true);
+ } break;
+ default: {
+ return 0;
+ }
+ }
+
+ mb->set_control((wParam & MK_CONTROL) != 0);
+ mb->set_shift((wParam & MK_SHIFT) != 0);
+ mb->set_alt(alt_mem);
+ //mb->get_alt()=(wParam&MK_MENU)!=0;
+ if (mb->is_pressed())
+ last_button_state |= (1 << (mb->get_button_index() - 1));
+ else
+ last_button_state &= ~(1 << (mb->get_button_index() - 1));
+ mb->set_button_mask(last_button_state);
+
+ mb->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
+
+ if (mouse_mode == MOUSE_MODE_CAPTURED && !use_raw_input) {
+
+ mb->set_position(Vector2(old_x, old_y));
+ }
+
+ if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) {
+ if (mb->is_pressed()) {
+
+ if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED)
+ SetCapture(hWnd);
+ } else {
+
+ if (--pressrc <= 0) {
+ if (mouse_mode != MOUSE_MODE_CAPTURED) {
+ ReleaseCapture();
+ }
+ pressrc = 0;
+ }
+ }
+ } else {
+ // for reasons unknown to mankind, wheel comes in screen coordinates
+ POINT coords;
+ coords.x = mb->get_position().x;
+ coords.y = mb->get_position().y;
+
+ ScreenToClient(hWnd, &coords);
+
+ mb->set_position(Vector2(coords.x, coords.y));
+ }
+
+ mb->set_global_position(mb->get_position());
+
+ InputFilter::get_singleton()->accumulate_input_event(mb);
+ if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) {
+ //send release for mouse wheel
+ Ref<InputEventMouseButton> mbd = mb->duplicate();
+ mbd->set_window_id(window_id);
+ last_button_state &= ~(1 << (mbd->get_button_index() - 1));
+ mbd->set_button_mask(last_button_state);
+ mbd->set_pressed(false);
+ InputFilter::get_singleton()->accumulate_input_event(mbd);
+ }
+
+ } break;
+
+ case WM_MOVE: {
+ if (!IsIconic(windows[window_id].hWnd)) {
+ int x = int16_t(LOWORD(lParam));
+ int y = int16_t(HIWORD(lParam));
+ windows[window_id].last_pos = Point2(x, y);
+
+ if (!windows[window_id].rect_changed_callback.is_null()) {
+
+ Variant size = Rect2i(windows[window_id].last_pos.x, windows[window_id].last_pos.y, windows[window_id].width, windows[window_id].height);
+ Variant *sizep = &size;
+ Variant ret;
+ Callable::CallError ce;
+ windows[window_id].rect_changed_callback.call((const Variant **)&sizep, 1, ret, ce);
+ }
+ }
+ } break;
+
+ case WM_SIZE: {
+ // Ignore size when a SIZE_MINIMIZED event is triggered
+ if (wParam != SIZE_MINIMIZED) {
+ int window_w = LOWORD(lParam);
+ int window_h = HIWORD(lParam);
+ if (window_w > 0 && window_h > 0 && !windows[window_id].preserve_window_size) {
+ windows[window_id].width = window_w;
+ windows[window_id].height = window_h;
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_resize(window_id, windows[window_id].width, windows[window_id].height);
+ }
+#endif
+
+ } else {
+ windows[window_id].preserve_window_size = false;
+ window_set_size(Size2(windows[window_id].width, windows[window_id].height), window_id);
+ }
+ }
+
+ if (!windows[window_id].rect_changed_callback.is_null()) {
+
+ Variant size = Rect2i(windows[window_id].last_pos.x, windows[window_id].last_pos.y, windows[window_id].width, windows[window_id].height);
+ Variant *sizep = &size;
+ Variant ret;
+ Callable::CallError ce;
+ windows[window_id].rect_changed_callback.call((const Variant **)&sizep, 1, ret, ce);
+ }
+
+ if (wParam == SIZE_MAXIMIZED) {
+ windows[window_id].maximized = true;
+ windows[window_id].minimized = false;
+ } else if (wParam == SIZE_MINIMIZED) {
+ windows[window_id].maximized = false;
+ windows[window_id].minimized = true;
+ } else if (wParam == SIZE_RESTORED) {
+ windows[window_id].maximized = false;
+ windows[window_id].minimized = false;
+ }
+#if 0
+ if (is_layered_allowed() && layered_window) {
+ DeleteObject(hBitmap);
+
+ RECT r;
+ GetWindowRect(hWnd, &r);
+ dib_size = Size2i(r.right - r.left, r.bottom - r.top);
+
+ BITMAPINFO bmi;
+ ZeroMemory(&bmi, sizeof(BITMAPINFO));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = dib_size.x;
+ bmi.bmiHeader.biHeight = dib_size.y;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biSizeImage = dib_size.x * dib_size.y * 4;
+ hBitmap = CreateDIBSection(hDC_dib, &bmi, DIB_RGB_COLORS, (void **)&dib_data, NULL, 0x0);
+ SelectObject(hDC_dib, hBitmap);
+
+ ZeroMemory(dib_data, dib_size.x * dib_size.y * 4);
+ }
+#endif
+ //return 0; // Jump Back
+ } break;
+
+ case WM_ENTERSIZEMOVE: {
+ InputFilter::get_singleton()->release_pressed_events();
+ move_timer_id = SetTimer(windows[window_id].hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC)NULL);
+ } break;
+ case WM_EXITSIZEMOVE: {
+ KillTimer(windows[window_id].hWnd, move_timer_id);
+ } break;
+ case WM_TIMER: {
+ if (wParam == move_timer_id) {
+ _process_key_events();
+ if (!Main::is_iterating()) {
+ Main::iteration();
+ }
+ }
+ } break;
+
+ case WM_SYSKEYDOWN:
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ case WM_KEYDOWN: {
+
+ if (wParam == VK_SHIFT)
+ shift_mem = uMsg == WM_KEYDOWN;
+ if (wParam == VK_CONTROL)
+ control_mem = uMsg == WM_KEYDOWN;
+ if (wParam == VK_MENU) {
+ alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
+ if (lParam & (1 << 24))
+ gr_mem = alt_mem;
+ }
+
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ // When SetCapture is used, ALT+F4 hotkey is ignored by Windows, so handle it ourselves
+ if (wParam == VK_F4 && alt_mem && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)) {
+ _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST);
+ }
+ }
+ /*
+ if (wParam==VK_WIN) TODO wtf is this?
+ meta_mem=uMsg==WM_KEYDOWN;
+ */
+ [[fallthrough]];
+ }
+ case WM_CHAR: {
+
+ ERR_BREAK(key_event_pos >= KEY_EVENT_BUFFER_SIZE);
+
+ // Make sure we don't include modifiers for the modifier key itself.
+ KeyEvent ke;
+ ke.shift = (wParam != VK_SHIFT) ? shift_mem : false;
+ ke.alt = (!(wParam == VK_MENU && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN))) ? alt_mem : false;
+ ke.control = (wParam != VK_CONTROL) ? control_mem : false;
+ ke.meta = meta_mem;
+ ke.uMsg = uMsg;
+ ke.window_id = window_id;
+
+ if (ke.uMsg == WM_SYSKEYDOWN)
+ ke.uMsg = WM_KEYDOWN;
+ if (ke.uMsg == WM_SYSKEYUP)
+ ke.uMsg = WM_KEYUP;
+
+ ke.wParam = wParam;
+ ke.lParam = lParam;
+ key_event_buffer[key_event_pos++] = ke;
+
+ } break;
+ case WM_INPUTLANGCHANGEREQUEST: {
+
+ // FIXME: Do something?
+ } break;
+
+ case WM_TOUCH: {
+
+ BOOL bHandled = FALSE;
+ UINT cInputs = LOWORD(wParam);
+ PTOUCHINPUT pInputs = memnew_arr(TOUCHINPUT, cInputs);
+ if (pInputs) {
+ if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) {
+ for (UINT i = 0; i < cInputs; i++) {
+ TOUCHINPUT ti = pInputs[i];
+ POINT touch_pos = {
+ TOUCH_COORD_TO_PIXEL(ti.x),
+ TOUCH_COORD_TO_PIXEL(ti.y),
+ };
+ ScreenToClient(hWnd, &touch_pos);
+ //do something with each touch input entry
+ if (ti.dwFlags & TOUCHEVENTF_MOVE) {
+
+ _drag_event(window_id, touch_pos.x, touch_pos.y, ti.dwID);
+ } else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) {
+
+ _touch_event(window_id, ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID);
+ };
+ }
+ bHandled = TRUE;
+ } else {
+ /* handle the error here */
+ }
+ memdelete_arr(pInputs);
+ } else {
+ /* handle the error here, probably out of memory */
+ }
+ if (bHandled) {
+ CloseTouchInputHandle((HTOUCHINPUT)lParam);
+ return 0;
+ };
+
+ } break;
+
+ case WM_DEVICECHANGE: {
+
+ joypad->probe_joypads();
+ } break;
+ case WM_SETCURSOR: {
+ if (LOWORD(lParam) == HTCLIENT) {
+ if (windows[window_id].window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) {
+ //Hide the cursor
+ if (hCursor == NULL)
+ hCursor = SetCursor(NULL);
+ else
+ SetCursor(NULL);
+ } else {
+ if (hCursor != NULL) {
+ CursorShape c = cursor_shape;
+ cursor_shape = CURSOR_MAX;
+ cursor_set_shape(c);
+ hCursor = NULL;
+ }
+ }
+ }
+
+ } break;
+ case WM_DROPFILES: {
+
+ HDROP hDropInfo = (HDROP)wParam;
+ const int buffsize = 4096;
+ wchar_t buf[buffsize];
+
+ int fcount = DragQueryFileW(hDropInfo, 0xFFFFFFFF, NULL, 0);
+
+ Vector<String> files;
+
+ for (int i = 0; i < fcount; i++) {
+
+ DragQueryFileW(hDropInfo, i, buf, buffsize);
+ String file = buf;
+ files.push_back(file);
+ }
+
+ if (files.size() && !windows[window_id].drop_files_callback.is_null()) {
+ Variant v = files;
+ Variant *vp = &v;
+ Variant ret;
+ Callable::CallError ce;
+ windows[window_id].drop_files_callback.call((const Variant **)&vp, 1, ret, ce);
+ }
+
+ } break;
+
+ default: {
+
+ if (user_proc) {
+
+ return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
+ };
+ };
+ }
+
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+}
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+
+ DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton());
+ if (ds_win)
+ return ds_win->WndProc(hWnd, uMsg, wParam, lParam);
+ else
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+}
+
+void DisplayServerWindows::_process_key_events() {
+
+ for (int i = 0; i < key_event_pos; i++) {
+
+ KeyEvent &ke = key_event_buffer[i];
+ switch (ke.uMsg) {
+
+ case WM_CHAR: {
+ if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) {
+ Ref<InputEventKey> k;
+ k.instance();
+
+ k->set_window_id(ke.window_id);
+ k->set_shift(ke.shift);
+ k->set_alt(ke.alt);
+ k->set_control(ke.control);
+ k->set_metakey(ke.meta);
+ k->set_pressed(true);
+ k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam));
+ k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)));
+ k->set_unicode(ke.wParam);
+ if (k->get_unicode() && gr_mem) {
+ k->set_alt(false);
+ k->set_control(false);
+ }
+
+ if (k->get_unicode() < 32)
+ k->set_unicode(0);
+
+ InputFilter::get_singleton()->accumulate_input_event(k);
+ }
+
+ //do nothing
+ } break;
+ case WM_KEYUP:
+ case WM_KEYDOWN: {
+
+ Ref<InputEventKey> k;
+ k.instance();
+
+ k->set_window_id(ke.window_id);
+ k->set_shift(ke.shift);
+ k->set_alt(ke.alt);
+ k->set_control(ke.control);
+ k->set_metakey(ke.meta);
+
+ k->set_pressed(ke.uMsg == WM_KEYDOWN);
+
+ if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) {
+ // Special case for Numpad Enter key
+ k->set_keycode(KEY_KP_ENTER);
+ } else {
+ k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam));
+ }
+
+ k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)));
+
+ if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) {
+ k->set_unicode(key_event_buffer[i + 1].wParam);
+ }
+ if (k->get_unicode() && gr_mem) {
+ k->set_alt(false);
+ k->set_control(false);
+ }
+
+ if (k->get_unicode() < 32)
+ k->set_unicode(0);
+
+ k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30))));
+
+ InputFilter::get_singleton()->accumulate_input_event(k);
+
+ } break;
+ }
+ }
+
+ key_event_pos = 0;
+}
+
+DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
+
+ DWORD dwExStyle;
+ DWORD dwStyle;
+
+ _get_window_style(window_id_counter == MAIN_WINDOW_ID, p_mode == WINDOW_MODE_FULLSCREEN, p_flags & WINDOW_FLAG_BORDERLESS_BIT, !(p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT), p_mode == WINDOW_MODE_MAXIMIZED, (p_flags & WINDOW_FLAG_NO_FOCUS_BIT), dwStyle, dwExStyle);
+
+ RECT WindowRect;
+
+ WindowRect.left = p_rect.position.x;
+ WindowRect.right = p_rect.position.x + p_rect.size.x;
+ WindowRect.top = p_rect.position.y;
+ WindowRect.bottom = p_rect.position.y + p_rect.size.y;
+
+ AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
+
+ WindowID id = window_id_counter;
+ {
+ WindowData wd;
+
+ wd.hWnd = CreateWindowExW(
+ dwExStyle,
+ L"Engine", L"",
+ dwStyle,
+ // (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2,
+ // (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2,
+ WindowRect.left,
+ WindowRect.top,
+ WindowRect.right - WindowRect.left,
+ WindowRect.bottom - WindowRect.top,
+ NULL, NULL, hInstance, NULL);
+ if (!wd.hWnd) {
+ MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
+ return INVALID_WINDOW_ID;
+ }
+#ifdef VULKAN_ENABLED
+
+ if (rendering_driver == "vulkan") {
+ if (context_vulkan->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top) == -1) {
+ memdelete(context_vulkan);
+ context_vulkan = NULL;
+ ERR_FAIL_V(INVALID_WINDOW_ID);
+ }
+ }
+#endif
+
+ RegisterTouchWindow(wd.hWnd, 0);
+
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = wd.hWnd;
+ tme.dwHoverTime = HOVER_DEFAULT;
+ TrackMouseEvent(&tme);
+
+ DragAcceptFiles(wd.hWnd, true);
+
+ // IME
+ wd.im_himc = ImmGetContext(wd.hWnd);
+ ImmReleaseContext(wd.hWnd, wd.im_himc);
+
+ wd.im_position = Vector2();
+ wd.last_pos = p_rect.position;
+ wd.width = p_rect.size.width;
+ wd.height = p_rect.size.height;
+
+ windows[id] = wd;
+
+ window_id_counter++;
+ }
+
+ return id;
+}
+
+GetPointerTypePtr DisplayServerWindows::win8p_GetPointerType = nullptr;
+GetPointerPenInfoPtr DisplayServerWindows::win8p_GetPointerPenInfo = nullptr;
+
+typedef enum _SHC_PROCESS_DPI_AWARENESS {
+ SHC_PROCESS_DPI_UNAWARE = 0,
+ SHC_PROCESS_SYSTEM_DPI_AWARE = 1,
+ SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2
+} SHC_PROCESS_DPI_AWARENESS;
+
+DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
+
+ //Note: Functions for pen input, available on Windows 8+
+ HMODULE user32_lib = LoadLibraryW(L"user32.dll");
+ if (user32_lib) {
+ win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
+ win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
+ }
+
+ drop_events = false;
+ key_event_pos = 0;
+
+ alt_mem = false;
+ gr_mem = false;
+ shift_mem = false;
+ control_mem = false;
+ meta_mem = false;
+ console_visible = IsWindowVisible(GetConsoleWindow());
+ hInstance = ((OS_Windows *)OS::get_singleton())->get_hinstance();
+
+ pressrc = 0;
+ old_invalid = true;
+ mouse_mode = MOUSE_MODE_VISIBLE;
+
+ outside = true;
+
+ if (OS::get_singleton()->is_hidpi_allowed()) {
+ HMODULE Shcore = LoadLibraryW(L"Shcore.dll");
+
+ if (Shcore != NULL) {
+ typedef HRESULT(WINAPI * SetProcessDpiAwareness_t)(SHC_PROCESS_DPI_AWARENESS);
+
+ SetProcessDpiAwareness_t SetProcessDpiAwareness = (SetProcessDpiAwareness_t)GetProcAddress(Shcore, "SetProcessDpiAwareness");
+
+ if (SetProcessDpiAwareness) {
+ SetProcessDpiAwareness(SHC_PROCESS_SYSTEM_DPI_AWARE);
+ }
+ }
+ }
+
+ memset(&wc, 0, sizeof(WNDCLASSEXW));
+ wc.cbSize = sizeof(WNDCLASSEXW);
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
+ wc.lpfnWndProc = (WNDPROC)::WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ //wc.hInstance = hInstance;
+ wc.hInstance = hInstance ? hInstance : GetModuleHandle(NULL);
+ wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
+ wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = L"Engine";
+
+ if (!RegisterClassExW(&wc)) {
+ MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
+ r_error = ERR_UNAVAILABLE;
+ return;
+ }
+
+ use_raw_input = true;
+
+ RAWINPUTDEVICE Rid[1];
+
+ Rid[0].usUsagePage = 0x01;
+ Rid[0].usUsage = 0x02;
+ Rid[0].dwFlags = 0;
+ Rid[0].hwndTarget = 0;
+
+ if (RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])) == FALSE) {
+ //registration failed.
+ use_raw_input = false;
+ }
+
+ rendering_driver = "vulkan";
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+
+ context_vulkan = memnew(VulkanContextWindows);
+ if (context_vulkan->initialize() != OK) {
+ memdelete(context_vulkan);
+ context_vulkan = NULL;
+ r_error = ERR_UNAVAILABLE;
+ return;
+ }
+ }
+#endif
+#if defined(OPENGL_ENABLED)
+ if (rendering_driver_index == VIDEO_DRIVER_GLES2) {
+
+ context_gles2 = memnew(ContextGL_Windows(hWnd, false));
+
+ if (context_gles2->initialize() != OK) {
+ memdelete(context_gles2);
+ context_gles2 = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
+
+ context_gles2->set_use_vsync(video_mode.use_vsync);
+ set_vsync_via_compositor(video_mode.vsync_via_compositor);
+
+ if (RasterizerGLES2::is_viable() == OK) {
+ RasterizerGLES2::register_config();
+ RasterizerGLES2::make_current();
+ } else {
+ memdelete(context_gles2);
+ context_gles2 = NULL;
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
+ }
+#endif
+ WindowID main_window = _create_window(p_mode, 0, Rect2i(Point2i(), p_resolution));
+ for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
+ if (p_flags & (1 << i)) {
+ window_set_flag(WindowFlags(i), true, main_window);
+ }
+ }
+
+ ShowWindow(windows[MAIN_WINDOW_ID].hWnd, SW_SHOW); // Show The Window
+ SetForegroundWindow(windows[MAIN_WINDOW_ID].hWnd); // Slightly Higher Priority
+ SetFocus(windows[MAIN_WINDOW_ID].hWnd); // Sets Keyboard Focus To
+
+#if defined(VULKAN_ENABLED)
+
+ if (rendering_driver == "vulkan") {
+
+ rendering_device_vulkan = memnew(RenderingDeviceVulkan);
+ rendering_device_vulkan->initialize(context_vulkan);
+
+ RasterizerRD::make_current();
+ }
+#endif
+
+ move_timer_id = 1;
+
+ //set_ime_active(false);
+
+ if (!OS::get_singleton()->is_in_low_processor_usage_mode()) {
+ //SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
+ SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
+ DWORD index = 0;
+ HANDLE handle = AvSetMmThreadCharacteristics("Games", &index);
+ if (handle)
+ AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL);
+
+ // This is needed to make sure that background work does not starve the main thread.
+ // This is only setting priority of this thread, not the whole process.
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ }
+
+ cursor_shape = CURSOR_ARROW;
+
+ _update_real_mouse_position(MAIN_WINDOW_ID);
+
+ joypad = new JoypadWindows(&windows[MAIN_WINDOW_ID].hWnd);
+
+ r_error = OK;
+
+ ((OS_Windows *)OS::get_singleton())->set_main_window(windows[MAIN_WINDOW_ID].hWnd);
+ InputFilter::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
+}
+
+Vector<String> DisplayServerWindows::get_rendering_drivers_func() {
+ Vector<String> drivers;
+
+#ifdef VULKAN_ENABLED
+ drivers.push_back("vulkan");
+#endif
+#ifdef OPENGL_ENABLED
+ drivers.push_back("opengl");
+#endif
+
+ return drivers;
+}
+
+DisplayServer *DisplayServerWindows::create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
+
+ return memnew(DisplayServerWindows(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
+}
+
+void DisplayServerWindows::register_windows_driver() {
+
+ register_create_function("windows", create_func, get_rendering_drivers_func);
+}
+
+DisplayServerWindows::~DisplayServerWindows() {
+
+ delete joypad;
+ touch_state.clear();
+
+ cursors_cache.clear();
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ }
+
+ if (context_vulkan)
+ memdelete(context_vulkan);
+ }
+#endif
+
+ if (user_proc) {
+ SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
+ };
+
+ if (windows.has(MAIN_WINDOW_ID)) {
+#ifdef VULKAN_ENABLED
+ if (rendering_driver == "vulkan") {
+ context_vulkan->window_destroy(MAIN_WINDOW_ID);
+ }
+#endif
+
+ DestroyWindow(windows[MAIN_WINDOW_ID].hWnd);
+ }
+}
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
new file mode 100644
index 0000000000..e2c2fd7253
--- /dev/null
+++ b/platform/windows/display_server_windows.h
@@ -0,0 +1,419 @@
+/*************************************************************************/
+/* display_server_windows.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef DISPLAY_SERVER_WINDOWS_H
+#define DISPLAY_SERVER_WINDOWS_H
+
+#include "servers/display_server.h"
+
+#include "core/input/input_filter.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
+#include "crash_handler_windows.h"
+#include "drivers/unix/ip_unix.h"
+#include "drivers/wasapi/audio_driver_wasapi.h"
+#include "drivers/winmidi/midi_driver_winmidi.h"
+#include "joypad_windows.h"
+#include "key_mapping_windows.h"
+#include "servers/audio_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_rd.h"
+#include "servers/rendering_server.h"
+
+#ifdef XAUDIO2_ENABLED
+#include "drivers/xaudio2/audio_driver_xaudio2.h"
+#endif
+
+#if defined(OPENGL_ENABLED)
+#include "context_gl_windows.h"
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "drivers/vulkan/rendering_device_vulkan.h"
+#include "platform/windows/vulkan_context_win.h"
+#endif
+
+#include <fcntl.h>
+#include <io.h>
+#include <stdio.h>
+#include <windows.h>
+#include <windowsx.h>
+
+#ifndef POINTER_STRUCTURES
+
+#define POINTER_STRUCTURES
+
+typedef DWORD POINTER_INPUT_TYPE;
+typedef UINT32 POINTER_FLAGS;
+typedef UINT32 PEN_FLAGS;
+typedef UINT32 PEN_MASK;
+
+enum tagPOINTER_INPUT_TYPE {
+ PT_POINTER = 0x00000001,
+ PT_TOUCH = 0x00000002,
+ PT_PEN = 0x00000003,
+ PT_MOUSE = 0x00000004,
+ PT_TOUCHPAD = 0x00000005
+};
+
+typedef enum tagPOINTER_BUTTON_CHANGE_TYPE {
+ POINTER_CHANGE_NONE,
+ POINTER_CHANGE_FIRSTBUTTON_DOWN,
+ POINTER_CHANGE_FIRSTBUTTON_UP,
+ POINTER_CHANGE_SECONDBUTTON_DOWN,
+ POINTER_CHANGE_SECONDBUTTON_UP,
+ POINTER_CHANGE_THIRDBUTTON_DOWN,
+ POINTER_CHANGE_THIRDBUTTON_UP,
+ POINTER_CHANGE_FOURTHBUTTON_DOWN,
+ POINTER_CHANGE_FOURTHBUTTON_UP,
+ POINTER_CHANGE_FIFTHBUTTON_DOWN,
+ POINTER_CHANGE_FIFTHBUTTON_UP,
+} POINTER_BUTTON_CHANGE_TYPE;
+
+typedef struct tagPOINTER_INFO {
+ POINTER_INPUT_TYPE pointerType;
+ UINT32 pointerId;
+ UINT32 frameId;
+ POINTER_FLAGS pointerFlags;
+ HANDLE sourceDevice;
+ HWND hwndTarget;
+ POINT ptPixelLocation;
+ POINT ptHimetricLocation;
+ POINT ptPixelLocationRaw;
+ POINT ptHimetricLocationRaw;
+ DWORD dwTime;
+ UINT32 historyCount;
+ INT32 InputData;
+ DWORD dwKeyStates;
+ UINT64 PerformanceCount;
+ POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
+} POINTER_INFO;
+
+typedef struct tagPOINTER_PEN_INFO {
+ POINTER_INFO pointerInfo;
+ PEN_FLAGS penFlags;
+ PEN_MASK penMask;
+ UINT32 pressure;
+ UINT32 rotation;
+ INT32 tiltX;
+ INT32 tiltY;
+} POINTER_PEN_INFO;
+
+#endif //POINTER_STRUCTURES
+
+typedef BOOL(WINAPI *GetPointerTypePtr)(uint32_t p_id, POINTER_INPUT_TYPE *p_type);
+typedef BOOL(WINAPI *GetPointerPenInfoPtr)(uint32_t p_id, POINTER_PEN_INFO *p_pen_info);
+
+typedef struct {
+ BYTE bWidth; // Width, in pixels, of the image
+ BYTE bHeight; // Height, in pixels, of the image
+ BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
+ BYTE bReserved; // Reserved ( must be 0)
+ WORD wPlanes; // Color Planes
+ WORD wBitCount; // Bits per pixel
+ DWORD dwBytesInRes; // How many bytes in this resource?
+ DWORD dwImageOffset; // Where in the file is this image?
+} ICONDIRENTRY, *LPICONDIRENTRY;
+
+typedef struct {
+ WORD idReserved; // Reserved (must be 0)
+ WORD idType; // Resource Type (1 for icons)
+ WORD idCount; // How many images?
+ ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
+} ICONDIR, *LPICONDIR;
+
+class DisplayServerWindows : public DisplayServer {
+ //No need to register, it's platform-specific and nothing is added
+ //GDCLASS(DisplayServerWindows, DisplayServer)
+
+ _THREAD_SAFE_CLASS_
+
+ static GetPointerTypePtr win8p_GetPointerType;
+ static GetPointerPenInfoPtr win8p_GetPointerPenInfo;
+
+ void GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap);
+
+ enum {
+ KEY_EVENT_BUFFER_SIZE = 512
+ };
+
+ struct KeyEvent {
+
+ WindowID window_id;
+ bool alt, shift, control, meta;
+ UINT uMsg;
+ WPARAM wParam;
+ LPARAM lParam;
+ };
+
+ KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE];
+ int key_event_pos;
+
+ bool old_invalid;
+ bool outside;
+ int old_x, old_y;
+ Point2i center;
+
+#if defined(OPENGL_ENABLED)
+ ContextGL_Windows *context_gles2;
+#endif
+
+#if defined(VULKAN_ENABLED)
+ VulkanContextWindows *context_vulkan;
+ RenderingDeviceVulkan *rendering_device_vulkan;
+#endif
+
+ Map<int, Vector2> touch_state;
+
+ int pressrc;
+ HINSTANCE hInstance; // Holds The Instance Of The Application
+ String rendering_driver;
+
+ struct WindowData {
+ HWND hWnd;
+ //layered window
+
+ bool preserve_window_size = false;
+ bool pre_fs_valid = false;
+ RECT pre_fs_rect;
+ bool maximized = false;
+ bool minimized = false;
+ bool fullscreen = false;
+ bool borderless = false;
+ bool resizable = true;
+ bool window_focused = false;
+ bool was_maximized = false;
+ bool always_on_top = false;
+ bool no_focus = false;
+ bool window_has_focus = false;
+
+ HBITMAP hBitmap; //DIB section for layered window
+ uint8_t *dib_data = nullptr;
+ Size2 dib_size;
+ HDC hDC_dib;
+ Size2 min_size;
+ Size2 max_size;
+ int width = 0, height = 0;
+
+ Size2 window_rect;
+ Point2 last_pos;
+
+ ObjectID instance_id;
+
+ // IME
+ HIMC im_himc;
+ Vector2 im_position;
+
+ bool layered_window = false;
+
+ Callable rect_changed_callback;
+ Callable event_callback;
+ Callable input_event_callback;
+ Callable input_text_callback;
+ Callable drop_files_callback;
+
+ WindowID transient_parent = INVALID_WINDOW_ID;
+ Set<WindowID> transient_children;
+ };
+
+ JoypadWindows *joypad;
+
+ WindowID _create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect);
+ WindowID window_id_counter = MAIN_WINDOW_ID;
+ Map<WindowID, WindowData> windows;
+
+ WindowID last_focused_window = INVALID_WINDOW_ID;
+
+ uint32_t move_timer_id;
+
+ HCURSOR hCursor;
+
+ WNDPROC user_proc = nullptr;
+
+ void _send_window_event(const WindowData &wd, WindowEvent p_event);
+ void _get_window_style(bool p_main_window, bool p_fullscreen, bool p_borderless, bool p_resizable, bool p_maximized, bool p_no_activate_focus, DWORD &r_style, DWORD &r_style_ex);
+
+ MouseMode mouse_mode;
+ bool alt_mem = false;
+ bool gr_mem = false;
+ bool shift_mem = false;
+ bool control_mem = false;
+ bool meta_mem = false;
+ bool force_quit = false;
+ uint32_t last_button_state = 0;
+ bool use_raw_input = false;
+ bool drop_events = false;
+ bool console_visible = false;
+
+ WNDCLASSEXW wc;
+
+ HCURSOR cursors[CURSOR_MAX] = { NULL };
+ CursorShape cursor_shape;
+ Map<CursorShape, Vector<Variant>> cursors_cache;
+
+ void _drag_event(WindowID p_window, float p_x, float p_y, int idx);
+ void _touch_event(WindowID p_window, bool p_pressed, float p_x, float p_y, int idx);
+
+ void _update_window_style(WindowID p_window, bool p_repaint = true, bool p_maximized = false);
+
+ void _update_real_mouse_position(WindowID p_window);
+
+ void _set_mouse_mode_impl(MouseMode p_mode);
+
+ void _process_key_events();
+
+ static void _dispatch_input_events(const Ref<InputEvent> &p_event);
+ void _dispatch_input_event(const Ref<InputEvent> &p_event);
+
+public:
+ LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+ virtual bool has_feature(Feature p_feature) const;
+ virtual String get_name() const;
+
+ virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+
+ virtual void mouse_set_mode(MouseMode p_mode);
+ virtual MouseMode mouse_get_mode() const;
+
+ virtual void mouse_warp_to_position(const Point2i &p_to);
+ virtual Point2i mouse_get_position() const;
+ virtual int mouse_get_button_state() const;
+
+ virtual void clipboard_set(const String &p_text);
+ virtual String clipboard_get() const;
+
+ virtual int get_screen_count() const;
+ virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+
+ virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW);
+ ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+
+ virtual void screen_set_keep_on(bool p_enable); //disable screensaver
+ virtual bool screen_is_kept_on() const;
+
+ virtual Vector<DisplayServer::WindowID> get_window_list() const;
+
+ virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i());
+ virtual void delete_sub_window(WindowID p_window);
+
+ virtual WindowID get_window_at_screen_position(const Point2i &p_position) const;
+
+ virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID);
+ virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void window_set_transient(WindowID p_window, WindowID p_parent);
+
+ virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
+ virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
+ virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const; //wtf is this? should probable use proper name
+
+ virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
+ virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
+ virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
+
+ virtual bool can_any_window_draw() const;
+
+ virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual void console_set_visible(bool p_enabled);
+ virtual bool is_console_visible() const;
+
+ virtual void cursor_set_shape(CursorShape p_shape);
+ virtual CursorShape cursor_get_shape() const;
+ virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
+
+ virtual bool get_swap_ok_cancel();
+
+ virtual void enable_for_stealing_focus(OS::ProcessID pid);
+
+ virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+
+ virtual void process_events();
+
+ virtual void force_process_and_drop_events();
+
+ virtual void release_rendering_thread();
+ virtual void make_rendering_thread();
+ virtual void swap_buffers();
+
+ virtual void set_native_icon(const String &p_filename);
+ virtual void set_icon(const Ref<Image> &p_icon);
+
+ virtual void vsync_set_use_via_compositor(bool p_enable);
+ virtual bool vsync_is_using_via_compositor() const;
+
+ virtual void set_context(Context p_context);
+
+ static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+ static Vector<String> get_rendering_drivers_func();
+ static void register_windows_driver();
+
+ DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+ ~DisplayServerWindows();
+};
+
+#endif // DISPLAY_SERVER_WINDOWS_H
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index 49432435b9..9de1b7b194 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -52,9 +52,9 @@ DWORD WINAPI _xinput_set_state(DWORD dwUserIndex, XINPUT_VIBRATION *pVibration)
JoypadWindows::JoypadWindows() {
}
-JoypadWindows::JoypadWindows(InputDefault *_input, HWND *hwnd) {
+JoypadWindows::JoypadWindows(HWND *hwnd) {
- input = _input;
+ input = InputFilter::get_singleton();
hWnd = hwnd;
joypad_count = 0;
dinput = NULL;
@@ -436,46 +436,46 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
// BOOL POVCentered = (LOWORD(dwPOV) == 0xFFFF);"
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416628(v%3Dvs.85)#remarks
if (LOWORD(p_dpad) == 0xFFFF) {
- dpad_val = InputDefault::HAT_MASK_CENTER;
+ dpad_val = InputFilter::HAT_MASK_CENTER;
}
if (p_dpad == 0) {
- dpad_val = InputDefault::HAT_MASK_UP;
+ dpad_val = InputFilter::HAT_MASK_UP;
} else if (p_dpad == 4500) {
- dpad_val = (InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_RIGHT);
+ dpad_val = (InputFilter::HAT_MASK_UP | InputFilter::HAT_MASK_RIGHT);
} else if (p_dpad == 9000) {
- dpad_val = InputDefault::HAT_MASK_RIGHT;
+ dpad_val = InputFilter::HAT_MASK_RIGHT;
} else if (p_dpad == 13500) {
- dpad_val = (InputDefault::HAT_MASK_RIGHT | InputDefault::HAT_MASK_DOWN);
+ dpad_val = (InputFilter::HAT_MASK_RIGHT | InputFilter::HAT_MASK_DOWN);
} else if (p_dpad == 18000) {
- dpad_val = InputDefault::HAT_MASK_DOWN;
+ dpad_val = InputFilter::HAT_MASK_DOWN;
} else if (p_dpad == 22500) {
- dpad_val = (InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_LEFT);
+ dpad_val = (InputFilter::HAT_MASK_DOWN | InputFilter::HAT_MASK_LEFT);
} else if (p_dpad == 27000) {
- dpad_val = InputDefault::HAT_MASK_LEFT;
+ dpad_val = InputFilter::HAT_MASK_LEFT;
} else if (p_dpad == 31500) {
- dpad_val = (InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_UP);
+ dpad_val = (InputFilter::HAT_MASK_LEFT | InputFilter::HAT_MASK_UP);
}
input->joy_hat(p_device, dpad_val);
};
-InputDefault::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
+InputFilter::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
- InputDefault::JoyAxis jx;
+ InputFilter::JoyAxis jx;
if (Math::abs(p_val) < MIN_JOY_AXIS) {
jx.min = p_trigger ? 0 : -1;
jx.value = 0.0f;
diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h
index ab85bc60ac..f010fd08ff 100644
--- a/platform/windows/joypad_windows.h
+++ b/platform/windows/joypad_windows.h
@@ -52,7 +52,7 @@
class JoypadWindows {
public:
JoypadWindows();
- JoypadWindows(InputDefault *_input, HWND *hwnd);
+ JoypadWindows(HWND *hwnd);
~JoypadWindows();
void probe_joypads();
@@ -117,7 +117,7 @@ private:
HWND *hWnd;
HANDLE xinput_dll;
LPDIRECTINPUT8 dinput;
- InputDefault *input;
+ InputFilter *input;
int id_to_change;
int joypad_count;
@@ -141,7 +141,7 @@ private:
void joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop_xinput(int p_device, uint64_t p_timestamp);
- InputDefault::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const;
+ InputFilter::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const;
XInputGetState_t xinput_get_state;
XInputSetState_t xinput_set_state;
};
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 041a5bffa6..4112135cec 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -37,15 +37,6 @@
#include "core/debugger/script_debugger.h"
#include "core/io/marshalls.h"
#include "core/version_generated.gen.h"
-
-#if defined(OPENGL_ENABLED)
-#include "drivers/gles2/rasterizer_gles2.h"
-#endif
-
-#if defined(VULKAN_ENABLED)
-#include "servers/visual/rasterizer_rd/rasterizer_rd.h"
-#endif
-
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/rw_lock_windows.h"
@@ -53,9 +44,10 @@
#include "joypad_windows.h"
#include "lang_table.h"
#include "main/main.h"
+#include "platform/windows/display_server_windows.h"
#include "servers/audio_server.h"
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_wrap_mt.h"
#include "windows_terminal_logger.h"
#include <avrt.h>
@@ -86,30 +78,6 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#define GetProcAddress (void *)GetProcAddress
#endif
-typedef struct {
- int count;
- int screen;
- Size2 size;
-} EnumSizeData;
-
-typedef struct {
- int count;
- int screen;
- Point2 pos;
-} EnumPosData;
-
-static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
- EnumSizeData *data = (EnumSizeData *)dwData;
- if (data->count == data->screen) {
- data->size.x = lprcMonitor->right - lprcMonitor->left;
- data->size.y = lprcMonitor->bottom - lprcMonitor->top;
- }
-
- data->count++;
- return TRUE;
-}
-
#ifdef DEBUG_ENABLED
static String format_error_message(DWORD id) {
@@ -125,8 +93,6 @@ static String format_error_message(DWORD id) {
}
#endif // DEBUG_ENABLED
-extern HINSTANCE godot_hinstance;
-
void RedirectIOToConsole() {
int hConHandle;
@@ -208,24 +174,16 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) {
}
}
-GetPointerTypePtr OS_Windows::win8p_GetPointerType = NULL;
-GetPointerPenInfoPtr OS_Windows::win8p_GetPointerPenInfo = NULL;
-
void OS_Windows::initialize_debugging() {
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
}
-void OS_Windows::initialize_core() {
+void OS_Windows::initialize() {
crash_handler.initialize();
- last_button_state = 0;
-
//RedirectIOToConsole();
- maximized = false;
- minimized = false;
- borderless = false;
ThreadWindows::make_default();
RWLockWindows::make_default();
@@ -255,1371 +213,9 @@ void OS_Windows::initialize_core() {
process_map = memnew((Map<ProcessID, ProcessInfo>));
IP_Unix::make_default();
-
- cursor_shape = CURSOR_ARROW;
-}
-
-bool OS_Windows::can_draw() const {
-
- return !minimized;
-};
-
-#define MI_WP_SIGNATURE 0xFF515700
-#define SIGNATURE_MASK 0xFFFFFF00
-// Keeping the name suggested by Microsoft, but this macro really answers:
-// Is this mouse event emulated from touch or pen input?
-#define IsPenEvent(dw) (((dw)&SIGNATURE_MASK) == MI_WP_SIGNATURE)
-// This one tells whether the event comes from touchscreen (and not from pen)
-#define IsTouchEvent(dw) (IsPenEvent(dw) && ((dw)&0x80))
-
-void OS_Windows::_touch_event(bool p_pressed, float p_x, float p_y, int idx) {
-
- // Defensive
- if (touch_state.has(idx) == p_pressed)
- return;
-
- if (p_pressed) {
- touch_state.insert(idx, Vector2(p_x, p_y));
- } else {
- touch_state.erase(idx);
- }
-
- Ref<InputEventScreenTouch> event;
- event.instance();
- event->set_index(idx);
- event->set_pressed(p_pressed);
- event->set_position(Vector2(p_x, p_y));
-
- if (main_loop) {
- input->accumulate_input_event(event);
- }
-};
-
-void OS_Windows::_drag_event(float p_x, float p_y, int idx) {
-
- Map<int, Vector2>::Element *curr = touch_state.find(idx);
- // Defensive
- if (!curr)
- return;
-
- if (curr->get() == Vector2(p_x, p_y))
- return;
-
- Ref<InputEventScreenDrag> event;
- event.instance();
- event->set_index(idx);
- event->set_position(Vector2(p_x, p_y));
- event->set_relative(Vector2(p_x, p_y) - curr->get());
-
- if (main_loop)
- input->accumulate_input_event(event);
-
- curr->get() = Vector2(p_x, p_y);
-};
-
-LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
-
- if (drop_events) {
-
- if (user_proc) {
-
- return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
- } else {
- return DefWindowProcW(hWnd, uMsg, wParam, lParam);
- }
- };
-
- switch (uMsg) // Check For Windows Messages
- {
- case WM_SETFOCUS: {
- window_has_focus = true;
-
- // Restore mouse mode
- _set_mouse_mode_impl(mouse_mode);
-
- break;
- }
- case WM_KILLFOCUS: {
- window_has_focus = false;
-
- // Release capture unconditionally because it can be set due to dragging, in addition to captured mode
- ReleaseCapture();
-
- // Release every touch to avoid sticky points
- for (Map<int, Vector2>::Element *E = touch_state.front(); E; E = E->next()) {
- _touch_event(false, E->get().x, E->get().y, E->key());
- }
- touch_state.clear();
-
- break;
- }
- case WM_ACTIVATE: // Watch For Window Activate Message
- {
- minimized = HIWORD(wParam) != 0;
- if (!main_loop) {
- return 0;
- };
- if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) {
-
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
- window_focused = true;
- alt_mem = false;
- control_mem = false;
- shift_mem = false;
- } else { // WM_INACTIVE
- input->release_pressed_events();
- main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
- window_focused = false;
- alt_mem = false;
- };
-
- return 0; // Return To The Message Loop
- }
- case WM_GETMINMAXINFO: {
- if (video_mode.resizable && !video_mode.fullscreen) {
- Size2 decor = get_real_window_size() - get_window_size(); // Size of window decorations
- MINMAXINFO *min_max_info = (MINMAXINFO *)lParam;
- if (min_size != Size2()) {
- min_max_info->ptMinTrackSize.x = min_size.x + decor.x;
- min_max_info->ptMinTrackSize.y = min_size.y + decor.y;
- }
- if (max_size != Size2()) {
- min_max_info->ptMaxTrackSize.x = max_size.x + decor.x;
- min_max_info->ptMaxTrackSize.y = max_size.y + decor.y;
- }
- return 0;
- } else {
- break;
- }
- }
- case WM_PAINT:
-
- Main::force_redraw();
- break;
-
- case WM_SYSCOMMAND: // Intercept System Commands
- {
- switch (wParam) // Check System Calls
- {
- case SC_SCREENSAVE: // Screensaver Trying To Start?
- case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
- return 0; // Prevent From Happening
- case SC_KEYMENU:
- if ((lParam >> 16) <= 0)
- return 0;
- }
- break; // Exit
- }
-
- case WM_CLOSE: // Did We Receive A Close Message?
- {
- if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
- //force_quit=true;
- return 0; // Jump Back
- }
- case WM_MOUSELEAVE: {
-
- old_invalid = true;
- outside = true;
- if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED)
- main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
-
- } break;
- case WM_INPUT: {
- if (mouse_mode != MOUSE_MODE_CAPTURED || !use_raw_input) {
- break;
- }
-
- UINT dwSize;
-
- GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- LPBYTE lpb = new BYTE[dwSize];
- if (lpb == NULL) {
- return 0;
- }
-
- if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
- OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
-
- RAWINPUT *raw = (RAWINPUT *)lpb;
-
- if (raw->header.dwType == RIM_TYPEMOUSE) {
- Ref<InputEventMouseMotion> mm;
- mm.instance();
-
- mm->set_control(control_mem);
- mm->set_shift(shift_mem);
- mm->set_alt(alt_mem);
-
- mm->set_button_mask(last_button_state);
-
- Point2i c(video_mode.width / 2, video_mode.height / 2);
-
- // centering just so it works as before
- POINT pos = { (int)c.x, (int)c.y };
- ClientToScreen(hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
-
- mm->set_position(c);
- mm->set_global_position(c);
- input->set_mouse_position(c);
- mm->set_speed(Vector2(0, 0));
-
- if (raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE) {
- mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY));
-
- } else if (raw->data.mouse.usFlags == MOUSE_MOVE_ABSOLUTE) {
-
- int nScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
- int nScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
- int nScreenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
- int nScreenTop = GetSystemMetrics(SM_YVIRTUALSCREEN);
-
- Vector2 abs_pos(
- (double(raw->data.mouse.lLastX) - 65536.0 / (nScreenWidth)) * nScreenWidth / 65536.0 + nScreenLeft,
- (double(raw->data.mouse.lLastY) - 65536.0 / (nScreenHeight)) * nScreenHeight / 65536.0 + nScreenTop);
-
- POINT coords; //client coords
- coords.x = abs_pos.x;
- coords.y = abs_pos.y;
-
- ScreenToClient(hWnd, &coords);
-
- mm->set_relative(Vector2(coords.x - old_x, coords.y - old_y));
- old_x = coords.x;
- old_y = coords.y;
-
- /*Input.mi.dx = (int)((((double)(pos.x)-nScreenLeft) * 65536) / nScreenWidth + 65536 / (nScreenWidth));
- Input.mi.dy = (int)((((double)(pos.y)-nScreenTop) * 65536) / nScreenHeight + 65536 / (nScreenHeight));
- */
- }
-
- if (window_has_focus && main_loop && mm->get_relative() != Vector2())
- input->accumulate_input_event(mm);
- }
- delete[] lpb;
- } break;
- case WM_POINTERUPDATE: {
- if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
- break;
- }
-
- if (!win8p_GetPointerType || !win8p_GetPointerPenInfo) {
- break;
- }
-
- uint32_t pointer_id = LOWORD(wParam);
- POINTER_INPUT_TYPE pointer_type = PT_POINTER;
- if (!win8p_GetPointerType(pointer_id, &pointer_type)) {
- break;
- }
-
- if (pointer_type != PT_PEN) {
- break;
- }
-
- POINTER_PEN_INFO pen_info;
- if (!win8p_GetPointerPenInfo(pointer_id, &pen_info)) {
- break;
- }
-
- if (input->is_emulating_mouse_from_touch()) {
- // Universal translation enabled; ignore OS translation
- LPARAM extra = GetMessageExtraInfo();
- if (IsTouchEvent(extra)) {
- break;
- }
- }
-
- if (outside) {
- //mouse enter
-
- if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED)
- main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
-
- CursorShape c = cursor_shape;
- cursor_shape = CURSOR_MAX;
- set_cursor_shape(c);
- outside = false;
-
- //Once-Off notification, must call again....
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- TrackMouseEvent(&tme);
- }
-
- // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
- if (!window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED)
- break;
-
- Ref<InputEventMouseMotion> mm;
- mm.instance();
-
- mm->set_pressure(pen_info.pressure ? (float)pen_info.pressure / 1024 : 0);
- mm->set_tilt(Vector2(pen_info.tiltX ? (float)pen_info.tiltX / 90 : 0, pen_info.tiltY ? (float)pen_info.tiltY / 90 : 0));
-
- mm->set_control((wParam & MK_CONTROL) != 0);
- mm->set_shift((wParam & MK_SHIFT) != 0);
- mm->set_alt(alt_mem);
-
- mm->set_button_mask(last_button_state);
-
- POINT coords; //client coords
- coords.x = GET_X_LPARAM(lParam);
- coords.y = GET_Y_LPARAM(lParam);
-
- ScreenToClient(hWnd, &coords);
-
- mm->set_position(Vector2(coords.x, coords.y));
- mm->set_global_position(Vector2(coords.x, coords.y));
-
- if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
- Point2i c(video_mode.width / 2, video_mode.height / 2);
- old_x = c.x;
- old_y = c.y;
-
- if (mm->get_position() == c) {
- center = c;
- return 0;
- }
-
- Point2i ncenter = mm->get_position();
- center = ncenter;
- POINT pos = { (int)c.x, (int)c.y };
- ClientToScreen(hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- }
-
- input->set_mouse_position(mm->get_position());
- mm->set_speed(input->get_last_mouse_speed());
-
- if (old_invalid) {
-
- old_x = mm->get_position().x;
- old_y = mm->get_position().y;
- old_invalid = false;
- }
-
- mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
- old_x = mm->get_position().x;
- old_y = mm->get_position().y;
- if (window_has_focus && main_loop)
- input->parse_input_event(mm);
-
- return 0; //Pointer event handled return 0 to avoid duplicate WM_MOUSEMOVE event
- } break;
- case WM_MOUSEMOVE: {
- if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
- break;
- }
-
- if (input->is_emulating_mouse_from_touch()) {
- // Universal translation enabled; ignore OS translation
- LPARAM extra = GetMessageExtraInfo();
- if (IsTouchEvent(extra)) {
- break;
- }
- }
-
- if (outside) {
- //mouse enter
-
- if (main_loop && mouse_mode != MOUSE_MODE_CAPTURED)
- main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
-
- CursorShape c = cursor_shape;
- cursor_shape = CURSOR_MAX;
- set_cursor_shape(c);
- outside = false;
-
- //Once-Off notification, must call again....
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- TrackMouseEvent(&tme);
- }
-
- // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
- if (!window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED)
- break;
-
- Ref<InputEventMouseMotion> mm;
- mm.instance();
-
- mm->set_control((wParam & MK_CONTROL) != 0);
- mm->set_shift((wParam & MK_SHIFT) != 0);
- mm->set_alt(alt_mem);
-
- mm->set_button_mask(last_button_state);
-
- mm->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
- mm->set_global_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
-
- if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
- Point2i c(video_mode.width / 2, video_mode.height / 2);
- old_x = c.x;
- old_y = c.y;
-
- if (mm->get_position() == c) {
- center = c;
- return 0;
- }
-
- Point2i ncenter = mm->get_position();
- center = ncenter;
- POINT pos = { (int)c.x, (int)c.y };
- ClientToScreen(hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- }
-
- input->set_mouse_position(mm->get_position());
- mm->set_speed(input->get_last_mouse_speed());
-
- if (old_invalid) {
-
- old_x = mm->get_position().x;
- old_y = mm->get_position().y;
- old_invalid = false;
- }
-
- mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y)));
- old_x = mm->get_position().x;
- old_y = mm->get_position().y;
- if (window_has_focus && main_loop)
- input->accumulate_input_event(mm);
-
- } break;
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- if (input->is_emulating_mouse_from_touch()) {
- // Universal translation enabled; ignore OS translations for left button
- LPARAM extra = GetMessageExtraInfo();
- if (IsTouchEvent(extra)) {
- break;
- }
- }
- [[fallthrough]];
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_MOUSEWHEEL:
- case WM_MOUSEHWHEEL:
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDBLCLK:
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- case WM_XBUTTONUP: {
-
- Ref<InputEventMouseButton> mb;
- mb.instance();
-
- switch (uMsg) {
- case WM_LBUTTONDOWN: {
- mb->set_pressed(true);
- mb->set_button_index(1);
- } break;
- case WM_LBUTTONUP: {
- mb->set_pressed(false);
- mb->set_button_index(1);
- } break;
- case WM_MBUTTONDOWN: {
- mb->set_pressed(true);
- mb->set_button_index(3);
- } break;
- case WM_MBUTTONUP: {
- mb->set_pressed(false);
- mb->set_button_index(3);
- } break;
- case WM_RBUTTONDOWN: {
- mb->set_pressed(true);
- mb->set_button_index(2);
- } break;
- case WM_RBUTTONUP: {
- mb->set_pressed(false);
- mb->set_button_index(2);
- } break;
- case WM_LBUTTONDBLCLK: {
- mb->set_pressed(true);
- mb->set_button_index(1);
- mb->set_doubleclick(true);
- } break;
- case WM_RBUTTONDBLCLK: {
- mb->set_pressed(true);
- mb->set_button_index(2);
- mb->set_doubleclick(true);
- } break;
- case WM_MBUTTONDBLCLK: {
- mb->set_pressed(true);
- mb->set_button_index(3);
- mb->set_doubleclick(true);
- } break;
- case WM_MOUSEWHEEL: {
-
- mb->set_pressed(true);
- int motion = (short)HIWORD(wParam);
- if (!motion)
- return 0;
-
- if (motion > 0)
- mb->set_button_index(BUTTON_WHEEL_UP);
- else
- mb->set_button_index(BUTTON_WHEEL_DOWN);
-
- } break;
- case WM_MOUSEHWHEEL: {
-
- mb->set_pressed(true);
- int motion = (short)HIWORD(wParam);
- if (!motion)
- return 0;
-
- if (motion < 0) {
- mb->set_button_index(BUTTON_WHEEL_LEFT);
- mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
- } else {
- mb->set_button_index(BUTTON_WHEEL_RIGHT);
- mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
- }
- } break;
- case WM_XBUTTONDOWN: {
-
- mb->set_pressed(true);
- if (HIWORD(wParam) == XBUTTON1)
- mb->set_button_index(BUTTON_XBUTTON1);
- else
- mb->set_button_index(BUTTON_XBUTTON2);
- } break;
- case WM_XBUTTONUP: {
-
- mb->set_pressed(false);
- if (HIWORD(wParam) == XBUTTON1)
- mb->set_button_index(BUTTON_XBUTTON1);
- else
- mb->set_button_index(BUTTON_XBUTTON2);
- } break;
- case WM_XBUTTONDBLCLK: {
-
- mb->set_pressed(true);
- if (HIWORD(wParam) == XBUTTON1)
- mb->set_button_index(BUTTON_XBUTTON1);
- else
- mb->set_button_index(BUTTON_XBUTTON2);
- mb->set_doubleclick(true);
- } break;
- default: {
- return 0;
- }
- }
-
- mb->set_control((wParam & MK_CONTROL) != 0);
- mb->set_shift((wParam & MK_SHIFT) != 0);
- mb->set_alt(alt_mem);
- //mb->get_alt()=(wParam&MK_MENU)!=0;
- if (mb->is_pressed())
- last_button_state |= (1 << (mb->get_button_index() - 1));
- else
- last_button_state &= ~(1 << (mb->get_button_index() - 1));
- mb->set_button_mask(last_button_state);
-
- mb->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
-
- if (mouse_mode == MOUSE_MODE_CAPTURED && !use_raw_input) {
-
- mb->set_position(Vector2(old_x, old_y));
- }
-
- if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) {
- if (mb->is_pressed()) {
-
- if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED)
- SetCapture(hWnd);
- } else {
-
- if (--pressrc <= 0) {
- if (mouse_mode != MOUSE_MODE_CAPTURED) {
- ReleaseCapture();
- }
- pressrc = 0;
- }
- }
- } else {
- // for reasons unknown to mankind, wheel comes in screen coordinates
- POINT coords;
- coords.x = mb->get_position().x;
- coords.y = mb->get_position().y;
-
- ScreenToClient(hWnd, &coords);
-
- mb->set_position(Vector2(coords.x, coords.y));
- }
-
- mb->set_global_position(mb->get_position());
-
- if (main_loop) {
- input->accumulate_input_event(mb);
- if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) {
- //send release for mouse wheel
- Ref<InputEventMouseButton> mbd = mb->duplicate();
- last_button_state &= ~(1 << (mbd->get_button_index() - 1));
- mbd->set_button_mask(last_button_state);
- mbd->set_pressed(false);
- input->accumulate_input_event(mbd);
- }
- }
- } break;
-
- case WM_MOVE: {
- if (!IsIconic(hWnd)) {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- last_pos = Point2(x, y);
- }
- } break;
-
- case WM_SIZE: {
- // Ignore size when a SIZE_MINIMIZED event is triggered
- if (wParam != SIZE_MINIMIZED) {
- int window_w = LOWORD(lParam);
- int window_h = HIWORD(lParam);
- if (window_w > 0 && window_h > 0 && !preserve_window_size) {
- video_mode.width = window_w;
- video_mode.height = window_h;
- } else {
- preserve_window_size = false;
- set_window_size(Size2(video_mode.width, video_mode.height));
- }
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- context_vulkan->window_resize(0, video_mode.width, video_mode.height);
- }
-#endif
- }
-
- if (wParam == SIZE_MAXIMIZED) {
- maximized = true;
- minimized = false;
- } else if (wParam == SIZE_MINIMIZED) {
- maximized = false;
- minimized = true;
- } else if (wParam == SIZE_RESTORED) {
- maximized = false;
- minimized = false;
- }
- if (is_layered_allowed() && layered_window) {
- DeleteObject(hBitmap);
-
- RECT r;
- GetWindowRect(hWnd, &r);
- dib_size = Size2i(r.right - r.left, r.bottom - r.top);
-
- BITMAPINFO bmi;
- ZeroMemory(&bmi, sizeof(BITMAPINFO));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = dib_size.x;
- bmi.bmiHeader.biHeight = dib_size.y;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = dib_size.x * dib_size.y * 4;
- hBitmap = CreateDIBSection(hDC_dib, &bmi, DIB_RGB_COLORS, (void **)&dib_data, NULL, 0x0);
- SelectObject(hDC_dib, hBitmap);
-
- ZeroMemory(dib_data, dib_size.x * dib_size.y * 4);
- }
- //return 0; // Jump Back
- } break;
-
- case WM_ENTERSIZEMOVE: {
- input->release_pressed_events();
- move_timer_id = SetTimer(hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC)NULL);
- } break;
- case WM_EXITSIZEMOVE: {
- KillTimer(hWnd, move_timer_id);
- } break;
- case WM_TIMER: {
- if (wParam == move_timer_id) {
- process_key_events();
- if (!Main::is_iterating()) {
- Main::iteration();
- }
- }
- } break;
-
- case WM_SYSKEYDOWN:
- case WM_SYSKEYUP:
- case WM_KEYUP:
- case WM_KEYDOWN: {
-
- if (wParam == VK_SHIFT)
- shift_mem = uMsg == WM_KEYDOWN;
- if (wParam == VK_CONTROL)
- control_mem = uMsg == WM_KEYDOWN;
- if (wParam == VK_MENU) {
- alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN);
- if (lParam & (1 << 24))
- gr_mem = alt_mem;
- }
-
- if (mouse_mode == MOUSE_MODE_CAPTURED) {
- // When SetCapture is used, ALT+F4 hotkey is ignored by Windows, so handle it ourselves
- if (wParam == VK_F4 && alt_mem && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)) {
- if (main_loop)
- main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
- }
- }
- /*
- if (wParam==VK_WIN) TODO wtf is this?
- meta_mem=uMsg==WM_KEYDOWN;
- */
- [[fallthrough]];
- }
- case WM_CHAR: {
-
- ERR_BREAK(key_event_pos >= KEY_EVENT_BUFFER_SIZE);
-
- // Make sure we don't include modifiers for the modifier key itself.
- KeyEvent ke;
- ke.shift = (wParam != VK_SHIFT) ? shift_mem : false;
- ke.alt = (!(wParam == VK_MENU && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN))) ? alt_mem : false;
- ke.control = (wParam != VK_CONTROL) ? control_mem : false;
- ke.meta = meta_mem;
- ke.uMsg = uMsg;
-
- if (ke.uMsg == WM_SYSKEYDOWN)
- ke.uMsg = WM_KEYDOWN;
- if (ke.uMsg == WM_SYSKEYUP)
- ke.uMsg = WM_KEYUP;
-
- ke.wParam = wParam;
- ke.lParam = lParam;
- key_event_buffer[key_event_pos++] = ke;
-
- } break;
- case WM_INPUTLANGCHANGEREQUEST: {
-
- // FIXME: Do something?
- } break;
-
- case WM_TOUCH: {
-
- BOOL bHandled = FALSE;
- UINT cInputs = LOWORD(wParam);
- PTOUCHINPUT pInputs = memnew_arr(TOUCHINPUT, cInputs);
- if (pInputs) {
- if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) {
- for (UINT i = 0; i < cInputs; i++) {
- TOUCHINPUT ti = pInputs[i];
- POINT touch_pos = {
- TOUCH_COORD_TO_PIXEL(ti.x),
- TOUCH_COORD_TO_PIXEL(ti.y),
- };
- ScreenToClient(hWnd, &touch_pos);
- //do something with each touch input entry
- if (ti.dwFlags & TOUCHEVENTF_MOVE) {
-
- _drag_event(touch_pos.x, touch_pos.y, ti.dwID);
- } else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) {
-
- _touch_event(ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID);
- };
- }
- bHandled = TRUE;
- } else {
- /* handle the error here */
- }
- memdelete_arr(pInputs);
- } else {
- /* handle the error here, probably out of memory */
- }
- if (bHandled) {
- CloseTouchInputHandle((HTOUCHINPUT)lParam);
- return 0;
- };
-
- } break;
-
- case WM_DEVICECHANGE: {
-
- joypad->probe_joypads();
- } break;
- case WM_SETCURSOR: {
- if (LOWORD(lParam) == HTCLIENT) {
- if (window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) {
- //Hide the cursor
- if (hCursor == NULL)
- hCursor = SetCursor(NULL);
- else
- SetCursor(NULL);
- } else {
- if (hCursor != NULL) {
- CursorShape c = cursor_shape;
- cursor_shape = CURSOR_MAX;
- set_cursor_shape(c);
- hCursor = NULL;
- }
- }
- }
-
- } break;
- case WM_DROPFILES: {
-
- HDROP hDropInfo = (HDROP)wParam;
- const int buffsize = 4096;
- wchar_t buf[buffsize];
-
- int fcount = DragQueryFileW(hDropInfo, 0xFFFFFFFF, NULL, 0);
-
- Vector<String> files;
-
- for (int i = 0; i < fcount; i++) {
-
- DragQueryFileW(hDropInfo, i, buf, buffsize);
- String file = buf;
- files.push_back(file);
- }
-
- if (files.size() && main_loop) {
- main_loop->drop_files(files, 0);
- }
-
- } break;
-
- default: {
-
- if (user_proc) {
-
- return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
- };
- };
- }
-
- return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-}
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
-
- OS_Windows *os_win = static_cast<OS_Windows *>(OS::get_singleton());
- if (os_win)
- return os_win->WndProc(hWnd, uMsg, wParam, lParam);
- else
- return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-}
-
-void OS_Windows::process_key_events() {
-
- for (int i = 0; i < key_event_pos; i++) {
-
- KeyEvent &ke = key_event_buffer[i];
- switch (ke.uMsg) {
-
- case WM_CHAR: {
- if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) {
- Ref<InputEventKey> k;
- k.instance();
-
- k->set_shift(ke.shift);
- k->set_alt(ke.alt);
- k->set_control(ke.control);
- k->set_metakey(ke.meta);
- k->set_pressed(true);
- k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam));
- k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)));
- k->set_unicode(ke.wParam);
- if (k->get_unicode() && gr_mem) {
- k->set_alt(false);
- k->set_control(false);
- }
-
- if (k->get_unicode() < 32)
- k->set_unicode(0);
-
- input->accumulate_input_event(k);
- }
-
- //do nothing
- } break;
- case WM_KEYUP:
- case WM_KEYDOWN: {
-
- Ref<InputEventKey> k;
- k.instance();
-
- k->set_shift(ke.shift);
- k->set_alt(ke.alt);
- k->set_control(ke.control);
- k->set_metakey(ke.meta);
-
- k->set_pressed(ke.uMsg == WM_KEYDOWN);
-
- if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) {
- // Special case for Numpad Enter key
- k->set_keycode(KEY_KP_ENTER);
- } else {
- k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam));
- }
-
- k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)));
-
- if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) {
- k->set_unicode(key_event_buffer[i + 1].wParam);
- }
- if (k->get_unicode() && gr_mem) {
- k->set_alt(false);
- k->set_control(false);
- }
-
- if (k->get_unicode() < 32)
- k->set_unicode(0);
-
- k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30))));
-
- input->accumulate_input_event(k);
-
- } break;
- }
- }
-
- key_event_pos = 0;
-}
-
-enum _MonitorDpiType {
- MDT_Effective_DPI = 0,
- MDT_Angular_DPI = 1,
- MDT_Raw_DPI = 2,
- MDT_Default = MDT_Effective_DPI
-};
-
-static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Default) {
-
- int dpiX = 96, dpiY = 96;
-
- static HMODULE Shcore = NULL;
- typedef HRESULT(WINAPI * GetDPIForMonitor_t)(HMONITOR hmonitor, _MonitorDpiType dpiType, UINT * dpiX, UINT * dpiY);
- static GetDPIForMonitor_t getDPIForMonitor = NULL;
-
- if (Shcore == NULL) {
- Shcore = LoadLibraryW(L"Shcore.dll");
- getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : NULL;
-
- if ((Shcore == NULL) || (getDPIForMonitor == NULL)) {
- if (Shcore)
- FreeLibrary(Shcore);
- Shcore = (HMODULE)INVALID_HANDLE_VALUE;
- }
- }
-
- UINT x = 0, y = 0;
- HRESULT hr = E_FAIL;
- if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE)) {
- hr = getDPIForMonitor(hmon, dpiType /*MDT_Effective_DPI*/, &x, &y);
- if (SUCCEEDED(hr) && (x > 0) && (y > 0)) {
-
- dpiX = (int)x;
- dpiY = (int)y;
- }
- } else {
- static int overallX = 0, overallY = 0;
- if (overallX <= 0 || overallY <= 0) {
- HDC hdc = GetDC(NULL);
- if (hdc) {
- overallX = GetDeviceCaps(hdc, LOGPIXELSX);
- overallY = GetDeviceCaps(hdc, LOGPIXELSY);
- ReleaseDC(NULL, hdc);
- }
- }
- if (overallX > 0 && overallY > 0) {
- dpiX = overallX;
- dpiY = overallY;
- }
- }
-
- return (dpiX + dpiY) / 2;
-}
-
-typedef enum _SHC_PROCESS_DPI_AWARENESS {
- SHC_PROCESS_DPI_UNAWARE = 0,
- SHC_PROCESS_SYSTEM_DPI_AWARE = 1,
- SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2
-} SHC_PROCESS_DPI_AWARENESS;
-
-int OS_Windows::get_current_video_driver() const {
- return video_driver_index;
-}
-
-Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
-
main_loop = NULL;
- outside = true;
- window_has_focus = true;
- WNDCLASSEXW wc;
-
- if (is_hidpi_allowed()) {
- HMODULE Shcore = LoadLibraryW(L"Shcore.dll");
-
- if (Shcore != NULL) {
- typedef HRESULT(WINAPI * SetProcessDpiAwareness_t)(SHC_PROCESS_DPI_AWARENESS);
-
- SetProcessDpiAwareness_t SetProcessDpiAwareness = (SetProcessDpiAwareness_t)GetProcAddress(Shcore, "SetProcessDpiAwareness");
-
- if (SetProcessDpiAwareness) {
- SetProcessDpiAwareness(SHC_PROCESS_SYSTEM_DPI_AWARE);
- }
- }
- }
-
- video_mode = p_desired;
- //printf("**************** desired %s, mode %s\n", p_desired.fullscreen?"true":"false", video_mode.fullscreen?"true":"false");
- RECT WindowRect;
-
- WindowRect.left = 0;
- WindowRect.right = video_mode.width;
- WindowRect.top = 0;
- WindowRect.bottom = video_mode.height;
-
- memset(&wc, 0, sizeof(WNDCLASSEXW));
- wc.cbSize = sizeof(WNDCLASSEXW);
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
- wc.lpfnWndProc = (WNDPROC)::WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- //wc.hInstance = hInstance;
- wc.hInstance = godot_hinstance ? godot_hinstance : GetModuleHandle(NULL);
- wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
- wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = L"Engine";
-
- if (!RegisterClassExW(&wc)) {
- MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return ERR_UNAVAILABLE;
- }
-
- use_raw_input = true;
-
- RAWINPUTDEVICE Rid[1];
-
- Rid[0].usUsagePage = 0x01;
- Rid[0].usUsage = 0x02;
- Rid[0].dwFlags = 0;
- Rid[0].hwndTarget = 0;
-
- if (RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])) == FALSE) {
- //registration failed.
- use_raw_input = false;
- }
-
- pre_fs_valid = true;
- if (video_mode.fullscreen) {
-
- /* this returns DPI unaware size, commenting
- DEVMODE current;
- memset(&current, 0, sizeof(current));
- EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &current);
-
- WindowRect.right = current.dmPelsWidth;
- WindowRect.bottom = current.dmPelsHeight;
-
- */
-
- EnumSizeData data = { 0, 0, Size2() };
- EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
-
- WindowRect.right = data.size.width;
- WindowRect.bottom = data.size.height;
-
- /* DEVMODE dmScreenSettings;
- memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
- dmScreenSettings.dmSize=sizeof(dmScreenSettings);
- dmScreenSettings.dmPelsWidth = video_mode.width;
- dmScreenSettings.dmPelsHeight = video_mode.height;
- dmScreenSettings.dmBitsPerPel = current.dmBitsPerPel;
- dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
-
- LONG err = ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN);
- if (err!=DISP_CHANGE_SUCCESSFUL) {
-
- video_mode.fullscreen=false;
- }*/
- pre_fs_valid = false;
- }
-
- DWORD dwExStyle;
- DWORD dwStyle;
-
- if (video_mode.fullscreen || video_mode.borderless_window) {
-
- dwExStyle = WS_EX_APPWINDOW;
- dwStyle = WS_POPUP;
-
- } else {
- dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
- dwStyle = WS_OVERLAPPEDWINDOW;
- if (!video_mode.resizable) {
- dwStyle &= ~WS_THICKFRAME;
- dwStyle &= ~WS_MAXIMIZEBOX;
- }
- }
-
- AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
-
- char *windowid;
-#ifdef MINGW_ENABLED
- windowid = getenv("GODOT_WINDOWID");
-#else
- size_t len;
- _dupenv_s(&windowid, &len, "GODOT_WINDOWID");
-#endif
-
- if (windowid) {
-
-// strtoull on mingw
-#ifdef MINGW_ENABLED
- hWnd = (HWND)strtoull(windowid, NULL, 0);
-#else
- hWnd = (HWND)_strtoui64(windowid, NULL, 0);
-#endif
- free(windowid);
- SetLastError(0);
- user_proc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC);
- SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)(WNDPROC)::WndProc);
- DWORD le = GetLastError();
- if (user_proc == 0 && le != 0) {
-
- printf("Error setting WNDPROC: %li\n", le);
- };
- GetWindowLongPtr(hWnd, GWLP_WNDPROC);
-
- RECT rect;
- if (!GetClientRect(hWnd, &rect)) {
- MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
- return ERR_UNAVAILABLE;
- };
- video_mode.width = rect.right;
- video_mode.height = rect.bottom;
- video_mode.fullscreen = false;
- } else {
-
- hWnd = CreateWindowExW(
- dwExStyle,
- L"Engine", L"",
- dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2,
- (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2,
- WindowRect.right - WindowRect.left,
- WindowRect.bottom - WindowRect.top,
- NULL, NULL, hInstance, NULL);
- if (!hWnd) {
- MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
- return ERR_UNAVAILABLE;
- }
- };
-
- if (video_mode.always_on_top) {
- SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
- }
-
- //!!!!!!!!!!!!!!!!!!!!!!!!!!
- //TODO - do Vulkan and GLES2 support checks, driver selection and fallback
- video_driver_index = p_video_driver;
- print_verbose("Driver: " + String(get_video_driver_name(video_driver_index)) + " [" + itos(video_driver_index) + "]");
- //!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- // Init context and rendering device
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
-
- context_gles2 = memnew(ContextGL_Windows(hWnd, false));
-
- if (context_gles2->initialize() != OK) {
- memdelete(context_gles2);
- context_gles2 = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- context_gles2->set_use_vsync(video_mode.use_vsync);
- set_vsync_via_compositor(video_mode.vsync_via_compositor);
-
- if (RasterizerGLES2::is_viable() == OK) {
- RasterizerGLES2::register_config();
- RasterizerGLES2::make_current();
- } else {
- memdelete(context_gles2);
- context_gles2 = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
-
- context_vulkan = memnew(VulkanContextWindows);
- if (context_vulkan->initialize() != OK) {
- memdelete(context_vulkan);
- context_vulkan = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- if (context_vulkan->window_create(hWnd, hInstance, get_video_mode().width, get_video_mode().height) == -1) {
- memdelete(context_vulkan);
- context_vulkan = NULL;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- //temporary
- rendering_device_vulkan = memnew(RenderingDeviceVulkan);
- rendering_device_vulkan->initialize(context_vulkan);
-
- RasterizerRD::make_current();
- }
-#endif
-
- visual_server = memnew(VisualServerRaster);
- if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
- }
-
- visual_server->init();
-
- input = memnew(InputDefault);
- joypad = memnew(JoypadWindows(input, &hWnd));
-
- AudioDriverManager::initialize(p_audio_driver);
-
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(TRACKMOUSEEVENT);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hWnd;
- tme.dwHoverTime = HOVER_DEFAULT;
- TrackMouseEvent(&tme);
-
- RegisterTouchWindow(hWnd, 0);
-
- _ensure_user_data_dir();
-
- DragAcceptFiles(hWnd, true);
-
- move_timer_id = 1;
-
- if (!is_no_window_mode_enabled()) {
- ShowWindow(hWnd, SW_SHOW); // Show The Window
- SetForegroundWindow(hWnd); // Slightly Higher Priority
- SetFocus(hWnd); // Sets Keyboard Focus To
- }
-
- if (p_desired.layered) {
- set_window_per_pixel_transparency_enabled(true);
- }
-
- // IME
- im_himc = ImmGetContext(hWnd);
- ImmReleaseContext(hWnd, im_himc);
-
- im_position = Vector2();
-
- set_ime_active(false);
-
- if (!OS::get_singleton()->is_in_low_processor_usage_mode()) {
- //SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
- SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
- DWORD index = 0;
- HANDLE handle = AvSetMmThreadCharacteristics("Games", &index);
- if (handle)
- AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL);
-
- // This is needed to make sure that background work does not starve the main thread.
- // This is only setting priority of this thread, not the whole process.
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
- }
-
- update_real_mouse_position();
-
- return OK;
}
-void OS_Windows::set_clipboard(const String &p_text) {
-
- // Convert LF line endings to CRLF in clipboard content
- // Otherwise, line endings won't be visible when pasted in other software
- String text = p_text.replace("\n", "\r\n");
-
- if (!OpenClipboard(hWnd)) {
- ERR_FAIL_MSG("Unable to open clipboard.");
- }
- EmptyClipboard();
-
- HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * sizeof(CharType));
- ERR_FAIL_COND_MSG(mem == NULL, "Unable to allocate memory for clipboard contents.");
-
- LPWSTR lptstrCopy = (LPWSTR)GlobalLock(mem);
- memcpy(lptstrCopy, text.c_str(), (text.length() + 1) * sizeof(CharType));
- GlobalUnlock(mem);
-
- SetClipboardData(CF_UNICODETEXT, mem);
-
- // set the CF_TEXT version (not needed?)
- CharString utf8 = text.utf8();
- mem = GlobalAlloc(GMEM_MOVEABLE, utf8.length() + 1);
- ERR_FAIL_COND_MSG(mem == NULL, "Unable to allocate memory for clipboard contents.");
-
- LPTSTR ptr = (LPTSTR)GlobalLock(mem);
- memcpy(ptr, utf8.get_data(), utf8.length());
- ptr[utf8.length()] = 0;
- GlobalUnlock(mem);
-
- SetClipboardData(CF_TEXT, mem);
-
- CloseClipboard();
-};
-
-String OS_Windows::get_clipboard() const {
-
- String ret;
- if (!OpenClipboard(hWnd)) {
- ERR_FAIL_V_MSG("", "Unable to open clipboard.");
- };
-
- if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
-
- HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
- if (mem != NULL) {
-
- LPWSTR ptr = (LPWSTR)GlobalLock(mem);
- if (ptr != NULL) {
-
- ret = String((CharType *)ptr);
- GlobalUnlock(mem);
- };
- };
-
- } else if (IsClipboardFormatAvailable(CF_TEXT)) {
-
- HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
- if (mem != NULL) {
-
- LPTSTR ptr = (LPTSTR)GlobalLock(mem);
- if (ptr != NULL) {
-
- ret.parse_utf8((const char *)ptr);
- GlobalUnlock(mem);
- };
- };
- };
-
- CloseClipboard();
-
- return ret;
-};
-
void OS_Windows::delete_main_loop() {
if (main_loop)
@@ -1629,7 +225,6 @@ void OS_Windows::delete_main_loop() {
void OS_Windows::set_main_loop(MainLoop *p_main_loop) {
- input->set_main_loop(p_main_loop);
main_loop = p_main_loop;
}
@@ -1643,38 +238,6 @@ void OS_Windows::finalize() {
memdelete(main_loop);
main_loop = NULL;
-
- memdelete(joypad);
- memdelete(input);
- touch_state.clear();
-
- cursors_cache.clear();
- visual_server->finish();
- memdelete(visual_server);
-
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
-
- if (context_gles2)
- memdelete(context_gles2);
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
-
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
- }
-
- if (context_vulkan)
- memdelete(context_vulkan);
- }
-#endif
-
- if (user_proc) {
- SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
- };
}
void OS_Windows::finalize_core() {
@@ -1685,576 +248,6 @@ void OS_Windows::finalize_core() {
NetSocketPosix::cleanup();
}
-void OS_Windows::alert(const String &p_alert, const String &p_title) {
-
- if (!is_no_window_mode_enabled())
- MessageBoxW(NULL, p_alert.c_str(), p_title.c_str(), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
- else
- print_line("ALERT: " + p_alert);
-}
-
-void OS_Windows::set_mouse_mode(MouseMode p_mode) {
-
- if (mouse_mode == p_mode)
- return;
-
- _set_mouse_mode_impl(p_mode);
-
- mouse_mode = p_mode;
-}
-
-void OS_Windows::_set_mouse_mode_impl(MouseMode p_mode) {
-
- if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED) {
- RECT clipRect;
- GetClientRect(hWnd, &clipRect);
- ClientToScreen(hWnd, (POINT *)&clipRect.left);
- ClientToScreen(hWnd, (POINT *)&clipRect.right);
- ClipCursor(&clipRect);
- if (p_mode == MOUSE_MODE_CAPTURED) {
- center = Point2i(video_mode.width / 2, video_mode.height / 2);
- POINT pos = { (int)center.x, (int)center.y };
- ClientToScreen(hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
- SetCapture(hWnd);
- }
- } else {
- ReleaseCapture();
- ClipCursor(NULL);
- }
-
- if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) {
- hCursor = SetCursor(NULL);
- } else {
- CursorShape c = cursor_shape;
- cursor_shape = CURSOR_MAX;
- set_cursor_shape(c);
- }
-}
-OS_Windows::MouseMode OS_Windows::get_mouse_mode() const {
-
- return mouse_mode;
-}
-
-void OS_Windows::warp_mouse_position(const Point2 &p_to) {
-
- if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
- old_x = p_to.x;
- old_y = p_to.y;
- } else {
-
- POINT p;
- p.x = p_to.x;
- p.y = p_to.y;
- ClientToScreen(hWnd, &p);
-
- SetCursorPos(p.x, p.y);
- }
-}
-
-Point2 OS_Windows::get_mouse_position() const {
-
- return Point2(old_x, old_y);
-}
-
-void OS_Windows::update_real_mouse_position() {
-
- POINT mouse_pos;
- if (GetCursorPos(&mouse_pos) && ScreenToClient(hWnd, &mouse_pos)) {
- if (mouse_pos.x > 0 && mouse_pos.y > 0 && mouse_pos.x <= video_mode.width && mouse_pos.y <= video_mode.height) {
- old_x = mouse_pos.x;
- old_y = mouse_pos.y;
- old_invalid = false;
- input->set_mouse_position(Point2i(mouse_pos.x, mouse_pos.y));
- }
- }
-}
-
-int OS_Windows::get_mouse_button_state() const {
-
- return last_button_state;
-}
-
-void OS_Windows::set_window_title(const String &p_title) {
-
- SetWindowTextW(hWnd, p_title.c_str());
-}
-
-void OS_Windows::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
-}
-
-OS::VideoMode OS_Windows::get_video_mode(int p_screen) const {
-
- return video_mode;
-}
-void OS_Windows::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
-}
-
-static BOOL CALLBACK _MonitorEnumProcCount(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
- int *data = (int *)dwData;
- (*data)++;
- return TRUE;
-}
-
-int OS_Windows::get_screen_count() const {
-
- int data = 0;
- EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcCount, (LPARAM)&data);
- return data;
-}
-
-typedef struct {
- int count;
- int screen;
- HMONITOR monitor;
-} EnumScreenData;
-
-static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
- EnumScreenData *data = (EnumScreenData *)dwData;
- if (data->monitor == hMonitor) {
- data->screen = data->count;
- }
-
- data->count++;
- return TRUE;
-}
-
-int OS_Windows::get_current_screen() const {
-
- EnumScreenData data = { 0, 0, MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST) };
- EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&data);
- return data.screen;
-}
-
-void OS_Windows::set_current_screen(int p_screen) {
-
- Vector2 ofs = get_window_position() - get_screen_position(get_current_screen());
- set_window_position(ofs + get_screen_position(p_screen));
-}
-
-static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
- EnumPosData *data = (EnumPosData *)dwData;
- if (data->count == data->screen) {
- data->pos.x = lprcMonitor->left;
- data->pos.y = lprcMonitor->top;
- }
-
- data->count++;
- return TRUE;
-}
-
-Point2 OS_Windows::get_screen_position(int p_screen) const {
-
- EnumPosData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, Point2() };
- EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcPos, (LPARAM)&data);
- return data.pos;
-}
-
-Size2 OS_Windows::get_screen_size(int p_screen) const {
-
- EnumSizeData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, Size2() };
- EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
- return data.size;
-}
-
-typedef struct {
- int count;
- int screen;
- int dpi;
-} EnumDpiData;
-
-static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
- EnumDpiData *data = (EnumDpiData *)dwData;
- if (data->count == data->screen) {
- data->dpi = QueryDpiForMonitor(hMonitor);
- }
-
- data->count++;
- return TRUE;
-}
-
-int OS_Windows::get_screen_dpi(int p_screen) const {
-
- EnumDpiData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, 72 };
- EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcDpi, (LPARAM)&data);
- return data.dpi;
-}
-
-Point2 OS_Windows::get_window_position() const {
-
- if (minimized) {
- return last_pos;
- }
-
- RECT r;
- GetWindowRect(hWnd, &r);
- return Point2(r.left, r.top);
-}
-
-void OS_Windows::set_window_position(const Point2 &p_position) {
-
- if (video_mode.fullscreen) return;
- RECT r;
- GetWindowRect(hWnd, &r);
- MoveWindow(hWnd, p_position.x, p_position.y, r.right - r.left, r.bottom - r.top, TRUE);
-
- // Don't let the mouse leave the window when moved
- if (mouse_mode == MOUSE_MODE_CONFINED) {
- RECT rect;
- GetClientRect(hWnd, &rect);
- ClientToScreen(hWnd, (POINT *)&rect.left);
- ClientToScreen(hWnd, (POINT *)&rect.right);
- ClipCursor(&rect);
- }
-
- last_pos = p_position;
- update_real_mouse_position();
-}
-
-Size2 OS_Windows::get_window_size() const {
-
- if (minimized) {
- return Size2(video_mode.width, video_mode.height);
- }
-
- RECT r;
- if (GetClientRect(hWnd, &r)) { // Only area inside of window border
- return Size2(r.right - r.left, r.bottom - r.top);
- }
- return Size2();
-}
-
-Size2 OS_Windows::get_max_window_size() const {
- return max_size;
-}
-
-Size2 OS_Windows::get_min_window_size() const {
- return min_size;
-}
-
-void OS_Windows::set_min_window_size(const Size2 p_size) {
-
- if ((p_size != Size2()) && (max_size != Size2()) && ((p_size.x > max_size.x) || (p_size.y > max_size.y))) {
- ERR_PRINT("Minimum window size can't be larger than maximum window size!");
- return;
- }
- min_size = p_size;
-}
-
-void OS_Windows::set_max_window_size(const Size2 p_size) {
-
- if ((p_size != Size2()) && ((p_size.x < min_size.x) || (p_size.y < min_size.y))) {
- ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
- return;
- }
- max_size = p_size;
-}
-
-Size2 OS_Windows::get_real_window_size() const {
-
- RECT r;
- if (GetWindowRect(hWnd, &r)) { // Includes area of the window border
- return Size2(r.right - r.left, r.bottom - r.top);
- }
- return Size2();
-}
-
-void OS_Windows::set_window_size(const Size2 p_size) {
-
- int w = p_size.width;
- int h = p_size.height;
-
- video_mode.width = w;
- video_mode.height = h;
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- context_vulkan->window_resize(0, video_mode.width, video_mode.height);
- }
-#endif
-
- if (video_mode.fullscreen) {
- return;
- }
-
- RECT rect;
- GetWindowRect(hWnd, &rect);
-
- if (!video_mode.borderless_window) {
- RECT crect;
- GetClientRect(hWnd, &crect);
-
- w += (rect.right - rect.left) - (crect.right - crect.left);
- h += (rect.bottom - rect.top) - (crect.bottom - crect.top);
- }
-
- MoveWindow(hWnd, rect.left, rect.top, w, h, TRUE);
-
- // Don't let the mouse leave the window when resizing to a smaller resolution
- if (mouse_mode == MOUSE_MODE_CONFINED) {
- RECT crect;
- GetClientRect(hWnd, &crect);
- ClientToScreen(hWnd, (POINT *)&crect.left);
- ClientToScreen(hWnd, (POINT *)&crect.right);
- ClipCursor(&crect);
- }
-}
-void OS_Windows::set_window_fullscreen(bool p_enabled) {
-
- if (video_mode.fullscreen == p_enabled)
- return;
-
- if (layered_window)
- set_window_per_pixel_transparency_enabled(false);
-
- if (p_enabled) {
-
- was_maximized = maximized;
-
- if (pre_fs_valid) {
- GetWindowRect(hWnd, &pre_fs_rect);
- }
-
- int cs = get_current_screen();
- Point2 pos = get_screen_position(cs);
- Size2 size = get_screen_size(cs);
-
- video_mode.fullscreen = true;
-
- _update_window_style(false);
-
- MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE);
-
- } else {
-
- RECT rect;
-
- video_mode.fullscreen = false;
-
- if (pre_fs_valid) {
- rect = pre_fs_rect;
- } else {
- rect.left = 0;
- rect.right = video_mode.width;
- rect.top = 0;
- rect.bottom = video_mode.height;
- }
-
- _update_window_style(false, was_maximized);
-
- MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
-
- pre_fs_valid = true;
- }
-}
-bool OS_Windows::is_window_fullscreen() const {
-
- return video_mode.fullscreen;
-}
-void OS_Windows::set_window_resizable(bool p_enabled) {
-
- if (video_mode.resizable == p_enabled)
- return;
-
- video_mode.resizable = p_enabled;
-
- _update_window_style();
-}
-bool OS_Windows::is_window_resizable() const {
-
- return video_mode.resizable;
-}
-void OS_Windows::set_window_minimized(bool p_enabled) {
-
- if (p_enabled) {
- maximized = false;
- minimized = true;
- ShowWindow(hWnd, SW_MINIMIZE);
- } else {
- ShowWindow(hWnd, SW_RESTORE);
- maximized = false;
- minimized = false;
- }
-}
-bool OS_Windows::is_window_minimized() const {
-
- return minimized;
-}
-void OS_Windows::set_window_maximized(bool p_enabled) {
-
- if (p_enabled) {
- maximized = true;
- minimized = false;
- ShowWindow(hWnd, SW_MAXIMIZE);
- } else {
- ShowWindow(hWnd, SW_RESTORE);
- maximized = false;
- minimized = false;
- }
-}
-bool OS_Windows::is_window_maximized() const {
-
- return maximized;
-}
-
-void OS_Windows::set_window_always_on_top(bool p_enabled) {
- if (video_mode.always_on_top == p_enabled)
- return;
-
- video_mode.always_on_top = p_enabled;
-
- _update_window_style();
-}
-
-bool OS_Windows::is_window_always_on_top() const {
- return video_mode.always_on_top;
-}
-
-bool OS_Windows::is_window_focused() const {
-
- return window_focused;
-}
-
-void OS_Windows::set_console_visible(bool p_enabled) {
- if (console_visible == p_enabled)
- return;
- ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE);
- console_visible = p_enabled;
-}
-
-bool OS_Windows::is_console_visible() const {
- return console_visible;
-}
-
-bool OS_Windows::get_window_per_pixel_transparency_enabled() const {
-
- if (!is_layered_allowed()) return false;
- return layered_window;
-}
-
-void OS_Windows::set_window_per_pixel_transparency_enabled(bool p_enabled) {
-
- if (!is_layered_allowed()) return;
- if (layered_window != p_enabled) {
- if (p_enabled) {
- set_borderless_window(true);
- //enable per-pixel alpha
- hDC_dib = CreateCompatibleDC(GetDC(hWnd));
-
- SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
-
- RECT r;
- GetWindowRect(hWnd, &r);
- dib_size = Size2(r.right - r.left, r.bottom - r.top);
-
- BITMAPINFO bmi;
- ZeroMemory(&bmi, sizeof(BITMAPINFO));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = dib_size.x;
- bmi.bmiHeader.biHeight = dib_size.y;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = dib_size.x * dib_size.y * 4;
- hBitmap = CreateDIBSection(hDC_dib, &bmi, DIB_RGB_COLORS, (void **)&dib_data, NULL, 0x0);
- SelectObject(hDC_dib, hBitmap);
-
- ZeroMemory(dib_data, dib_size.x * dib_size.y * 4);
-
- layered_window = true;
- } else {
- //disable per-pixel alpha
- layered_window = false;
-
- SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
-
- //cleanup
- DeleteObject(hBitmap);
- DeleteDC(hDC_dib);
- }
- }
-}
-
-uint8_t *OS_Windows::get_layered_buffer_data() {
-
- return (is_layered_allowed() && layered_window) ? dib_data : NULL;
-}
-
-Size2 OS_Windows::get_layered_buffer_size() {
-
- return (is_layered_allowed() && layered_window) ? dib_size : Size2();
-}
-
-void OS_Windows::swap_layered_buffer() {
-
- if (is_layered_allowed() && layered_window) {
-
- //premultiply alpha
- for (int y = 0; y < dib_size.y; y++) {
- for (int x = 0; x < dib_size.x; x++) {
- float alpha = (float)dib_data[y * (int)dib_size.x * 4 + x * 4 + 3] / (float)0xFF;
- dib_data[y * (int)dib_size.x * 4 + x * 4 + 0] *= alpha;
- dib_data[y * (int)dib_size.x * 4 + x * 4 + 1] *= alpha;
- dib_data[y * (int)dib_size.x * 4 + x * 4 + 2] *= alpha;
- }
- }
- //swap layered window buffer
- POINT ptSrc = { 0, 0 };
- SIZE sizeWnd = { (long)dib_size.x, (long)dib_size.y };
- BLENDFUNCTION bf;
- bf.BlendOp = AC_SRC_OVER;
- bf.BlendFlags = 0;
- bf.AlphaFormat = AC_SRC_ALPHA;
- bf.SourceConstantAlpha = 0xFF;
- UpdateLayeredWindow(hWnd, NULL, NULL, &sizeWnd, hDC_dib, &ptSrc, 0, &bf, ULW_ALPHA);
- }
-}
-
-void OS_Windows::set_borderless_window(bool p_borderless) {
- if (video_mode.borderless_window == p_borderless)
- return;
-
- if (!p_borderless && layered_window)
- set_window_per_pixel_transparency_enabled(false);
-
- video_mode.borderless_window = p_borderless;
-
- preserve_window_size = true;
- _update_window_style();
-}
-
-bool OS_Windows::get_borderless_window() {
- return video_mode.borderless_window;
-}
-
-void OS_Windows::_update_window_style(bool p_repaint, bool p_maximized) {
- if (video_mode.fullscreen || video_mode.borderless_window) {
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE);
- } else {
- if (video_mode.resizable) {
- if (p_maximized) {
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE);
- } else {
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
- }
- } else {
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE);
- }
- }
-
- SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
-
- if (p_repaint) {
- RECT rect;
- GetWindowRect(hWnd, &rect);
- MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
- }
-}
-
Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
String path = p_path;
@@ -2306,17 +299,6 @@ Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, cons
return OK;
}
-void OS_Windows::request_attention() {
-
- FLASHWINFO info;
- info.cbSize = sizeof(FLASHWINFO);
- info.hwnd = hWnd;
- info.dwFlags = FLASHW_TRAY;
- info.dwTimeout = 0;
- info.uCount = 2;
- FlashWindowEx(&info);
-}
-
String OS_Windows::get_name() const {
return "Windows";
@@ -2448,253 +430,6 @@ uint64_t OS_Windows::get_ticks_usec() const {
return time;
}
-void OS_Windows::process_events() {
-
- MSG msg;
-
- if (!drop_events) {
- joypad->process_joypads();
- }
-
- while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
-
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
- }
-
- if (!drop_events) {
- process_key_events();
- input->flush_accumulated_events();
- }
-}
-
-void OS_Windows::set_cursor_shape(CursorShape p_shape) {
-
- ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
-
- if (cursor_shape == p_shape)
- return;
-
- if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
- cursor_shape = p_shape;
- return;
- }
-
- static const LPCTSTR win_cursors[CURSOR_MAX] = {
- IDC_ARROW,
- IDC_IBEAM,
- IDC_HAND, //finger
- IDC_CROSS,
- IDC_WAIT,
- IDC_APPSTARTING,
- IDC_ARROW,
- IDC_ARROW,
- IDC_NO,
- IDC_SIZENS,
- IDC_SIZEWE,
- IDC_SIZENESW,
- IDC_SIZENWSE,
- IDC_SIZEALL,
- IDC_SIZENS,
- IDC_SIZEWE,
- IDC_HELP
- };
-
- if (cursors[p_shape] != NULL) {
- SetCursor(cursors[p_shape]);
- } else {
- SetCursor(LoadCursor(hInstance, win_cursors[p_shape]));
- }
-
- cursor_shape = p_shape;
-}
-
-OS::CursorShape OS_Windows::get_cursor_shape() const {
-
- return cursor_shape;
-}
-
-void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
-
- if (p_cursor.is_valid()) {
-
- Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
-
- if (cursor_c) {
- if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
- set_cursor_shape(p_shape);
- return;
- }
-
- cursors_cache.erase(p_shape);
- }
-
- Ref<Texture2D> texture = p_cursor;
- Ref<AtlasTexture> atlas_texture = p_cursor;
- Ref<Image> image;
- Size2 texture_size;
- Rect2 atlas_rect;
-
- if (texture.is_valid()) {
- image = texture->get_data();
- }
-
- if (!image.is_valid() && atlas_texture.is_valid()) {
- texture = atlas_texture->get_atlas();
-
- atlas_rect.size.width = texture->get_width();
- atlas_rect.size.height = texture->get_height();
- atlas_rect.position.x = atlas_texture->get_region().position.x;
- atlas_rect.position.y = atlas_texture->get_region().position.y;
-
- texture_size.width = atlas_texture->get_region().size.x;
- texture_size.height = atlas_texture->get_region().size.y;
- } else if (image.is_valid()) {
- texture_size.width = texture->get_width();
- texture_size.height = texture->get_height();
- }
-
- ERR_FAIL_COND(!texture.is_valid());
- ERR_FAIL_COND(p_hotspot.x < 0 || p_hotspot.y < 0);
- ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256);
- ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height);
-
- image = texture->get_data();
-
- ERR_FAIL_COND(!image.is_valid());
-
- UINT image_size = texture_size.width * texture_size.height;
-
- // Create the BITMAP with alpha channel
- COLORREF *buffer = (COLORREF *)memalloc(sizeof(COLORREF) * image_size);
-
- for (UINT index = 0; index < image_size; index++) {
- int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
- int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
-
- if (atlas_texture.is_valid()) {
- column_index = MIN(column_index, atlas_rect.size.width - 1);
- row_index = MIN(row_index, atlas_rect.size.height - 1);
- }
-
- *(buffer + index) = image->get_pixel(column_index, row_index).to_argb32();
- }
-
- // Using 4 channels, so 4 * 8 bits
- HBITMAP bitmap = CreateBitmap(texture_size.width, texture_size.height, 1, 4 * 8, buffer);
- COLORREF clrTransparent = -1;
-
- // Create the AND and XOR masks for the bitmap
- HBITMAP hAndMask = NULL;
- HBITMAP hXorMask = NULL;
-
- GetMaskBitmaps(bitmap, clrTransparent, hAndMask, hXorMask);
-
- if (NULL == hAndMask || NULL == hXorMask) {
- memfree(buffer);
- DeleteObject(bitmap);
- return;
- }
-
- // Finally, create the icon
- ICONINFO iconinfo;
- iconinfo.fIcon = FALSE;
- iconinfo.xHotspot = p_hotspot.x;
- iconinfo.yHotspot = p_hotspot.y;
- iconinfo.hbmMask = hAndMask;
- iconinfo.hbmColor = hXorMask;
-
- if (cursors[p_shape])
- DestroyIcon(cursors[p_shape]);
-
- cursors[p_shape] = CreateIconIndirect(&iconinfo);
-
- Vector<Variant> params;
- params.push_back(p_cursor);
- params.push_back(p_hotspot);
- cursors_cache.insert(p_shape, params);
-
- if (p_shape == cursor_shape) {
- if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
- SetCursor(cursors[p_shape]);
- }
- }
-
- if (hAndMask != NULL) {
- DeleteObject(hAndMask);
- }
-
- if (hXorMask != NULL) {
- DeleteObject(hXorMask);
- }
-
- memfree(buffer);
- DeleteObject(bitmap);
- } else {
- // Reset to default system cursor
- if (cursors[p_shape]) {
- DestroyIcon(cursors[p_shape]);
- cursors[p_shape] = NULL;
- }
-
- CursorShape c = cursor_shape;
- cursor_shape = CURSOR_MAX;
- set_cursor_shape(c);
-
- cursors_cache.erase(p_shape);
- }
-}
-
-void OS_Windows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap) {
-
- // Get the system display DC
- HDC hDC = GetDC(NULL);
-
- // Create helper DC
- HDC hMainDC = CreateCompatibleDC(hDC);
- HDC hAndMaskDC = CreateCompatibleDC(hDC);
- HDC hXorMaskDC = CreateCompatibleDC(hDC);
-
- // Get the dimensions of the source bitmap
- BITMAP bm;
- GetObject(hSourceBitmap, sizeof(BITMAP), &bm);
-
- // Create the mask bitmaps
- hAndMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // color
- hXorMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // color
-
- // Release the system display DC
- ReleaseDC(NULL, hDC);
-
- // Select the bitmaps to helper DC
- HBITMAP hOldMainBitmap = (HBITMAP)SelectObject(hMainDC, hSourceBitmap);
- HBITMAP hOldAndMaskBitmap = (HBITMAP)SelectObject(hAndMaskDC, hAndMaskBitmap);
- HBITMAP hOldXorMaskBitmap = (HBITMAP)SelectObject(hXorMaskDC, hXorMaskBitmap);
-
- // Assign the monochrome AND mask bitmap pixels so that a pixels of the source bitmap
- // with 'clrTransparent' will be white pixels of the monochrome bitmap
- SetBkColor(hMainDC, clrTransparent);
- BitBlt(hAndMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCCOPY);
-
- // Assign the color XOR mask bitmap pixels so that a pixels of the source bitmap
- // with 'clrTransparent' will be black and rest the pixels same as corresponding
- // pixels of the source bitmap
- SetBkColor(hXorMaskDC, RGB(0, 0, 0));
- SetTextColor(hXorMaskDC, RGB(255, 255, 255));
- BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hAndMaskDC, 0, 0, SRCCOPY);
- BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCAND);
-
- // Deselect bitmaps from the helper DC
- SelectObject(hMainDC, hOldMainBitmap);
- SelectObject(hAndMaskDC, hOldAndMaskBitmap);
- SelectObject(hXorMaskDC, hOldXorMaskBitmap);
-
- // Delete the helper DC
- DeleteDC(hXorMaskDC);
- DeleteDC(hAndMaskDC);
- DeleteDC(hMainDC);
-}
-
Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
if (p_blocking && r_pipe) {
@@ -2812,151 +547,6 @@ String OS_Windows::get_executable_path() const {
return s;
}
-void OS_Windows::set_native_icon(const String &p_filename) {
-
- FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
- ERR_FAIL_COND_MSG(!f, "Cannot open file with icon '" + p_filename + "'.");
-
- ICONDIR *icon_dir = (ICONDIR *)memalloc(sizeof(ICONDIR));
- int pos = 0;
-
- icon_dir->idReserved = f->get_32();
- pos += sizeof(WORD);
- f->seek(pos);
-
- icon_dir->idType = f->get_32();
- pos += sizeof(WORD);
- f->seek(pos);
-
- ERR_FAIL_COND_MSG(icon_dir->idType != 1, "Invalid icon file format!");
-
- icon_dir->idCount = f->get_32();
- pos += sizeof(WORD);
- f->seek(pos);
-
- icon_dir = (ICONDIR *)memrealloc(icon_dir, 3 * sizeof(WORD) + icon_dir->idCount * sizeof(ICONDIRENTRY));
- f->get_buffer((uint8_t *)&icon_dir->idEntries[0], icon_dir->idCount * sizeof(ICONDIRENTRY));
-
- int small_icon_index = -1; // Select 16x16 with largest color count
- int small_icon_cc = 0;
- int big_icon_index = -1; // Select largest
- int big_icon_width = 16;
- int big_icon_cc = 0;
-
- for (int i = 0; i < icon_dir->idCount; i++) {
- int colors = (icon_dir->idEntries[i].bColorCount == 0) ? 32768 : icon_dir->idEntries[i].bColorCount;
- int width = (icon_dir->idEntries[i].bWidth == 0) ? 256 : icon_dir->idEntries[i].bWidth;
- if (width == 16) {
- if (colors >= small_icon_cc) {
- small_icon_index = i;
- small_icon_cc = colors;
- }
- }
- if (width >= big_icon_width) {
- if (colors >= big_icon_cc) {
- big_icon_index = i;
- big_icon_width = width;
- big_icon_cc = colors;
- }
- }
- }
-
- ERR_FAIL_COND_MSG(big_icon_index == -1, "No valid icons found!");
-
- if (small_icon_index == -1) {
- WARN_PRINT("No small icon found, reusing " + itos(big_icon_width) + "x" + itos(big_icon_width) + " @" + itos(big_icon_cc) + " icon!");
- small_icon_index = big_icon_index;
- small_icon_cc = big_icon_cc;
- }
-
- // Read the big icon
- DWORD bytecount_big = icon_dir->idEntries[big_icon_index].dwBytesInRes;
- Vector<uint8_t> data_big;
- data_big.resize(bytecount_big);
- pos = icon_dir->idEntries[big_icon_index].dwImageOffset;
- f->seek(pos);
- f->get_buffer((uint8_t *)&data_big.write[0], bytecount_big);
- HICON icon_big = CreateIconFromResource((PBYTE)&data_big.write[0], bytecount_big, TRUE, 0x00030000);
- ERR_FAIL_COND_MSG(!icon_big, "Could not create " + itos(big_icon_width) + "x" + itos(big_icon_width) + " @" + itos(big_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
-
- // Read the small icon
- DWORD bytecount_small = icon_dir->idEntries[small_icon_index].dwBytesInRes;
- Vector<uint8_t> data_small;
- data_small.resize(bytecount_small);
- pos = icon_dir->idEntries[small_icon_index].dwImageOffset;
- f->seek(pos);
- f->get_buffer((uint8_t *)&data_small.write[0], bytecount_small);
- HICON icon_small = CreateIconFromResource((PBYTE)&data_small.write[0], bytecount_small, TRUE, 0x00030000);
- ERR_FAIL_COND_MSG(!icon_small, "Could not create 16x16 @" + itos(small_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
-
- // Online tradition says to be sure last error is cleared and set the small icon first
- int err = 0;
- SetLastError(err);
-
- SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon_small);
- err = GetLastError();
- ERR_FAIL_COND_MSG(err, "Error setting ICON_SMALL: " + format_error_message(err) + ".");
-
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon_big);
- err = GetLastError();
- ERR_FAIL_COND_MSG(err, "Error setting ICON_BIG: " + format_error_message(err) + ".");
-
- memdelete(f);
- memdelete(icon_dir);
-}
-
-void OS_Windows::set_icon(const Ref<Image> &p_icon) {
-
- ERR_FAIL_COND(!p_icon.is_valid());
- Ref<Image> icon = p_icon->duplicate();
- if (icon->get_format() != Image::FORMAT_RGBA8)
- icon->convert(Image::FORMAT_RGBA8);
- int w = icon->get_width();
- int h = icon->get_height();
-
- /* Create temporary bitmap buffer */
- int icon_len = 40 + h * w * 4;
- Vector<BYTE> v;
- v.resize(icon_len);
- BYTE *icon_bmp = v.ptrw();
-
- encode_uint32(40, &icon_bmp[0]);
- encode_uint32(w, &icon_bmp[4]);
- encode_uint32(h * 2, &icon_bmp[8]);
- encode_uint16(1, &icon_bmp[12]);
- encode_uint16(32, &icon_bmp[14]);
- encode_uint32(BI_RGB, &icon_bmp[16]);
- encode_uint32(w * h * 4, &icon_bmp[20]);
- encode_uint32(0, &icon_bmp[24]);
- encode_uint32(0, &icon_bmp[28]);
- encode_uint32(0, &icon_bmp[32]);
- encode_uint32(0, &icon_bmp[36]);
-
- uint8_t *wr = &icon_bmp[40];
- const uint8_t *r = icon->get_data().ptr();
-
- for (int i = 0; i < h; i++) {
-
- for (int j = 0; j < w; j++) {
-
- const uint8_t *rpx = &r[((h - i - 1) * w + j) * 4];
- uint8_t *wpx = &wr[(i * w + j) * 4];
- wpx[0] = rpx[2];
- wpx[1] = rpx[1];
- wpx[2] = rpx[0];
- wpx[3] = rpx[3];
- }
- }
-
- HICON hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
-
- /* Set the icon for the window */
- SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon);
-
- /* Set the icon in the task manager (should we do this?) */
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hicon);
-}
-
bool OS_Windows::has_environment(const String &p_var) const {
#ifdef MINGW_ENABLED
@@ -2996,16 +586,6 @@ String OS_Windows::get_stdin_string(bool p_block) {
return String();
}
-void OS_Windows::enable_for_stealing_focus(ProcessID pid) {
-
- AllowSetForegroundWindow(pid);
-}
-
-void OS_Windows::move_window_to_foreground() {
-
- SetForegroundWindow(hWnd);
-}
-
Error OS_Windows::shell_open(String p_uri) {
ShellExecuteW(NULL, NULL, p_uri.c_str(), NULL, NULL, SW_SHOWNORMAL);
@@ -3068,101 +648,6 @@ int OS_Windows::get_processor_count() const {
return sysinfo.dwNumberOfProcessors;
}
-OS::LatinKeyboardVariant OS_Windows::get_latin_keyboard_variant() const {
-
- unsigned long azerty[] = {
- 0x00020401, // Arabic (102) AZERTY
- 0x0001080c, // Belgian (Comma)
- 0x0000080c, // Belgian French
- 0x0000040c, // French
- 0 // <--- STOP MARK
- };
- unsigned long qwertz[] = {
- 0x0000041a, // Croation
- 0x00000405, // Czech
- 0x00000407, // German
- 0x00010407, // German (IBM)
- 0x0000040e, // Hungarian
- 0x0000046e, // Luxembourgish
- 0x00010415, // Polish (214)
- 0x00000418, // Romanian (Legacy)
- 0x0000081a, // Serbian (Latin)
- 0x0000041b, // Slovak
- 0x00000424, // Slovenian
- 0x0001042e, // Sorbian Extended
- 0x0002042e, // Sorbian Standard
- 0x0000042e, // Sorbian Standard (Legacy)
- 0x0000100c, // Swiss French
- 0x00000807, // Swiss German
- 0 // <--- STOP MARK
- };
- unsigned long dvorak[] = {
- 0x00010409, // US-Dvorak
- 0x00030409, // US-Dvorak for left hand
- 0x00040409, // US-Dvorak for right hand
- 0 // <--- STOP MARK
- };
-
- char name[KL_NAMELENGTH + 1];
- name[0] = 0;
- GetKeyboardLayoutNameA(name);
-
- unsigned long hex = strtoul(name, NULL, 16);
-
- int i = 0;
- while (azerty[i] != 0) {
- if (azerty[i] == hex) return LATIN_KEYBOARD_AZERTY;
- i++;
- }
-
- i = 0;
- while (qwertz[i] != 0) {
- if (qwertz[i] == hex) return LATIN_KEYBOARD_QWERTZ;
- i++;
- }
-
- i = 0;
- while (dvorak[i] != 0) {
- if (dvorak[i] == hex) return LATIN_KEYBOARD_DVORAK;
- i++;
- }
-
- return LATIN_KEYBOARD_QWERTY;
-}
-
-void OS_Windows::release_rendering_thread() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->release_current();
- }
-#endif
-}
-
-void OS_Windows::make_rendering_thread() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->make_current();
- }
-#endif
-}
-
-void OS_Windows::swap_buffers() {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2->swap_buffers();
- }
-#endif
-#if defined(VULKAN_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_VULKAN) {
- context_vulkan->swap_buffers();
- }
-#endif
-}
-
-void OS_Windows::force_process_input() {
- process_events(); // get rid of pending events
-}
-
void OS_Windows::run() {
if (!main_loop)
@@ -3172,7 +657,7 @@ void OS_Windows::run() {
while (!force_quit) {
- process_events(); // get rid of pending events
+ DisplayServer::get_singleton()->process_events(); // get rid of pending events
if (Main::iteration())
break;
};
@@ -3287,50 +772,6 @@ String OS_Windows::get_unique_id() const {
return String(HwProfInfo.szHwProfileGuid);
}
-void OS_Windows::set_ime_active(const bool p_active) {
-
- if (p_active) {
- ImmAssociateContext(hWnd, im_himc);
-
- set_ime_position(im_position);
- } else {
- ImmAssociateContext(hWnd, (HIMC)0);
- }
-}
-
-void OS_Windows::set_ime_position(const Point2 &p_pos) {
-
- im_position = p_pos;
-
- HIMC himc = ImmGetContext(hWnd);
- if (himc == (HIMC)0)
- return;
-
- COMPOSITIONFORM cps;
- cps.dwStyle = CFS_FORCE_POSITION;
- cps.ptCurrentPos.x = im_position.x;
- cps.ptCurrentPos.y = im_position.y;
- ImmSetCompositionWindow(himc, &cps);
- ImmReleaseContext(hWnd, himc);
-}
-
-bool OS_Windows::is_joy_known(int p_device) {
- return input->is_joy_mapped(p_device);
-}
-
-String OS_Windows::get_joy_guid(int p_device) const {
- return input->get_joy_guid_remapped(p_device);
-}
-
-void OS_Windows::_set_use_vsync(bool p_enable) {
-#if defined(OPENGL_ENABLED)
- if (video_driver_index == VIDEO_DRIVER_GLES2) {
- if (context_gles2)
- context_gles2->set_use_vsync(p_enable);
- }
-#endif
-}
-
bool OS_Windows::_check_internal_feature_support(const String &p_feature) {
return p_feature == "pc";
@@ -3344,20 +785,13 @@ bool OS_Windows::is_disable_crash_handler() const {
return crash_handler.is_disabled();
}
-void OS_Windows::process_and_drop_events() {
-
- drop_events = true;
- process_events();
- drop_events = false;
-}
-
Error OS_Windows::move_to_trash(const String &p_path) {
SHFILEOPSTRUCTW sf;
WCHAR *from = new WCHAR[p_path.length() + 2];
wcscpy_s(from, p_path.length() + 1, p_path.c_str());
from[p_path.length() + 1] = 0;
- sf.hwnd = hWnd;
+ sf.hwnd = main_window;
sf.wFunc = FO_DELETE;
sf.pFrom = from;
sf.pTo = NULL;
@@ -3379,36 +813,12 @@ Error OS_Windows::move_to_trash(const String &p_path) {
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
- drop_events = false;
- key_event_pos = 0;
- layered_window = false;
- hBitmap = NULL;
force_quit = false;
- alt_mem = false;
- gr_mem = false;
- shift_mem = false;
- control_mem = false;
- meta_mem = false;
- minimized = false;
- was_maximized = false;
- window_focused = true;
- console_visible = IsWindowVisible(GetConsoleWindow());
-
- //Note: Functions for pen input, available on Windows 8+
- HMODULE user32_lib = LoadLibraryW(L"user32.dll");
- if (user32_lib) {
- win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
- win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
- }
hInstance = _hInstance;
- pressrc = 0;
- old_invalid = true;
- mouse_mode = MOUSE_MODE_VISIBLE;
#ifdef STDOUT_FILE
stdo = fopen("stdout.txt", "wb");
#endif
- user_proc = NULL;
#ifdef WASAPI_ENABLED
AudioDriverManager::add_driver(&driver_wasapi);
@@ -3417,16 +827,14 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
AudioDriverManager::add_driver(&driver_xaudio2);
#endif
+ DisplayServerWindows::register_windows_driver();
+
Vector<Logger *> loggers;
loggers.push_back(memnew(WindowsTerminalLogger));
_set_logger(memnew(CompositeLogger(loggers)));
}
OS_Windows::~OS_Windows() {
- if (is_layered_allowed() && layered_window) {
- DeleteObject(hBitmap);
- DeleteDC(hDC_dib);
- }
#ifdef STDOUT_FILE
fclose(stdo);
#endif
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 8506aa7b20..29280eb17c 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -31,7 +31,7 @@
#ifndef OS_WINDOWS_H
#define OS_WINDOWS_H
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "crash_handler_windows.h"
@@ -39,10 +39,9 @@
#include "drivers/wasapi/audio_driver_wasapi.h"
#include "drivers/winmidi/midi_driver_winmidi.h"
#include "key_mapping_windows.h"
-#include "main/input_default.h"
#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
#ifdef XAUDIO2_ENABLED
#include "drivers/xaudio2/audio_driver_xaudio2.h"
#endif
@@ -62,183 +61,19 @@
#include <windows.h>
#include <windowsx.h>
-#ifndef POINTER_STRUCTURES
-
-#define POINTER_STRUCTURES
-
-typedef DWORD POINTER_INPUT_TYPE;
-typedef UINT32 POINTER_FLAGS;
-typedef UINT32 PEN_FLAGS;
-typedef UINT32 PEN_MASK;
-
-enum tagPOINTER_INPUT_TYPE {
- PT_POINTER = 0x00000001,
- PT_TOUCH = 0x00000002,
- PT_PEN = 0x00000003,
- PT_MOUSE = 0x00000004,
- PT_TOUCHPAD = 0x00000005
-};
-
-typedef enum tagPOINTER_BUTTON_CHANGE_TYPE {
- POINTER_CHANGE_NONE,
- POINTER_CHANGE_FIRSTBUTTON_DOWN,
- POINTER_CHANGE_FIRSTBUTTON_UP,
- POINTER_CHANGE_SECONDBUTTON_DOWN,
- POINTER_CHANGE_SECONDBUTTON_UP,
- POINTER_CHANGE_THIRDBUTTON_DOWN,
- POINTER_CHANGE_THIRDBUTTON_UP,
- POINTER_CHANGE_FOURTHBUTTON_DOWN,
- POINTER_CHANGE_FOURTHBUTTON_UP,
- POINTER_CHANGE_FIFTHBUTTON_DOWN,
- POINTER_CHANGE_FIFTHBUTTON_UP,
-} POINTER_BUTTON_CHANGE_TYPE;
-
-typedef struct tagPOINTER_INFO {
- POINTER_INPUT_TYPE pointerType;
- UINT32 pointerId;
- UINT32 frameId;
- POINTER_FLAGS pointerFlags;
- HANDLE sourceDevice;
- HWND hwndTarget;
- POINT ptPixelLocation;
- POINT ptHimetricLocation;
- POINT ptPixelLocationRaw;
- POINT ptHimetricLocationRaw;
- DWORD dwTime;
- UINT32 historyCount;
- INT32 InputData;
- DWORD dwKeyStates;
- UINT64 PerformanceCount;
- POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
-} POINTER_INFO;
-
-typedef struct tagPOINTER_PEN_INFO {
- POINTER_INFO pointerInfo;
- PEN_FLAGS penFlags;
- PEN_MASK penMask;
- UINT32 pressure;
- UINT32 rotation;
- INT32 tiltX;
- INT32 tiltY;
-} POINTER_PEN_INFO;
-
-#endif
-
-typedef BOOL(WINAPI *GetPointerTypePtr)(uint32_t p_id, POINTER_INPUT_TYPE *p_type);
-typedef BOOL(WINAPI *GetPointerPenInfoPtr)(uint32_t p_id, POINTER_PEN_INFO *p_pen_info);
-
-typedef struct {
- BYTE bWidth; // Width, in pixels, of the image
- BYTE bHeight; // Height, in pixels, of the image
- BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
- BYTE bReserved; // Reserved ( must be 0)
- WORD wPlanes; // Color Planes
- WORD wBitCount; // Bits per pixel
- DWORD dwBytesInRes; // How many bytes in this resource?
- DWORD dwImageOffset; // Where in the file is this image?
-} ICONDIRENTRY, *LPICONDIRENTRY;
-
-typedef struct {
- WORD idReserved; // Reserved (must be 0)
- WORD idType; // Resource Type (1 for icons)
- WORD idCount; // How many images?
- ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
-} ICONDIR, *LPICONDIR;
-
class JoypadWindows;
class OS_Windows : public OS {
- static GetPointerTypePtr win8p_GetPointerType;
- static GetPointerPenInfoPtr win8p_GetPointerPenInfo;
-
- enum {
- KEY_EVENT_BUFFER_SIZE = 512
- };
-
#ifdef STDOUT_FILE
FILE *stdo;
#endif
- struct KeyEvent {
-
- bool alt, shift, control, meta;
- UINT uMsg;
- WPARAM wParam;
- LPARAM lParam;
- };
-
- KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE];
- int key_event_pos;
-
uint64_t ticks_start;
uint64_t ticks_per_second;
- bool old_invalid;
- bool outside;
- int old_x, old_y;
- Point2i center;
-
-#if defined(OPENGL_ENABLED)
- ContextGL_Windows *context_gles2;
-#endif
-
-#if defined(VULKAN_ENABLED)
- VulkanContextWindows *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
-#endif
-
- VisualServer *visual_server;
- int pressrc;
- HINSTANCE hInstance; // Holds The Instance Of The Application
- HWND hWnd;
- Point2 last_pos;
-
- HBITMAP hBitmap; //DIB section for layered window
- uint8_t *dib_data;
- Size2 dib_size;
- HDC hDC_dib;
- bool layered_window;
-
- uint32_t move_timer_id;
-
- HCURSOR hCursor;
-
- Size2 min_size;
- Size2 max_size;
-
- Size2 window_rect;
- VideoMode video_mode;
- bool preserve_window_size = false;
-
+ HINSTANCE hInstance;
MainLoop *main_loop;
- WNDPROC user_proc;
-
- // IME
- HIMC im_himc;
- Vector2 im_position;
-
- MouseMode mouse_mode;
- bool alt_mem;
- bool gr_mem;
- bool shift_mem;
- bool control_mem;
- bool meta_mem;
- bool force_quit;
- bool window_has_focus;
- uint32_t last_button_state;
- bool use_raw_input;
- bool drop_events;
-
- HCURSOR cursors[CURSOR_MAX] = { NULL };
- CursorShape cursor_shape;
- Map<CursorShape, Vector<Variant>> cursors_cache;
-
- InputDefault *input;
- JoypadWindows *joypad;
- Map<int, Vector2> touch_state;
-
- int video_driver_index;
#ifdef WASAPI_ENABLED
AudioDriverWASAPI driver_wasapi;
#endif
@@ -251,28 +86,19 @@ class OS_Windows : public OS {
CrashHandler crash_handler;
- void _drag_event(float p_x, float p_y, int idx);
- void _touch_event(bool p_pressed, float p_x, float p_y, int idx);
-
- void _update_window_style(bool p_repaint = true, bool p_maximized = false);
-
- void _set_mouse_mode_impl(MouseMode p_mode);
+ bool force_quit;
+ HWND main_window;
// functions used by main to initialize/deinitialize the OS
protected:
- virtual int get_current_video_driver() const;
-
- virtual void initialize_core();
- virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
+ virtual void initialize();
virtual void set_main_loop(MainLoop *p_main_loop);
virtual void delete_main_loop();
virtual void finalize();
virtual void finalize_core();
-
- void process_events();
- void process_key_events();
+ virtual String get_stdin_string(bool p_block);
struct ProcessInfo {
@@ -281,75 +107,7 @@ protected:
};
Map<ProcessID, ProcessInfo> *process_map;
- bool pre_fs_valid;
- RECT pre_fs_rect;
- bool maximized;
- bool minimized;
- bool borderless;
- bool window_focused;
- bool console_visible;
- bool was_maximized;
-
public:
- LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
- virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
- String get_stdin_string(bool p_block);
-
- void set_mouse_mode(MouseMode p_mode);
- MouseMode get_mouse_mode() const;
-
- virtual void warp_mouse_position(const Point2 &p_to);
- virtual Point2 get_mouse_position() const;
- void update_real_mouse_position();
- virtual int get_mouse_button_state() const;
- virtual void set_window_title(const String &p_title);
-
- virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
- virtual VideoMode get_video_mode(int p_screen = 0) const;
- virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
-
- virtual int get_screen_count() const;
- virtual int get_current_screen() const;
- virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = -1) const;
- virtual Size2 get_screen_size(int p_screen = -1) const;
- virtual int get_screen_dpi(int p_screen = -1) const;
-
- virtual Point2 get_window_position() const;
- virtual void set_window_position(const Point2 &p_position);
- virtual Size2 get_window_size() const;
- virtual Size2 get_real_window_size() const;
- virtual Size2 get_max_window_size() const;
- virtual Size2 get_min_window_size() const;
- virtual void set_min_window_size(const Size2 p_size);
- virtual void set_max_window_size(const Size2 p_size);
- virtual void set_window_size(const Size2 p_size);
- virtual void set_window_fullscreen(bool p_enabled);
- virtual bool is_window_fullscreen() const;
- virtual void set_window_resizable(bool p_enabled);
- virtual bool is_window_resizable() const;
- virtual void set_window_minimized(bool p_enabled);
- virtual bool is_window_minimized() const;
- virtual void set_window_maximized(bool p_enabled);
- virtual bool is_window_maximized() const;
- virtual void set_window_always_on_top(bool p_enabled);
- virtual bool is_window_always_on_top() const;
- virtual bool is_window_focused() const;
- virtual void set_console_visible(bool p_enabled);
- virtual bool is_console_visible() const;
- virtual void request_attention();
-
- virtual void set_borderless_window(bool p_borderless);
- virtual bool get_borderless_window();
-
- virtual bool get_window_per_pixel_transparency_enabled() const;
- virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
-
- virtual uint8_t *get_layered_buffer_data();
- virtual Size2 get_layered_buffer_size();
- virtual void swap_layered_buffer();
-
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
virtual Error close_dynamic_library(void *p_library_handle);
virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
@@ -358,6 +116,8 @@ public:
virtual String get_name() const;
+ virtual void initialize_joypads() {}
+
virtual Date get_date(bool utc) const;
virtual Time get_time(bool utc) const;
virtual TimeZoneInfo get_time_zone_info() const;
@@ -365,7 +125,6 @@ public:
virtual uint64_t get_system_time_secs() const;
virtual uint64_t get_system_time_msecs() const;
- virtual bool can_draw() const;
virtual Error set_cwd(const String &p_cwd);
virtual void delay_usec(uint32_t p_usec) const;
@@ -379,28 +138,12 @@ public:
virtual String get_environment(const String &p_var) const;
virtual bool set_environment(const String &p_var, const String &p_value) const;
- virtual void set_clipboard(const String &p_text);
- virtual String get_clipboard() const;
-
- void set_cursor_shape(CursorShape p_shape);
- CursorShape get_cursor_shape() const;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
- void GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap);
-
- void set_native_icon(const String &p_filename);
- void set_icon(const Ref<Image> &p_icon);
-
virtual String get_executable_path() const;
virtual String get_locale() const;
virtual int get_processor_count() const;
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
-
- virtual void enable_for_stealing_focus(ProcessID pid);
- virtual void move_window_to_foreground();
-
virtual String get_config_path() const;
virtual String get_data_path() const;
virtual String get_cache_path() const;
@@ -411,37 +154,21 @@ public:
virtual String get_unique_id() const;
- virtual void set_ime_active(const bool p_active);
- virtual void set_ime_position(const Point2 &p_pos);
-
- virtual void release_rendering_thread();
- virtual void make_rendering_thread();
- virtual void swap_buffers();
-
virtual Error shell_open(String p_uri);
void run();
- virtual bool get_swap_ok_cancel() { return true; }
-
- virtual bool is_joy_known(int p_device);
- virtual String get_joy_guid(int p_device) const;
-
- virtual void _set_use_vsync(bool p_enable);
- //virtual bool is_vsync_enabled() const;
-
virtual bool _check_internal_feature_support(const String &p_feature);
void disable_crash_handler();
bool is_disable_crash_handler() const;
virtual void initialize_debugging();
- void force_process_input();
-
virtual Error move_to_trash(const String &p_path);
- virtual void process_and_drop_events();
+ void set_main_window(HWND p_main_window) { main_window = p_main_window; }
+ HINSTANCE get_hinstance() { return hInstance; }
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();
};
diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp
index 20e1b46682..66b5cf8113 100644
--- a/platform/windows/vulkan_context_win.cpp
+++ b/platform/windows/vulkan_context_win.cpp
@@ -35,7 +35,7 @@ const char *VulkanContextWindows::_get_platform_surface_extension() const {
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
}
-int VulkanContextWindows::window_create(HWND p_window, HINSTANCE p_instance, int p_width, int p_height) {
+int VulkanContextWindows::window_create(DisplayServer::WindowID p_window_id, HWND p_window, HINSTANCE p_instance, int p_width, int p_height) {
VkWin32SurfaceCreateInfoKHR createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
@@ -47,7 +47,7 @@ int VulkanContextWindows::window_create(HWND p_window, HINSTANCE p_instance, int
VkSurfaceKHR surface;
VkResult err = vkCreateWin32SurfaceKHR(_get_instance(), &createInfo, NULL, &surface);
ERR_FAIL_COND_V(err, -1);
- return _window_create(surface, p_width, p_height);
+ return _window_create(p_window_id, surface, p_width, p_height);
}
VulkanContextWindows::VulkanContextWindows() {
diff --git a/platform/windows/vulkan_context_win.h b/platform/windows/vulkan_context_win.h
index 1289f2a299..c9fea9369b 100644
--- a/platform/windows/vulkan_context_win.h
+++ b/platform/windows/vulkan_context_win.h
@@ -39,7 +39,7 @@ class VulkanContextWindows : public VulkanContext {
virtual const char *_get_platform_surface_extension() const;
public:
- int window_create(HWND p_window, HINSTANCE p_instance, int p_width, int p_height);
+ int window_create(DisplayServer::WindowID p_window_id, HWND p_window, HINSTANCE p_instance, int p_width, int p_height);
VulkanContextWindows();
~VulkanContextWindows();
diff --git a/platform/x11/SCsub b/platform/x11/SCsub
deleted file mode 100644
index 2268e4cc3d..0000000000
--- a/platform/x11/SCsub
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-
-from platform_methods import run_in_subprocess
-import platform_x11_builders
-
-common_x11 = [
- "context_gl_x11.cpp",
- "vulkan_context_x11.cpp",
- "crash_handler_x11.cpp",
- "os_x11.cpp",
- "key_mapping_x11.cpp",
- "joypad_linux.cpp",
- "detect_prime.cpp"
-]
-
-prog = env.add_program('#bin/godot', ['godot_x11.cpp'] + common_x11)
-
-if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]:
- env.AddPostAction(prog, run_in_subprocess(platform_x11_builders.make_debug_x11))
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
deleted file mode 100644
index 997a6cc053..0000000000
--- a/platform/x11/os_x11.h
+++ /dev/null
@@ -1,339 +0,0 @@
-/*************************************************************************/
-/* os_x11.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef OS_X11_H
-#define OS_X11_H
-
-#include "core/os/input.h"
-#include "crash_handler_x11.h"
-#include "drivers/alsa/audio_driver_alsa.h"
-#include "drivers/alsamidi/midi_driver_alsamidi.h"
-#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
-#include "drivers/unix/os_unix.h"
-#include "joypad_linux.h"
-#include "main/input_default.h"
-#include "servers/audio_server.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
-
-#if defined(OPENGL_ENABLED)
-#include "context_gl_x11.h"
-#endif
-
-#if defined(VULKAN_ENABLED)
-#include "drivers/vulkan/rendering_device_vulkan.h"
-#include "platform/x11/vulkan_context_x11.h"
-#endif
-
-#include <X11/Xcursor/Xcursor.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/XInput2.h>
-#include <X11/extensions/Xrandr.h>
-#include <X11/keysym.h>
-
-// Hints for X11 fullscreen
-typedef struct {
- unsigned long flags;
- unsigned long functions;
- unsigned long decorations;
- long inputMode;
- unsigned long status;
-} Hints;
-
-typedef struct _xrr_monitor_info {
- Atom name;
- Bool primary;
- Bool automatic;
- int noutput;
- int x;
- int y;
- int width;
- int height;
- int mwidth;
- int mheight;
- RROutput *outputs;
-} xrr_monitor_info;
-
-#undef CursorShape
-
-class OS_X11 : public OS_Unix {
-
- Atom wm_delete;
- Atom xdnd_enter;
- Atom xdnd_position;
- Atom xdnd_status;
- Atom xdnd_action_copy;
- Atom xdnd_drop;
- Atom xdnd_finished;
- Atom xdnd_selection;
- Atom requested;
-
- int xdnd_version;
-
-#if defined(OPENGL_ENABLED)
- ContextGL_X11 *context_gles2;
-#endif
-#if defined(VULKAN_ENABLED)
- VulkanContextX11 *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
-#endif
-
- //Rasterizer *rasterizer;
- VisualServer *visual_server;
- VideoMode current_videomode;
- List<String> args;
- Window x11_window;
- Window xdnd_source_window;
- MainLoop *main_loop;
- ::Display *x11_display;
- char *xmbstring;
- int xmblen;
- unsigned long last_timestamp;
- ::Time last_keyrelease_time;
- ::XIC xic;
- ::XIM xim;
- ::XIMStyle xim_style;
- static void xim_destroy_callback(::XIM im, ::XPointer client_data,
- ::XPointer call_data);
-
- // IME
- bool im_active;
- Vector2 im_position;
- Vector2 last_position_before_fs;
-
- Size2 min_size;
- Size2 max_size;
-
- Point2 last_mouse_pos;
- bool last_mouse_pos_valid;
- Point2i last_click_pos;
- uint64_t last_click_ms;
- int last_click_button_index;
- uint32_t last_button_state;
-
- struct {
- int opcode;
- Vector<int> touch_devices;
- Map<int, Vector2> absolute_devices;
- Map<int, Vector3> pen_devices;
- XIEventMask all_event_mask;
- XIEventMask all_master_event_mask;
- Map<int, Vector2> state;
- double pressure;
- Vector2 tilt;
- Vector2 mouse_pos_to_filter;
- Vector2 relative_motion;
- Vector2 raw_pos;
- Vector2 old_raw_pos;
- ::Time last_relative_time;
- } xi;
-
- bool refresh_device_info();
-
- unsigned int get_mouse_button_state(unsigned int p_x11_button, int p_x11_type);
- void get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state);
- void flush_mouse_motion();
-
- MouseMode mouse_mode;
- Point2i center;
-
- void handle_key_event(XKeyEvent *p_event, bool p_echo = false);
- void process_xevents();
- virtual void delete_main_loop();
-
- bool force_quit;
- bool minimized;
- bool window_has_focus;
- bool do_mouse_warp;
-
- const char *cursor_theme;
- int cursor_size;
- XcursorImage *img[CURSOR_MAX];
- Cursor cursors[CURSOR_MAX];
- Cursor null_cursor;
- CursorShape current_cursor;
- Map<CursorShape, Vector<Variant>> cursors_cache;
-
- InputDefault *input;
-
-#ifdef JOYDEV_ENABLED
- JoypadLinux *joypad;
-#endif
-
-#ifdef ALSA_ENABLED
- AudioDriverALSA driver_alsa;
-#endif
-
-#ifdef ALSAMIDI_ENABLED
- MIDIDriverALSAMidi driver_alsamidi;
-#endif
-
-#ifdef PULSEAUDIO_ENABLED
- AudioDriverPulseAudio driver_pulseaudio;
-#endif
-
- bool layered_window;
-
- CrashHandler crash_handler;
-
- int video_driver_index;
- bool maximized;
- bool window_focused;
- //void set_wm_border(bool p_enabled);
- void set_wm_fullscreen(bool p_enabled);
- void set_wm_above(bool p_enabled);
-
- typedef xrr_monitor_info *(*xrr_get_monitors_t)(Display *dpy, Window window, Bool get_active, int *nmonitors);
- typedef void (*xrr_free_monitors_t)(xrr_monitor_info *monitors);
- xrr_get_monitors_t xrr_get_monitors;
- xrr_free_monitors_t xrr_free_monitors;
- void *xrandr_handle;
- Bool xrandr_ext_ok;
-
-protected:
- virtual int get_current_video_driver() const;
-
- virtual void initialize_core();
- virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
- virtual void finalize();
-
- virtual void set_main_loop(MainLoop *p_main_loop);
-
- void _window_changed(XEvent *event);
-
- bool is_window_maximize_allowed();
-
-public:
- virtual String get_name() const;
-
- virtual void set_cursor_shape(CursorShape p_shape);
- virtual CursorShape get_cursor_shape() const;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
-
- void set_mouse_mode(MouseMode p_mode);
- MouseMode get_mouse_mode() const;
-
- virtual void warp_mouse_position(const Point2 &p_to);
- virtual Point2 get_mouse_position() const;
- virtual int get_mouse_button_state() const;
- virtual void set_window_title(const String &p_title);
-
- virtual void set_icon(const Ref<Image> &p_icon);
-
- virtual MainLoop *get_main_loop() const;
-
- virtual bool can_draw() const;
-
- virtual void set_clipboard(const String &p_text);
- virtual String get_clipboard() const;
-
- virtual void release_rendering_thread();
- virtual void make_rendering_thread();
- virtual void swap_buffers();
-
- virtual String get_config_path() const;
- virtual String get_data_path() const;
- virtual String get_cache_path() const;
-
- virtual String get_system_dir(SystemDir p_dir) const;
-
- virtual Error shell_open(String p_uri);
-
- virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
- virtual VideoMode get_video_mode(int p_screen = 0) const;
- virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
-
- virtual int get_screen_count() const;
- virtual int get_current_screen() const;
- virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = -1) const;
- virtual Size2 get_screen_size(int p_screen = -1) const;
- virtual int get_screen_dpi(int p_screen = -1) const;
- virtual Point2 get_window_position() const;
- virtual void set_window_position(const Point2 &p_position);
- virtual Size2 get_window_size() const;
- virtual Size2 get_real_window_size() const;
- virtual Size2 get_max_window_size() const;
- virtual Size2 get_min_window_size() const;
- virtual void set_min_window_size(const Size2 p_size);
- virtual void set_max_window_size(const Size2 p_size);
- virtual void set_window_size(const Size2 p_size);
- virtual void set_window_fullscreen(bool p_enabled);
- virtual bool is_window_fullscreen() const;
- virtual void set_window_resizable(bool p_enabled);
- virtual bool is_window_resizable() const;
- virtual void set_window_minimized(bool p_enabled);
- virtual bool is_window_minimized() const;
- virtual void set_window_maximized(bool p_enabled);
- virtual bool is_window_maximized() const;
- virtual void set_window_always_on_top(bool p_enabled);
- virtual bool is_window_always_on_top() const;
- virtual bool is_window_focused() const;
- virtual void request_attention();
-
- virtual void set_borderless_window(bool p_borderless);
- virtual bool get_borderless_window();
-
- virtual bool get_window_per_pixel_transparency_enabled() const;
- virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
-
- virtual void set_ime_active(const bool p_active);
- virtual void set_ime_position(const Point2 &p_pos);
-
- virtual String get_unique_id() const;
-
- virtual void move_window_to_foreground();
- virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
-
- virtual bool is_joy_known(int p_device);
- virtual String get_joy_guid(int p_device) const;
-
- virtual void set_context(int p_context);
-
- virtual void _set_use_vsync(bool p_enable);
- //virtual bool is_vsync_enabled() const;
-
- virtual bool _check_internal_feature_support(const String &p_feature);
-
- virtual void force_process_input();
- void run();
-
- void disable_crash_handler();
- bool is_disable_crash_handler() const;
-
- virtual Error move_to_trash(const String &p_path);
-
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
-
- void update_real_mouse_position();
- OS_X11();
-};
-
-#endif
diff --git a/platform_methods.py b/platform_methods.py
index 4300216427..eed76bc8a8 100644
--- a/platform_methods.py
+++ b/platform_methods.py
@@ -7,10 +7,7 @@ import subprocess
# NOTE: The multiprocessing module is not compatible with SCons due to conflict on cPickle
-if sys.version_info[0] < 3:
- JSON_SERIALIZABLE_TYPES = (bool, int, long, float, basestring)
-else:
- JSON_SERIALIZABLE_TYPES = (bool, int, float, str)
+JSON_SERIALIZABLE_TYPES = (bool, int, float, str)
def run_in_subprocess(builder_function):
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite_2d.cpp
index f3f7ba9ddd..4cedfc0c20 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* animated_sprite.cpp */
+/* animated_sprite_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "animated_sprite.h"
+#include "animated_sprite_2d.h"
#include "core/os/os.h"
#include "scene/scene_string_names.h"
@@ -37,35 +37,35 @@
#define SPECULAR_SUFFIX "_specular"
#ifdef TOOLS_ENABLED
-Dictionary AnimatedSprite::_edit_get_state() const {
+Dictionary AnimatedSprite2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
return state;
}
-void AnimatedSprite::_edit_set_state(const Dictionary &p_state) {
+void AnimatedSprite2D::_edit_set_state(const Dictionary &p_state) {
Node2D::_edit_set_state(p_state);
set_offset(p_state["offset"]);
}
-void AnimatedSprite::_edit_set_pivot(const Point2 &p_pivot) {
+void AnimatedSprite2D::_edit_set_pivot(const Point2 &p_pivot) {
set_offset(get_offset() - p_pivot);
set_position(get_transform().xform(p_pivot));
}
-Point2 AnimatedSprite::_edit_get_pivot() const {
+Point2 AnimatedSprite2D::_edit_get_pivot() const {
return Vector2();
}
-bool AnimatedSprite::_edit_use_pivot() const {
+bool AnimatedSprite2D::_edit_use_pivot() const {
return true;
}
-Rect2 AnimatedSprite::_edit_get_rect() const {
+Rect2 AnimatedSprite2D::_edit_get_rect() const {
return _get_rect();
}
-bool AnimatedSprite::_edit_use_rect() const {
+bool AnimatedSprite2D::_edit_use_rect() const {
if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
return false;
}
@@ -76,11 +76,11 @@ bool AnimatedSprite::_edit_use_rect() const {
}
#endif
-Rect2 AnimatedSprite::get_anchorable_rect() const {
+Rect2 AnimatedSprite2D::get_anchorable_rect() const {
return _get_rect();
}
-Rect2 AnimatedSprite::_get_rect() const {
+Rect2 AnimatedSprite2D::_get_rect() const {
if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
return Rect2();
}
@@ -328,7 +328,7 @@ SpriteFrames::SpriteFrames() {
add_animation(SceneStringNames::get_singleton()->_default);
}
-void AnimatedSprite::_validate_property(PropertyInfo &property) const {
+void AnimatedSprite2D::_validate_property(PropertyInfo &property) const {
if (!frames.is_valid())
return;
@@ -370,7 +370,7 @@ void AnimatedSprite::_validate_property(PropertyInfo &property) const {
}
}
-void AnimatedSprite::_notification(int p_what) {
+void AnimatedSprite2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_INTERNAL_PROCESS: {
@@ -472,13 +472,13 @@ void AnimatedSprite::_notification(int p_what) {
}
}
-void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
+void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
if (frames.is_valid())
- frames->disconnect("changed", callable_mp(this, &AnimatedSprite::_res_changed));
+ frames->disconnect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed));
frames = p_frames;
if (frames.is_valid())
- frames->connect("changed", callable_mp(this, &AnimatedSprite::_res_changed));
+ frames->connect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed));
if (!frames.is_valid()) {
frame = 0;
@@ -492,12 +492,12 @@ void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
update_configuration_warning();
}
-Ref<SpriteFrames> AnimatedSprite::get_sprite_frames() const {
+Ref<SpriteFrames> AnimatedSprite2D::get_sprite_frames() const {
return frames;
}
-void AnimatedSprite::set_frame(int p_frame) {
+void AnimatedSprite2D::set_frame(int p_frame) {
if (!frames.is_valid()) {
return;
@@ -521,12 +521,12 @@ void AnimatedSprite::set_frame(int p_frame) {
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
-int AnimatedSprite::get_frame() const {
+int AnimatedSprite2D::get_frame() const {
return frame;
}
-void AnimatedSprite::set_speed_scale(float p_speed_scale) {
+void AnimatedSprite2D::set_speed_scale(float p_speed_scale) {
float elapsed = _get_frame_duration() - timeout;
@@ -537,56 +537,56 @@ void AnimatedSprite::set_speed_scale(float p_speed_scale) {
timeout -= elapsed;
}
-float AnimatedSprite::get_speed_scale() const {
+float AnimatedSprite2D::get_speed_scale() const {
return speed_scale;
}
-void AnimatedSprite::set_centered(bool p_center) {
+void AnimatedSprite2D::set_centered(bool p_center) {
centered = p_center;
update();
item_rect_changed();
}
-bool AnimatedSprite::is_centered() const {
+bool AnimatedSprite2D::is_centered() const {
return centered;
}
-void AnimatedSprite::set_offset(const Point2 &p_offset) {
+void AnimatedSprite2D::set_offset(const Point2 &p_offset) {
offset = p_offset;
update();
item_rect_changed();
_change_notify("offset");
}
-Point2 AnimatedSprite::get_offset() const {
+Point2 AnimatedSprite2D::get_offset() const {
return offset;
}
-void AnimatedSprite::set_flip_h(bool p_flip) {
+void AnimatedSprite2D::set_flip_h(bool p_flip) {
hflip = p_flip;
update();
}
-bool AnimatedSprite::is_flipped_h() const {
+bool AnimatedSprite2D::is_flipped_h() const {
return hflip;
}
-void AnimatedSprite::set_flip_v(bool p_flip) {
+void AnimatedSprite2D::set_flip_v(bool p_flip) {
vflip = p_flip;
update();
}
-bool AnimatedSprite::is_flipped_v() const {
+bool AnimatedSprite2D::is_flipped_v() const {
return vflip;
}
-void AnimatedSprite::_res_changed() {
+void AnimatedSprite2D::_res_changed() {
set_frame(frame);
_change_notify("frame");
@@ -594,7 +594,7 @@ void AnimatedSprite::_res_changed() {
update();
}
-void AnimatedSprite::_set_playing(bool p_playing) {
+void AnimatedSprite2D::_set_playing(bool p_playing) {
if (playing == p_playing)
return;
@@ -603,12 +603,12 @@ void AnimatedSprite::_set_playing(bool p_playing) {
set_process_internal(playing);
}
-bool AnimatedSprite::_is_playing() const {
+bool AnimatedSprite2D::_is_playing() const {
return playing;
}
-void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards) {
+void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backwards) {
backwards = p_backwards;
@@ -621,17 +621,17 @@ void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards)
_set_playing(true);
}
-void AnimatedSprite::stop() {
+void AnimatedSprite2D::stop() {
_set_playing(false);
}
-bool AnimatedSprite::is_playing() const {
+bool AnimatedSprite2D::is_playing() const {
return playing;
}
-float AnimatedSprite::_get_frame_duration() {
+float AnimatedSprite2D::_get_frame_duration() {
if (frames.is_valid() && frames->has_animation(animation)) {
float speed = frames->get_animation_speed(animation) * speed_scale;
if (speed > 0) {
@@ -641,7 +641,7 @@ float AnimatedSprite::_get_frame_duration() {
return 0.0;
}
-void AnimatedSprite::_reset_timeout() {
+void AnimatedSprite2D::_reset_timeout() {
if (!playing)
return;
@@ -650,7 +650,7 @@ void AnimatedSprite::_reset_timeout() {
is_over = false;
}
-void AnimatedSprite::set_animation(const StringName &p_animation) {
+void AnimatedSprite2D::set_animation(const StringName &p_animation) {
ERR_FAIL_COND_MSG(frames == NULL, vformat("There is no animation with name '%s'.", p_animation));
ERR_FAIL_COND_MSG(frames->get_animation_names().find(p_animation) == -1, vformat("There is no animation with name '%s'.", p_animation));
@@ -664,12 +664,12 @@ void AnimatedSprite::set_animation(const StringName &p_animation) {
_change_notify();
update();
}
-StringName AnimatedSprite::get_animation() const {
+StringName AnimatedSprite2D::get_animation() const {
return animation;
}
-String AnimatedSprite::get_configuration_warning() const {
+String AnimatedSprite2D::get_configuration_warning() const {
if (frames.is_null()) {
return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite to display frames.");
@@ -678,62 +678,62 @@ String AnimatedSprite::get_configuration_warning() const {
return String();
}
-void AnimatedSprite::set_specular_color(const Color &p_color) {
+void AnimatedSprite2D::set_specular_color(const Color &p_color) {
specular_color = p_color;
update();
}
-Color AnimatedSprite::get_specular_color() const {
+Color AnimatedSprite2D::get_specular_color() const {
return specular_color;
}
-void AnimatedSprite::set_shininess(float p_shininess) {
+void AnimatedSprite2D::set_shininess(float p_shininess) {
shininess = CLAMP(p_shininess, 0.0, 1.0);
update();
}
-float AnimatedSprite::get_shininess() const {
+float AnimatedSprite2D::get_shininess() const {
return shininess;
}
-void AnimatedSprite::_bind_methods() {
+void AnimatedSprite2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite::set_sprite_frames);
- ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite::get_sprite_frames);
+ ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite2D::set_sprite_frames);
+ ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite2D::get_sprite_frames);
- ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite::set_animation);
- ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite::get_animation);
+ ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite2D::set_animation);
+ ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite2D::get_animation);
- ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite::_set_playing);
- ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite::_is_playing);
+ ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite2D::_set_playing);
+ ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite2D::_is_playing);
- ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite::play, DEFVAL(StringName()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite::stop);
- ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite::is_playing);
+ ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite2D::play, DEFVAL(StringName()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite2D::stop);
+ ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite2D::is_playing);
- ClassDB::bind_method(D_METHOD("set_centered", "centered"), &AnimatedSprite::set_centered);
- ClassDB::bind_method(D_METHOD("is_centered"), &AnimatedSprite::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered", "centered"), &AnimatedSprite2D::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"), &AnimatedSprite2D::is_centered);
- ClassDB::bind_method(D_METHOD("set_offset", "offset"), &AnimatedSprite::set_offset);
- ClassDB::bind_method(D_METHOD("get_offset"), &AnimatedSprite::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset", "offset"), &AnimatedSprite2D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"), &AnimatedSprite2D::get_offset);
- ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &AnimatedSprite::set_flip_h);
- ClassDB::bind_method(D_METHOD("is_flipped_h"), &AnimatedSprite::is_flipped_h);
+ ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &AnimatedSprite2D::set_flip_h);
+ ClassDB::bind_method(D_METHOD("is_flipped_h"), &AnimatedSprite2D::is_flipped_h);
- ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &AnimatedSprite::set_flip_v);
- ClassDB::bind_method(D_METHOD("is_flipped_v"), &AnimatedSprite::is_flipped_v);
+ ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &AnimatedSprite2D::set_flip_v);
+ ClassDB::bind_method(D_METHOD("is_flipped_v"), &AnimatedSprite2D::is_flipped_v);
- ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite::set_frame);
- ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite2D::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite2D::get_frame);
- ClassDB::bind_method(D_METHOD("set_speed_scale", "speed_scale"), &AnimatedSprite::set_speed_scale);
- ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimatedSprite::get_speed_scale);
+ ClassDB::bind_method(D_METHOD("set_speed_scale", "speed_scale"), &AnimatedSprite2D::set_speed_scale);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimatedSprite2D::get_speed_scale);
- ClassDB::bind_method(D_METHOD("set_specular_color", "color"), &AnimatedSprite::set_specular_color);
- ClassDB::bind_method(D_METHOD("get_specular_color"), &AnimatedSprite::get_specular_color);
+ ClassDB::bind_method(D_METHOD("set_specular_color", "color"), &AnimatedSprite2D::set_specular_color);
+ ClassDB::bind_method(D_METHOD("get_specular_color"), &AnimatedSprite2D::get_specular_color);
- ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &AnimatedSprite::set_shininess);
- ClassDB::bind_method(D_METHOD("get_shininess"), &AnimatedSprite::get_shininess);
+ ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &AnimatedSprite2D::set_shininess);
+ ClassDB::bind_method(D_METHOD("get_shininess"), &AnimatedSprite2D::get_shininess);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("animation_finished"));
@@ -754,7 +754,7 @@ void AnimatedSprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_v"), "set_flip_v", "is_flipped_v");
}
-AnimatedSprite::AnimatedSprite() {
+AnimatedSprite2D::AnimatedSprite2D() {
centered = true;
hflip = false;
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite_2d.h
index e5d015b07c..726ecefd32 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* animated_sprite.h */
+/* animated_sprite_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef ANIMATED_SPRITE_H
-#define ANIMATED_SPRITE_H
+#ifndef ANIMATED_SPRITE_2D_H
+#define ANIMATED_SPRITE_2D_H
#include "scene/2d/node_2d.h"
#include "scene/resources/texture.h"
@@ -140,9 +140,9 @@ public:
SpriteFrames();
};
-class AnimatedSprite : public Node2D {
+class AnimatedSprite2D : public Node2D {
- GDCLASS(AnimatedSprite, Node2D);
+ GDCLASS(AnimatedSprite2D, Node2D);
Ref<SpriteFrames> frames;
bool playing;
@@ -225,7 +225,7 @@ public:
float get_shininess() const;
virtual String get_configuration_warning() const;
- AnimatedSprite();
+ AnimatedSprite2D();
};
#endif // ANIMATED_SPRITE_H
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index b99c4c88bf..4ccff07416 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -32,12 +32,12 @@
#include "scene/scene_string_names.h"
#include "servers/audio_server.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
void Area2D::set_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode;
- Physics2DServer::get_singleton()->area_set_space_override_mode(get_rid(), Physics2DServer::AreaSpaceOverrideMode(p_mode));
+ PhysicsServer2D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer2D::AreaSpaceOverrideMode(p_mode));
}
Area2D::SpaceOverride Area2D::get_space_override_mode() const {
@@ -47,7 +47,7 @@ Area2D::SpaceOverride Area2D::get_space_override_mode() const {
void Area2D::set_gravity_is_point(bool p_enabled) {
gravity_is_point = p_enabled;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
bool Area2D::is_gravity_a_point() const {
@@ -57,7 +57,7 @@ bool Area2D::is_gravity_a_point() const {
void Area2D::set_gravity_distance_scale(real_t p_scale) {
gravity_distance_scale = p_scale;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
}
real_t Area2D::get_gravity_distance_scale() const {
@@ -67,7 +67,7 @@ real_t Area2D::get_gravity_distance_scale() const {
void Area2D::set_gravity_vector(const Vector2 &p_vec) {
gravity_vec = p_vec;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, p_vec);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_vec);
}
Vector2 Area2D::get_gravity_vector() const {
@@ -77,7 +77,7 @@ Vector2 Area2D::get_gravity_vector() const {
void Area2D::set_gravity(real_t p_gravity) {
gravity = p_gravity;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY, p_gravity);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY, p_gravity);
}
real_t Area2D::get_gravity() const {
@@ -87,7 +87,7 @@ real_t Area2D::get_gravity() const {
void Area2D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
real_t Area2D::get_linear_damp() const {
@@ -97,7 +97,7 @@ real_t Area2D::get_linear_damp() const {
void Area2D::set_angular_damp(real_t p_angular_damp) {
angular_damp = p_angular_damp;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
real_t Area2D::get_angular_damp() const {
@@ -108,7 +108,7 @@ real_t Area2D::get_angular_damp() const {
void Area2D::set_priority(real_t p_priority) {
priority = p_priority;
- Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_PRIORITY, p_priority);
+ PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_PRIORITY, p_priority);
}
real_t Area2D::get_priority() const {
@@ -151,7 +151,7 @@ void Area2D::_body_exit_tree(ObjectID p_id) {
void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
- bool body_in = p_status == Physics2DServer::AREA_BODY_ADDED;
+ bool body_in = p_status == PhysicsServer2D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
@@ -254,7 +254,7 @@ void Area2D::_area_exit_tree(ObjectID p_id) {
void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
- bool area_in = p_status == Physics2DServer::AREA_BODY_ADDED;
+ bool area_in = p_status == PhysicsServer2D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
@@ -403,12 +403,12 @@ void Area2D::set_monitoring(bool p_enable) {
if (monitoring) {
- Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
- Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
+ PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
+ PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
} else {
- Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
- Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
+ PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
+ PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
_clear_monitoring();
}
}
@@ -420,14 +420,14 @@ bool Area2D::is_monitoring() const {
void Area2D::set_monitorable(bool p_enable) {
- ERR_FAIL_COND_MSG(locked || (is_inside_tree() && Physics2DServer::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
+ ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer2D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
if (p_enable == monitorable)
return;
monitorable = p_enable;
- Physics2DServer::get_singleton()->area_set_monitorable(get_rid(), monitorable);
+ PhysicsServer2D::get_singleton()->area_set_monitorable(get_rid(), monitorable);
}
bool Area2D::is_monitorable() const {
@@ -492,7 +492,7 @@ bool Area2D::overlaps_body(Node *p_body) const {
void Area2D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- Physics2DServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
+ PhysicsServer2D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
}
uint32_t Area2D::get_collision_mask() const {
@@ -503,7 +503,7 @@ uint32_t Area2D::get_collision_mask() const {
void Area2D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- Physics2DServer::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
+ PhysicsServer2D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
}
uint32_t Area2D::get_collision_layer() const {
@@ -676,7 +676,7 @@ void Area2D::_bind_methods() {
}
Area2D::Area2D() :
- CollisionObject2D(Physics2DServer::get_singleton()->area_create(), true) {
+ CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) {
space_override = SPACE_OVERRIDE_DISABLED;
set_gravity(98);
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index aa4ed233fb..55d111439a 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "scene/2d/area_2d.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void AudioStreamPlayer2D::_mix_audio() {
@@ -87,7 +87,7 @@ void AudioStreamPlayer2D::_mix_audio() {
AudioFrame target_volume = stream_paused_fade_out ? AudioFrame(0.f, 0.f) : current.vol;
AudioFrame vol_prev = stream_paused_fade_in ? AudioFrame(0.f, 0.f) : prev_outputs[i].vol;
AudioFrame vol_inc = (target_volume - vol_prev) / float(buffer_size);
- AudioFrame vol = stream_paused_fade_in ? AudioFrame(0.f, 0.f) : current.vol;
+ AudioFrame vol = vol_prev;
int cc = AudioServer::get_singleton()->get_channel_count();
@@ -187,9 +187,9 @@ void AudioStreamPlayer2D::_notification(int p_what) {
//check if any area is diverting sound into a bus
- Physics2DDirectSpaceState *space_state = Physics2DServer::get_singleton()->space_get_direct_state(world_2d->get_space());
+ PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space());
- Physics2DDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
+ PhysicsDirectSpaceState2D::ShapeResult sr[MAX_INTERSECT_AREAS];
int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true);
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index faeb6b7169..4c952b7ca6 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -36,15 +36,15 @@ void BackBufferCopy::_update_copy_mode() {
case COPY_MODE_DISABLED: {
- VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2());
+ RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2());
} break;
case COPY_MODE_RECT: {
- VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect);
+ RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect);
} break;
case COPY_MODE_VIEWPORT: {
- VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2());
+ RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2());
} break;
}
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index a8860c3d81..6d8d981974 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -33,7 +33,7 @@
#include "core/engine.h"
#include "core/math/math_funcs.h"
#include "scene/scene_string_names.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
void Camera2D::_update_scroll() {
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 04b5260444..7a106ef79a 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -32,7 +32,7 @@
#define CAMERA_2D_H
#include "scene/2d/node_2d.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
class Camera2D : public Node2D {
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 25db434918..05f8804e2a 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -35,23 +35,23 @@ void CanvasModulate::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_CANVAS) {
if (is_visible_in_tree()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(), color);
+ RS::get_singleton()->canvas_set_modulate(get_canvas(), color);
add_to_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
} else if (p_what == NOTIFICATION_EXIT_CANVAS) {
if (is_visible_in_tree()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1));
+ RS::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_in_tree()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(), color);
+ RS::get_singleton()->canvas_set_modulate(get_canvas(), color);
add_to_group("_canvas_modulate_" + itos(get_canvas().get_id()));
} else {
- VS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1));
+ RS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1));
remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
@@ -71,7 +71,7 @@ void CanvasModulate::set_color(const Color &p_color) {
color = p_color;
if (is_visible_in_tree()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(), color);
+ RS::get_singleton()->canvas_set_modulate(get_canvas(), color);
}
}
Color CanvasModulate::get_color() const {
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 4af2e846f7..5535043432 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -31,7 +31,7 @@
#include "collision_object_2d.h"
#include "scene/scene_string_names.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
void CollisionObject2D::_notification(int p_what) {
@@ -42,15 +42,15 @@ void CollisionObject2D::_notification(int p_what) {
Transform2D global_transform = get_global_transform();
if (area)
- Physics2DServer::get_singleton()->area_set_transform(rid, global_transform);
+ PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform);
else
- Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform);
RID space = get_world_2d()->get_space();
if (area) {
- Physics2DServer::get_singleton()->area_set_space(rid, space);
+ PhysicsServer2D::get_singleton()->area_set_space(rid, space);
} else
- Physics2DServer::get_singleton()->body_set_space(rid, space);
+ PhysicsServer2D::get_singleton()->body_set_space(rid, space);
_update_pickable();
@@ -60,9 +60,9 @@ void CollisionObject2D::_notification(int p_what) {
case NOTIFICATION_ENTER_CANVAS: {
if (area)
- Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
+ PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
else
- Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
+ PhysicsServer2D::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -78,26 +78,26 @@ void CollisionObject2D::_notification(int p_what) {
Transform2D global_transform = get_global_transform();
if (area)
- Physics2DServer::get_singleton()->area_set_transform(rid, global_transform);
+ PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform);
else
- Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform);
} break;
case NOTIFICATION_EXIT_TREE: {
if (area) {
- Physics2DServer::get_singleton()->area_set_space(rid, RID());
+ PhysicsServer2D::get_singleton()->area_set_space(rid, RID());
} else
- Physics2DServer::get_singleton()->body_set_space(rid, RID());
+ PhysicsServer2D::get_singleton()->body_set_space(rid, RID());
} break;
case NOTIFICATION_EXIT_CANVAS: {
if (area)
- Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, ObjectID());
+ PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, ObjectID());
else
- Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, ObjectID());
+ PhysicsServer2D::get_singleton()->body_attach_canvas_instance_id(rid, ObjectID());
} break;
}
}
@@ -136,9 +136,9 @@ void CollisionObject2D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl
sd.disabled = p_disabled;
for (int i = 0; i < sd.shapes.size(); i++) {
if (area) {
- Physics2DServer::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
+ PhysicsServer2D::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
} else {
- Physics2DServer::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
+ PhysicsServer2D::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
}
}
}
@@ -160,7 +160,7 @@ void CollisionObject2D::shape_owner_set_one_way_collision(uint32_t p_owner, bool
ShapeData &sd = shapes[p_owner];
sd.one_way_collision = p_enable;
for (int i = 0; i < sd.shapes.size(); i++) {
- Physics2DServer::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin);
+ PhysicsServer2D::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin);
}
}
@@ -181,7 +181,7 @@ void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owne
ShapeData &sd = shapes[p_owner];
sd.one_way_collision_margin = p_margin;
for (int i = 0; i < sd.shapes.size(); i++) {
- Physics2DServer::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin);
+ PhysicsServer2D::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin);
}
}
@@ -218,9 +218,9 @@ void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transf
sd.xform = p_transform;
for (int i = 0; i < sd.shapes.size(); i++) {
if (area) {
- Physics2DServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
+ PhysicsServer2D::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
} else {
- Physics2DServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
+ PhysicsServer2D::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
}
}
}
@@ -248,9 +248,9 @@ void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2
s.index = total_subshapes;
s.shape = p_shape;
if (area) {
- Physics2DServer::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
+ PhysicsServer2D::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
} else {
- Physics2DServer::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
+ PhysicsServer2D::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
}
sd.shapes.push_back(s);
@@ -284,9 +284,9 @@ void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape)
int index_to_remove = shapes[p_owner].shapes[p_shape].index;
if (area) {
- Physics2DServer::get_singleton()->area_remove_shape(rid, index_to_remove);
+ PhysicsServer2D::get_singleton()->area_remove_shape(rid, index_to_remove);
} else {
- Physics2DServer::get_singleton()->body_remove_shape(rid, index_to_remove);
+ PhysicsServer2D::get_singleton()->body_remove_shape(rid, index_to_remove);
}
shapes[p_owner].shapes.remove(p_shape);
@@ -375,9 +375,9 @@ void CollisionObject2D::_update_pickable() {
bool is_pickable = pickable && is_visible_in_tree();
if (area)
- Physics2DServer::get_singleton()->area_set_pickable(rid, is_pickable);
+ PhysicsServer2D::get_singleton()->area_set_pickable(rid, is_pickable);
else
- Physics2DServer::get_singleton()->body_set_pickable(rid, is_pickable);
+ PhysicsServer2D::get_singleton()->body_set_pickable(rid, is_pickable);
}
String CollisionObject2D::get_configuration_warning() const {
@@ -442,9 +442,9 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
if (p_area) {
- Physics2DServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
+ PhysicsServer2D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
} else {
- Physics2DServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
+ PhysicsServer2D::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
}
}
@@ -457,5 +457,5 @@ CollisionObject2D::CollisionObject2D() {
CollisionObject2D::~CollisionObject2D() {
- Physics2DServer::get_singleton()->free(rid);
+ PhysicsServer2D::get_singleton()->free(rid);
}
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index e9dfb94cb2..5880045e90 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -106,7 +106,7 @@ void CollisionPolygon2D::_notification(int p_what) {
/*if (Engine::get_singleton()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
- set_z_index(VS::CANVAS_ITEM_Z_MAX - 1);
+ set_z_index(RS::CANVAS_ITEM_Z_MAX - 1);
}*/
} break;
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index b2ad040654..cb2953cc15 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -73,7 +73,7 @@ void CollisionShape2D::_notification(int p_what) {
/*if (Engine::get_singleton()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
- set_z_index(VS::CANVAS_ITEM_Z_MAX - 1);
+ set_z_index(RS::CANVAS_ITEM_Z_MAX - 1);
}*/
} break;
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 3b8a81d2ca..ba604c086e 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -31,10 +31,10 @@
#include "cpu_particles_2d.h"
#include "core/core_string_names.h"
-#include "scene/2d/canvas_item.h"
-#include "scene/2d/particles_2d.h"
+#include "scene/2d/gpu_particles_2d.h"
+#include "scene/main/canvas_item.h"
#include "scene/resources/particles_material.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
void CPUParticles2D::set_emitting(bool p_emitting) {
@@ -60,7 +60,7 @@ void CPUParticles2D::set_amount(int p_amount) {
}
particle_data.resize((8 + 4 + 4) * p_amount);
- VS::get_singleton()->multimesh_allocate(multimesh, p_amount, VS::MULTIMESH_TRANSFORM_2D, true, true);
+ RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_2D, true, true);
particle_order.resize(p_amount);
}
@@ -198,14 +198,14 @@ void CPUParticles2D::_update_mesh_texture() {
indices.push_back(0);
Array arr;
- arr.resize(VS::ARRAY_MAX);
- arr[VS::ARRAY_VERTEX] = vertices;
- arr[VS::ARRAY_TEX_UV] = uvs;
- arr[VS::ARRAY_COLOR] = colors;
- arr[VS::ARRAY_INDEX] = indices;
+ arr.resize(RS::ARRAY_MAX);
+ arr[RS::ARRAY_VERTEX] = vertices;
+ arr[RS::ARRAY_TEX_UV] = uvs;
+ arr[RS::ARRAY_COLOR] = colors;
+ arr[RS::ARRAY_INDEX] = indices;
- VS::get_singleton()->mesh_clear(mesh);
- VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VS::PRIMITIVE_TRIANGLES, arr);
+ RS::get_singleton()->mesh_clear(mesh);
+ RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RS::PRIMITIVE_TRIANGLES, arr);
}
void CPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) {
@@ -1046,17 +1046,17 @@ void CPUParticles2D::_set_redraw(bool p_redraw) {
MutexLock lock(update_mutex);
if (redraw) {
- VS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread));
- VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true);
+ RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread));
+ RS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
+ RS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
} else {
- if (VS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread))) {
- VS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread));
+ if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread))) {
+ RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread));
}
- VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), false);
+ RS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), false);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
+ RS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
}
}
@@ -1067,7 +1067,7 @@ void CPUParticles2D::_update_render_thread() {
MutexLock lock(update_mutex);
- VS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
+ RS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
}
void CPUParticles2D::_notification(int p_what) {
@@ -1098,7 +1098,7 @@ void CPUParticles2D::_notification(int p_what) {
normrid = normalmap->get_rid();
}
- VS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid, normrid);
+ RS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid, normrid);
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
@@ -1144,7 +1144,7 @@ void CPUParticles2D::_notification(int p_what) {
void CPUParticles2D::convert_from_particles(Node *p_particles) {
- Particles2D *particles = Object::cast_to<Particles2D>(p_particles);
+ GPUParticles2D *particles = Object::cast_to<GPUParticles2D>(p_particles);
ERR_FAIL_COND_MSG(!particles, "Only Particles2D nodes can be converted to CPUParticles2D.");
set_emitting(particles->is_emitting());
@@ -1428,9 +1428,9 @@ CPUParticles2D::CPUParticles2D() {
redraw = false;
emitting = false;
- mesh = VisualServer::get_singleton()->mesh_create();
- multimesh = VisualServer::get_singleton()->multimesh_create();
- VisualServer::get_singleton()->multimesh_set_mesh(multimesh, mesh);
+ mesh = RenderingServer::get_singleton()->mesh_create();
+ multimesh = RenderingServer::get_singleton()->multimesh_create();
+ RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, mesh);
set_emitting(true);
set_one_shot(false);
@@ -1481,6 +1481,6 @@ CPUParticles2D::CPUParticles2D() {
}
CPUParticles2D::~CPUParticles2D() {
- VS::get_singleton()->free(multimesh);
- VS::get_singleton()->free(mesh);
+ RS::get_singleton()->free(multimesh);
+ RS::get_singleton()->free(mesh);
}
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp
index 2ba2fd8f79..fd9706eb2a 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/gpu_particles_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles_2d.cpp */
+/* gpu_particles_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "particles_2d.h"
+#include "gpu_particles_2d.h"
#include "core/os/os.h"
#include "scene/resources/particles_material.h"
@@ -38,9 +38,9 @@
#include "core/engine.h"
#endif
-void Particles2D::set_emitting(bool p_emitting) {
+void GPUParticles2D::set_emitting(bool p_emitting) {
- VS::get_singleton()->particles_set_emitting(particles, p_emitting);
+ RS::get_singleton()->particles_set_emitting(particles, p_emitting);
if (p_emitting && one_shot) {
set_process_internal(true);
@@ -49,50 +49,50 @@ void Particles2D::set_emitting(bool p_emitting) {
}
}
-void Particles2D::set_amount(int p_amount) {
+void GPUParticles2D::set_amount(int p_amount) {
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1.");
amount = p_amount;
- VS::get_singleton()->particles_set_amount(particles, amount);
+ RS::get_singleton()->particles_set_amount(particles, amount);
}
-void Particles2D::set_lifetime(float p_lifetime) {
+void GPUParticles2D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
- VS::get_singleton()->particles_set_lifetime(particles, lifetime);
+ RS::get_singleton()->particles_set_lifetime(particles, lifetime);
}
-void Particles2D::set_one_shot(bool p_enable) {
+void GPUParticles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
- VS::get_singleton()->particles_set_one_shot(particles, one_shot);
+ RS::get_singleton()->particles_set_one_shot(particles, one_shot);
if (is_emitting()) {
set_process_internal(true);
if (!one_shot)
- VisualServer::get_singleton()->particles_restart(particles);
+ RenderingServer::get_singleton()->particles_restart(particles);
}
if (!one_shot)
set_process_internal(false);
}
-void Particles2D::set_pre_process_time(float p_time) {
+void GPUParticles2D::set_pre_process_time(float p_time) {
pre_process_time = p_time;
- VS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
+ RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
}
-void Particles2D::set_explosiveness_ratio(float p_ratio) {
+void GPUParticles2D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
- VS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
+ RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
}
-void Particles2D::set_randomness_ratio(float p_ratio) {
+void GPUParticles2D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
- VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
+ RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
-void Particles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
+void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
visibility_rect = p_visibility_rect;
AABB aabb;
@@ -101,22 +101,22 @@ void Particles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
aabb.size.x = p_visibility_rect.size.x;
aabb.size.y = p_visibility_rect.size.y;
- VS::get_singleton()->particles_set_custom_aabb(particles, aabb);
+ RS::get_singleton()->particles_set_custom_aabb(particles, aabb);
_change_notify("visibility_rect");
update();
}
-void Particles2D::set_use_local_coordinates(bool p_enable) {
+void GPUParticles2D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
- VS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
+ RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
set_notify_transform(!p_enable);
if (!p_enable && is_inside_tree()) {
_update_particle_emission_transform();
}
}
-void Particles2D::_update_particle_emission_transform() {
+void GPUParticles2D::_update_particle_emission_transform() {
Transform2D xf2d = get_global_transform();
Transform xf;
@@ -124,10 +124,10 @@ void Particles2D::_update_particle_emission_transform() {
xf.basis.set_axis(1, Vector3(xf2d.get_axis(1).x, xf2d.get_axis(1).y, 0));
xf.set_origin(Vector3(xf2d.get_origin().x, xf2d.get_origin().y, 0));
- VS::get_singleton()->particles_set_emission_transform(particles, xf);
+ RS::get_singleton()->particles_set_emission_transform(particles, xf);
}
-void Particles2D::set_process_material(const Ref<Material> &p_material) {
+void GPUParticles2D::set_process_material(const Ref<Material> &p_material) {
process_material = p_material;
Ref<ParticlesMaterial> pm = p_material;
@@ -139,96 +139,96 @@ void Particles2D::set_process_material(const Ref<Material> &p_material) {
RID material_rid;
if (process_material.is_valid())
material_rid = process_material->get_rid();
- VS::get_singleton()->particles_set_process_material(particles, material_rid);
+ RS::get_singleton()->particles_set_process_material(particles, material_rid);
update_configuration_warning();
}
-void Particles2D::set_speed_scale(float p_scale) {
+void GPUParticles2D::set_speed_scale(float p_scale) {
speed_scale = p_scale;
- VS::get_singleton()->particles_set_speed_scale(particles, p_scale);
+ RS::get_singleton()->particles_set_speed_scale(particles, p_scale);
}
-bool Particles2D::is_emitting() const {
+bool GPUParticles2D::is_emitting() const {
- return VS::get_singleton()->particles_get_emitting(particles);
+ return RS::get_singleton()->particles_get_emitting(particles);
}
-int Particles2D::get_amount() const {
+int GPUParticles2D::get_amount() const {
return amount;
}
-float Particles2D::get_lifetime() const {
+float GPUParticles2D::get_lifetime() const {
return lifetime;
}
-bool Particles2D::get_one_shot() const {
+bool GPUParticles2D::get_one_shot() const {
return one_shot;
}
-float Particles2D::get_pre_process_time() const {
+float GPUParticles2D::get_pre_process_time() const {
return pre_process_time;
}
-float Particles2D::get_explosiveness_ratio() const {
+float GPUParticles2D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float Particles2D::get_randomness_ratio() const {
+float GPUParticles2D::get_randomness_ratio() const {
return randomness_ratio;
}
-Rect2 Particles2D::get_visibility_rect() const {
+Rect2 GPUParticles2D::get_visibility_rect() const {
return visibility_rect;
}
-bool Particles2D::get_use_local_coordinates() const {
+bool GPUParticles2D::get_use_local_coordinates() const {
return local_coords;
}
-Ref<Material> Particles2D::get_process_material() const {
+Ref<Material> GPUParticles2D::get_process_material() const {
return process_material;
}
-float Particles2D::get_speed_scale() const {
+float GPUParticles2D::get_speed_scale() const {
return speed_scale;
}
-void Particles2D::set_draw_order(DrawOrder p_order) {
+void GPUParticles2D::set_draw_order(DrawOrder p_order) {
draw_order = p_order;
- VS::get_singleton()->particles_set_draw_order(particles, VS::ParticlesDrawOrder(p_order));
+ RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order));
}
-Particles2D::DrawOrder Particles2D::get_draw_order() const {
+GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const {
return draw_order;
}
-void Particles2D::set_fixed_fps(int p_count) {
+void GPUParticles2D::set_fixed_fps(int p_count) {
fixed_fps = p_count;
- VS::get_singleton()->particles_set_fixed_fps(particles, p_count);
+ RS::get_singleton()->particles_set_fixed_fps(particles, p_count);
}
-int Particles2D::get_fixed_fps() const {
+int GPUParticles2D::get_fixed_fps() const {
return fixed_fps;
}
-void Particles2D::set_fractional_delta(bool p_enable) {
+void GPUParticles2D::set_fractional_delta(bool p_enable) {
fractional_delta = p_enable;
- VS::get_singleton()->particles_set_fractional_delta(particles, p_enable);
+ RS::get_singleton()->particles_set_fractional_delta(particles, p_enable);
}
-bool Particles2D::get_fractional_delta() const {
+bool GPUParticles2D::get_fractional_delta() const {
return fractional_delta;
}
-String Particles2D::get_configuration_warning() const {
+String GPUParticles2D::get_configuration_warning() const {
- if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles\" option for this purpose.");
}
@@ -257,9 +257,9 @@ String Particles2D::get_configuration_warning() const {
return warnings;
}
-Rect2 Particles2D::capture_rect() const {
+Rect2 GPUParticles2D::capture_rect() const {
- AABB aabb = VS::get_singleton()->particles_get_current_aabb(particles);
+ AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles);
Rect2 r;
r.position.x = aabb.position.x;
r.position.y = aabb.position.y;
@@ -268,34 +268,34 @@ Rect2 Particles2D::capture_rect() const {
return r;
}
-void Particles2D::set_texture(const Ref<Texture2D> &p_texture) {
+void GPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) {
texture = p_texture;
update();
}
-Ref<Texture2D> Particles2D::get_texture() const {
+Ref<Texture2D> GPUParticles2D::get_texture() const {
return texture;
}
-void Particles2D::set_normal_map(const Ref<Texture2D> &p_normal_map) {
+void GPUParticles2D::set_normal_map(const Ref<Texture2D> &p_normal_map) {
normal_map = p_normal_map;
update();
}
-Ref<Texture2D> Particles2D::get_normal_map() const {
+Ref<Texture2D> GPUParticles2D::get_normal_map() const {
return normal_map;
}
-void Particles2D::_validate_property(PropertyInfo &property) const {
+void GPUParticles2D::_validate_property(PropertyInfo &property) const {
}
-void Particles2D::restart() {
- VS::get_singleton()->particles_restart(particles);
- VS::get_singleton()->particles_set_emitting(particles, true);
+void GPUParticles2D::restart() {
+ RS::get_singleton()->particles_restart(particles);
+ RS::get_singleton()->particles_set_emitting(particles, true);
}
-void Particles2D::_notification(int p_what) {
+void GPUParticles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
@@ -306,7 +306,7 @@ void Particles2D::_notification(int p_what) {
if (normal_map.is_valid())
normal_rid = normal_map->get_rid();
- VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid);
+ RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid);
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
@@ -318,10 +318,10 @@ void Particles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
if (can_process()) {
- VS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
+ RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
} else {
- VS::get_singleton()->particles_set_speed_scale(particles, 0);
+ RS::get_singleton()->particles_set_speed_scale(particles, 0);
}
}
@@ -338,48 +338,48 @@ void Particles2D::_notification(int p_what) {
}
}
-void Particles2D::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &Particles2D::set_emitting);
- ClassDB::bind_method(D_METHOD("set_amount", "amount"), &Particles2D::set_amount);
- ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &Particles2D::set_lifetime);
- ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &Particles2D::set_one_shot);
- ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &Particles2D::set_pre_process_time);
- ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &Particles2D::set_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &Particles2D::set_randomness_ratio);
- ClassDB::bind_method(D_METHOD("set_visibility_rect", "visibility_rect"), &Particles2D::set_visibility_rect);
- ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &Particles2D::set_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &Particles2D::set_fixed_fps);
- ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &Particles2D::set_fractional_delta);
- ClassDB::bind_method(D_METHOD("set_process_material", "material"), &Particles2D::set_process_material);
- ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &Particles2D::set_speed_scale);
-
- ClassDB::bind_method(D_METHOD("is_emitting"), &Particles2D::is_emitting);
- ClassDB::bind_method(D_METHOD("get_amount"), &Particles2D::get_amount);
- ClassDB::bind_method(D_METHOD("get_lifetime"), &Particles2D::get_lifetime);
- ClassDB::bind_method(D_METHOD("get_one_shot"), &Particles2D::get_one_shot);
- ClassDB::bind_method(D_METHOD("get_pre_process_time"), &Particles2D::get_pre_process_time);
- ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &Particles2D::get_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &Particles2D::get_randomness_ratio);
- ClassDB::bind_method(D_METHOD("get_visibility_rect"), &Particles2D::get_visibility_rect);
- ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &Particles2D::get_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("get_fixed_fps"), &Particles2D::get_fixed_fps);
- ClassDB::bind_method(D_METHOD("get_fractional_delta"), &Particles2D::get_fractional_delta);
- ClassDB::bind_method(D_METHOD("get_process_material"), &Particles2D::get_process_material);
- ClassDB::bind_method(D_METHOD("get_speed_scale"), &Particles2D::get_speed_scale);
-
- ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &Particles2D::set_draw_order);
- ClassDB::bind_method(D_METHOD("get_draw_order"), &Particles2D::get_draw_order);
-
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Particles2D::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &Particles2D::get_texture);
-
- ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &Particles2D::set_normal_map);
- ClassDB::bind_method(D_METHOD("get_normal_map"), &Particles2D::get_normal_map);
-
- ClassDB::bind_method(D_METHOD("capture_rect"), &Particles2D::capture_rect);
-
- ClassDB::bind_method(D_METHOD("restart"), &Particles2D::restart);
+void GPUParticles2D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles2D::set_emitting);
+ ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles2D::set_amount);
+ ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles2D::set_lifetime);
+ ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &GPUParticles2D::set_one_shot);
+ ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &GPUParticles2D::set_pre_process_time);
+ ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &GPUParticles2D::set_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &GPUParticles2D::set_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("set_visibility_rect", "visibility_rect"), &GPUParticles2D::set_visibility_rect);
+ ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &GPUParticles2D::set_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &GPUParticles2D::set_fixed_fps);
+ ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &GPUParticles2D::set_fractional_delta);
+ ClassDB::bind_method(D_METHOD("set_process_material", "material"), &GPUParticles2D::set_process_material);
+ ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &GPUParticles2D::set_speed_scale);
+
+ ClassDB::bind_method(D_METHOD("is_emitting"), &GPUParticles2D::is_emitting);
+ ClassDB::bind_method(D_METHOD("get_amount"), &GPUParticles2D::get_amount);
+ ClassDB::bind_method(D_METHOD("get_lifetime"), &GPUParticles2D::get_lifetime);
+ ClassDB::bind_method(D_METHOD("get_one_shot"), &GPUParticles2D::get_one_shot);
+ ClassDB::bind_method(D_METHOD("get_pre_process_time"), &GPUParticles2D::get_pre_process_time);
+ ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &GPUParticles2D::get_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &GPUParticles2D::get_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("get_visibility_rect"), &GPUParticles2D::get_visibility_rect);
+ ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &GPUParticles2D::get_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("get_fixed_fps"), &GPUParticles2D::get_fixed_fps);
+ ClassDB::bind_method(D_METHOD("get_fractional_delta"), &GPUParticles2D::get_fractional_delta);
+ ClassDB::bind_method(D_METHOD("get_process_material"), &GPUParticles2D::get_process_material);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"), &GPUParticles2D::get_speed_scale);
+
+ ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &GPUParticles2D::set_draw_order);
+ ClassDB::bind_method(D_METHOD("get_draw_order"), &GPUParticles2D::get_draw_order);
+
+ ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticles2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticles2D::get_texture);
+
+ ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &GPUParticles2D::set_normal_map);
+ ClassDB::bind_method(D_METHOD("get_normal_map"), &GPUParticles2D::get_normal_map);
+
+ ClassDB::bind_method(D_METHOD("capture_rect"), &GPUParticles2D::capture_rect);
+
+ ClassDB::bind_method(D_METHOD("restart"), &GPUParticles2D::restart);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_EXP_RANGE, "1,1000000,1"), "set_amount", "get_amount");
@@ -406,9 +406,9 @@ void Particles2D::_bind_methods() {
BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
}
-Particles2D::Particles2D() {
+GPUParticles2D::GPUParticles2D() {
- particles = VS::get_singleton()->particles_create();
+ particles = RS::get_singleton()->particles_create();
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
set_emitting(true);
@@ -426,7 +426,7 @@ Particles2D::Particles2D() {
set_speed_scale(1);
}
-Particles2D::~Particles2D() {
+GPUParticles2D::~GPUParticles2D() {
- VS::get_singleton()->free(particles);
+ RS::get_singleton()->free(particles);
}
diff --git a/scene/2d/particles_2d.h b/scene/2d/gpu_particles_2d.h
index 66281d7950..47951d76dc 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/gpu_particles_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles_2d.h */
+/* gpu_particles_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,9 +35,9 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/texture.h"
-class Particles2D : public Node2D {
+class GPUParticles2D : public Node2D {
private:
- GDCLASS(Particles2D, Node2D);
+ GDCLASS(GPUParticles2D, Node2D);
public:
enum DrawOrder {
@@ -118,10 +118,10 @@ public:
void restart();
Rect2 capture_rect() const;
- Particles2D();
- ~Particles2D();
+ GPUParticles2D();
+ ~GPUParticles2D();
};
-VARIANT_ENUM_CAST(Particles2D::DrawOrder)
+VARIANT_ENUM_CAST(GPUParticles2D::DrawOrder)
#endif // PARTICLES_2D_H
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 9cc9ab25ac..6cbb0d2a39 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -32,15 +32,15 @@
#include "core/engine.h"
#include "physics_body_2d.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
void Joint2D::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
if (ba.is_valid() && bb.is_valid() && exclude_from_collision)
- Physics2DServer::get_singleton()->joint_disable_collisions_between_bodies(joint, false);
+ PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, false);
- Physics2DServer::get_singleton()->free(joint);
+ PhysicsServer2D::get_singleton()->free(joint);
joint = RID();
ba = RID();
bb = RID();
@@ -66,12 +66,12 @@ void Joint2D::_update_joint(bool p_only_free) {
if (!joint.is_valid())
return;
- Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
+ PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias);
ba = body_a->get_rid();
bb = body_b->get_rid();
- Physics2DServer::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
+ PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
}
void Joint2D::set_node_a(const NodePath &p_node_a) {
@@ -119,7 +119,7 @@ void Joint2D::set_bias(real_t p_bias) {
bias = p_bias;
if (joint.is_valid())
- Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
+ PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias);
}
real_t Joint2D::get_bias() const {
@@ -192,8 +192,8 @@ void PinJoint2D::_notification(int p_what) {
RID PinJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
- RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
- Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness);
+ RID pj = PhysicsServer2D::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(pj, PhysicsServer2D::PIN_JOINT_SOFTNESS, softness);
return pj;
}
@@ -202,7 +202,7 @@ void PinJoint2D::set_softness(real_t p_softness) {
softness = p_softness;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->pin_joint_set_param(get_joint(), Physics2DServer::PIN_JOINT_SOFTNESS, p_softness);
+ PhysicsServer2D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness);
}
real_t PinJoint2D::get_softness() const {
@@ -253,7 +253,7 @@ RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b
Vector2 groove_A2 = gt.xform(Vector2(0, length));
Vector2 anchor_B = gt.xform(Vector2(0, initial_offset));
- return Physics2DServer::get_singleton()->groove_joint_create(groove_A1, groove_A2, anchor_B, body_a->get_rid(), body_b->get_rid());
+ return PhysicsServer2D::get_singleton()->groove_joint_create(groove_A1, groove_A2, anchor_B, body_a->get_rid(), body_b->get_rid());
}
void GrooveJoint2D::set_length(real_t p_length) {
@@ -324,11 +324,11 @@ RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *
Vector2 anchor_A = gt.get_origin();
Vector2 anchor_B = gt.xform(Vector2(0, length));
- RID dsj = Physics2DServer::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
+ RID dsj = PhysicsServer2D::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
if (rest_length)
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_REST_LENGTH, rest_length);
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_STIFFNESS, stiffness);
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_DAMPING, damping);
+ PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_REST_LENGTH, rest_length);
+ PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_STIFFNESS, stiffness);
+ PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_DAMPING, damping);
return dsj;
}
@@ -349,7 +349,7 @@ void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
rest_length = p_rest_length;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
+ PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
}
real_t DampedSpringJoint2D::get_rest_length() const {
@@ -362,7 +362,7 @@ void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
stiffness = p_stiffness;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_STIFFNESS, p_stiffness);
+ PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_STIFFNESS, p_stiffness);
}
real_t DampedSpringJoint2D::get_stiffness() const {
@@ -375,7 +375,7 @@ void DampedSpringJoint2D::set_damping(real_t p_damping) {
damping = p_damping;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_DAMPING, p_damping);
+ PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_DAMPING, p_damping);
}
real_t DampedSpringJoint2D::get_damping() const {
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index e61b1fa339..b3d54b81f8 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -31,7 +31,7 @@
#include "light_2d.h"
#include "core/engine.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
Dictionary Light2D::_edit_get_state() const {
@@ -100,7 +100,7 @@ void Light2D::_update_light_visibility() {
}
#endif
- VS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible_in_tree() && editor_ok);
+ RS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible_in_tree() && editor_ok);
}
void Light2D::set_enabled(bool p_enabled) {
@@ -129,9 +129,9 @@ void Light2D::set_texture(const Ref<Texture2D> &p_texture) {
texture = p_texture;
if (texture.is_valid())
- VS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid());
+ RS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid());
else
- VS::get_singleton()->canvas_light_set_texture(canvas_light, RID());
+ RS::get_singleton()->canvas_light_set_texture(canvas_light, RID());
update_configuration_warning();
}
@@ -144,7 +144,7 @@ Ref<Texture2D> Light2D::get_texture() const {
void Light2D::set_texture_offset(const Vector2 &p_offset) {
texture_offset = p_offset;
- VS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset);
+ RS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset);
item_rect_changed();
_change_notify("offset");
}
@@ -157,7 +157,7 @@ Vector2 Light2D::get_texture_offset() const {
void Light2D::set_color(const Color &p_color) {
color = p_color;
- VS::get_singleton()->canvas_light_set_color(canvas_light, color);
+ RS::get_singleton()->canvas_light_set_color(canvas_light, color);
}
Color Light2D::get_color() const {
@@ -167,7 +167,7 @@ Color Light2D::get_color() const {
void Light2D::set_height(float p_height) {
height = p_height;
- VS::get_singleton()->canvas_light_set_height(canvas_light, height);
+ RS::get_singleton()->canvas_light_set_height(canvas_light, height);
}
float Light2D::get_height() const {
@@ -178,7 +178,7 @@ float Light2D::get_height() const {
void Light2D::set_energy(float p_energy) {
energy = p_energy;
- VS::get_singleton()->canvas_light_set_energy(canvas_light, energy);
+ RS::get_singleton()->canvas_light_set_energy(canvas_light, energy);
}
float Light2D::get_energy() const {
@@ -193,7 +193,7 @@ void Light2D::set_texture_scale(float p_scale) {
if (_scale == 0) {
_scale = CMP_EPSILON;
}
- VS::get_singleton()->canvas_light_set_scale(canvas_light, _scale);
+ RS::get_singleton()->canvas_light_set_scale(canvas_light, _scale);
item_rect_changed();
}
@@ -205,7 +205,7 @@ float Light2D::get_texture_scale() const {
void Light2D::set_z_range_min(int p_min_z) {
z_min = p_min_z;
- VS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
+ RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
}
int Light2D::get_z_range_min() const {
@@ -215,7 +215,7 @@ int Light2D::get_z_range_min() const {
void Light2D::set_z_range_max(int p_max_z) {
z_max = p_max_z;
- VS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
+ RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
}
int Light2D::get_z_range_max() const {
@@ -225,7 +225,7 @@ int Light2D::get_z_range_max() const {
void Light2D::set_layer_range_min(int p_min_layer) {
layer_min = p_min_layer;
- VS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
+ RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
}
int Light2D::get_layer_range_min() const {
@@ -235,7 +235,7 @@ int Light2D::get_layer_range_min() const {
void Light2D::set_layer_range_max(int p_max_layer) {
layer_max = p_max_layer;
- VS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
+ RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
}
int Light2D::get_layer_range_max() const {
@@ -245,7 +245,7 @@ int Light2D::get_layer_range_max() const {
void Light2D::set_item_cull_mask(int p_mask) {
item_mask = p_mask;
- VS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light, item_mask);
+ RS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light, item_mask);
}
int Light2D::get_item_cull_mask() const {
@@ -256,7 +256,7 @@ int Light2D::get_item_cull_mask() const {
void Light2D::set_item_shadow_cull_mask(int p_mask) {
item_shadow_mask = p_mask;
- VS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light, item_shadow_mask);
+ RS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light, item_shadow_mask);
}
int Light2D::get_item_shadow_cull_mask() const {
@@ -267,7 +267,7 @@ int Light2D::get_item_shadow_cull_mask() const {
void Light2D::set_mode(Mode p_mode) {
mode = p_mode;
- VS::get_singleton()->canvas_light_set_mode(canvas_light, VS::CanvasLightMode(p_mode));
+ RS::get_singleton()->canvas_light_set_mode(canvas_light, RS::CanvasLightMode(p_mode));
}
Light2D::Mode Light2D::get_mode() const {
@@ -278,7 +278,7 @@ Light2D::Mode Light2D::get_mode() const {
void Light2D::set_shadow_enabled(bool p_enabled) {
shadow = p_enabled;
- VS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow);
+ RS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow);
}
bool Light2D::is_shadow_enabled() const {
@@ -288,7 +288,7 @@ bool Light2D::is_shadow_enabled() const {
void Light2D::set_shadow_buffer_size(int p_size) {
shadow_buffer_size = p_size;
- VS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size);
+ RS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size);
}
int Light2D::get_shadow_buffer_size() const {
@@ -299,7 +299,7 @@ int Light2D::get_shadow_buffer_size() const {
void Light2D::set_shadow_filter(ShadowFilter p_filter) {
ERR_FAIL_INDEX(p_filter, SHADOW_FILTER_MAX);
shadow_filter = p_filter;
- VS::get_singleton()->canvas_light_set_shadow_filter(canvas_light, VS::CanvasLightShadowFilter(p_filter));
+ RS::get_singleton()->canvas_light_set_shadow_filter(canvas_light, RS::CanvasLightShadowFilter(p_filter));
}
Light2D::ShadowFilter Light2D::get_shadow_filter() const {
@@ -309,7 +309,7 @@ Light2D::ShadowFilter Light2D::get_shadow_filter() const {
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);
+ RS::get_singleton()->canvas_light_set_shadow_color(canvas_light, shadow_color);
}
Color Light2D::get_shadow_color() const {
@@ -320,13 +320,13 @@ void Light2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- VS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas());
+ RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas());
_update_light_visibility();
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
- VS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform());
+ RS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform());
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -335,7 +335,7 @@ void Light2D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
- VS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID());
+ RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID());
_update_light_visibility();
}
}
@@ -352,7 +352,7 @@ String Light2D::get_configuration_warning() const {
void Light2D::set_shadow_smooth(float p_amount) {
shadow_smooth = p_amount;
- VS::get_singleton()->canvas_light_set_shadow_smooth(canvas_light, shadow_smooth);
+ RS::get_singleton()->canvas_light_set_shadow_smooth(canvas_light, shadow_smooth);
}
float Light2D::get_shadow_smooth() const {
@@ -432,8 +432,8 @@ void Light2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Add,Sub,Mix,Mask"), "set_mode", "get_mode");
ADD_GROUP("Range", "range_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range_height", PROPERTY_HINT_RANGE, "-2048,2048,0.1,or_lesser,or_greater"), "set_height", "get_height");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_min", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_min", "get_z_range_min");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_max", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_max", "get_z_range_max");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_min", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_min", "get_z_range_min");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_max", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_max", "get_z_range_max");
ADD_PROPERTY(PropertyInfo(Variant::INT, "range_layer_min", PROPERTY_HINT_RANGE, "-512,512,1"), "set_layer_range_min", "get_layer_range_min");
ADD_PROPERTY(PropertyInfo(Variant::INT, "range_layer_max", PROPERTY_HINT_RANGE, "-512,512,1"), "set_layer_range_max", "get_layer_range_max");
ADD_PROPERTY(PropertyInfo(Variant::INT, "range_item_cull_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_item_cull_mask", "get_item_cull_mask");
@@ -458,7 +458,7 @@ void Light2D::_bind_methods() {
Light2D::Light2D() {
- canvas_light = VisualServer::get_singleton()->canvas_light_create();
+ canvas_light = RenderingServer::get_singleton()->canvas_light_create();
enabled = true;
editor_only = false;
shadow = false;
@@ -483,5 +483,5 @@ Light2D::Light2D() {
Light2D::~Light2D() {
- VisualServer::get_singleton()->free(canvas_light);
+ RenderingServer::get_singleton()->free(canvas_light);
}
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index d4a5c93823..bd1a820aec 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -88,7 +88,7 @@ void OccluderPolygon2D::set_polygon(const Vector<Vector2> &p_polygon) {
polygon = p_polygon;
rect_cache_dirty = true;
- VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed);
+ RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed);
emit_changed();
}
@@ -103,7 +103,7 @@ void OccluderPolygon2D::set_closed(bool p_closed) {
return;
closed = p_closed;
if (polygon.size())
- VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, polygon, closed);
+ RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, polygon, closed);
emit_changed();
}
@@ -115,7 +115,7 @@ bool OccluderPolygon2D::is_closed() const {
void OccluderPolygon2D::set_cull_mode(CullMode p_mode) {
cull = p_mode;
- VS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, VS::CanvasOccluderPolygonCullMode(p_mode));
+ RS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, RS::CanvasOccluderPolygonCullMode(p_mode));
}
OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const {
@@ -150,7 +150,7 @@ void OccluderPolygon2D::_bind_methods() {
OccluderPolygon2D::OccluderPolygon2D() {
- occ_polygon = VS::get_singleton()->canvas_occluder_polygon_create();
+ occ_polygon = RS::get_singleton()->canvas_occluder_polygon_create();
closed = true;
cull = CULL_DISABLED;
rect_cache_dirty = true;
@@ -158,7 +158,7 @@ OccluderPolygon2D::OccluderPolygon2D() {
OccluderPolygon2D::~OccluderPolygon2D() {
- VS::get_singleton()->free(occ_polygon);
+ RS::get_singleton()->free(occ_polygon);
}
void LightOccluder2D::_poly_changed() {
@@ -172,17 +172,17 @@ void LightOccluder2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_CANVAS) {
- 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_in_tree());
+ RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas());
+ RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
+ RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
+ RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
+ RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
}
if (p_what == NOTIFICATION_DRAW) {
@@ -214,7 +214,7 @@ void LightOccluder2D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_CANVAS) {
- VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID());
+ RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID());
}
}
@@ -239,9 +239,9 @@ void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polyg
occluder_polygon = p_polygon;
if (occluder_polygon.is_valid())
- VS::get_singleton()->canvas_light_occluder_set_polygon(occluder, occluder_polygon->get_rid());
+ RS::get_singleton()->canvas_light_occluder_set_polygon(occluder, occluder_polygon->get_rid());
else
- VS::get_singleton()->canvas_light_occluder_set_polygon(occluder, RID());
+ RS::get_singleton()->canvas_light_occluder_set_polygon(occluder, RID());
#ifdef DEBUG_ENABLED
if (occluder_polygon.is_valid())
@@ -258,7 +258,7 @@ Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {
void LightOccluder2D::set_occluder_light_mask(int p_mask) {
mask = p_mask;
- VS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask);
+ RS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask);
}
int LightOccluder2D::get_occluder_light_mask() const {
@@ -293,12 +293,12 @@ void LightOccluder2D::_bind_methods() {
LightOccluder2D::LightOccluder2D() {
- occluder = VS::get_singleton()->canvas_light_occluder_create();
+ occluder = RS::get_singleton()->canvas_light_occluder_create();
mask = 1;
set_notify_transform(true);
}
LightOccluder2D::~LightOccluder2D() {
- VS::get_singleton()->free(occluder);
+ RS::get_singleton()->free(occluder);
}
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 873c901c0a..c45eab70df 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -311,7 +311,7 @@ void Line2D::_draw() {
lb.build();
- VS::get_singleton()->canvas_item_add_triangle_array(
+ RS::get_singleton()->canvas_item_add_triangle_array(
get_canvas_item(),
lb.indices,
lb.vertices,
diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp
index bbabfa16c7..ae9fc0f32c 100644
--- a/scene/2d/navigation_2d.cpp
+++ b/scene/2d/navigation_2d.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "navigation_2d.h"
-#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server_2d.h"
void Navigation2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &Navigation2D::get_rid);
@@ -51,44 +51,44 @@ void Navigation2D::_bind_methods() {
void Navigation2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- Navigation2DServer::get_singleton()->map_set_active(map, true);
+ NavigationServer2D::get_singleton()->map_set_active(map, true);
} break;
case NOTIFICATION_EXIT_TREE: {
- Navigation2DServer::get_singleton()->map_set_active(map, false);
+ NavigationServer2D::get_singleton()->map_set_active(map, false);
} break;
}
}
void Navigation2D::set_cell_size(float p_cell_size) {
cell_size = p_cell_size;
- Navigation2DServer::get_singleton()->map_set_cell_size(map, cell_size);
+ NavigationServer2D::get_singleton()->map_set_cell_size(map, cell_size);
}
void Navigation2D::set_edge_connection_margin(float p_edge_connection_margin) {
edge_connection_margin = p_edge_connection_margin;
- Navigation2DServer::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin);
+ NavigationServer2D::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin);
}
Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) const {
- return Navigation2DServer::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
+ return NavigationServer2D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
}
Vector2 Navigation2D::get_closest_point(const Vector2 &p_point) const {
- return Navigation2DServer::get_singleton()->map_get_closest_point(map, p_point);
+ return NavigationServer2D::get_singleton()->map_get_closest_point(map, p_point);
}
RID Navigation2D::get_closest_point_owner(const Vector2 &p_point) const {
- return Navigation2DServer::get_singleton()->map_get_closest_point_owner(map, p_point);
+ return NavigationServer2D::get_singleton()->map_get_closest_point_owner(map, p_point);
}
Navigation2D::Navigation2D() {
- map = Navigation2DServer::get_singleton()->map_create();
+ map = NavigationServer2D::get_singleton()->map_create();
set_cell_size(10); // Ten pixels
set_edge_connection_margin(100);
}
Navigation2D::~Navigation2D() {
- Navigation2DServer::get_singleton()->free(map);
+ NavigationServer2D::get_singleton()->free(map);
}
diff --git a/scene/2d/navigation_2d.h b/scene/2d/navigation_2d.h
index 5520f5006e..1da13fc78a 100644
--- a/scene/2d/navigation_2d.h
+++ b/scene/2d/navigation_2d.h
@@ -31,7 +31,7 @@
#ifndef NAVIGATION_2D_H
#define NAVIGATION_2D_H
-#include "scene/2d/navigation_polygon.h"
+#include "scene/2d/navigation_region_2d.h"
#include "scene/2d/node_2d.h"
class Navigation2D : public Node2D {
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index e345a076ae..c70d5ab1fe 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "scene/2d/navigation_2d.h"
-#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server_2d.h"
void NavigationAgent2D::_bind_methods() {
@@ -94,7 +94,7 @@ void NavigationAgent2D::_notification(int p_what) {
agent_parent = Object::cast_to<Node2D>(get_parent());
- Navigation2DServer::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
+ NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
// Search the navigation node and set it
{
@@ -121,7 +121,7 @@ void NavigationAgent2D::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent) {
- Navigation2DServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin());
+ NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin());
if (!target_reached) {
if (distance_to_target() < target_desired_distance) {
emit_signal("target_reached");
@@ -142,7 +142,7 @@ NavigationAgent2D::NavigationAgent2D() :
velocity_submitted(false),
target_reached(false),
navigation_finished(true) {
- agent = Navigation2DServer::get_singleton()->agent_create();
+ agent = NavigationServer2D::get_singleton()->agent_create();
set_neighbor_dist(500.0);
set_max_neighbors(10);
set_time_horizon(20.0);
@@ -151,7 +151,7 @@ NavigationAgent2D::NavigationAgent2D() :
}
NavigationAgent2D::~NavigationAgent2D() {
- Navigation2DServer::get_singleton()->free(agent);
+ NavigationServer2D::get_singleton()->free(agent);
agent = RID(); // Pointless
}
@@ -160,7 +160,7 @@ void NavigationAgent2D::set_navigation(Navigation2D *p_nav) {
return; // Pointless
navigation = p_nav;
- Navigation2DServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
+ NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
}
void NavigationAgent2D::set_navigation_node(Node *p_nav) {
@@ -179,27 +179,27 @@ void NavigationAgent2D::set_target_desired_distance(real_t p_dd) {
void NavigationAgent2D::set_radius(real_t p_radius) {
radius = p_radius;
- Navigation2DServer::get_singleton()->agent_set_radius(agent, radius);
+ NavigationServer2D::get_singleton()->agent_set_radius(agent, radius);
}
void NavigationAgent2D::set_neighbor_dist(real_t p_dist) {
neighbor_dist = p_dist;
- Navigation2DServer::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist);
+ NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist);
}
void NavigationAgent2D::set_max_neighbors(int p_count) {
max_neighbors = p_count;
- Navigation2DServer::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
+ NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
}
void NavigationAgent2D::set_time_horizon(real_t p_time) {
time_horizon = p_time;
- Navigation2DServer::get_singleton()->agent_set_time_horizon(agent, time_horizon);
+ NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, time_horizon);
}
void NavigationAgent2D::set_max_speed(real_t p_max_speed) {
max_speed = p_max_speed;
- Navigation2DServer::get_singleton()->agent_set_max_speed(agent, max_speed);
+ NavigationServer2D::get_singleton()->agent_set_max_speed(agent, max_speed);
}
void NavigationAgent2D::set_path_max_distance(real_t p_pmd) {
@@ -260,8 +260,8 @@ Vector2 NavigationAgent2D::get_final_location() {
void NavigationAgent2D::set_velocity(Vector2 p_velocity) {
target_velocity = p_velocity;
- Navigation2DServer::get_singleton()->agent_set_target_velocity(agent, target_velocity);
- Navigation2DServer::get_singleton()->agent_set_velocity(agent, prev_safe_velocity);
+ NavigationServer2D::get_singleton()->agent_set_target_velocity(agent, target_velocity);
+ NavigationServer2D::get_singleton()->agent_set_velocity(agent, prev_safe_velocity);
velocity_submitted = true;
}
@@ -298,7 +298,7 @@ void NavigationAgent2D::update_navigation() {
bool reload_path = false;
- if (Navigation2DServer::get_singleton()->agent_is_map_changed(agent)) {
+ if (NavigationServer2D::get_singleton()->agent_is_map_changed(agent)) {
reload_path = true;
} else if (navigation_path.size() == 0) {
reload_path = true;
@@ -317,7 +317,7 @@ void NavigationAgent2D::update_navigation() {
}
if (reload_path) {
- navigation_path = Navigation2DServer::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true);
+ navigation_path = NavigationServer2D::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true);
navigation_finished = false;
nav_path_index = 0;
emit_signal("path_changed");
diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp
index cc9f5740a9..4c6e777e73 100644
--- a/scene/2d/navigation_obstacle_2d.cpp
+++ b/scene/2d/navigation_obstacle_2d.cpp
@@ -33,7 +33,7 @@
#include "scene/2d/collision_shape_2d.h"
#include "scene/2d/navigation_2d.h"
#include "scene/2d/physics_body_2d.h"
-#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server_2d.h"
void NavigationObstacle2D::_bind_methods() {
@@ -71,7 +71,7 @@ void NavigationObstacle2D::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
Node2D *node = Object::cast_to<Node2D>(get_parent());
if (node) {
- Navigation2DServer::get_singleton()->agent_set_position(agent, node->get_global_transform().get_origin());
+ NavigationServer2D::get_singleton()->agent_set_position(agent, node->get_global_transform().get_origin());
}
} break;
@@ -81,11 +81,11 @@ void NavigationObstacle2D::_notification(int p_what) {
NavigationObstacle2D::NavigationObstacle2D() :
navigation(NULL),
agent(RID()) {
- agent = Navigation2DServer::get_singleton()->agent_create();
+ agent = NavigationServer2D::get_singleton()->agent_create();
}
NavigationObstacle2D::~NavigationObstacle2D() {
- Navigation2DServer::get_singleton()->free(agent);
+ NavigationServer2D::get_singleton()->free(agent);
agent = RID(); // Pointless
}
@@ -94,7 +94,7 @@ void NavigationObstacle2D::set_navigation(Navigation2D *p_nav) {
return; // Pointless
navigation = p_nav;
- Navigation2DServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
+ NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
}
void NavigationObstacle2D::set_navigation_node(Node *p_nav) {
@@ -146,9 +146,9 @@ void NavigationObstacle2D::update_agent_shape() {
radius = 1.0; // Never a 0 radius
// Initialize the Agent as an object
- Navigation2DServer::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
- Navigation2DServer::get_singleton()->agent_set_max_neighbors(agent, 0);
- Navigation2DServer::get_singleton()->agent_set_time_horizon(agent, 0.0);
- Navigation2DServer::get_singleton()->agent_set_radius(agent, radius);
- Navigation2DServer::get_singleton()->agent_set_max_speed(agent, 0.0);
+ NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
+ NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, 0);
+ NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, 0.0);
+ NavigationServer2D::get_singleton()->agent_set_radius(agent, radius);
+ NavigationServer2D::get_singleton()->agent_set_max_speed(agent, 0.0);
}
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_region_2d.cpp
index 9159ef21c5..f0839b4597 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_polygon.cpp */
+/* navigation_region_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "navigation_polygon.h"
+#include "navigation_region_2d.h"
#include "core/core_string_names.h"
#include "core/engine.h"
#include "core/os/mutex.h"
#include "navigation_2d.h"
-#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server_2d.h"
#include "thirdparty/misc/triangulator.h"
@@ -385,12 +385,12 @@ void NavigationRegion2D::set_enabled(bool p_enabled) {
if (!enabled) {
- Navigation2DServer::get_singleton()->region_set_map(region, RID());
+ NavigationServer2D::get_singleton()->region_set_map(region, RID());
} else {
if (navigation) {
- Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid());
}
}
@@ -429,7 +429,7 @@ void NavigationRegion2D::_notification(int p_what) {
if (enabled) {
- Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid());
}
break;
}
@@ -440,14 +440,14 @@ void NavigationRegion2D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- Navigation2DServer::get_singleton()->region_set_transform(region, get_global_transform());
+ NavigationServer2D::get_singleton()->region_set_transform(region, get_global_transform());
} break;
case NOTIFICATION_EXIT_TREE: {
if (navigation) {
- Navigation2DServer::get_singleton()->region_set_map(region, RID());
+ NavigationServer2D::get_singleton()->region_set_map(region, RID());
}
navigation = NULL;
} break;
@@ -494,7 +494,7 @@ void NavigationRegion2D::_notification(int p_what) {
}
}
}
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, vertices, colors);
+ RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, vertices, colors);
}
} break;
}
@@ -511,7 +511,7 @@ void NavigationRegion2D::set_navigation_polygon(const Ref<NavigationPolygon> &p_
}
navpoly = p_navpoly;
- Navigation2DServer::get_singleton()->region_set_navpoly(region, p_navpoly);
+ NavigationServer2D::get_singleton()->region_set_navpoly(region, p_navpoly);
if (navpoly.is_valid()) {
navpoly->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NavigationRegion2D::_navpoly_changed));
@@ -572,11 +572,11 @@ NavigationRegion2D::NavigationRegion2D() {
enabled = true;
set_notify_transform(true);
- region = Navigation2DServer::get_singleton()->region_create();
+ region = NavigationServer2D::get_singleton()->region_create();
navigation = NULL;
}
NavigationRegion2D::~NavigationRegion2D() {
- Navigation2DServer::get_singleton()->free(region);
+ NavigationServer2D::get_singleton()->free(region);
}
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_region_2d.h
index 3d096ec91b..73e056a353 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_region_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_polygon.h */
+/* navigation_region_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NAVIGATION_POLYGON_H
-#define NAVIGATION_POLYGON_H
+#ifndef NAVIGATION_REGION_2D_H
+#define NAVIGATION_REGION_2D_H
#include "scene/2d/node_2d.h"
#include "scene/resources/navigation_mesh.h"
@@ -127,4 +127,4 @@ public:
~NavigationRegion2D();
};
-#endif // NAVIGATIONPOLYGON_H
+#endif // NAVIGATION_REGION_2D_H
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index df21538609..ac8a77b6cb 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -32,8 +32,8 @@
#include "core/message_queue.h"
#include "scene/gui/control.h"
-#include "scene/main/viewport.h"
-#include "servers/visual_server.h"
+#include "scene/main/window.h"
+#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
@@ -136,7 +136,7 @@ void Node2D::_update_transform() {
_mat.set_rotation_and_scale(angle, _scale);
_mat.elements[2] = pos;
- VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
+ RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
if (!is_inside_tree())
return;
@@ -315,7 +315,7 @@ void Node2D::set_transform(const Transform2D &p_transform) {
_mat = p_transform;
_xform_dirty = true;
- VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
+ RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
if (!is_inside_tree())
return;
@@ -334,10 +334,10 @@ void Node2D::set_global_transform(const Transform2D &p_transform) {
void Node2D::set_z_index(int p_z) {
- ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN);
- ERR_FAIL_COND(p_z > VS::CANVAS_ITEM_Z_MAX);
+ ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN);
+ ERR_FAIL_COND(p_z > RS::CANVAS_ITEM_Z_MAX);
z_index = p_z;
- VS::get_singleton()->canvas_item_set_z_index(get_canvas_item(), z_index);
+ RS::get_singleton()->canvas_item_set_z_index(get_canvas_item(), z_index);
_change_notify("z_index");
}
@@ -346,7 +346,7 @@ void Node2D::set_z_as_relative(bool p_enabled) {
if (z_relative == p_enabled)
return;
z_relative = p_enabled;
- VS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(), p_enabled);
+ RS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(), p_enabled);
}
bool Node2D::is_z_relative() const {
@@ -452,7 +452,7 @@ void Node2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform");
ADD_GROUP("Z Index", "");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "z_as_relative"), "set_z_as_relative", "is_z_relative");
}
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 00202481a6..abed05ed0c 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -31,7 +31,7 @@
#ifndef NODE2D_H
#define NODE2D_H
-#include "scene/2d/canvas_item.h"
+#include "scene/main/canvas_item.h"
class Node2D : public CanvasItem {
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 5aea1025ef..181f0f158c 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -78,7 +78,7 @@ void ParallaxLayer::_update_mirroring() {
RID c = pb->get_canvas();
RID ci = get_canvas_item();
Point2 mirrorScale = mirroring * get_scale();
- VisualServer::get_singleton()->canvas_set_item_mirroring(c, ci, mirrorScale);
+ RenderingServer::get_singleton()->canvas_set_item_mirroring(c, ci, mirrorScale);
}
}
diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp
deleted file mode 100644
index 590f70a1b2..0000000000
--- a/scene/2d/path_texture.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*************************************************************************/
-/* path_texture.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "path_texture.h"
-
-void PathTexture::set_begin_texture(const Ref<Texture2D> &p_texture) {
-
- begin = p_texture;
- update();
-}
-
-Ref<Texture2D> PathTexture::get_begin_texture() const {
-
- return begin;
-}
-
-void PathTexture::set_repeat_texture(const Ref<Texture2D> &p_texture) {
-
- repeat = p_texture;
- update();
-}
-Ref<Texture2D> PathTexture::get_repeat_texture() const {
-
- return repeat;
-}
-
-void PathTexture::set_end_texture(const Ref<Texture2D> &p_texture) {
-
- end = p_texture;
- update();
-}
-Ref<Texture2D> PathTexture::get_end_texture() const {
-
- return end;
-}
-
-void PathTexture::set_subdivisions(int p_amount) {
-
- ERR_FAIL_INDEX(p_amount, 32);
- subdivs = p_amount;
- update();
-}
-
-int PathTexture::get_subdivisions() const {
-
- return subdivs;
-}
-
-void PathTexture::set_overlap(int p_amount) {
-
- overlap = p_amount;
- update();
-}
-int PathTexture::get_overlap() const {
-
- return overlap;
-}
-
-PathTexture::PathTexture() {
-
- overlap = 0;
- subdivs = 1;
-}
diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h
deleted file mode 100644
index 014d0dc959..0000000000
--- a/scene/2d/path_texture.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************/
-/* path_texture.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef PATH_TEXTURE_H
-#define PATH_TEXTURE_H
-
-#include "scene/2d/node_2d.h"
-
-class PathTexture : public Node2D {
- GDCLASS(PathTexture, Node2D);
-
- Ref<Texture2D> begin;
- Ref<Texture2D> repeat;
- Ref<Texture2D> end;
- int subdivs;
- bool overlap;
-
-public:
- void set_begin_texture(const Ref<Texture2D> &p_texture);
- Ref<Texture2D> get_begin_texture() const;
-
- void set_repeat_texture(const Ref<Texture2D> &p_texture);
- Ref<Texture2D> get_repeat_texture() const;
-
- void set_end_texture(const Ref<Texture2D> &p_texture);
- Ref<Texture2D> get_end_texture() const;
-
- void set_subdivisions(int p_amount);
- int get_subdivisions() const;
-
- void set_overlap(int p_amount);
- int get_overlap() const;
-
- PathTexture();
-};
-
-#endif // PATH_TEXTURE_H
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 9bfeca7e56..942d2aac24 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -82,7 +82,7 @@ void PhysicsBody2D::_bind_methods() {
void PhysicsBody2D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- Physics2DServer::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
+ PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
}
uint32_t PhysicsBody2D::get_collision_layer() const {
@@ -93,7 +93,7 @@ uint32_t PhysicsBody2D::get_collision_layer() const {
void PhysicsBody2D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- Physics2DServer::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
+ PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody2D::get_collision_mask() const {
@@ -130,10 +130,10 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
-PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) :
- CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) {
+PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) :
+ CollisionObject2D(PhysicsServer2D::get_singleton()->body_create(), false) {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), p_mode);
collision_layer = 1;
collision_mask = 1;
set_pickable(false);
@@ -141,11 +141,11 @@ PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) :
Array PhysicsBody2D::get_collision_exceptions() {
List<RID> exceptions;
- Physics2DServer::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions);
+ PhysicsServer2D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions);
Array ret;
for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) {
RID body = E->get();
- ObjectID instance_id = Physics2DServer::get_singleton()->body_get_object_instance_id(body);
+ ObjectID instance_id = PhysicsServer2D::get_singleton()->body_get_object_instance_id(body);
Object *obj = ObjectDB::get_instance(instance_id);
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(obj);
ret.append(physics_body);
@@ -158,7 +158,7 @@ void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody type.");
- Physics2DServer::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid());
+ PhysicsServer2D::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid());
}
void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
@@ -166,19 +166,19 @@ void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody type.");
- Physics2DServer::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid());
+ PhysicsServer2D::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid());
}
void StaticBody2D::set_constant_linear_velocity(const Vector2 &p_vel) {
constant_linear_velocity = p_vel;
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
void StaticBody2D::set_constant_angular_velocity(real_t p_vel) {
constant_angular_velocity = p_vel;
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector2 StaticBody2D::get_constant_linear_velocity() const {
@@ -225,7 +225,7 @@ void StaticBody2D::_bind_methods() {
}
StaticBody2D::StaticBody2D() :
- PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) {
+ PhysicsBody2D(PhysicsServer2D::BODY_MODE_STATIC) {
constant_angular_velocity = 0;
}
@@ -235,11 +235,11 @@ StaticBody2D::~StaticBody2D() {
void StaticBody2D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, 0);
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, 1);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1);
} else {
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
@@ -360,20 +360,20 @@ struct _RigidBody2DInOut {
int local_shape;
};
-bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) {
+bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
- Physics2DServer::MotionResult *r = NULL;
+ PhysicsServer2D::MotionResult *r = NULL;
if (p_result.is_valid())
r = p_result->get_result_ptr();
- return Physics2DServer::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r);
+ return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r);
}
void RigidBody2D::_direct_state_changed(Object *p_state) {
#ifdef DEBUG_ENABLED
- state = Object::cast_to<Physics2DDirectBodyState>(p_state);
+ state = Object::cast_to<PhysicsDirectBodyState2D>(p_state);
#else
- state = (Physics2DDirectBodyState *)p_state; //trust it
+ state = (PhysicsDirectBodyState2D *)p_state; //trust it
#endif
set_block_transform_notify(true); // don't want notify (would feedback loop)
@@ -484,20 +484,20 @@ void RigidBody2D::set_mode(Mode p_mode) {
case MODE_RIGID: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_RIGID);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_RIGID);
} break;
case MODE_STATIC: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_STATIC);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_STATIC);
} break;
case MODE_KINEMATIC: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_KINEMATIC);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_KINEMATIC);
} break;
case MODE_CHARACTER: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_CHARACTER);
+ PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_CHARACTER);
} break;
}
@@ -514,7 +514,7 @@ void RigidBody2D::set_mass(real_t p_mass) {
mass = p_mass;
_change_notify("mass");
_change_notify("weight");
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_MASS, mass);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass);
}
real_t RigidBody2D::get_mass() const {
@@ -524,12 +524,12 @@ real_t RigidBody2D::get_mass() const {
void RigidBody2D::set_inertia(real_t p_inertia) {
ERR_FAIL_COND(p_inertia < 0);
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_INERTIA, p_inertia);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, p_inertia);
}
real_t RigidBody2D::get_inertia() const {
- return Physics2DServer::get_singleton()->body_get_param(get_rid(), Physics2DServer::BODY_PARAM_INERTIA);
+ return PhysicsServer2D::get_singleton()->body_get_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA);
}
void RigidBody2D::set_weight(real_t p_weight) {
@@ -564,7 +564,7 @@ Ref<PhysicsMaterial> RigidBody2D::get_physics_material_override() const {
void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale;
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
real_t RigidBody2D::get_gravity_scale() const {
@@ -575,7 +575,7 @@ void RigidBody2D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < -1);
linear_damp = p_linear_damp;
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_LINEAR_DAMP, linear_damp);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
real_t RigidBody2D::get_linear_damp() const {
@@ -586,7 +586,7 @@ void RigidBody2D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < -1);
angular_damp = p_angular_damp;
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_ANGULAR_DAMP, angular_damp);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
real_t RigidBody2D::get_angular_damp() const {
@@ -602,7 +602,7 @@ void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) {
if (state) {
set_linear_velocity(v);
} else {
- Physics2DServer::get_singleton()->body_set_axis_velocity(get_rid(), p_axis);
+ PhysicsServer2D::get_singleton()->body_set_axis_velocity(get_rid(), p_axis);
linear_velocity = v;
}
}
@@ -614,7 +614,7 @@ void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) {
state->set_linear_velocity(linear_velocity);
else {
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
}
@@ -629,7 +629,7 @@ void RigidBody2D::set_angular_velocity(real_t p_velocity) {
if (state)
state->set_angular_velocity(angular_velocity);
else
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
real_t RigidBody2D::get_angular_velocity() const {
@@ -642,7 +642,7 @@ void RigidBody2D::set_use_custom_integrator(bool p_enable) {
return;
custom_integrator = p_enable;
- Physics2DServer::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
+ PhysicsServer2D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
}
bool RigidBody2D::is_using_custom_integrator() {
@@ -652,13 +652,13 @@ bool RigidBody2D::is_using_custom_integrator() {
void RigidBody2D::set_sleeping(bool p_sleeping) {
sleeping = p_sleeping;
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_SLEEPING, sleeping);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody2D::set_can_sleep(bool p_active) {
can_sleep = p_active;
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_CAN_SLEEP, p_active);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody2D::is_able_to_sleep() const {
@@ -674,7 +674,7 @@ bool RigidBody2D::is_sleeping() const {
void RigidBody2D::set_max_contacts_reported(int p_amount) {
max_contacts_reported = p_amount;
- Physics2DServer::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
+ PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
int RigidBody2D::get_max_contacts_reported() const {
@@ -683,55 +683,55 @@ int RigidBody2D::get_max_contacts_reported() const {
}
void RigidBody2D::apply_central_impulse(const Vector2 &p_impulse) {
- Physics2DServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
+ PhysicsServer2D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
}
void RigidBody2D::apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) {
- Physics2DServer::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse);
+ PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse);
}
void RigidBody2D::apply_torque_impulse(float p_torque) {
- Physics2DServer::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque);
+ PhysicsServer2D::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque);
}
void RigidBody2D::set_applied_force(const Vector2 &p_force) {
- Physics2DServer::get_singleton()->body_set_applied_force(get_rid(), p_force);
+ PhysicsServer2D::get_singleton()->body_set_applied_force(get_rid(), p_force);
};
Vector2 RigidBody2D::get_applied_force() const {
- return Physics2DServer::get_singleton()->body_get_applied_force(get_rid());
+ return PhysicsServer2D::get_singleton()->body_get_applied_force(get_rid());
};
void RigidBody2D::set_applied_torque(const float p_torque) {
- Physics2DServer::get_singleton()->body_set_applied_torque(get_rid(), p_torque);
+ PhysicsServer2D::get_singleton()->body_set_applied_torque(get_rid(), p_torque);
};
float RigidBody2D::get_applied_torque() const {
- return Physics2DServer::get_singleton()->body_get_applied_torque(get_rid());
+ return PhysicsServer2D::get_singleton()->body_get_applied_torque(get_rid());
};
void RigidBody2D::add_central_force(const Vector2 &p_force) {
- Physics2DServer::get_singleton()->body_add_central_force(get_rid(), p_force);
+ PhysicsServer2D::get_singleton()->body_add_central_force(get_rid(), p_force);
}
void RigidBody2D::add_force(const Vector2 &p_offset, const Vector2 &p_force) {
- Physics2DServer::get_singleton()->body_add_force(get_rid(), p_offset, p_force);
+ PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_offset, p_force);
}
void RigidBody2D::add_torque(const float p_torque) {
- Physics2DServer::get_singleton()->body_add_torque(get_rid(), p_torque);
+ PhysicsServer2D::get_singleton()->body_add_torque(get_rid(), p_torque);
}
void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) {
ccd_mode = p_mode;
- Physics2DServer::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), Physics2DServer::CCDMode(p_mode));
+ PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode));
}
RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const {
@@ -898,7 +898,7 @@ void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody2D::get_colliding_bodies);
- BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "Physics2DDirectBodyState")));
+ BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectBodyState2D")));
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), "set_mode", "get_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass");
@@ -939,7 +939,7 @@ void RigidBody2D::_bind_methods() {
}
RigidBody2D::RigidBody2D() :
- PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) {
+ PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) {
mode = MODE_RIGID;
@@ -960,7 +960,7 @@ RigidBody2D::RigidBody2D() :
contact_monitor = NULL;
can_sleep = true;
- Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
}
RigidBody2D::~RigidBody2D() {
@@ -971,11 +971,11 @@ RigidBody2D::~RigidBody2D() {
void RigidBody2D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, 0);
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, 1);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1);
} else {
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
@@ -1001,12 +1001,12 @@ Ref<KinematicCollision2D> KinematicBody2D::_move(const Vector2 &p_motion, bool p
bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) {
- Physics2DServer::SeparationResult sep_res[8]; //max 8 rays
+ PhysicsServer2D::SeparationResult sep_res[8]; //max 8 rays
Transform2D gt = get_global_transform();
Vector2 recover;
- int hits = Physics2DServer::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
+ int hits = PhysicsServer2D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
int deepest = -1;
float deepest_depth;
for (int i = 0; i < hits; i++) {
@@ -1042,8 +1042,8 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_
ERR_PRINT("Functions move_and_slide and move_and_collide do not work together with 'sync to physics' option. Please read the documentation.");
}
Transform2D gt = get_global_transform();
- Physics2DServer::MotionResult result;
- bool colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, margin, &result, p_exclude_raycast_shapes);
+ PhysicsServer2D::MotionResult result;
+ bool colliding = PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, margin, &result, p_exclude_raycast_shapes);
if (colliding) {
r_collision.collider_metadata = result.collider_metadata;
@@ -1077,7 +1077,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
Vector2 current_floor_velocity = floor_velocity;
if (on_floor && on_floor_body.is_valid()) {
//this approach makes sure there is less delay between the actual body velocity and the one we saved
- Physics2DDirectBodyState *bs = Physics2DServer::get_singleton()->body_get_direct_state(on_floor_body);
+ PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(on_floor_body);
if (bs) {
current_floor_velocity = bs->get_linear_velocity();
}
@@ -1227,7 +1227,7 @@ bool KinematicBody2D::test_move(const Transform2D &p_from, const Vector2 &p_moti
ERR_FAIL_COND_V(!is_inside_tree(), false);
- return Physics2DServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin);
+ return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin);
}
void KinematicBody2D::set_safe_margin(float p_margin) {
@@ -1277,11 +1277,11 @@ void KinematicBody2D::set_sync_to_physics(bool p_enable) {
return;
if (p_enable) {
- Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
set_only_update_transform_changes(true);
set_notify_local_transform(true);
} else {
- Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, "");
+ PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, "");
set_only_update_transform_changes(false);
set_notify_local_transform(false);
}
@@ -1296,7 +1296,7 @@ void KinematicBody2D::_direct_state_changed(Object *p_state) {
if (!sync_to_physics)
return;
- Physics2DDirectBodyState *state = Object::cast_to<Physics2DDirectBodyState>(p_state);
+ PhysicsDirectBodyState2D *state = Object::cast_to<PhysicsDirectBodyState2D>(p_state);
last_valid_transform = state->get_transform();
set_notify_local_transform(false);
@@ -1320,7 +1320,7 @@ void KinematicBody2D::_notification(int p_what) {
if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
//used by sync to physics, send the new transform to the physics
Transform2D new_transform = get_global_transform();
- Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_TRANSFORM, new_transform);
+ PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform);
//but then revert changes
set_notify_local_transform(false);
set_global_transform(last_valid_transform);
@@ -1357,7 +1357,7 @@ void KinematicBody2D::_bind_methods() {
}
KinematicBody2D::KinematicBody2D() :
- PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC) {
+ PhysicsBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
margin = 0.08;
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index eb7aefb495..0d92a820e3 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -34,7 +34,7 @@
#include "core/vset.h"
#include "scene/2d/collision_object_2d.h"
#include "scene/resources/physics_material.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
class KinematicCollision2D;
@@ -50,7 +50,7 @@ class PhysicsBody2D : public CollisionObject2D {
protected:
void _notification(int p_what);
- PhysicsBody2D(Physics2DServer::BodyMode p_mode);
+ PhysicsBody2D(PhysicsServer2D::BodyMode p_mode);
static void _bind_methods();
@@ -123,7 +123,7 @@ public:
private:
bool can_sleep;
- Physics2DDirectBodyState *state;
+ PhysicsDirectBodyState2D *state;
Mode mode;
real_t mass;
@@ -185,7 +185,7 @@ private:
void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
void _direct_state_changed(Object *p_state);
- bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
+ bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
protected:
void _notification(int p_what);
@@ -303,7 +303,7 @@ private:
Vector<Ref<KinematicCollision2D>> slide_colliders;
Ref<KinematicCollision2D> motion_cache;
- _FORCE_INLINE_ bool _ignores_mode(Physics2DServer::BodyMode) const;
+ _FORCE_INLINE_ bool _ignores_mode(PhysicsServer2D::BodyMode) const;
Ref<KinematicCollision2D> _move(const Vector2 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, bool p_test_only = false);
Ref<KinematicCollision2D> _get_slide_collision(int p_bounce);
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 95656b9610..8d20053c6e 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -111,10 +111,10 @@ void Polygon2D::_notification(int p_what) {
ObjectID new_skeleton_id;
if (skeleton_node) {
- VS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), skeleton_node->get_skeleton());
+ RS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), skeleton_node->get_skeleton());
new_skeleton_id = skeleton_node->get_instance_id();
} else {
- VS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), RID());
+ RS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), RID());
}
if (new_skeleton_id != current_skeleton_id) {
@@ -307,7 +307,7 @@ void Polygon2D::_notification(int p_what) {
if (invert || polygons.size() == 0) {
Vector<int> indices = Geometry::triangulate_polygon(points);
if (indices.size()) {
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess));
+ RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess));
}
} else {
//draw individual polygons
@@ -341,7 +341,7 @@ void Polygon2D::_notification(int p_what) {
}
if (total_indices.size()) {
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID());
+ RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID());
}
}
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index fd6e0aebcc..ed971b1c3a 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -33,7 +33,7 @@
#include "collision_object_2d.h"
#include "core/engine.h"
#include "physics_body_2d.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
void RayCast2D::set_cast_to(const Vector2 &p_point) {
@@ -205,7 +205,7 @@ void RayCast2D::_update_raycast_state() {
Ref<World2D> w2d = get_world_2d();
ERR_FAIL_COND(w2d.is_null());
- Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
+ PhysicsDirectSpaceState2D *dss = PhysicsServer2D::get_singleton()->space_get_direct_state(w2d->get_space());
ERR_FAIL_COND(!dss);
Transform2D gt = get_global_transform();
@@ -214,7 +214,7 @@ void RayCast2D::_update_raycast_state() {
if (to == Vector2())
to = Vector2(0, 0.01);
- Physics2DDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState2D::RayResult rr;
if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) {
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp
index 9ebaf23c3a..2be6b6a75c 100644
--- a/scene/2d/skeleton_2d.cpp
+++ b/scene/2d/skeleton_2d.cpp
@@ -186,7 +186,7 @@ void Skeleton2D::_update_bone_setup() {
return;
bone_setup_dirty = false;
- VS::get_singleton()->skeleton_allocate(skeleton, bones.size(), true);
+ RS::get_singleton()->skeleton_allocate(skeleton, bones.size(), true);
bones.sort(); //sorty so they are always in the same order/index
@@ -240,7 +240,7 @@ void Skeleton2D::_update_transform() {
for (int i = 0; i < bones.size(); i++) {
Transform2D final_xform = bones[i].accum_transform * bones[i].rest_inverse;
- VS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform);
+ RS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform);
}
}
@@ -276,7 +276,7 @@ void Skeleton2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
- VS::get_singleton()->skeleton_set_base_transform_2d(skeleton, get_global_transform());
+ RS::get_singleton()->skeleton_set_base_transform_2d(skeleton, get_global_transform());
}
}
@@ -300,11 +300,11 @@ Skeleton2D::Skeleton2D() {
bone_setup_dirty = true;
transform_dirty = true;
- skeleton = VS::get_singleton()->skeleton_create();
+ skeleton = RS::get_singleton()->skeleton_create();
set_notify_transform(true);
}
Skeleton2D::~Skeleton2D() {
- VS::get_singleton()->free(skeleton);
+ RS::get_singleton()->free(skeleton);
}
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite_2d.cpp
index 7eaafe5348..df8859bd9a 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sprite.cpp */
+/* sprite_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,57 +28,57 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "sprite.h"
+#include "sprite_2d.h"
#include "core/core_string_names.h"
#include "core/os/os.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
-Dictionary Sprite::_edit_get_state() const {
+Dictionary Sprite2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
return state;
}
-void Sprite::_edit_set_state(const Dictionary &p_state) {
+void Sprite2D::_edit_set_state(const Dictionary &p_state) {
Node2D::_edit_set_state(p_state);
set_offset(p_state["offset"]);
}
-void Sprite::_edit_set_pivot(const Point2 &p_pivot) {
+void Sprite2D::_edit_set_pivot(const Point2 &p_pivot) {
set_offset(get_offset() - p_pivot);
set_position(get_transform().xform(p_pivot));
}
-Point2 Sprite::_edit_get_pivot() const {
+Point2 Sprite2D::_edit_get_pivot() const {
return Vector2();
}
-bool Sprite::_edit_use_pivot() const {
+bool Sprite2D::_edit_use_pivot() const {
return true;
}
-bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
+bool Sprite2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return is_pixel_opaque(p_point);
}
-Rect2 Sprite::_edit_get_rect() const {
+Rect2 Sprite2D::_edit_get_rect() const {
return get_rect();
}
-bool Sprite::_edit_use_rect() const {
+bool Sprite2D::_edit_use_rect() const {
return texture.is_valid();
}
#endif
-Rect2 Sprite::get_anchorable_rect() const {
+Rect2 Sprite2D::get_anchorable_rect() const {
return get_rect();
}
-void Sprite::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const {
+void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const {
Rect2 base_rect;
@@ -112,7 +112,7 @@ void Sprite::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_cli
r_dst_rect.size.y = -r_dst_rect.size.y;
}
-void Sprite::_notification(int p_what) {
+void Sprite2D::_notification(int p_what) {
switch (p_what) {
@@ -131,24 +131,24 @@ void Sprite::_notification(int p_what) {
Rect2 src_rect, dst_rect;
bool filter_clip;
_get_rects(src_rect, dst_rect, filter_clip);
- texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess), VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, filter_clip);
+ texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, filter_clip);
} break;
}
}
-void Sprite::set_texture(const Ref<Texture2D> &p_texture) {
+void Sprite2D::set_texture(const Ref<Texture2D> &p_texture) {
if (p_texture == texture)
return;
if (texture.is_valid())
- texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite::_texture_changed));
+ texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed));
texture = p_texture;
if (texture.is_valid())
- texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite::_texture_changed));
+ texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed));
update();
emit_signal("texture_changed");
@@ -156,96 +156,96 @@ void Sprite::set_texture(const Ref<Texture2D> &p_texture) {
_change_notify("texture");
}
-void Sprite::set_normal_map(const Ref<Texture2D> &p_texture) {
+void Sprite2D::set_normal_map(const Ref<Texture2D> &p_texture) {
normal_map = p_texture;
update();
}
-Ref<Texture2D> Sprite::get_normal_map() const {
+Ref<Texture2D> Sprite2D::get_normal_map() const {
return normal_map;
}
-void Sprite::set_specular_map(const Ref<Texture2D> &p_texture) {
+void Sprite2D::set_specular_map(const Ref<Texture2D> &p_texture) {
specular = p_texture;
update();
}
-Ref<Texture2D> Sprite::get_specular_map() const {
+Ref<Texture2D> Sprite2D::get_specular_map() const {
return specular;
}
-void Sprite::set_specular_color(const Color &p_color) {
+void Sprite2D::set_specular_color(const Color &p_color) {
specular_color = p_color;
update();
}
-Color Sprite::get_specular_color() const {
+Color Sprite2D::get_specular_color() const {
return specular_color;
}
-void Sprite::set_shininess(float p_shininess) {
+void Sprite2D::set_shininess(float p_shininess) {
shininess = CLAMP(p_shininess, 0.0, 1.0);
update();
}
-float Sprite::get_shininess() const {
+float Sprite2D::get_shininess() const {
return shininess;
}
-Ref<Texture2D> Sprite::get_texture() const {
+Ref<Texture2D> Sprite2D::get_texture() const {
return texture;
}
-void Sprite::set_centered(bool p_center) {
+void Sprite2D::set_centered(bool p_center) {
centered = p_center;
update();
item_rect_changed();
}
-bool Sprite::is_centered() const {
+bool Sprite2D::is_centered() const {
return centered;
}
-void Sprite::set_offset(const Point2 &p_offset) {
+void Sprite2D::set_offset(const Point2 &p_offset) {
offset = p_offset;
update();
item_rect_changed();
_change_notify("offset");
}
-Point2 Sprite::get_offset() const {
+Point2 Sprite2D::get_offset() const {
return offset;
}
-void Sprite::set_flip_h(bool p_flip) {
+void Sprite2D::set_flip_h(bool p_flip) {
hflip = p_flip;
update();
}
-bool Sprite::is_flipped_h() const {
+bool Sprite2D::is_flipped_h() const {
return hflip;
}
-void Sprite::set_flip_v(bool p_flip) {
+void Sprite2D::set_flip_v(bool p_flip) {
vflip = p_flip;
update();
}
-bool Sprite::is_flipped_v() const {
+bool Sprite2D::is_flipped_v() const {
return vflip;
}
-void Sprite::set_region(bool p_region) {
+void Sprite2D::set_region(bool p_region) {
if (p_region == region)
return;
@@ -254,12 +254,12 @@ void Sprite::set_region(bool p_region) {
update();
}
-bool Sprite::is_region() const {
+bool Sprite2D::is_region() const {
return region;
}
-void Sprite::set_region_rect(const Rect2 &p_region_rect) {
+void Sprite2D::set_region_rect(const Rect2 &p_region_rect) {
if (region_rect == p_region_rect)
return;
@@ -272,21 +272,21 @@ void Sprite::set_region_rect(const Rect2 &p_region_rect) {
_change_notify("region_rect");
}
-Rect2 Sprite::get_region_rect() const {
+Rect2 Sprite2D::get_region_rect() const {
return region_rect;
}
-void Sprite::set_region_filter_clip(bool p_enable) {
+void Sprite2D::set_region_filter_clip(bool p_enable) {
region_filter_clip = p_enable;
update();
}
-bool Sprite::is_region_filter_clip_enabled() const {
+bool Sprite2D::is_region_filter_clip_enabled() const {
return region_filter_clip;
}
-void Sprite::set_frame(int p_frame) {
+void Sprite2D::set_frame(int p_frame) {
ERR_FAIL_INDEX(p_frame, vframes * hframes);
@@ -300,23 +300,23 @@ void Sprite::set_frame(int p_frame) {
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
-int Sprite::get_frame() const {
+int Sprite2D::get_frame() const {
return frame;
}
-void Sprite::set_frame_coords(const Vector2 &p_coord) {
+void Sprite2D::set_frame_coords(const Vector2 &p_coord) {
ERR_FAIL_INDEX(int(p_coord.x), hframes);
ERR_FAIL_INDEX(int(p_coord.y), vframes);
set_frame(int(p_coord.y) * hframes + int(p_coord.x));
}
-Vector2 Sprite::get_frame_coords() const {
+Vector2 Sprite2D::get_frame_coords() const {
return Vector2(frame % hframes, frame / hframes);
}
-void Sprite::set_vframes(int p_amount) {
+void Sprite2D::set_vframes(int p_amount) {
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of vframes cannot be smaller than 1.");
vframes = p_amount;
@@ -324,12 +324,12 @@ void Sprite::set_vframes(int p_amount) {
item_rect_changed();
_change_notify();
}
-int Sprite::get_vframes() const {
+int Sprite2D::get_vframes() const {
return vframes;
}
-void Sprite::set_hframes(int p_amount) {
+void Sprite2D::set_hframes(int p_amount) {
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of hframes cannot be smaller than 1.");
hframes = p_amount;
@@ -337,12 +337,12 @@ void Sprite::set_hframes(int p_amount) {
item_rect_changed();
_change_notify();
}
-int Sprite::get_hframes() const {
+int Sprite2D::get_hframes() const {
return hframes;
}
-bool Sprite::is_pixel_opaque(const Point2 &p_point) const {
+bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const {
if (texture.is_null())
return false;
@@ -392,7 +392,7 @@ bool Sprite::is_pixel_opaque(const Point2 &p_point) const {
return texture->is_pixel_opaque((int)q.x, (int)q.y);
}
-Rect2 Sprite::get_rect() const {
+Rect2 Sprite2D::get_rect() const {
if (texture.is_null())
return Rect2(0, 0, 1, 1);
@@ -417,7 +417,7 @@ Rect2 Sprite::get_rect() const {
return Rect2(ofs, s);
}
-void Sprite::_validate_property(PropertyInfo &property) const {
+void Sprite2D::_validate_property(PropertyInfo &property) const {
if (property.name == "frame") {
property.hint = PROPERTY_HINT_RANGE;
@@ -430,7 +430,7 @@ void Sprite::_validate_property(PropertyInfo &property) const {
}
}
-void Sprite::_texture_changed() {
+void Sprite2D::_texture_changed() {
// Changes to the texture need to trigger an update to make
// the editor redraw the sprite with the updated texture.
@@ -439,59 +439,59 @@ void Sprite::_texture_changed() {
}
}
-void Sprite::_bind_methods() {
+void Sprite2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite::set_texture);
- ClassDB::bind_method(D_METHOD("get_texture"), &Sprite::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture"), &Sprite2D::get_texture);
- ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &Sprite::set_normal_map);
- ClassDB::bind_method(D_METHOD("get_normal_map"), &Sprite::get_normal_map);
+ ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &Sprite2D::set_normal_map);
+ ClassDB::bind_method(D_METHOD("get_normal_map"), &Sprite2D::get_normal_map);
- ClassDB::bind_method(D_METHOD("set_specular_map", "specular_map"), &Sprite::set_specular_map);
- ClassDB::bind_method(D_METHOD("get_specular_map"), &Sprite::get_specular_map);
+ ClassDB::bind_method(D_METHOD("set_specular_map", "specular_map"), &Sprite2D::set_specular_map);
+ ClassDB::bind_method(D_METHOD("get_specular_map"), &Sprite2D::get_specular_map);
- ClassDB::bind_method(D_METHOD("set_specular_color", "specular_color"), &Sprite::set_specular_color);
- ClassDB::bind_method(D_METHOD("get_specular_color"), &Sprite::get_specular_color);
+ ClassDB::bind_method(D_METHOD("set_specular_color", "specular_color"), &Sprite2D::set_specular_color);
+ ClassDB::bind_method(D_METHOD("get_specular_color"), &Sprite2D::get_specular_color);
- ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &Sprite::set_shininess);
- ClassDB::bind_method(D_METHOD("get_shininess"), &Sprite::get_shininess);
+ ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &Sprite2D::set_shininess);
+ ClassDB::bind_method(D_METHOD("get_shininess"), &Sprite2D::get_shininess);
- ClassDB::bind_method(D_METHOD("set_centered", "centered"), &Sprite::set_centered);
- ClassDB::bind_method(D_METHOD("is_centered"), &Sprite::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered", "centered"), &Sprite2D::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"), &Sprite2D::is_centered);
- ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Sprite::set_offset);
- ClassDB::bind_method(D_METHOD("get_offset"), &Sprite::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Sprite2D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"), &Sprite2D::get_offset);
- ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &Sprite::set_flip_h);
- ClassDB::bind_method(D_METHOD("is_flipped_h"), &Sprite::is_flipped_h);
+ ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &Sprite2D::set_flip_h);
+ ClassDB::bind_method(D_METHOD("is_flipped_h"), &Sprite2D::is_flipped_h);
- ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &Sprite::set_flip_v);
- ClassDB::bind_method(D_METHOD("is_flipped_v"), &Sprite::is_flipped_v);
+ ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &Sprite2D::set_flip_v);
+ ClassDB::bind_method(D_METHOD("is_flipped_v"), &Sprite2D::is_flipped_v);
- ClassDB::bind_method(D_METHOD("set_region", "enabled"), &Sprite::set_region);
- ClassDB::bind_method(D_METHOD("is_region"), &Sprite::is_region);
+ ClassDB::bind_method(D_METHOD("set_region", "enabled"), &Sprite2D::set_region);
+ ClassDB::bind_method(D_METHOD("is_region"), &Sprite2D::is_region);
- ClassDB::bind_method(D_METHOD("is_pixel_opaque", "pos"), &Sprite::is_pixel_opaque);
+ ClassDB::bind_method(D_METHOD("is_pixel_opaque", "pos"), &Sprite2D::is_pixel_opaque);
- ClassDB::bind_method(D_METHOD("set_region_rect", "rect"), &Sprite::set_region_rect);
- ClassDB::bind_method(D_METHOD("get_region_rect"), &Sprite::get_region_rect);
+ ClassDB::bind_method(D_METHOD("set_region_rect", "rect"), &Sprite2D::set_region_rect);
+ ClassDB::bind_method(D_METHOD("get_region_rect"), &Sprite2D::get_region_rect);
- ClassDB::bind_method(D_METHOD("set_region_filter_clip", "enabled"), &Sprite::set_region_filter_clip);
- ClassDB::bind_method(D_METHOD("is_region_filter_clip_enabled"), &Sprite::is_region_filter_clip_enabled);
+ ClassDB::bind_method(D_METHOD("set_region_filter_clip", "enabled"), &Sprite2D::set_region_filter_clip);
+ ClassDB::bind_method(D_METHOD("is_region_filter_clip_enabled"), &Sprite2D::is_region_filter_clip_enabled);
- ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite::set_frame);
- ClassDB::bind_method(D_METHOD("get_frame"), &Sprite::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite2D::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"), &Sprite2D::get_frame);
- ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite::set_frame_coords);
- ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite::get_frame_coords);
+ ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite2D::set_frame_coords);
+ ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite2D::get_frame_coords);
- ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite::set_vframes);
- ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite::get_vframes);
+ ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite2D::set_vframes);
+ ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite2D::get_vframes);
- ClassDB::bind_method(D_METHOD("set_hframes", "hframes"), &Sprite::set_hframes);
- ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite::get_hframes);
+ ClassDB::bind_method(D_METHOD("set_hframes", "hframes"), &Sprite2D::set_hframes);
+ ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite2D::get_hframes);
- ClassDB::bind_method(D_METHOD("get_rect"), &Sprite::get_rect);
+ ClassDB::bind_method(D_METHOD("get_rect"), &Sprite2D::get_rect);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("texture_changed"));
@@ -519,7 +519,7 @@ void Sprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_filter_clip"), "set_region_filter_clip", "is_region_filter_clip_enabled");
}
-Sprite::Sprite() {
+Sprite2D::Sprite2D() {
centered = true;
hflip = false;
@@ -535,5 +535,5 @@ Sprite::Sprite() {
hframes = 1;
}
-Sprite::~Sprite() {
+Sprite2D::~Sprite2D() {
}
diff --git a/scene/2d/sprite.h b/scene/2d/sprite_2d.h
index a96f023231..599a9e937e 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sprite.h */
+/* sprite_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SPRITE_H
-#define SPRITE_H
+#ifndef SPRITE_2D_H
+#define SPRITE_2D_H
#include "scene/2d/node_2d.h"
#include "scene/resources/texture.h"
-class Sprite : public Node2D {
+class Sprite2D : public Node2D {
- GDCLASS(Sprite, Node2D);
+ GDCLASS(Sprite2D, Node2D);
Ref<Texture2D> texture;
Ref<Texture2D> normal_map;
@@ -136,8 +136,8 @@ public:
Rect2 get_rect() const;
virtual Rect2 get_anchorable_rect() const;
- Sprite();
- ~Sprite();
+ Sprite2D();
+ ~Sprite2D();
};
#endif // SPRITE_H
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 601be17274..c468389040 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -35,8 +35,8 @@
#include "core/method_bind_ext.gen.inc"
#include "core/os/os.h"
#include "scene/2d/area_2d.h"
-#include "servers/navigation_2d_server.h"
-#include "servers/physics_2d_server.h"
+#include "servers/navigation_server_2d.h"
+#include "servers/physics_server_2d.h"
int TileMap::_get_quadrant_size() const {
@@ -87,7 +87,7 @@ void TileMap::_notification(int p_what) {
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
- Navigation2DServer::get_singleton()->region_set_map(F->get().region, RID());
+ NavigationServer2D::get_singleton()->region_set_map(F->get().region, RID());
}
q.navpoly_ids.clear();
}
@@ -98,7 +98,7 @@ void TileMap::_notification(int p_what) {
}
for (Map<PosKey, Quadrant::Occluder>::Element *F = q.occluder_instances.front(); F; F = F->next()) {
- VS::get_singleton()->free(F->get().id);
+ RS::get_singleton()->free(F->get().id);
}
q.occluder_instances.clear();
}
@@ -130,7 +130,7 @@ void TileMap::_update_quadrant_space(const RID &p_space) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_space(q.body, p_space);
+ PhysicsServer2D::get_singleton()->body_set_space(q.body, p_space);
}
}
}
@@ -158,18 +158,18 @@ void TileMap::_update_quadrant_transform() {
if (!use_parent) {
xform = global_transform * xform;
- Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ PhysicsServer2D::get_singleton()->body_set_state(q.body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
}
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
- Navigation2DServer::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform);
+ NavigationServer2D::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform);
}
}
for (Map<PosKey, Quadrant::Occluder>::Element *F = q.occluder_instances.front(); F; F = F->next()) {
- VS::get_singleton()->canvas_light_occluder_set_transform(F->get().id, global_transform * F->get().xform);
+ RS::get_singleton()->canvas_light_occluder_set_transform(F->get().id, global_transform * F->get().xform);
}
}
}
@@ -298,7 +298,7 @@ void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const
}
void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> &p_shape, const TileSet::ShapeData &p_shape_data, const Transform2D &p_xform, const Vector2 &p_metadata) {
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
if (!use_parent) {
ps->body_add_shape(p_q.body, p_shape->get_rid(), p_xform);
@@ -334,8 +334,8 @@ void TileMap::update_dirty_quadrants() {
return;
}
- VisualServer *vs = VisualServer::get_singleton();
- Physics2DServer *ps = Physics2DServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
Vector2 tofs = get_cell_draw_offset();
Transform2D nav_rel;
if (navigation)
@@ -378,13 +378,13 @@ void TileMap::update_dirty_quadrants() {
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
- Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID());
+ NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID());
}
q.navpoly_ids.clear();
}
for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
- VS::get_singleton()->free(E->get().id);
+ RS::get_singleton()->free(E->get().id);
}
q.occluder_instances.clear();
Ref<ShaderMaterial> prev_material;
@@ -439,7 +439,7 @@ void TileMap::update_dirty_quadrants() {
debug_canvas_item = vs->canvas_item_create();
vs->canvas_item_set_parent(debug_canvas_item, canvas_item);
vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item, false);
- vs->canvas_item_set_z_index(debug_canvas_item, VS::CANVAS_ITEM_Z_MAX - 1);
+ vs->canvas_item_set_z_index(debug_canvas_item, RS::CANVAS_ITEM_Z_MAX - 1);
q.canvas_items.push_back(debug_canvas_item);
prev_debug_canvas_item = debug_canvas_item;
}
@@ -550,7 +550,7 @@ void TileMap::update_dirty_quadrants() {
if (r == Rect2()) {
tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map);
} else {
- tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, clip_uv);
+ tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, clip_uv);
}
Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id);
@@ -612,10 +612,10 @@ void TileMap::update_dirty_quadrants() {
xform.set_origin(offset.floor() + q.pos);
_fix_cell_transform(xform, c, npoly_ofs, s);
- RID region = Navigation2DServer::get_singleton()->region_create();
- Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid());
- Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform);
- Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly);
+ RID region = NavigationServer2D::get_singleton()->region_create();
+ NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid());
+ NavigationServer2D::get_singleton()->region_set_transform(region, nav_rel * xform);
+ NavigationServer2D::get_singleton()->region_set_navpoly(region, navpoly);
Quadrant::NavPoly np;
np.region = region;
@@ -626,7 +626,7 @@ void TileMap::update_dirty_quadrants() {
RID debug_navigation_item = vs->canvas_item_create();
vs->canvas_item_set_parent(debug_navigation_item, canvas_item);
vs->canvas_item_set_z_as_relative_to_parent(debug_navigation_item, false);
- vs->canvas_item_set_z_index(debug_navigation_item, VS::CANVAS_ITEM_Z_MAX - 2); // Display one below collision debug
+ vs->canvas_item_set_z_index(debug_navigation_item, RS::CANVAS_ITEM_Z_MAX - 2); // Display one below collision debug
if (debug_navigation_item.is_valid()) {
Vector<Vector2> navigation_polygon_vertices = navpoly->get_vertices();
@@ -685,11 +685,11 @@ void TileMap::update_dirty_quadrants() {
xform.set_origin(offset.floor() + q.pos);
_fix_cell_transform(xform, c, occluder_ofs, s);
- RID orid = VS::get_singleton()->canvas_light_occluder_create();
- VS::get_singleton()->canvas_light_occluder_set_transform(orid, get_global_transform() * xform);
- VS::get_singleton()->canvas_light_occluder_set_polygon(orid, occluder->get_rid());
- VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid, get_canvas());
- VS::get_singleton()->canvas_light_occluder_set_light_mask(orid, occluder_light_mask);
+ RID orid = RS::get_singleton()->canvas_light_occluder_create();
+ RS::get_singleton()->canvas_light_occluder_set_transform(orid, get_global_transform() * xform);
+ RS::get_singleton()->canvas_light_occluder_set_polygon(orid, occluder->get_rid());
+ RS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid, get_canvas());
+ RS::get_singleton()->canvas_light_occluder_set_light_mask(orid, occluder_light_mask);
Quadrant::Occluder oc;
oc.xform = xform;
oc.id = orid;
@@ -711,7 +711,7 @@ void TileMap::update_dirty_quadrants() {
Quadrant &q = E->get();
for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) {
- VS::get_singleton()->canvas_item_set_draw_index(F->get(), index++);
+ RS::get_singleton()->canvas_item_set_draw_index(F->get(), index++);
}
}
@@ -763,24 +763,24 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
q.pos.y += cell_size.y;
xform.set_origin(q.pos);
- //q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
+ //q.canvas_item = RenderingServer::get_singleton()->canvas_item_create();
if (!use_parent) {
- q.body = Physics2DServer::get_singleton()->body_create();
- Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
+ q.body = PhysicsServer2D::get_singleton()->body_create();
+ PhysicsServer2D::get_singleton()->body_set_mode(q.body, use_kinematic ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC);
- Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
- Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce);
+ PhysicsServer2D::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
+ PhysicsServer2D::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ PhysicsServer2D::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_FRICTION, friction);
+ PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_BOUNCE, bounce);
if (is_inside_tree()) {
xform = get_global_transform() * xform;
RID space = get_world_2d()->get_space();
- Physics2DServer::get_singleton()->body_set_space(q.body, space);
+ PhysicsServer2D::get_singleton()->body_set_space(q.body, space);
}
- Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ PhysicsServer2D::get_singleton()->body_set_state(q.body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
} else if (collision_parent) {
xform = get_transform() * xform;
q.shape_owner_id = collision_parent->create_shape_owner(this);
@@ -797,14 +797,14 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
Quadrant &q = Q->get();
if (!use_parent) {
- Physics2DServer::get_singleton()->free(q.body);
+ PhysicsServer2D::get_singleton()->free(q.body);
} else if (collision_parent) {
collision_parent->remove_shape_owner(q.shape_owner_id);
}
for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
- VisualServer::get_singleton()->free(E->get());
+ RenderingServer::get_singleton()->free(E->get());
}
q.canvas_items.clear();
if (q.dirty_list.in_list())
@@ -813,13 +813,13 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
- Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID());
+ NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID());
}
q.navpoly_ids.clear();
}
for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
- VS::get_singleton()->free(E->get().id);
+ RS::get_singleton()->free(E->get().id);
}
q.occluder_instances.clear();
@@ -1197,7 +1197,7 @@ void TileMap::_update_all_items_material_state() {
void TileMap::_update_item_material_state(const RID &p_canvas_item) {
- VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid());
+ RS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid());
}
void TileMap::clear() {
@@ -1302,7 +1302,7 @@ void TileMap::set_collision_layer(uint32_t p_layer) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ PhysicsServer2D::get_singleton()->body_set_collision_layer(q.body, collision_layer);
}
}
}
@@ -1314,7 +1314,7 @@ void TileMap::set_collision_mask(uint32_t p_mask) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ PhysicsServer2D::get_singleton()->body_set_collision_mask(q.body, collision_mask);
}
}
}
@@ -1383,7 +1383,7 @@ void TileMap::set_collision_friction(float p_friction) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction);
+ PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_FRICTION, p_friction);
}
}
}
@@ -1400,7 +1400,7 @@ void TileMap::set_collision_bounce(float p_bounce) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce);
+ PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_BOUNCE, p_bounce);
}
}
}
@@ -1655,7 +1655,7 @@ void TileMap::set_y_sort_mode(bool p_enable) {
_clear_quadrants();
y_sort_mode = p_enable;
- VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), y_sort_mode);
+ RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), y_sort_mode);
_recreate_quadrants();
emit_signal("settings_changed");
}
@@ -1746,7 +1746,7 @@ void TileMap::set_occluder_light_mask(int p_mask) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
for (Map<PosKey, Quadrant::Occluder>::Element *F = E->get().occluder_instances.front(); F; F = F->next()) {
- VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask);
+ RenderingServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask);
}
}
}
@@ -1762,7 +1762,7 @@ void TileMap::set_light_mask(int p_light_mask) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
for (List<RID>::Element *F = E->get().canvas_items.front(); F; F = F->next()) {
- VisualServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask());
+ RenderingServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask());
}
}
}
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp
index 1cca45b422..2cb979a0e0 100644
--- a/scene/2d/touch_screen_button.cpp
+++ b/scene/2d/touch_screen_button.cpp
@@ -30,10 +30,11 @@
#include "touch_screen_button.h"
-#include "core/input_map.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
+#include "core/input/input_map.h"
#include "core/os/os.h"
-
+#include "scene/main/window.h"
+#
void TouchScreenButton::set_texture(const Ref<Texture2D> &p_texture) {
texture = p_texture;
@@ -114,7 +115,7 @@ void TouchScreenButton::_notification(int p_what) {
if (!is_inside_tree())
return;
- if (!Engine::get_singleton()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
if (finger_pressed != -1) {
@@ -145,7 +146,7 @@ void TouchScreenButton::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
- if (!Engine::get_singleton()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
update();
@@ -289,12 +290,12 @@ void TouchScreenButton::_press(int p_finger_pressed) {
if (action != StringName()) {
- Input::get_singleton()->action_press(action);
+ InputFilter::get_singleton()->action_press(action);
Ref<InputEventAction> iea;
iea.instance();
iea->set_action(action);
iea->set_pressed(true);
- get_tree()->input_event(iea);
+ get_viewport()->input(iea, true);
}
emit_signal("pressed");
@@ -307,14 +308,14 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
if (action != StringName()) {
- Input::get_singleton()->action_release(action);
+ InputFilter::get_singleton()->action_release(action);
if (!p_exiting_tree) {
Ref<InputEventAction> iea;
iea.instance();
iea->set_action(action);
iea->set_pressed(false);
- get_tree()->input_event(iea);
+ get_viewport()->input(iea, true);
}
}
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 54511bbe1b..c374dd5faa 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -31,11 +31,11 @@
#include "visibility_notifier_2d.h"
#include "core/engine.h"
-#include "particles_2d.h"
-#include "scene/2d/animated_sprite.h"
+#include "gpu_particles_2d.h"
+#include "scene/2d/animated_sprite_2d.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -205,14 +205,14 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
}
{
- AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
+ AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node);
if (as) {
add = true;
}
}
{
- Particles2D *ps = Object::cast_to<Particles2D>(p_node);
+ GPUParticles2D *ps = Object::cast_to<GPUParticles2D>(p_node);
if (ps) {
add = true;
}
@@ -292,7 +292,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
}
if (enabler[ENABLER_PAUSE_ANIMATED_SPRITES]) {
- AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
+ AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node);
if (as) {
@@ -304,7 +304,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
}
if (enabler[ENABLER_PAUSE_PARTICLES]) {
- Particles2D *ps = Object::cast_to<Particles2D>(p_node);
+ GPUParticles2D *ps = Object::cast_to<GPUParticles2D>(p_node);
if (ps) {
diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp
index 62f10a5c96..15d97eeaa0 100644
--- a/scene/2d/y_sort.cpp
+++ b/scene/2d/y_sort.cpp
@@ -33,7 +33,7 @@
void YSort::set_sort_enabled(bool p_enabled) {
sort_enabled = p_enabled;
- VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled);
+ RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled);
}
bool YSort::is_sort_enabled() const {
@@ -53,5 +53,5 @@ void YSort::_bind_methods() {
YSort::YSort() {
sort_enabled = true;
- VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true);
+ RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true);
}
diff --git a/scene/3d/SCsub b/scene/3d/SCsub
index 31a443bad1..45b96bd9c4 100644
--- a/scene/3d/SCsub
+++ b/scene/3d/SCsub
@@ -3,10 +3,7 @@
Import('env')
if env['disable_3d']:
- env.add_source_files(env.scene_sources, "spatial.cpp")
- env.add_source_files(env.scene_sources, "skeleton.cpp")
- env.add_source_files(env.scene_sources, "particles.cpp")
- env.add_source_files(env.scene_sources, "visual_instance.cpp")
- env.add_source_files(env.scene_sources, "world_environment.cpp")
+ env.add_source_files(env.scene_sources, "node_3d.cpp")
+ env.add_source_files(env.scene_sources, "skeleton_3d.cpp")
else:
env.add_source_files(env.scene_sources, "*.cpp")
diff --git a/scene/3d/area.cpp b/scene/3d/area_3d.cpp
index 321926d841..5b02a91793 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* area.cpp */
+/* area_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,93 +28,93 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "area.h"
+#include "area_3d.h"
#include "scene/scene_string_names.h"
#include "servers/audio_server.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-void Area::set_space_override_mode(SpaceOverride p_mode) {
+void Area3D::set_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode;
- PhysicsServer::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer::AreaSpaceOverrideMode(p_mode));
+ PhysicsServer3D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer3D::AreaSpaceOverrideMode(p_mode));
}
-Area::SpaceOverride Area::get_space_override_mode() const {
+Area3D::SpaceOverride Area3D::get_space_override_mode() const {
return space_override;
}
-void Area::set_gravity_is_point(bool p_enabled) {
+void Area3D::set_gravity_is_point(bool p_enabled) {
gravity_is_point = p_enabled;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
-bool Area::is_gravity_a_point() const {
+bool Area3D::is_gravity_a_point() const {
return gravity_is_point;
}
-void Area::set_gravity_distance_scale(real_t p_scale) {
+void Area3D::set_gravity_distance_scale(real_t p_scale) {
gravity_distance_scale = p_scale;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
}
-real_t Area::get_gravity_distance_scale() const {
+real_t Area3D::get_gravity_distance_scale() const {
return gravity_distance_scale;
}
-void Area::set_gravity_vector(const Vector3 &p_vec) {
+void Area3D::set_gravity_vector(const Vector3 &p_vec) {
gravity_vec = p_vec;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_VECTOR, p_vec);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_vec);
}
-Vector3 Area::get_gravity_vector() const {
+Vector3 Area3D::get_gravity_vector() const {
return gravity_vec;
}
-void Area::set_gravity(real_t p_gravity) {
+void Area3D::set_gravity(real_t p_gravity) {
gravity = p_gravity;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY, p_gravity);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY, p_gravity);
}
-real_t Area::get_gravity() const {
+real_t Area3D::get_gravity() const {
return gravity;
}
-void Area::set_linear_damp(real_t p_linear_damp) {
+void Area3D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
-real_t Area::get_linear_damp() const {
+real_t Area3D::get_linear_damp() const {
return linear_damp;
}
-void Area::set_angular_damp(real_t p_angular_damp) {
+void Area3D::set_angular_damp(real_t p_angular_damp) {
angular_damp = p_angular_damp;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
-real_t Area::get_angular_damp() const {
+real_t Area3D::get_angular_damp() const {
return angular_damp;
}
-void Area::set_priority(real_t p_priority) {
+void Area3D::set_priority(real_t p_priority) {
priority = p_priority;
- PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_PRIORITY, p_priority);
+ PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_PRIORITY, p_priority);
}
-real_t Area::get_priority() const {
+real_t Area3D::get_priority() const {
return priority;
}
-void Area::_body_enter_tree(ObjectID p_id) {
+void Area3D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
@@ -132,7 +132,7 @@ void Area::_body_enter_tree(ObjectID p_id) {
}
}
-void Area::_body_exit_tree(ObjectID p_id) {
+void Area3D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
@@ -148,9 +148,9 @@ void Area::_body_exit_tree(ObjectID p_id) {
}
}
-void Area::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
+void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
- bool body_in = p_status == PhysicsServer::AREA_BODY_ADDED;
+ bool body_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
@@ -171,8 +171,8 @@ void Area::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int
E->get().rc = 0;
E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area::_body_enter_tree), make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area::_body_exit_tree), make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree), make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree), make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@@ -198,8 +198,8 @@ void Area::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int
if (E->get().rc == 0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area::_body_enter_tree));
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area::_body_exit_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree));
if (E->get().in_tree)
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
}
@@ -217,7 +217,7 @@ void Area::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int
locked = false;
}
-void Area::_clear_monitoring() {
+void Area3D::_clear_monitoring() {
ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal.");
@@ -245,8 +245,8 @@ void Area::_clear_monitoring() {
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
- node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area::_body_enter_tree));
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area::_body_exit_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree));
}
}
@@ -275,19 +275,19 @@ void Area::_clear_monitoring() {
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
- node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area::_area_enter_tree));
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area::_area_exit_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_area_enter_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_area_exit_tree));
}
}
}
-void Area::_notification(int p_what) {
+void Area3D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
_clear_monitoring();
}
}
-void Area::set_monitoring(bool p_enable) {
+void Area3D::set_monitoring(bool p_enable) {
ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false).");
@@ -298,16 +298,16 @@ void Area::set_monitoring(bool p_enable) {
if (monitoring) {
- PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
- PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
+ PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
+ PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
} else {
- PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
- PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
+ PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
+ PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
_clear_monitoring();
}
}
-void Area::_area_enter_tree(ObjectID p_id) {
+void Area3D::_area_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
@@ -325,7 +325,7 @@ void Area::_area_enter_tree(ObjectID p_id) {
}
}
-void Area::_area_exit_tree(ObjectID p_id) {
+void Area3D::_area_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
@@ -341,9 +341,9 @@ void Area::_area_exit_tree(ObjectID p_id) {
}
}
-void Area::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
+void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
- bool area_in = p_status == PhysicsServer::AREA_BODY_ADDED;
+ bool area_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
@@ -364,8 +364,8 @@ void Area::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int
E->get().rc = 0;
E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area::_area_enter_tree), make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area::_area_exit_tree), make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_area_enter_tree), make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_area_exit_tree), make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
}
@@ -391,8 +391,8 @@ void Area::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int
if (E->get().rc == 0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area::_area_enter_tree));
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area::_area_exit_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_area_enter_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_area_exit_tree));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
}
@@ -411,12 +411,12 @@ void Area::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int
locked = false;
}
-bool Area::is_monitoring() const {
+bool Area3D::is_monitoring() const {
return monitoring;
}
-Array Area::get_overlapping_bodies() const {
+Array Area3D::get_overlapping_bodies() const {
ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
@@ -434,24 +434,24 @@ Array Area::get_overlapping_bodies() const {
return ret;
}
-void Area::set_monitorable(bool p_enable) {
+void Area3D::set_monitorable(bool p_enable) {
- ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
+ ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
if (p_enable == monitorable)
return;
monitorable = p_enable;
- PhysicsServer::get_singleton()->area_set_monitorable(get_rid(), monitorable);
+ PhysicsServer3D::get_singleton()->area_set_monitorable(get_rid(), monitorable);
}
-bool Area::is_monitorable() const {
+bool Area3D::is_monitorable() const {
return monitorable;
}
-Array Area::get_overlapping_areas() const {
+Array Area3D::get_overlapping_areas() const {
ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
@@ -469,7 +469,7 @@ Array Area::get_overlapping_areas() const {
return ret;
}
-bool Area::overlaps_area(Node *p_area) const {
+bool Area3D::overlaps_area(Node *p_area) const {
ERR_FAIL_NULL_V(p_area, false);
const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
@@ -478,7 +478,7 @@ bool Area::overlaps_area(Node *p_area) const {
return E->get().in_tree;
}
-bool Area::overlaps_body(Node *p_body) const {
+bool Area3D::overlaps_body(Node *p_body) const {
ERR_FAIL_NULL_V(p_body, false);
const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
@@ -486,28 +486,28 @@ bool Area::overlaps_body(Node *p_body) const {
return false;
return E->get().in_tree;
}
-void Area::set_collision_mask(uint32_t p_mask) {
+void Area3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- PhysicsServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
+ PhysicsServer3D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
}
-uint32_t Area::get_collision_mask() const {
+uint32_t Area3D::get_collision_mask() const {
return collision_mask;
}
-void Area::set_collision_layer(uint32_t p_layer) {
+void Area3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- PhysicsServer::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
+ PhysicsServer3D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
}
-uint32_t Area::get_collision_layer() const {
+uint32_t Area3D::get_collision_layer() const {
return collision_layer;
}
-void Area::set_collision_mask_bit(int p_bit, bool p_value) {
+void Area3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
@@ -517,12 +517,12 @@ void Area::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool Area::get_collision_mask_bit(int p_bit) const {
+bool Area3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-void Area::set_collision_layer_bit(int p_bit, bool p_value) {
+void Area3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t layer = get_collision_layer();
if (p_value)
@@ -532,26 +532,26 @@ void Area::set_collision_layer_bit(int p_bit, bool p_value) {
set_collision_layer(layer);
}
-bool Area::get_collision_layer_bit(int p_bit) const {
+bool Area3D::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
-void Area::set_audio_bus_override(bool p_override) {
+void Area3D::set_audio_bus_override(bool p_override) {
audio_bus_override = p_override;
}
-bool Area::is_overriding_audio_bus() const {
+bool Area3D::is_overriding_audio_bus() const {
return audio_bus_override;
}
-void Area::set_audio_bus(const StringName &p_audio_bus) {
+void Area3D::set_audio_bus(const StringName &p_audio_bus) {
audio_bus = p_audio_bus;
}
-StringName Area::get_audio_bus() const {
+StringName Area3D::get_audio_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) {
@@ -561,20 +561,20 @@ StringName Area::get_audio_bus() const {
return "Master";
}
-void Area::set_use_reverb_bus(bool p_enable) {
+void Area3D::set_use_reverb_bus(bool p_enable) {
use_reverb_bus = p_enable;
}
-bool Area::is_using_reverb_bus() const {
+bool Area3D::is_using_reverb_bus() const {
return use_reverb_bus;
}
-void Area::set_reverb_bus(const StringName &p_audio_bus) {
+void Area3D::set_reverb_bus(const StringName &p_audio_bus) {
reverb_bus = p_audio_bus;
}
-StringName Area::get_reverb_bus() const {
+StringName Area3D::get_reverb_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == reverb_bus) {
@@ -584,25 +584,25 @@ StringName Area::get_reverb_bus() const {
return "Master";
}
-void Area::set_reverb_amount(float p_amount) {
+void Area3D::set_reverb_amount(float p_amount) {
reverb_amount = p_amount;
}
-float Area::get_reverb_amount() const {
+float Area3D::get_reverb_amount() const {
return reverb_amount;
}
-void Area::set_reverb_uniformity(float p_uniformity) {
+void Area3D::set_reverb_uniformity(float p_uniformity) {
reverb_uniformity = p_uniformity;
}
-float Area::get_reverb_uniformity() const {
+float Area3D::get_reverb_uniformity() const {
return reverb_uniformity;
}
-void Area::_validate_property(PropertyInfo &property) const {
+void Area3D::_validate_property(PropertyInfo &property) const {
if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") {
@@ -618,85 +618,85 @@ void Area::_validate_property(PropertyInfo &property) const {
}
}
-void Area::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_space_override_mode", "enable"), &Area::set_space_override_mode);
- ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area::get_space_override_mode);
+void Area3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_space_override_mode", "enable"), &Area3D::set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area3D::get_space_override_mode);
- ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area::set_gravity_is_point);
- ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area::is_gravity_a_point);
+ ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area3D::set_gravity_is_point);
+ ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area3D::is_gravity_a_point);
- ClassDB::bind_method(D_METHOD("set_gravity_distance_scale", "distance_scale"), &Area::set_gravity_distance_scale);
- ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"), &Area::get_gravity_distance_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_distance_scale", "distance_scale"), &Area3D::set_gravity_distance_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"), &Area3D::get_gravity_distance_scale);
- ClassDB::bind_method(D_METHOD("set_gravity_vector", "vector"), &Area::set_gravity_vector);
- ClassDB::bind_method(D_METHOD("get_gravity_vector"), &Area::get_gravity_vector);
+ ClassDB::bind_method(D_METHOD("set_gravity_vector", "vector"), &Area3D::set_gravity_vector);
+ ClassDB::bind_method(D_METHOD("get_gravity_vector"), &Area3D::get_gravity_vector);
- ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area::set_gravity);
- ClassDB::bind_method(D_METHOD("get_gravity"), &Area::get_gravity);
+ ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area3D::set_gravity);
+ ClassDB::bind_method(D_METHOD("get_gravity"), &Area3D::get_gravity);
- ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &Area::set_angular_damp);
- ClassDB::bind_method(D_METHOD("get_angular_damp"), &Area::get_angular_damp);
+ ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &Area3D::set_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_angular_damp"), &Area3D::get_angular_damp);
- ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &Area::set_linear_damp);
- ClassDB::bind_method(D_METHOD("get_linear_damp"), &Area::get_linear_damp);
+ ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &Area3D::set_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_linear_damp"), &Area3D::get_linear_damp);
- ClassDB::bind_method(D_METHOD("set_priority", "priority"), &Area::set_priority);
- ClassDB::bind_method(D_METHOD("get_priority"), &Area::get_priority);
+ ClassDB::bind_method(D_METHOD("set_priority", "priority"), &Area3D::set_priority);
+ ClassDB::bind_method(D_METHOD("get_priority"), &Area3D::get_priority);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &Area::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &Area::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &Area3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &Area3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Area::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &Area::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Area3D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &Area3D::get_collision_layer);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &Area::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &Area::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &Area3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &Area3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &Area::set_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &Area::get_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &Area3D::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &Area3D::get_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("set_monitorable", "enable"), &Area::set_monitorable);
- ClassDB::bind_method(D_METHOD("is_monitorable"), &Area::is_monitorable);
+ ClassDB::bind_method(D_METHOD("set_monitorable", "enable"), &Area3D::set_monitorable);
+ ClassDB::bind_method(D_METHOD("is_monitorable"), &Area3D::is_monitorable);
- ClassDB::bind_method(D_METHOD("set_monitoring", "enable"), &Area::set_monitoring);
- ClassDB::bind_method(D_METHOD("is_monitoring"), &Area::is_monitoring);
+ ClassDB::bind_method(D_METHOD("set_monitoring", "enable"), &Area3D::set_monitoring);
+ ClassDB::bind_method(D_METHOD("is_monitoring"), &Area3D::is_monitoring);
- ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area::get_overlapping_bodies);
- ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area::get_overlapping_areas);
+ ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area3D::get_overlapping_bodies);
+ ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area3D::get_overlapping_areas);
- ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area::overlaps_body);
- ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area::overlaps_area);
+ ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area3D::overlaps_body);
+ ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area3D::overlaps_area);
- ClassDB::bind_method(D_METHOD("_body_inout"), &Area::_body_inout);
- ClassDB::bind_method(D_METHOD("_area_inout"), &Area::_area_inout);
+ ClassDB::bind_method(D_METHOD("_body_inout"), &Area3D::_body_inout);
+ ClassDB::bind_method(D_METHOD("_area_inout"), &Area3D::_area_inout);
- ClassDB::bind_method(D_METHOD("set_audio_bus_override", "enable"), &Area::set_audio_bus_override);
- ClassDB::bind_method(D_METHOD("is_overriding_audio_bus"), &Area::is_overriding_audio_bus);
+ ClassDB::bind_method(D_METHOD("set_audio_bus_override", "enable"), &Area3D::set_audio_bus_override);
+ ClassDB::bind_method(D_METHOD("is_overriding_audio_bus"), &Area3D::is_overriding_audio_bus);
- ClassDB::bind_method(D_METHOD("set_audio_bus", "name"), &Area::set_audio_bus);
- ClassDB::bind_method(D_METHOD("get_audio_bus"), &Area::get_audio_bus);
+ ClassDB::bind_method(D_METHOD("set_audio_bus", "name"), &Area3D::set_audio_bus);
+ ClassDB::bind_method(D_METHOD("get_audio_bus"), &Area3D::get_audio_bus);
- ClassDB::bind_method(D_METHOD("set_use_reverb_bus", "enable"), &Area::set_use_reverb_bus);
- ClassDB::bind_method(D_METHOD("is_using_reverb_bus"), &Area::is_using_reverb_bus);
+ ClassDB::bind_method(D_METHOD("set_use_reverb_bus", "enable"), &Area3D::set_use_reverb_bus);
+ ClassDB::bind_method(D_METHOD("is_using_reverb_bus"), &Area3D::is_using_reverb_bus);
- ClassDB::bind_method(D_METHOD("set_reverb_bus", "name"), &Area::set_reverb_bus);
- ClassDB::bind_method(D_METHOD("get_reverb_bus"), &Area::get_reverb_bus);
+ ClassDB::bind_method(D_METHOD("set_reverb_bus", "name"), &Area3D::set_reverb_bus);
+ ClassDB::bind_method(D_METHOD("get_reverb_bus"), &Area3D::get_reverb_bus);
- ClassDB::bind_method(D_METHOD("set_reverb_amount", "amount"), &Area::set_reverb_amount);
- ClassDB::bind_method(D_METHOD("get_reverb_amount"), &Area::get_reverb_amount);
+ ClassDB::bind_method(D_METHOD("set_reverb_amount", "amount"), &Area3D::set_reverb_amount);
+ ClassDB::bind_method(D_METHOD("get_reverb_amount"), &Area3D::get_reverb_amount);
- ClassDB::bind_method(D_METHOD("set_reverb_uniformity", "amount"), &Area::set_reverb_uniformity);
- ClassDB::bind_method(D_METHOD("get_reverb_uniformity"), &Area::get_reverb_uniformity);
+ ClassDB::bind_method(D_METHOD("set_reverb_uniformity", "amount"), &Area3D::set_reverb_uniformity);
+ ClassDB::bind_method(D_METHOD("get_reverb_uniformity"), &Area3D::get_reverb_uniformity);
ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), 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, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
- 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_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area3D"), 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, "Area3D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
+ ADD_SIGNAL(MethodInfo("area_entered", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area3D")));
+ ADD_SIGNAL(MethodInfo("area_exited", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area3D")));
ADD_PROPERTY(PropertyInfo(Variant::INT, "space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine"), "set_space_override_mode", "get_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point"), "set_gravity_is_point", "is_gravity_a_point");
@@ -727,8 +727,8 @@ void Area::_bind_methods() {
BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE_COMBINE);
}
-Area::Area() :
- CollisionObject(PhysicsServer::get_singleton()->area_create(), true) {
+Area3D::Area3D() :
+ CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) {
space_override = SPACE_OVERRIDE_DISABLED;
set_gravity(9.8);
@@ -755,5 +755,5 @@ Area::Area() :
reverb_uniformity = 0.0;
}
-Area::~Area() {
+Area3D::~Area3D() {
}
diff --git a/scene/3d/area.h b/scene/3d/area_3d.h
index 7fe61430fa..ff6c0b6b08 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* area.h */
+/* area_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef AREA_H
-#define AREA_H
+#ifndef AREA_3D_H
+#define AREA_3D_H
#include "core/vset.h"
-#include "scene/3d/collision_object.h"
+#include "scene/3d/collision_object_3d.h"
-class Area : public CollisionObject {
+class Area3D : public CollisionObject3D {
- GDCLASS(Area, CollisionObject);
+ GDCLASS(Area3D, CollisionObject3D);
public:
enum SpaceOverride {
@@ -208,10 +208,10 @@ public:
void set_reverb_uniformity(float p_uniformity);
float get_reverb_uniformity() const;
- Area();
- ~Area();
+ Area3D();
+ ~Area3D();
};
-VARIANT_ENUM_CAST(Area::SpaceOverride);
+VARIANT_ENUM_CAST(Area3D::SpaceOverride);
#endif // AREA__H
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index d23e5ffa08..ce7c885a40 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "arvr_nodes.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "servers/arvr/arvr_interface.h"
#include "servers/arvr_server.h"
@@ -75,7 +75,7 @@ Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const {
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
if (arvr_interface.is_null()) {
// we might be in the editor or have VR turned off, just call superclass
- return Camera::project_local_ray_normal(p_pos);
+ return Camera3D::project_local_ray_normal(p_pos);
}
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
@@ -99,7 +99,7 @@ Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const {
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
if (arvr_interface.is_null()) {
// we might be in the editor or have VR turned off, just call superclass
- return Camera::unproject_position(p_pos);
+ return Camera3D::unproject_position(p_pos);
}
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene.");
@@ -128,7 +128,7 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
if (arvr_interface.is_null()) {
// we might be in the editor or have VR turned off, just call superclass
- return Camera::project_position(p_point, p_z_depth);
+ return Camera3D::project_position(p_point, p_z_depth);
}
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
@@ -157,7 +157,7 @@ Vector<Plane> ARVRCamera::get_frustum() const {
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
if (arvr_interface.is_null()) {
// we might be in the editor or have VR turned off, just call superclass
- return Camera::get_frustum();
+ return Camera3D::get_frustum();
}
ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
@@ -206,7 +206,7 @@ void ARVRController::_notification(int p_what) {
// check button states
for (int i = 0; i < 16; i++) {
bool was_pressed = (button_states & mask) == mask;
- bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, i);
+ bool is_pressed = InputFilter::get_singleton()->is_joy_button_pressed(joy_id, i);
if (!was_pressed && is_pressed) {
emit_signal("button_pressed", i);
@@ -306,7 +306,7 @@ bool ARVRController::is_button_pressed(int p_button) const {
return false;
};
- return Input::get_singleton()->is_joy_button_pressed(joy_id, p_button);
+ return InputFilter::get_singleton()->is_joy_button_pressed(joy_id, p_button);
};
float ARVRController::get_joystick_axis(int p_axis) const {
@@ -315,7 +315,7 @@ float ARVRController::get_joystick_axis(int p_axis) const {
return 0.0;
};
- return Input::get_singleton()->get_joy_axis(joy_id, p_axis);
+ return InputFilter::get_singleton()->get_joy_axis(joy_id, p_axis);
};
real_t ARVRController::get_rumble() const {
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index e968e33c9d..bc5df2e174 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -31,8 +31,8 @@
#ifndef ARVR_NODES_H
#define ARVR_NODES_H
-#include "scene/3d/camera.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/mesh.h"
#include "servers/arvr/arvr_positional_tracker.h"
@@ -43,9 +43,9 @@
/*
ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned
*/
-class ARVRCamera : public Camera {
+class ARVRCamera : public Camera3D {
- GDCLASS(ARVRCamera, Camera);
+ GDCLASS(ARVRCamera, Camera3D);
protected:
void _notification(int p_what);
@@ -68,9 +68,9 @@ public:
It must be a child node of our ARVROrigin node
*/
-class ARVRController : public Spatial {
+class ARVRController : public Node3D {
- GDCLASS(ARVRController, Spatial);
+ GDCLASS(ARVRController, Node3D);
private:
int controller_id;
@@ -110,8 +110,8 @@ public:
It must be a child node of our ARVROrigin node
*/
-class ARVRAnchor : public Spatial {
- GDCLASS(ARVRAnchor, Spatial);
+class ARVRAnchor : public Node3D {
+ GDCLASS(ARVRAnchor, Node3D);
private:
int anchor_id;
@@ -149,9 +149,9 @@ public:
Our camera and controllers will always be child nodes and thus place relative to this origin point.
This node will automatically locate any camera child nodes and update its position while our ARVRController node will handle tracked controllers.
*/
-class ARVROrigin : public Spatial {
+class ARVROrigin : public Node3D {
- GDCLASS(ARVROrigin, Spatial);
+ GDCLASS(ARVROrigin, Node3D);
private:
ARVRCamera *tracked_camera;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 855d254bd6..bddf748be7 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -30,10 +30,10 @@
#include "audio_stream_player_3d.h"
#include "core/engine.h"
-#include "scene/3d/area.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/listener.h"
-#include "scene/main/viewport.h"
+#include "scene/3d/area_3d.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/listener_3d.h"
+#include "scene/main/window.h"
// Based on "A Novel Multichannel Panning Method for Standard and Arbitrary Loudspeaker Configurations" by Ramy Sadek and Chris Kyriakakis (2004)
// Speaker-Placement Correction Amplitude Panning (SPCAP)
@@ -213,7 +213,7 @@ void AudioStreamPlayer3D::_mix_audio() {
AudioFrame target_volume = stream_paused_fade_out ? AudioFrame(0.f, 0.f) : current.vol[k];
AudioFrame vol_prev = stream_paused_fade_in ? AudioFrame(0.f, 0.f) : prev_outputs[i].vol[k];
AudioFrame vol_inc = (target_volume - vol_prev) / float(buffer_size);
- AudioFrame vol = stream_paused_fade_in ? AudioFrame(0.f, 0.f) : current.vol[k];
+ AudioFrame vol = vol_prev;
if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, k))
continue; //may have been deleted, will be updated on process
@@ -384,7 +384,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
linear_velocity = velocity_tracker->get_tracked_linear_velocity();
}
- Ref<World> world = get_world();
+ Ref<World3D> world = get_world();
ERR_FAIL_COND(world.is_null());
int new_output_count = 0;
@@ -395,18 +395,18 @@ void AudioStreamPlayer3D::_notification(int p_what) {
//check if any area is diverting sound into a bus
- PhysicsDirectSpaceState *space_state = PhysicsServer::get_singleton()->space_get_direct_state(world->get_space());
+ PhysicsDirectSpaceState3D *space_state = PhysicsServer3D::get_singleton()->space_get_direct_state(world->get_space());
- PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
+ PhysicsDirectSpaceState3D::ShapeResult sr[MAX_INTERSECT_AREAS];
int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true);
- Area *area = NULL;
+ Area3D *area = NULL;
for (int i = 0; i < areas; i++) {
if (!sr[i].collider)
continue;
- Area *tarea = Object::cast_to<Area>(sr[i].collider);
+ Area3D *tarea = Object::cast_to<Area3D>(sr[i].collider);
if (!tarea)
continue;
@@ -417,20 +417,20 @@ void AudioStreamPlayer3D::_notification(int p_what) {
break;
}
- List<Camera *> cameras;
+ List<Camera3D *> cameras;
world->get_camera_list(&cameras);
- for (List<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
+ for (List<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
- Camera *camera = E->get();
+ Camera3D *camera = E->get();
Viewport *vp = camera->get_viewport();
if (!vp->is_audio_listener())
continue;
bool listener_is_camera = true;
- Spatial *listener_node = camera;
+ Node3D *listener_node = camera;
- Listener *listener = vp->get_listener();
+ Listener3D *listener = vp->get_listener();
if (listener) {
listener_node = listener;
listener_is_camera = false;
diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h
index 5b4c865475..1cce0c77d5 100644
--- a/scene/3d/audio_stream_player_3d.h
+++ b/scene/3d/audio_stream_player_3d.h
@@ -31,16 +31,16 @@
#ifndef AUDIO_STREAM_PLAYER_3D_H
#define AUDIO_STREAM_PLAYER_3D_H
-#include "scene/3d/spatial.h"
-#include "scene/3d/spatial_velocity_tracker.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/velocity_tracker_3d.h"
#include "servers/audio/audio_filter_sw.h"
#include "servers/audio/audio_stream.h"
#include "servers/audio_server.h"
-class Camera;
-class AudioStreamPlayer3D : public Spatial {
+class Camera3D;
+class AudioStreamPlayer3D : public Node3D {
- GDCLASS(AudioStreamPlayer3D, Spatial);
+ GDCLASS(AudioStreamPlayer3D, Node3D);
public:
enum AttenuationModel {
@@ -134,7 +134,7 @@ private:
float max_distance;
- Ref<SpatialVelocityTracker> velocity_tracker;
+ Ref<VelocityTracker3D> velocity_tracker;
DopplerTracking doppler_tracking;
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 73b1d450f0..05e3f3fefa 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -39,7 +39,7 @@
void BakedLightmapData::set_bounds(const AABB &p_bounds) {
bounds = p_bounds;
- VS::get_singleton()->lightmap_capture_set_bounds(baked_light, p_bounds);
+ RS::get_singleton()->lightmap_capture_set_bounds(baked_light, p_bounds);
}
AABB BakedLightmapData::get_bounds() const {
@@ -49,18 +49,18 @@ AABB BakedLightmapData::get_bounds() const {
void BakedLightmapData::set_octree(const Vector<uint8_t> &p_octree) {
- VS::get_singleton()->lightmap_capture_set_octree(baked_light, p_octree);
+ RS::get_singleton()->lightmap_capture_set_octree(baked_light, p_octree);
}
Vector<uint8_t> BakedLightmapData::get_octree() const {
- return VS::get_singleton()->lightmap_capture_get_octree(baked_light);
+ return RS::get_singleton()->lightmap_capture_get_octree(baked_light);
}
void BakedLightmapData::set_cell_space_transform(const Transform &p_xform) {
cell_space_xform = p_xform;
- VS::get_singleton()->lightmap_capture_set_octree_cell_transform(baked_light, p_xform);
+ RS::get_singleton()->lightmap_capture_set_octree_cell_transform(baked_light, p_xform);
}
Transform BakedLightmapData::get_cell_space_transform() const {
@@ -69,7 +69,7 @@ Transform BakedLightmapData::get_cell_space_transform() const {
void BakedLightmapData::set_cell_subdiv(int p_cell_subdiv) {
cell_subdiv = p_cell_subdiv;
- VS::get_singleton()->lightmap_capture_set_octree_cell_subdiv(baked_light, p_cell_subdiv);
+ RS::get_singleton()->lightmap_capture_set_octree_cell_subdiv(baked_light, p_cell_subdiv);
}
int BakedLightmapData::get_cell_subdiv() const {
@@ -79,7 +79,7 @@ int BakedLightmapData::get_cell_subdiv() const {
void BakedLightmapData::set_energy(float p_energy) {
energy = p_energy;
- VS::get_singleton()->lightmap_capture_set_energy(baked_light, energy);
+ RS::get_singleton()->lightmap_capture_set_energy(baked_light, energy);
}
float BakedLightmapData::get_energy() const {
@@ -181,14 +181,14 @@ void BakedLightmapData::_bind_methods() {
BakedLightmapData::BakedLightmapData() {
- baked_light = VS::get_singleton()->lightmap_capture_create();
+ baked_light = RS::get_singleton()->lightmap_capture_create();
energy = 1;
cell_subdiv = 1;
}
BakedLightmapData::~BakedLightmapData() {
- VS::get_singleton()->free(baked_light);
+ RS::get_singleton()->free(baked_light);
}
///////////////////////////
@@ -425,13 +425,13 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
pmc++;
PlotLight pl = E->get();
switch (pl.light->get_light_type()) {
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
baker.plot_light_directional(-pl.local_xform.basis.get_axis(2), pl.light->get_color(), pl.light->get_param(Light::PARAM_ENERGY), pl.light->get_param(Light::PARAM_INDIRECT_ENERGY), pl.light->get_bake_mode() == Light::BAKE_ALL);
} break;
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_OMNI: {
baker.plot_light_omni(pl.local_xform.origin, pl.light->get_color(), pl.light->get_param(Light::PARAM_ENERGY), pl.light->get_param(Light::PARAM_INDIRECT_ENERGY), pl.light->get_param(Light::PARAM_RANGE), pl.light->get_param(Light::PARAM_ATTENUATION), pl.light->get_bake_mode() == Light::BAKE_ALL);
} break;
- case VS::LIGHT_SPOT: {
+ case RS::LIGHT_SPOT: {
baker.plot_light_spot(pl.local_xform.origin, pl.local_xform.basis.get_axis(2), pl.light->get_color(), pl.light->get_param(Light::PARAM_ENERGY), pl.light->get_param(Light::PARAM_INDIRECT_ENERGY), pl.light->get_param(Light::PARAM_RANGE), pl.light->get_param(Light::PARAM_ATTENUATION), pl.light->get_param(Light::PARAM_SPOT_ANGLE), pl.light->get_param(Light::PARAM_SPOT_ATTENUATION), pl.light->get_bake_mode() == Light::BAKE_ALL);
} break;
@@ -675,12 +675,12 @@ void BakedLightmap::_assign_lightmaps() {
if (instance_idx >= 0) {
RID instance = node->call("get_bake_mesh_instance", instance_idx);
if (instance.is_valid()) {
- VS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), lightmap->get_rid());
+ RS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), lightmap->get_rid());
}
} else {
VisualInstance *vi = Object::cast_to<VisualInstance>(node);
ERR_CONTINUE(!vi);
- VS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), lightmap->get_rid());
+ RS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), lightmap->get_rid());
}
}
}
@@ -693,12 +693,12 @@ void BakedLightmap::_clear_lightmaps() {
if (instance_idx >= 0) {
RID instance = node->call("get_bake_mesh_instance", instance_idx);
if (instance.is_valid()) {
- VS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), RID());
+ RS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), RID());
}
} else {
VisualInstance *vi = Object::cast_to<VisualInstance>(node);
ERR_CONTINUE(!vi);
- VS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), RID());
+ RS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), RID());
}
}
}
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment_3d.cpp
index b1cd9bfe8b..825cb39e2d 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* bone_attachment.cpp */
+/* bone_attachment_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "bone_attachment.h"
+#include "bone_attachment_3d.h"
-void BoneAttachment::_validate_property(PropertyInfo &property) const {
+void BoneAttachment3D::_validate_property(PropertyInfo &property) const {
if (property.name == "bone_name") {
- Skeleton *parent = Object::cast_to<Skeleton>(get_parent());
+ Skeleton3D *parent = Object::cast_to<Skeleton3D>(get_parent());
if (parent) {
@@ -54,9 +54,9 @@ void BoneAttachment::_validate_property(PropertyInfo &property) const {
}
}
-void BoneAttachment::_check_bind() {
+void BoneAttachment3D::_check_bind() {
- Skeleton *sk = Object::cast_to<Skeleton>(get_parent());
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(get_parent());
if (sk) {
int idx = sk->find_bone(bone_name);
@@ -68,11 +68,11 @@ void BoneAttachment::_check_bind() {
}
}
-void BoneAttachment::_check_unbind() {
+void BoneAttachment3D::_check_unbind() {
if (bound) {
- Skeleton *sk = Object::cast_to<Skeleton>(get_parent());
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(get_parent());
if (sk) {
int idx = sk->find_bone(bone_name);
@@ -84,7 +84,7 @@ void BoneAttachment::_check_unbind() {
}
}
-void BoneAttachment::set_bone_name(const String &p_name) {
+void BoneAttachment3D::set_bone_name(const String &p_name) {
if (is_inside_tree())
_check_unbind();
@@ -95,12 +95,12 @@ void BoneAttachment::set_bone_name(const String &p_name) {
_check_bind();
}
-String BoneAttachment::get_bone_name() const {
+String BoneAttachment3D::get_bone_name() const {
return bone_name;
}
-void BoneAttachment::_notification(int p_what) {
+void BoneAttachment3D::_notification(int p_what) {
switch (p_what) {
@@ -115,13 +115,13 @@ void BoneAttachment::_notification(int p_what) {
}
}
-BoneAttachment::BoneAttachment() {
+BoneAttachment3D::BoneAttachment3D() {
bound = false;
}
-void BoneAttachment::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_bone_name", "bone_name"), &BoneAttachment::set_bone_name);
- ClassDB::bind_method(D_METHOD("get_bone_name"), &BoneAttachment::get_bone_name);
+void BoneAttachment3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_bone_name", "bone_name"), &BoneAttachment3D::set_bone_name);
+ ClassDB::bind_method(D_METHOD("get_bone_name"), &BoneAttachment3D::get_bone_name);
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bone_name"), "set_bone_name", "get_bone_name");
}
diff --git a/scene/3d/bone_attachment.h b/scene/3d/bone_attachment_3d.h
index 43c46dd759..d2a3ffec90 100644
--- a/scene/3d/bone_attachment.h
+++ b/scene/3d/bone_attachment_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* bone_attachment.h */
+/* bone_attachment_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,11 +31,11 @@
#ifndef BONE_ATTACHMENT_H
#define BONE_ATTACHMENT_H
-#include "scene/3d/skeleton.h"
+#include "scene/3d/skeleton_3d.h"
-class BoneAttachment : public Spatial {
+class BoneAttachment3D : public Node3D {
- GDCLASS(BoneAttachment, Spatial);
+ GDCLASS(BoneAttachment3D, Node3D);
bool bound;
String bone_name;
@@ -53,7 +53,7 @@ public:
void set_bone_name(const String &p_name);
String get_bone_name() const;
- BoneAttachment();
+ BoneAttachment3D();
};
#endif // BONE_ATTACHMENT_H
diff --git a/scene/3d/camera.cpp b/scene/3d/camera_3d.cpp
index 741712025c..7980c15f89 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* camera.cpp */
+/* camera_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,22 +28,22 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "camera.h"
+#include "camera_3d.h"
-#include "collision_object.h"
+#include "collision_object_3d.h"
#include "core/engine.h"
#include "core/math/camera_matrix.h"
#include "scene/resources/material.h"
#include "scene/resources/surface_tool.h"
-void Camera::_update_audio_listener_state() {
+void Camera3D::_update_audio_listener_state() {
}
-void Camera::_request_camera_update() {
+void Camera3D::_request_camera_update() {
_update_camera();
}
-void Camera::_update_camera_mode() {
+void Camera3D::_update_camera_mode() {
force_change = true;
switch (mode) {
@@ -61,7 +61,7 @@ void Camera::_update_camera_mode() {
}
}
-void Camera::_validate_property(PropertyInfo &p_property) const {
+void Camera3D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "fov") {
if (mode != PROJECTION_PERSPECTIVE) {
p_property.usage = PROPERTY_USAGE_NOEDITOR;
@@ -77,12 +77,12 @@ void Camera::_validate_property(PropertyInfo &p_property) const {
}
}
-void Camera::_update_camera() {
+void Camera3D::_update_camera() {
if (!is_inside_tree())
return;
- VisualServer::get_singleton()->camera_set_transform(camera, get_camera_transform());
+ RenderingServer::get_singleton()->camera_set_transform(camera, get_camera_transform());
// here goes listener stuff
/*
@@ -100,7 +100,7 @@ void Camera::_update_camera() {
}
}
-void Camera::_notification(int p_what) {
+void Camera3D::_notification(int p_what) {
switch (p_what) {
@@ -155,7 +155,7 @@ void Camera::_notification(int p_what) {
}
}
-Transform Camera::get_camera_transform() const {
+Transform Camera3D::get_camera_transform() const {
Transform tr = get_global_transform().orthonormalized();
tr.origin += tr.basis.get_axis(1) * v_offset;
@@ -163,7 +163,7 @@ Transform Camera::get_camera_transform() const {
return tr;
}
-void Camera::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) {
+void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) {
if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE)
return;
@@ -173,11 +173,11 @@ void Camera::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far
far = p_z_far;
mode = PROJECTION_PERSPECTIVE;
- VisualServer::get_singleton()->camera_set_perspective(camera, fov, near, far);
+ RenderingServer::get_singleton()->camera_set_perspective(camera, fov, near, far);
update_gizmo();
force_change = false;
}
-void Camera::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
+void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL)
return;
@@ -189,11 +189,11 @@ void Camera::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
mode = PROJECTION_ORTHOGONAL;
force_change = false;
- VisualServer::get_singleton()->camera_set_orthogonal(camera, size, near, far);
+ RenderingServer::get_singleton()->camera_set_orthogonal(camera, size, near, far);
update_gizmo();
}
-void Camera::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
+void Camera3D::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
if (!force_change && size == p_size && frustum_offset == p_offset && p_z_near == near && p_z_far == far && mode == PROJECTION_FRUSTUM)
return;
@@ -205,11 +205,11 @@ void Camera::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p
mode = PROJECTION_FRUSTUM;
force_change = false;
- VisualServer::get_singleton()->camera_set_frustum(camera, size, frustum_offset, near, far);
+ RenderingServer::get_singleton()->camera_set_frustum(camera, size, frustum_offset, near, far);
update_gizmo();
}
-void Camera::set_projection(Camera::Projection p_mode) {
+void Camera3D::set_projection(Camera3D::Projection p_mode) {
if (p_mode == PROJECTION_PERSPECTIVE || p_mode == PROJECTION_ORTHOGONAL || p_mode == PROJECTION_FRUSTUM) {
mode = p_mode;
_update_camera_mode();
@@ -217,12 +217,12 @@ void Camera::set_projection(Camera::Projection p_mode) {
}
}
-RID Camera::get_camera() const {
+RID Camera3D::get_camera() const {
return camera;
};
-void Camera::make_current() {
+void Camera3D::make_current() {
current = true;
@@ -234,7 +234,7 @@ void Camera::make_current() {
//get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_current",this);
}
-void Camera::clear_current(bool p_enable_next) {
+void Camera3D::clear_current(bool p_enable_next) {
current = false;
if (!is_inside_tree())
@@ -249,7 +249,7 @@ void Camera::clear_current(bool p_enable_next) {
}
}
-void Camera::set_current(bool p_current) {
+void Camera3D::set_current(bool p_current) {
if (p_current) {
make_current();
} else {
@@ -257,7 +257,7 @@ void Camera::set_current(bool p_current) {
}
}
-bool Camera::is_current() const {
+bool Camera3D::is_current() const {
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
@@ -266,18 +266,18 @@ bool Camera::is_current() const {
return current;
}
-bool Camera::_can_gizmo_scale() const {
+bool Camera3D::_can_gizmo_scale() const {
return false;
}
-Vector3 Camera::project_ray_normal(const Point2 &p_pos) const {
+Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const {
Vector3 ray = project_local_ray_normal(p_pos);
return get_camera_transform().basis.xform(ray).normalized();
};
-Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const {
+Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
@@ -298,7 +298,7 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const {
return ray;
};
-Vector3 Camera::project_ray_origin(const Point2 &p_pos) const {
+Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
@@ -330,14 +330,14 @@ Vector3 Camera::project_ray_origin(const Point2 &p_pos) const {
};
};
-bool Camera::is_position_behind(const Vector3 &p_pos) const {
+bool Camera3D::is_position_behind(const Vector3 &p_pos) const {
Transform t = get_global_transform();
Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized();
return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near);
}
-Vector<Vector3> Camera::get_near_plane_points() const {
+Vector<Vector3> Camera3D::get_near_plane_points() const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector<Vector3>(), "Camera is not inside scene.");
Size2 viewport_size = get_viewport()->get_visible_rect().size;
@@ -360,7 +360,7 @@ Vector<Vector3> Camera::get_near_plane_points() const {
return points;
}
-Point2 Camera::unproject_position(const Vector3 &p_pos) const {
+Point2 Camera3D::unproject_position(const Vector3 &p_pos) const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene.");
@@ -385,7 +385,7 @@ Point2 Camera::unproject_position(const Vector3 &p_pos) const {
return res;
}
-Vector3 Camera::project_position(const Point2 &p_point, float p_z_depth) const {
+Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
@@ -418,61 +418,61 @@ void Camera::_camera_make_current(Node *p_camera) {
if (p_camera==this) {
- VisualServer::get_singleton()->viewport_attach_camera(viewport_id,camera);
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport_id,camera);
active=true;
} else {
if (active && p_camera==NULL) {
//detech camera because no one else will claim it
- VisualServer::get_singleton()->viewport_attach_camera(viewport_id,RID());
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport_id,RID());
}
active=false;
}
}
*/
-void Camera::set_environment(const Ref<Environment> &p_environment) {
+void Camera3D::set_environment(const Ref<Environment> &p_environment) {
environment = p_environment;
if (environment.is_valid())
- VS::get_singleton()->camera_set_environment(camera, environment->get_rid());
+ RS::get_singleton()->camera_set_environment(camera, environment->get_rid());
else
- VS::get_singleton()->camera_set_environment(camera, RID());
+ RS::get_singleton()->camera_set_environment(camera, RID());
_update_camera_mode();
}
-Ref<Environment> Camera::get_environment() const {
+Ref<Environment> Camera3D::get_environment() const {
return environment;
}
-void Camera::set_effects(const Ref<CameraEffects> &p_effects) {
+void Camera3D::set_effects(const Ref<CameraEffects> &p_effects) {
effects = p_effects;
if (effects.is_valid())
- VS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid());
+ RS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid());
else
- VS::get_singleton()->camera_set_camera_effects(camera, RID());
+ RS::get_singleton()->camera_set_camera_effects(camera, RID());
_update_camera_mode();
}
-Ref<CameraEffects> Camera::get_effects() const {
+Ref<CameraEffects> Camera3D::get_effects() const {
return effects;
}
-void Camera::set_keep_aspect_mode(KeepAspect p_aspect) {
+void Camera3D::set_keep_aspect_mode(KeepAspect p_aspect) {
keep_aspect = p_aspect;
- VisualServer::get_singleton()->camera_set_use_vertical_aspect(camera, p_aspect == KEEP_WIDTH);
+ RenderingServer::get_singleton()->camera_set_use_vertical_aspect(camera, p_aspect == KEEP_WIDTH);
_update_camera_mode();
_change_notify();
}
-Camera::KeepAspect Camera::get_keep_aspect_mode() const {
+Camera3D::KeepAspect Camera3D::get_keep_aspect_mode() const {
return keep_aspect;
}
-void Camera::set_doppler_tracking(DopplerTracking p_tracking) {
+void Camera3D::set_doppler_tracking(DopplerTracking p_tracking) {
if (doppler_tracking == p_tracking)
return;
@@ -487,57 +487,57 @@ void Camera::set_doppler_tracking(DopplerTracking p_tracking) {
_update_camera_mode();
}
-Camera::DopplerTracking Camera::get_doppler_tracking() const {
+Camera3D::DopplerTracking Camera3D::get_doppler_tracking() const {
return doppler_tracking;
}
-void Camera::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("project_ray_normal", "screen_point"), &Camera::project_ray_normal);
- ClassDB::bind_method(D_METHOD("project_local_ray_normal", "screen_point"), &Camera::project_local_ray_normal);
- ClassDB::bind_method(D_METHOD("project_ray_origin", "screen_point"), &Camera::project_ray_origin);
- ClassDB::bind_method(D_METHOD("unproject_position", "world_point"), &Camera::unproject_position);
- ClassDB::bind_method(D_METHOD("is_position_behind", "world_point"), &Camera::is_position_behind);
- ClassDB::bind_method(D_METHOD("project_position", "screen_point", "z_depth"), &Camera::project_position);
- ClassDB::bind_method(D_METHOD("set_perspective", "fov", "z_near", "z_far"), &Camera::set_perspective);
- ClassDB::bind_method(D_METHOD("set_orthogonal", "size", "z_near", "z_far"), &Camera::set_orthogonal);
- ClassDB::bind_method(D_METHOD("set_frustum", "size", "offset", "z_near", "z_far"), &Camera::set_frustum);
- ClassDB::bind_method(D_METHOD("make_current"), &Camera::make_current);
- ClassDB::bind_method(D_METHOD("clear_current", "enable_next"), &Camera::clear_current, DEFVAL(true));
- ClassDB::bind_method(D_METHOD("set_current"), &Camera::set_current);
- ClassDB::bind_method(D_METHOD("is_current"), &Camera::is_current);
- ClassDB::bind_method(D_METHOD("get_camera_transform"), &Camera::get_camera_transform);
- ClassDB::bind_method(D_METHOD("get_fov"), &Camera::get_fov);
- ClassDB::bind_method(D_METHOD("get_frustum_offset"), &Camera::get_frustum_offset);
- ClassDB::bind_method(D_METHOD("get_size"), &Camera::get_size);
- ClassDB::bind_method(D_METHOD("get_zfar"), &Camera::get_zfar);
- ClassDB::bind_method(D_METHOD("get_znear"), &Camera::get_znear);
- ClassDB::bind_method(D_METHOD("set_fov"), &Camera::set_fov);
- ClassDB::bind_method(D_METHOD("set_frustum_offset"), &Camera::set_frustum_offset);
- ClassDB::bind_method(D_METHOD("set_size"), &Camera::set_size);
- ClassDB::bind_method(D_METHOD("set_zfar"), &Camera::set_zfar);
- ClassDB::bind_method(D_METHOD("set_znear"), &Camera::set_znear);
- ClassDB::bind_method(D_METHOD("get_projection"), &Camera::get_projection);
- ClassDB::bind_method(D_METHOD("set_projection"), &Camera::set_projection);
- ClassDB::bind_method(D_METHOD("set_h_offset", "ofs"), &Camera::set_h_offset);
- ClassDB::bind_method(D_METHOD("get_h_offset"), &Camera::get_h_offset);
- ClassDB::bind_method(D_METHOD("set_v_offset", "ofs"), &Camera::set_v_offset);
- ClassDB::bind_method(D_METHOD("get_v_offset"), &Camera::get_v_offset);
- ClassDB::bind_method(D_METHOD("set_cull_mask", "mask"), &Camera::set_cull_mask);
- ClassDB::bind_method(D_METHOD("get_cull_mask"), &Camera::get_cull_mask);
- ClassDB::bind_method(D_METHOD("set_environment", "env"), &Camera::set_environment);
- ClassDB::bind_method(D_METHOD("get_environment"), &Camera::get_environment);
- ClassDB::bind_method(D_METHOD("set_effects", "env"), &Camera::set_effects);
- ClassDB::bind_method(D_METHOD("get_effects"), &Camera::get_effects);
- ClassDB::bind_method(D_METHOD("set_keep_aspect_mode", "mode"), &Camera::set_keep_aspect_mode);
- ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera::get_keep_aspect_mode);
- ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera::set_doppler_tracking);
- ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera::get_doppler_tracking);
- ClassDB::bind_method(D_METHOD("get_frustum"), &Camera::get_frustum);
- ClassDB::bind_method(D_METHOD("get_camera_rid"), &Camera::get_camera);
-
- ClassDB::bind_method(D_METHOD("set_cull_mask_bit", "layer", "enable"), &Camera::set_cull_mask_bit);
- ClassDB::bind_method(D_METHOD("get_cull_mask_bit", "layer"), &Camera::get_cull_mask_bit);
+void Camera3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("project_ray_normal", "screen_point"), &Camera3D::project_ray_normal);
+ ClassDB::bind_method(D_METHOD("project_local_ray_normal", "screen_point"), &Camera3D::project_local_ray_normal);
+ ClassDB::bind_method(D_METHOD("project_ray_origin", "screen_point"), &Camera3D::project_ray_origin);
+ ClassDB::bind_method(D_METHOD("unproject_position", "world_point"), &Camera3D::unproject_position);
+ ClassDB::bind_method(D_METHOD("is_position_behind", "world_point"), &Camera3D::is_position_behind);
+ ClassDB::bind_method(D_METHOD("project_position", "screen_point", "z_depth"), &Camera3D::project_position);
+ ClassDB::bind_method(D_METHOD("set_perspective", "fov", "z_near", "z_far"), &Camera3D::set_perspective);
+ ClassDB::bind_method(D_METHOD("set_orthogonal", "size", "z_near", "z_far"), &Camera3D::set_orthogonal);
+ ClassDB::bind_method(D_METHOD("set_frustum", "size", "offset", "z_near", "z_far"), &Camera3D::set_frustum);
+ ClassDB::bind_method(D_METHOD("make_current"), &Camera3D::make_current);
+ ClassDB::bind_method(D_METHOD("clear_current", "enable_next"), &Camera3D::clear_current, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_current"), &Camera3D::set_current);
+ ClassDB::bind_method(D_METHOD("is_current"), &Camera3D::is_current);
+ ClassDB::bind_method(D_METHOD("get_camera_transform"), &Camera3D::get_camera_transform);
+ ClassDB::bind_method(D_METHOD("get_fov"), &Camera3D::get_fov);
+ ClassDB::bind_method(D_METHOD("get_frustum_offset"), &Camera3D::get_frustum_offset);
+ ClassDB::bind_method(D_METHOD("get_size"), &Camera3D::get_size);
+ ClassDB::bind_method(D_METHOD("get_zfar"), &Camera3D::get_zfar);
+ ClassDB::bind_method(D_METHOD("get_znear"), &Camera3D::get_znear);
+ ClassDB::bind_method(D_METHOD("set_fov"), &Camera3D::set_fov);
+ ClassDB::bind_method(D_METHOD("set_frustum_offset"), &Camera3D::set_frustum_offset);
+ ClassDB::bind_method(D_METHOD("set_size"), &Camera3D::set_size);
+ ClassDB::bind_method(D_METHOD("set_zfar"), &Camera3D::set_zfar);
+ ClassDB::bind_method(D_METHOD("set_znear"), &Camera3D::set_znear);
+ ClassDB::bind_method(D_METHOD("get_projection"), &Camera3D::get_projection);
+ ClassDB::bind_method(D_METHOD("set_projection"), &Camera3D::set_projection);
+ ClassDB::bind_method(D_METHOD("set_h_offset", "ofs"), &Camera3D::set_h_offset);
+ ClassDB::bind_method(D_METHOD("get_h_offset"), &Camera3D::get_h_offset);
+ ClassDB::bind_method(D_METHOD("set_v_offset", "ofs"), &Camera3D::set_v_offset);
+ ClassDB::bind_method(D_METHOD("get_v_offset"), &Camera3D::get_v_offset);
+ ClassDB::bind_method(D_METHOD("set_cull_mask", "mask"), &Camera3D::set_cull_mask);
+ ClassDB::bind_method(D_METHOD("get_cull_mask"), &Camera3D::get_cull_mask);
+ ClassDB::bind_method(D_METHOD("set_environment", "env"), &Camera3D::set_environment);
+ ClassDB::bind_method(D_METHOD("get_environment"), &Camera3D::get_environment);
+ ClassDB::bind_method(D_METHOD("set_effects", "env"), &Camera3D::set_effects);
+ ClassDB::bind_method(D_METHOD("get_effects"), &Camera3D::get_effects);
+ ClassDB::bind_method(D_METHOD("set_keep_aspect_mode", "mode"), &Camera3D::set_keep_aspect_mode);
+ ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera3D::get_keep_aspect_mode);
+ ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera3D::set_doppler_tracking);
+ ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera3D::get_doppler_tracking);
+ ClassDB::bind_method(D_METHOD("get_frustum"), &Camera3D::get_frustum);
+ ClassDB::bind_method(D_METHOD("get_camera_rid"), &Camera3D::get_camera);
+
+ ClassDB::bind_method(D_METHOD("set_cull_mask_bit", "layer", "enable"), &Camera3D::set_cull_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_cull_mask_bit", "layer"), &Camera3D::get_cull_mask_bit);
//ClassDB::bind_method(D_METHOD("_camera_make_current"),&Camera::_camera_make_current );
@@ -568,76 +568,76 @@ void Camera::_bind_methods() {
BIND_ENUM_CONSTANT(DOPPLER_TRACKING_PHYSICS_STEP);
}
-float Camera::get_fov() const {
+float Camera3D::get_fov() const {
return fov;
}
-float Camera::get_size() const {
+float Camera3D::get_size() const {
return size;
}
-float Camera::get_znear() const {
+float Camera3D::get_znear() const {
return near;
}
-Vector2 Camera::get_frustum_offset() const {
+Vector2 Camera3D::get_frustum_offset() const {
return frustum_offset;
}
-float Camera::get_zfar() const {
+float Camera3D::get_zfar() const {
return far;
}
-Camera::Projection Camera::get_projection() const {
+Camera3D::Projection Camera3D::get_projection() const {
return mode;
}
-void Camera::set_fov(float p_fov) {
+void Camera3D::set_fov(float p_fov) {
ERR_FAIL_COND(p_fov < 1 || p_fov > 179);
fov = p_fov;
_update_camera_mode();
_change_notify("fov");
}
-void Camera::set_size(float p_size) {
+void Camera3D::set_size(float p_size) {
ERR_FAIL_COND(p_size < 0.1 || p_size > 16384);
size = p_size;
_update_camera_mode();
_change_notify("size");
}
-void Camera::set_znear(float p_znear) {
+void Camera3D::set_znear(float p_znear) {
near = p_znear;
_update_camera_mode();
}
-void Camera::set_frustum_offset(Vector2 p_offset) {
+void Camera3D::set_frustum_offset(Vector2 p_offset) {
frustum_offset = p_offset;
_update_camera_mode();
}
-void Camera::set_zfar(float p_zfar) {
+void Camera3D::set_zfar(float p_zfar) {
far = p_zfar;
_update_camera_mode();
}
-void Camera::set_cull_mask(uint32_t p_layers) {
+void Camera3D::set_cull_mask(uint32_t p_layers) {
layers = p_layers;
- VisualServer::get_singleton()->camera_set_cull_mask(camera, layers);
+ RenderingServer::get_singleton()->camera_set_cull_mask(camera, layers);
_update_camera_mode();
}
-uint32_t Camera::get_cull_mask() const {
+uint32_t Camera3D::get_cull_mask() const {
return layers;
}
-void Camera::set_cull_mask_bit(int p_layer, bool p_enable) {
+void Camera3D::set_cull_mask_bit(int p_layer, bool p_enable) {
ERR_FAIL_INDEX(p_layer, 32);
if (p_enable) {
set_cull_mask(layers | (1 << p_layer));
@@ -646,12 +646,12 @@ void Camera::set_cull_mask_bit(int p_layer, bool p_enable) {
}
}
-bool Camera::get_cull_mask_bit(int p_layer) const {
+bool Camera3D::get_cull_mask_bit(int p_layer) const {
ERR_FAIL_INDEX_V(p_layer, 32, false);
return (layers & (1 << p_layer));
}
-Vector<Plane> Camera::get_frustum() const {
+Vector<Plane> Camera3D::get_frustum() const {
ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
@@ -665,28 +665,28 @@ Vector<Plane> Camera::get_frustum() const {
return cm.get_projection_planes(get_camera_transform());
}
-void Camera::set_v_offset(float p_offset) {
+void Camera3D::set_v_offset(float p_offset) {
v_offset = p_offset;
_update_camera();
}
-float Camera::get_v_offset() const {
+float Camera3D::get_v_offset() const {
return v_offset;
}
-void Camera::set_h_offset(float p_offset) {
+void Camera3D::set_h_offset(float p_offset) {
h_offset = p_offset;
_update_camera();
}
-float Camera::get_h_offset() const {
+float Camera3D::get_h_offset() const {
return h_offset;
}
-Vector3 Camera::get_doppler_tracked_velocity() const {
+Vector3 Camera3D::get_doppler_tracked_velocity() const {
if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
return velocity_tracker->get_tracked_linear_velocity();
@@ -694,9 +694,9 @@ Vector3 Camera::get_doppler_tracked_velocity() const {
return Vector3();
}
}
-Camera::Camera() {
+Camera3D::Camera3D() {
- camera = VisualServer::get_singleton()->camera_create();
+ camera = RenderingServer::get_singleton()->camera_create();
size = 1;
fov = 0;
frustum_offset = Vector2();
@@ -711,7 +711,7 @@ Camera::Camera() {
layers = 0xfffff;
v_offset = 0;
h_offset = 0;
- VisualServer::get_singleton()->camera_set_cull_mask(camera, layers);
+ RenderingServer::get_singleton()->camera_set_cull_mask(camera, layers);
//active=false;
velocity_tracker.instance();
doppler_tracking = DOPPLER_TRACKING_DISABLED;
@@ -719,20 +719,20 @@ Camera::Camera() {
set_disable_scale(true);
}
-Camera::~Camera() {
+Camera3D::~Camera3D() {
- VisualServer::get_singleton()->free(camera);
+ RenderingServer::get_singleton()->free(camera);
}
////////////////////////////////////////
-void ClippedCamera::set_margin(float p_margin) {
+void ClippedCamera3D::set_margin(float p_margin) {
margin = p_margin;
}
-float ClippedCamera::get_margin() const {
+float ClippedCamera3D::get_margin() const {
return margin;
}
-void ClippedCamera::set_process_mode(ProcessMode p_mode) {
+void ClippedCamera3D::set_process_mode(ProcessMode p_mode) {
if (process_mode == p_mode) {
return;
@@ -741,26 +741,26 @@ void ClippedCamera::set_process_mode(ProcessMode p_mode) {
set_process_internal(process_mode == CLIP_PROCESS_IDLE);
set_physics_process_internal(process_mode == CLIP_PROCESS_PHYSICS);
}
-ClippedCamera::ProcessMode ClippedCamera::get_process_mode() const {
+ClippedCamera3D::ProcessMode ClippedCamera3D::get_process_mode() const {
return process_mode;
}
-Transform ClippedCamera::get_camera_transform() const {
+Transform ClippedCamera3D::get_camera_transform() const {
- Transform t = Camera::get_camera_transform();
+ Transform t = Camera3D::get_camera_transform();
t.origin += -t.basis.get_axis(Vector3::AXIS_Z).normalized() * clip_offset;
return t;
}
-void ClippedCamera::_notification(int p_what) {
+void ClippedCamera3D::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS || p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
- Spatial *parent = Object::cast_to<Spatial>(get_parent());
+ Node3D *parent = Object::cast_to<Node3D>(get_parent());
if (!parent) {
return;
}
- PhysicsDirectSpaceState *dspace = get_world()->get_direct_space_state();
+ PhysicsDirectSpaceState3D *dspace = get_world()->get_direct_space_state();
ERR_FAIL_COND(!dspace); // most likely physics set to threads
Vector3 cam_fw = -get_global_transform().basis.get_axis(Vector3::AXIS_Z).normalized();
@@ -791,7 +791,7 @@ void ClippedCamera::_notification(int p_what) {
}
if (!all_equal) {
- PhysicsServer::get_singleton()->shape_set_data(pyramid_shape, local_points);
+ PhysicsServer3D::get_singleton()->shape_set_data(pyramid_shape, local_points);
points = local_points;
}
}
@@ -813,17 +813,17 @@ void ClippedCamera::_notification(int p_what) {
}
}
-void ClippedCamera::set_collision_mask(uint32_t p_mask) {
+void ClippedCamera3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
}
-uint32_t ClippedCamera::get_collision_mask() const {
+uint32_t ClippedCamera3D::get_collision_mask() const {
return collision_mask;
}
-void ClippedCamera::set_collision_mask_bit(int p_bit, bool p_value) {
+void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
@@ -833,98 +833,98 @@ void ClippedCamera::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool ClippedCamera::get_collision_mask_bit(int p_bit) const {
+bool ClippedCamera3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-void ClippedCamera::add_exception_rid(const RID &p_rid) {
+void ClippedCamera3D::add_exception_rid(const RID &p_rid) {
exclude.insert(p_rid);
}
-void ClippedCamera::add_exception(const Object *p_object) {
+void ClippedCamera3D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
+ const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
if (!co)
return;
add_exception_rid(co->get_rid());
}
-void ClippedCamera::remove_exception_rid(const RID &p_rid) {
+void ClippedCamera3D::remove_exception_rid(const RID &p_rid) {
exclude.erase(p_rid);
}
-void ClippedCamera::remove_exception(const Object *p_object) {
+void ClippedCamera3D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
+ const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
if (!co)
return;
remove_exception_rid(co->get_rid());
}
-void ClippedCamera::clear_exceptions() {
+void ClippedCamera3D::clear_exceptions() {
exclude.clear();
}
-float ClippedCamera::get_clip_offset() const {
+float ClippedCamera3D::get_clip_offset() const {
return clip_offset;
}
-void ClippedCamera::set_clip_to_areas(bool p_clip) {
+void ClippedCamera3D::set_clip_to_areas(bool p_clip) {
clip_to_areas = p_clip;
}
-bool ClippedCamera::is_clip_to_areas_enabled() const {
+bool ClippedCamera3D::is_clip_to_areas_enabled() const {
return clip_to_areas;
}
-void ClippedCamera::set_clip_to_bodies(bool p_clip) {
+void ClippedCamera3D::set_clip_to_bodies(bool p_clip) {
clip_to_bodies = p_clip;
}
-bool ClippedCamera::is_clip_to_bodies_enabled() const {
+bool ClippedCamera3D::is_clip_to_bodies_enabled() const {
return clip_to_bodies;
}
-void ClippedCamera::_bind_methods() {
+void ClippedCamera3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &ClippedCamera::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &ClippedCamera::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &ClippedCamera3D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &ClippedCamera3D::get_margin);
- ClassDB::bind_method(D_METHOD("set_process_mode", "process_mode"), &ClippedCamera::set_process_mode);
- ClassDB::bind_method(D_METHOD("get_process_mode"), &ClippedCamera::get_process_mode);
+ ClassDB::bind_method(D_METHOD("set_process_mode", "process_mode"), &ClippedCamera3D::set_process_mode);
+ ClassDB::bind_method(D_METHOD("get_process_mode"), &ClippedCamera3D::get_process_mode);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &ClippedCamera::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &ClippedCamera::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &ClippedCamera3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &ClippedCamera3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &ClippedCamera::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &ClippedCamera::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &ClippedCamera3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &ClippedCamera3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("add_exception_rid", "rid"), &ClippedCamera::add_exception_rid);
- ClassDB::bind_method(D_METHOD("add_exception", "node"), &ClippedCamera::add_exception);
+ ClassDB::bind_method(D_METHOD("add_exception_rid", "rid"), &ClippedCamera3D::add_exception_rid);
+ ClassDB::bind_method(D_METHOD("add_exception", "node"), &ClippedCamera3D::add_exception);
- ClassDB::bind_method(D_METHOD("remove_exception_rid", "rid"), &ClippedCamera::remove_exception_rid);
- ClassDB::bind_method(D_METHOD("remove_exception", "node"), &ClippedCamera::remove_exception);
+ ClassDB::bind_method(D_METHOD("remove_exception_rid", "rid"), &ClippedCamera3D::remove_exception_rid);
+ ClassDB::bind_method(D_METHOD("remove_exception", "node"), &ClippedCamera3D::remove_exception);
- ClassDB::bind_method(D_METHOD("set_clip_to_areas", "enable"), &ClippedCamera::set_clip_to_areas);
- ClassDB::bind_method(D_METHOD("is_clip_to_areas_enabled"), &ClippedCamera::is_clip_to_areas_enabled);
+ ClassDB::bind_method(D_METHOD("set_clip_to_areas", "enable"), &ClippedCamera3D::set_clip_to_areas);
+ ClassDB::bind_method(D_METHOD("is_clip_to_areas_enabled"), &ClippedCamera3D::is_clip_to_areas_enabled);
- ClassDB::bind_method(D_METHOD("get_clip_offset"), &ClippedCamera::get_clip_offset);
+ ClassDB::bind_method(D_METHOD("get_clip_offset"), &ClippedCamera3D::get_clip_offset);
- ClassDB::bind_method(D_METHOD("set_clip_to_bodies", "enable"), &ClippedCamera::set_clip_to_bodies);
- ClassDB::bind_method(D_METHOD("is_clip_to_bodies_enabled"), &ClippedCamera::is_clip_to_bodies_enabled);
+ ClassDB::bind_method(D_METHOD("set_clip_to_bodies", "enable"), &ClippedCamera3D::set_clip_to_bodies);
+ ClassDB::bind_method(D_METHOD("is_clip_to_bodies_enabled"), &ClippedCamera3D::is_clip_to_bodies_enabled);
- ClassDB::bind_method(D_METHOD("clear_exceptions"), &ClippedCamera::clear_exceptions);
+ ClassDB::bind_method(D_METHOD("clear_exceptions"), &ClippedCamera3D::clear_exceptions);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_margin", "get_margin");
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_mode", "get_process_mode");
@@ -937,7 +937,7 @@ void ClippedCamera::_bind_methods() {
BIND_ENUM_CONSTANT(CLIP_PROCESS_PHYSICS);
BIND_ENUM_CONSTANT(CLIP_PROCESS_IDLE);
}
-ClippedCamera::ClippedCamera() {
+ClippedCamera3D::ClippedCamera3D() {
margin = 0;
clip_offset = 0;
process_mode = CLIP_PROCESS_PHYSICS;
@@ -945,10 +945,10 @@ ClippedCamera::ClippedCamera() {
collision_mask = 1;
set_notify_local_transform(Engine::get_singleton()->is_editor_hint());
points.resize(5);
- pyramid_shape = PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON);
+ pyramid_shape = PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON);
clip_to_areas = false;
clip_to_bodies = true;
}
-ClippedCamera::~ClippedCamera() {
- PhysicsServer::get_singleton()->free(pyramid_shape);
+ClippedCamera3D::~ClippedCamera3D() {
+ PhysicsServer3D::get_singleton()->free(pyramid_shape);
}
diff --git a/scene/3d/camera.h b/scene/3d/camera_3d.h
index 6ac3ece798..9a005226cb 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* camera.h */
+/* camera_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CAMERA_H
-#define CAMERA_H
+#ifndef CAMERA_3D_H
+#define CAMERA_3D_H
-#include "scene/3d/spatial.h"
-#include "scene/3d/spatial_velocity_tracker.h"
-#include "scene/main/viewport.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/velocity_tracker_3d.h"
+#include "scene/main/window.h"
#include "scene/resources/environment.h"
-class Camera : public Spatial {
+class Camera3D : public Node3D {
- GDCLASS(Camera, Spatial);
+ GDCLASS(Camera3D, Node3D);
public:
enum Projection {
@@ -48,10 +48,8 @@ public:
PROJECTION_FRUSTUM
};
- enum KeepAspect {
- KEEP_WIDTH,
- KEEP_HEIGHT
- };
+ enum KeepAspect { KEEP_WIDTH,
+ KEEP_HEIGHT };
enum DopplerTracking {
DOPPLER_TRACKING_DISABLED,
@@ -77,7 +75,7 @@ private:
RID camera;
RID scenario_id;
- //String camera_group;
+ // String camera_group;
uint32_t layers;
@@ -86,12 +84,12 @@ private:
virtual bool _can_gizmo_scale() const;
- //void _camera_make_current(Node *p_camera);
+ // void _camera_make_current(Node *p_camera);
friend class Viewport;
void _update_audio_listener_state();
DopplerTracking doppler_tracking;
- Ref<SpatialVelocityTracker> velocity_tracker;
+ Ref<VelocityTracker3D> velocity_tracker;
protected:
void _update_camera();
@@ -112,8 +110,9 @@ public:
void set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
void set_orthogonal(float p_size, float p_z_near, float p_z_far);
- void set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far);
- void set_projection(Camera::Projection p_mode);
+ void set_frustum(float p_size, Vector2 p_offset, float p_z_near,
+ float p_z_far);
+ void set_projection(Camera3D::Projection p_mode);
void make_current();
void clear_current(bool p_enable_next = true);
@@ -143,7 +142,8 @@ public:
virtual Vector3 project_local_ray_normal(const Point2 &p_pos) const;
virtual Point2 unproject_position(const Vector3 &p_pos) const;
bool is_position_behind(const Vector3 &p_pos) const;
- virtual Vector3 project_position(const Point2 &p_point, float p_z_depth) const;
+ virtual Vector3 project_position(const Point2 &p_point,
+ float p_z_depth) const;
Vector<Vector3> get_near_plane_points() const;
@@ -175,17 +175,17 @@ public:
Vector3 get_doppler_tracked_velocity() const;
- Camera();
- ~Camera();
+ Camera3D();
+ ~Camera3D();
};
-VARIANT_ENUM_CAST(Camera::Projection);
-VARIANT_ENUM_CAST(Camera::KeepAspect);
-VARIANT_ENUM_CAST(Camera::DopplerTracking);
+VARIANT_ENUM_CAST(Camera3D::Projection);
+VARIANT_ENUM_CAST(Camera3D::KeepAspect);
+VARIANT_ENUM_CAST(Camera3D::DopplerTracking);
-class ClippedCamera : public Camera {
+class ClippedCamera3D : public Camera3D {
- GDCLASS(ClippedCamera, Camera);
+ GDCLASS(ClippedCamera3D, Camera3D);
public:
enum ProcessMode {
@@ -238,9 +238,9 @@ public:
float get_clip_offset() const;
- ClippedCamera();
- ~ClippedCamera();
+ ClippedCamera3D();
+ ~ClippedCamera3D();
};
-VARIANT_ENUM_CAST(ClippedCamera::ProcessMode);
+VARIANT_ENUM_CAST(ClippedCamera3D::ProcessMode);
#endif
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object_3d.cpp
index c067ef34a6..da37ca8ae2 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_object.cpp */
+/* collision_object_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,27 +28,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_object.h"
+#include "collision_object_3d.h"
#include "scene/scene_string_names.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-void CollisionObject::_notification(int p_what) {
+void CollisionObject3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
if (area)
- PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform());
+ PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
else
- PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
RID space = get_world()->get_space();
if (area) {
- PhysicsServer::get_singleton()->area_set_space(rid, space);
+ PhysicsServer3D::get_singleton()->area_set_space(rid, space);
} else
- PhysicsServer::get_singleton()->body_set_space(rid, space);
+ PhysicsServer3D::get_singleton()->body_set_space(rid, space);
_update_pickable();
//get space
@@ -57,9 +57,9 @@ void CollisionObject::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
if (area)
- PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform());
+ PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
else
- PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -70,15 +70,15 @@ void CollisionObject::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
if (area) {
- PhysicsServer::get_singleton()->area_set_space(rid, RID());
+ PhysicsServer3D::get_singleton()->area_set_space(rid, RID());
} else
- PhysicsServer::get_singleton()->body_set_space(rid, RID());
+ PhysicsServer3D::get_singleton()->body_set_space(rid, RID());
} break;
}
}
-void CollisionObject::_input_event(Node *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
+void CollisionObject3D::_input_event(Node *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_camera, p_input_event, p_pos, p_normal, p_shape);
@@ -86,7 +86,7 @@ void CollisionObject::_input_event(Node *p_camera, const Ref<InputEvent> &p_inpu
emit_signal(SceneStringNames::get_singleton()->input_event, p_camera, p_input_event, p_pos, p_normal, p_shape);
}
-void CollisionObject::_mouse_enter() {
+void CollisionObject3D::_mouse_enter() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
@@ -94,7 +94,7 @@ void CollisionObject::_mouse_enter() {
emit_signal(SceneStringNames::get_singleton()->mouse_entered);
}
-void CollisionObject::_mouse_exit() {
+void CollisionObject3D::_mouse_exit() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
@@ -102,50 +102,50 @@ void CollisionObject::_mouse_exit() {
emit_signal(SceneStringNames::get_singleton()->mouse_exited);
}
-void CollisionObject::_update_pickable() {
+void CollisionObject3D::_update_pickable() {
if (!is_inside_tree())
return;
bool pickable = ray_pickable && is_visible_in_tree();
if (area)
- PhysicsServer::get_singleton()->area_set_ray_pickable(rid, pickable);
+ PhysicsServer3D::get_singleton()->area_set_ray_pickable(rid, pickable);
else
- PhysicsServer::get_singleton()->body_set_ray_pickable(rid, pickable);
+ PhysicsServer3D::get_singleton()->body_set_ray_pickable(rid, pickable);
}
-void CollisionObject::set_ray_pickable(bool p_ray_pickable) {
+void CollisionObject3D::set_ray_pickable(bool p_ray_pickable) {
ray_pickable = p_ray_pickable;
_update_pickable();
}
-bool CollisionObject::is_ray_pickable() const {
+bool CollisionObject3D::is_ray_pickable() const {
return ray_pickable;
}
-void CollisionObject::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &CollisionObject::set_ray_pickable);
- ClassDB::bind_method(D_METHOD("is_ray_pickable"), &CollisionObject::is_ray_pickable);
- ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject::set_capture_input_on_drag);
- ClassDB::bind_method(D_METHOD("get_capture_input_on_drag"), &CollisionObject::get_capture_input_on_drag);
- ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject::get_rid);
- ClassDB::bind_method(D_METHOD("create_shape_owner", "owner"), &CollisionObject::create_shape_owner);
- ClassDB::bind_method(D_METHOD("remove_shape_owner", "owner_id"), &CollisionObject::remove_shape_owner);
- ClassDB::bind_method(D_METHOD("get_shape_owners"), &CollisionObject::_get_shape_owners);
- ClassDB::bind_method(D_METHOD("shape_owner_set_transform", "owner_id", "transform"), &CollisionObject::shape_owner_set_transform);
- ClassDB::bind_method(D_METHOD("shape_owner_get_transform", "owner_id"), &CollisionObject::shape_owner_get_transform);
- ClassDB::bind_method(D_METHOD("shape_owner_get_owner", "owner_id"), &CollisionObject::shape_owner_get_owner);
- ClassDB::bind_method(D_METHOD("shape_owner_set_disabled", "owner_id", "disabled"), &CollisionObject::shape_owner_set_disabled);
- ClassDB::bind_method(D_METHOD("is_shape_owner_disabled", "owner_id"), &CollisionObject::is_shape_owner_disabled);
- ClassDB::bind_method(D_METHOD("shape_owner_add_shape", "owner_id", "shape"), &CollisionObject::shape_owner_add_shape);
- ClassDB::bind_method(D_METHOD("shape_owner_get_shape_count", "owner_id"), &CollisionObject::shape_owner_get_shape_count);
- ClassDB::bind_method(D_METHOD("shape_owner_get_shape", "owner_id", "shape_id"), &CollisionObject::shape_owner_get_shape);
- ClassDB::bind_method(D_METHOD("shape_owner_get_shape_index", "owner_id", "shape_id"), &CollisionObject::shape_owner_get_shape_index);
- ClassDB::bind_method(D_METHOD("shape_owner_remove_shape", "owner_id", "shape_id"), &CollisionObject::shape_owner_remove_shape);
- ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject::shape_owner_clear_shapes);
- ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject::shape_find_owner);
+void CollisionObject3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &CollisionObject3D::set_ray_pickable);
+ ClassDB::bind_method(D_METHOD("is_ray_pickable"), &CollisionObject3D::is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject3D::set_capture_input_on_drag);
+ ClassDB::bind_method(D_METHOD("get_capture_input_on_drag"), &CollisionObject3D::get_capture_input_on_drag);
+ ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject3D::get_rid);
+ ClassDB::bind_method(D_METHOD("create_shape_owner", "owner"), &CollisionObject3D::create_shape_owner);
+ ClassDB::bind_method(D_METHOD("remove_shape_owner", "owner_id"), &CollisionObject3D::remove_shape_owner);
+ ClassDB::bind_method(D_METHOD("get_shape_owners"), &CollisionObject3D::_get_shape_owners);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_transform", "owner_id", "transform"), &CollisionObject3D::shape_owner_set_transform);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_transform", "owner_id"), &CollisionObject3D::shape_owner_get_transform);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_owner", "owner_id"), &CollisionObject3D::shape_owner_get_owner);
+ ClassDB::bind_method(D_METHOD("shape_owner_set_disabled", "owner_id", "disabled"), &CollisionObject3D::shape_owner_set_disabled);
+ ClassDB::bind_method(D_METHOD("is_shape_owner_disabled", "owner_id"), &CollisionObject3D::is_shape_owner_disabled);
+ ClassDB::bind_method(D_METHOD("shape_owner_add_shape", "owner_id", "shape"), &CollisionObject3D::shape_owner_add_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape_count", "owner_id"), &CollisionObject3D::shape_owner_get_shape_count);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape", "owner_id", "shape_id"), &CollisionObject3D::shape_owner_get_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_get_shape_index", "owner_id", "shape_id"), &CollisionObject3D::shape_owner_get_shape_index);
+ ClassDB::bind_method(D_METHOD("shape_owner_remove_shape", "owner_id", "shape_id"), &CollisionObject3D::shape_owner_remove_shape);
+ ClassDB::bind_method(D_METHOD("shape_owner_clear_shapes", "owner_id"), &CollisionObject3D::shape_owner_clear_shapes);
+ ClassDB::bind_method(D_METHOD("shape_find_owner", "shape_index"), &CollisionObject3D::shape_find_owner);
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::VECTOR3, "click_position"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
@@ -157,7 +157,7 @@ void CollisionObject::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input_capture_on_drag"), "set_capture_input_on_drag", "get_capture_input_on_drag");
}
-uint32_t CollisionObject::create_shape_owner(Object *p_owner) {
+uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) {
ShapeData sd;
uint32_t id;
@@ -175,7 +175,7 @@ uint32_t CollisionObject::create_shape_owner(Object *p_owner) {
return id;
}
-void CollisionObject::remove_shape_owner(uint32_t owner) {
+void CollisionObject3D::remove_shape_owner(uint32_t owner) {
ERR_FAIL_COND(!shapes.has(owner));
@@ -184,35 +184,35 @@ void CollisionObject::remove_shape_owner(uint32_t owner) {
shapes.erase(owner);
}
-void CollisionObject::shape_owner_set_disabled(uint32_t p_owner, bool p_disabled) {
+void CollisionObject3D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabled) {
ERR_FAIL_COND(!shapes.has(p_owner));
ShapeData &sd = shapes[p_owner];
sd.disabled = p_disabled;
for (int i = 0; i < sd.shapes.size(); i++) {
if (area) {
- PhysicsServer::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
+ PhysicsServer3D::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
} else {
- PhysicsServer::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
+ PhysicsServer3D::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled);
}
}
}
-bool CollisionObject::is_shape_owner_disabled(uint32_t p_owner) const {
+bool CollisionObject3D::is_shape_owner_disabled(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), false);
return shapes[p_owner].disabled;
}
-void CollisionObject::get_shape_owners(List<uint32_t> *r_owners) {
+void CollisionObject3D::get_shape_owners(List<uint32_t> *r_owners) {
for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
r_owners->push_back(E->key());
}
}
-Array CollisionObject::_get_shape_owners() {
+Array CollisionObject3D::_get_shape_owners() {
Array ret;
for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
@@ -222,7 +222,7 @@ Array CollisionObject::_get_shape_owners() {
return ret;
}
-void CollisionObject::shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform) {
+void CollisionObject3D::shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform) {
ERR_FAIL_COND(!shapes.has(p_owner));
@@ -230,27 +230,27 @@ void CollisionObject::shape_owner_set_transform(uint32_t p_owner, const Transfor
sd.xform = p_transform;
for (int i = 0; i < sd.shapes.size(); i++) {
if (area) {
- PhysicsServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ PhysicsServer3D::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform);
} else {
- PhysicsServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ PhysicsServer3D::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform);
}
}
}
-Transform CollisionObject::shape_owner_get_transform(uint32_t p_owner) const {
+Transform CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), Transform());
return shapes[p_owner].xform;
}
-Object *CollisionObject::shape_owner_get_owner(uint32_t p_owner) const {
+Object *CollisionObject3D::shape_owner_get_owner(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), NULL);
return shapes[p_owner].owner;
}
-void CollisionObject::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape> &p_shape) {
+void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3D> &p_shape) {
ERR_FAIL_COND(!shapes.has(p_owner));
ERR_FAIL_COND(p_shape.is_null());
@@ -260,28 +260,28 @@ void CollisionObject::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape> &
s.index = total_subshapes;
s.shape = p_shape;
if (area) {
- PhysicsServer::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
+ PhysicsServer3D::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
} else {
- PhysicsServer::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
+ PhysicsServer3D::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled);
}
sd.shapes.push_back(s);
total_subshapes++;
}
-int CollisionObject::shape_owner_get_shape_count(uint32_t p_owner) const {
+int CollisionObject3D::shape_owner_get_shape_count(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
return shapes[p_owner].shapes.size();
}
-Ref<Shape> CollisionObject::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
+Ref<Shape3D> CollisionObject3D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
- ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape>());
- ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape>());
+ ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape3D>());
+ ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape3D>());
return shapes[p_owner].shapes[p_shape].shape;
}
-int CollisionObject::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
+int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), -1);
ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), -1);
@@ -289,16 +289,16 @@ int CollisionObject::shape_owner_get_shape_index(uint32_t p_owner, int p_shape)
return shapes[p_owner].shapes[p_shape].index;
}
-void CollisionObject::shape_owner_remove_shape(uint32_t p_owner, int p_shape) {
+void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) {
ERR_FAIL_COND(!shapes.has(p_owner));
ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size());
int index_to_remove = shapes[p_owner].shapes[p_shape].index;
if (area) {
- PhysicsServer::get_singleton()->area_remove_shape(rid, index_to_remove);
+ PhysicsServer3D::get_singleton()->area_remove_shape(rid, index_to_remove);
} else {
- PhysicsServer::get_singleton()->body_remove_shape(rid, index_to_remove);
+ PhysicsServer3D::get_singleton()->body_remove_shape(rid, index_to_remove);
}
shapes[p_owner].shapes.remove(p_shape);
@@ -314,7 +314,7 @@ void CollisionObject::shape_owner_remove_shape(uint32_t p_owner, int p_shape) {
total_subshapes--;
}
-void CollisionObject::shape_owner_clear_shapes(uint32_t p_owner) {
+void CollisionObject3D::shape_owner_clear_shapes(uint32_t p_owner) {
ERR_FAIL_COND(!shapes.has(p_owner));
@@ -323,7 +323,7 @@ void CollisionObject::shape_owner_clear_shapes(uint32_t p_owner) {
}
}
-uint32_t CollisionObject::shape_find_owner(int p_shape_index) const {
+uint32_t CollisionObject3D::shape_find_owner(int p_shape_index) const {
ERR_FAIL_INDEX_V(p_shape_index, total_subshapes, 0);
@@ -339,7 +339,7 @@ uint32_t CollisionObject::shape_find_owner(int p_shape_index) const {
return 0;
}
-CollisionObject::CollisionObject(RID p_rid, bool p_area) {
+CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) {
rid = p_rid;
area = p_area;
@@ -349,26 +349,26 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) {
total_subshapes = 0;
if (p_area) {
- PhysicsServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
+ PhysicsServer3D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
} else {
- PhysicsServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
}
//set_transform_notify(true);
}
-void CollisionObject::set_capture_input_on_drag(bool p_capture) {
+void CollisionObject3D::set_capture_input_on_drag(bool p_capture) {
capture_input_on_drag = p_capture;
}
-bool CollisionObject::get_capture_input_on_drag() const {
+bool CollisionObject3D::get_capture_input_on_drag() const {
return capture_input_on_drag;
}
-String CollisionObject::get_configuration_warning() const {
+String CollisionObject3D::get_configuration_warning() const {
- String warning = Spatial::get_configuration_warning();
+ String warning = Node3D::get_configuration_warning();
if (shapes.empty()) {
if (!warning.empty()) {
@@ -380,7 +380,7 @@ String CollisionObject::get_configuration_warning() const {
return warning;
}
-CollisionObject::CollisionObject() {
+CollisionObject3D::CollisionObject3D() {
capture_input_on_drag = false;
ray_pickable = true;
@@ -390,7 +390,7 @@ CollisionObject::CollisionObject() {
//set_transform_notify(true);
}
-CollisionObject::~CollisionObject() {
+CollisionObject3D::~CollisionObject3D() {
- PhysicsServer::get_singleton()->free(rid);
+ PhysicsServer3D::get_singleton()->free(rid);
}
diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object_3d.h
index 572e73d51b..6a70f56caa 100644
--- a/scene/3d/collision_object.h
+++ b/scene/3d/collision_object_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_object.h */
+/* collision_object_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef COLLISION_OBJECT_H
-#define COLLISION_OBJECT_H
+#ifndef COLLISION_OBJECT_3D_H
+#define COLLISION_OBJECT_3D_H
-#include "scene/3d/spatial.h"
-#include "scene/resources/shape.h"
+#include "scene/3d/node_3d.h"
+#include "scene/resources/shape_3d.h"
-class CollisionObject : public Spatial {
+class CollisionObject3D : public Node3D {
- GDCLASS(CollisionObject, Spatial);
+ GDCLASS(CollisionObject3D, Node3D);
bool area;
@@ -47,7 +47,7 @@ class CollisionObject : public Spatial {
Object *owner;
Transform xform;
struct ShapeBase {
- Ref<Shape> shape;
+ Ref<Shape3D> shape;
int index;
};
@@ -70,7 +70,7 @@ class CollisionObject : public Spatial {
void _update_pickable();
protected:
- CollisionObject(RID p_rid, bool p_area);
+ CollisionObject3D(RID p_rid, bool p_area);
void _notification(int p_what);
static void _bind_methods();
@@ -92,9 +92,9 @@ public:
void shape_owner_set_disabled(uint32_t p_owner, bool p_disabled);
bool is_shape_owner_disabled(uint32_t p_owner) const;
- void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape> &p_shape);
+ void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
- Ref<Shape> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
+ Ref<Shape3D> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
void shape_owner_remove_shape(uint32_t p_owner, int p_shape);
@@ -112,8 +112,8 @@ public:
virtual String get_configuration_warning() const;
- CollisionObject();
- ~CollisionObject();
+ CollisionObject3D();
+ ~CollisionObject3D();
};
#endif // COLLISION_OBJECT__H
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon_3d.cpp
index 24c3a9eb41..c8b1b728bc 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_polygon.cpp */
+/* collision_polygon_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_polygon.h"
+#include "collision_polygon_3d.h"
-#include "collision_object.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
+#include "collision_object_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
-void CollisionPolygon::_build_polygon() {
+void CollisionPolygon3D::_build_polygon() {
if (!parent)
return;
@@ -52,7 +52,7 @@ void CollisionPolygon::_build_polygon() {
//decompose concave into multiple convex polygons and add them
for (int i = 0; i < decomp.size(); i++) {
- Ref<ConvexPolygonShape> convex = memnew(ConvexPolygonShape);
+ Ref<ConvexPolygonShape3D> convex = memnew(ConvexPolygonShape3D);
Vector<Vector3> cp;
int cs = decomp[i].size();
cp.resize(cs * 2);
@@ -73,7 +73,7 @@ void CollisionPolygon::_build_polygon() {
}
}
-void CollisionPolygon::_update_in_shape_owner(bool p_xform_only) {
+void CollisionPolygon3D::_update_in_shape_owner(bool p_xform_only) {
parent->shape_owner_set_transform(owner_id, get_transform());
if (p_xform_only)
@@ -81,12 +81,12 @@ void CollisionPolygon::_update_in_shape_owner(bool p_xform_only) {
parent->shape_owner_set_disabled(owner_id, disabled);
}
-void CollisionPolygon::_notification(int p_what) {
+void CollisionPolygon3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_PARENTED: {
- parent = Object::cast_to<CollisionObject>(get_parent());
+ parent = Object::cast_to<CollisionObject3D>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
_build_polygon();
@@ -117,7 +117,7 @@ void CollisionPolygon::_notification(int p_what) {
}
}
-void CollisionPolygon::set_polygon(const Vector<Point2> &p_polygon) {
+void CollisionPolygon3D::set_polygon(const Vector<Point2> &p_polygon) {
polygon = p_polygon;
if (parent) {
@@ -127,29 +127,29 @@ void CollisionPolygon::set_polygon(const Vector<Point2> &p_polygon) {
update_gizmo();
}
-Vector<Point2> CollisionPolygon::get_polygon() const {
+Vector<Point2> CollisionPolygon3D::get_polygon() const {
return polygon;
}
-AABB CollisionPolygon::get_item_rect() const {
+AABB CollisionPolygon3D::get_item_rect() const {
return aabb;
}
-void CollisionPolygon::set_depth(float p_depth) {
+void CollisionPolygon3D::set_depth(float p_depth) {
depth = p_depth;
_build_polygon();
update_gizmo();
}
-float CollisionPolygon::get_depth() const {
+float CollisionPolygon3D::get_depth() const {
return depth;
}
-void CollisionPolygon::set_disabled(bool p_disabled) {
+void CollisionPolygon3D::set_disabled(bool p_disabled) {
disabled = p_disabled;
update_gizmo();
@@ -158,13 +158,13 @@ void CollisionPolygon::set_disabled(bool p_disabled) {
}
}
-bool CollisionPolygon::is_disabled() const {
+bool CollisionPolygon3D::is_disabled() const {
return disabled;
}
-String CollisionPolygon::get_configuration_warning() const {
+String CollisionPolygon3D::get_configuration_warning() const {
- if (!Object::cast_to<CollisionObject>(get_parent())) {
+ if (!Object::cast_to<CollisionObject3D>(get_parent())) {
return TTR("CollisionPolygon only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
}
@@ -175,28 +175,28 @@ String CollisionPolygon::get_configuration_warning() const {
return String();
}
-bool CollisionPolygon::_is_editable_3d_polygon() const {
+bool CollisionPolygon3D::_is_editable_3d_polygon() const {
return true;
}
-void CollisionPolygon::_bind_methods() {
+void CollisionPolygon3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CollisionPolygon::set_depth);
- ClassDB::bind_method(D_METHOD("get_depth"), &CollisionPolygon::get_depth);
+ ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CollisionPolygon3D::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"), &CollisionPolygon3D::get_depth);
- ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CollisionPolygon::set_polygon);
- ClassDB::bind_method(D_METHOD("get_polygon"), &CollisionPolygon::get_polygon);
+ ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CollisionPolygon3D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"), &CollisionPolygon3D::get_polygon);
- ClassDB::bind_method(D_METHOD("set_disabled", "disabled"), &CollisionPolygon::set_disabled);
- ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionPolygon::is_disabled);
+ ClassDB::bind_method(D_METHOD("set_disabled", "disabled"), &CollisionPolygon3D::set_disabled);
+ ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionPolygon3D::is_disabled);
- ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &CollisionPolygon::_is_editable_3d_polygon);
+ ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &CollisionPolygon3D::_is_editable_3d_polygon);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth"), "set_depth", "get_depth");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
}
-CollisionPolygon::CollisionPolygon() {
+CollisionPolygon3D::CollisionPolygon3D() {
aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
depth = 1.0;
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon_3d.h
index 9ecdc02697..256aee3d7e 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_polygon.h */
+/* collision_polygon_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef COLLISION_POLYGON_H
-#define COLLISION_POLYGON_H
+#ifndef COLLISION_POLYGON_3D_H
+#define COLLISION_POLYGON_3D_H
-#include "scene/3d/spatial.h"
-#include "scene/resources/shape.h"
+#include "scene/3d/node_3d.h"
+#include "scene/resources/shape_3d.h"
-class CollisionObject;
-class CollisionPolygon : public Spatial {
+class CollisionObject3D;
+class CollisionPolygon3D : public Node3D {
- GDCLASS(CollisionPolygon, Spatial);
+ GDCLASS(CollisionPolygon3D, Node3D);
protected:
float depth;
@@ -45,7 +45,7 @@ protected:
Vector<Point2> polygon;
uint32_t owner_id;
- CollisionObject *parent;
+ CollisionObject3D *parent;
bool disabled;
@@ -73,7 +73,7 @@ public:
String get_configuration_warning() const;
- CollisionPolygon();
+ CollisionPolygon3D();
};
#endif // COLLISION_POLYGON_H
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape_3d.cpp
index d825c8daf7..e736f20614 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_shape.cpp */
+/* collision_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,21 +28,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_shape.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/ray_shape.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/world_margin_shape.h"
-#include "servers/visual_server.h"
+#include "collision_shape_3d.h"
+#include "scene/resources/box_shape_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/ray_shape_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
+#include "scene/resources/world_margin_shape_3d.h"
+#include "servers/rendering_server.h"
//TODO: Implement CylinderShape and HeightMapShape?
#include "core/math/quick_hull.h"
-#include "mesh_instance.h"
-#include "physics_body.h"
+#include "mesh_instance_3d.h"
+#include "physics_body_3d.h"
-void CollisionShape::make_convex_from_brothers() {
+void CollisionShape3D::make_convex_from_brothers() {
Node *p = get_parent();
if (!p)
@@ -51,32 +51,32 @@ void CollisionShape::make_convex_from_brothers() {
for (int i = 0; i < p->get_child_count(); i++) {
Node *n = p->get_child(i);
- MeshInstance *mi = Object::cast_to<MeshInstance>(n);
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(n);
if (mi) {
Ref<Mesh> m = mi->get_mesh();
if (m.is_valid()) {
- Ref<Shape> s = m->create_convex_shape();
+ Ref<Shape3D> s = m->create_convex_shape();
set_shape(s);
}
}
}
}
-void CollisionShape::_update_in_shape_owner(bool p_xform_only) {
+void CollisionShape3D::_update_in_shape_owner(bool p_xform_only) {
parent->shape_owner_set_transform(owner_id, get_transform());
if (p_xform_only)
return;
parent->shape_owner_set_disabled(owner_id, disabled);
}
-void CollisionShape::_notification(int p_what) {
+void CollisionShape3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_PARENTED: {
- parent = Object::cast_to<CollisionObject>(get_parent());
+ parent = Object::cast_to<CollisionObject3D>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
if (shape.is_valid()) {
@@ -108,14 +108,14 @@ void CollisionShape::_notification(int p_what) {
}
}
-void CollisionShape::resource_changed(RES res) {
+void CollisionShape3D::resource_changed(RES res) {
update_gizmo();
}
-String CollisionShape::get_configuration_warning() const {
+String CollisionShape3D::get_configuration_warning() const {
- if (!Object::cast_to<CollisionObject>(get_parent())) {
+ if (!Object::cast_to<CollisionObject3D>(get_parent())) {
return TTR("CollisionShape only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
}
@@ -123,9 +123,9 @@ String CollisionShape::get_configuration_warning() const {
return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it.");
}
- if (Object::cast_to<RigidBody>(get_parent())) {
- if (Object::cast_to<ConcavePolygonShape>(*shape)) {
- if (Object::cast_to<RigidBody>(get_parent())->get_mode() != RigidBody::MODE_STATIC) {
+ if (Object::cast_to<RigidBody3D>(get_parent())) {
+ if (Object::cast_to<ConcavePolygonShape3D>(*shape)) {
+ if (Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) {
return TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static.");
}
}
@@ -134,33 +134,33 @@ String CollisionShape::get_configuration_warning() const {
return String();
}
-void CollisionShape::_bind_methods() {
+void CollisionShape3D::_bind_methods() {
//not sure if this should do anything
- ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &CollisionShape::resource_changed);
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &CollisionShape::get_shape);
- ClassDB::bind_method(D_METHOD("set_disabled", "enable"), &CollisionShape::set_disabled);
- ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionShape::is_disabled);
- ClassDB::bind_method(D_METHOD("make_convex_from_brothers"), &CollisionShape::make_convex_from_brothers);
- ClassDB::set_method_flags("CollisionShape", "make_convex_from_brothers", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &CollisionShape3D::resource_changed);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape3D::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape"), &CollisionShape3D::get_shape);
+ ClassDB::bind_method(D_METHOD("set_disabled", "enable"), &CollisionShape3D::set_disabled);
+ ClassDB::bind_method(D_METHOD("is_disabled"), &CollisionShape3D::is_disabled);
+ ClassDB::bind_method(D_METHOD("make_convex_from_brothers"), &CollisionShape3D::make_convex_from_brothers);
+ ClassDB::set_method_flags("CollisionShape3D", "make_convex_from_brothers", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
- ClassDB::bind_method(D_METHOD("_update_debug_shape"), &CollisionShape::_update_debug_shape);
+ ClassDB::bind_method(D_METHOD("_update_debug_shape"), &CollisionShape3D::_update_debug_shape);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), "set_shape", "get_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
}
-void CollisionShape::set_shape(const Ref<Shape> &p_shape) {
+void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
if (!shape.is_null()) {
shape->unregister_owner(this);
- shape->disconnect("changed", callable_mp(this, &CollisionShape::_shape_changed));
+ shape->disconnect("changed", callable_mp(this, &CollisionShape3D::_shape_changed));
}
shape = p_shape;
if (!shape.is_null()) {
shape->register_owner(this);
- shape->connect("changed", callable_mp(this, &CollisionShape::_shape_changed));
+ shape->connect("changed", callable_mp(this, &CollisionShape3D::_shape_changed));
}
update_gizmo();
if (parent) {
@@ -175,12 +175,12 @@ void CollisionShape::set_shape(const Ref<Shape> &p_shape) {
update_configuration_warning();
}
-Ref<Shape> CollisionShape::get_shape() const {
+Ref<Shape3D> CollisionShape3D::get_shape() const {
return shape;
}
-void CollisionShape::set_disabled(bool p_disabled) {
+void CollisionShape3D::set_disabled(bool p_disabled) {
disabled = p_disabled;
update_gizmo();
@@ -189,14 +189,14 @@ void CollisionShape::set_disabled(bool p_disabled) {
}
}
-bool CollisionShape::is_disabled() const {
+bool CollisionShape3D::is_disabled() const {
return disabled;
}
-CollisionShape::CollisionShape() {
+CollisionShape3D::CollisionShape3D() {
- //indicator = VisualServer::get_singleton()->mesh_create();
+ //indicator = RenderingServer::get_singleton()->mesh_create();
disabled = false;
debug_shape = NULL;
parent = NULL;
@@ -204,13 +204,13 @@ CollisionShape::CollisionShape() {
set_notify_local_transform(true);
}
-CollisionShape::~CollisionShape() {
+CollisionShape3D::~CollisionShape3D() {
if (!shape.is_null())
shape->unregister_owner(this);
- //VisualServer::get_singleton()->free(indicator);
+ //RenderingServer::get_singleton()->free(indicator);
}
-void CollisionShape::_update_debug_shape() {
+void CollisionShape3D::_update_debug_shape() {
debug_shape_dirty = false;
if (debug_shape) {
@@ -218,18 +218,18 @@ void CollisionShape::_update_debug_shape() {
debug_shape = NULL;
}
- Ref<Shape> s = get_shape();
+ Ref<Shape3D> s = get_shape();
if (s.is_null())
return;
Ref<Mesh> mesh = s->get_debug_mesh();
- MeshInstance *mi = memnew(MeshInstance);
+ MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(mesh);
add_child(mi);
debug_shape = mi;
}
-void CollisionShape::_shape_changed() {
+void CollisionShape3D::_shape_changed() {
// If this is a heightfield shape our center may have changed
if (parent) {
_update_in_shape_owner(true);
diff --git a/scene/3d/collision_shape.h b/scene/3d/collision_shape_3d.h
index 3150a41ebf..8515d292af 100644
--- a/scene/3d/collision_shape.h
+++ b/scene/3d/collision_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_shape.h */
+/* collision_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,18 +31,18 @@
#ifndef COLLISION_SHAPE_H
#define COLLISION_SHAPE_H
-#include "scene/3d/spatial.h"
-#include "scene/resources/shape.h"
-class CollisionObject;
-class CollisionShape : public Spatial {
+#include "scene/3d/node_3d.h"
+#include "scene/resources/shape_3d.h"
+class CollisionObject3D;
+class CollisionShape3D : public Node3D {
- GDCLASS(CollisionShape, Spatial);
+ GDCLASS(CollisionShape3D, Node3D);
OBJ_CATEGORY("3D Physics Nodes");
- Ref<Shape> shape;
+ Ref<Shape3D> shape;
uint32_t owner_id;
- CollisionObject *parent;
+ CollisionObject3D *parent;
Node *debug_shape;
bool debug_shape_dirty;
@@ -63,16 +63,16 @@ protected:
public:
void make_convex_from_brothers();
- void set_shape(const Ref<Shape> &p_shape);
- Ref<Shape> get_shape() const;
+ void set_shape(const Ref<Shape3D> &p_shape);
+ Ref<Shape3D> get_shape() const;
void set_disabled(bool p_disabled);
bool is_disabled() const;
String get_configuration_warning() const;
- CollisionShape();
- ~CollisionShape();
+ CollisionShape3D();
+ ~CollisionShape3D();
};
#endif // BODY_VOLUME_H
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles_3d.cpp
index bde578d0af..4350d4da25 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cpu_particles.cpp */
+/* cpu_particles_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,23 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "cpu_particles.h"
+#include "cpu_particles_3d.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/particles.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/gpu_particles_3d.h"
#include "scene/resources/particles_material.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
-AABB CPUParticles::get_aabb() const {
+AABB CPUParticles3D::get_aabb() const {
return AABB();
}
-Vector<Face3> CPUParticles::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> CPUParticles3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-void CPUParticles::set_emitting(bool p_emitting) {
+void CPUParticles3D::set_emitting(bool p_emitting) {
if (emitting == p_emitting)
return;
@@ -59,7 +59,7 @@ void CPUParticles::set_emitting(bool p_emitting) {
}
}
-void CPUParticles::set_amount(int p_amount) {
+void CPUParticles3D::set_amount(int p_amount) {
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0.");
@@ -73,132 +73,132 @@ void CPUParticles::set_amount(int p_amount) {
}
particle_data.resize((12 + 4 + 4) * p_amount);
- VS::get_singleton()->multimesh_allocate(multimesh, p_amount, VS::MULTIMESH_TRANSFORM_3D, true, true);
+ RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_3D, true, true);
particle_order.resize(p_amount);
}
-void CPUParticles::set_lifetime(float p_lifetime) {
+void CPUParticles3D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
}
-void CPUParticles::set_one_shot(bool p_one_shot) {
+void CPUParticles3D::set_one_shot(bool p_one_shot) {
one_shot = p_one_shot;
}
-void CPUParticles::set_pre_process_time(float p_time) {
+void CPUParticles3D::set_pre_process_time(float p_time) {
pre_process_time = p_time;
}
-void CPUParticles::set_explosiveness_ratio(float p_ratio) {
+void CPUParticles3D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
}
-void CPUParticles::set_randomness_ratio(float p_ratio) {
+void CPUParticles3D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
}
-void CPUParticles::set_lifetime_randomness(float p_random) {
+void CPUParticles3D::set_lifetime_randomness(float p_random) {
lifetime_randomness = p_random;
}
-void CPUParticles::set_use_local_coordinates(bool p_enable) {
+void CPUParticles3D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
}
-void CPUParticles::set_speed_scale(float p_scale) {
+void CPUParticles3D::set_speed_scale(float p_scale) {
speed_scale = p_scale;
}
-bool CPUParticles::is_emitting() const {
+bool CPUParticles3D::is_emitting() const {
return emitting;
}
-int CPUParticles::get_amount() const {
+int CPUParticles3D::get_amount() const {
return particles.size();
}
-float CPUParticles::get_lifetime() const {
+float CPUParticles3D::get_lifetime() const {
return lifetime;
}
-bool CPUParticles::get_one_shot() const {
+bool CPUParticles3D::get_one_shot() const {
return one_shot;
}
-float CPUParticles::get_pre_process_time() const {
+float CPUParticles3D::get_pre_process_time() const {
return pre_process_time;
}
-float CPUParticles::get_explosiveness_ratio() const {
+float CPUParticles3D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float CPUParticles::get_randomness_ratio() const {
+float CPUParticles3D::get_randomness_ratio() const {
return randomness_ratio;
}
-float CPUParticles::get_lifetime_randomness() const {
+float CPUParticles3D::get_lifetime_randomness() const {
return lifetime_randomness;
}
-bool CPUParticles::get_use_local_coordinates() const {
+bool CPUParticles3D::get_use_local_coordinates() const {
return local_coords;
}
-float CPUParticles::get_speed_scale() const {
+float CPUParticles3D::get_speed_scale() const {
return speed_scale;
}
-void CPUParticles::set_draw_order(DrawOrder p_order) {
+void CPUParticles3D::set_draw_order(DrawOrder p_order) {
draw_order = p_order;
}
-CPUParticles::DrawOrder CPUParticles::get_draw_order() const {
+CPUParticles3D::DrawOrder CPUParticles3D::get_draw_order() const {
return draw_order;
}
-void CPUParticles::set_mesh(const Ref<Mesh> &p_mesh) {
+void CPUParticles3D::set_mesh(const Ref<Mesh> &p_mesh) {
mesh = p_mesh;
if (mesh.is_valid()) {
- VS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
+ RS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
} else {
- VS::get_singleton()->multimesh_set_mesh(multimesh, RID());
+ RS::get_singleton()->multimesh_set_mesh(multimesh, RID());
}
}
-Ref<Mesh> CPUParticles::get_mesh() const {
+Ref<Mesh> CPUParticles3D::get_mesh() const {
return mesh;
}
-void CPUParticles::set_fixed_fps(int p_count) {
+void CPUParticles3D::set_fixed_fps(int p_count) {
fixed_fps = p_count;
}
-int CPUParticles::get_fixed_fps() const {
+int CPUParticles3D::get_fixed_fps() const {
return fixed_fps;
}
-void CPUParticles::set_fractional_delta(bool p_enable) {
+void CPUParticles3D::set_fractional_delta(bool p_enable) {
fractional_delta = p_enable;
}
-bool CPUParticles::get_fractional_delta() const {
+bool CPUParticles3D::get_fractional_delta() const {
return fractional_delta;
}
-String CPUParticles::get_configuration_warning() const {
+String CPUParticles3D::get_configuration_warning() const {
String warnings;
@@ -234,7 +234,7 @@ String CPUParticles::get_configuration_warning() const {
return warnings;
}
-void CPUParticles::restart() {
+void CPUParticles3D::restart() {
time = 0;
inactive_time = 0;
@@ -254,55 +254,55 @@ void CPUParticles::restart() {
set_emitting(true);
}
-void CPUParticles::set_direction(Vector3 p_direction) {
+void CPUParticles3D::set_direction(Vector3 p_direction) {
direction = p_direction;
}
-Vector3 CPUParticles::get_direction() const {
+Vector3 CPUParticles3D::get_direction() const {
return direction;
}
-void CPUParticles::set_spread(float p_spread) {
+void CPUParticles3D::set_spread(float p_spread) {
spread = p_spread;
}
-float CPUParticles::get_spread() const {
+float CPUParticles3D::get_spread() const {
return spread;
}
-void CPUParticles::set_flatness(float p_flatness) {
+void CPUParticles3D::set_flatness(float p_flatness) {
flatness = p_flatness;
}
-float CPUParticles::get_flatness() const {
+float CPUParticles3D::get_flatness() const {
return flatness;
}
-void CPUParticles::set_param(Parameter p_param, float p_value) {
+void CPUParticles3D::set_param(Parameter p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
parameters[p_param] = p_value;
}
-float CPUParticles::get_param(Parameter p_param) const {
+float CPUParticles3D::get_param(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return parameters[p_param];
}
-void CPUParticles::set_param_randomness(Parameter p_param, float p_value) {
+void CPUParticles3D::set_param_randomness(Parameter p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
randomness[p_param] = p_value;
}
-float CPUParticles::get_param_randomness(Parameter p_param) const {
+float CPUParticles3D::get_param_randomness(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
@@ -318,7 +318,7 @@ static void _adjust_curve_range(const Ref<Curve> &p_curve, float p_min, float p_
curve->ensure_default_setup(p_min, p_max);
}
-void CPUParticles::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve) {
+void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
@@ -364,34 +364,34 @@ void CPUParticles::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve)
}
}
}
-Ref<Curve> CPUParticles::get_param_curve(Parameter p_param) const {
+Ref<Curve> CPUParticles3D::get_param_curve(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Curve>());
return curve_parameters[p_param];
}
-void CPUParticles::set_color(const Color &p_color) {
+void CPUParticles3D::set_color(const Color &p_color) {
color = p_color;
}
-Color CPUParticles::get_color() const {
+Color CPUParticles3D::get_color() const {
return color;
}
-void CPUParticles::set_color_ramp(const Ref<Gradient> &p_ramp) {
+void CPUParticles3D::set_color_ramp(const Ref<Gradient> &p_ramp) {
color_ramp = p_ramp;
}
-Ref<Gradient> CPUParticles::get_color_ramp() const {
+Ref<Gradient> CPUParticles3D::get_color_ramp() const {
return color_ramp;
}
-void CPUParticles::set_particle_flag(Flags p_flag, bool p_enable) {
+void CPUParticles3D::set_particle_flag(Flags p_flag, bool p_enable) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_enable;
if (p_flag == FLAG_DISABLE_Z) {
@@ -399,77 +399,77 @@ void CPUParticles::set_particle_flag(Flags p_flag, bool p_enable) {
}
}
-bool CPUParticles::get_particle_flag(Flags p_flag) const {
+bool CPUParticles3D::get_particle_flag(Flags p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
-void CPUParticles::set_emission_shape(EmissionShape p_shape) {
+void CPUParticles3D::set_emission_shape(EmissionShape p_shape) {
ERR_FAIL_INDEX(p_shape, EMISSION_SHAPE_MAX);
emission_shape = p_shape;
}
-void CPUParticles::set_emission_sphere_radius(float p_radius) {
+void CPUParticles3D::set_emission_sphere_radius(float p_radius) {
emission_sphere_radius = p_radius;
}
-void CPUParticles::set_emission_box_extents(Vector3 p_extents) {
+void CPUParticles3D::set_emission_box_extents(Vector3 p_extents) {
emission_box_extents = p_extents;
}
-void CPUParticles::set_emission_points(const Vector<Vector3> &p_points) {
+void CPUParticles3D::set_emission_points(const Vector<Vector3> &p_points) {
emission_points = p_points;
}
-void CPUParticles::set_emission_normals(const Vector<Vector3> &p_normals) {
+void CPUParticles3D::set_emission_normals(const Vector<Vector3> &p_normals) {
emission_normals = p_normals;
}
-void CPUParticles::set_emission_colors(const Vector<Color> &p_colors) {
+void CPUParticles3D::set_emission_colors(const Vector<Color> &p_colors) {
emission_colors = p_colors;
}
-float CPUParticles::get_emission_sphere_radius() const {
+float CPUParticles3D::get_emission_sphere_radius() const {
return emission_sphere_radius;
}
-Vector3 CPUParticles::get_emission_box_extents() const {
+Vector3 CPUParticles3D::get_emission_box_extents() const {
return emission_box_extents;
}
-Vector<Vector3> CPUParticles::get_emission_points() const {
+Vector<Vector3> CPUParticles3D::get_emission_points() const {
return emission_points;
}
-Vector<Vector3> CPUParticles::get_emission_normals() const {
+Vector<Vector3> CPUParticles3D::get_emission_normals() const {
return emission_normals;
}
-Vector<Color> CPUParticles::get_emission_colors() const {
+Vector<Color> CPUParticles3D::get_emission_colors() const {
return emission_colors;
}
-CPUParticles::EmissionShape CPUParticles::get_emission_shape() const {
+CPUParticles3D::EmissionShape CPUParticles3D::get_emission_shape() const {
return emission_shape;
}
-void CPUParticles::set_gravity(const Vector3 &p_gravity) {
+void CPUParticles3D::set_gravity(const Vector3 &p_gravity) {
gravity = p_gravity;
}
-Vector3 CPUParticles::get_gravity() const {
+Vector3 CPUParticles3D::get_gravity() const {
return gravity;
}
-void CPUParticles::_validate_property(PropertyInfo &property) const {
+void CPUParticles3D::_validate_property(PropertyInfo &property) const {
if (property.name == "color" && color_ramp.is_valid()) {
property.usage = 0;
@@ -517,7 +517,7 @@ static float rand_from_seed(uint32_t &seed) {
return float(seed % uint32_t(65536)) / 65535.0;
}
-void CPUParticles::_update_internal() {
+void CPUParticles3D::_update_internal() {
if (particles.size() == 0 || !is_visible_in_tree()) {
_set_redraw(false);
@@ -592,7 +592,7 @@ void CPUParticles::_update_internal() {
}
}
-void CPUParticles::_particles_process(float p_delta) {
+void CPUParticles3D::_particles_process(float p_delta) {
p_delta *= speed_scale;
@@ -1016,7 +1016,7 @@ void CPUParticles::_particles_process(float p_delta) {
}
}
-void CPUParticles::_update_particle_data_buffer() {
+void CPUParticles3D::_update_particle_data_buffer() {
MutexLock lock(update_mutex);
int pc = particles.size();
@@ -1040,7 +1040,7 @@ void CPUParticles::_update_particle_data_buffer() {
sorter.compare.particles = r;
sorter.sort(order, pc);
} else if (draw_order == DRAW_ORDER_VIEW_DEPTH) {
- Camera *c = get_viewport()->get_camera();
+ Camera3D *c = get_viewport()->get_camera();
if (c) {
Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close
@@ -1106,7 +1106,7 @@ void CPUParticles::_update_particle_data_buffer() {
can_update = true;
}
-void CPUParticles::_set_redraw(bool p_redraw) {
+void CPUParticles3D::_set_redraw(bool p_redraw) {
if (redraw == p_redraw)
return;
redraw = p_redraw;
@@ -1115,30 +1115,30 @@ void CPUParticles::_set_redraw(bool p_redraw) {
MutexLock lock(update_mutex);
if (redraw) {
- VS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles::_update_render_thread));
- VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
+ RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread));
+ RS::get_singleton()->instance_geometry_set_flag(get_instance(), RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true);
+ RS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
} else {
- if (VS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles::_update_render_thread))) {
- VS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles::_update_render_thread));
+ if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread))) {
+ RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread));
}
- VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false);
- VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
+ RS::get_singleton()->instance_geometry_set_flag(get_instance(), RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false);
+ RS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
}
}
}
-void CPUParticles::_update_render_thread() {
+void CPUParticles3D::_update_render_thread() {
MutexLock lock(update_mutex);
if (can_update) {
- VS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
+ RS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
can_update = false; //wait for next time
}
}
-void CPUParticles::_notification(int p_what) {
+void CPUParticles3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
set_process_internal(emitting);
@@ -1203,9 +1203,9 @@ void CPUParticles::_notification(int p_what) {
}
}
-void CPUParticles::convert_from_particles(Node *p_particles) {
+void CPUParticles3D::convert_from_particles(Node *p_particles) {
- Particles *particles = Object::cast_to<Particles>(p_particles);
+ GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_particles);
ERR_FAIL_COND_MSG(!particles, "Only Particles nodes can be converted to CPUParticles.");
set_emitting(particles->is_emitting());
@@ -1272,42 +1272,42 @@ void CPUParticles::convert_from_particles(Node *p_particles) {
#undef CONVERT_PARAM
}
-void CPUParticles::_bind_methods() {
+void CPUParticles3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles::set_emitting);
- ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles::set_amount);
- ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles::set_lifetime);
- ClassDB::bind_method(D_METHOD("set_one_shot", "enable"), &CPUParticles::set_one_shot);
- ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &CPUParticles::set_pre_process_time);
- ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &CPUParticles::set_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &CPUParticles::set_randomness_ratio);
- ClassDB::bind_method(D_METHOD("set_lifetime_randomness", "random"), &CPUParticles::set_lifetime_randomness);
- ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &CPUParticles::set_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &CPUParticles::set_fixed_fps);
- ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &CPUParticles::set_fractional_delta);
- ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &CPUParticles::set_speed_scale);
+ ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles3D::set_emitting);
+ ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles3D::set_amount);
+ ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles3D::set_lifetime);
+ ClassDB::bind_method(D_METHOD("set_one_shot", "enable"), &CPUParticles3D::set_one_shot);
+ ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &CPUParticles3D::set_pre_process_time);
+ ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &CPUParticles3D::set_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &CPUParticles3D::set_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("set_lifetime_randomness", "random"), &CPUParticles3D::set_lifetime_randomness);
+ ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &CPUParticles3D::set_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &CPUParticles3D::set_fixed_fps);
+ ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &CPUParticles3D::set_fractional_delta);
+ ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &CPUParticles3D::set_speed_scale);
- ClassDB::bind_method(D_METHOD("is_emitting"), &CPUParticles::is_emitting);
- ClassDB::bind_method(D_METHOD("get_amount"), &CPUParticles::get_amount);
- ClassDB::bind_method(D_METHOD("get_lifetime"), &CPUParticles::get_lifetime);
- ClassDB::bind_method(D_METHOD("get_one_shot"), &CPUParticles::get_one_shot);
- ClassDB::bind_method(D_METHOD("get_pre_process_time"), &CPUParticles::get_pre_process_time);
- ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &CPUParticles::get_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &CPUParticles::get_randomness_ratio);
- ClassDB::bind_method(D_METHOD("get_lifetime_randomness"), &CPUParticles::get_lifetime_randomness);
- ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &CPUParticles::get_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("get_fixed_fps"), &CPUParticles::get_fixed_fps);
- ClassDB::bind_method(D_METHOD("get_fractional_delta"), &CPUParticles::get_fractional_delta);
- ClassDB::bind_method(D_METHOD("get_speed_scale"), &CPUParticles::get_speed_scale);
+ ClassDB::bind_method(D_METHOD("is_emitting"), &CPUParticles3D::is_emitting);
+ ClassDB::bind_method(D_METHOD("get_amount"), &CPUParticles3D::get_amount);
+ ClassDB::bind_method(D_METHOD("get_lifetime"), &CPUParticles3D::get_lifetime);
+ ClassDB::bind_method(D_METHOD("get_one_shot"), &CPUParticles3D::get_one_shot);
+ ClassDB::bind_method(D_METHOD("get_pre_process_time"), &CPUParticles3D::get_pre_process_time);
+ ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &CPUParticles3D::get_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &CPUParticles3D::get_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("get_lifetime_randomness"), &CPUParticles3D::get_lifetime_randomness);
+ ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &CPUParticles3D::get_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("get_fixed_fps"), &CPUParticles3D::get_fixed_fps);
+ ClassDB::bind_method(D_METHOD("get_fractional_delta"), &CPUParticles3D::get_fractional_delta);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"), &CPUParticles3D::get_speed_scale);
- ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &CPUParticles::set_draw_order);
+ ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &CPUParticles3D::set_draw_order);
- ClassDB::bind_method(D_METHOD("get_draw_order"), &CPUParticles::get_draw_order);
+ ClassDB::bind_method(D_METHOD("get_draw_order"), &CPUParticles3D::get_draw_order);
- ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CPUParticles::set_mesh);
- ClassDB::bind_method(D_METHOD("get_mesh"), &CPUParticles::get_mesh);
+ ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CPUParticles3D::set_mesh);
+ ClassDB::bind_method(D_METHOD("get_mesh"), &CPUParticles3D::get_mesh);
- ClassDB::bind_method(D_METHOD("restart"), &CPUParticles::restart);
+ ClassDB::bind_method(D_METHOD("restart"), &CPUParticles3D::restart);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_EXP_RANGE, "1,1000000,1"), "set_amount", "get_amount");
@@ -1332,55 +1332,55 @@ void CPUParticles::_bind_methods() {
////////////////////////////////
- ClassDB::bind_method(D_METHOD("set_direction", "direction"), &CPUParticles::set_direction);
- ClassDB::bind_method(D_METHOD("get_direction"), &CPUParticles::get_direction);
+ ClassDB::bind_method(D_METHOD("set_direction", "direction"), &CPUParticles3D::set_direction);
+ ClassDB::bind_method(D_METHOD("get_direction"), &CPUParticles3D::get_direction);
- ClassDB::bind_method(D_METHOD("set_spread", "degrees"), &CPUParticles::set_spread);
- ClassDB::bind_method(D_METHOD("get_spread"), &CPUParticles::get_spread);
+ ClassDB::bind_method(D_METHOD("set_spread", "degrees"), &CPUParticles3D::set_spread);
+ ClassDB::bind_method(D_METHOD("get_spread"), &CPUParticles3D::get_spread);
- ClassDB::bind_method(D_METHOD("set_flatness", "amount"), &CPUParticles::set_flatness);
- ClassDB::bind_method(D_METHOD("get_flatness"), &CPUParticles::get_flatness);
+ ClassDB::bind_method(D_METHOD("set_flatness", "amount"), &CPUParticles3D::set_flatness);
+ ClassDB::bind_method(D_METHOD("get_flatness"), &CPUParticles3D::get_flatness);
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &CPUParticles::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &CPUParticles::get_param);
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &CPUParticles3D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &CPUParticles3D::get_param);
- ClassDB::bind_method(D_METHOD("set_param_randomness", "param", "randomness"), &CPUParticles::set_param_randomness);
- ClassDB::bind_method(D_METHOD("get_param_randomness", "param"), &CPUParticles::get_param_randomness);
+ ClassDB::bind_method(D_METHOD("set_param_randomness", "param", "randomness"), &CPUParticles3D::set_param_randomness);
+ ClassDB::bind_method(D_METHOD("get_param_randomness", "param"), &CPUParticles3D::get_param_randomness);
- ClassDB::bind_method(D_METHOD("set_param_curve", "param", "curve"), &CPUParticles::set_param_curve);
- ClassDB::bind_method(D_METHOD("get_param_curve", "param"), &CPUParticles::get_param_curve);
+ ClassDB::bind_method(D_METHOD("set_param_curve", "param", "curve"), &CPUParticles3D::set_param_curve);
+ ClassDB::bind_method(D_METHOD("get_param_curve", "param"), &CPUParticles3D::get_param_curve);
- ClassDB::bind_method(D_METHOD("set_color", "color"), &CPUParticles::set_color);
- ClassDB::bind_method(D_METHOD("get_color"), &CPUParticles::get_color);
+ ClassDB::bind_method(D_METHOD("set_color", "color"), &CPUParticles3D::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"), &CPUParticles3D::get_color);
- ClassDB::bind_method(D_METHOD("set_color_ramp", "ramp"), &CPUParticles::set_color_ramp);
- ClassDB::bind_method(D_METHOD("get_color_ramp"), &CPUParticles::get_color_ramp);
+ ClassDB::bind_method(D_METHOD("set_color_ramp", "ramp"), &CPUParticles3D::set_color_ramp);
+ ClassDB::bind_method(D_METHOD("get_color_ramp"), &CPUParticles3D::get_color_ramp);
- ClassDB::bind_method(D_METHOD("set_particle_flag", "flag", "enable"), &CPUParticles::set_particle_flag);
- ClassDB::bind_method(D_METHOD("get_particle_flag", "flag"), &CPUParticles::get_particle_flag);
+ ClassDB::bind_method(D_METHOD("set_particle_flag", "flag", "enable"), &CPUParticles3D::set_particle_flag);
+ ClassDB::bind_method(D_METHOD("get_particle_flag", "flag"), &CPUParticles3D::get_particle_flag);
- ClassDB::bind_method(D_METHOD("set_emission_shape", "shape"), &CPUParticles::set_emission_shape);
- ClassDB::bind_method(D_METHOD("get_emission_shape"), &CPUParticles::get_emission_shape);
+ ClassDB::bind_method(D_METHOD("set_emission_shape", "shape"), &CPUParticles3D::set_emission_shape);
+ ClassDB::bind_method(D_METHOD("get_emission_shape"), &CPUParticles3D::get_emission_shape);
- ClassDB::bind_method(D_METHOD("set_emission_sphere_radius", "radius"), &CPUParticles::set_emission_sphere_radius);
- ClassDB::bind_method(D_METHOD("get_emission_sphere_radius"), &CPUParticles::get_emission_sphere_radius);
+ ClassDB::bind_method(D_METHOD("set_emission_sphere_radius", "radius"), &CPUParticles3D::set_emission_sphere_radius);
+ ClassDB::bind_method(D_METHOD("get_emission_sphere_radius"), &CPUParticles3D::get_emission_sphere_radius);
- ClassDB::bind_method(D_METHOD("set_emission_box_extents", "extents"), &CPUParticles::set_emission_box_extents);
- ClassDB::bind_method(D_METHOD("get_emission_box_extents"), &CPUParticles::get_emission_box_extents);
+ ClassDB::bind_method(D_METHOD("set_emission_box_extents", "extents"), &CPUParticles3D::set_emission_box_extents);
+ ClassDB::bind_method(D_METHOD("get_emission_box_extents"), &CPUParticles3D::get_emission_box_extents);
- ClassDB::bind_method(D_METHOD("set_emission_points", "array"), &CPUParticles::set_emission_points);
- ClassDB::bind_method(D_METHOD("get_emission_points"), &CPUParticles::get_emission_points);
+ ClassDB::bind_method(D_METHOD("set_emission_points", "array"), &CPUParticles3D::set_emission_points);
+ ClassDB::bind_method(D_METHOD("get_emission_points"), &CPUParticles3D::get_emission_points);
- ClassDB::bind_method(D_METHOD("set_emission_normals", "array"), &CPUParticles::set_emission_normals);
- ClassDB::bind_method(D_METHOD("get_emission_normals"), &CPUParticles::get_emission_normals);
+ ClassDB::bind_method(D_METHOD("set_emission_normals", "array"), &CPUParticles3D::set_emission_normals);
+ ClassDB::bind_method(D_METHOD("get_emission_normals"), &CPUParticles3D::get_emission_normals);
- ClassDB::bind_method(D_METHOD("set_emission_colors", "array"), &CPUParticles::set_emission_colors);
- ClassDB::bind_method(D_METHOD("get_emission_colors"), &CPUParticles::get_emission_colors);
+ ClassDB::bind_method(D_METHOD("set_emission_colors", "array"), &CPUParticles3D::set_emission_colors);
+ ClassDB::bind_method(D_METHOD("get_emission_colors"), &CPUParticles3D::get_emission_colors);
- ClassDB::bind_method(D_METHOD("get_gravity"), &CPUParticles::get_gravity);
- ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &CPUParticles::set_gravity);
+ ClassDB::bind_method(D_METHOD("get_gravity"), &CPUParticles3D::get_gravity);
+ ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &CPUParticles3D::set_gravity);
- ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &CPUParticles::convert_from_particles);
+ ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &CPUParticles3D::convert_from_particles);
ADD_GROUP("Emission Shape", "emission_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points"), "set_emission_shape", "get_emission_shape");
@@ -1477,7 +1477,7 @@ void CPUParticles::_bind_methods() {
BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX);
}
-CPUParticles::CPUParticles() {
+CPUParticles3D::CPUParticles3D() {
time = 0;
inactive_time = 0;
@@ -1488,8 +1488,8 @@ CPUParticles::CPUParticles() {
set_notify_transform(true);
- multimesh = VisualServer::get_singleton()->multimesh_create();
- VisualServer::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
+ multimesh = RenderingServer::get_singleton()->multimesh_create();
+ RenderingServer::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
set_base(multimesh);
set_emitting(true);
@@ -1541,6 +1541,6 @@ CPUParticles::CPUParticles() {
set_color(Color(1, 1, 1, 1));
}
-CPUParticles::~CPUParticles() {
- VS::get_singleton()->free(multimesh);
+CPUParticles3D::~CPUParticles3D() {
+ RS::get_singleton()->free(multimesh);
}
diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles_3d.h
index 231e1f1ad9..ffe0ecc9a9 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cpu_particles.h */
+/* cpu_particles_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,11 +32,11 @@
#define CPU_PARTICLES_H
#include "core/rid.h"
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
-class CPUParticles : public GeometryInstance {
+class CPUParticles3D : public GeometryInstance3D {
private:
- GDCLASS(CPUParticles, GeometryInstance);
+ GDCLASS(CPUParticles3D, GeometryInstance3D);
public:
enum DrawOrder {
@@ -286,13 +286,13 @@ public:
void convert_from_particles(Node *p_particles);
- CPUParticles();
- ~CPUParticles();
+ CPUParticles3D();
+ ~CPUParticles3D();
};
-VARIANT_ENUM_CAST(CPUParticles::DrawOrder)
-VARIANT_ENUM_CAST(CPUParticles::Parameter)
-VARIANT_ENUM_CAST(CPUParticles::Flags)
-VARIANT_ENUM_CAST(CPUParticles::EmissionShape)
+VARIANT_ENUM_CAST(CPUParticles3D::DrawOrder)
+VARIANT_ENUM_CAST(CPUParticles3D::Parameter)
+VARIANT_ENUM_CAST(CPUParticles3D::Flags)
+VARIANT_ENUM_CAST(CPUParticles3D::EmissionShape)
#endif // CPU_PARTICLES_H
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index c3f039ae85..a46cd90612 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -33,7 +33,7 @@
#include "core/os/os.h"
#include "core/method_bind_ext.gen.inc"
-#include "mesh_instance.h"
+#include "mesh_instance_3d.h"
#include "voxelizer.h"
void GIProbeData::_set_data(const Dictionary &p_data) {
@@ -92,7 +92,7 @@ Dictionary GIProbeData::_get_data() const {
}
void GIProbeData::allocate(const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {
- VS::get_singleton()->gi_probe_allocate(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts);
+ RS::get_singleton()->gi_probe_allocate(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts);
bounds = p_aabb;
to_cell_xform = p_to_cell_xform;
octree_size = p_octree_size;
@@ -105,24 +105,24 @@ Vector3 GIProbeData::get_octree_size() const {
return octree_size;
}
Vector<uint8_t> GIProbeData::get_octree_cells() const {
- return VS::get_singleton()->gi_probe_get_octree_cells(probe);
+ return RS::get_singleton()->gi_probe_get_octree_cells(probe);
}
Vector<uint8_t> GIProbeData::get_data_cells() const {
- return VS::get_singleton()->gi_probe_get_data_cells(probe);
+ return RS::get_singleton()->gi_probe_get_data_cells(probe);
}
Vector<uint8_t> GIProbeData::get_distance_field() const {
- return VS::get_singleton()->gi_probe_get_distance_field(probe);
+ return RS::get_singleton()->gi_probe_get_distance_field(probe);
}
Vector<int> GIProbeData::get_level_counts() const {
- return VS::get_singleton()->gi_probe_get_level_counts(probe);
+ return RS::get_singleton()->gi_probe_get_level_counts(probe);
}
Transform GIProbeData::get_to_cell_xform() const {
return to_cell_xform;
}
void GIProbeData::set_dynamic_range(float p_range) {
- VS::get_singleton()->gi_probe_set_dynamic_range(probe, p_range);
+ RS::get_singleton()->gi_probe_set_dynamic_range(probe, p_range);
dynamic_range = p_range;
}
@@ -131,7 +131,7 @@ float GIProbeData::get_dynamic_range() const {
}
void GIProbeData::set_propagation(float p_propagation) {
- VS::get_singleton()->gi_probe_set_propagation(probe, p_propagation);
+ RS::get_singleton()->gi_probe_set_propagation(probe, p_propagation);
propagation = p_propagation;
}
@@ -140,7 +140,7 @@ float GIProbeData::get_propagation() const {
}
void GIProbeData::set_anisotropy_strength(float p_anisotropy_strength) {
- VS::get_singleton()->gi_probe_set_anisotropy_strength(probe, p_anisotropy_strength);
+ RS::get_singleton()->gi_probe_set_anisotropy_strength(probe, p_anisotropy_strength);
anisotropy_strength = p_anisotropy_strength;
}
@@ -149,7 +149,7 @@ float GIProbeData::get_anisotropy_strength() const {
}
void GIProbeData::set_energy(float p_energy) {
- VS::get_singleton()->gi_probe_set_energy(probe, p_energy);
+ RS::get_singleton()->gi_probe_set_energy(probe, p_energy);
energy = p_energy;
}
@@ -158,7 +158,7 @@ float GIProbeData::get_energy() const {
}
void GIProbeData::set_ao(float p_ao) {
- VS::get_singleton()->gi_probe_set_ao(probe, p_ao);
+ RS::get_singleton()->gi_probe_set_ao(probe, p_ao);
ao = p_ao;
}
@@ -167,7 +167,7 @@ float GIProbeData::get_ao() const {
}
void GIProbeData::set_ao_size(float p_ao_size) {
- VS::get_singleton()->gi_probe_set_ao_size(probe, p_ao_size);
+ RS::get_singleton()->gi_probe_set_ao_size(probe, p_ao_size);
ao_size = p_ao_size;
}
@@ -176,7 +176,7 @@ float GIProbeData::get_ao_size() const {
}
void GIProbeData::set_bias(float p_bias) {
- VS::get_singleton()->gi_probe_set_bias(probe, p_bias);
+ RS::get_singleton()->gi_probe_set_bias(probe, p_bias);
bias = p_bias;
}
@@ -185,7 +185,7 @@ float GIProbeData::get_bias() const {
}
void GIProbeData::set_normal_bias(float p_normal_bias) {
- VS::get_singleton()->gi_probe_set_normal_bias(probe, p_normal_bias);
+ RS::get_singleton()->gi_probe_set_normal_bias(probe, p_normal_bias);
normal_bias = p_normal_bias;
}
@@ -194,7 +194,7 @@ float GIProbeData::get_normal_bias() const {
}
void GIProbeData::set_interior(bool p_enable) {
- VS::get_singleton()->gi_probe_set_interior(probe, p_enable);
+ RS::get_singleton()->gi_probe_set_interior(probe, p_enable);
interior = p_enable;
}
@@ -203,7 +203,7 @@ bool GIProbeData::is_interior() const {
}
void GIProbeData::set_use_two_bounces(bool p_enable) {
- VS::get_singleton()->gi_probe_set_use_two_bounces(probe, p_enable);
+ RS::get_singleton()->gi_probe_set_use_two_bounces(probe, p_enable);
use_two_bounces = p_enable;
}
@@ -294,12 +294,12 @@ GIProbeData::GIProbeData() {
anisotropy_strength = 0.5;
interior = false;
- probe = VS::get_singleton()->gi_probe_create();
+ probe = RS::get_singleton()->gi_probe_create();
}
GIProbeData::~GIProbeData() {
- VS::get_singleton()->free(probe);
+ RS::get_singleton()->free(probe);
}
//////////////////////
@@ -308,9 +308,9 @@ GIProbeData::~GIProbeData() {
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());
+ RS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid());
} else {
- VS::get_singleton()->instance_set_base(get_instance(), RID());
+ RS::get_singleton()->instance_set_base(get_instance(), RID());
}
probe_data = p_data;
@@ -347,8 +347,8 @@ Vector3 GIProbe::get_extents() const {
void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
- MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
- if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) {
+ MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node);
+ if (mi && mi->get_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
@@ -369,7 +369,7 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
}
}
- Spatial *s = Object::cast_to<Spatial>(p_at_node);
+ Node3D *s = Object::cast_to<Node3D>(p_at_node);
if (s) {
if (s->is_visible_in_tree()) {
@@ -468,7 +468,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
//create the data for visual server
if (p_create_visual_debug) {
- MultiMeshInstance *mmi = memnew(MultiMeshInstance);
+ MultiMeshInstance3D *mmi = memnew(MultiMeshInstance3D);
mmi->set_multimesh(baker.create_debug_multimesh());
add_child(mmi);
#ifdef TOOLS_ENABLED
@@ -526,7 +526,7 @@ Vector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
String GIProbe::get_configuration_warning() const {
- if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GIProbes are not supported by the GLES2 video driver.\nUse a BakedLightmap instead.");
}
return String();
@@ -563,10 +563,10 @@ GIProbe::GIProbe() {
subdiv = SUBDIV_128;
extents = Vector3(10, 10, 10);
- gi_probe = VS::get_singleton()->gi_probe_create();
+ gi_probe = RS::get_singleton()->gi_probe_create();
set_disable_scale(true);
}
GIProbe::~GIProbe() {
- VS::get_singleton()->free(gi_probe);
+ RS::get_singleton()->free(gi_probe);
}
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index f991843883..c00ee2cb73 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -31,8 +31,8 @@
#ifndef GIPROBE_H
#define GIPROBE_H
-#include "multimesh_instance.h"
-#include "scene/3d/visual_instance.h"
+#include "multimesh_instance_3d.h"
+#include "scene/3d/visual_instance_3d.h"
class GIProbeData : public Resource {
@@ -108,8 +108,8 @@ public:
~GIProbeData();
};
-class GIProbe : public VisualInstance {
- GDCLASS(GIProbe, VisualInstance);
+class GIProbe : public VisualInstance3D {
+ GDCLASS(GIProbe, VisualInstance3D);
public:
enum Subdiv {
diff --git a/scene/3d/particles.cpp b/scene/3d/gpu_particles_3d.cpp
index e502b0c037..ad45228ca8 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/gpu_particles_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles.cpp */
+/* gpu_particles_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,25 +28,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "particles.h"
+#include "gpu_particles_3d.h"
#include "core/os/os.h"
#include "scene/resources/particles_material.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
-AABB Particles::get_aabb() const {
+AABB GPUParticles3D::get_aabb() const {
return AABB();
}
-Vector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> GPUParticles3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-void Particles::set_emitting(bool p_emitting) {
+void GPUParticles3D::set_emitting(bool p_emitting) {
- VS::get_singleton()->particles_set_emitting(particles, p_emitting);
+ RS::get_singleton()->particles_set_emitting(particles, p_emitting);
if (p_emitting && one_shot) {
set_process_internal(true);
@@ -55,150 +55,150 @@ void Particles::set_emitting(bool p_emitting) {
}
}
-void Particles::set_amount(int p_amount) {
+void GPUParticles3D::set_amount(int p_amount) {
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1.");
amount = p_amount;
- VS::get_singleton()->particles_set_amount(particles, amount);
+ RS::get_singleton()->particles_set_amount(particles, amount);
}
-void Particles::set_lifetime(float p_lifetime) {
+void GPUParticles3D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
- VS::get_singleton()->particles_set_lifetime(particles, lifetime);
+ RS::get_singleton()->particles_set_lifetime(particles, lifetime);
}
-void Particles::set_one_shot(bool p_one_shot) {
+void GPUParticles3D::set_one_shot(bool p_one_shot) {
one_shot = p_one_shot;
- VS::get_singleton()->particles_set_one_shot(particles, one_shot);
+ RS::get_singleton()->particles_set_one_shot(particles, one_shot);
if (is_emitting()) {
set_process_internal(true);
if (!one_shot)
- VisualServer::get_singleton()->particles_restart(particles);
+ RenderingServer::get_singleton()->particles_restart(particles);
}
if (!one_shot)
set_process_internal(false);
}
-void Particles::set_pre_process_time(float p_time) {
+void GPUParticles3D::set_pre_process_time(float p_time) {
pre_process_time = p_time;
- VS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
+ RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
}
-void Particles::set_explosiveness_ratio(float p_ratio) {
+void GPUParticles3D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
- VS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
+ RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
}
-void Particles::set_randomness_ratio(float p_ratio) {
+void GPUParticles3D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
- VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
+ RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
-void Particles::set_visibility_aabb(const AABB &p_aabb) {
+void GPUParticles3D::set_visibility_aabb(const AABB &p_aabb) {
visibility_aabb = p_aabb;
- VS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb);
+ RS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb);
update_gizmo();
_change_notify("visibility_aabb");
}
-void Particles::set_use_local_coordinates(bool p_enable) {
+void GPUParticles3D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
- VS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
+ RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
}
-void Particles::set_process_material(const Ref<Material> &p_material) {
+void GPUParticles3D::set_process_material(const Ref<Material> &p_material) {
process_material = p_material;
RID material_rid;
if (process_material.is_valid())
material_rid = process_material->get_rid();
- VS::get_singleton()->particles_set_process_material(particles, material_rid);
+ RS::get_singleton()->particles_set_process_material(particles, material_rid);
update_configuration_warning();
}
-void Particles::set_speed_scale(float p_scale) {
+void GPUParticles3D::set_speed_scale(float p_scale) {
speed_scale = p_scale;
- VS::get_singleton()->particles_set_speed_scale(particles, p_scale);
+ RS::get_singleton()->particles_set_speed_scale(particles, p_scale);
}
-bool Particles::is_emitting() const {
+bool GPUParticles3D::is_emitting() const {
- return VS::get_singleton()->particles_get_emitting(particles);
+ return RS::get_singleton()->particles_get_emitting(particles);
}
-int Particles::get_amount() const {
+int GPUParticles3D::get_amount() const {
return amount;
}
-float Particles::get_lifetime() const {
+float GPUParticles3D::get_lifetime() const {
return lifetime;
}
-bool Particles::get_one_shot() const {
+bool GPUParticles3D::get_one_shot() const {
return one_shot;
}
-float Particles::get_pre_process_time() const {
+float GPUParticles3D::get_pre_process_time() const {
return pre_process_time;
}
-float Particles::get_explosiveness_ratio() const {
+float GPUParticles3D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float Particles::get_randomness_ratio() const {
+float GPUParticles3D::get_randomness_ratio() const {
return randomness_ratio;
}
-AABB Particles::get_visibility_aabb() const {
+AABB GPUParticles3D::get_visibility_aabb() const {
return visibility_aabb;
}
-bool Particles::get_use_local_coordinates() const {
+bool GPUParticles3D::get_use_local_coordinates() const {
return local_coords;
}
-Ref<Material> Particles::get_process_material() const {
+Ref<Material> GPUParticles3D::get_process_material() const {
return process_material;
}
-float Particles::get_speed_scale() const {
+float GPUParticles3D::get_speed_scale() const {
return speed_scale;
}
-void Particles::set_draw_order(DrawOrder p_order) {
+void GPUParticles3D::set_draw_order(DrawOrder p_order) {
draw_order = p_order;
- VS::get_singleton()->particles_set_draw_order(particles, VS::ParticlesDrawOrder(p_order));
+ RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order));
}
-Particles::DrawOrder Particles::get_draw_order() const {
+GPUParticles3D::DrawOrder GPUParticles3D::get_draw_order() const {
return draw_order;
}
-void Particles::set_draw_passes(int p_count) {
+void GPUParticles3D::set_draw_passes(int p_count) {
ERR_FAIL_COND(p_count < 1);
draw_passes.resize(p_count);
- VS::get_singleton()->particles_set_draw_passes(particles, p_count);
+ RS::get_singleton()->particles_set_draw_passes(particles, p_count);
_change_notify();
}
-int Particles::get_draw_passes() const {
+int GPUParticles3D::get_draw_passes() const {
return draw_passes.size();
}
-void Particles::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) {
+void GPUParticles3D::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) {
ERR_FAIL_INDEX(p_pass, draw_passes.size());
@@ -208,39 +208,39 @@ void Particles::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) {
if (p_mesh.is_valid())
mesh_rid = p_mesh->get_rid();
- VS::get_singleton()->particles_set_draw_pass_mesh(particles, p_pass, mesh_rid);
+ RS::get_singleton()->particles_set_draw_pass_mesh(particles, p_pass, mesh_rid);
update_configuration_warning();
}
-Ref<Mesh> Particles::get_draw_pass_mesh(int p_pass) const {
+Ref<Mesh> GPUParticles3D::get_draw_pass_mesh(int p_pass) const {
ERR_FAIL_INDEX_V(p_pass, draw_passes.size(), Ref<Mesh>());
return draw_passes[p_pass];
}
-void Particles::set_fixed_fps(int p_count) {
+void GPUParticles3D::set_fixed_fps(int p_count) {
fixed_fps = p_count;
- VS::get_singleton()->particles_set_fixed_fps(particles, p_count);
+ RS::get_singleton()->particles_set_fixed_fps(particles, p_count);
}
-int Particles::get_fixed_fps() const {
+int GPUParticles3D::get_fixed_fps() const {
return fixed_fps;
}
-void Particles::set_fractional_delta(bool p_enable) {
+void GPUParticles3D::set_fractional_delta(bool p_enable) {
fractional_delta = p_enable;
- VS::get_singleton()->particles_set_fractional_delta(particles, p_enable);
+ RS::get_singleton()->particles_set_fractional_delta(particles, p_enable);
}
-bool Particles::get_fractional_delta() const {
+bool GPUParticles3D::get_fractional_delta() const {
return fractional_delta;
}
-String Particles::get_configuration_warning() const {
+String GPUParticles3D::get_configuration_warning() const {
- if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles node instead. You can use the \"Convert to CPUParticles\" option for this purpose.");
}
@@ -289,18 +289,18 @@ String Particles::get_configuration_warning() const {
return warnings;
}
-void Particles::restart() {
+void GPUParticles3D::restart() {
- VisualServer::get_singleton()->particles_restart(particles);
- VisualServer::get_singleton()->particles_set_emitting(particles, true);
+ RenderingServer::get_singleton()->particles_restart(particles);
+ RenderingServer::get_singleton()->particles_set_emitting(particles, true);
}
-AABB Particles::capture_aabb() const {
+AABB GPUParticles3D::capture_aabb() const {
- return VS::get_singleton()->particles_get_current_aabb(particles);
+ return RS::get_singleton()->particles_get_current_aabb(particles);
}
-void Particles::_validate_property(PropertyInfo &property) const {
+void GPUParticles3D::_validate_property(PropertyInfo &property) const {
if (property.name.begins_with("draw_pass_")) {
int index = property.name.get_slicec('_', 2).to_int() - 1;
@@ -311,14 +311,14 @@ void Particles::_validate_property(PropertyInfo &property) const {
}
}
-void Particles::_notification(int p_what) {
+void GPUParticles3D::_notification(int p_what) {
if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
if (can_process()) {
- VS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
+ RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
} else {
- VS::get_singleton()->particles_set_speed_scale(particles, 0);
+ RS::get_singleton()->particles_set_speed_scale(particles, 0);
}
}
@@ -334,54 +334,54 @@ void Particles::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
// make sure particles are updated before rendering occurs if they were active before
- if (is_visible_in_tree() && !VS::get_singleton()->particles_is_inactive(particles)) {
- VS::get_singleton()->particles_request_process(particles);
+ if (is_visible_in_tree() && !RS::get_singleton()->particles_is_inactive(particles)) {
+ RS::get_singleton()->particles_request_process(particles);
}
}
}
-void Particles::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &Particles::set_emitting);
- ClassDB::bind_method(D_METHOD("set_amount", "amount"), &Particles::set_amount);
- ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &Particles::set_lifetime);
- ClassDB::bind_method(D_METHOD("set_one_shot", "enable"), &Particles::set_one_shot);
- ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &Particles::set_pre_process_time);
- ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &Particles::set_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &Particles::set_randomness_ratio);
- ClassDB::bind_method(D_METHOD("set_visibility_aabb", "aabb"), &Particles::set_visibility_aabb);
- ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &Particles::set_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &Particles::set_fixed_fps);
- ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &Particles::set_fractional_delta);
- ClassDB::bind_method(D_METHOD("set_process_material", "material"), &Particles::set_process_material);
- ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &Particles::set_speed_scale);
-
- ClassDB::bind_method(D_METHOD("is_emitting"), &Particles::is_emitting);
- ClassDB::bind_method(D_METHOD("get_amount"), &Particles::get_amount);
- ClassDB::bind_method(D_METHOD("get_lifetime"), &Particles::get_lifetime);
- ClassDB::bind_method(D_METHOD("get_one_shot"), &Particles::get_one_shot);
- ClassDB::bind_method(D_METHOD("get_pre_process_time"), &Particles::get_pre_process_time);
- ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &Particles::get_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &Particles::get_randomness_ratio);
- ClassDB::bind_method(D_METHOD("get_visibility_aabb"), &Particles::get_visibility_aabb);
- ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &Particles::get_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("get_fixed_fps"), &Particles::get_fixed_fps);
- ClassDB::bind_method(D_METHOD("get_fractional_delta"), &Particles::get_fractional_delta);
- ClassDB::bind_method(D_METHOD("get_process_material"), &Particles::get_process_material);
- ClassDB::bind_method(D_METHOD("get_speed_scale"), &Particles::get_speed_scale);
-
- ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &Particles::set_draw_order);
-
- ClassDB::bind_method(D_METHOD("get_draw_order"), &Particles::get_draw_order);
-
- ClassDB::bind_method(D_METHOD("set_draw_passes", "passes"), &Particles::set_draw_passes);
- ClassDB::bind_method(D_METHOD("set_draw_pass_mesh", "pass", "mesh"), &Particles::set_draw_pass_mesh);
-
- ClassDB::bind_method(D_METHOD("get_draw_passes"), &Particles::get_draw_passes);
- ClassDB::bind_method(D_METHOD("get_draw_pass_mesh", "pass"), &Particles::get_draw_pass_mesh);
-
- ClassDB::bind_method(D_METHOD("restart"), &Particles::restart);
- ClassDB::bind_method(D_METHOD("capture_aabb"), &Particles::capture_aabb);
+void GPUParticles3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles3D::set_emitting);
+ ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles3D::set_amount);
+ ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles3D::set_lifetime);
+ ClassDB::bind_method(D_METHOD("set_one_shot", "enable"), &GPUParticles3D::set_one_shot);
+ ClassDB::bind_method(D_METHOD("set_pre_process_time", "secs"), &GPUParticles3D::set_pre_process_time);
+ ClassDB::bind_method(D_METHOD("set_explosiveness_ratio", "ratio"), &GPUParticles3D::set_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("set_randomness_ratio", "ratio"), &GPUParticles3D::set_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("set_visibility_aabb", "aabb"), &GPUParticles3D::set_visibility_aabb);
+ ClassDB::bind_method(D_METHOD("set_use_local_coordinates", "enable"), &GPUParticles3D::set_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("set_fixed_fps", "fps"), &GPUParticles3D::set_fixed_fps);
+ ClassDB::bind_method(D_METHOD("set_fractional_delta", "enable"), &GPUParticles3D::set_fractional_delta);
+ ClassDB::bind_method(D_METHOD("set_process_material", "material"), &GPUParticles3D::set_process_material);
+ ClassDB::bind_method(D_METHOD("set_speed_scale", "scale"), &GPUParticles3D::set_speed_scale);
+
+ ClassDB::bind_method(D_METHOD("is_emitting"), &GPUParticles3D::is_emitting);
+ ClassDB::bind_method(D_METHOD("get_amount"), &GPUParticles3D::get_amount);
+ ClassDB::bind_method(D_METHOD("get_lifetime"), &GPUParticles3D::get_lifetime);
+ ClassDB::bind_method(D_METHOD("get_one_shot"), &GPUParticles3D::get_one_shot);
+ ClassDB::bind_method(D_METHOD("get_pre_process_time"), &GPUParticles3D::get_pre_process_time);
+ ClassDB::bind_method(D_METHOD("get_explosiveness_ratio"), &GPUParticles3D::get_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("get_randomness_ratio"), &GPUParticles3D::get_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("get_visibility_aabb"), &GPUParticles3D::get_visibility_aabb);
+ ClassDB::bind_method(D_METHOD("get_use_local_coordinates"), &GPUParticles3D::get_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("get_fixed_fps"), &GPUParticles3D::get_fixed_fps);
+ ClassDB::bind_method(D_METHOD("get_fractional_delta"), &GPUParticles3D::get_fractional_delta);
+ ClassDB::bind_method(D_METHOD("get_process_material"), &GPUParticles3D::get_process_material);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"), &GPUParticles3D::get_speed_scale);
+
+ ClassDB::bind_method(D_METHOD("set_draw_order", "order"), &GPUParticles3D::set_draw_order);
+
+ ClassDB::bind_method(D_METHOD("get_draw_order"), &GPUParticles3D::get_draw_order);
+
+ ClassDB::bind_method(D_METHOD("set_draw_passes", "passes"), &GPUParticles3D::set_draw_passes);
+ ClassDB::bind_method(D_METHOD("set_draw_pass_mesh", "pass", "mesh"), &GPUParticles3D::set_draw_pass_mesh);
+
+ ClassDB::bind_method(D_METHOD("get_draw_passes"), &GPUParticles3D::get_draw_passes);
+ ClassDB::bind_method(D_METHOD("get_draw_pass_mesh", "pass"), &GPUParticles3D::get_draw_pass_mesh);
+
+ ClassDB::bind_method(D_METHOD("restart"), &GPUParticles3D::restart);
+ ClassDB::bind_method(D_METHOD("capture_aabb"), &GPUParticles3D::capture_aabb);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting");
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_EXP_RANGE, "1,1000000,1"), "set_amount", "get_amount");
@@ -414,9 +414,9 @@ void Particles::_bind_methods() {
BIND_CONSTANT(MAX_DRAW_PASSES);
}
-Particles::Particles() {
+GPUParticles3D::GPUParticles3D() {
- particles = VS::get_singleton()->particles_create();
+ particles = RS::get_singleton()->particles_create();
set_base(particles);
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
set_emitting(true);
@@ -435,7 +435,7 @@ Particles::Particles() {
set_speed_scale(1);
}
-Particles::~Particles() {
+GPUParticles3D::~GPUParticles3D() {
- VS::get_singleton()->free(particles);
+ RS::get_singleton()->free(particles);
}
diff --git a/scene/3d/particles.h b/scene/3d/gpu_particles_3d.h
index cf461f25e9..0c6653294b 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/gpu_particles_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* particles.h */
+/* gpu_particles_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,12 +32,12 @@
#define PARTICLES_H
#include "core/rid.h"
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/material.h"
-class Particles : public GeometryInstance {
+class GPUParticles3D : public GeometryInstance3D {
private:
- GDCLASS(Particles, GeometryInstance);
+ GDCLASS(GPUParticles3D, GeometryInstance3D);
public:
enum DrawOrder {
@@ -124,10 +124,10 @@ public:
void restart();
AABB capture_aabb() const;
- Particles();
- ~Particles();
+ GPUParticles3D();
+ ~GPUParticles3D();
};
-VARIANT_ENUM_CAST(Particles::DrawOrder)
+VARIANT_ENUM_CAST(GPUParticles3D::DrawOrder)
#endif // PARTICLES_H
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry_3d.cpp
index f5b08b86e1..63d4b1ac84 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* immediate_geometry.cpp */
+/* immediate_geometry_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,43 +28,43 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "immediate_geometry.h"
+#include "immediate_geometry_3d.h"
-void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) {
+void ImmediateGeometry3D::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) {
- VS::get_singleton()->immediate_begin(im, (VS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID());
+ RS::get_singleton()->immediate_begin(im, (RS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID());
if (p_texture.is_valid())
cached_textures.push_back(p_texture);
}
-void ImmediateGeometry::set_normal(const Vector3 &p_normal) {
+void ImmediateGeometry3D::set_normal(const Vector3 &p_normal) {
- VS::get_singleton()->immediate_normal(im, p_normal);
+ RS::get_singleton()->immediate_normal(im, p_normal);
}
-void ImmediateGeometry::set_tangent(const Plane &p_tangent) {
+void ImmediateGeometry3D::set_tangent(const Plane &p_tangent) {
- VS::get_singleton()->immediate_tangent(im, p_tangent);
+ RS::get_singleton()->immediate_tangent(im, p_tangent);
}
-void ImmediateGeometry::set_color(const Color &p_color) {
+void ImmediateGeometry3D::set_color(const Color &p_color) {
- VS::get_singleton()->immediate_color(im, p_color);
+ RS::get_singleton()->immediate_color(im, p_color);
}
-void ImmediateGeometry::set_uv(const Vector2 &p_uv) {
+void ImmediateGeometry3D::set_uv(const Vector2 &p_uv) {
- VS::get_singleton()->immediate_uv(im, p_uv);
+ RS::get_singleton()->immediate_uv(im, p_uv);
}
-void ImmediateGeometry::set_uv2(const Vector2 &p_uv2) {
+void ImmediateGeometry3D::set_uv2(const Vector2 &p_uv2) {
- VS::get_singleton()->immediate_uv2(im, p_uv2);
+ RS::get_singleton()->immediate_uv2(im, p_uv2);
}
-void ImmediateGeometry::add_vertex(const Vector3 &p_vertex) {
+void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) {
- VS::get_singleton()->immediate_vertex(im, p_vertex);
+ RS::get_singleton()->immediate_vertex(im, p_vertex);
if (empty) {
aabb.position = p_vertex;
aabb.size = Vector3();
@@ -74,28 +74,28 @@ void ImmediateGeometry::add_vertex(const Vector3 &p_vertex) {
}
}
-void ImmediateGeometry::end() {
+void ImmediateGeometry3D::end() {
- VS::get_singleton()->immediate_end(im);
+ RS::get_singleton()->immediate_end(im);
}
-void ImmediateGeometry::clear() {
+void ImmediateGeometry3D::clear() {
- VS::get_singleton()->immediate_clear(im);
+ RS::get_singleton()->immediate_clear(im);
empty = true;
cached_textures.clear();
}
-AABB ImmediateGeometry::get_aabb() const {
+AABB ImmediateGeometry3D::get_aabb() const {
return aabb;
}
-Vector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> ImmediateGeometry3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
+void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
for (int i = 1; i <= p_lats; i++) {
double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
@@ -142,28 +142,28 @@ void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool
}
}
-void ImmediateGeometry::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry::begin, DEFVAL(Ref<Texture2D>()));
- ClassDB::bind_method(D_METHOD("set_normal", "normal"), &ImmediateGeometry::set_normal);
- ClassDB::bind_method(D_METHOD("set_tangent", "tangent"), &ImmediateGeometry::set_tangent);
- ClassDB::bind_method(D_METHOD("set_color", "color"), &ImmediateGeometry::set_color);
- ClassDB::bind_method(D_METHOD("set_uv", "uv"), &ImmediateGeometry::set_uv);
- ClassDB::bind_method(D_METHOD("set_uv2", "uv"), &ImmediateGeometry::set_uv2);
- ClassDB::bind_method(D_METHOD("add_vertex", "position"), &ImmediateGeometry::add_vertex);
- ClassDB::bind_method(D_METHOD("add_sphere", "lats", "lons", "radius", "add_uv"), &ImmediateGeometry::add_sphere, DEFVAL(true));
- ClassDB::bind_method(D_METHOD("end"), &ImmediateGeometry::end);
- ClassDB::bind_method(D_METHOD("clear"), &ImmediateGeometry::clear);
+void ImmediateGeometry3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry3D::begin, DEFVAL(Ref<Texture2D>()));
+ ClassDB::bind_method(D_METHOD("set_normal", "normal"), &ImmediateGeometry3D::set_normal);
+ ClassDB::bind_method(D_METHOD("set_tangent", "tangent"), &ImmediateGeometry3D::set_tangent);
+ ClassDB::bind_method(D_METHOD("set_color", "color"), &ImmediateGeometry3D::set_color);
+ ClassDB::bind_method(D_METHOD("set_uv", "uv"), &ImmediateGeometry3D::set_uv);
+ ClassDB::bind_method(D_METHOD("set_uv2", "uv"), &ImmediateGeometry3D::set_uv2);
+ ClassDB::bind_method(D_METHOD("add_vertex", "position"), &ImmediateGeometry3D::add_vertex);
+ ClassDB::bind_method(D_METHOD("add_sphere", "lats", "lons", "radius", "add_uv"), &ImmediateGeometry3D::add_sphere, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("end"), &ImmediateGeometry3D::end);
+ ClassDB::bind_method(D_METHOD("clear"), &ImmediateGeometry3D::clear);
}
-ImmediateGeometry::ImmediateGeometry() {
+ImmediateGeometry3D::ImmediateGeometry3D() {
- im = VisualServer::get_singleton()->immediate_create();
+ im = RenderingServer::get_singleton()->immediate_create();
set_base(im);
empty = true;
}
-ImmediateGeometry::~ImmediateGeometry() {
+ImmediateGeometry3D::~ImmediateGeometry3D() {
- VisualServer::get_singleton()->free(im);
+ RenderingServer::get_singleton()->free(im);
}
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry_3d.h
index f9222c75fa..6e15450a5b 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* immediate_geometry.h */
+/* immediate_geometry_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,19 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef IMMEDIATE_GEOMETRY_H
-#define IMMEDIATE_GEOMETRY_H
+#ifndef IMMEDIATE_GEOMETRY_3D_H
+#define IMMEDIATE_GEOMETRY_3D_H
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/mesh.h"
-class ImmediateGeometry : public GeometryInstance {
+class ImmediateGeometry3D : public GeometryInstance3D {
- GDCLASS(ImmediateGeometry, GeometryInstance);
+ GDCLASS(ImmediateGeometry3D, GeometryInstance3D);
RID im;
//a list of textures drawn need to be kept, to avoid references
- // in VisualServer from becoming invalid if the texture is no longer used
+ // in RenderingServer from becoming invalid if the texture is no longer used
List<Ref<Texture2D>> cached_textures;
bool empty;
AABB aabb;
@@ -66,8 +66,8 @@ public:
virtual AABB get_aabb() const;
virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const;
- ImmediateGeometry();
- ~ImmediateGeometry();
+ ImmediateGeometry3D();
+ ~ImmediateGeometry3D();
};
#endif // IMMEDIATE_GEOMETRY_H
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
deleted file mode 100644
index 592d592a38..0000000000
--- a/scene/3d/interpolated_camera.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*************************************************************************/
-/* interpolated_camera.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "interpolated_camera.h"
-
-#include "core/engine.h"
-
-void InterpolatedCamera::_notification(int p_what) {
-
- switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
-
- if (Engine::get_singleton()->is_editor_hint() && enabled)
- set_process_internal(false);
-
- } break;
- case NOTIFICATION_INTERNAL_PROCESS: {
-
- if (!enabled)
- break;
- if (has_node(target)) {
-
- Spatial *node = Object::cast_to<Spatial>(get_node(target));
- if (!node)
- break;
-
- float delta = speed * get_process_delta_time();
- Transform target_xform = node->get_global_transform();
- Transform local_transform = get_global_transform();
- local_transform = local_transform.interpolate_with(target_xform, delta);
- set_global_transform(local_transform);
- Camera *cam = Object::cast_to<Camera>(node);
- if (cam) {
-
- if (cam->get_projection() == get_projection()) {
-
- float new_near = Math::lerp(get_znear(), cam->get_znear(), delta);
- float new_far = Math::lerp(get_zfar(), cam->get_zfar(), delta);
-
- if (cam->get_projection() == PROJECTION_ORTHOGONAL) {
-
- float size = Math::lerp(get_size(), cam->get_size(), delta);
- set_orthogonal(size, new_near, new_far);
- } else {
-
- float fov = Math::lerp(get_fov(), cam->get_fov(), delta);
- set_perspective(fov, new_near, new_far);
- }
- }
- }
- }
-
- } break;
- }
-}
-
-void InterpolatedCamera::_set_target(const Object *p_target) {
-
- ERR_FAIL_NULL(p_target);
- set_target(Object::cast_to<Spatial>(p_target));
-}
-
-void InterpolatedCamera::set_target(const Spatial *p_target) {
-
- ERR_FAIL_NULL(p_target);
- target = get_path_to(p_target);
-}
-
-void InterpolatedCamera::set_target_path(const NodePath &p_path) {
-
- target = p_path;
-}
-
-NodePath InterpolatedCamera::get_target_path() const {
-
- return target;
-}
-
-void InterpolatedCamera::set_interpolation_enabled(bool p_enable) {
-
- if (enabled == p_enable)
- return;
- enabled = p_enable;
- if (p_enable) {
- if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
- return;
- set_process_internal(true);
- } else
- set_process_internal(false);
-}
-
-bool InterpolatedCamera::is_interpolation_enabled() const {
-
- return enabled;
-}
-
-void InterpolatedCamera::set_speed(real_t p_speed) {
-
- speed = p_speed;
-}
-
-real_t InterpolatedCamera::get_speed() const {
-
- return speed;
-}
-
-void InterpolatedCamera::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_target_path", "target_path"), &InterpolatedCamera::set_target_path);
- ClassDB::bind_method(D_METHOD("get_target_path"), &InterpolatedCamera::get_target_path);
- ClassDB::bind_method(D_METHOD("set_target", "target"), &InterpolatedCamera::_set_target);
-
- ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InterpolatedCamera::set_speed);
- ClassDB::bind_method(D_METHOD("get_speed"), &InterpolatedCamera::get_speed);
-
- ClassDB::bind_method(D_METHOD("set_interpolation_enabled", "target_path"), &InterpolatedCamera::set_interpolation_enabled);
- ClassDB::bind_method(D_METHOD("is_interpolation_enabled"), &InterpolatedCamera::is_interpolation_enabled);
-
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "target"), "set_target_path", "get_target_path");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed"), "set_speed", "get_speed");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_interpolation_enabled", "is_interpolation_enabled");
-}
-
-InterpolatedCamera::InterpolatedCamera() {
-
- enabled = false;
- speed = 1;
-}
diff --git a/scene/3d/interpolated_camera.h b/scene/3d/interpolated_camera.h
deleted file mode 100644
index 7b160c66fa..0000000000
--- a/scene/3d/interpolated_camera.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*************************************************************************/
-/* interpolated_camera.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef INTERPOLATED_CAMERA_H
-#define INTERPOLATED_CAMERA_H
-
-#include "scene/3d/camera.h"
-
-class InterpolatedCamera : public Camera {
-
- GDCLASS(InterpolatedCamera, Camera);
-
- bool enabled;
- real_t speed;
- NodePath target;
-
-protected:
- void _notification(int p_what);
- static void _bind_methods();
- void _set_target(const Object *p_target);
-
-public:
- void set_target(const Spatial *p_target);
- void set_target_path(const NodePath &p_path);
- NodePath get_target_path() const;
-
- void set_speed(real_t p_speed);
- real_t get_speed() const;
-
- void set_interpolation_enabled(bool p_enable);
- bool is_interpolation_enabled() const;
-
- InterpolatedCamera();
-};
-
-#endif // INTERPOLATED_CAMERA_H
diff --git a/scene/3d/light.cpp b/scene/3d/light_3d.cpp
index 7c922ce1cd..7fc7fe2bf5 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* light.cpp */
+/* light_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,23 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "light.h"
+#include "light_3d.h"
#include "core/engine.h"
#include "core/project_settings.h"
#include "scene/resources/surface_tool.h"
-bool Light::_can_gizmo_scale() const {
+bool Light3D::_can_gizmo_scale() const {
return false;
}
-void Light::set_param(Param p_param, float p_value) {
+void Light3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
param[p_param] = p_value;
- VS::get_singleton()->light_set_param(light, VS::LightParam(p_param), p_value);
+ RS::get_singleton()->light_set_param(light, RS::LightParam(p_param), p_value);
if (p_param == PARAM_SPOT_ANGLE || p_param == PARAM_RANGE) {
update_gizmo();
@@ -59,90 +59,90 @@ void Light::set_param(Param p_param, float p_value) {
}
}
-float Light::get_param(Param p_param) const {
+float Light3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return param[p_param];
}
-void Light::set_shadow(bool p_enable) {
+void Light3D::set_shadow(bool p_enable) {
shadow = p_enable;
- VS::get_singleton()->light_set_shadow(light, p_enable);
+ RS::get_singleton()->light_set_shadow(light, p_enable);
- if (type == VisualServer::LIGHT_SPOT) {
+ if (type == RenderingServer::LIGHT_SPOT) {
update_configuration_warning();
}
}
-bool Light::has_shadow() const {
+bool Light3D::has_shadow() const {
return shadow;
}
-void Light::set_negative(bool p_enable) {
+void Light3D::set_negative(bool p_enable) {
negative = p_enable;
- VS::get_singleton()->light_set_negative(light, p_enable);
+ RS::get_singleton()->light_set_negative(light, p_enable);
}
-bool Light::is_negative() const {
+bool Light3D::is_negative() const {
return negative;
}
-void Light::set_cull_mask(uint32_t p_cull_mask) {
+void Light3D::set_cull_mask(uint32_t p_cull_mask) {
cull_mask = p_cull_mask;
- VS::get_singleton()->light_set_cull_mask(light, p_cull_mask);
+ RS::get_singleton()->light_set_cull_mask(light, p_cull_mask);
}
-uint32_t Light::get_cull_mask() const {
+uint32_t Light3D::get_cull_mask() const {
return cull_mask;
}
-void Light::set_color(const Color &p_color) {
+void Light3D::set_color(const Color &p_color) {
color = p_color;
- VS::get_singleton()->light_set_color(light, p_color);
+ RS::get_singleton()->light_set_color(light, p_color);
// The gizmo color depends on the light color, so update it.
update_gizmo();
}
-Color Light::get_color() const {
+Color Light3D::get_color() const {
return color;
}
-void Light::set_shadow_color(const Color &p_shadow_color) {
+void Light3D::set_shadow_color(const Color &p_shadow_color) {
shadow_color = p_shadow_color;
- VS::get_singleton()->light_set_shadow_color(light, p_shadow_color);
+ RS::get_singleton()->light_set_shadow_color(light, p_shadow_color);
}
-Color Light::get_shadow_color() const {
+Color Light3D::get_shadow_color() const {
return shadow_color;
}
-void Light::set_shadow_reverse_cull_face(bool p_enable) {
+void Light3D::set_shadow_reverse_cull_face(bool p_enable) {
reverse_cull = p_enable;
- VS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull);
+ RS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull);
}
-bool Light::get_shadow_reverse_cull_face() const {
+bool Light3D::get_shadow_reverse_cull_face() const {
return reverse_cull;
}
-AABB Light::get_aabb() const {
+AABB Light3D::get_aabb() const {
- if (type == VisualServer::LIGHT_DIRECTIONAL) {
+ if (type == RenderingServer::LIGHT_DIRECTIONAL) {
return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
- } else if (type == VisualServer::LIGHT_OMNI) {
+ } else if (type == RenderingServer::LIGHT_OMNI) {
return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
- } else if (type == VisualServer::LIGHT_SPOT) {
+ } else if (type == RenderingServer::LIGHT_SPOT) {
float len = param[PARAM_RANGE];
float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len;
@@ -152,21 +152,21 @@ AABB Light::get_aabb() const {
return AABB();
}
-Vector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> Light3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-void Light::set_bake_mode(BakeMode p_mode) {
+void Light3D::set_bake_mode(BakeMode p_mode) {
bake_mode = p_mode;
- VS::get_singleton()->light_set_use_gi(light, p_mode != BAKE_DISABLED);
+ RS::get_singleton()->light_set_use_gi(light, p_mode != BAKE_DISABLED);
}
-Light::BakeMode Light::get_bake_mode() const {
+Light3D::BakeMode Light3D::get_bake_mode() const {
return bake_mode;
}
-void Light::_update_visibility() {
+void Light3D::_update_visibility() {
if (!is_inside_tree())
return;
@@ -187,12 +187,12 @@ void Light::_update_visibility() {
}
#endif
- VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok);
+ RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok);
_change_notify("geometry/visible");
}
-void Light::_notification(int p_what) {
+void Light3D::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -204,52 +204,52 @@ void Light::_notification(int p_what) {
}
}
-void Light::set_editor_only(bool p_editor_only) {
+void Light3D::set_editor_only(bool p_editor_only) {
editor_only = p_editor_only;
_update_visibility();
}
-bool Light::is_editor_only() const {
+bool Light3D::is_editor_only() const {
return editor_only;
}
-void Light::_validate_property(PropertyInfo &property) const {
+void Light3D::_validate_property(PropertyInfo &property) const {
- if (VisualServer::get_singleton()->is_low_end() && property.name == "shadow_contact") {
+ if (RenderingServer::get_singleton()->is_low_end() && property.name == "shadow_contact") {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
}
-void Light::_bind_methods() {
+void Light3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_editor_only", "editor_only"), &Light::set_editor_only);
- ClassDB::bind_method(D_METHOD("is_editor_only"), &Light::is_editor_only);
+ ClassDB::bind_method(D_METHOD("set_editor_only", "editor_only"), &Light3D::set_editor_only);
+ ClassDB::bind_method(D_METHOD("is_editor_only"), &Light3D::is_editor_only);
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &Light::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &Light::get_param);
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &Light3D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &Light3D::get_param);
- ClassDB::bind_method(D_METHOD("set_shadow", "enabled"), &Light::set_shadow);
- ClassDB::bind_method(D_METHOD("has_shadow"), &Light::has_shadow);
+ ClassDB::bind_method(D_METHOD("set_shadow", "enabled"), &Light3D::set_shadow);
+ ClassDB::bind_method(D_METHOD("has_shadow"), &Light3D::has_shadow);
- ClassDB::bind_method(D_METHOD("set_negative", "enabled"), &Light::set_negative);
- ClassDB::bind_method(D_METHOD("is_negative"), &Light::is_negative);
+ ClassDB::bind_method(D_METHOD("set_negative", "enabled"), &Light3D::set_negative);
+ ClassDB::bind_method(D_METHOD("is_negative"), &Light3D::is_negative);
- ClassDB::bind_method(D_METHOD("set_cull_mask", "cull_mask"), &Light::set_cull_mask);
- ClassDB::bind_method(D_METHOD("get_cull_mask"), &Light::get_cull_mask);
+ ClassDB::bind_method(D_METHOD("set_cull_mask", "cull_mask"), &Light3D::set_cull_mask);
+ ClassDB::bind_method(D_METHOD("get_cull_mask"), &Light3D::get_cull_mask);
- ClassDB::bind_method(D_METHOD("set_color", "color"), &Light::set_color);
- ClassDB::bind_method(D_METHOD("get_color"), &Light::get_color);
+ ClassDB::bind_method(D_METHOD("set_color", "color"), &Light3D::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"), &Light3D::get_color);
- ClassDB::bind_method(D_METHOD("set_shadow_reverse_cull_face", "enable"), &Light::set_shadow_reverse_cull_face);
- ClassDB::bind_method(D_METHOD("get_shadow_reverse_cull_face"), &Light::get_shadow_reverse_cull_face);
+ ClassDB::bind_method(D_METHOD("set_shadow_reverse_cull_face", "enable"), &Light3D::set_shadow_reverse_cull_face);
+ ClassDB::bind_method(D_METHOD("get_shadow_reverse_cull_face"), &Light3D::get_shadow_reverse_cull_face);
- ClassDB::bind_method(D_METHOD("set_shadow_color", "shadow_color"), &Light::set_shadow_color);
- ClassDB::bind_method(D_METHOD("get_shadow_color"), &Light::get_shadow_color);
+ ClassDB::bind_method(D_METHOD("set_shadow_color", "shadow_color"), &Light3D::set_shadow_color);
+ ClassDB::bind_method(D_METHOD("get_shadow_color"), &Light3D::get_shadow_color);
- ClassDB::bind_method(D_METHOD("set_bake_mode", "bake_mode"), &Light::set_bake_mode);
- ClassDB::bind_method(D_METHOD("get_bake_mode"), &Light::get_bake_mode);
+ ClassDB::bind_method(D_METHOD("set_bake_mode", "bake_mode"), &Light3D::set_bake_mode);
+ ClassDB::bind_method(D_METHOD("get_bake_mode"), &Light3D::get_bake_mode);
ADD_GROUP("Light", "light_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_color", "get_color");
@@ -292,18 +292,18 @@ void Light::_bind_methods() {
BIND_ENUM_CONSTANT(BAKE_ALL);
}
-Light::Light(VisualServer::LightType p_type) {
+Light3D::Light3D(RenderingServer::LightType p_type) {
type = p_type;
switch (p_type) {
- case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break;
- case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break;
- case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break;
+ case RS::LIGHT_DIRECTIONAL: light = RenderingServer::get_singleton()->directional_light_create(); break;
+ case RS::LIGHT_OMNI: light = RenderingServer::get_singleton()->omni_light_create(); break;
+ case RS::LIGHT_SPOT: light = RenderingServer::get_singleton()->spot_light_create(); break;
default: {
};
}
- VS::get_singleton()->instance_set_base(get_instance(), light);
+ RS::get_singleton()->instance_set_base(get_instance(), light);
reverse_cull = false;
bake_mode = BAKE_INDIRECT;
@@ -333,63 +333,63 @@ Light::Light(VisualServer::LightType p_type) {
set_disable_scale(true);
}
-Light::Light() {
+Light3D::Light3D() {
- type = VisualServer::LIGHT_DIRECTIONAL;
+ type = RenderingServer::LIGHT_DIRECTIONAL;
ERR_PRINT("Light should not be instanced directly; use the DirectionalLight, OmniLight or SpotLight subtypes instead.");
}
-Light::~Light() {
+Light3D::~Light3D() {
- VS::get_singleton()->instance_set_base(get_instance(), RID());
+ RS::get_singleton()->instance_set_base(get_instance(), RID());
if (light.is_valid())
- VisualServer::get_singleton()->free(light);
+ RenderingServer::get_singleton()->free(light);
}
/////////////////////////////////////////
-void DirectionalLight::set_shadow_mode(ShadowMode p_mode) {
+void DirectionalLight3D::set_shadow_mode(ShadowMode p_mode) {
shadow_mode = p_mode;
- VS::get_singleton()->light_directional_set_shadow_mode(light, VS::LightDirectionalShadowMode(p_mode));
+ RS::get_singleton()->light_directional_set_shadow_mode(light, RS::LightDirectionalShadowMode(p_mode));
}
-DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
+DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const {
return shadow_mode;
}
-void DirectionalLight::set_shadow_depth_range(ShadowDepthRange p_range) {
+void DirectionalLight3D::set_shadow_depth_range(ShadowDepthRange p_range) {
shadow_depth_range = p_range;
- VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range));
+ RS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, RS::LightDirectionalShadowDepthRangeMode(p_range));
}
-DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() const {
+DirectionalLight3D::ShadowDepthRange DirectionalLight3D::get_shadow_depth_range() const {
return shadow_depth_range;
}
-void DirectionalLight::set_blend_splits(bool p_enable) {
+void DirectionalLight3D::set_blend_splits(bool p_enable) {
blend_splits = p_enable;
- VS::get_singleton()->light_directional_set_blend_splits(light, p_enable);
+ RS::get_singleton()->light_directional_set_blend_splits(light, p_enable);
}
-bool DirectionalLight::is_blend_splits_enabled() const {
+bool DirectionalLight3D::is_blend_splits_enabled() const {
return blend_splits;
}
-void DirectionalLight::_bind_methods() {
+void DirectionalLight3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode);
- ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight::get_shadow_mode);
+ ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight3D::set_shadow_mode);
+ ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight3D::get_shadow_mode);
- ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight::set_shadow_depth_range);
- ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight::get_shadow_depth_range);
+ ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight3D::set_shadow_depth_range);
+ ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight3D::get_shadow_depth_range);
- ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight::set_blend_splits);
- ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight::is_blend_splits_enabled);
+ ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight3D::set_blend_splits);
+ ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight3D::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"), "set_shadow_mode", "get_shadow_mode");
@@ -411,8 +411,8 @@ void DirectionalLight::_bind_methods() {
BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_OPTIMIZED);
}
-DirectionalLight::DirectionalLight() :
- Light(VisualServer::LIGHT_DIRECTIONAL) {
+DirectionalLight3D::DirectionalLight3D() :
+ Light3D(RenderingServer::LIGHT_DIRECTIONAL) {
set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8);
set_param(PARAM_SHADOW_BIAS, 0.1);
@@ -425,21 +425,21 @@ DirectionalLight::DirectionalLight() :
blend_splits = false;
}
-void OmniLight::set_shadow_mode(ShadowMode p_mode) {
+void OmniLight3D::set_shadow_mode(ShadowMode p_mode) {
shadow_mode = p_mode;
- VS::get_singleton()->light_omni_set_shadow_mode(light, VS::LightOmniShadowMode(p_mode));
+ RS::get_singleton()->light_omni_set_shadow_mode(light, RS::LightOmniShadowMode(p_mode));
}
-OmniLight::ShadowMode OmniLight::get_shadow_mode() const {
+OmniLight3D::ShadowMode OmniLight3D::get_shadow_mode() const {
return shadow_mode;
}
-void OmniLight::_bind_methods() {
+void OmniLight3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &OmniLight::set_shadow_mode);
- ClassDB::bind_method(D_METHOD("get_shadow_mode"), &OmniLight::get_shadow_mode);
+ ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &OmniLight3D::set_shadow_mode);
+ ClassDB::bind_method(D_METHOD("get_shadow_mode"), &OmniLight3D::get_shadow_mode);
ADD_GROUP("Omni", "omni_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "omni_range", PROPERTY_HINT_EXP_RANGE, "0,4096,0.1,or_greater"), "set_param", "get_param", PARAM_RANGE);
@@ -450,14 +450,14 @@ void OmniLight::_bind_methods() {
BIND_ENUM_CONSTANT(SHADOW_CUBE);
}
-OmniLight::OmniLight() :
- Light(VisualServer::LIGHT_OMNI) {
+OmniLight3D::OmniLight3D() :
+ Light3D(RenderingServer::LIGHT_OMNI) {
set_shadow_mode(SHADOW_CUBE);
}
-String SpotLight::get_configuration_warning() const {
- String warning = Light::get_configuration_warning();
+String SpotLight3D::get_configuration_warning() const {
+ String warning = Light3D::get_configuration_warning();
if (has_shadow() && get_param(PARAM_SPOT_ANGLE) >= 90.0) {
if (warning != String()) {
@@ -470,7 +470,7 @@ String SpotLight::get_configuration_warning() const {
return warning;
}
-void SpotLight::_bind_methods() {
+void SpotLight3D::_bind_methods() {
ADD_GROUP("Spot", "spot_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "spot_range", PROPERTY_HINT_EXP_RANGE, "0,4096,0.1,or_greater"), "set_param", "get_param", PARAM_RANGE);
diff --git a/scene/3d/light.h b/scene/3d/light_3d.h
index 16e0c47083..197e5854ec 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* light.h */
+/* light_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,34 +31,34 @@
#ifndef LIGHT_H
#define LIGHT_H
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/texture.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
-class Light : public VisualInstance {
+class Light3D : public VisualInstance3D {
- GDCLASS(Light, VisualInstance);
+ GDCLASS(Light3D, VisualInstance3D);
OBJ_CATEGORY("3D Light Nodes");
public:
enum Param {
- PARAM_ENERGY = VS::LIGHT_PARAM_ENERGY,
- PARAM_INDIRECT_ENERGY = VS::LIGHT_PARAM_INDIRECT_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_CONTACT_SHADOW_SIZE = VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE,
- PARAM_SHADOW_MAX_DISTANCE = VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE,
- PARAM_SHADOW_SPLIT_1_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
- PARAM_SHADOW_SPLIT_2_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
- PARAM_SHADOW_SPLIT_3_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET,
- PARAM_SHADOW_FADE_START = VS::LIGHT_PARAM_SHADOW_FADE_START,
- 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
+ PARAM_ENERGY = RS::LIGHT_PARAM_ENERGY,
+ PARAM_INDIRECT_ENERGY = RS::LIGHT_PARAM_INDIRECT_ENERGY,
+ PARAM_SPECULAR = RS::LIGHT_PARAM_SPECULAR,
+ PARAM_RANGE = RS::LIGHT_PARAM_RANGE,
+ PARAM_ATTENUATION = RS::LIGHT_PARAM_ATTENUATION,
+ PARAM_SPOT_ANGLE = RS::LIGHT_PARAM_SPOT_ANGLE,
+ PARAM_SPOT_ATTENUATION = RS::LIGHT_PARAM_SPOT_ATTENUATION,
+ PARAM_CONTACT_SHADOW_SIZE = RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE,
+ PARAM_SHADOW_MAX_DISTANCE = RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE,
+ PARAM_SHADOW_SPLIT_1_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
+ PARAM_SHADOW_SPLIT_2_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
+ PARAM_SHADOW_SPLIT_3_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET,
+ PARAM_SHADOW_FADE_START = RS::LIGHT_PARAM_SHADOW_FADE_START,
+ PARAM_SHADOW_NORMAL_BIAS = RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS,
+ PARAM_SHADOW_BIAS = RS::LIGHT_PARAM_SHADOW_BIAS,
+ PARAM_SHADOW_BIAS_SPLIT_SCALE = RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE,
+ PARAM_MAX = RS::LIGHT_PARAM_MAX
};
enum BakeMode {
@@ -75,7 +75,7 @@ private:
bool negative;
bool reverse_cull;
uint32_t cull_mask;
- VS::LightType type;
+ RS::LightType type;
bool editor_only;
void _update_visibility();
BakeMode bake_mode;
@@ -91,10 +91,10 @@ protected:
void _notification(int p_what);
virtual void _validate_property(PropertyInfo &property) const;
- Light(VisualServer::LightType p_type);
+ Light3D(RenderingServer::LightType p_type);
public:
- VS::LightType get_light_type() const { return type; }
+ RS::LightType get_light_type() const { return type; }
void set_editor_only(bool p_editor_only);
bool is_editor_only() const;
@@ -126,16 +126,16 @@ public:
virtual AABB get_aabb() const;
virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const;
- Light();
- ~Light();
+ Light3D();
+ ~Light3D();
};
-VARIANT_ENUM_CAST(Light::Param);
-VARIANT_ENUM_CAST(Light::BakeMode);
+VARIANT_ENUM_CAST(Light3D::Param);
+VARIANT_ENUM_CAST(Light3D::BakeMode);
-class DirectionalLight : public Light {
+class DirectionalLight3D : public Light3D {
- GDCLASS(DirectionalLight, Light);
+ GDCLASS(DirectionalLight3D, Light3D);
public:
enum ShadowMode {
@@ -145,8 +145,8 @@ public:
};
enum ShadowDepthRange {
- SHADOW_DEPTH_RANGE_STABLE = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE,
- SHADOW_DEPTH_RANGE_OPTIMIZED = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED,
+ SHADOW_DEPTH_RANGE_STABLE = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE,
+ SHADOW_DEPTH_RANGE_OPTIMIZED = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED,
};
private:
@@ -167,15 +167,15 @@ public:
void set_blend_splits(bool p_enable);
bool is_blend_splits_enabled() const;
- DirectionalLight();
+ DirectionalLight3D();
};
-VARIANT_ENUM_CAST(DirectionalLight::ShadowMode)
-VARIANT_ENUM_CAST(DirectionalLight::ShadowDepthRange)
+VARIANT_ENUM_CAST(DirectionalLight3D::ShadowMode)
+VARIANT_ENUM_CAST(DirectionalLight3D::ShadowDepthRange)
-class OmniLight : public Light {
+class OmniLight3D : public Light3D {
- GDCLASS(OmniLight, Light);
+ GDCLASS(OmniLight3D, Light3D);
public:
// omni light
@@ -194,14 +194,14 @@ public:
void set_shadow_mode(ShadowMode p_mode);
ShadowMode get_shadow_mode() const;
- OmniLight();
+ OmniLight3D();
};
-VARIANT_ENUM_CAST(OmniLight::ShadowMode)
+VARIANT_ENUM_CAST(OmniLight3D::ShadowMode)
-class SpotLight : public Light {
+class SpotLight3D : public Light3D {
- GDCLASS(SpotLight, Light);
+ GDCLASS(SpotLight3D, Light3D);
protected:
static void _bind_methods();
@@ -209,8 +209,8 @@ protected:
public:
virtual String get_configuration_warning() const;
- SpotLight() :
- Light(VisualServer::LIGHT_SPOT) {}
+ SpotLight3D() :
+ Light3D(RenderingServer::LIGHT_SPOT) {}
};
#endif
diff --git a/scene/3d/listener.cpp b/scene/3d/listener_3d.cpp
index 2779d14b57..f352eb24b1 100644
--- a/scene/3d/listener.cpp
+++ b/scene/3d/listener_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* listener.cpp */
+/* listener_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,19 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "listener.h"
+#include "listener_3d.h"
#include "scene/resources/mesh.h"
-void Listener::_update_audio_listener_state() {
+void Listener3D::_update_audio_listener_state() {
}
-void Listener::_request_listener_update() {
+void Listener3D::_request_listener_update() {
_update_listener();
}
-bool Listener::_set(const StringName &p_name, const Variant &p_value) {
+bool Listener3D::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "current") {
if (p_value.operator bool()) {
@@ -53,7 +53,7 @@ bool Listener::_set(const StringName &p_name, const Variant &p_value) {
return true;
}
-bool Listener::_get(const StringName &p_name, Variant &r_ret) const {
+bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "current") {
if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
@@ -67,19 +67,19 @@ bool Listener::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
-void Listener::_get_property_list(List<PropertyInfo> *p_list) const {
+void Listener3D::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
}
-void Listener::_update_listener() {
+void Listener3D::_update_listener() {
if (is_inside_tree() && is_current()) {
get_viewport()->_listener_transform_changed_notify();
}
}
-void Listener::_notification(int p_what) {
+void Listener3D::_notification(int p_what) {
switch (p_what) {
@@ -109,12 +109,12 @@ void Listener::_notification(int p_what) {
}
}
-Transform Listener::get_listener_transform() const {
+Transform Listener3D::get_listener_transform() const {
return get_global_transform().orthonormalized();
}
-void Listener::make_current() {
+void Listener3D::make_current() {
current = true;
@@ -124,7 +124,7 @@ void Listener::make_current() {
get_viewport()->_listener_set(this);
}
-void Listener::clear_current() {
+void Listener3D::clear_current() {
current = false;
if (!is_inside_tree())
@@ -136,7 +136,7 @@ void Listener::clear_current() {
}
}
-bool Listener::is_current() const {
+bool Listener3D::is_current() const {
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
@@ -147,26 +147,26 @@ bool Listener::is_current() const {
return false;
}
-bool Listener::_can_gizmo_scale() const {
+bool Listener3D::_can_gizmo_scale() const {
return false;
}
-RES Listener::_get_gizmo_geometry() const {
+RES Listener3D::_get_gizmo_geometry() const {
Ref<ArrayMesh> mesh = memnew(ArrayMesh);
return mesh;
}
-void Listener::_bind_methods() {
+void Listener3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("make_current"), &Listener::make_current);
- ClassDB::bind_method(D_METHOD("clear_current"), &Listener::clear_current);
- ClassDB::bind_method(D_METHOD("is_current"), &Listener::is_current);
- ClassDB::bind_method(D_METHOD("get_listener_transform"), &Listener::get_listener_transform);
+ ClassDB::bind_method(D_METHOD("make_current"), &Listener3D::make_current);
+ ClassDB::bind_method(D_METHOD("clear_current"), &Listener3D::clear_current);
+ ClassDB::bind_method(D_METHOD("is_current"), &Listener3D::is_current);
+ ClassDB::bind_method(D_METHOD("get_listener_transform"), &Listener3D::get_listener_transform);
}
-Listener::Listener() {
+Listener3D::Listener3D() {
current = false;
force_change = false;
@@ -174,5 +174,5 @@ Listener::Listener() {
//active=false;
}
-Listener::~Listener() {
+Listener3D::~Listener3D() {
}
diff --git a/scene/3d/listener.h b/scene/3d/listener_3d.h
index 287e67f31e..3383d6725e 100644
--- a/scene/3d/listener.h
+++ b/scene/3d/listener_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* listener.h */
+/* listener_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef LISTENER_H
-#define LISTENER_H
+#ifndef LISTENER_3D_H
+#define LISTENER_3D_H
-#include "scene/3d/spatial.h"
-#include "scene/main/viewport.h"
+#include "scene/3d/node_3d.h"
+#include "scene/main/window.h"
-class Listener : public Spatial {
+class Listener3D : public Node3D {
- GDCLASS(Listener, Spatial);
+ GDCLASS(Listener3D, Node3D);
private:
bool force_change;
@@ -71,8 +71,8 @@ public:
void set_visible_layers(uint32_t p_layers);
uint32_t get_visible_layers() const;
- Listener();
- ~Listener();
+ Listener3D();
+ ~Listener3D();
};
#endif
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance_3d.cpp
index 4ca139ebbc..284bbd7091 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* mesh_instance.cpp */
+/* mesh_instance_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "mesh_instance.h"
+#include "mesh_instance_3d.h"
-#include "collision_shape.h"
+#include "collision_shape_3d.h"
#include "core/core_string_names.h"
-#include "physics_body.h"
+#include "physics_body_3d.h"
#include "scene/resources/material.h"
-#include "skeleton.h"
+#include "skeleton_3d.h"
-bool MeshInstance::_set(const StringName &p_name, const Variant &p_value) {
+bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
//add to it that it's probably found on first call to _set anyway.
@@ -47,7 +47,7 @@ bool MeshInstance::_set(const StringName &p_name, const Variant &p_value) {
Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
E->get().value = p_value;
- VisualServer::get_singleton()->instance_set_blend_shape_weight(get_instance(), E->get().idx, E->get().value);
+ RenderingServer::get_singleton()->instance_set_blend_shape_weight(get_instance(), E->get().idx, E->get().value);
return true;
}
@@ -63,7 +63,7 @@ bool MeshInstance::_set(const StringName &p_name, const Variant &p_value) {
return false;
}
-bool MeshInstance::_get(const StringName &p_name, Variant &r_ret) const {
+bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
if (!get_instance().is_valid())
return false;
@@ -84,7 +84,7 @@ bool MeshInstance::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void MeshInstance::_get_property_list(List<PropertyInfo> *p_list) const {
+void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
List<String> ls;
for (const Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.front(); E; E = E->next()) {
@@ -105,13 +105,13 @@ void MeshInstance::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-void MeshInstance::set_mesh(const Ref<Mesh> &p_mesh) {
+void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
if (mesh == p_mesh)
return;
if (mesh.is_valid()) {
- mesh->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance::_mesh_changed));
+ mesh->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed));
materials.clear();
}
@@ -128,7 +128,7 @@ void MeshInstance::set_mesh(const Ref<Mesh> &p_mesh) {
blend_shape_tracks["blend_shapes/" + String(mesh->get_blend_shape_name(i))] = mt;
}
- mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance::_mesh_changed));
+ mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed));
materials.resize(mesh->get_surface_count());
set_base(mesh->get_rid());
@@ -141,17 +141,17 @@ void MeshInstance::set_mesh(const Ref<Mesh> &p_mesh) {
_change_notify();
}
-Ref<Mesh> MeshInstance::get_mesh() const {
+Ref<Mesh> MeshInstance3D::get_mesh() const {
return mesh;
}
-void MeshInstance::_resolve_skeleton_path() {
+void MeshInstance3D::_resolve_skeleton_path() {
Ref<SkinReference> new_skin_reference;
if (!skeleton_path.is_empty()) {
- Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path));
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(get_node(skeleton_path));
if (skeleton) {
new_skin_reference = skeleton->register_skin(skin_internal);
if (skin_internal.is_null()) {
@@ -165,13 +165,13 @@ void MeshInstance::_resolve_skeleton_path() {
skin_ref = new_skin_reference;
if (skin_ref.is_valid()) {
- VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), skin_ref->get_skeleton());
+ RenderingServer::get_singleton()->instance_attach_skeleton(get_instance(), skin_ref->get_skeleton());
} else {
- VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), RID());
+ RenderingServer::get_singleton()->instance_attach_skeleton(get_instance(), RID());
}
}
-void MeshInstance::set_skin(const Ref<Skin> &p_skin) {
+void MeshInstance3D::set_skin(const Ref<Skin> &p_skin) {
skin_internal = p_skin;
skin = p_skin;
if (!is_inside_tree())
@@ -179,11 +179,11 @@ void MeshInstance::set_skin(const Ref<Skin> &p_skin) {
_resolve_skeleton_path();
}
-Ref<Skin> MeshInstance::get_skin() const {
+Ref<Skin> MeshInstance3D::get_skin() const {
return skin;
}
-void MeshInstance::set_skeleton_path(const NodePath &p_skeleton) {
+void MeshInstance3D::set_skeleton_path(const NodePath &p_skeleton) {
skeleton_path = p_skeleton;
if (!is_inside_tree())
@@ -191,11 +191,11 @@ void MeshInstance::set_skeleton_path(const NodePath &p_skeleton) {
_resolve_skeleton_path();
}
-NodePath MeshInstance::get_skeleton_path() {
+NodePath MeshInstance3D::get_skeleton_path() {
return skeleton_path;
}
-AABB MeshInstance::get_aabb() const {
+AABB MeshInstance3D::get_aabb() const {
if (!mesh.is_null())
return mesh->get_aabb();
@@ -203,7 +203,7 @@ AABB MeshInstance::get_aabb() const {
return AABB();
}
-Vector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> MeshInstance3D::get_faces(uint32_t p_usage_flags) const {
if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING)))
return Vector<Face3>();
@@ -214,103 +214,103 @@ Vector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
return mesh->get_faces();
}
-Node *MeshInstance::create_trimesh_collision_node() {
+Node *MeshInstance3D::create_trimesh_collision_node() {
if (mesh.is_null())
return NULL;
- Ref<Shape> shape = mesh->create_trimesh_shape();
+ Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null())
return NULL;
- StaticBody *static_body = memnew(StaticBody);
- CollisionShape *cshape = memnew(CollisionShape);
+ StaticBody3D *static_body = memnew(StaticBody3D);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
static_body->add_child(cshape);
return static_body;
}
-void MeshInstance::create_trimesh_collision() {
+void MeshInstance3D::create_trimesh_collision() {
- StaticBody *static_body = Object::cast_to<StaticBody>(create_trimesh_collision_node());
+ StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_trimesh_collision_node());
ERR_FAIL_COND(!static_body);
static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
if (get_owner()) {
- CollisionShape *cshape = Object::cast_to<CollisionShape>(static_body->get_child(0));
+ CollisionShape3D *cshape = Object::cast_to<CollisionShape3D>(static_body->get_child(0));
static_body->set_owner(get_owner());
cshape->set_owner(get_owner());
}
}
-Node *MeshInstance::create_convex_collision_node() {
+Node *MeshInstance3D::create_convex_collision_node() {
if (mesh.is_null())
return NULL;
- Ref<Shape> shape = mesh->create_convex_shape();
+ Ref<Shape3D> shape = mesh->create_convex_shape();
if (shape.is_null())
return NULL;
- StaticBody *static_body = memnew(StaticBody);
- CollisionShape *cshape = memnew(CollisionShape);
+ StaticBody3D *static_body = memnew(StaticBody3D);
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
static_body->add_child(cshape);
return static_body;
}
-void MeshInstance::create_convex_collision() {
+void MeshInstance3D::create_convex_collision() {
- StaticBody *static_body = Object::cast_to<StaticBody>(create_convex_collision_node());
+ StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_convex_collision_node());
ERR_FAIL_COND(!static_body);
static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
if (get_owner()) {
- CollisionShape *cshape = Object::cast_to<CollisionShape>(static_body->get_child(0));
+ CollisionShape3D *cshape = Object::cast_to<CollisionShape3D>(static_body->get_child(0));
static_body->set_owner(get_owner());
cshape->set_owner(get_owner());
}
}
-void MeshInstance::_notification(int p_what) {
+void MeshInstance3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
_resolve_skeleton_path();
}
}
-int MeshInstance::get_surface_material_count() const {
+int MeshInstance3D::get_surface_material_count() const {
return materials.size();
}
-void MeshInstance::set_surface_material(int p_surface, const Ref<Material> &p_material) {
+void MeshInstance3D::set_surface_material(int p_surface, const Ref<Material> &p_material) {
ERR_FAIL_INDEX(p_surface, materials.size());
materials.write[p_surface] = p_material;
if (materials[p_surface].is_valid())
- VS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid());
+ RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid());
else
- VS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID());
+ RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID());
}
-Ref<Material> MeshInstance::get_surface_material(int p_surface) const {
+Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, materials.size(), Ref<Material>());
return materials[p_surface];
}
-void MeshInstance::_mesh_changed() {
+void MeshInstance3D::_mesh_changed() {
materials.resize(mesh->get_surface_count());
}
-void MeshInstance::create_debug_tangents() {
+void MeshInstance3D::create_debug_tangents() {
Vector<Vector3> lines;
Vector<Color> colors;
@@ -371,7 +371,7 @@ void MeshInstance::create_debug_tangents() {
am->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, a);
am->surface_set_material(0, sm);
- MeshInstance *mi = memnew(MeshInstance);
+ MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(am);
mi->set_name("DebugTangents");
add_child(mi);
@@ -385,37 +385,37 @@ void MeshInstance::create_debug_tangents() {
}
}
-void MeshInstance::_bind_methods() {
+void MeshInstance3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance::set_mesh);
- ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance::get_mesh);
- ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance::set_skeleton_path);
- ClassDB::bind_method(D_METHOD("get_skeleton_path"), &MeshInstance::get_skeleton_path);
- ClassDB::bind_method(D_METHOD("set_skin", "skin"), &MeshInstance::set_skin);
- ClassDB::bind_method(D_METHOD("get_skin"), &MeshInstance::get_skin);
+ ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance3D::set_mesh);
+ ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance3D::get_mesh);
+ ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance3D::set_skeleton_path);
+ ClassDB::bind_method(D_METHOD("get_skeleton_path"), &MeshInstance3D::get_skeleton_path);
+ ClassDB::bind_method(D_METHOD("set_skin", "skin"), &MeshInstance3D::set_skin);
+ ClassDB::bind_method(D_METHOD("get_skin"), &MeshInstance3D::get_skin);
- ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance::get_surface_material_count);
- ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance::set_surface_material);
- ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance::get_surface_material);
+ ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance3D::get_surface_material_count);
+ ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance3D::set_surface_material);
+ ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance3D::get_surface_material);
- ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance::create_trimesh_collision);
- ClassDB::set_method_flags("MeshInstance", "create_trimesh_collision", METHOD_FLAGS_DEFAULT);
- ClassDB::bind_method(D_METHOD("create_convex_collision"), &MeshInstance::create_convex_collision);
- ClassDB::set_method_flags("MeshInstance", "create_convex_collision", METHOD_FLAGS_DEFAULT);
+ ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance3D::create_trimesh_collision);
+ ClassDB::set_method_flags("MeshInstance3D", "create_trimesh_collision", METHOD_FLAGS_DEFAULT);
+ ClassDB::bind_method(D_METHOD("create_convex_collision"), &MeshInstance3D::create_convex_collision);
+ ClassDB::set_method_flags("MeshInstance3D", "create_convex_collision", METHOD_FLAGS_DEFAULT);
- ClassDB::bind_method(D_METHOD("create_debug_tangents"), &MeshInstance::create_debug_tangents);
- ClassDB::set_method_flags("MeshInstance", "create_debug_tangents", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("create_debug_tangents"), &MeshInstance3D::create_debug_tangents);
+ ClassDB::set_method_flags("MeshInstance3D", "create_debug_tangents", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
ADD_GROUP("Skeleton", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin");
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton"), "set_skeleton_path", "get_skeleton_path");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton3D"), "set_skeleton_path", "get_skeleton_path");
ADD_GROUP("", "");
}
-MeshInstance::MeshInstance() {
+MeshInstance3D::MeshInstance3D() {
skeleton_path = NodePath("..");
}
-MeshInstance::~MeshInstance() {
+MeshInstance3D::~MeshInstance3D() {
}
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance_3d.h
index a6190e7660..e45f68e295 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* mesh_instance.h */
+/* mesh_instance_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,14 +31,14 @@
#ifndef MESH_INSTANCE_H
#define MESH_INSTANCE_H
-#include "scene/3d/skeleton.h"
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/skeleton_3d.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/mesh.h"
#include "scene/resources/skin.h"
-class MeshInstance : public GeometryInstance {
+class MeshInstance3D : public GeometryInstance3D {
- GDCLASS(MeshInstance, GeometryInstance);
+ GDCLASS(MeshInstance3D, GeometryInstance3D);
protected:
Ref<Mesh> mesh;
@@ -96,8 +96,8 @@ public:
virtual AABB get_aabb() const;
virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const;
- MeshInstance();
- ~MeshInstance();
+ MeshInstance3D();
+ ~MeshInstance3D();
};
#endif
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance_3d.cpp
index 075eb0a1ec..a625a34283 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* multimesh_instance.cpp */
+/* multimesh_instance_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "multimesh_instance.h"
+#include "multimesh_instance_3d.h"
-void MultiMeshInstance::_bind_methods() {
+void MultiMeshInstance3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance::set_multimesh);
- ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance::get_multimesh);
+ ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance3D::set_multimesh);
+ ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance3D::get_multimesh);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), "set_multimesh", "get_multimesh");
}
-void MultiMeshInstance::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
+void MultiMeshInstance3D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
multimesh = p_multimesh;
if (multimesh.is_valid())
@@ -46,17 +46,17 @@ void MultiMeshInstance::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
set_base(RID());
}
-Ref<MultiMesh> MultiMeshInstance::get_multimesh() const {
+Ref<MultiMesh> MultiMeshInstance3D::get_multimesh() const {
return multimesh;
}
-Vector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> MultiMeshInstance3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-AABB MultiMeshInstance::get_aabb() const {
+AABB MultiMeshInstance3D::get_aabb() const {
if (multimesh.is_null())
return AABB();
@@ -64,8 +64,8 @@ AABB MultiMeshInstance::get_aabb() const {
return multimesh->get_aabb();
}
-MultiMeshInstance::MultiMeshInstance() {
+MultiMeshInstance3D::MultiMeshInstance3D() {
}
-MultiMeshInstance::~MultiMeshInstance() {
+MultiMeshInstance3D::~MultiMeshInstance3D() {
}
diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance_3d.h
index 2b59c3b96c..87ec9e120e 100644
--- a/scene/3d/multimesh_instance.h
+++ b/scene/3d/multimesh_instance_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* multimesh_instance.h */
+/* multimesh_instance_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef MULTIMESH_INSTANCE_H
-#define MULTIMESH_INSTANCE_H
+#ifndef MULTIMESH_INSTANCE_3D_H
+#define MULTIMESH_INSTANCE_3D_H
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/multimesh.h"
-class MultiMeshInstance : public GeometryInstance {
- GDCLASS(MultiMeshInstance, GeometryInstance);
+class MultiMeshInstance3D : public GeometryInstance3D {
+ GDCLASS(MultiMeshInstance3D, GeometryInstance3D);
Ref<MultiMesh> multimesh;
@@ -51,8 +51,8 @@ public:
virtual AABB get_aabb() const;
- MultiMeshInstance();
- ~MultiMeshInstance();
+ MultiMeshInstance3D();
+ ~MultiMeshInstance3D();
};
#endif // MULTIMESH_INSTANCE_H
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation_3d.cpp
index 8c543bc97f..f880f65d37 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation.cpp */
+/* navigation_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,91 +28,91 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "navigation.h"
+#include "navigation_3d.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
-Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const {
+Vector<Vector3> Navigation3D::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const {
- return NavigationServer::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
+ return NavigationServer3D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
}
-Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision) const {
- return NavigationServer::get_singleton()->map_get_closest_point_to_segment(map, p_from, p_to, p_use_collision);
+Vector3 Navigation3D::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision) const {
+ return NavigationServer3D::get_singleton()->map_get_closest_point_to_segment(map, p_from, p_to, p_use_collision);
}
-Vector3 Navigation::get_closest_point(const Vector3 &p_point) const {
- return NavigationServer::get_singleton()->map_get_closest_point(map, p_point);
+Vector3 Navigation3D::get_closest_point(const Vector3 &p_point) const {
+ return NavigationServer3D::get_singleton()->map_get_closest_point(map, p_point);
}
-Vector3 Navigation::get_closest_point_normal(const Vector3 &p_point) const {
- return NavigationServer::get_singleton()->map_get_closest_point_normal(map, p_point);
+Vector3 Navigation3D::get_closest_point_normal(const Vector3 &p_point) const {
+ return NavigationServer3D::get_singleton()->map_get_closest_point_normal(map, p_point);
}
-RID Navigation::get_closest_point_owner(const Vector3 &p_point) const {
- return NavigationServer::get_singleton()->map_get_closest_point_owner(map, p_point);
+RID Navigation3D::get_closest_point_owner(const Vector3 &p_point) const {
+ return NavigationServer3D::get_singleton()->map_get_closest_point_owner(map, p_point);
}
-void Navigation::set_up_vector(const Vector3 &p_up) {
+void Navigation3D::set_up_vector(const Vector3 &p_up) {
up = p_up;
- NavigationServer::get_singleton()->map_set_up(map, up);
+ NavigationServer3D::get_singleton()->map_set_up(map, up);
}
-Vector3 Navigation::get_up_vector() const {
+Vector3 Navigation3D::get_up_vector() const {
return up;
}
-void Navigation::set_cell_size(float p_cell_size) {
+void Navigation3D::set_cell_size(float p_cell_size) {
cell_size = p_cell_size;
- NavigationServer::get_singleton()->map_set_cell_size(map, cell_size);
+ NavigationServer3D::get_singleton()->map_set_cell_size(map, cell_size);
}
-void Navigation::set_edge_connection_margin(float p_edge_connection_margin) {
+void Navigation3D::set_edge_connection_margin(float p_edge_connection_margin) {
edge_connection_margin = p_edge_connection_margin;
- NavigationServer::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin);
+ NavigationServer3D::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin);
}
-void Navigation::_bind_methods() {
+void Navigation3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_rid"), &Navigation::get_rid);
+ ClassDB::bind_method(D_METHOD("get_rid"), &Navigation3D::get_rid);
- ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation::get_simple_path, DEFVAL(true));
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "start", "end", "use_collision"), &Navigation::get_closest_point_to_segment, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("get_closest_point", "to_point"), &Navigation::get_closest_point);
- ClassDB::bind_method(D_METHOD("get_closest_point_normal", "to_point"), &Navigation::get_closest_point_normal);
- ClassDB::bind_method(D_METHOD("get_closest_point_owner", "to_point"), &Navigation::get_closest_point_owner);
+ ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation3D::get_simple_path, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "start", "end", "use_collision"), &Navigation3D::get_closest_point_to_segment, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_closest_point", "to_point"), &Navigation3D::get_closest_point);
+ ClassDB::bind_method(D_METHOD("get_closest_point_normal", "to_point"), &Navigation3D::get_closest_point_normal);
+ ClassDB::bind_method(D_METHOD("get_closest_point_owner", "to_point"), &Navigation3D::get_closest_point_owner);
- ClassDB::bind_method(D_METHOD("set_up_vector", "up"), &Navigation::set_up_vector);
- ClassDB::bind_method(D_METHOD("get_up_vector"), &Navigation::get_up_vector);
+ ClassDB::bind_method(D_METHOD("set_up_vector", "up"), &Navigation3D::set_up_vector);
+ ClassDB::bind_method(D_METHOD("get_up_vector"), &Navigation3D::get_up_vector);
- ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &Navigation::set_cell_size);
- ClassDB::bind_method(D_METHOD("get_cell_size"), &Navigation::get_cell_size);
+ ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &Navigation3D::set_cell_size);
+ ClassDB::bind_method(D_METHOD("get_cell_size"), &Navigation3D::get_cell_size);
- ClassDB::bind_method(D_METHOD("set_edge_connection_margin", "margin"), &Navigation::set_edge_connection_margin);
- ClassDB::bind_method(D_METHOD("get_edge_connection_margin"), &Navigation::get_edge_connection_margin);
+ ClassDB::bind_method(D_METHOD("set_edge_connection_margin", "margin"), &Navigation3D::set_edge_connection_margin);
+ ClassDB::bind_method(D_METHOD("get_edge_connection_margin"), &Navigation3D::get_edge_connection_margin);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "up_vector"), "set_up_vector", "get_up_vector");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_size"), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "edge_connection_margin"), "set_edge_connection_margin", "get_edge_connection_margin");
}
-void Navigation::_notification(int p_what) {
+void Navigation3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- NavigationServer::get_singleton()->map_set_active(map, true);
+ NavigationServer3D::get_singleton()->map_set_active(map, true);
} break;
case NOTIFICATION_EXIT_TREE: {
- NavigationServer::get_singleton()->map_set_active(map, false);
+ NavigationServer3D::get_singleton()->map_set_active(map, false);
} break;
}
}
-Navigation::Navigation() {
+Navigation3D::Navigation3D() {
- map = NavigationServer::get_singleton()->map_create();
+ map = NavigationServer3D::get_singleton()->map_create();
set_cell_size(0.3);
set_edge_connection_margin(5.0); // Five meters, depends alot on the agents radius
@@ -120,6 +120,6 @@ Navigation::Navigation() {
up = Vector3(0, 1, 0);
}
-Navigation::~Navigation() {
- NavigationServer::get_singleton()->free(map);
+Navigation3D::~Navigation3D() {
+ NavigationServer3D::get_singleton()->free(map);
}
diff --git a/scene/3d/navigation.h b/scene/3d/navigation_3d.h
index 08f306611f..daa9558125 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation.h */
+/* navigation_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NAVIGATION_H
-#define NAVIGATION_H
+#ifndef NAVIGATION_3D_H
+#define NAVIGATION_3D_H
-#include "scene/3d/navigation_region.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/navigation_region_3d.h"
+#include "scene/3d/node_3d.h"
-class Navigation : public Spatial {
+class Navigation3D : public Node3D {
- GDCLASS(Navigation, Spatial);
+ GDCLASS(Navigation3D, Node3D);
RID map;
@@ -72,8 +72,8 @@ public:
Vector3 get_closest_point_normal(const Vector3 &p_point) const;
RID get_closest_point_owner(const Vector3 &p_point) const;
- Navigation();
- ~Navigation();
+ Navigation3D();
+ ~Navigation3D();
};
#endif // NAVIGATION_H
diff --git a/scene/3d/navigation_agent.cpp b/scene/3d/navigation_agent_3d.cpp
index 3da1ea66d6..76f1d4688d 100644
--- a/scene/3d/navigation_agent.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_agent.cpp */
+/* navigation_agent_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,57 +28,57 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "navigation_agent.h"
+#include "navigation_agent_3d.h"
#include "core/engine.h"
-#include "scene/3d/navigation.h"
-#include "servers/navigation_server.h"
+#include "scene/3d/navigation_3d.h"
+#include "servers/navigation_server_3d.h"
-void NavigationAgent::_bind_methods() {
+void NavigationAgent3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent::set_target_desired_distance);
- ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent::get_target_desired_distance);
+ ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent3D::set_target_desired_distance);
+ ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent3D::get_target_desired_distance);
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &NavigationAgent::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &NavigationAgent::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &NavigationAgent3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &NavigationAgent3D::get_radius);
- ClassDB::bind_method(D_METHOD("set_agent_height_offset", "agent_height_offset"), &NavigationAgent::set_agent_height_offset);
- ClassDB::bind_method(D_METHOD("get_agent_height_offset"), &NavigationAgent::get_agent_height_offset);
+ ClassDB::bind_method(D_METHOD("set_agent_height_offset", "agent_height_offset"), &NavigationAgent3D::set_agent_height_offset);
+ ClassDB::bind_method(D_METHOD("get_agent_height_offset"), &NavigationAgent3D::get_agent_height_offset);
- ClassDB::bind_method(D_METHOD("set_ignore_y", "ignore"), &NavigationAgent::set_ignore_y);
- ClassDB::bind_method(D_METHOD("get_ignore_y"), &NavigationAgent::get_ignore_y);
+ ClassDB::bind_method(D_METHOD("set_ignore_y", "ignore"), &NavigationAgent3D::set_ignore_y);
+ ClassDB::bind_method(D_METHOD("get_ignore_y"), &NavigationAgent3D::get_ignore_y);
- ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationAgent::set_navigation_node);
- ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationAgent::get_navigation_node);
+ ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationAgent3D::set_navigation_node);
+ ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationAgent3D::get_navigation_node);
- ClassDB::bind_method(D_METHOD("set_neighbor_dist", "neighbor_dist"), &NavigationAgent::set_neighbor_dist);
- ClassDB::bind_method(D_METHOD("get_neighbor_dist"), &NavigationAgent::get_neighbor_dist);
+ ClassDB::bind_method(D_METHOD("set_neighbor_dist", "neighbor_dist"), &NavigationAgent3D::set_neighbor_dist);
+ ClassDB::bind_method(D_METHOD("get_neighbor_dist"), &NavigationAgent3D::get_neighbor_dist);
- ClassDB::bind_method(D_METHOD("set_max_neighbors", "max_neighbors"), &NavigationAgent::set_max_neighbors);
- ClassDB::bind_method(D_METHOD("get_max_neighbors"), &NavigationAgent::get_max_neighbors);
+ ClassDB::bind_method(D_METHOD("set_max_neighbors", "max_neighbors"), &NavigationAgent3D::set_max_neighbors);
+ ClassDB::bind_method(D_METHOD("get_max_neighbors"), &NavigationAgent3D::get_max_neighbors);
- ClassDB::bind_method(D_METHOD("set_time_horizon", "time_horizon"), &NavigationAgent::set_time_horizon);
- ClassDB::bind_method(D_METHOD("get_time_horizon"), &NavigationAgent::get_time_horizon);
+ ClassDB::bind_method(D_METHOD("set_time_horizon", "time_horizon"), &NavigationAgent3D::set_time_horizon);
+ ClassDB::bind_method(D_METHOD("get_time_horizon"), &NavigationAgent3D::get_time_horizon);
- ClassDB::bind_method(D_METHOD("set_max_speed", "max_speed"), &NavigationAgent::set_max_speed);
- ClassDB::bind_method(D_METHOD("get_max_speed"), &NavigationAgent::get_max_speed);
+ ClassDB::bind_method(D_METHOD("set_max_speed", "max_speed"), &NavigationAgent3D::set_max_speed);
+ ClassDB::bind_method(D_METHOD("get_max_speed"), &NavigationAgent3D::get_max_speed);
- ClassDB::bind_method(D_METHOD("set_path_max_distance", "max_speed"), &NavigationAgent::set_path_max_distance);
- ClassDB::bind_method(D_METHOD("get_path_max_distance"), &NavigationAgent::get_path_max_distance);
+ ClassDB::bind_method(D_METHOD("set_path_max_distance", "max_speed"), &NavigationAgent3D::set_path_max_distance);
+ ClassDB::bind_method(D_METHOD("get_path_max_distance"), &NavigationAgent3D::get_path_max_distance);
- ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent::set_target_location);
- ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent::get_target_location);
- ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent::get_next_location);
- ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent::distance_to_target);
- ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent::set_velocity);
- ClassDB::bind_method(D_METHOD("get_nav_path"), &NavigationAgent::get_nav_path);
- ClassDB::bind_method(D_METHOD("get_nav_path_index"), &NavigationAgent::get_nav_path_index);
- ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent::is_target_reached);
- ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent::is_target_reachable);
- ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent::is_navigation_finished);
- ClassDB::bind_method(D_METHOD("get_final_location"), &NavigationAgent::get_final_location);
+ ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent3D::set_target_location);
+ ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent3D::get_target_location);
+ ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent3D::get_next_location);
+ ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent3D::distance_to_target);
+ ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent3D::set_velocity);
+ ClassDB::bind_method(D_METHOD("get_nav_path"), &NavigationAgent3D::get_nav_path);
+ ClassDB::bind_method(D_METHOD("get_nav_path_index"), &NavigationAgent3D::get_nav_path_index);
+ ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent3D::is_target_reached);
+ ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent3D::is_target_reachable);
+ ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent3D::is_navigation_finished);
+ ClassDB::bind_method(D_METHOD("get_final_location"), &NavigationAgent3D::get_final_location);
- ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent::_avoidance_done);
+ ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent3D::_avoidance_done);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01"), "set_target_desired_distance", "get_target_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.1,100,0.01"), "set_radius", "get_radius");
@@ -96,20 +96,20 @@ void NavigationAgent::_bind_methods() {
ADD_SIGNAL(MethodInfo("velocity_computed", PropertyInfo(Variant::VECTOR3, "safe_velocity")));
}
-void NavigationAgent::_notification(int p_what) {
+void NavigationAgent3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- agent_parent = Object::cast_to<Spatial>(get_parent());
+ agent_parent = Object::cast_to<Node3D>(get_parent());
- NavigationServer::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
+ NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
// Search the navigation node and set it
{
- Navigation *nav = NULL;
+ Navigation3D *nav = NULL;
Node *p = get_parent();
while (p != NULL) {
- nav = Object::cast_to<Navigation>(p);
+ nav = Object::cast_to<Navigation3D>(p);
if (nav != NULL)
p = NULL;
else
@@ -129,7 +129,7 @@ void NavigationAgent::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent) {
- NavigationServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
+ NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
if (!target_reached) {
if (distance_to_target() < target_desired_distance) {
emit_signal("target_reached");
@@ -141,7 +141,7 @@ void NavigationAgent::_notification(int p_what) {
}
}
-NavigationAgent::NavigationAgent() :
+NavigationAgent3D::NavigationAgent3D() :
agent_parent(NULL),
navigation(NULL),
agent(RID()),
@@ -151,7 +151,7 @@ NavigationAgent::NavigationAgent() :
velocity_submitted(false),
target_reached(false),
navigation_finished(true) {
- agent = NavigationServer::get_singleton()->agent_create();
+ agent = NavigationServer3D::get_singleton()->agent_create();
set_neighbor_dist(50.0);
set_max_neighbors(10);
set_time_horizon(5.0);
@@ -160,76 +160,76 @@ NavigationAgent::NavigationAgent() :
set_ignore_y(true);
}
-NavigationAgent::~NavigationAgent() {
- NavigationServer::get_singleton()->free(agent);
+NavigationAgent3D::~NavigationAgent3D() {
+ NavigationServer3D::get_singleton()->free(agent);
agent = RID(); // Pointless
}
-void NavigationAgent::set_navigation(Navigation *p_nav) {
+void NavigationAgent3D::set_navigation(Navigation3D *p_nav) {
if (navigation == p_nav)
return; // Pointless
navigation = p_nav;
- NavigationServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
+ NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
}
-void NavigationAgent::set_navigation_node(Node *p_nav) {
- Navigation *nav = Object::cast_to<Navigation>(p_nav);
+void NavigationAgent3D::set_navigation_node(Node *p_nav) {
+ Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav);
ERR_FAIL_COND(nav == NULL);
set_navigation(nav);
}
-Node *NavigationAgent::get_navigation_node() const {
+Node *NavigationAgent3D::get_navigation_node() const {
return Object::cast_to<Node>(navigation);
}
-void NavigationAgent::set_target_desired_distance(real_t p_dd) {
+void NavigationAgent3D::set_target_desired_distance(real_t p_dd) {
target_desired_distance = p_dd;
}
-void NavigationAgent::set_radius(real_t p_radius) {
+void NavigationAgent3D::set_radius(real_t p_radius) {
radius = p_radius;
- NavigationServer::get_singleton()->agent_set_radius(agent, radius);
+ NavigationServer3D::get_singleton()->agent_set_radius(agent, radius);
}
-void NavigationAgent::set_agent_height_offset(real_t p_hh) {
+void NavigationAgent3D::set_agent_height_offset(real_t p_hh) {
navigation_height_offset = p_hh;
}
-void NavigationAgent::set_ignore_y(bool p_ignore_y) {
+void NavigationAgent3D::set_ignore_y(bool p_ignore_y) {
ignore_y = p_ignore_y;
- NavigationServer::get_singleton()->agent_set_ignore_y(agent, ignore_y);
+ NavigationServer3D::get_singleton()->agent_set_ignore_y(agent, ignore_y);
}
-void NavigationAgent::set_neighbor_dist(real_t p_dist) {
+void NavigationAgent3D::set_neighbor_dist(real_t p_dist) {
neighbor_dist = p_dist;
- NavigationServer::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist);
+ NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist);
}
-void NavigationAgent::set_max_neighbors(int p_count) {
+void NavigationAgent3D::set_max_neighbors(int p_count) {
max_neighbors = p_count;
- NavigationServer::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
+ NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors);
}
-void NavigationAgent::set_time_horizon(real_t p_time) {
+void NavigationAgent3D::set_time_horizon(real_t p_time) {
time_horizon = p_time;
- NavigationServer::get_singleton()->agent_set_time_horizon(agent, time_horizon);
+ NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, time_horizon);
}
-void NavigationAgent::set_max_speed(real_t p_max_speed) {
+void NavigationAgent3D::set_max_speed(real_t p_max_speed) {
max_speed = p_max_speed;
- NavigationServer::get_singleton()->agent_set_max_speed(agent, max_speed);
+ NavigationServer3D::get_singleton()->agent_set_max_speed(agent, max_speed);
}
-void NavigationAgent::set_path_max_distance(real_t p_pmd) {
+void NavigationAgent3D::set_path_max_distance(real_t p_pmd) {
path_max_distance = p_pmd;
}
-real_t NavigationAgent::get_path_max_distance() {
+real_t NavigationAgent3D::get_path_max_distance() {
return path_max_distance;
}
-void NavigationAgent::set_target_location(Vector3 p_location) {
+void NavigationAgent3D::set_target_location(Vector3 p_location) {
target_location = p_location;
navigation_path.clear();
target_reached = false;
@@ -237,11 +237,11 @@ void NavigationAgent::set_target_location(Vector3 p_location) {
update_frame_id = 0;
}
-Vector3 NavigationAgent::get_target_location() const {
+Vector3 NavigationAgent3D::get_target_location() const {
return target_location;
}
-Vector3 NavigationAgent::get_next_location() {
+Vector3 NavigationAgent3D::get_next_location() {
update_navigation();
if (navigation_path.size() == 0) {
ERR_FAIL_COND_V(agent_parent == NULL, Vector3());
@@ -251,25 +251,25 @@ Vector3 NavigationAgent::get_next_location() {
}
}
-real_t NavigationAgent::distance_to_target() const {
+real_t NavigationAgent3D::distance_to_target() const {
ERR_FAIL_COND_V(agent_parent == NULL, 0.0);
return agent_parent->get_global_transform().origin.distance_to(target_location);
}
-bool NavigationAgent::is_target_reached() const {
+bool NavigationAgent3D::is_target_reached() const {
return target_reached;
}
-bool NavigationAgent::is_target_reachable() {
+bool NavigationAgent3D::is_target_reachable() {
return target_desired_distance >= get_final_location().distance_to(target_location);
}
-bool NavigationAgent::is_navigation_finished() {
+bool NavigationAgent3D::is_navigation_finished() {
update_navigation();
return navigation_finished;
}
-Vector3 NavigationAgent::get_final_location() {
+Vector3 NavigationAgent3D::get_final_location() {
update_navigation();
if (navigation_path.size() == 0) {
return Vector3();
@@ -277,14 +277,14 @@ Vector3 NavigationAgent::get_final_location() {
return navigation_path[navigation_path.size() - 1];
}
-void NavigationAgent::set_velocity(Vector3 p_velocity) {
+void NavigationAgent3D::set_velocity(Vector3 p_velocity) {
target_velocity = p_velocity;
- NavigationServer::get_singleton()->agent_set_target_velocity(agent, target_velocity);
- NavigationServer::get_singleton()->agent_set_velocity(agent, prev_safe_velocity);
+ NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, target_velocity);
+ NavigationServer3D::get_singleton()->agent_set_velocity(agent, prev_safe_velocity);
velocity_submitted = true;
}
-void NavigationAgent::_avoidance_done(Vector3 p_new_velocity) {
+void NavigationAgent3D::_avoidance_done(Vector3 p_new_velocity) {
prev_safe_velocity = p_new_velocity;
if (!velocity_submitted) {
@@ -296,15 +296,15 @@ void NavigationAgent::_avoidance_done(Vector3 p_new_velocity) {
emit_signal("velocity_computed", p_new_velocity);
}
-String NavigationAgent::get_configuration_warning() const {
- if (!Object::cast_to<Spatial>(get_parent())) {
+String NavigationAgent3D::get_configuration_warning() const {
+ if (!Object::cast_to<Node3D>(get_parent())) {
return TTR("The NavigationAgent can be used only under a spatial node.");
}
return String();
}
-void NavigationAgent::update_navigation() {
+void NavigationAgent3D::update_navigation() {
if (agent_parent == NULL) return;
if (navigation == NULL) return;
@@ -316,7 +316,7 @@ void NavigationAgent::update_navigation() {
bool reload_path = false;
- if (NavigationServer::get_singleton()->agent_is_map_changed(agent)) {
+ if (NavigationServer3D::get_singleton()->agent_is_map_changed(agent)) {
reload_path = true;
} else if (navigation_path.size() == 0) {
reload_path = true;
@@ -337,7 +337,7 @@ void NavigationAgent::update_navigation() {
}
if (reload_path) {
- navigation_path = NavigationServer::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true);
+ navigation_path = NavigationServer3D::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true);
navigation_finished = false;
nav_path_index = 0;
emit_signal("path_changed");
diff --git a/scene/3d/navigation_agent.h b/scene/3d/navigation_agent_3d.h
index 200d5db475..3558b4e51b 100644
--- a/scene/3d/navigation_agent.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_agent.h */
+/* navigation_agent_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,14 +34,14 @@
#include "core/vector.h"
#include "scene/main/node.h"
-class Spatial;
-class Navigation;
+class Node3D;
+class Navigation3D;
-class NavigationAgent : public Node {
- GDCLASS(NavigationAgent, Node);
+class NavigationAgent3D : public Node {
+ GDCLASS(NavigationAgent3D, Node);
- Spatial *agent_parent;
- Navigation *navigation;
+ Node3D *agent_parent;
+ Navigation3D *navigation;
RID agent;
@@ -73,11 +73,11 @@ protected:
void _notification(int p_what);
public:
- NavigationAgent();
- virtual ~NavigationAgent();
+ NavigationAgent3D();
+ virtual ~NavigationAgent3D();
- void set_navigation(Navigation *p_nav);
- const Navigation *get_navigation() const {
+ void set_navigation(Navigation3D *p_nav);
+ const Navigation3D *get_navigation() const {
return navigation;
}
diff --git a/scene/3d/navigation_obstacle.cpp b/scene/3d/navigation_obstacle_3d.cpp
index befc41eee5..63c273b4ca 100644
--- a/scene/3d/navigation_obstacle.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_obstacle.cpp */
+/* navigation_obstacle_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,20 +28,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "navigation_obstacle.h"
+#include "navigation_obstacle_3d.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/navigation.h"
-#include "scene/3d/physics_body.h"
-#include "servers/navigation_server.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/navigation_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "servers/navigation_server_3d.h"
-void NavigationObstacle::_bind_methods() {
+void NavigationObstacle3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle::set_navigation_node);
- ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle::get_navigation_node);
+ ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle3D::set_navigation_node);
+ ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle3D::get_navigation_node);
}
-void NavigationObstacle::_notification(int p_what) {
+void NavigationObstacle3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
@@ -49,10 +49,10 @@ void NavigationObstacle::_notification(int p_what) {
// Search the navigation node and set it
{
- Navigation *nav = NULL;
+ Navigation3D *nav = NULL;
Node *p = get_parent();
while (p != NULL) {
- nav = Object::cast_to<Navigation>(p);
+ nav = Object::cast_to<Navigation3D>(p);
if (nav != NULL)
p = NULL;
else
@@ -69,54 +69,54 @@ void NavigationObstacle::_notification(int p_what) {
set_physics_process_internal(false);
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
- Spatial *spatial = Object::cast_to<Spatial>(get_parent());
+ Node3D *spatial = Object::cast_to<Node3D>(get_parent());
if (spatial) {
- NavigationServer::get_singleton()->agent_set_position(agent, spatial->get_global_transform().origin);
+ NavigationServer3D::get_singleton()->agent_set_position(agent, spatial->get_global_transform().origin);
}
- PhysicsBody *rigid = Object::cast_to<PhysicsBody>(get_parent());
+ PhysicsBody3D *rigid = Object::cast_to<PhysicsBody3D>(get_parent());
if (rigid) {
Vector3 v = rigid->get_linear_velocity();
- NavigationServer::get_singleton()->agent_set_velocity(agent, v);
- NavigationServer::get_singleton()->agent_set_target_velocity(agent, v);
+ NavigationServer3D::get_singleton()->agent_set_velocity(agent, v);
+ NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, v);
}
} break;
}
}
-NavigationObstacle::NavigationObstacle() :
+NavigationObstacle3D::NavigationObstacle3D() :
navigation(NULL),
agent(RID()) {
- agent = NavigationServer::get_singleton()->agent_create();
+ agent = NavigationServer3D::get_singleton()->agent_create();
}
-NavigationObstacle::~NavigationObstacle() {
- NavigationServer::get_singleton()->free(agent);
+NavigationObstacle3D::~NavigationObstacle3D() {
+ NavigationServer3D::get_singleton()->free(agent);
agent = RID(); // Pointless
}
-void NavigationObstacle::set_navigation(Navigation *p_nav) {
+void NavigationObstacle3D::set_navigation(Navigation3D *p_nav) {
if (navigation == p_nav)
return; // Pointless
navigation = p_nav;
- NavigationServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
+ NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid());
}
-void NavigationObstacle::set_navigation_node(Node *p_nav) {
- Navigation *nav = Object::cast_to<Navigation>(p_nav);
+void NavigationObstacle3D::set_navigation_node(Node *p_nav) {
+ Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav);
ERR_FAIL_COND(nav == NULL);
set_navigation(nav);
}
-Node *NavigationObstacle::get_navigation_node() const {
+Node *NavigationObstacle3D::get_navigation_node() const {
return Object::cast_to<Node>(navigation);
}
-String NavigationObstacle::get_configuration_warning() const {
- if (!Object::cast_to<Spatial>(get_parent())) {
+String NavigationObstacle3D::get_configuration_warning() const {
+ if (!Object::cast_to<Node3D>(get_parent())) {
return TTR("The NavigationObstacle only serves to provide collision avoidance to a spatial object.");
}
@@ -124,14 +124,14 @@ String NavigationObstacle::get_configuration_warning() const {
return String();
}
-void NavigationObstacle::update_agent_shape() {
+void NavigationObstacle3D::update_agent_shape() {
Node *node = get_parent();
// Estimate the radius of this physics body
real_t radius = 0.0;
for (int i(0); i < node->get_child_count(); i++) {
// For each collision shape
- CollisionShape *cs = Object::cast_to<CollisionShape>(node->get_child(i));
+ CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(node->get_child(i));
if (cs) {
// Take the distance between the Body center to the shape center
real_t r = cs->get_transform().origin.length();
@@ -145,7 +145,7 @@ void NavigationObstacle::update_agent_shape() {
radius = MAX(radius, r);
}
}
- Spatial *spa = Object::cast_to<Spatial>(node);
+ Node3D *spa = Object::cast_to<Node3D>(node);
if (spa) {
Vector3 s = spa->get_global_transform().basis.get_scale();
radius *= MAX(s.x, MAX(s.y, s.z));
@@ -155,9 +155,9 @@ void NavigationObstacle::update_agent_shape() {
radius = 1.0; // Never a 0 radius
// Initialize the Agent as an object
- NavigationServer::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
- NavigationServer::get_singleton()->agent_set_max_neighbors(agent, 0);
- NavigationServer::get_singleton()->agent_set_time_horizon(agent, 0.0);
- NavigationServer::get_singleton()->agent_set_radius(agent, radius);
- NavigationServer::get_singleton()->agent_set_max_speed(agent, 0.0);
+ NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
+ NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, 0);
+ NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, 0.0);
+ NavigationServer3D::get_singleton()->agent_set_radius(agent, radius);
+ NavigationServer3D::get_singleton()->agent_set_max_speed(agent, 0.0);
}
diff --git a/scene/3d/navigation_obstacle.h b/scene/3d/navigation_obstacle_3d.h
index 7257a43150..b58d7c4991 100644
--- a/scene/3d/navigation_obstacle.h
+++ b/scene/3d/navigation_obstacle_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_obstacle.h */
+/* navigation_obstacle_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,12 +33,12 @@
#include "scene/main/node.h"
-class Navigation;
+class Navigation3D;
-class NavigationObstacle : public Node {
- GDCLASS(NavigationObstacle, Node);
+class NavigationObstacle3D : public Node {
+ GDCLASS(NavigationObstacle3D, Node);
- Navigation *navigation;
+ Navigation3D *navigation;
RID agent;
@@ -47,11 +47,11 @@ protected:
void _notification(int p_what);
public:
- NavigationObstacle();
- virtual ~NavigationObstacle();
+ NavigationObstacle3D();
+ virtual ~NavigationObstacle3D();
- void set_navigation(Navigation *p_nav);
- const Navigation *get_navigation() const {
+ void set_navigation(Navigation3D *p_nav);
+ const Navigation3D *get_navigation() const {
return navigation;
}
diff --git a/scene/3d/navigation_region.cpp b/scene/3d/navigation_region_3d.cpp
index 53b707a29a..4bb2c72172 100644
--- a/scene/3d/navigation_region.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_region.cpp */
+/* navigation_region_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "navigation_region.h"
+#include "navigation_region_3d.h"
#include "core/os/thread.h"
-#include "mesh_instance.h"
-#include "navigation.h"
-#include "servers/navigation_server.h"
+#include "mesh_instance_3d.h"
+#include "navigation_3d.h"
+#include "servers/navigation_server_3d.h"
-void NavigationRegion::set_enabled(bool p_enabled) {
+void NavigationRegion3D::set_enabled(bool p_enabled) {
if (enabled == p_enabled)
return;
@@ -45,17 +45,17 @@ void NavigationRegion::set_enabled(bool p_enabled) {
if (!enabled) {
- NavigationServer::get_singleton()->region_set_map(region, RID());
+ NavigationServer3D::get_singleton()->region_set_map(region, RID());
} else {
if (navigation) {
- NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
}
}
if (debug_view) {
- MeshInstance *dm = Object::cast_to<MeshInstance>(debug_view);
+ MeshInstance3D *dm = Object::cast_to<MeshInstance3D>(debug_view);
if (is_enabled()) {
dm->set_material_override(get_tree()->get_debug_navigation_material());
} else {
@@ -66,27 +66,27 @@ void NavigationRegion::set_enabled(bool p_enabled) {
update_gizmo();
}
-bool NavigationRegion::is_enabled() const {
+bool NavigationRegion3D::is_enabled() const {
return enabled;
}
/////////////////////////////
-void NavigationRegion::_notification(int p_what) {
+void NavigationRegion3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- Spatial *c = this;
+ Node3D *c = this;
while (c) {
- navigation = Object::cast_to<Navigation>(c);
+ navigation = Object::cast_to<Navigation3D>(c);
if (navigation) {
if (enabled) {
- NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
}
break;
}
@@ -96,7 +96,7 @@ void NavigationRegion::_notification(int p_what) {
if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) {
- MeshInstance *dm = memnew(MeshInstance);
+ MeshInstance3D *dm = memnew(MeshInstance3D);
dm->set_mesh(navmesh->get_debug_mesh());
if (is_enabled()) {
dm->set_material_override(get_tree()->get_debug_navigation_material());
@@ -110,14 +110,14 @@ void NavigationRegion::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- NavigationServer::get_singleton()->region_set_transform(region, get_global_transform());
+ NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform());
} break;
case NOTIFICATION_EXIT_TREE: {
if (navigation) {
- NavigationServer::get_singleton()->region_set_map(region, RID());
+ NavigationServer3D::get_singleton()->region_set_map(region, RID());
}
if (debug_view) {
@@ -129,7 +129,7 @@ void NavigationRegion::_notification(int p_what) {
}
}
-void NavigationRegion::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
+void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
if (p_navmesh == navmesh)
return;
@@ -144,10 +144,10 @@ void NavigationRegion::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh)
navmesh->add_change_receptor(this);
}
- NavigationServer::get_singleton()->region_set_navmesh(region, p_navmesh);
+ NavigationServer3D::get_singleton()->region_set_navmesh(region, p_navmesh);
if (debug_view && navmesh.is_valid()) {
- Object::cast_to<MeshInstance>(debug_view)->set_mesh(navmesh->get_debug_mesh());
+ Object::cast_to<MeshInstance3D>(debug_view)->set_mesh(navmesh->get_debug_mesh());
}
emit_signal("navigation_mesh_changed");
@@ -156,13 +156,13 @@ void NavigationRegion::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh)
update_configuration_warning();
}
-Ref<NavigationMesh> NavigationRegion::get_navigation_mesh() const {
+Ref<NavigationMesh> NavigationRegion3D::get_navigation_mesh() const {
return navmesh;
}
struct BakeThreadsArgs {
- NavigationRegion *nav_region;
+ NavigationRegion3D *nav_region;
};
void _bake_navigation_mesh(void *p_user_data) {
@@ -171,7 +171,7 @@ void _bake_navigation_mesh(void *p_user_data) {
if (args->nav_region->get_navigation_mesh().is_valid()) {
Ref<NavigationMesh> nav_mesh = args->nav_region->get_navigation_mesh()->duplicate();
- NavigationServer::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_region);
+ NavigationServer3D::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_region);
args->nav_region->call_deferred("_bake_finished", nav_mesh);
memdelete(args);
} else {
@@ -182,7 +182,7 @@ void _bake_navigation_mesh(void *p_user_data) {
}
}
-void NavigationRegion::bake_navigation_mesh() {
+void NavigationRegion3D::bake_navigation_mesh() {
ERR_FAIL_COND(bake_thread != NULL);
BakeThreadsArgs *args = memnew(BakeThreadsArgs);
@@ -192,12 +192,12 @@ void NavigationRegion::bake_navigation_mesh() {
ERR_FAIL_COND(bake_thread == NULL);
}
-void NavigationRegion::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
+void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
set_navigation_mesh(p_nav_mesh);
bake_thread = NULL;
}
-String NavigationRegion::get_configuration_warning() const {
+String NavigationRegion3D::get_configuration_warning() const {
if (!is_visible_in_tree() || !is_inside_tree())
return String();
@@ -205,28 +205,28 @@ String NavigationRegion::get_configuration_warning() const {
if (!navmesh.is_valid()) {
return TTR("A NavigationMesh resource must be set or created for this node to work.");
}
- const Spatial *c = this;
+ const Node3D *c = this;
while (c) {
- if (Object::cast_to<Navigation>(c))
+ if (Object::cast_to<Navigation3D>(c))
return String();
- c = Object::cast_to<Spatial>(c->get_parent());
+ c = Object::cast_to<Node3D>(c->get_parent());
}
return TTR("NavigationRegion must be a child or grandchild to a Navigation node. It only provides navigation data.");
}
-void NavigationRegion::_bind_methods() {
+void NavigationRegion3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationRegion::set_navigation_mesh);
- ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationRegion::get_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationRegion3D::set_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationRegion3D::get_navigation_mesh);
- ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion::set_enabled);
- ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationRegion3D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationRegion3D::is_enabled);
- ClassDB::bind_method(D_METHOD("bake_navigation_mesh"), &NavigationRegion::bake_navigation_mesh);
- ClassDB::bind_method(D_METHOD("_bake_finished", "nav_mesh"), &NavigationRegion::_bake_finished);
+ ClassDB::bind_method(D_METHOD("bake_navigation_mesh"), &NavigationRegion3D::bake_navigation_mesh);
+ ClassDB::bind_method(D_METHOD("_bake_finished", "nav_mesh"), &NavigationRegion3D::_bake_finished);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), "set_navigation_mesh", "get_navigation_mesh");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
@@ -235,24 +235,24 @@ void NavigationRegion::_bind_methods() {
ADD_SIGNAL(MethodInfo("bake_finished"));
}
-void NavigationRegion::_changed_callback(Object *p_changed, const char *p_prop) {
+void NavigationRegion3D::_changed_callback(Object *p_changed, const char *p_prop) {
update_gizmo();
update_configuration_warning();
}
-NavigationRegion::NavigationRegion() {
+NavigationRegion3D::NavigationRegion3D() {
enabled = true;
set_notify_transform(true);
- region = NavigationServer::get_singleton()->region_create();
+ region = NavigationServer3D::get_singleton()->region_create();
navigation = NULL;
debug_view = NULL;
bake_thread = NULL;
}
-NavigationRegion::~NavigationRegion() {
+NavigationRegion3D::~NavigationRegion3D() {
if (navmesh.is_valid())
navmesh->remove_change_receptor(this);
- NavigationServer::get_singleton()->free(region);
+ NavigationServer3D::get_singleton()->free(region);
}
diff --git a/scene/3d/navigation_region.h b/scene/3d/navigation_region_3d.h
index f215e92c97..ae071e6b7a 100644
--- a/scene/3d/navigation_region.h
+++ b/scene/3d/navigation_region_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_region.h */
+/* navigation_region_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,21 +31,21 @@
#ifndef NAVIGATION_REGION_H
#define NAVIGATION_REGION_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/mesh.h"
#include "scene/resources/navigation_mesh.h"
-class Navigation;
+class Navigation3D;
-class NavigationRegion : public Spatial {
+class NavigationRegion3D : public Node3D {
- GDCLASS(NavigationRegion, Spatial);
+ GDCLASS(NavigationRegion3D, Node3D);
bool enabled;
RID region;
Ref<NavigationMesh> navmesh;
- Navigation *navigation;
+ Navigation3D *navigation;
Node *debug_view;
Thread *bake_thread;
@@ -68,8 +68,8 @@ public:
String get_configuration_warning() const;
- NavigationRegion();
- ~NavigationRegion();
+ NavigationRegion3D();
+ ~NavigationRegion3D();
};
#endif // NAVIGATION_REGION_H
diff --git a/scene/3d/spatial.cpp b/scene/3d/node_3d.cpp
index f1911348ce..7f444d59bf 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/node_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial.cpp */
+/* node_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "spatial.h"
+#include "node_3d.h"
#include "core/engine.h"
#include "core/message_queue.h"
#include "scene/main/scene_tree.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
/*
@@ -70,10 +70,10 @@ future: no idea
*/
-SpatialGizmo::SpatialGizmo() {
+Node3DGizmo::Node3DGizmo() {
}
-void Spatial::_notify_dirty() {
+void Node3D::_notify_dirty() {
#ifdef TOOLS_ENABLED
if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) {
@@ -85,12 +85,12 @@ void Spatial::_notify_dirty() {
}
}
-void Spatial::_update_local_transform() const {
+void Node3D::_update_local_transform() const {
data.local_transform.basis.set_euler_scale(data.rotation, data.scale);
data.dirty &= ~DIRTY_LOCAL;
}
-void Spatial::_propagate_transform_changed(Spatial *p_origin) {
+void Node3D::_propagate_transform_changed(Node3D *p_origin) {
if (!is_inside_tree()) {
return;
@@ -103,7 +103,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
data.children_lock++;
- for (List<Spatial *>::Element *E = data.children.front(); E; E = E->next()) {
+ for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) {
if (E->get()->data.toplevel_active)
continue; //don't propagate to a toplevel
@@ -121,7 +121,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
data.children_lock--;
}
-void Spatial::_notification(int p_what) {
+void Node3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -129,7 +129,7 @@ void Spatial::_notification(int p_what) {
Node *p = get_parent();
if (p)
- data.parent = Object::cast_to<Spatial>(p);
+ data.parent = Object::cast_to<Node3D>(p);
if (data.parent)
data.C = data.parent->data.children.push_back(this);
@@ -230,7 +230,7 @@ void Spatial::_notification(int p_what) {
}
}
-void Spatial::set_transform(const Transform &p_transform) {
+void Node3D::set_transform(const Transform &p_transform) {
data.local_transform = p_transform;
data.dirty |= DIRTY_VECTORS;
@@ -244,7 +244,7 @@ void Spatial::set_transform(const Transform &p_transform) {
}
}
-void Spatial::set_global_transform(const Transform &p_transform) {
+void Node3D::set_global_transform(const Transform &p_transform) {
Transform xform =
(data.parent && !data.toplevel_active) ?
@@ -254,7 +254,7 @@ void Spatial::set_global_transform(const Transform &p_transform) {
set_transform(xform);
}
-Transform Spatial::get_transform() const {
+Transform Node3D::get_transform() const {
if (data.dirty & DIRTY_LOCAL) {
@@ -263,7 +263,7 @@ Transform Spatial::get_transform() const {
return data.local_transform;
}
-Transform Spatial::get_global_transform() const {
+Transform Node3D::get_global_transform() const {
ERR_FAIL_COND_V(!is_inside_tree(), Transform());
@@ -293,21 +293,21 @@ Transform Spatial::get_global_transform() const {
}
#ifdef TOOLS_ENABLED
-Transform Spatial::get_global_gizmo_transform() const {
+Transform Node3D::get_global_gizmo_transform() const {
return get_global_transform();
}
-Transform Spatial::get_local_gizmo_transform() const {
+Transform Node3D::get_local_gizmo_transform() const {
return get_transform();
}
#endif
-Spatial *Spatial::get_parent_spatial() const {
+Node3D *Node3D::get_parent_spatial() const {
return data.parent;
}
-Transform Spatial::get_relative_transform(const Node *p_parent) const {
+Transform Node3D::get_relative_transform(const Node *p_parent) const {
if (p_parent == this)
return Transform();
@@ -320,7 +320,7 @@ Transform Spatial::get_relative_transform(const Node *p_parent) const {
return data.parent->get_relative_transform(p_parent) * get_transform();
}
-void Spatial::set_translation(const Vector3 &p_translation) {
+void Node3D::set_translation(const Vector3 &p_translation) {
data.local_transform.origin = p_translation;
_change_notify("transform");
@@ -330,7 +330,7 @@ void Spatial::set_translation(const Vector3 &p_translation) {
}
}
-void Spatial::set_rotation(const Vector3 &p_euler_rad) {
+void Node3D::set_rotation(const Vector3 &p_euler_rad) {
if (data.dirty & DIRTY_VECTORS) {
data.scale = data.local_transform.basis.get_scale();
@@ -346,12 +346,12 @@ void Spatial::set_rotation(const Vector3 &p_euler_rad) {
}
}
-void Spatial::set_rotation_degrees(const Vector3 &p_euler_deg) {
+void Node3D::set_rotation_degrees(const Vector3 &p_euler_deg) {
set_rotation(p_euler_deg * Math_PI / 180.0);
}
-void Spatial::set_scale(const Vector3 &p_scale) {
+void Node3D::set_scale(const Vector3 &p_scale) {
if (data.dirty & DIRTY_VECTORS) {
data.rotation = data.local_transform.basis.get_rotation();
@@ -367,12 +367,12 @@ void Spatial::set_scale(const Vector3 &p_scale) {
}
}
-Vector3 Spatial::get_translation() const {
+Vector3 Node3D::get_translation() const {
return data.local_transform.origin;
}
-Vector3 Spatial::get_rotation() const {
+Vector3 Node3D::get_rotation() const {
if (data.dirty & DIRTY_VECTORS) {
data.scale = data.local_transform.basis.get_scale();
@@ -384,12 +384,12 @@ Vector3 Spatial::get_rotation() const {
return data.rotation;
}
-Vector3 Spatial::get_rotation_degrees() const {
+Vector3 Node3D::get_rotation_degrees() const {
return get_rotation() * 180.0 / Math_PI;
}
-Vector3 Spatial::get_scale() const {
+Vector3 Node3D::get_scale() const {
if (data.dirty & DIRTY_VECTORS) {
data.scale = data.local_transform.basis.get_scale();
@@ -401,7 +401,7 @@ Vector3 Spatial::get_scale() const {
return data.scale;
}
-void Spatial::update_gizmo() {
+void Node3D::update_gizmo() {
#ifdef TOOLS_ENABLED
if (!is_inside_world())
@@ -417,7 +417,7 @@ void Spatial::update_gizmo() {
#endif
}
-void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
+void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) {
#ifdef TOOLS_ENABLED
@@ -438,18 +438,18 @@ void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
#endif
}
-Ref<SpatialGizmo> Spatial::get_gizmo() const {
+Ref<Node3DGizmo> Node3D::get_gizmo() const {
#ifdef TOOLS_ENABLED
return data.gizmo;
#else
- return Ref<SpatialGizmo>();
+ return Ref<Node3DGizmo>();
#endif
}
-void Spatial::_update_gizmo() {
+void Node3D::_update_gizmo() {
#ifdef TOOLS_ENABLED
if (!is_inside_world())
@@ -465,25 +465,25 @@ void Spatial::_update_gizmo() {
}
#ifdef TOOLS_ENABLED
-void Spatial::set_disable_gizmo(bool p_enabled) {
+void Node3D::set_disable_gizmo(bool p_enabled) {
data.gizmo_disabled = p_enabled;
if (!p_enabled && data.gizmo.is_valid())
- data.gizmo = Ref<SpatialGizmo>();
+ data.gizmo = Ref<Node3DGizmo>();
}
#endif
-void Spatial::set_disable_scale(bool p_enabled) {
+void Node3D::set_disable_scale(bool p_enabled) {
data.disable_scale = p_enabled;
}
-bool Spatial::is_scale_disabled() const {
+bool Node3D::is_scale_disabled() const {
return data.disable_scale;
}
-void Spatial::set_as_toplevel(bool p_enabled) {
+void Node3D::set_as_toplevel(bool p_enabled) {
if (data.toplevel == p_enabled)
return;
@@ -502,20 +502,20 @@ void Spatial::set_as_toplevel(bool p_enabled) {
}
}
-bool Spatial::is_set_as_toplevel() const {
+bool Node3D::is_set_as_toplevel() const {
return data.toplevel;
}
-Ref<World> Spatial::get_world() const {
+Ref<World3D> Node3D::get_world() const {
- ERR_FAIL_COND_V(!is_inside_world(), Ref<World>());
- ERR_FAIL_COND_V(!data.viewport, Ref<World>());
+ ERR_FAIL_COND_V(!is_inside_world(), Ref<World3D>());
+ ERR_FAIL_COND_V(!data.viewport, Ref<World3D>());
return data.viewport->find_world();
}
-void Spatial::_propagate_visibility_changed() {
+void Node3D::_propagate_visibility_changed() {
notification(NOTIFICATION_VISIBILITY_CHANGED);
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
@@ -525,16 +525,16 @@ void Spatial::_propagate_visibility_changed() {
_update_gizmo();
#endif
- for (List<Spatial *>::Element *E = data.children.front(); E; E = E->next()) {
+ for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) {
- Spatial *c = E->get();
+ Node3D *c = E->get();
if (!c || !c->data.visible)
continue;
c->_propagate_visibility_changed();
}
}
-void Spatial::show() {
+void Node3D::show() {
if (data.visible)
return;
@@ -547,7 +547,7 @@ void Spatial::show() {
_propagate_visibility_changed();
}
-void Spatial::hide() {
+void Node3D::hide() {
if (!data.visible)
return;
@@ -560,9 +560,9 @@ void Spatial::hide() {
_propagate_visibility_changed();
}
-bool Spatial::is_visible_in_tree() const {
+bool Node3D::is_visible_in_tree() const {
- const Spatial *s = this;
+ const Node3D *s = this;
while (s) {
if (!s->data.visible) {
@@ -574,7 +574,7 @@ bool Spatial::is_visible_in_tree() const {
return true;
}
-void Spatial::set_visible(bool p_visible) {
+void Node3D::set_visible(bool p_visible) {
if (p_visible)
show();
@@ -582,52 +582,52 @@ void Spatial::set_visible(bool p_visible) {
hide();
}
-bool Spatial::is_visible() const {
+bool Node3D::is_visible() const {
return data.visible;
}
-void Spatial::rotate_object_local(const Vector3 &p_axis, float p_angle) {
+void Node3D::rotate_object_local(const Vector3 &p_axis, float p_angle) {
Transform t = get_transform();
t.basis.rotate_local(p_axis, p_angle);
set_transform(t);
}
-void Spatial::rotate(const Vector3 &p_axis, float p_angle) {
+void Node3D::rotate(const Vector3 &p_axis, float p_angle) {
Transform t = get_transform();
t.basis.rotate(p_axis, p_angle);
set_transform(t);
}
-void Spatial::rotate_x(float p_angle) {
+void Node3D::rotate_x(float p_angle) {
Transform t = get_transform();
t.basis.rotate(Vector3(1, 0, 0), p_angle);
set_transform(t);
}
-void Spatial::rotate_y(float p_angle) {
+void Node3D::rotate_y(float p_angle) {
Transform t = get_transform();
t.basis.rotate(Vector3(0, 1, 0), p_angle);
set_transform(t);
}
-void Spatial::rotate_z(float p_angle) {
+void Node3D::rotate_z(float p_angle) {
Transform t = get_transform();
t.basis.rotate(Vector3(0, 0, 1), p_angle);
set_transform(t);
}
-void Spatial::translate(const Vector3 &p_offset) {
+void Node3D::translate(const Vector3 &p_offset) {
Transform t = get_transform();
t.translate(p_offset);
set_transform(t);
}
-void Spatial::translate_object_local(const Vector3 &p_offset) {
+void Node3D::translate_object_local(const Vector3 &p_offset) {
Transform t = get_transform();
Transform s;
@@ -635,58 +635,58 @@ void Spatial::translate_object_local(const Vector3 &p_offset) {
set_transform(t * s);
}
-void Spatial::scale(const Vector3 &p_ratio) {
+void Node3D::scale(const Vector3 &p_ratio) {
Transform t = get_transform();
t.basis.scale(p_ratio);
set_transform(t);
}
-void Spatial::scale_object_local(const Vector3 &p_scale) {
+void Node3D::scale_object_local(const Vector3 &p_scale) {
Transform t = get_transform();
t.basis.scale_local(p_scale);
set_transform(t);
}
-void Spatial::global_rotate(const Vector3 &p_axis, float p_angle) {
+void Node3D::global_rotate(const Vector3 &p_axis, float p_angle) {
Transform t = get_global_transform();
t.basis.rotate(p_axis, p_angle);
set_global_transform(t);
}
-void Spatial::global_scale(const Vector3 &p_scale) {
+void Node3D::global_scale(const Vector3 &p_scale) {
Transform t = get_global_transform();
t.basis.scale(p_scale);
set_global_transform(t);
}
-void Spatial::global_translate(const Vector3 &p_offset) {
+void Node3D::global_translate(const Vector3 &p_offset) {
Transform t = get_global_transform();
t.origin += p_offset;
set_global_transform(t);
}
-void Spatial::orthonormalize() {
+void Node3D::orthonormalize() {
Transform t = get_transform();
t.orthonormalize();
set_transform(t);
}
-void Spatial::set_identity() {
+void Node3D::set_identity() {
set_transform(Transform());
}
-void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up) {
+void Node3D::look_at(const Vector3 &p_target, const Vector3 &p_up) {
Vector3 origin(get_global_transform().origin);
look_at_from_position(origin, p_target, p_up);
}
-void Spatial::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up) {
+void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up) {
ERR_FAIL_COND_MSG(p_pos == p_target, "Node origin and target are in the same position, look_at() failed.");
ERR_FAIL_COND_MSG(p_up.cross(p_target - p_pos) == Vector3(), "Up vector and direction between node origin and target are aligned, look_at() failed.");
@@ -700,33 +700,33 @@ void Spatial::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_targe
set_scale(original_scale);
}
-Vector3 Spatial::to_local(Vector3 p_global) const {
+Vector3 Node3D::to_local(Vector3 p_global) const {
return get_global_transform().affine_inverse().xform(p_global);
}
-Vector3 Spatial::to_global(Vector3 p_local) const {
+Vector3 Node3D::to_global(Vector3 p_local) const {
return get_global_transform().xform(p_local);
}
-void Spatial::set_notify_transform(bool p_enable) {
+void Node3D::set_notify_transform(bool p_enable) {
data.notify_transform = p_enable;
}
-bool Spatial::is_transform_notification_enabled() const {
+bool Node3D::is_transform_notification_enabled() const {
return data.notify_transform;
}
-void Spatial::set_notify_local_transform(bool p_enable) {
+void Node3D::set_notify_local_transform(bool p_enable) {
data.notify_local_transform = p_enable;
}
-bool Spatial::is_local_transform_notification_enabled() const {
+bool Node3D::is_local_transform_notification_enabled() const {
return data.notify_local_transform;
}
-void Spatial::force_update_transform() {
+void Node3D::force_update_transform() {
ERR_FAIL_COND(!is_inside_tree());
if (!xform_change.in_list()) {
return; //nothing to update
@@ -736,67 +736,67 @@ void Spatial::force_update_transform() {
notification(NOTIFICATION_TRANSFORM_CHANGED);
}
-void Spatial::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_transform", "local"), &Spatial::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &Spatial::get_transform);
- ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Spatial::set_translation);
- ClassDB::bind_method(D_METHOD("get_translation"), &Spatial::get_translation);
- ClassDB::bind_method(D_METHOD("set_rotation", "euler"), &Spatial::set_rotation);
- ClassDB::bind_method(D_METHOD("get_rotation"), &Spatial::get_rotation);
- ClassDB::bind_method(D_METHOD("set_rotation_degrees", "euler_degrees"), &Spatial::set_rotation_degrees);
- ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Spatial::get_rotation_degrees);
- ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Spatial::set_scale);
- ClassDB::bind_method(D_METHOD("get_scale"), &Spatial::get_scale);
- ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Spatial::set_global_transform);
- ClassDB::bind_method(D_METHOD("get_global_transform"), &Spatial::get_global_transform);
- ClassDB::bind_method(D_METHOD("get_parent_spatial"), &Spatial::get_parent_spatial);
- ClassDB::bind_method(D_METHOD("set_ignore_transform_notification", "enabled"), &Spatial::set_ignore_transform_notification);
- ClassDB::bind_method(D_METHOD("set_as_toplevel", "enable"), &Spatial::set_as_toplevel);
- ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
- ClassDB::bind_method(D_METHOD("set_disable_scale", "disable"), &Spatial::set_disable_scale);
- ClassDB::bind_method(D_METHOD("is_scale_disabled"), &Spatial::is_scale_disabled);
- ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world);
-
- ClassDB::bind_method(D_METHOD("force_update_transform"), &Spatial::force_update_transform);
-
- ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo);
-
- ClassDB::bind_method(D_METHOD("update_gizmo"), &Spatial::update_gizmo);
- ClassDB::bind_method(D_METHOD("set_gizmo", "gizmo"), &Spatial::set_gizmo);
- ClassDB::bind_method(D_METHOD("get_gizmo"), &Spatial::get_gizmo);
-
- ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Spatial::set_visible);
- ClassDB::bind_method(D_METHOD("is_visible"), &Spatial::is_visible);
- ClassDB::bind_method(D_METHOD("is_visible_in_tree"), &Spatial::is_visible_in_tree);
- ClassDB::bind_method(D_METHOD("show"), &Spatial::show);
- ClassDB::bind_method(D_METHOD("hide"), &Spatial::hide);
-
- ClassDB::bind_method(D_METHOD("set_notify_local_transform", "enable"), &Spatial::set_notify_local_transform);
- ClassDB::bind_method(D_METHOD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
-
- ClassDB::bind_method(D_METHOD("set_notify_transform", "enable"), &Spatial::set_notify_transform);
- ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"), &Spatial::is_transform_notification_enabled);
-
- ClassDB::bind_method(D_METHOD("rotate", "axis", "angle"), &Spatial::rotate);
- ClassDB::bind_method(D_METHOD("global_rotate", "axis", "angle"), &Spatial::global_rotate);
- ClassDB::bind_method(D_METHOD("global_scale", "scale"), &Spatial::global_scale);
- ClassDB::bind_method(D_METHOD("global_translate", "offset"), &Spatial::global_translate);
- ClassDB::bind_method(D_METHOD("rotate_object_local", "axis", "angle"), &Spatial::rotate_object_local);
- ClassDB::bind_method(D_METHOD("scale_object_local", "scale"), &Spatial::scale_object_local);
- ClassDB::bind_method(D_METHOD("translate_object_local", "offset"), &Spatial::translate_object_local);
- ClassDB::bind_method(D_METHOD("rotate_x", "angle"), &Spatial::rotate_x);
- ClassDB::bind_method(D_METHOD("rotate_y", "angle"), &Spatial::rotate_y);
- ClassDB::bind_method(D_METHOD("rotate_z", "angle"), &Spatial::rotate_z);
- ClassDB::bind_method(D_METHOD("translate", "offset"), &Spatial::translate);
- ClassDB::bind_method(D_METHOD("orthonormalize"), &Spatial::orthonormalize);
- ClassDB::bind_method(D_METHOD("set_identity"), &Spatial::set_identity);
-
- ClassDB::bind_method(D_METHOD("look_at", "target", "up"), &Spatial::look_at);
- ClassDB::bind_method(D_METHOD("look_at_from_position", "position", "target", "up"), &Spatial::look_at_from_position);
-
- ClassDB::bind_method(D_METHOD("to_local", "global_point"), &Spatial::to_local);
- ClassDB::bind_method(D_METHOD("to_global", "local_point"), &Spatial::to_global);
+void Node3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_transform", "local"), &Node3D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform);
+ ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Node3D::set_translation);
+ ClassDB::bind_method(D_METHOD("get_translation"), &Node3D::get_translation);
+ ClassDB::bind_method(D_METHOD("set_rotation", "euler"), &Node3D::set_rotation);
+ ClassDB::bind_method(D_METHOD("get_rotation"), &Node3D::get_rotation);
+ ClassDB::bind_method(D_METHOD("set_rotation_degrees", "euler_degrees"), &Node3D::set_rotation_degrees);
+ ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node3D::get_rotation_degrees);
+ ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node3D::set_scale);
+ ClassDB::bind_method(D_METHOD("get_scale"), &Node3D::get_scale);
+ ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Node3D::set_global_transform);
+ ClassDB::bind_method(D_METHOD("get_global_transform"), &Node3D::get_global_transform);
+ ClassDB::bind_method(D_METHOD("get_parent_spatial"), &Node3D::get_parent_spatial);
+ ClassDB::bind_method(D_METHOD("set_ignore_transform_notification", "enabled"), &Node3D::set_ignore_transform_notification);
+ ClassDB::bind_method(D_METHOD("set_as_toplevel", "enable"), &Node3D::set_as_toplevel);
+ ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Node3D::is_set_as_toplevel);
+ ClassDB::bind_method(D_METHOD("set_disable_scale", "disable"), &Node3D::set_disable_scale);
+ ClassDB::bind_method(D_METHOD("is_scale_disabled"), &Node3D::is_scale_disabled);
+ ClassDB::bind_method(D_METHOD("get_world"), &Node3D::get_world);
+
+ ClassDB::bind_method(D_METHOD("force_update_transform"), &Node3D::force_update_transform);
+
+ ClassDB::bind_method(D_METHOD("_update_gizmo"), &Node3D::_update_gizmo);
+
+ ClassDB::bind_method(D_METHOD("update_gizmo"), &Node3D::update_gizmo);
+ ClassDB::bind_method(D_METHOD("set_gizmo", "gizmo"), &Node3D::set_gizmo);
+ ClassDB::bind_method(D_METHOD("get_gizmo"), &Node3D::get_gizmo);
+
+ ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Node3D::set_visible);
+ ClassDB::bind_method(D_METHOD("is_visible"), &Node3D::is_visible);
+ ClassDB::bind_method(D_METHOD("is_visible_in_tree"), &Node3D::is_visible_in_tree);
+ ClassDB::bind_method(D_METHOD("show"), &Node3D::show);
+ ClassDB::bind_method(D_METHOD("hide"), &Node3D::hide);
+
+ ClassDB::bind_method(D_METHOD("set_notify_local_transform", "enable"), &Node3D::set_notify_local_transform);
+ ClassDB::bind_method(D_METHOD("is_local_transform_notification_enabled"), &Node3D::is_local_transform_notification_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_notify_transform", "enable"), &Node3D::set_notify_transform);
+ ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"), &Node3D::is_transform_notification_enabled);
+
+ ClassDB::bind_method(D_METHOD("rotate", "axis", "angle"), &Node3D::rotate);
+ ClassDB::bind_method(D_METHOD("global_rotate", "axis", "angle"), &Node3D::global_rotate);
+ ClassDB::bind_method(D_METHOD("global_scale", "scale"), &Node3D::global_scale);
+ ClassDB::bind_method(D_METHOD("global_translate", "offset"), &Node3D::global_translate);
+ ClassDB::bind_method(D_METHOD("rotate_object_local", "axis", "angle"), &Node3D::rotate_object_local);
+ ClassDB::bind_method(D_METHOD("scale_object_local", "scale"), &Node3D::scale_object_local);
+ ClassDB::bind_method(D_METHOD("translate_object_local", "offset"), &Node3D::translate_object_local);
+ ClassDB::bind_method(D_METHOD("rotate_x", "angle"), &Node3D::rotate_x);
+ ClassDB::bind_method(D_METHOD("rotate_y", "angle"), &Node3D::rotate_y);
+ ClassDB::bind_method(D_METHOD("rotate_z", "angle"), &Node3D::rotate_z);
+ ClassDB::bind_method(D_METHOD("translate", "offset"), &Node3D::translate);
+ ClassDB::bind_method(D_METHOD("orthonormalize"), &Node3D::orthonormalize);
+ ClassDB::bind_method(D_METHOD("set_identity"), &Node3D::set_identity);
+
+ ClassDB::bind_method(D_METHOD("look_at", "target", "up"), &Node3D::look_at);
+ ClassDB::bind_method(D_METHOD("look_at_from_position", "position", "target", "up"), &Node3D::look_at_from_position);
+
+ ClassDB::bind_method(D_METHOD("to_local", "global_point"), &Node3D::to_local);
+ ClassDB::bind_method(D_METHOD("to_global", "local_point"), &Node3D::to_global);
BIND_CONSTANT(NOTIFICATION_TRANSFORM_CHANGED);
BIND_CONSTANT(NOTIFICATION_ENTER_WORLD);
@@ -814,12 +814,12 @@ void Spatial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform");
ADD_GROUP("Visibility", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "SpatialGizmo", 0), "set_gizmo", "get_gizmo");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "Node3DGizmo", 0), "set_gizmo", "get_gizmo");
ADD_SIGNAL(MethodInfo("visibility_changed"));
}
-Spatial::Spatial() :
+Node3D::Node3D() :
xform_change(this) {
data.dirty = DIRTY_NONE;
@@ -844,5 +844,5 @@ Spatial::Spatial() :
data.C = NULL;
}
-Spatial::~Spatial() {
+Node3D::~Node3D() {
}
diff --git a/scene/3d/spatial.h b/scene/3d/node_3d.h
index 9d4705700b..f97a8a97dc 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/node_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial.h */
+/* node_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SPATIAL_H
-#define SPATIAL_H
+#ifndef NODE_3D_H
+#define NODE_3D_H
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
-class SpatialGizmo : public Reference {
+class Node3DGizmo : public Reference {
- GDCLASS(SpatialGizmo, Reference);
+ GDCLASS(Node3DGizmo, Reference);
public:
virtual void create() = 0;
@@ -45,13 +45,13 @@ public:
virtual void redraw() = 0;
virtual void free() = 0;
- SpatialGizmo();
- virtual ~SpatialGizmo() {}
+ Node3DGizmo();
+ virtual ~Node3DGizmo() {}
};
-class Spatial : public Node {
+class Node3D : public Node {
- GDCLASS(Spatial, Node);
+ GDCLASS(Node3D, Node);
OBJ_CATEGORY("3D");
enum TransformDirty {
@@ -79,9 +79,9 @@ class Spatial : public Node {
bool inside_world;
int children_lock;
- Spatial *parent;
- List<Spatial *> children;
- List<Spatial *>::Element *C;
+ Node3D *parent;
+ List<Node3D *> children;
+ List<Node3D *>::Element *C;
bool ignore_notification;
bool notify_local_transform;
@@ -91,7 +91,7 @@ class Spatial : public Node {
bool disable_scale;
#ifdef TOOLS_ENABLED
- Ref<SpatialGizmo> gizmo;
+ Ref<Node3DGizmo> gizmo;
bool gizmo_disabled;
bool gizmo_dirty;
#endif
@@ -100,7 +100,7 @@ class Spatial : public Node {
void _update_gizmo();
void _notify_dirty();
- void _propagate_transform_changed(Spatial *p_origin);
+ void _propagate_transform_changed(Node3D *p_origin);
void _propagate_visibility_changed();
@@ -122,9 +122,9 @@ public:
NOTIFICATION_LOCAL_TRANSFORM_CHANGED = 44,
};
- Spatial *get_parent_spatial() const;
+ Node3D *get_parent_spatial() const;
- Ref<World> get_world() const;
+ Ref<World3D> get_world() const;
void set_translation(const Vector3 &p_translation);
void set_rotation(const Vector3 &p_euler_rad);
@@ -155,8 +155,8 @@ public:
void set_disable_gizmo(bool p_enabled);
void update_gizmo();
- void set_gizmo(const Ref<SpatialGizmo> &p_gizmo);
- Ref<SpatialGizmo> get_gizmo() const;
+ void set_gizmo(const Ref<Node3DGizmo> &p_gizmo);
+ Ref<Node3DGizmo> get_gizmo() const;
_FORCE_INLINE_ bool is_inside_world() const { return data.inside_world; }
@@ -200,8 +200,8 @@ public:
void force_update_transform();
- Spatial();
- ~Spatial();
+ Node3D();
+ ~Node3D();
};
-#endif
+#endif // NODE_3D_H
diff --git a/scene/3d/path.cpp b/scene/3d/path_3d.cpp
index f93485d79f..2169f664ea 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path.cpp */
+/* path_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "path.h"
+#include "path_3d.h"
#include "core/engine.h"
#include "scene/scene_string_names.h"
-void Path::_notification(int p_what) {
+void Path3D::_notification(int p_what) {
}
-void Path::_curve_changed() {
+void Path3D::_curve_changed() {
if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
update_gizmo();
@@ -48,7 +48,7 @@ void Path::_curve_changed() {
// previously used for PathFollowOriented (now enforced orientation is done in PathFollow)
if (is_inside_tree()) {
for (int i = 0; i < get_child_count(); i++) {
- PathFollow *child = Object::cast_to<PathFollow>(get_child(i));
+ PathFollow3D *child = Object::cast_to<PathFollow3D>(get_child(i));
if (child) {
child->update_configuration_warning();
}
@@ -56,43 +56,43 @@ void Path::_curve_changed() {
}
}
-void Path::set_curve(const Ref<Curve3D> &p_curve) {
+void Path3D::set_curve(const Ref<Curve3D> &p_curve) {
if (curve.is_valid()) {
- curve->disconnect("changed", callable_mp(this, &Path::_curve_changed));
+ curve->disconnect("changed", callable_mp(this, &Path3D::_curve_changed));
}
curve = p_curve;
if (curve.is_valid()) {
- curve->connect("changed", callable_mp(this, &Path::_curve_changed));
+ curve->connect("changed", callable_mp(this, &Path3D::_curve_changed));
}
_curve_changed();
}
-Ref<Curve3D> Path::get_curve() const {
+Ref<Curve3D> Path3D::get_curve() const {
return curve;
}
-void Path::_bind_methods() {
+void Path3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path::set_curve);
- ClassDB::bind_method(D_METHOD("get_curve"), &Path::get_curve);
+ ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve);
+ ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), "set_curve", "get_curve");
ADD_SIGNAL(MethodInfo("curve_changed"));
}
-Path::Path() {
+Path3D::Path3D() {
set_curve(Ref<Curve3D>(memnew(Curve3D))); //create one by default
}
//////////////
-void PathFollow::_update_transform() {
+void PathFollow3D::_update_transform() {
if (!path)
return;
@@ -212,7 +212,7 @@ void PathFollow::_update_transform() {
set_transform(t);
}
-void PathFollow::_notification(int p_what) {
+void PathFollow3D::_notification(int p_what) {
switch (p_what) {
@@ -220,7 +220,7 @@ void PathFollow::_notification(int p_what) {
Node *parent = get_parent();
if (parent) {
- path = Object::cast_to<Path>(parent);
+ path = Object::cast_to<Path3D>(parent);
if (path) {
_update_transform();
}
@@ -234,17 +234,17 @@ void PathFollow::_notification(int p_what) {
}
}
-void PathFollow::set_cubic_interpolation(bool p_enable) {
+void PathFollow3D::set_cubic_interpolation(bool p_enable) {
cubic = p_enable;
}
-bool PathFollow::get_cubic_interpolation() const {
+bool PathFollow3D::get_cubic_interpolation() const {
return cubic;
}
-void PathFollow::_validate_property(PropertyInfo &property) const {
+void PathFollow3D::_validate_property(PropertyInfo &property) const {
if (property.name == "offset") {
@@ -256,15 +256,15 @@ void PathFollow::_validate_property(PropertyInfo &property) const {
}
}
-String PathFollow::get_configuration_warning() const {
+String PathFollow3D::get_configuration_warning() const {
if (!is_visible_in_tree() || !is_inside_tree())
return String();
- if (!Object::cast_to<Path>(get_parent())) {
+ if (!Object::cast_to<Path3D>(get_parent())) {
return TTR("PathFollow only works when set as a child of a Path node.");
} else {
- Path *path = Object::cast_to<Path>(get_parent());
+ Path3D *path = Object::cast_to<Path3D>(get_parent());
if (path->get_curve().is_valid() && !path->get_curve()->is_up_vector_enabled() && rotation_mode == ROTATION_ORIENTED) {
return TTR("PathFollow's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its parent Path's Curve resource.");
}
@@ -273,28 +273,28 @@ String PathFollow::get_configuration_warning() const {
return String();
}
-void PathFollow::_bind_methods() {
+void PathFollow3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow::set_offset);
- ClassDB::bind_method(D_METHOD("get_offset"), &PathFollow::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow3D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"), &PathFollow3D::get_offset);
- ClassDB::bind_method(D_METHOD("set_h_offset", "h_offset"), &PathFollow::set_h_offset);
- ClassDB::bind_method(D_METHOD("get_h_offset"), &PathFollow::get_h_offset);
+ ClassDB::bind_method(D_METHOD("set_h_offset", "h_offset"), &PathFollow3D::set_h_offset);
+ ClassDB::bind_method(D_METHOD("get_h_offset"), &PathFollow3D::get_h_offset);
- ClassDB::bind_method(D_METHOD("set_v_offset", "v_offset"), &PathFollow::set_v_offset);
- ClassDB::bind_method(D_METHOD("get_v_offset"), &PathFollow::get_v_offset);
+ ClassDB::bind_method(D_METHOD("set_v_offset", "v_offset"), &PathFollow3D::set_v_offset);
+ ClassDB::bind_method(D_METHOD("get_v_offset"), &PathFollow3D::get_v_offset);
- ClassDB::bind_method(D_METHOD("set_unit_offset", "unit_offset"), &PathFollow::set_unit_offset);
- ClassDB::bind_method(D_METHOD("get_unit_offset"), &PathFollow::get_unit_offset);
+ ClassDB::bind_method(D_METHOD("set_unit_offset", "unit_offset"), &PathFollow3D::set_unit_offset);
+ ClassDB::bind_method(D_METHOD("get_unit_offset"), &PathFollow3D::get_unit_offset);
- ClassDB::bind_method(D_METHOD("set_rotation_mode", "rotation_mode"), &PathFollow::set_rotation_mode);
- ClassDB::bind_method(D_METHOD("get_rotation_mode"), &PathFollow::get_rotation_mode);
+ ClassDB::bind_method(D_METHOD("set_rotation_mode", "rotation_mode"), &PathFollow3D::set_rotation_mode);
+ ClassDB::bind_method(D_METHOD("get_rotation_mode"), &PathFollow3D::get_rotation_mode);
- ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enable"), &PathFollow::set_cubic_interpolation);
- ClassDB::bind_method(D_METHOD("get_cubic_interpolation"), &PathFollow::get_cubic_interpolation);
+ ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enable"), &PathFollow3D::set_cubic_interpolation);
+ ClassDB::bind_method(D_METHOD("get_cubic_interpolation"), &PathFollow3D::get_cubic_interpolation);
- ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow::set_loop);
- ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow::has_loop);
+ ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow3D::set_loop);
+ ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow3D::has_loop);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_lesser,or_greater"), "set_offset", "get_offset");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset");
@@ -311,7 +311,7 @@ void PathFollow::_bind_methods() {
BIND_ENUM_CONSTANT(ROTATION_ORIENTED);
}
-void PathFollow::set_offset(float p_offset) {
+void PathFollow3D::set_offset(float p_offset) {
delta_offset = p_offset - offset;
offset = p_offset;
@@ -337,42 +337,42 @@ void PathFollow::set_offset(float p_offset) {
_change_notify("unit_offset");
}
-void PathFollow::set_h_offset(float p_h_offset) {
+void PathFollow3D::set_h_offset(float p_h_offset) {
h_offset = p_h_offset;
if (path)
_update_transform();
}
-float PathFollow::get_h_offset() const {
+float PathFollow3D::get_h_offset() const {
return h_offset;
}
-void PathFollow::set_v_offset(float p_v_offset) {
+void PathFollow3D::set_v_offset(float p_v_offset) {
v_offset = p_v_offset;
if (path)
_update_transform();
}
-float PathFollow::get_v_offset() const {
+float PathFollow3D::get_v_offset() const {
return v_offset;
}
-float PathFollow::get_offset() const {
+float PathFollow3D::get_offset() const {
return offset;
}
-void PathFollow::set_unit_offset(float p_unit_offset) {
+void PathFollow3D::set_unit_offset(float p_unit_offset) {
if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
set_offset(p_unit_offset * path->get_curve()->get_baked_length());
}
-float PathFollow::get_unit_offset() const {
+float PathFollow3D::get_unit_offset() const {
if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
return get_offset() / path->get_curve()->get_baked_length();
@@ -380,7 +380,7 @@ float PathFollow::get_unit_offset() const {
return 0;
}
-void PathFollow::set_rotation_mode(RotationMode p_rotation_mode) {
+void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) {
rotation_mode = p_rotation_mode;
@@ -388,22 +388,22 @@ void PathFollow::set_rotation_mode(RotationMode p_rotation_mode) {
_update_transform();
}
-PathFollow::RotationMode PathFollow::get_rotation_mode() const {
+PathFollow3D::RotationMode PathFollow3D::get_rotation_mode() const {
return rotation_mode;
}
-void PathFollow::set_loop(bool p_loop) {
+void PathFollow3D::set_loop(bool p_loop) {
loop = p_loop;
}
-bool PathFollow::has_loop() const {
+bool PathFollow3D::has_loop() const {
return loop;
}
-PathFollow::PathFollow() {
+PathFollow3D::PathFollow3D() {
offset = 0;
delta_offset = 0;
diff --git a/scene/3d/path.h b/scene/3d/path_3d.h
index 497913b925..6f0db8c5c2 100644
--- a/scene/3d/path.h
+++ b/scene/3d/path_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path.h */
+/* path_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,12 +31,12 @@
#ifndef PATH_H
#define PATH_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/curve.h"
-class Path : public Spatial {
+class Path3D : public Node3D {
- GDCLASS(Path, Spatial);
+ GDCLASS(Path3D, Node3D);
Ref<Curve3D> curve;
@@ -50,12 +50,12 @@ public:
void set_curve(const Ref<Curve3D> &p_curve);
Ref<Curve3D> get_curve() const;
- Path();
+ Path3D();
};
-class PathFollow : public Spatial {
+class PathFollow3D : public Node3D {
- GDCLASS(PathFollow, Spatial);
+ GDCLASS(PathFollow3D, Node3D);
public:
enum RotationMode {
@@ -68,7 +68,7 @@ public:
};
private:
- Path *path;
+ Path3D *path;
real_t delta_offset; // change in offset since last _update_transform
real_t offset;
real_t h_offset;
@@ -109,9 +109,9 @@ public:
String get_configuration_warning() const;
- PathFollow();
+ PathFollow3D();
};
-VARIANT_ENUM_CAST(PathFollow::RotationMode);
+VARIANT_ENUM_CAST(PathFollow3D::RotationMode);
#endif // PATH_H
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body_3d.cpp
index 2f8dc31cb6..680d6e8594 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_body.cpp */
+/* physics_body_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physics_body.h"
+#include "physics_body_3d.h"
#include "core/core_string_names.h"
#include "core/engine.h"
@@ -36,51 +36,51 @@
#include "core/method_bind_ext.gen.inc"
#include "core/object.h"
#include "core/rid.h"
-#include "scene/3d/collision_shape.h"
+#include "scene/3d/collision_shape_3d.h"
#include "scene/scene_string_names.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#ifdef TOOLS_ENABLED
-#include "editor/plugins/spatial_editor_plugin.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
#endif
-Vector3 PhysicsBody::get_linear_velocity() const {
+Vector3 PhysicsBody3D::get_linear_velocity() const {
return Vector3();
}
-Vector3 PhysicsBody::get_angular_velocity() const {
+Vector3 PhysicsBody3D::get_angular_velocity() const {
return Vector3();
}
-float PhysicsBody::get_inverse_mass() const {
+float PhysicsBody3D::get_inverse_mass() const {
return 0;
}
-void PhysicsBody::set_collision_layer(uint32_t p_layer) {
+void PhysicsBody3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
}
-uint32_t PhysicsBody::get_collision_layer() const {
+uint32_t PhysicsBody3D::get_collision_layer() const {
return collision_layer;
}
-void PhysicsBody::set_collision_mask(uint32_t p_mask) {
+void PhysicsBody3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
}
-uint32_t PhysicsBody::get_collision_mask() const {
+uint32_t PhysicsBody3D::get_collision_mask() const {
return collision_mask;
}
-void PhysicsBody::set_collision_mask_bit(int p_bit, bool p_value) {
+void PhysicsBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
@@ -90,12 +90,12 @@ void PhysicsBody::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool PhysicsBody::get_collision_mask_bit(int p_bit) const {
+bool PhysicsBody3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-void PhysicsBody::set_collision_layer_bit(int p_bit, bool p_value) {
+void PhysicsBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_layer();
if (p_value)
@@ -105,155 +105,155 @@ void PhysicsBody::set_collision_layer_bit(int p_bit, bool p_value) {
set_collision_layer(mask);
}
-bool PhysicsBody::get_collision_layer_bit(int p_bit) const {
+bool PhysicsBody3D::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
-Array PhysicsBody::get_collision_exceptions() {
+Array PhysicsBody3D::get_collision_exceptions() {
List<RID> exceptions;
- PhysicsServer::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions);
+ PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions);
Array ret;
for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) {
RID body = E->get();
- ObjectID instance_id = PhysicsServer::get_singleton()->body_get_object_instance_id(body);
+ ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body);
Object *obj = ObjectDB::get_instance(instance_id);
- PhysicsBody *physics_body = Object::cast_to<PhysicsBody>(obj);
+ PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj);
ret.append(physics_body);
}
return ret;
}
-void PhysicsBody::add_collision_exception_with(Node *p_node) {
+void PhysicsBody3D::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- CollisionObject *collision_object = Object::cast_to<CollisionObject>(p_node);
+ CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject.");
- PhysicsServer::get_singleton()->body_add_collision_exception(get_rid(), collision_object->get_rid());
+ PhysicsServer3D::get_singleton()->body_add_collision_exception(get_rid(), collision_object->get_rid());
}
-void PhysicsBody::remove_collision_exception_with(Node *p_node) {
+void PhysicsBody3D::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- CollisionObject *collision_object = Object::cast_to<CollisionObject>(p_node);
+ CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject.");
- PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid());
+ PhysicsServer3D::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid());
}
-void PhysicsBody::_set_layers(uint32_t p_mask) {
+void PhysicsBody3D::_set_layers(uint32_t p_mask) {
set_collision_layer(p_mask);
set_collision_mask(p_mask);
}
-uint32_t PhysicsBody::_get_layers() const {
+uint32_t PhysicsBody3D::_get_layers() const {
return get_collision_layer();
}
-void PhysicsBody::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsBody::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsBody::get_collision_layer);
+void PhysicsBody3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsBody3D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsBody3D::get_collision_layer);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsBody::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsBody::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsBody3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsBody3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &PhysicsBody::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &PhysicsBody::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &PhysicsBody3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &PhysicsBody3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &PhysicsBody::set_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &PhysicsBody::get_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &PhysicsBody3D::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &PhysicsBody3D::get_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("_set_layers", "mask"), &PhysicsBody::_set_layers);
- ClassDB::bind_method(D_METHOD("_get_layers"), &PhysicsBody::_get_layers);
+ ClassDB::bind_method(D_METHOD("_set_layers", "mask"), &PhysicsBody3D::_set_layers);
+ ClassDB::bind_method(D_METHOD("_get_layers"), &PhysicsBody3D::_get_layers);
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
}
-PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) :
- CollisionObject(PhysicsServer::get_singleton()->body_create(p_mode), false) {
+PhysicsBody3D::PhysicsBody3D(PhysicsServer3D::BodyMode p_mode) :
+ CollisionObject3D(PhysicsServer3D::get_singleton()->body_create(p_mode), false) {
collision_layer = 1;
collision_mask = 1;
}
-void StaticBody::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
+void StaticBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) {
- if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &StaticBody::_reload_physics_characteristics))) {
- physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &StaticBody::_reload_physics_characteristics));
+ if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &StaticBody3D::_reload_physics_characteristics))) {
+ physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &StaticBody3D::_reload_physics_characteristics));
}
}
physics_material_override = p_physics_material_override;
if (physics_material_override.is_valid()) {
- physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &StaticBody::_reload_physics_characteristics));
+ physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &StaticBody3D::_reload_physics_characteristics));
}
_reload_physics_characteristics();
}
-Ref<PhysicsMaterial> StaticBody::get_physics_material_override() const {
+Ref<PhysicsMaterial> StaticBody3D::get_physics_material_override() const {
return physics_material_override;
}
-void StaticBody::set_constant_linear_velocity(const Vector3 &p_vel) {
+void StaticBody3D::set_constant_linear_velocity(const Vector3 &p_vel) {
constant_linear_velocity = p_vel;
- PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
-void StaticBody::set_constant_angular_velocity(const Vector3 &p_vel) {
+void StaticBody3D::set_constant_angular_velocity(const Vector3 &p_vel) {
constant_angular_velocity = p_vel;
- PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
-Vector3 StaticBody::get_constant_linear_velocity() const {
+Vector3 StaticBody3D::get_constant_linear_velocity() const {
return constant_linear_velocity;
}
-Vector3 StaticBody::get_constant_angular_velocity() const {
+Vector3 StaticBody3D::get_constant_angular_velocity() const {
return constant_angular_velocity;
}
-void StaticBody::_bind_methods() {
+void StaticBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody::set_constant_linear_velocity);
- ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "vel"), &StaticBody::set_constant_angular_velocity);
- ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody::get_constant_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"), &StaticBody::get_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody3D::set_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "vel"), &StaticBody3D::set_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody3D::get_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"), &StaticBody3D::get_constant_angular_velocity);
- ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody::set_physics_material_override);
- ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody::get_physics_material_override);
+ ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody3D::set_physics_material_override);
+ ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody3D::get_physics_material_override);
- ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &PhysicsBody::get_collision_exceptions);
- ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody::add_collision_exception_with);
- ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody::remove_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &PhysicsBody3D::get_collision_exceptions);
+ ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody3D::add_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody3D::remove_collision_exception_with);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity");
}
-StaticBody::StaticBody() :
- PhysicsBody(PhysicsServer::BODY_MODE_STATIC) {
+StaticBody3D::StaticBody3D() :
+ PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC) {
}
-StaticBody::~StaticBody() {}
+StaticBody3D::~StaticBody3D() {}
-void StaticBody::_reload_physics_characteristics() {
+void StaticBody3D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, 0);
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, 1);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1);
} else {
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
-void RigidBody::_body_enter_tree(ObjectID p_id) {
+void RigidBody3D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
@@ -278,7 +278,7 @@ void RigidBody::_body_enter_tree(ObjectID p_id) {
contact_monitor->locked = false;
}
-void RigidBody::_body_exit_tree(ObjectID p_id) {
+void RigidBody3D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
@@ -301,7 +301,7 @@ void RigidBody::_body_exit_tree(ObjectID p_id) {
contact_monitor->locked = false;
}
-void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
+void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
bool body_in = p_status == 1;
ObjectID objid = p_instance;
@@ -321,8 +321,8 @@ 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()->tree_entered, callable_mp(this, &RigidBody::_body_enter_tree), make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody::_body_exit_tree), make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree), make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree), make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@@ -348,8 +348,8 @@ 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()->tree_entered, callable_mp(this, &RigidBody::_body_enter_tree));
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody::_body_exit_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
if (in_tree)
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
}
@@ -369,12 +369,12 @@ struct _RigidBodyInOut {
int local_shape;
};
-void RigidBody::_direct_state_changed(Object *p_state) {
+void RigidBody3D::_direct_state_changed(Object *p_state) {
#ifdef DEBUG_ENABLED
- state = Object::cast_to<PhysicsDirectBodyState>(p_state);
+ state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
#else
- state = (PhysicsDirectBodyState *)p_state; //trust it
+ state = (PhysicsDirectBodyState3D *)p_state; //trust it
#endif
set_ignore_transform_notification(true);
@@ -477,7 +477,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
state = NULL;
}
-void RigidBody::_notification(int p_what) {
+void RigidBody3D::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -495,111 +495,111 @@ void RigidBody::_notification(int p_what) {
#endif
}
-void RigidBody::set_mode(Mode p_mode) {
+void RigidBody3D::set_mode(Mode p_mode) {
mode = p_mode;
switch (p_mode) {
case MODE_RIGID: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_RIGID);
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_RIGID);
} break;
case MODE_STATIC: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_STATIC);
} break;
case MODE_CHARACTER: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_CHARACTER);
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_CHARACTER);
} break;
case MODE_KINEMATIC: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_KINEMATIC);
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_KINEMATIC);
} break;
}
update_configuration_warning();
}
-RigidBody::Mode RigidBody::get_mode() const {
+RigidBody3D::Mode RigidBody3D::get_mode() const {
return mode;
}
-void RigidBody::set_mass(real_t p_mass) {
+void RigidBody3D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
_change_notify("mass");
_change_notify("weight");
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
}
-real_t RigidBody::get_mass() const {
+real_t RigidBody3D::get_mass() const {
return mass;
}
-void RigidBody::set_weight(real_t p_weight) {
+void RigidBody3D::set_weight(real_t p_weight) {
set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)));
}
-real_t RigidBody::get_weight() const {
+real_t RigidBody3D::get_weight() const {
return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
}
-void RigidBody::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
+void RigidBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) {
- if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody::_reload_physics_characteristics))) {
- physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody::_reload_physics_characteristics));
+ if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody3D::_reload_physics_characteristics))) {
+ physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody3D::_reload_physics_characteristics));
}
}
physics_material_override = p_physics_material_override;
if (physics_material_override.is_valid()) {
- physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody::_reload_physics_characteristics));
+ physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody3D::_reload_physics_characteristics));
}
_reload_physics_characteristics();
}
-Ref<PhysicsMaterial> RigidBody::get_physics_material_override() const {
+Ref<PhysicsMaterial> RigidBody3D::get_physics_material_override() const {
return physics_material_override;
}
-void RigidBody::set_gravity_scale(real_t p_gravity_scale) {
+void RigidBody3D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
-real_t RigidBody::get_gravity_scale() const {
+real_t RigidBody3D::get_gravity_scale() const {
return gravity_scale;
}
-void RigidBody::set_linear_damp(real_t p_linear_damp) {
+void RigidBody3D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < -1);
linear_damp = p_linear_damp;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_LINEAR_DAMP, linear_damp);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
-real_t RigidBody::get_linear_damp() const {
+real_t RigidBody3D::get_linear_damp() const {
return linear_damp;
}
-void RigidBody::set_angular_damp(real_t p_angular_damp) {
+void RigidBody3D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < -1);
angular_damp = p_angular_damp;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_ANGULAR_DAMP, angular_damp);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
-real_t RigidBody::get_angular_damp() const {
+real_t RigidBody3D::get_angular_damp() const {
return angular_damp;
}
-void RigidBody::set_axis_velocity(const Vector3 &p_axis) {
+void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) {
Vector3 v = state ? state->get_linear_velocity() : linear_velocity;
Vector3 axis = p_axis.normalized();
@@ -608,121 +608,121 @@ void RigidBody::set_axis_velocity(const Vector3 &p_axis) {
if (state) {
set_linear_velocity(v);
} else {
- PhysicsServer::get_singleton()->body_set_axis_velocity(get_rid(), p_axis);
+ PhysicsServer3D::get_singleton()->body_set_axis_velocity(get_rid(), p_axis);
linear_velocity = v;
}
}
-void RigidBody::set_linear_velocity(const Vector3 &p_velocity) {
+void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) {
linear_velocity = p_velocity;
if (state)
state->set_linear_velocity(linear_velocity);
else
- PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
-Vector3 RigidBody::get_linear_velocity() const {
+Vector3 RigidBody3D::get_linear_velocity() const {
return linear_velocity;
}
-void RigidBody::set_angular_velocity(const Vector3 &p_velocity) {
+void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) {
angular_velocity = p_velocity;
if (state)
state->set_angular_velocity(angular_velocity);
else
- PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
-Vector3 RigidBody::get_angular_velocity() const {
+Vector3 RigidBody3D::get_angular_velocity() const {
return angular_velocity;
}
-void RigidBody::set_use_custom_integrator(bool p_enable) {
+void RigidBody3D::set_use_custom_integrator(bool p_enable) {
if (custom_integrator == p_enable)
return;
custom_integrator = p_enable;
- PhysicsServer::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
+ PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
}
-bool RigidBody::is_using_custom_integrator() {
+bool RigidBody3D::is_using_custom_integrator() {
return custom_integrator;
}
-void RigidBody::set_sleeping(bool p_sleeping) {
+void RigidBody3D::set_sleeping(bool p_sleeping) {
sleeping = p_sleeping;
- PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_SLEEPING, sleeping);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping);
}
-void RigidBody::set_can_sleep(bool p_active) {
+void RigidBody3D::set_can_sleep(bool p_active) {
can_sleep = p_active;
- PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_CAN_SLEEP, p_active);
+ PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active);
}
-bool RigidBody::is_able_to_sleep() const {
+bool RigidBody3D::is_able_to_sleep() const {
return can_sleep;
}
-bool RigidBody::is_sleeping() const {
+bool RigidBody3D::is_sleeping() const {
return sleeping;
}
-void RigidBody::set_max_contacts_reported(int p_amount) {
+void RigidBody3D::set_max_contacts_reported(int p_amount) {
max_contacts_reported = p_amount;
- PhysicsServer::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
+ PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
-int RigidBody::get_max_contacts_reported() const {
+int RigidBody3D::get_max_contacts_reported() const {
return max_contacts_reported;
}
-void RigidBody::add_central_force(const Vector3 &p_force) {
- PhysicsServer::get_singleton()->body_add_central_force(get_rid(), p_force);
+void RigidBody3D::add_central_force(const Vector3 &p_force) {
+ PhysicsServer3D::get_singleton()->body_add_central_force(get_rid(), p_force);
}
-void RigidBody::add_force(const Vector3 &p_force, const Vector3 &p_pos) {
- PhysicsServer::get_singleton()->body_add_force(get_rid(), p_force, p_pos);
+void RigidBody3D::add_force(const Vector3 &p_force, const Vector3 &p_pos) {
+ PhysicsServer3D::get_singleton()->body_add_force(get_rid(), p_force, p_pos);
}
-void RigidBody::add_torque(const Vector3 &p_torque) {
- PhysicsServer::get_singleton()->body_add_torque(get_rid(), p_torque);
+void RigidBody3D::add_torque(const Vector3 &p_torque) {
+ PhysicsServer3D::get_singleton()->body_add_torque(get_rid(), p_torque);
}
-void RigidBody::apply_central_impulse(const Vector3 &p_impulse) {
- PhysicsServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
+void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) {
+ PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
}
-void RigidBody::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
+void RigidBody3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
- PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
+ PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
}
-void RigidBody::apply_torque_impulse(const Vector3 &p_impulse) {
- PhysicsServer::get_singleton()->body_apply_torque_impulse(get_rid(), p_impulse);
+void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) {
+ PhysicsServer3D::get_singleton()->body_apply_torque_impulse(get_rid(), p_impulse);
}
-void RigidBody::set_use_continuous_collision_detection(bool p_enable) {
+void RigidBody3D::set_use_continuous_collision_detection(bool p_enable) {
ccd = p_enable;
- PhysicsServer::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable);
+ PhysicsServer3D::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable);
}
-bool RigidBody::is_using_continuous_collision_detection() const {
+bool RigidBody3D::is_using_continuous_collision_detection() const {
return ccd;
}
-void RigidBody::set_contact_monitor(bool p_enabled) {
+void RigidBody3D::set_contact_monitor(bool p_enabled) {
if (p_enabled == is_contact_monitor_enabled())
return;
@@ -738,8 +738,8 @@ void RigidBody::set_contact_monitor(bool p_enabled) {
Node *node = Object::cast_to<Node>(obj);
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody::_body_enter_tree));
- node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody::_body_exit_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
}
}
@@ -752,20 +752,20 @@ void RigidBody::set_contact_monitor(bool p_enabled) {
}
}
-bool RigidBody::is_contact_monitor_enabled() const {
+bool RigidBody3D::is_contact_monitor_enabled() const {
return contact_monitor != NULL;
}
-void RigidBody::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock) {
- PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
+void RigidBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) {
+ PhysicsServer3D::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
}
-bool RigidBody::get_axis_lock(PhysicsServer::BodyAxis p_axis) const {
- return PhysicsServer::get_singleton()->body_is_axis_locked(get_rid(), p_axis);
+bool RigidBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
+ return PhysicsServer3D::get_singleton()->body_is_axis_locked(get_rid(), p_axis);
}
-Array RigidBody::get_colliding_bodies() const {
+Array RigidBody3D::get_colliding_bodies() const {
ERR_FAIL_COND_V(!contact_monitor, Array());
@@ -784,11 +784,11 @@ Array RigidBody::get_colliding_bodies() const {
return ret;
}
-String RigidBody::get_configuration_warning() const {
+String RigidBody3D::get_configuration_warning() const {
Transform t = get_transform();
- String warning = CollisionObject::get_configuration_warning();
+ String warning = CollisionObject3D::get_configuration_warning();
if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) {
if (warning != String()) {
@@ -800,69 +800,69 @@ String RigidBody::get_configuration_warning() const {
return warning;
}
-void RigidBody::_bind_methods() {
+void RigidBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &RigidBody::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody3D::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"), &RigidBody3D::get_mode);
- ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidBody::set_mass);
- ClassDB::bind_method(D_METHOD("get_mass"), &RigidBody::get_mass);
+ ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidBody3D::set_mass);
+ ClassDB::bind_method(D_METHOD("get_mass"), &RigidBody3D::get_mass);
- ClassDB::bind_method(D_METHOD("set_weight", "weight"), &RigidBody::set_weight);
- ClassDB::bind_method(D_METHOD("get_weight"), &RigidBody::get_weight);
+ ClassDB::bind_method(D_METHOD("set_weight", "weight"), &RigidBody3D::set_weight);
+ ClassDB::bind_method(D_METHOD("get_weight"), &RigidBody3D::get_weight);
- ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody::set_physics_material_override);
- ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody::get_physics_material_override);
+ ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody3D::set_physics_material_override);
+ ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody3D::get_physics_material_override);
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &RigidBody::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &RigidBody::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &RigidBody3D::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"), &RigidBody3D::get_linear_velocity);
- ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidBody::set_angular_velocity);
- ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidBody::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidBody3D::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidBody3D::get_angular_velocity);
- ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidBody::set_gravity_scale);
- ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidBody::get_gravity_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidBody3D::set_gravity_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidBody3D::get_gravity_scale);
- ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &RigidBody::set_linear_damp);
- ClassDB::bind_method(D_METHOD("get_linear_damp"), &RigidBody::get_linear_damp);
+ ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &RigidBody3D::set_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_linear_damp"), &RigidBody3D::get_linear_damp);
- ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &RigidBody::set_angular_damp);
- ClassDB::bind_method(D_METHOD("get_angular_damp"), &RigidBody::get_angular_damp);
+ ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &RigidBody3D::set_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_angular_damp"), &RigidBody3D::get_angular_damp);
- ClassDB::bind_method(D_METHOD("set_max_contacts_reported", "amount"), &RigidBody::set_max_contacts_reported);
- ClassDB::bind_method(D_METHOD("get_max_contacts_reported"), &RigidBody::get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("set_max_contacts_reported", "amount"), &RigidBody3D::set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("get_max_contacts_reported"), &RigidBody3D::get_max_contacts_reported);
- ClassDB::bind_method(D_METHOD("set_use_custom_integrator", "enable"), &RigidBody::set_use_custom_integrator);
- ClassDB::bind_method(D_METHOD("is_using_custom_integrator"), &RigidBody::is_using_custom_integrator);
+ ClassDB::bind_method(D_METHOD("set_use_custom_integrator", "enable"), &RigidBody3D::set_use_custom_integrator);
+ ClassDB::bind_method(D_METHOD("is_using_custom_integrator"), &RigidBody3D::is_using_custom_integrator);
- ClassDB::bind_method(D_METHOD("set_contact_monitor", "enabled"), &RigidBody::set_contact_monitor);
- ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"), &RigidBody::is_contact_monitor_enabled);
+ ClassDB::bind_method(D_METHOD("set_contact_monitor", "enabled"), &RigidBody3D::set_contact_monitor);
+ ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"), &RigidBody3D::is_contact_monitor_enabled);
- ClassDB::bind_method(D_METHOD("set_use_continuous_collision_detection", "enable"), &RigidBody::set_use_continuous_collision_detection);
- ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"), &RigidBody::is_using_continuous_collision_detection);
+ ClassDB::bind_method(D_METHOD("set_use_continuous_collision_detection", "enable"), &RigidBody3D::set_use_continuous_collision_detection);
+ ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"), &RigidBody3D::is_using_continuous_collision_detection);
- ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody::set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody3D::set_axis_velocity);
- ClassDB::bind_method(D_METHOD("add_central_force", "force"), &RigidBody::add_central_force);
- ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody::add_force);
- ClassDB::bind_method(D_METHOD("add_torque", "torque"), &RigidBody::add_torque);
+ ClassDB::bind_method(D_METHOD("add_central_force", "force"), &RigidBody3D::add_central_force);
+ ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody3D::add_force);
+ ClassDB::bind_method(D_METHOD("add_torque", "torque"), &RigidBody3D::add_torque);
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &RigidBody::apply_impulse);
- ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidBody::apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody3D::apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &RigidBody3D::apply_impulse);
+ ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidBody3D::apply_torque_impulse);
- ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody::set_sleeping);
- ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidBody::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody3D::set_sleeping);
+ ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidBody3D::is_sleeping);
- ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidBody::set_can_sleep);
- ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidBody::is_able_to_sleep);
+ ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidBody3D::set_can_sleep);
+ ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidBody3D::is_able_to_sleep);
- ClassDB::bind_method(D_METHOD("_direct_state_changed"), &RigidBody::_direct_state_changed);
+ ClassDB::bind_method(D_METHOD("_direct_state_changed"), &RigidBody3D::_direct_state_changed);
- ClassDB::bind_method(D_METHOD("set_axis_lock", "axis", "lock"), &RigidBody::set_axis_lock);
- ClassDB::bind_method(D_METHOD("get_axis_lock", "axis"), &RigidBody::get_axis_lock);
+ ClassDB::bind_method(D_METHOD("set_axis_lock", "axis", "lock"), &RigidBody3D::set_axis_lock);
+ ClassDB::bind_method(D_METHOD("get_axis_lock", "axis"), &RigidBody3D::get_axis_lock);
- ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody::get_colliding_bodies);
+ ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody3D::get_colliding_bodies);
BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectBodyState")));
@@ -878,12 +878,12 @@ void RigidBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleeping", "is_sleeping");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), "set_can_sleep", "is_able_to_sleep");
ADD_GROUP("Axis Lock", "axis_lock_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_x"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_X);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_y"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_z"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Z);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_x"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_X);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_y"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_Z);
ADD_GROUP("Linear", "linear_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp");
@@ -903,8 +903,8 @@ void RigidBody::_bind_methods() {
BIND_ENUM_CONSTANT(MODE_KINEMATIC);
}
-RigidBody::RigidBody() :
- PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
+RigidBody3D::RigidBody3D() :
+ PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) {
mode = MODE_RIGID;
@@ -924,29 +924,29 @@ RigidBody::RigidBody() :
contact_monitor = NULL;
can_sleep = true;
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
}
-RigidBody::~RigidBody() {
+RigidBody3D::~RigidBody3D() {
if (contact_monitor)
memdelete(contact_monitor);
}
-void RigidBody::_reload_physics_characteristics() {
+void RigidBody3D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) {
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, 0);
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, 1);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1);
} else {
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce());
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, physics_material_override->computed_friction());
}
}
//////////////////////////////////////////////////////
//////////////////////////
-Ref<KinematicCollision> KinematicBody::_move(const Vector3 &p_motion, bool p_infinite_inertia, bool p_exclude_raycast_shapes, bool p_test_only) {
+Ref<KinematicCollision3D> KinematicBody3D::_move(const Vector3 &p_motion, bool p_infinite_inertia, bool p_exclude_raycast_shapes, bool p_test_only) {
Collision col;
if (move_and_collide(p_motion, p_infinite_inertia, col, p_exclude_raycast_shapes, p_test_only)) {
@@ -960,22 +960,22 @@ Ref<KinematicCollision> KinematicBody::_move(const Vector3 &p_motion, bool p_inf
return motion_cache;
}
- return Ref<KinematicCollision>();
+ return Ref<KinematicCollision3D>();
}
-Vector3 KinematicBody::get_linear_velocity() const {
+Vector3 KinematicBody3D::get_linear_velocity() const {
return linear_velocity;
}
-Vector3 KinematicBody::get_angular_velocity() const {
+Vector3 KinematicBody3D::get_angular_velocity() const {
return angular_velocity;
}
-bool KinematicBody::move_and_collide(const Vector3 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) {
+bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) {
Transform gt = get_global_transform();
- PhysicsServer::MotionResult result;
- bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, &result, p_exclude_raycast_shapes);
+ PhysicsServer3D::MotionResult result;
+ bool colliding = PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, &result, p_exclude_raycast_shapes);
if (colliding) {
r_collision.collider_metadata = result.collider_metadata;
@@ -1007,7 +1007,7 @@ bool KinematicBody::move_and_collide(const Vector3 &p_motion, bool p_infinite_in
//so, if you pass 45 as limit, avoid numerical precision errors when angle is 45.
#define FLOOR_ANGLE_THRESHOLD 0.01
-Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
Vector3 body_velocity = p_linear_velocity;
Vector3 body_velocity_normal = body_velocity.normalized();
@@ -1101,7 +1101,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
return body_velocity;
}
-Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
+Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
bool was_on_floor = on_floor;
@@ -1140,45 +1140,45 @@ Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity
return ret;
}
-bool KinematicBody::is_on_floor() const {
+bool KinematicBody3D::is_on_floor() const {
return on_floor;
}
-bool KinematicBody::is_on_wall() const {
+bool KinematicBody3D::is_on_wall() const {
return on_wall;
}
-bool KinematicBody::is_on_ceiling() const {
+bool KinematicBody3D::is_on_ceiling() const {
return on_ceiling;
}
-Vector3 KinematicBody::get_floor_normal() const {
+Vector3 KinematicBody3D::get_floor_normal() const {
return floor_normal;
}
-Vector3 KinematicBody::get_floor_velocity() const {
+Vector3 KinematicBody3D::get_floor_velocity() const {
return floor_velocity;
}
-bool KinematicBody::test_move(const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia) {
+bool KinematicBody3D::test_move(const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia) {
ERR_FAIL_COND_V(!is_inside_tree(), false);
- return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia);
+ return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia);
}
-bool KinematicBody::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) {
+bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) {
- PhysicsServer::SeparationResult sep_res[8]; //max 8 rays
+ PhysicsServer3D::SeparationResult sep_res[8]; //max 8 rays
Transform gt = get_global_transform();
Vector3 recover;
- int hits = PhysicsServer::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
+ int hits = PhysicsServer3D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
int deepest = -1;
float deepest_depth;
for (int i = 0; i < hits; i++) {
@@ -1208,37 +1208,37 @@ bool KinematicBody::separate_raycast_shapes(bool p_infinite_inertia, Collision &
}
}
-void KinematicBody::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock) {
- PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
+void KinematicBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) {
+ PhysicsServer3D::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
}
-bool KinematicBody::get_axis_lock(PhysicsServer::BodyAxis p_axis) const {
- return PhysicsServer::get_singleton()->body_is_axis_locked(get_rid(), p_axis);
+bool KinematicBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
+ return PhysicsServer3D::get_singleton()->body_is_axis_locked(get_rid(), p_axis);
}
-void KinematicBody::set_safe_margin(float p_margin) {
+void KinematicBody3D::set_safe_margin(float p_margin) {
margin = p_margin;
- PhysicsServer::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin);
+ PhysicsServer3D::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin);
}
-float KinematicBody::get_safe_margin() const {
+float KinematicBody3D::get_safe_margin() const {
return margin;
}
-int KinematicBody::get_slide_count() const {
+int KinematicBody3D::get_slide_count() const {
return colliders.size();
}
-KinematicBody::Collision KinematicBody::get_slide_collision(int p_bounce) const {
+KinematicBody3D::Collision KinematicBody3D::get_slide_collision(int p_bounce) const {
ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Collision());
return colliders[p_bounce];
}
-Ref<KinematicCollision> KinematicBody::_get_slide_collision(int p_bounce) {
+Ref<KinematicCollision3D> KinematicBody3D::_get_slide_collision(int p_bounce) {
- ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision>());
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision3D>());
if (p_bounce >= slide_colliders.size()) {
slide_colliders.resize(p_bounce + 1);
}
@@ -1252,7 +1252,7 @@ Ref<KinematicCollision> KinematicBody::_get_slide_collision(int p_bounce) {
return slide_colliders[p_bounce];
}
-void KinematicBody::_notification(int p_what) {
+void KinematicBody3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
// Reset move_and_slide() data.
on_floor = false;
@@ -1264,51 +1264,51 @@ void KinematicBody::_notification(int p_what) {
}
}
-void KinematicBody::_bind_methods() {
+void KinematicBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_direct_state_changed"), &KinematicBody::_direct_state_changed);
+ ClassDB::bind_method(D_METHOD("_direct_state_changed"), &KinematicBody3D::_direct_state_changed);
- ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody3D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody3D::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody3D::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody::test_move, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody3D::test_move, DEFVAL(true));
- ClassDB::bind_method(D_METHOD("is_on_floor"), &KinematicBody::is_on_floor);
- ClassDB::bind_method(D_METHOD("is_on_ceiling"), &KinematicBody::is_on_ceiling);
- ClassDB::bind_method(D_METHOD("is_on_wall"), &KinematicBody::is_on_wall);
- ClassDB::bind_method(D_METHOD("get_floor_normal"), &KinematicBody::get_floor_normal);
- ClassDB::bind_method(D_METHOD("get_floor_velocity"), &KinematicBody::get_floor_velocity);
+ ClassDB::bind_method(D_METHOD("is_on_floor"), &KinematicBody3D::is_on_floor);
+ ClassDB::bind_method(D_METHOD("is_on_ceiling"), &KinematicBody3D::is_on_ceiling);
+ ClassDB::bind_method(D_METHOD("is_on_wall"), &KinematicBody3D::is_on_wall);
+ ClassDB::bind_method(D_METHOD("get_floor_normal"), &KinematicBody3D::get_floor_normal);
+ ClassDB::bind_method(D_METHOD("get_floor_velocity"), &KinematicBody3D::get_floor_velocity);
- ClassDB::bind_method(D_METHOD("set_axis_lock", "axis", "lock"), &KinematicBody::set_axis_lock);
- ClassDB::bind_method(D_METHOD("get_axis_lock", "axis"), &KinematicBody::get_axis_lock);
+ ClassDB::bind_method(D_METHOD("set_axis_lock", "axis", "lock"), &KinematicBody3D::set_axis_lock);
+ ClassDB::bind_method(D_METHOD("get_axis_lock", "axis"), &KinematicBody3D::get_axis_lock);
- ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody::set_safe_margin);
- ClassDB::bind_method(D_METHOD("get_safe_margin"), &KinematicBody::get_safe_margin);
+ ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody3D::set_safe_margin);
+ ClassDB::bind_method(D_METHOD("get_safe_margin"), &KinematicBody3D::get_safe_margin);
- ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody::get_slide_count);
- ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody::_get_slide_collision);
+ ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody3D::get_slide_count);
+ ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody3D::_get_slide_collision);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_x", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_X);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_y", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_z", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_x", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_y", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_z", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
}
-void KinematicBody::_direct_state_changed(Object *p_state) {
+void KinematicBody3D::_direct_state_changed(Object *p_state) {
#ifdef DEBUG_ENABLED
- PhysicsDirectBodyState *state = Object::cast_to<PhysicsDirectBodyState>(p_state);
+ PhysicsDirectBodyState3D *state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
#else
- PhysicsDirectBodyState *state = (PhysicsDirectBodyState *)p_state; //trust it
+ PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state; //trust it
#endif
linear_velocity = state->get_linear_velocity();
angular_velocity = state->get_angular_velocity();
}
-KinematicBody::KinematicBody() :
- PhysicsBody(PhysicsServer::BODY_MODE_KINEMATIC) {
+KinematicBody3D::KinematicBody3D() :
+ PhysicsBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) {
margin = 0.001;
locked_axis = 0;
@@ -1316,9 +1316,9 @@ KinematicBody::KinematicBody() :
on_ceiling = false;
on_wall = false;
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
}
-KinematicBody::~KinematicBody() {
+KinematicBody3D::~KinematicBody3D() {
if (motion_cache.is_valid()) {
motion_cache->owner = NULL;
@@ -1332,26 +1332,26 @@ KinematicBody::~KinematicBody() {
}
///////////////////////////////////////
-Vector3 KinematicCollision::get_position() const {
+Vector3 KinematicCollision3D::get_position() const {
return collision.collision;
}
-Vector3 KinematicCollision::get_normal() const {
+Vector3 KinematicCollision3D::get_normal() const {
return collision.normal;
}
-Vector3 KinematicCollision::get_travel() const {
+Vector3 KinematicCollision3D::get_travel() const {
return collision.travel;
}
-Vector3 KinematicCollision::get_remainder() const {
+Vector3 KinematicCollision3D::get_remainder() const {
return collision.remainder;
}
-Object *KinematicCollision::get_local_shape() const {
+Object *KinematicCollision3D::get_local_shape() const {
if (!owner) return NULL;
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
-Object *KinematicCollision::get_collider() const {
+Object *KinematicCollision3D::get_collider() const {
if (collision.collider.is_valid()) {
return ObjectDB::get_instance(collision.collider);
@@ -1359,15 +1359,15 @@ Object *KinematicCollision::get_collider() const {
return NULL;
}
-ObjectID KinematicCollision::get_collider_id() const {
+ObjectID KinematicCollision3D::get_collider_id() const {
return collision.collider;
}
-Object *KinematicCollision::get_collider_shape() const {
+Object *KinematicCollision3D::get_collider_shape() const {
Object *collider = get_collider();
if (collider) {
- CollisionObject *obj2d = Object::cast_to<CollisionObject>(collider);
+ CollisionObject3D *obj2d = Object::cast_to<CollisionObject3D>(collider);
if (obj2d) {
uint32_t ownerid = obj2d->shape_find_owner(collision.collider_shape);
return obj2d->shape_owner_get_owner(ownerid);
@@ -1376,32 +1376,32 @@ Object *KinematicCollision::get_collider_shape() const {
return NULL;
}
-int KinematicCollision::get_collider_shape_index() const {
+int KinematicCollision3D::get_collider_shape_index() const {
return collision.collider_shape;
}
-Vector3 KinematicCollision::get_collider_velocity() const {
+Vector3 KinematicCollision3D::get_collider_velocity() const {
return collision.collider_vel;
}
-Variant KinematicCollision::get_collider_metadata() const {
+Variant KinematicCollision3D::get_collider_metadata() const {
return Variant();
}
-void KinematicCollision::_bind_methods() {
+void KinematicCollision3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision::get_position);
- ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision::get_normal);
- ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision::get_travel);
- ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision::get_remainder);
- ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision::get_local_shape);
- ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision::get_collider);
- ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision::get_collider_id);
- ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision::get_collider_shape);
- ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision::get_collider_shape_index);
- ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision::get_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collider_metadata"), &KinematicCollision::get_collider_metadata);
+ ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision3D::get_position);
+ ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision3D::get_normal);
+ ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision3D::get_travel);
+ ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision3D::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision3D::get_local_shape);
+ ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision3D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision3D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision3D::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision3D::get_collider_shape_index);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision3D::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_metadata"), &KinematicCollision3D::get_collider_metadata);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "", "get_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "normal"), "", "get_normal");
@@ -1416,7 +1416,7 @@ void KinematicCollision::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::NIL, "collider_metadata", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "", "get_collider_metadata");
}
-KinematicCollision::KinematicCollision() {
+KinematicCollision3D::KinematicCollision3D() {
collision.collider_shape = 0;
collision.local_shape = 0;
@@ -1425,26 +1425,26 @@ KinematicCollision::KinematicCollision() {
///////////////////////////////////////
-bool PhysicalBone::JointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
+bool PhysicalBone3D::JointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
return false;
}
-bool PhysicalBone::JointData::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::JointData::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void PhysicalBone::JointData::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::JointData::_get_property_list(List<PropertyInfo> *p_list) const {
}
-void PhysicalBone::apply_central_impulse(const Vector3 &p_impulse) {
- PhysicsServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
+void PhysicalBone3D::apply_central_impulse(const Vector3 &p_impulse) {
+ PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
}
-void PhysicalBone::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
- PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
+void PhysicalBone3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
+ PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
}
-void PhysicalBone::reset_physics_simulation_state() {
+void PhysicalBone3D::reset_physics_simulation_state() {
if (simulate_physics) {
_start_physics_simulation();
} else {
@@ -1452,7 +1452,7 @@ void PhysicalBone::reset_physics_simulation_state() {
}
}
-void PhysicalBone::reset_to_rest_position() {
+void PhysicalBone3D::reset_to_rest_position() {
if (parent_skeleton) {
if (-1 == bone_id) {
set_global_transform(parent_skeleton->get_global_transform() * body_offset);
@@ -1462,7 +1462,7 @@ void PhysicalBone::reset_to_rest_position() {
}
}
-bool PhysicalBone::PinJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
+bool PhysicalBone3D::PinJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
if (JointData::_set(p_name, p_value, j)) {
return true;
}
@@ -1470,17 +1470,17 @@ bool PhysicalBone::PinJointData::_set(const StringName &p_name, const Variant &p
if ("joint_constraints/bias" == p_name) {
bias = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PIN_JOINT_BIAS, bias);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_BIAS, bias);
} else if ("joint_constraints/damping" == p_name) {
damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PIN_JOINT_DAMPING, damping);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_DAMPING, damping);
} else if ("joint_constraints/impulse_clamp" == p_name) {
impulse_clamp = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
} else {
return false;
@@ -1489,7 +1489,7 @@ bool PhysicalBone::PinJointData::_set(const StringName &p_name, const Variant &p
return true;
}
-bool PhysicalBone::PinJointData::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::PinJointData::_get(const StringName &p_name, Variant &r_ret) const {
if (JointData::_get(p_name, r_ret)) {
return true;
}
@@ -1507,7 +1507,7 @@ bool PhysicalBone::PinJointData::_get(const StringName &p_name, Variant &r_ret)
return true;
}
-void PhysicalBone::PinJointData::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::PinJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"));
@@ -1515,7 +1515,7 @@ void PhysicalBone::PinJointData::_get_property_list(List<PropertyInfo> *p_list)
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/impulse_clamp", PROPERTY_HINT_RANGE, "0.0,64.0,0.01"));
}
-bool PhysicalBone::ConeJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
+bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
if (JointData::_set(p_name, p_value, j)) {
return true;
}
@@ -1523,27 +1523,27 @@ bool PhysicalBone::ConeJointData::_set(const StringName &p_name, const Variant &
if ("joint_constraints/swing_span" == p_name) {
swing_span = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
} else if ("joint_constraints/twist_span" == p_name) {
twist_span = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
} else if ("joint_constraints/bias" == p_name) {
bias = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_BIAS, bias);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, bias);
} else if ("joint_constraints/softness" == p_name) {
softness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_SOFTNESS, softness);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, softness);
} else if ("joint_constraints/relaxation" == p_name) {
relaxation = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_RELAXATION, relaxation);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, relaxation);
} else {
return false;
@@ -1552,7 +1552,7 @@ bool PhysicalBone::ConeJointData::_set(const StringName &p_name, const Variant &
return true;
}
-bool PhysicalBone::ConeJointData::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::ConeJointData::_get(const StringName &p_name, Variant &r_ret) const {
if (JointData::_get(p_name, r_ret)) {
return true;
}
@@ -1574,7 +1574,7 @@ bool PhysicalBone::ConeJointData::_get(const StringName &p_name, Variant &r_ret)
return true;
}
-void PhysicalBone::ConeJointData::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::ConeJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/swing_span", PROPERTY_HINT_RANGE, "-180,180,0.01"));
@@ -1584,7 +1584,7 @@ void PhysicalBone::ConeJointData::_get_property_list(List<PropertyInfo> *p_list)
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/relaxation", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"));
}
-bool PhysicalBone::HingeJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
+bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
if (JointData::_set(p_name, p_value, j)) {
return true;
}
@@ -1592,32 +1592,32 @@ bool PhysicalBone::HingeJointData::_set(const StringName &p_name, const Variant
if ("joint_constraints/angular_limit_enabled" == p_name) {
angular_limit_enabled = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_flag(j, PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
} else if ("joint_constraints/angular_limit_bias" == p_name) {
angular_limit_bias = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
} else if ("joint_constraints/angular_limit_relaxation" == p_name) {
angular_limit_relaxation = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
} else {
return false;
@@ -1626,7 +1626,7 @@ bool PhysicalBone::HingeJointData::_set(const StringName &p_name, const Variant
return true;
}
-bool PhysicalBone::HingeJointData::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::HingeJointData::_get(const StringName &p_name, Variant &r_ret) const {
if (JointData::_get(p_name, r_ret)) {
return true;
}
@@ -1650,7 +1650,7 @@ bool PhysicalBone::HingeJointData::_get(const StringName &p_name, Variant &r_ret
return true;
}
-void PhysicalBone::HingeJointData::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::HingeJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/angular_limit_enabled"));
@@ -1661,7 +1661,7 @@ void PhysicalBone::HingeJointData::_get_property_list(List<PropertyInfo> *p_list
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_relaxation", PROPERTY_HINT_RANGE, "0.01,16,0.01"));
}
-bool PhysicalBone::SliderJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
+bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
if (JointData::_set(p_name, p_value, j)) {
return true;
}
@@ -1669,52 +1669,52 @@ bool PhysicalBone::SliderJointData::_set(const StringName &p_name, const Variant
if ("joint_constraints/linear_limit_upper" == p_name) {
linear_limit_upper = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
} else if ("joint_constraints/linear_limit_lower" == p_name) {
linear_limit_lower = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
} else if ("joint_constraints/linear_limit_softness" == p_name) {
linear_limit_softness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
} else if ("joint_constraints/linear_limit_restitution" == p_name) {
linear_limit_restitution = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
} else if ("joint_constraints/linear_limit_damping" == p_name) {
linear_limit_damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
} else if ("joint_constraints/angular_limit_restitution" == p_name) {
angular_limit_restitution = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
} else if ("joint_constraints/angular_limit_damping" == p_name) {
angular_limit_damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
} else {
return false;
@@ -1723,7 +1723,7 @@ bool PhysicalBone::SliderJointData::_set(const StringName &p_name, const Variant
return true;
}
-bool PhysicalBone::SliderJointData::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::SliderJointData::_get(const StringName &p_name, Variant &r_ret) const {
if (JointData::_get(p_name, r_ret)) {
return true;
}
@@ -1755,7 +1755,7 @@ bool PhysicalBone::SliderJointData::_get(const StringName &p_name, Variant &r_re
return true;
}
-void PhysicalBone::SliderJointData::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::SliderJointData::_get_property_list(List<PropertyInfo> *p_list) const {
JointData::_get_property_list(p_list);
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/linear_limit_upper"));
@@ -1771,7 +1771,7 @@ void PhysicalBone::SliderJointData::_get_property_list(List<PropertyInfo> *p_lis
p_list->push_back(PropertyInfo(Variant::FLOAT, "joint_constraints/angular_limit_damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"));
}
-bool PhysicalBone::SixDOFJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
+bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
if (JointData::_set(p_name, p_value, j)) {
return true;
}
@@ -1797,107 +1797,107 @@ bool PhysicalBone::SixDOFJointData::_set(const StringName &p_name, const Variant
if ("linear_limit_enabled" == var_name) {
axis_data[axis].linear_limit_enabled = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled);
} else if ("linear_limit_upper" == var_name) {
axis_data[axis].linear_limit_upper = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper);
} else if ("linear_limit_lower" == var_name) {
axis_data[axis].linear_limit_lower = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower);
} else if ("linear_limit_softness" == var_name) {
axis_data[axis].linear_limit_softness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness);
} else if ("linear_spring_enabled" == var_name) {
axis_data[axis].linear_spring_enabled = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled);
} else if ("linear_spring_stiffness" == var_name) {
axis_data[axis].linear_spring_stiffness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness);
} else if ("linear_spring_damping" == var_name) {
axis_data[axis].linear_spring_damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping);
} else if ("linear_equilibrium_point" == var_name) {
axis_data[axis].linear_equilibrium_point = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point);
} else if ("linear_restitution" == var_name) {
axis_data[axis].linear_restitution = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution);
} else if ("linear_damping" == var_name) {
axis_data[axis].linear_damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping);
} else if ("angular_limit_enabled" == var_name) {
axis_data[axis].angular_limit_enabled = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled);
} else if ("angular_limit_upper" == var_name) {
axis_data[axis].angular_limit_upper = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper);
} else if ("angular_limit_lower" == var_name) {
axis_data[axis].angular_limit_lower = Math::deg2rad(real_t(p_value));
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower);
} else if ("angular_limit_softness" == var_name) {
axis_data[axis].angular_limit_softness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness);
} else if ("angular_restitution" == var_name) {
axis_data[axis].angular_restitution = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution);
} else if ("angular_damping" == var_name) {
axis_data[axis].angular_damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping);
} else if ("erp" == var_name) {
axis_data[axis].erp = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp);
} else if ("angular_spring_enabled" == var_name) {
axis_data[axis].angular_spring_enabled = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled);
} else if ("angular_spring_stiffness" == var_name) {
axis_data[axis].angular_spring_stiffness = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness);
} else if ("angular_spring_damping" == var_name) {
axis_data[axis].angular_spring_damping = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping);
} else if ("angular_equilibrium_point" == var_name) {
axis_data[axis].angular_equilibrium_point = p_value;
if (j.is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point);
} else {
return false;
@@ -1906,7 +1906,7 @@ bool PhysicalBone::SixDOFJointData::_set(const StringName &p_name, const Variant
return true;
}
-bool PhysicalBone::SixDOFJointData::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::SixDOFJointData::_get(const StringName &p_name, Variant &r_ret) const {
if (JointData::_get(p_name, r_ret)) {
return true;
}
@@ -1978,7 +1978,7 @@ bool PhysicalBone::SixDOFJointData::_get(const StringName &p_name, Variant &r_re
return true;
}
-void PhysicalBone::SixDOFJointData::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::SixDOFJointData::_get_property_list(List<PropertyInfo> *p_list) const {
const StringName axis_names[] = { "x", "y", "z" };
for (int i = 0; i < 3; ++i) {
p_list->push_back(PropertyInfo(Variant::BOOL, "joint_constraints/" + axis_names[i] + "/linear_limit_enabled"));
@@ -2005,7 +2005,7 @@ void PhysicalBone::SixDOFJointData::_get_property_list(List<PropertyInfo> *p_lis
}
}
-bool PhysicalBone::_set(const StringName &p_name, const Variant &p_value) {
+bool PhysicalBone3D::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "bone_name") {
set_bone_name(p_value);
return true;
@@ -2024,7 +2024,7 @@ bool PhysicalBone::_set(const StringName &p_name, const Variant &p_value) {
return false;
}
-bool PhysicalBone::_get(const StringName &p_name, Variant &r_ret) const {
+bool PhysicalBone3D::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "bone_name") {
r_ret = get_bone_name();
return true;
@@ -2037,9 +2037,9 @@ bool PhysicalBone::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void PhysicalBone::_get_property_list(List<PropertyInfo> *p_list) const {
+void PhysicalBone3D::_get_property_list(List<PropertyInfo> *p_list) const {
- Skeleton *parent = find_skeleton_parent(get_parent());
+ Skeleton3D *parent = find_skeleton_parent(get_parent());
if (parent) {
@@ -2061,7 +2061,7 @@ void PhysicalBone::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-void PhysicalBone::_notification(int p_what) {
+void PhysicalBone3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
parent_skeleton = find_skeleton_parent(get_parent());
@@ -2080,7 +2080,7 @@ void PhysicalBone::_notification(int p_what) {
}
parent_skeleton = NULL;
if (joint.is_valid()) {
- PhysicsServer::get_singleton()->free(joint);
+ PhysicsServer3D::get_singleton()->free(joint);
joint = RID();
}
break;
@@ -2093,7 +2093,7 @@ void PhysicalBone::_notification(int p_what) {
}
}
-void PhysicalBone::_direct_state_changed(Object *p_state) {
+void PhysicalBone3D::_direct_state_changed(Object *p_state) {
if (!simulate_physics || !_internal_simulate_physics) {
return;
@@ -2101,12 +2101,12 @@ void PhysicalBone::_direct_state_changed(Object *p_state) {
/// Update bone transform
- PhysicsDirectBodyState *state;
+ PhysicsDirectBodyState3D *state;
#ifdef DEBUG_ENABLED
- state = Object::cast_to<PhysicsDirectBodyState>(p_state);
+ state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
#else
- state = (PhysicsDirectBodyState *)p_state; //trust it
+ state = (PhysicsDirectBodyState3D *)p_state; //trust it
#endif
Transform global_transform(state->get_transform());
@@ -2123,41 +2123,41 @@ void PhysicalBone::_direct_state_changed(Object *p_state) {
}
}
-void PhysicalBone::_bind_methods() {
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicalBone::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &PhysicalBone::apply_impulse);
+void PhysicalBone3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicalBone3D::apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &PhysicalBone3D::apply_impulse);
- ClassDB::bind_method(D_METHOD("_direct_state_changed"), &PhysicalBone::_direct_state_changed);
+ ClassDB::bind_method(D_METHOD("_direct_state_changed"), &PhysicalBone3D::_direct_state_changed);
- ClassDB::bind_method(D_METHOD("set_joint_type", "joint_type"), &PhysicalBone::set_joint_type);
- ClassDB::bind_method(D_METHOD("get_joint_type"), &PhysicalBone::get_joint_type);
+ ClassDB::bind_method(D_METHOD("set_joint_type", "joint_type"), &PhysicalBone3D::set_joint_type);
+ ClassDB::bind_method(D_METHOD("get_joint_type"), &PhysicalBone3D::get_joint_type);
- ClassDB::bind_method(D_METHOD("set_joint_offset", "offset"), &PhysicalBone::set_joint_offset);
- ClassDB::bind_method(D_METHOD("get_joint_offset"), &PhysicalBone::get_joint_offset);
+ ClassDB::bind_method(D_METHOD("set_joint_offset", "offset"), &PhysicalBone3D::set_joint_offset);
+ ClassDB::bind_method(D_METHOD("get_joint_offset"), &PhysicalBone3D::get_joint_offset);
- ClassDB::bind_method(D_METHOD("set_body_offset", "offset"), &PhysicalBone::set_body_offset);
- ClassDB::bind_method(D_METHOD("get_body_offset"), &PhysicalBone::get_body_offset);
+ ClassDB::bind_method(D_METHOD("set_body_offset", "offset"), &PhysicalBone3D::set_body_offset);
+ ClassDB::bind_method(D_METHOD("get_body_offset"), &PhysicalBone3D::get_body_offset);
- ClassDB::bind_method(D_METHOD("get_simulate_physics"), &PhysicalBone::get_simulate_physics);
+ ClassDB::bind_method(D_METHOD("get_simulate_physics"), &PhysicalBone3D::get_simulate_physics);
- ClassDB::bind_method(D_METHOD("is_simulating_physics"), &PhysicalBone::is_simulating_physics);
+ ClassDB::bind_method(D_METHOD("is_simulating_physics"), &PhysicalBone3D::is_simulating_physics);
- ClassDB::bind_method(D_METHOD("get_bone_id"), &PhysicalBone::get_bone_id);
+ ClassDB::bind_method(D_METHOD("get_bone_id"), &PhysicalBone3D::get_bone_id);
- ClassDB::bind_method(D_METHOD("set_mass", "mass"), &PhysicalBone::set_mass);
- ClassDB::bind_method(D_METHOD("get_mass"), &PhysicalBone::get_mass);
+ ClassDB::bind_method(D_METHOD("set_mass", "mass"), &PhysicalBone3D::set_mass);
+ ClassDB::bind_method(D_METHOD("get_mass"), &PhysicalBone3D::get_mass);
- ClassDB::bind_method(D_METHOD("set_weight", "weight"), &PhysicalBone::set_weight);
- ClassDB::bind_method(D_METHOD("get_weight"), &PhysicalBone::get_weight);
+ ClassDB::bind_method(D_METHOD("set_weight", "weight"), &PhysicalBone3D::set_weight);
+ ClassDB::bind_method(D_METHOD("get_weight"), &PhysicalBone3D::get_weight);
- ClassDB::bind_method(D_METHOD("set_friction", "friction"), &PhysicalBone::set_friction);
- ClassDB::bind_method(D_METHOD("get_friction"), &PhysicalBone::get_friction);
+ ClassDB::bind_method(D_METHOD("set_friction", "friction"), &PhysicalBone3D::set_friction);
+ ClassDB::bind_method(D_METHOD("get_friction"), &PhysicalBone3D::get_friction);
- ClassDB::bind_method(D_METHOD("set_bounce", "bounce"), &PhysicalBone::set_bounce);
- ClassDB::bind_method(D_METHOD("get_bounce"), &PhysicalBone::get_bounce);
+ ClassDB::bind_method(D_METHOD("set_bounce", "bounce"), &PhysicalBone3D::set_bounce);
+ ClassDB::bind_method(D_METHOD("get_bounce"), &PhysicalBone3D::get_bounce);
- ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &PhysicalBone::set_gravity_scale);
- ClassDB::bind_method(D_METHOD("get_gravity_scale"), &PhysicalBone::get_gravity_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &PhysicalBone3D::set_gravity_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_scale"), &PhysicalBone3D::get_gravity_scale);
ADD_GROUP("Joint", "joint_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "joint_type", PROPERTY_HINT_ENUM, "None,PinJoint,ConeJoint,HingeJoint,SliderJoint,6DOFJoint"), "set_joint_type", "get_joint_type");
@@ -2179,25 +2179,25 @@ void PhysicalBone::_bind_methods() {
BIND_ENUM_CONSTANT(JOINT_TYPE_6DOF);
}
-Skeleton *PhysicalBone::find_skeleton_parent(Node *p_parent) {
+Skeleton3D *PhysicalBone3D::find_skeleton_parent(Node *p_parent) {
if (!p_parent) {
return NULL;
}
- Skeleton *s = Object::cast_to<Skeleton>(p_parent);
+ Skeleton3D *s = Object::cast_to<Skeleton3D>(p_parent);
return s ? s : find_skeleton_parent(p_parent->get_parent());
}
-void PhysicalBone::_fix_joint_offset() {
+void PhysicalBone3D::_fix_joint_offset() {
// Clamp joint origin to bone origin
if (parent_skeleton) {
joint_offset.origin = body_offset.affine_inverse().origin;
}
}
-void PhysicalBone::_reload_joint() {
+void PhysicalBone3D::_reload_joint() {
if (joint.is_valid()) {
- PhysicsServer::get_singleton()->free(joint);
+ PhysicsServer3D::get_singleton()->free(joint);
joint = RID();
}
@@ -2205,7 +2205,7 @@ void PhysicalBone::_reload_joint() {
return;
}
- PhysicalBone *body_a = parent_skeleton->get_physical_bone_parent(bone_id);
+ PhysicalBone3D *body_a = parent_skeleton->get_physical_bone_parent(bone_id);
if (!body_a) {
return;
}
@@ -2217,78 +2217,78 @@ void PhysicalBone::_reload_joint() {
switch (get_joint_type()) {
case JOINT_TYPE_PIN: {
- joint = PhysicsServer::get_singleton()->joint_create_pin(body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin);
+ joint = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin);
const PinJointData *pjd(static_cast<const PinJointData *>(joint_data));
- PhysicsServer::get_singleton()->pin_joint_set_param(joint, PhysicsServer::PIN_JOINT_BIAS, pjd->bias);
- PhysicsServer::get_singleton()->pin_joint_set_param(joint, PhysicsServer::PIN_JOINT_DAMPING, pjd->damping);
- PhysicsServer::get_singleton()->pin_joint_set_param(joint, PhysicsServer::PIN_JOINT_IMPULSE_CLAMP, pjd->impulse_clamp);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_BIAS, pjd->bias);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_DAMPING, pjd->damping);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, pjd->impulse_clamp);
} break;
case JOINT_TYPE_CONE: {
- joint = PhysicsServer::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, get_rid(), joint_offset);
+ joint = PhysicsServer3D::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, get_rid(), joint_offset);
const ConeJointData *cjd(static_cast<const ConeJointData *>(joint_data));
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span);
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN, cjd->twist_span);
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_BIAS, cjd->bias);
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_SOFTNESS, cjd->softness);
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_RELAXATION, cjd->relaxation);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, cjd->twist_span);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, cjd->bias);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, cjd->softness);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, cjd->relaxation);
} break;
case JOINT_TYPE_HINGE: {
- joint = PhysicsServer::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, get_rid(), joint_offset);
+ joint = PhysicsServer3D::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, get_rid(), joint_offset);
const HingeJointData *hjd(static_cast<const HingeJointData *>(joint_data));
- PhysicsServer::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled);
- PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_UPPER, hjd->angular_limit_upper);
- PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_LOWER, hjd->angular_limit_lower);
- PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_BIAS, hjd->angular_limit_bias);
- PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS, hjd->angular_limit_softness);
- PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION, hjd->angular_limit_relaxation);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, hjd->angular_limit_upper);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, hjd->angular_limit_lower);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, hjd->angular_limit_bias);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, hjd->angular_limit_softness);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, hjd->angular_limit_relaxation);
} break;
case JOINT_TYPE_SLIDER: {
- joint = PhysicsServer::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, get_rid(), joint_offset);
+ joint = PhysicsServer3D::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, get_rid(), joint_offset);
const SliderJointData *sjd(static_cast<const SliderJointData *>(joint_data));
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER, sjd->linear_limit_lower);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, sjd->linear_limit_softness);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, sjd->linear_limit_restitution);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, sjd->linear_limit_restitution);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, sjd->angular_limit_upper);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, sjd->angular_limit_lower);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
- PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, sjd->angular_limit_damping);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, sjd->linear_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, sjd->linear_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, sjd->linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, sjd->linear_limit_restitution);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, sjd->angular_limit_upper);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, sjd->angular_limit_lower);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, sjd->angular_limit_damping);
} break;
case JOINT_TYPE_6DOF: {
- joint = PhysicsServer::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, get_rid(), joint_offset);
+ joint = PhysicsServer3D::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, get_rid(), joint_offset);
const SixDOFJointData *g6dofjd(static_cast<const SixDOFJointData *>(joint_data));
for (int axis = 0; axis < 3; ++axis) {
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, g6dofjd->axis_data[axis].linear_limit_enabled);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT, g6dofjd->axis_data[axis].linear_limit_upper);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT, g6dofjd->axis_data[axis].linear_limit_lower);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].linear_limit_softness);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, g6dofjd->axis_data[axis].linear_spring_enabled);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].linear_spring_stiffness);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING, g6dofjd->axis_data[axis].linear_spring_damping);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].linear_equilibrium_point);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION, g6dofjd->axis_data[axis].linear_restitution);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING, g6dofjd->axis_data[axis].linear_damping);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, g6dofjd->axis_data[axis].angular_limit_enabled);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, g6dofjd->axis_data[axis].angular_limit_upper);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, g6dofjd->axis_data[axis].angular_limit_lower);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].angular_limit_softness);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION, g6dofjd->axis_data[axis].angular_restitution);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING, g6dofjd->axis_data[axis].angular_damping);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_ERP, g6dofjd->axis_data[axis].erp);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, g6dofjd->axis_data[axis].angular_spring_enabled);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].angular_spring_stiffness);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, g6dofjd->axis_data[axis].angular_spring_damping);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].angular_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, g6dofjd->axis_data[axis].linear_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, g6dofjd->axis_data[axis].linear_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, g6dofjd->axis_data[axis].linear_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].linear_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, g6dofjd->axis_data[axis].linear_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].linear_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, g6dofjd->axis_data[axis].linear_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].linear_equilibrium_point);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, g6dofjd->axis_data[axis].linear_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, g6dofjd->axis_data[axis].linear_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, g6dofjd->axis_data[axis].angular_limit_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, g6dofjd->axis_data[axis].angular_limit_upper);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, g6dofjd->axis_data[axis].angular_limit_lower);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].angular_limit_softness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, g6dofjd->axis_data[axis].angular_restitution);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, g6dofjd->axis_data[axis].angular_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, g6dofjd->axis_data[axis].erp);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, g6dofjd->axis_data[axis].angular_spring_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].angular_spring_stiffness);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, g6dofjd->axis_data[axis].angular_spring_damping);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].angular_equilibrium_point);
}
} break;
@@ -2297,36 +2297,36 @@ void PhysicalBone::_reload_joint() {
}
}
-void PhysicalBone::_on_bone_parent_changed() {
+void PhysicalBone3D::_on_bone_parent_changed() {
_reload_joint();
}
-void PhysicalBone::_set_gizmo_move_joint(bool p_move_joint) {
+void PhysicalBone3D::_set_gizmo_move_joint(bool p_move_joint) {
#ifdef TOOLS_ENABLED
gizmo_move_joint = p_move_joint;
- SpatialEditor::get_singleton()->update_transform_gizmo();
+ Node3DEditor::get_singleton()->update_transform_gizmo();
#endif
}
#ifdef TOOLS_ENABLED
-Transform PhysicalBone::get_global_gizmo_transform() const {
+Transform PhysicalBone3D::get_global_gizmo_transform() const {
return gizmo_move_joint ? get_global_transform() * joint_offset : get_global_transform();
}
-Transform PhysicalBone::get_local_gizmo_transform() const {
+Transform PhysicalBone3D::get_local_gizmo_transform() const {
return gizmo_move_joint ? get_transform() * joint_offset : get_transform();
}
#endif
-const PhysicalBone::JointData *PhysicalBone::get_joint_data() const {
+const PhysicalBone3D::JointData *PhysicalBone3D::get_joint_data() const {
return joint_data;
}
-Skeleton *PhysicalBone::find_skeleton_parent() {
+Skeleton3D *PhysicalBone3D::find_skeleton_parent() {
return find_skeleton_parent(this);
}
-void PhysicalBone::set_joint_type(JointType p_joint_type) {
+void PhysicalBone3D::set_joint_type(JointType p_joint_type) {
if (p_joint_type == get_joint_type())
return;
@@ -2363,11 +2363,11 @@ void PhysicalBone::set_joint_type(JointType p_joint_type) {
#endif
}
-PhysicalBone::JointType PhysicalBone::get_joint_type() const {
+PhysicalBone3D::JointType PhysicalBone3D::get_joint_type() const {
return joint_data ? joint_data->get_joint_type() : JOINT_TYPE_NONE;
}
-void PhysicalBone::set_joint_offset(const Transform &p_offset) {
+void PhysicalBone3D::set_joint_offset(const Transform &p_offset) {
joint_offset = p_offset;
_fix_joint_offset();
@@ -2382,11 +2382,11 @@ void PhysicalBone::set_joint_offset(const Transform &p_offset) {
#endif
}
-const Transform &PhysicalBone::get_body_offset() const {
+const Transform &PhysicalBone3D::get_body_offset() const {
return body_offset;
}
-void PhysicalBone::set_body_offset(const Transform &p_offset) {
+void PhysicalBone3D::set_body_offset(const Transform &p_offset) {
body_offset = p_offset;
body_offset_inverse = body_offset.affine_inverse();
@@ -2402,11 +2402,11 @@ void PhysicalBone::set_body_offset(const Transform &p_offset) {
#endif
}
-const Transform &PhysicalBone::get_joint_offset() const {
+const Transform &PhysicalBone3D::get_joint_offset() const {
return joint_offset;
}
-void PhysicalBone::set_simulate_physics(bool p_simulate) {
+void PhysicalBone3D::set_simulate_physics(bool p_simulate) {
if (simulate_physics == p_simulate) {
return;
}
@@ -2415,15 +2415,15 @@ void PhysicalBone::set_simulate_physics(bool p_simulate) {
reset_physics_simulation_state();
}
-bool PhysicalBone::get_simulate_physics() {
+bool PhysicalBone3D::get_simulate_physics() {
return simulate_physics;
}
-bool PhysicalBone::is_simulating_physics() {
+bool PhysicalBone3D::is_simulating_physics() {
return _internal_simulate_physics;
}
-void PhysicalBone::set_bone_name(const String &p_name) {
+void PhysicalBone3D::set_bone_name(const String &p_name) {
bone_name = p_name;
bone_id = -1;
@@ -2432,72 +2432,72 @@ void PhysicalBone::set_bone_name(const String &p_name) {
reset_to_rest_position();
}
-const String &PhysicalBone::get_bone_name() const {
+const String &PhysicalBone3D::get_bone_name() const {
return bone_name;
}
-void PhysicalBone::set_mass(real_t p_mass) {
+void PhysicalBone3D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
}
-real_t PhysicalBone::get_mass() const {
+real_t PhysicalBone3D::get_mass() const {
return mass;
}
-void PhysicalBone::set_weight(real_t p_weight) {
+void PhysicalBone3D::set_weight(real_t p_weight) {
set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)));
}
-real_t PhysicalBone::get_weight() const {
+real_t PhysicalBone3D::get_weight() const {
return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
}
-void PhysicalBone::set_friction(real_t p_friction) {
+void PhysicalBone3D::set_friction(real_t p_friction) {
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
friction = p_friction;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, friction);
}
-real_t PhysicalBone::get_friction() const {
+real_t PhysicalBone3D::get_friction() const {
return friction;
}
-void PhysicalBone::set_bounce(real_t p_bounce) {
+void PhysicalBone3D::set_bounce(real_t p_bounce) {
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
bounce = p_bounce;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, bounce);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, bounce);
}
-real_t PhysicalBone::get_bounce() const {
+real_t PhysicalBone3D::get_bounce() const {
return bounce;
}
-void PhysicalBone::set_gravity_scale(real_t p_gravity_scale) {
+void PhysicalBone3D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
+ PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
-real_t PhysicalBone::get_gravity_scale() const {
+real_t PhysicalBone3D::get_gravity_scale() const {
return gravity_scale;
}
-PhysicalBone::PhysicalBone() :
- PhysicsBody(PhysicsServer::BODY_MODE_STATIC),
+PhysicalBone3D::PhysicalBone3D() :
+ PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC),
#ifdef TOOLS_ENABLED
gizmo_move_joint(false),
#endif
@@ -2515,12 +2515,12 @@ PhysicalBone::PhysicalBone() :
reset_physics_simulation_state();
}
-PhysicalBone::~PhysicalBone() {
+PhysicalBone3D::~PhysicalBone3D() {
if (joint_data)
memdelete(joint_data);
}
-void PhysicalBone::update_bone_id() {
+void PhysicalBone3D::update_bone_id() {
if (!parent_skeleton) {
return;
}
@@ -2543,7 +2543,7 @@ void PhysicalBone::update_bone_id() {
}
}
-void PhysicalBone::update_offset() {
+void PhysicalBone3D::update_offset() {
#ifdef TOOLS_ENABLED
if (parent_skeleton) {
@@ -2561,34 +2561,34 @@ void PhysicalBone::update_offset() {
#endif
}
-void PhysicalBone::_start_physics_simulation() {
+void PhysicalBone3D::_start_physics_simulation() {
if (_internal_simulate_physics || !parent_skeleton) {
return;
}
reset_to_rest_position();
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_RIGID);
- PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
- PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_RIGID);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
+ PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
set_as_toplevel(true);
_internal_simulate_physics = true;
}
-void PhysicalBone::_stop_physics_simulation() {
+void PhysicalBone3D::_stop_physics_simulation() {
if (!parent_skeleton) {
return;
}
if (parent_skeleton->get_animate_physical_bones()) {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_KINEMATIC);
- PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
- PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_KINEMATIC);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
} else {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), 0);
- PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), 0);
+ PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), 0);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), 0);
}
if (_internal_simulate_physics) {
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, "");
+ PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, "");
parent_skeleton->set_bone_global_pose_override(bone_id, Transform(), 0.0, false);
set_as_toplevel(false);
_internal_simulate_physics = false;
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body_3d.h
index 90de1ffce6..ed7cfa8733 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_body.h */
+/* physics_body_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,18 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PHYSICS_BODY__H
-#define PHYSICS_BODY__H
+#ifndef PHYSICS_BODY_3D_H
+#define PHYSICS_BODY_3D_H
#include "core/vset.h"
-#include "scene/3d/collision_object.h"
+#include "scene/3d/collision_object_3d.h"
#include "scene/resources/physics_material.h"
-#include "servers/physics_server.h"
-#include "skeleton.h"
+#include "servers/physics_server_3d.h"
+#include "skeleton_3d.h"
-class PhysicsBody : public CollisionObject {
+class PhysicsBody3D : public CollisionObject3D {
- GDCLASS(PhysicsBody, CollisionObject);
+ GDCLASS(PhysicsBody3D, CollisionObject3D);
uint32_t collision_layer;
uint32_t collision_mask;
@@ -49,7 +49,7 @@ class PhysicsBody : public CollisionObject {
protected:
static void _bind_methods();
- PhysicsBody(PhysicsServer::BodyMode p_mode);
+ PhysicsBody3D(PhysicsServer3D::BodyMode p_mode);
public:
virtual Vector3 get_linear_velocity() const;
@@ -72,12 +72,12 @@ public:
void add_collision_exception_with(Node *p_node); //must be physicsbody
void remove_collision_exception_with(Node *p_node);
- PhysicsBody();
+ PhysicsBody3D();
};
-class StaticBody : public PhysicsBody {
+class StaticBody3D : public PhysicsBody3D {
- GDCLASS(StaticBody, PhysicsBody);
+ GDCLASS(StaticBody3D, PhysicsBody3D);
Vector3 constant_linear_velocity;
Vector3 constant_angular_velocity;
@@ -97,16 +97,16 @@ public:
Vector3 get_constant_linear_velocity() const;
Vector3 get_constant_angular_velocity() const;
- StaticBody();
- ~StaticBody();
+ StaticBody3D();
+ ~StaticBody3D();
private:
void _reload_physics_characteristics();
};
-class RigidBody : public PhysicsBody {
+class RigidBody3D : public PhysicsBody3D {
- GDCLASS(RigidBody, PhysicsBody);
+ GDCLASS(RigidBody3D, PhysicsBody3D);
public:
enum Mode {
@@ -118,7 +118,7 @@ public:
protected:
bool can_sleep;
- PhysicsDirectBodyState *state;
+ PhysicsDirectBodyState3D *state;
Mode mode;
real_t mass;
@@ -234,8 +234,8 @@ public:
void set_use_continuous_collision_detection(bool p_enable);
bool is_using_continuous_collision_detection() const;
- void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock);
- bool get_axis_lock(PhysicsServer::BodyAxis p_axis) const;
+ void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock);
+ bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const;
Array get_colliding_bodies() const;
@@ -249,20 +249,20 @@ public:
virtual String get_configuration_warning() const;
- RigidBody();
- ~RigidBody();
+ RigidBody3D();
+ ~RigidBody3D();
private:
void _reload_physics_characteristics();
};
-VARIANT_ENUM_CAST(RigidBody::Mode);
+VARIANT_ENUM_CAST(RigidBody3D::Mode);
-class KinematicCollision;
+class KinematicCollision3D;
-class KinematicBody : public PhysicsBody {
+class KinematicBody3D : public PhysicsBody3D {
- GDCLASS(KinematicBody, PhysicsBody);
+ GDCLASS(KinematicBody3D, PhysicsBody3D);
public:
struct Collision {
@@ -293,13 +293,13 @@ private:
bool on_ceiling;
bool on_wall;
Vector<Collision> colliders;
- Vector<Ref<KinematicCollision>> slide_colliders;
- Ref<KinematicCollision> motion_cache;
+ Vector<Ref<KinematicCollision3D>> slide_colliders;
+ Ref<KinematicCollision3D> motion_cache;
- _FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const;
+ _FORCE_INLINE_ bool _ignores_mode(PhysicsServer3D::BodyMode) const;
- Ref<KinematicCollision> _move(const Vector3 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, bool p_test_only = false);
- Ref<KinematicCollision> _get_slide_collision(int p_bounce);
+ Ref<KinematicCollision3D> _move(const Vector3 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, bool p_test_only = false);
+ Ref<KinematicCollision3D> _get_slide_collision(int p_bounce);
protected:
void _notification(int p_what);
@@ -316,8 +316,8 @@ public:
bool separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision);
- void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock);
- bool get_axis_lock(PhysicsServer::BodyAxis p_axis) const;
+ void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock);
+ bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const;
void set_safe_margin(float p_margin);
float get_safe_margin() const;
@@ -333,17 +333,17 @@ public:
int get_slide_count() const;
Collision get_slide_collision(int p_bounce) const;
- KinematicBody();
- ~KinematicBody();
+ KinematicBody3D();
+ ~KinematicBody3D();
};
-class KinematicCollision : public Reference {
+class KinematicCollision3D : public Reference {
- GDCLASS(KinematicCollision, Reference);
+ GDCLASS(KinematicCollision3D, Reference);
- KinematicBody *owner;
- friend class KinematicBody;
- KinematicBody::Collision collision;
+ KinematicBody3D *owner;
+ friend class KinematicBody3D;
+ KinematicBody3D::Collision collision;
protected:
static void _bind_methods();
@@ -361,12 +361,12 @@ public:
Vector3 get_collider_velocity() const;
Variant get_collider_metadata() const;
- KinematicCollision();
+ KinematicCollision3D();
};
-class PhysicalBone : public PhysicsBody {
+class PhysicalBone3D : public PhysicsBody3D {
- GDCLASS(PhysicalBone, PhysicsBody);
+ GDCLASS(PhysicalBone3D, PhysicsBody3D);
public:
enum JointType {
@@ -381,7 +381,7 @@ public:
struct JointData {
virtual JointType get_joint_type() { return JOINT_TYPE_NONE; }
- /// "j" is used to set the parameter inside the PhysicsServer
+ /// "j" is used to set the parameter inside the PhysicsServer3D
virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
@@ -550,7 +550,7 @@ private:
Transform joint_offset;
RID joint;
- Skeleton *parent_skeleton;
+ Skeleton3D *parent_skeleton;
Transform body_offset;
Transform body_offset_inverse;
bool simulate_physics;
@@ -573,7 +573,7 @@ protected:
static void _bind_methods();
private:
- static Skeleton *find_skeleton_parent(Node *p_parent);
+ static Skeleton3D *find_skeleton_parent(Node *p_parent);
void _fix_joint_offset();
void _reload_joint();
@@ -589,7 +589,7 @@ public:
#endif
const JointData *get_joint_data() const;
- Skeleton *find_skeleton_parent();
+ Skeleton3D *find_skeleton_parent();
int get_bone_id() const { return bone_id; }
@@ -630,8 +630,8 @@ public:
void reset_physics_simulation_state();
void reset_to_rest_position();
- PhysicalBone();
- ~PhysicalBone();
+ PhysicalBone3D();
+ ~PhysicalBone3D();
private:
void update_bone_id();
@@ -641,6 +641,6 @@ private:
void _stop_physics_simulation();
};
-VARIANT_ENUM_CAST(PhysicalBone::JointType);
+VARIANT_ENUM_CAST(PhysicalBone3D::JointType);
#endif // PHYSICS_BODY__H
diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h
deleted file mode 100644
index d03dbac392..0000000000
--- a/scene/3d/physics_joint.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/*************************************************************************/
-/* physics_joint.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef PHYSICS_JOINT_H
-#define PHYSICS_JOINT_H
-
-#include "scene/3d/physics_body.h"
-#include "scene/3d/spatial.h"
-
-class Joint : public Spatial {
-
- GDCLASS(Joint, Spatial);
-
- RID ba, bb;
-
- RID joint;
-
- NodePath a;
- NodePath b;
-
- int solver_priority;
- bool exclude_from_collision;
-
-protected:
- void _update_joint(bool p_only_free = false);
-
- void _notification(int p_what);
-
- virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) = 0;
-
- static void _bind_methods();
-
-public:
- void set_node_a(const NodePath &p_node_a);
- NodePath get_node_a() const;
-
- void set_node_b(const NodePath &p_node_b);
- NodePath get_node_b() const;
-
- void set_solver_priority(int p_priority);
- int get_solver_priority() const;
-
- void set_exclude_nodes_from_collision(bool p_enable);
- bool get_exclude_nodes_from_collision() const;
-
- RID get_joint() const { return joint; }
- Joint();
-};
-
-///////////////////////////////////////////
-
-class PinJoint : public Joint {
-
- GDCLASS(PinJoint, Joint);
-
-public:
- enum Param {
- PARAM_BIAS = PhysicsServer::PIN_JOINT_BIAS,
- PARAM_DAMPING = PhysicsServer::PIN_JOINT_DAMPING,
- PARAM_IMPULSE_CLAMP = PhysicsServer::PIN_JOINT_IMPULSE_CLAMP
- };
-
-protected:
- float params[3];
- virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
- static void _bind_methods();
-
-public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
-
- PinJoint();
-};
-
-VARIANT_ENUM_CAST(PinJoint::Param);
-
-class HingeJoint : public Joint {
-
- GDCLASS(HingeJoint, Joint);
-
-public:
- enum Param {
- PARAM_BIAS = PhysicsServer::HINGE_JOINT_BIAS,
- PARAM_LIMIT_UPPER = PhysicsServer::HINGE_JOINT_LIMIT_UPPER,
- PARAM_LIMIT_LOWER = PhysicsServer::HINGE_JOINT_LIMIT_LOWER,
- PARAM_LIMIT_BIAS = PhysicsServer::HINGE_JOINT_LIMIT_BIAS,
- PARAM_LIMIT_SOFTNESS = PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS,
- PARAM_LIMIT_RELAXATION = PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION,
- PARAM_MOTOR_TARGET_VELOCITY = PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY,
- PARAM_MOTOR_MAX_IMPULSE = PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE,
- PARAM_MAX = PhysicsServer::HINGE_JOINT_MAX
- };
-
- enum Flag {
- FLAG_USE_LIMIT = PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT,
- FLAG_ENABLE_MOTOR = PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR,
- FLAG_MAX = PhysicsServer::HINGE_JOINT_FLAG_MAX
- };
-
-protected:
- float params[PARAM_MAX];
- bool flags[FLAG_MAX];
- virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
- static void _bind_methods();
-
- void _set_upper_limit(float p_limit);
- float _get_upper_limit() const;
-
- void _set_lower_limit(float p_limit);
- float _get_lower_limit() const;
-
-public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
-
- void set_flag(Flag p_flag, bool p_value);
- bool get_flag(Flag p_flag) const;
-
- HingeJoint();
-};
-
-VARIANT_ENUM_CAST(HingeJoint::Param);
-VARIANT_ENUM_CAST(HingeJoint::Flag);
-
-class SliderJoint : public Joint {
-
- GDCLASS(SliderJoint, Joint);
-
-public:
- enum Param {
- PARAM_LINEAR_LIMIT_UPPER = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER,
- PARAM_LINEAR_LIMIT_LOWER = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER,
- PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
- PARAM_LINEAR_LIMIT_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
- PARAM_LINEAR_LIMIT_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
- PARAM_LINEAR_MOTION_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
- PARAM_LINEAR_MOTION_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
- PARAM_LINEAR_MOTION_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING,
- PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
- PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
- PARAM_LINEAR_ORTHOGONAL_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
-
- PARAM_ANGULAR_LIMIT_UPPER = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
- PARAM_ANGULAR_LIMIT_LOWER = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
- PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
- PARAM_ANGULAR_LIMIT_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
- PARAM_ANGULAR_LIMIT_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
- PARAM_ANGULAR_MOTION_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
- PARAM_ANGULAR_MOTION_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
- PARAM_ANGULAR_MOTION_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
- PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
- PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
- PARAM_ANGULAR_ORTHOGONAL_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
- PARAM_MAX = PhysicsServer::SLIDER_JOINT_MAX
-
- };
-
-protected:
- void _set_upper_limit_angular(float p_limit_angular);
- float _get_upper_limit_angular() const;
-
- void _set_lower_limit_angular(float p_limit_angular);
- float _get_lower_limit_angular() const;
-
- float params[PARAM_MAX];
- virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
- static void _bind_methods();
-
-public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
-
- SliderJoint();
-};
-
-VARIANT_ENUM_CAST(SliderJoint::Param);
-
-class ConeTwistJoint : public Joint {
-
- GDCLASS(ConeTwistJoint, Joint);
-
-public:
- enum Param {
-
- PARAM_SWING_SPAN,
- PARAM_TWIST_SPAN,
- PARAM_BIAS,
- PARAM_SOFTNESS,
- PARAM_RELAXATION,
- PARAM_MAX
- };
-
-protected:
- void _set_swing_span(float p_limit_angular);
- float _get_swing_span() const;
-
- void _set_twist_span(float p_limit_angular);
- float _get_twist_span() const;
-
- float params[PARAM_MAX];
- virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
- static void _bind_methods();
-
-public:
- void set_param(Param p_param, float p_value);
- float get_param(Param p_param) const;
-
- ConeTwistJoint();
-};
-
-VARIANT_ENUM_CAST(ConeTwistJoint::Param);
-
-class Generic6DOFJoint : public Joint {
-
- GDCLASS(Generic6DOFJoint, Joint);
-
-public:
- enum Param {
-
- PARAM_LINEAR_LOWER_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT,
- PARAM_LINEAR_UPPER_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT,
- PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
- PARAM_LINEAR_RESTITUTION = PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION,
- PARAM_LINEAR_DAMPING = PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING,
- PARAM_LINEAR_MOTOR_TARGET_VELOCITY = PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
- PARAM_LINEAR_MOTOR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
- PARAM_LINEAR_SPRING_STIFFNESS = PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
- PARAM_LINEAR_SPRING_DAMPING = PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING,
- PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
- PARAM_ANGULAR_LOWER_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
- PARAM_ANGULAR_UPPER_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
- PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
- PARAM_ANGULAR_DAMPING = PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING,
- PARAM_ANGULAR_RESTITUTION = PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION,
- PARAM_ANGULAR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
- PARAM_ANGULAR_ERP = PhysicsServer::G6DOF_JOINT_ANGULAR_ERP,
- PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
- PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
- PARAM_ANGULAR_SPRING_STIFFNESS = PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
- PARAM_ANGULAR_SPRING_DAMPING = PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
- PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
- PARAM_MAX = PhysicsServer::G6DOF_JOINT_MAX,
- };
-
- enum Flag {
- FLAG_ENABLE_LINEAR_LIMIT = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
- FLAG_ENABLE_ANGULAR_LIMIT = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
- FLAG_ENABLE_LINEAR_SPRING = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
- FLAG_ENABLE_ANGULAR_SPRING = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
- FLAG_ENABLE_MOTOR = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR,
- FLAG_ENABLE_LINEAR_MOTOR = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
- FLAG_MAX = PhysicsServer::G6DOF_JOINT_FLAG_MAX
- };
-
-protected:
- void _set_angular_hi_limit_x(float p_limit_angular);
- float _get_angular_hi_limit_x() const;
-
- void _set_angular_hi_limit_y(float p_limit_angular);
- float _get_angular_hi_limit_y() const;
-
- void _set_angular_hi_limit_z(float p_limit_angular);
- float _get_angular_hi_limit_z() const;
-
- void _set_angular_lo_limit_x(float p_limit_angular);
- float _get_angular_lo_limit_x() const;
-
- void _set_angular_lo_limit_y(float p_limit_angular);
- float _get_angular_lo_limit_y() const;
-
- void _set_angular_lo_limit_z(float p_limit_angular);
- float _get_angular_lo_limit_z() const;
-
- float params_x[PARAM_MAX];
- bool flags_x[FLAG_MAX];
- float params_y[PARAM_MAX];
- bool flags_y[FLAG_MAX];
- float params_z[PARAM_MAX];
- bool flags_z[FLAG_MAX];
-
- int precision;
-
- virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
- static void _bind_methods();
-
-public:
- void set_param_x(Param p_param, float p_value);
- float get_param_x(Param p_param) const;
-
- void set_param_y(Param p_param, float p_value);
- float get_param_y(Param p_param) const;
-
- void set_param_z(Param p_param, float p_value);
- float get_param_z(Param p_param) const;
-
- void set_flag_x(Flag p_flag, bool p_enabled);
- bool get_flag_x(Flag p_flag) const;
-
- void set_flag_y(Flag p_flag, bool p_enabled);
- bool get_flag_y(Flag p_flag) const;
-
- void set_flag_z(Flag p_flag, bool p_enabled);
- bool get_flag_z(Flag p_flag) const;
-
- void set_precision(int p_precision);
- int get_precision() const {
- return precision;
- }
-
- Generic6DOFJoint();
-};
-
-VARIANT_ENUM_CAST(Generic6DOFJoint::Param);
-VARIANT_ENUM_CAST(Generic6DOFJoint::Flag);
-
-#endif // PHYSICS_JOINT_H
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint_3d.cpp
index 0699e366e0..f6b3e79300 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_joint.cpp */
+/* physics_joint_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physics_joint.h"
+#include "physics_joint_3d.h"
-void Joint::_update_joint(bool p_only_free) {
+void Joint3D::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
if (ba.is_valid() && bb.is_valid())
- PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb);
+ PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb);
- PhysicsServer::get_singleton()->free(joint);
+ PhysicsServer3D::get_singleton()->free(joint);
joint = RID();
ba = RID();
bb = RID();
@@ -48,8 +48,8 @@ void Joint::_update_joint(bool p_only_free) {
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
- PhysicsBody *body_a = Object::cast_to<PhysicsBody>(node_a);
- PhysicsBody *body_b = Object::cast_to<PhysicsBody>(node_b);
+ PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a);
+ PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b);
if (!body_a && body_b)
SWAP(body_a, body_b);
@@ -62,16 +62,16 @@ void Joint::_update_joint(bool p_only_free) {
if (!joint.is_valid())
return;
- PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
+ PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
ba = body_a->get_rid();
if (body_b)
bb = body_b->get_rid();
- PhysicsServer::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
+ PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
}
-void Joint::set_node_a(const NodePath &p_node_a) {
+void Joint3D::set_node_a(const NodePath &p_node_a) {
if (a == p_node_a)
return;
@@ -80,36 +80,36 @@ void Joint::set_node_a(const NodePath &p_node_a) {
_update_joint();
}
-NodePath Joint::get_node_a() const {
+NodePath Joint3D::get_node_a() const {
return a;
}
-void Joint::set_node_b(const NodePath &p_node_b) {
+void Joint3D::set_node_b(const NodePath &p_node_b) {
if (b == p_node_b)
return;
b = p_node_b;
_update_joint();
}
-NodePath Joint::get_node_b() const {
+NodePath Joint3D::get_node_b() const {
return b;
}
-void Joint::set_solver_priority(int p_priority) {
+void Joint3D::set_solver_priority(int p_priority) {
solver_priority = p_priority;
if (joint.is_valid())
- PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
+ PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
}
-int Joint::get_solver_priority() const {
+int Joint3D::get_solver_priority() const {
return solver_priority;
}
-void Joint::_notification(int p_what) {
+void Joint3D::_notification(int p_what) {
switch (p_what) {
@@ -124,7 +124,7 @@ void Joint::_notification(int p_what) {
}
}
-void Joint::set_exclude_nodes_from_collision(bool p_enable) {
+void Joint3D::set_exclude_nodes_from_collision(bool p_enable) {
if (exclude_from_collision == p_enable)
return;
@@ -132,33 +132,33 @@ void Joint::set_exclude_nodes_from_collision(bool p_enable) {
_update_joint();
}
-bool Joint::get_exclude_nodes_from_collision() const {
+bool Joint3D::get_exclude_nodes_from_collision() const {
return exclude_from_collision;
}
-void Joint::_bind_methods() {
+void Joint3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint::set_node_a);
- ClassDB::bind_method(D_METHOD("get_node_a"), &Joint::get_node_a);
+ ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint3D::set_node_a);
+ ClassDB::bind_method(D_METHOD("get_node_a"), &Joint3D::get_node_a);
- ClassDB::bind_method(D_METHOD("set_node_b", "node"), &Joint::set_node_b);
- ClassDB::bind_method(D_METHOD("get_node_b"), &Joint::get_node_b);
+ ClassDB::bind_method(D_METHOD("set_node_b", "node"), &Joint3D::set_node_b);
+ ClassDB::bind_method(D_METHOD("get_node_b"), &Joint3D::get_node_b);
- ClassDB::bind_method(D_METHOD("set_solver_priority", "priority"), &Joint::set_solver_priority);
- ClassDB::bind_method(D_METHOD("get_solver_priority"), &Joint::get_solver_priority);
+ ClassDB::bind_method(D_METHOD("set_solver_priority", "priority"), &Joint3D::set_solver_priority);
+ ClassDB::bind_method(D_METHOD("get_solver_priority"), &Joint3D::get_solver_priority);
- ClassDB::bind_method(D_METHOD("set_exclude_nodes_from_collision", "enable"), &Joint::set_exclude_nodes_from_collision);
- ClassDB::bind_method(D_METHOD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision);
+ ClassDB::bind_method(D_METHOD("set_exclude_nodes_from_collision", "enable"), &Joint3D::set_exclude_nodes_from_collision);
+ ClassDB::bind_method(D_METHOD("get_exclude_nodes_from_collision"), &Joint3D::get_exclude_nodes_from_collision);
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_a", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "CollisionObject"), "set_node_a", "get_node_a");
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_b", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "CollisionObject"), "set_node_b", "get_node_b");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_a", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "CollisionObject3D"), "set_node_a", "get_node_a");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_b", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "CollisionObject3D"), "set_node_b", "get_node_b");
ADD_PROPERTY(PropertyInfo(Variant::INT, "solver/priority", PROPERTY_HINT_RANGE, "1,8,1"), "set_solver_priority", "get_solver_priority");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision/exclude_nodes"), "set_exclude_nodes_from_collision", "get_exclude_nodes_from_collision");
}
-Joint::Joint() {
+Joint3D::Joint3D() {
exclude_from_collision = true;
solver_priority = 1;
@@ -167,10 +167,10 @@ Joint::Joint() {
///////////////////////////////////
-void PinJoint::_bind_methods() {
+void PinJoint3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &PinJoint::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &PinJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &PinJoint3D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &PinJoint3D::get_param);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), "set_param", "get_param", PARAM_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/damping", PROPERTY_HINT_RANGE, "0.01,8.0,0.01"), "set_param", "get_param", PARAM_DAMPING);
@@ -181,20 +181,20 @@ void PinJoint::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_IMPULSE_CLAMP);
}
-void PinJoint::set_param(Param p_param, float p_value) {
+void PinJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, 3);
params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer::PinJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value);
}
-float PinJoint::get_param(Param p_param) const {
+float PinJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, 3, 0);
return params[p_param];
}
-RID PinJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
+RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Vector3 pinpos = get_global_transform().origin;
Vector3 local_a = body_a->get_global_transform().affine_inverse().xform(pinpos);
@@ -205,14 +205,14 @@ RID PinJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
else
local_b = pinpos;
- RID j = PhysicsServer::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ RID j = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < 3; i++) {
- PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PinJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PinJointParam(i), params[i]);
}
return j;
}
-PinJoint::PinJoint() {
+PinJoint3D::PinJoint3D() {
params[PARAM_BIAS] = 0.3;
params[PARAM_DAMPING] = 1;
@@ -223,39 +223,39 @@ PinJoint::PinJoint() {
///////////////////////////////////
-void HingeJoint::_set_upper_limit(float p_limit) {
+void HingeJoint3D::_set_upper_limit(float p_limit) {
set_param(PARAM_LIMIT_UPPER, Math::deg2rad(p_limit));
}
-float HingeJoint::_get_upper_limit() const {
+float HingeJoint3D::_get_upper_limit() const {
return Math::rad2deg(get_param(PARAM_LIMIT_UPPER));
}
-void HingeJoint::_set_lower_limit(float p_limit) {
+void HingeJoint3D::_set_lower_limit(float p_limit) {
set_param(PARAM_LIMIT_LOWER, Math::deg2rad(p_limit));
}
-float HingeJoint::_get_lower_limit() const {
+float HingeJoint3D::_get_lower_limit() const {
return Math::rad2deg(get_param(PARAM_LIMIT_LOWER));
}
-void HingeJoint::_bind_methods() {
+void HingeJoint3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &HingeJoint::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &HingeJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &HingeJoint3D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &HingeJoint3D::get_param);
- ClassDB::bind_method(D_METHOD("set_flag", "flag", "enabled"), &HingeJoint::set_flag);
- ClassDB::bind_method(D_METHOD("get_flag", "flag"), &HingeJoint::get_flag);
+ ClassDB::bind_method(D_METHOD("set_flag", "flag", "enabled"), &HingeJoint3D::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag", "flag"), &HingeJoint3D::get_flag);
- ClassDB::bind_method(D_METHOD("_set_upper_limit", "upper_limit"), &HingeJoint::_set_upper_limit);
- ClassDB::bind_method(D_METHOD("_get_upper_limit"), &HingeJoint::_get_upper_limit);
+ ClassDB::bind_method(D_METHOD("_set_upper_limit", "upper_limit"), &HingeJoint3D::_set_upper_limit);
+ ClassDB::bind_method(D_METHOD("_get_upper_limit"), &HingeJoint3D::_get_upper_limit);
- ClassDB::bind_method(D_METHOD("_set_lower_limit", "lower_limit"), &HingeJoint::_set_lower_limit);
- ClassDB::bind_method(D_METHOD("_get_lower_limit"), &HingeJoint::_get_lower_limit);
+ ClassDB::bind_method(D_METHOD("_set_lower_limit", "lower_limit"), &HingeJoint3D::_set_lower_limit);
+ ClassDB::bind_method(D_METHOD("_get_lower_limit"), &HingeJoint3D::_get_lower_limit);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/bias", PROPERTY_HINT_RANGE, "0.00,0.99,0.01"), "set_param", "get_param", PARAM_BIAS);
@@ -285,37 +285,37 @@ void HingeJoint::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
}
-void HingeJoint::set_param(Param p_param, float p_value) {
+void HingeJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer::HingeJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value);
update_gizmo();
}
-float HingeJoint::get_param(Param p_param) const {
+float HingeJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
-void HingeJoint::set_flag(Flag p_flag, bool p_value) {
+void HingeJoint3D::set_flag(Flag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer::HingeJointFlag(p_flag), p_value);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
update_gizmo();
}
-bool HingeJoint::get_flag(Flag p_flag) const {
+bool HingeJoint3D::get_flag(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
-RID HingeJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
+RID HingeJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Transform gt = get_global_transform();
Transform ainv = body_a->get_global_transform().affine_inverse();
@@ -331,18 +331,18 @@ RID HingeJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ RID j = PhysicsServer3D::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HingeJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HingeJointParam(i), params[i]);
}
for (int i = 0; i < FLAG_MAX; i++) {
set_flag(Flag(i), flags[i]);
- PhysicsServer::get_singleton()->hinge_joint_set_flag(j, PhysicsServer::HingeJointFlag(i), flags[i]);
+ PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HingeJointFlag(i), flags[i]);
}
return j;
}
-HingeJoint::HingeJoint() {
+HingeJoint3D::HingeJoint3D() {
params[PARAM_BIAS] = 0.3;
params[PARAM_LIMIT_UPPER] = Math_PI * 0.5;
@@ -361,36 +361,36 @@ HingeJoint::HingeJoint() {
//////////////////////////////////
-void SliderJoint::_set_upper_limit_angular(float p_limit_angular) {
+void SliderJoint3D::_set_upper_limit_angular(float p_limit_angular) {
set_param(PARAM_ANGULAR_LIMIT_UPPER, Math::deg2rad(p_limit_angular));
}
-float SliderJoint::_get_upper_limit_angular() const {
+float SliderJoint3D::_get_upper_limit_angular() const {
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_UPPER));
}
-void SliderJoint::_set_lower_limit_angular(float p_limit_angular) {
+void SliderJoint3D::_set_lower_limit_angular(float p_limit_angular) {
set_param(PARAM_ANGULAR_LIMIT_LOWER, Math::deg2rad(p_limit_angular));
}
-float SliderJoint::_get_lower_limit_angular() const {
+float SliderJoint3D::_get_lower_limit_angular() const {
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_LOWER));
}
-void SliderJoint::_bind_methods() {
+void SliderJoint3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &SliderJoint::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &SliderJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &SliderJoint3D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &SliderJoint3D::get_param);
- ClassDB::bind_method(D_METHOD("_set_upper_limit_angular", "upper_limit_angular"), &SliderJoint::_set_upper_limit_angular);
- ClassDB::bind_method(D_METHOD("_get_upper_limit_angular"), &SliderJoint::_get_upper_limit_angular);
+ ClassDB::bind_method(D_METHOD("_set_upper_limit_angular", "upper_limit_angular"), &SliderJoint3D::_set_upper_limit_angular);
+ ClassDB::bind_method(D_METHOD("_get_upper_limit_angular"), &SliderJoint3D::_get_upper_limit_angular);
- ClassDB::bind_method(D_METHOD("_set_lower_limit_angular", "lower_limit_angular"), &SliderJoint::_set_lower_limit_angular);
- ClassDB::bind_method(D_METHOD("_get_lower_limit_angular"), &SliderJoint::_get_lower_limit_angular);
+ ClassDB::bind_method(D_METHOD("_set_lower_limit_angular", "lower_limit_angular"), &SliderJoint3D::_set_lower_limit_angular);
+ ClassDB::bind_method(D_METHOD("_get_lower_limit_angular"), &SliderJoint3D::_get_lower_limit_angular);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/upper_distance", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_UPPER);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/lower_distance", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_LOWER);
@@ -443,21 +443,21 @@ void SliderJoint::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_MAX);
}
-void SliderJoint::set_param(Param p_param, float p_value) {
+void SliderJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer::SliderJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value);
update_gizmo();
}
-float SliderJoint::get_param(Param p_param) const {
+float SliderJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
-RID SliderJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
+RID SliderJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Transform gt = get_global_transform();
Transform ainv = body_a->get_global_transform().affine_inverse();
@@ -473,15 +473,15 @@ RID SliderJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ RID j = PhysicsServer3D::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SliderJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SliderJointParam(i), params[i]);
}
return j;
}
-SliderJoint::SliderJoint() {
+SliderJoint3D::SliderJoint3D() {
params[PARAM_LINEAR_LIMIT_UPPER] = 1.0;
params[PARAM_LINEAR_LIMIT_LOWER] = -1.0;
@@ -510,36 +510,36 @@ SliderJoint::SliderJoint() {
//////////////////////////////////
-void ConeTwistJoint::_set_swing_span(float p_limit_angular) {
+void ConeTwistJoint3D::_set_swing_span(float p_limit_angular) {
set_param(PARAM_SWING_SPAN, Math::deg2rad(p_limit_angular));
}
-float ConeTwistJoint::_get_swing_span() const {
+float ConeTwistJoint3D::_get_swing_span() const {
return Math::rad2deg(get_param(PARAM_SWING_SPAN));
}
-void ConeTwistJoint::_set_twist_span(float p_limit_angular) {
+void ConeTwistJoint3D::_set_twist_span(float p_limit_angular) {
set_param(PARAM_TWIST_SPAN, Math::deg2rad(p_limit_angular));
}
-float ConeTwistJoint::_get_twist_span() const {
+float ConeTwistJoint3D::_get_twist_span() const {
return Math::rad2deg(get_param(PARAM_TWIST_SPAN));
}
-void ConeTwistJoint::_bind_methods() {
+void ConeTwistJoint3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ConeTwistJoint::set_param);
- ClassDB::bind_method(D_METHOD("get_param", "param"), &ConeTwistJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ConeTwistJoint3D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param", "param"), &ConeTwistJoint3D::get_param);
- ClassDB::bind_method(D_METHOD("_set_swing_span", "swing_span"), &ConeTwistJoint::_set_swing_span);
- ClassDB::bind_method(D_METHOD("_get_swing_span"), &ConeTwistJoint::_get_swing_span);
+ ClassDB::bind_method(D_METHOD("_set_swing_span", "swing_span"), &ConeTwistJoint3D::_set_swing_span);
+ ClassDB::bind_method(D_METHOD("_get_swing_span"), &ConeTwistJoint3D::_get_swing_span);
- ClassDB::bind_method(D_METHOD("_set_twist_span", "twist_span"), &ConeTwistJoint::_set_twist_span);
- ClassDB::bind_method(D_METHOD("_get_twist_span"), &ConeTwistJoint::_get_twist_span);
+ ClassDB::bind_method(D_METHOD("_set_twist_span", "twist_span"), &ConeTwistJoint3D::_set_twist_span);
+ ClassDB::bind_method(D_METHOD("_get_twist_span"), &ConeTwistJoint3D::_get_twist_span);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "swing_span", PROPERTY_HINT_RANGE, "-180,180,0.1"), "_set_swing_span", "_get_swing_span");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "twist_span", PROPERTY_HINT_RANGE, "-40000,40000,0.1"), "_set_twist_span", "_get_twist_span");
@@ -556,22 +556,22 @@ void ConeTwistJoint::_bind_methods() {
BIND_ENUM_CONSTANT(PARAM_MAX);
}
-void ConeTwistJoint::set_param(Param p_param, float p_value) {
+void ConeTwistJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer::ConeTwistJointParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
update_gizmo();
}
-float ConeTwistJoint::get_param(Param p_param) const {
+float ConeTwistJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
-RID ConeTwistJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
+RID ConeTwistJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Transform gt = get_global_transform();
//Vector3 cone_twistpos = gt.origin;
@@ -590,15 +590,15 @@ RID ConeTwistJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ RID j = PhysicsServer3D::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::ConeTwistJointParam(i), params[i]);
+ PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::ConeTwistJointParam(i), params[i]);
}
return j;
}
-ConeTwistJoint::ConeTwistJoint() {
+ConeTwistJoint3D::ConeTwistJoint3D() {
params[PARAM_SWING_SPAN] = Math_PI * 0.25;
params[PARAM_TWIST_SPAN] = Math_PI;
@@ -609,106 +609,106 @@ ConeTwistJoint::ConeTwistJoint() {
/////////////////////////////////////////////////////////////////////
-void Generic6DOFJoint::_set_angular_hi_limit_x(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_hi_limit_x(float p_limit_angular) {
set_param_x(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_hi_limit_x() const {
+float Generic6DOFJoint3D::_get_angular_hi_limit_x() const {
return Math::rad2deg(get_param_x(PARAM_ANGULAR_UPPER_LIMIT));
}
-void Generic6DOFJoint::_set_angular_lo_limit_x(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_lo_limit_x(float p_limit_angular) {
set_param_x(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_lo_limit_x() const {
+float Generic6DOFJoint3D::_get_angular_lo_limit_x() const {
return Math::rad2deg(get_param_x(PARAM_ANGULAR_LOWER_LIMIT));
}
-void Generic6DOFJoint::_set_angular_hi_limit_y(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_hi_limit_y(float p_limit_angular) {
set_param_y(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_hi_limit_y() const {
+float Generic6DOFJoint3D::_get_angular_hi_limit_y() const {
return Math::rad2deg(get_param_y(PARAM_ANGULAR_UPPER_LIMIT));
}
-void Generic6DOFJoint::_set_angular_lo_limit_y(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_lo_limit_y(float p_limit_angular) {
set_param_y(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_lo_limit_y() const {
+float Generic6DOFJoint3D::_get_angular_lo_limit_y() const {
return Math::rad2deg(get_param_y(PARAM_ANGULAR_LOWER_LIMIT));
}
-void Generic6DOFJoint::_set_angular_hi_limit_z(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_hi_limit_z(float p_limit_angular) {
set_param_z(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_hi_limit_z() const {
+float Generic6DOFJoint3D::_get_angular_hi_limit_z() const {
return Math::rad2deg(get_param_z(PARAM_ANGULAR_UPPER_LIMIT));
}
-void Generic6DOFJoint::_set_angular_lo_limit_z(float p_limit_angular) {
+void Generic6DOFJoint3D::_set_angular_lo_limit_z(float p_limit_angular) {
set_param_z(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_lo_limit_z() const {
+float Generic6DOFJoint3D::_get_angular_lo_limit_z() const {
return Math::rad2deg(get_param_z(PARAM_ANGULAR_LOWER_LIMIT));
}
-void Generic6DOFJoint::_bind_methods() {
+void Generic6DOFJoint3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_x", "angle"), &Generic6DOFJoint::_set_angular_hi_limit_x);
- ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_x"), &Generic6DOFJoint::_get_angular_hi_limit_x);
+ ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_x", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_x);
+ ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_x"), &Generic6DOFJoint3D::_get_angular_hi_limit_x);
- ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_x", "angle"), &Generic6DOFJoint::_set_angular_lo_limit_x);
- ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_x"), &Generic6DOFJoint::_get_angular_lo_limit_x);
+ ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_x", "angle"), &Generic6DOFJoint3D::_set_angular_lo_limit_x);
+ ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_x"), &Generic6DOFJoint3D::_get_angular_lo_limit_x);
- ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_y", "angle"), &Generic6DOFJoint::_set_angular_hi_limit_y);
- ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_y"), &Generic6DOFJoint::_get_angular_hi_limit_y);
+ ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_y", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_y);
+ ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_y"), &Generic6DOFJoint3D::_get_angular_hi_limit_y);
- ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_y", "angle"), &Generic6DOFJoint::_set_angular_lo_limit_y);
- ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_y"), &Generic6DOFJoint::_get_angular_lo_limit_y);
+ ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_y", "angle"), &Generic6DOFJoint3D::_set_angular_lo_limit_y);
+ ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_y"), &Generic6DOFJoint3D::_get_angular_lo_limit_y);
- ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_z", "angle"), &Generic6DOFJoint::_set_angular_hi_limit_z);
- ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_z"), &Generic6DOFJoint::_get_angular_hi_limit_z);
+ ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_z", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_z);
+ ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_z"), &Generic6DOFJoint3D::_get_angular_hi_limit_z);
- ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_z", "angle"), &Generic6DOFJoint::_set_angular_lo_limit_z);
- ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_z"), &Generic6DOFJoint::_get_angular_lo_limit_z);
+ ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_z", "angle"), &Generic6DOFJoint3D::_set_angular_lo_limit_z);
+ ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_z"), &Generic6DOFJoint3D::_get_angular_lo_limit_z);
- ClassDB::bind_method(D_METHOD("set_param_x", "param", "value"), &Generic6DOFJoint::set_param_x);
- ClassDB::bind_method(D_METHOD("get_param_x", "param"), &Generic6DOFJoint::get_param_x);
+ ClassDB::bind_method(D_METHOD("set_param_x", "param", "value"), &Generic6DOFJoint3D::set_param_x);
+ ClassDB::bind_method(D_METHOD("get_param_x", "param"), &Generic6DOFJoint3D::get_param_x);
- ClassDB::bind_method(D_METHOD("set_param_y", "param", "value"), &Generic6DOFJoint::set_param_y);
- ClassDB::bind_method(D_METHOD("get_param_y", "param"), &Generic6DOFJoint::get_param_y);
+ ClassDB::bind_method(D_METHOD("set_param_y", "param", "value"), &Generic6DOFJoint3D::set_param_y);
+ ClassDB::bind_method(D_METHOD("get_param_y", "param"), &Generic6DOFJoint3D::get_param_y);
- ClassDB::bind_method(D_METHOD("set_param_z", "param", "value"), &Generic6DOFJoint::set_param_z);
- ClassDB::bind_method(D_METHOD("get_param_z", "param"), &Generic6DOFJoint::get_param_z);
+ ClassDB::bind_method(D_METHOD("set_param_z", "param", "value"), &Generic6DOFJoint3D::set_param_z);
+ ClassDB::bind_method(D_METHOD("get_param_z", "param"), &Generic6DOFJoint3D::get_param_z);
- ClassDB::bind_method(D_METHOD("set_flag_x", "flag", "value"), &Generic6DOFJoint::set_flag_x);
- ClassDB::bind_method(D_METHOD("get_flag_x", "flag"), &Generic6DOFJoint::get_flag_x);
+ ClassDB::bind_method(D_METHOD("set_flag_x", "flag", "value"), &Generic6DOFJoint3D::set_flag_x);
+ ClassDB::bind_method(D_METHOD("get_flag_x", "flag"), &Generic6DOFJoint3D::get_flag_x);
- ClassDB::bind_method(D_METHOD("set_flag_y", "flag", "value"), &Generic6DOFJoint::set_flag_y);
- ClassDB::bind_method(D_METHOD("get_flag_y", "flag"), &Generic6DOFJoint::get_flag_y);
+ ClassDB::bind_method(D_METHOD("set_flag_y", "flag", "value"), &Generic6DOFJoint3D::set_flag_y);
+ ClassDB::bind_method(D_METHOD("get_flag_y", "flag"), &Generic6DOFJoint3D::get_flag_y);
- ClassDB::bind_method(D_METHOD("set_flag_z", "flag", "value"), &Generic6DOFJoint::set_flag_z);
- ClassDB::bind_method(D_METHOD("get_flag_z", "flag"), &Generic6DOFJoint::get_flag_z);
+ ClassDB::bind_method(D_METHOD("set_flag_z", "flag", "value"), &Generic6DOFJoint3D::set_flag_z);
+ ClassDB::bind_method(D_METHOD("get_flag_z", "flag"), &Generic6DOFJoint3D::get_flag_z);
- ClassDB::bind_method(D_METHOD("set_precision", "precision"), &Generic6DOFJoint::set_precision);
- ClassDB::bind_method(D_METHOD("get_precision"), &Generic6DOFJoint::get_precision);
+ ClassDB::bind_method(D_METHOD("set_precision", "precision"), &Generic6DOFJoint3D::set_precision);
+ ClassDB::bind_method(D_METHOD("get_precision"), &Generic6DOFJoint3D::get_precision);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_LINEAR_LIMIT);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_x/upper_distance"), "set_param_x", "get_param_x", PARAM_LINEAR_UPPER_LIMIT);
@@ -827,100 +827,100 @@ void Generic6DOFJoint::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
}
-void Generic6DOFJoint::set_param_x(Param p_param, float p_value) {
+void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_x[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
update_gizmo();
}
-float Generic6DOFJoint::get_param_x(Param p_param) const {
+float Generic6DOFJoint3D::get_param_x(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_x[p_param];
}
-void Generic6DOFJoint::set_param_y(Param p_param, float p_value) {
+void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_y[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
update_gizmo();
}
-float Generic6DOFJoint::get_param_y(Param p_param) const {
+float Generic6DOFJoint3D::get_param_y(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_y[p_param];
}
-void Generic6DOFJoint::set_param_z(Param p_param, float p_value) {
+void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_z[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisParam(p_param), p_value);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
update_gizmo();
}
-float Generic6DOFJoint::get_param_z(Param p_param) const {
+float Generic6DOFJoint3D::get_param_z(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_z[p_param];
}
-void Generic6DOFJoint::set_flag_x(Flag p_flag, bool p_enabled) {
+void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_x[p_flag] = p_enabled;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
update_gizmo();
}
-bool Generic6DOFJoint::get_flag_x(Flag p_flag) const {
+bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_x[p_flag];
}
-void Generic6DOFJoint::set_flag_y(Flag p_flag, bool p_enabled) {
+void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_y[p_flag] = p_enabled;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
update_gizmo();
}
-bool Generic6DOFJoint::get_flag_y(Flag p_flag) const {
+bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_y[p_flag];
}
-void Generic6DOFJoint::set_flag_z(Flag p_flag, bool p_enabled) {
+void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_z[p_flag] = p_enabled;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
update_gizmo();
}
-bool Generic6DOFJoint::get_flag_z(Flag p_flag) const {
+bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_z[p_flag];
}
-void Generic6DOFJoint::set_precision(int p_precision) {
+void Generic6DOFJoint3D::set_precision(int p_precision) {
precision = p_precision;
- PhysicsServer::get_singleton()->generic_6dof_joint_set_precision(
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_precision(
get_joint(),
precision);
}
-RID Generic6DOFJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
+RID Generic6DOFJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Transform gt = get_global_transform();
//Vector3 cone_twistpos = gt.origin;
@@ -939,22 +939,22 @@ RID Generic6DOFJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b)
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ RID j = PhysicsServer3D::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < PARAM_MAX; i++) {
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisParam(i), params_x[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisParam(i), params_y[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisParam(i), params_z[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(i), params_x[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(i), params_y[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(i), params_z[i]);
}
for (int i = 0; i < FLAG_MAX; i++) {
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisFlag(i), flags_x[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisFlag(i), flags_y[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisFlag(i), flags_z[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_x[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_y[i]);
+ PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_z[i]);
}
return j;
}
-Generic6DOFJoint::Generic6DOFJoint() :
+Generic6DOFJoint3D::Generic6DOFJoint3D() :
precision(1) {
set_param_x(PARAM_LINEAR_LOWER_LIMIT, 0);
diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h
new file mode 100644
index 0000000000..ce0c7af5d1
--- /dev/null
+++ b/scene/3d/physics_joint_3d.h
@@ -0,0 +1,343 @@
+/*************************************************************************/
+/* physics_joint_3d.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef PHYSICS_JOINT_H
+#define PHYSICS_JOINT_H
+
+#include "scene/3d/node_3d.h"
+#include "scene/3d/physics_body_3d.h"
+
+class Joint3D : public Node3D {
+
+ GDCLASS(Joint3D, Node3D);
+
+ RID ba, bb;
+
+ RID joint;
+
+ NodePath a;
+ NodePath b;
+
+ int solver_priority;
+ bool exclude_from_collision;
+
+protected:
+ void _update_joint(bool p_only_free = false);
+
+ void _notification(int p_what);
+
+ virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) = 0;
+
+ static void _bind_methods();
+
+public:
+ void set_node_a(const NodePath &p_node_a);
+ NodePath get_node_a() const;
+
+ void set_node_b(const NodePath &p_node_b);
+ NodePath get_node_b() const;
+
+ void set_solver_priority(int p_priority);
+ int get_solver_priority() const;
+
+ void set_exclude_nodes_from_collision(bool p_enable);
+ bool get_exclude_nodes_from_collision() const;
+
+ RID get_joint() const { return joint; }
+ Joint3D();
+};
+
+///////////////////////////////////////////
+
+class PinJoint3D : public Joint3D {
+
+ GDCLASS(PinJoint3D, Joint3D);
+
+public:
+ enum Param {
+ PARAM_BIAS = PhysicsServer3D::PIN_JOINT_BIAS,
+ PARAM_DAMPING = PhysicsServer3D::PIN_JOINT_DAMPING,
+ PARAM_IMPULSE_CLAMP = PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP
+ };
+
+protected:
+ float params[3];
+ virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b);
+ static void _bind_methods();
+
+public:
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
+
+ PinJoint3D();
+};
+
+VARIANT_ENUM_CAST(PinJoint3D::Param);
+
+class HingeJoint3D : public Joint3D {
+
+ GDCLASS(HingeJoint3D, Joint3D);
+
+public:
+ enum Param {
+ PARAM_BIAS = PhysicsServer3D::HINGE_JOINT_BIAS,
+ PARAM_LIMIT_UPPER = PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER,
+ PARAM_LIMIT_LOWER = PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER,
+ PARAM_LIMIT_BIAS = PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS,
+ PARAM_LIMIT_SOFTNESS = PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS,
+ PARAM_LIMIT_RELAXATION = PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION,
+ PARAM_MOTOR_TARGET_VELOCITY = PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY,
+ PARAM_MOTOR_MAX_IMPULSE = PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE,
+ PARAM_MAX = PhysicsServer3D::HINGE_JOINT_MAX
+ };
+
+ enum Flag {
+ FLAG_USE_LIMIT = PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT,
+ FLAG_ENABLE_MOTOR = PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR,
+ FLAG_MAX = PhysicsServer3D::HINGE_JOINT_FLAG_MAX
+ };
+
+protected:
+ float params[PARAM_MAX];
+ bool flags[FLAG_MAX];
+ virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b);
+ static void _bind_methods();
+
+ void _set_upper_limit(float p_limit);
+ float _get_upper_limit() const;
+
+ void _set_lower_limit(float p_limit);
+ float _get_lower_limit() const;
+
+public:
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
+
+ void set_flag(Flag p_flag, bool p_value);
+ bool get_flag(Flag p_flag) const;
+
+ HingeJoint3D();
+};
+
+VARIANT_ENUM_CAST(HingeJoint3D::Param);
+VARIANT_ENUM_CAST(HingeJoint3D::Flag);
+
+class SliderJoint3D : public Joint3D {
+
+ GDCLASS(SliderJoint3D, Joint3D);
+
+public:
+ enum Param {
+ PARAM_LINEAR_LIMIT_UPPER = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER,
+ PARAM_LINEAR_LIMIT_LOWER = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER,
+ PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
+ PARAM_LINEAR_LIMIT_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
+ PARAM_LINEAR_LIMIT_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
+ PARAM_LINEAR_MOTION_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
+ PARAM_LINEAR_MOTION_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
+ PARAM_LINEAR_MOTION_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING,
+ PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
+ PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
+ PARAM_LINEAR_ORTHOGONAL_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
+
+ PARAM_ANGULAR_LIMIT_UPPER = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
+ PARAM_ANGULAR_LIMIT_LOWER = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
+ PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ PARAM_ANGULAR_LIMIT_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
+ PARAM_ANGULAR_LIMIT_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
+ PARAM_ANGULAR_MOTION_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
+ PARAM_ANGULAR_MOTION_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
+ PARAM_ANGULAR_MOTION_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
+ PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
+ PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
+ PARAM_ANGULAR_ORTHOGONAL_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
+ PARAM_MAX = PhysicsServer3D::SLIDER_JOINT_MAX
+
+ };
+
+protected:
+ void _set_upper_limit_angular(float p_limit_angular);
+ float _get_upper_limit_angular() const;
+
+ void _set_lower_limit_angular(float p_limit_angular);
+ float _get_lower_limit_angular() const;
+
+ float params[PARAM_MAX];
+ virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b);
+ static void _bind_methods();
+
+public:
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
+
+ SliderJoint3D();
+};
+
+VARIANT_ENUM_CAST(SliderJoint3D::Param);
+
+class ConeTwistJoint3D : public Joint3D {
+
+ GDCLASS(ConeTwistJoint3D, Joint3D);
+
+public:
+ enum Param {
+
+ PARAM_SWING_SPAN,
+ PARAM_TWIST_SPAN,
+ PARAM_BIAS,
+ PARAM_SOFTNESS,
+ PARAM_RELAXATION,
+ PARAM_MAX
+ };
+
+protected:
+ void _set_swing_span(float p_limit_angular);
+ float _get_swing_span() const;
+
+ void _set_twist_span(float p_limit_angular);
+ float _get_twist_span() const;
+
+ float params[PARAM_MAX];
+ virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b);
+ static void _bind_methods();
+
+public:
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
+
+ ConeTwistJoint3D();
+};
+
+VARIANT_ENUM_CAST(ConeTwistJoint3D::Param);
+
+class Generic6DOFJoint3D : public Joint3D {
+
+ GDCLASS(Generic6DOFJoint3D, Joint3D);
+
+public:
+ enum Param {
+
+ PARAM_LINEAR_LOWER_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT,
+ PARAM_LINEAR_UPPER_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT,
+ PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
+ PARAM_LINEAR_RESTITUTION = PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION,
+ PARAM_LINEAR_DAMPING = PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING,
+ PARAM_LINEAR_MOTOR_TARGET_VELOCITY = PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY,
+ PARAM_LINEAR_MOTOR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT,
+ PARAM_LINEAR_SPRING_STIFFNESS = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS,
+ PARAM_LINEAR_SPRING_DAMPING = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING,
+ PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT,
+ PARAM_ANGULAR_LOWER_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
+ PARAM_ANGULAR_UPPER_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
+ PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ PARAM_ANGULAR_DAMPING = PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING,
+ PARAM_ANGULAR_RESTITUTION = PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION,
+ PARAM_ANGULAR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
+ PARAM_ANGULAR_ERP = PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP,
+ PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
+ PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
+ PARAM_ANGULAR_SPRING_STIFFNESS = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS,
+ PARAM_ANGULAR_SPRING_DAMPING = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING,
+ PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT,
+ PARAM_MAX = PhysicsServer3D::G6DOF_JOINT_MAX,
+ };
+
+ enum Flag {
+ FLAG_ENABLE_LINEAR_LIMIT = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
+ FLAG_ENABLE_ANGULAR_LIMIT = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
+ FLAG_ENABLE_LINEAR_SPRING = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING,
+ FLAG_ENABLE_ANGULAR_SPRING = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING,
+ FLAG_ENABLE_MOTOR = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR,
+ FLAG_ENABLE_LINEAR_MOTOR = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR,
+ FLAG_MAX = PhysicsServer3D::G6DOF_JOINT_FLAG_MAX
+ };
+
+protected:
+ void _set_angular_hi_limit_x(float p_limit_angular);
+ float _get_angular_hi_limit_x() const;
+
+ void _set_angular_hi_limit_y(float p_limit_angular);
+ float _get_angular_hi_limit_y() const;
+
+ void _set_angular_hi_limit_z(float p_limit_angular);
+ float _get_angular_hi_limit_z() const;
+
+ void _set_angular_lo_limit_x(float p_limit_angular);
+ float _get_angular_lo_limit_x() const;
+
+ void _set_angular_lo_limit_y(float p_limit_angular);
+ float _get_angular_lo_limit_y() const;
+
+ void _set_angular_lo_limit_z(float p_limit_angular);
+ float _get_angular_lo_limit_z() const;
+
+ float params_x[PARAM_MAX];
+ bool flags_x[FLAG_MAX];
+ float params_y[PARAM_MAX];
+ bool flags_y[FLAG_MAX];
+ float params_z[PARAM_MAX];
+ bool flags_z[FLAG_MAX];
+
+ int precision;
+
+ virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b);
+ static void _bind_methods();
+
+public:
+ void set_param_x(Param p_param, float p_value);
+ float get_param_x(Param p_param) const;
+
+ void set_param_y(Param p_param, float p_value);
+ float get_param_y(Param p_param) const;
+
+ void set_param_z(Param p_param, float p_value);
+ float get_param_z(Param p_param) const;
+
+ void set_flag_x(Flag p_flag, bool p_enabled);
+ bool get_flag_x(Flag p_flag) const;
+
+ void set_flag_y(Flag p_flag, bool p_enabled);
+ bool get_flag_y(Flag p_flag) const;
+
+ void set_flag_z(Flag p_flag, bool p_enabled);
+ bool get_flag_z(Flag p_flag) const;
+
+ void set_precision(int p_precision);
+ int get_precision() const {
+ return precision;
+ }
+
+ Generic6DOFJoint3D();
+};
+
+VARIANT_ENUM_CAST(Generic6DOFJoint3D::Param);
+VARIANT_ENUM_CAST(Generic6DOFJoint3D::Flag);
+
+#endif // PHYSICS_JOINT_H
diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h
index cd5080c95a..9c806723fb 100644
--- a/scene/3d/position_3d.h
+++ b/scene/3d/position_3d.h
@@ -31,11 +31,11 @@
#ifndef POSITION_3D_H
#define POSITION_3D_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
-class Position3D : public Spatial {
+class Position3D : public Node3D {
- GDCLASS(Position3D, Spatial);
+ GDCLASS(Position3D, Node3D);
public:
Position3D();
diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group_3d.cpp
index 2e1478b1cf..44ffabb655 100644
--- a/scene/3d/proximity_group.cpp
+++ b/scene/3d/proximity_group_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* proximity_group.cpp */
+/* proximity_group_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "proximity_group.h"
+#include "proximity_group_3d.h"
#include "core/math/math_funcs.h"
-void ProximityGroup::clear_groups() {
+void ProximityGroup3D::clear_groups() {
Map<StringName, uint32_t>::Element *E;
@@ -60,7 +60,7 @@ void ProximityGroup::clear_groups() {
};
};
-void ProximityGroup::update_groups() {
+void ProximityGroup3D::update_groups() {
if (grid_radius == Vector3(0, 0, 0))
return;
@@ -76,7 +76,7 @@ void ProximityGroup::update_groups() {
clear_groups();
};
-void ProximityGroup::add_groups(int *p_cell, String p_base, int p_depth) {
+void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) {
p_base = p_base + "|";
if (grid_radius[p_depth] == 0) {
@@ -102,7 +102,7 @@ void ProximityGroup::add_groups(int *p_cell, String p_base, int p_depth) {
};
};
-void ProximityGroup::_new_group(StringName p_name) {
+void ProximityGroup3D::_new_group(StringName p_name) {
const Map<StringName, uint32_t>::Element *E = groups.find(p_name);
if (!E) {
@@ -112,7 +112,7 @@ void ProximityGroup::_new_group(StringName p_name) {
groups[p_name] = group_version;
};
-void ProximityGroup::_notification(int p_what) {
+void ProximityGroup3D::_notification(int p_what) {
switch (p_what) {
@@ -126,7 +126,7 @@ void ProximityGroup::_notification(int p_what) {
};
};
-void ProximityGroup::broadcast(String p_name, Variant p_params) {
+void ProximityGroup3D::broadcast(String p_name, Variant p_params) {
Map<StringName, uint32_t>::Element *E;
E = groups.front();
@@ -137,7 +137,7 @@ void ProximityGroup::broadcast(String p_name, Variant p_params) {
};
};
-void ProximityGroup::_proximity_group_broadcast(String p_name, Variant p_params) {
+void ProximityGroup3D::_proximity_group_broadcast(String p_name, Variant p_params) {
if (dispatch_mode == MODE_PROXY) {
@@ -148,46 +148,46 @@ void ProximityGroup::_proximity_group_broadcast(String p_name, Variant p_params)
};
};
-void ProximityGroup::set_group_name(const String &p_group_name) {
+void ProximityGroup3D::set_group_name(const String &p_group_name) {
group_name = p_group_name;
};
-String ProximityGroup::get_group_name() const {
+String ProximityGroup3D::get_group_name() const {
return group_name;
};
-void ProximityGroup::set_dispatch_mode(DispatchMode p_mode) {
+void ProximityGroup3D::set_dispatch_mode(DispatchMode p_mode) {
dispatch_mode = p_mode;
};
-ProximityGroup::DispatchMode ProximityGroup::get_dispatch_mode() const {
+ProximityGroup3D::DispatchMode ProximityGroup3D::get_dispatch_mode() const {
return dispatch_mode;
};
-void ProximityGroup::set_grid_radius(const Vector3 &p_radius) {
+void ProximityGroup3D::set_grid_radius(const Vector3 &p_radius) {
grid_radius = p_radius;
};
-Vector3 ProximityGroup::get_grid_radius() const {
+Vector3 ProximityGroup3D::get_grid_radius() const {
return grid_radius;
};
-void ProximityGroup::_bind_methods() {
+void ProximityGroup3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_group_name", "name"), &ProximityGroup::set_group_name);
- ClassDB::bind_method(D_METHOD("get_group_name"), &ProximityGroup::get_group_name);
- ClassDB::bind_method(D_METHOD("set_dispatch_mode", "mode"), &ProximityGroup::set_dispatch_mode);
- ClassDB::bind_method(D_METHOD("get_dispatch_mode"), &ProximityGroup::get_dispatch_mode);
- ClassDB::bind_method(D_METHOD("set_grid_radius", "radius"), &ProximityGroup::set_grid_radius);
- ClassDB::bind_method(D_METHOD("get_grid_radius"), &ProximityGroup::get_grid_radius);
- ClassDB::bind_method(D_METHOD("broadcast", "name", "parameters"), &ProximityGroup::broadcast);
- ClassDB::bind_method(D_METHOD("_proximity_group_broadcast", "name", "params"), &ProximityGroup::_proximity_group_broadcast);
+ ClassDB::bind_method(D_METHOD("set_group_name", "name"), &ProximityGroup3D::set_group_name);
+ ClassDB::bind_method(D_METHOD("get_group_name"), &ProximityGroup3D::get_group_name);
+ ClassDB::bind_method(D_METHOD("set_dispatch_mode", "mode"), &ProximityGroup3D::set_dispatch_mode);
+ ClassDB::bind_method(D_METHOD("get_dispatch_mode"), &ProximityGroup3D::get_dispatch_mode);
+ ClassDB::bind_method(D_METHOD("set_grid_radius", "radius"), &ProximityGroup3D::set_grid_radius);
+ ClassDB::bind_method(D_METHOD("get_grid_radius"), &ProximityGroup3D::get_grid_radius);
+ ClassDB::bind_method(D_METHOD("broadcast", "name", "parameters"), &ProximityGroup3D::broadcast);
+ ClassDB::bind_method(D_METHOD("_proximity_group_broadcast", "name", "params"), &ProximityGroup3D::_proximity_group_broadcast);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "group_name"), "set_group_name", "get_group_name");
ADD_PROPERTY(PropertyInfo(Variant::INT, "dispatch_mode", PROPERTY_HINT_ENUM, "Proxy,Signal"), "set_dispatch_mode", "get_dispatch_mode");
@@ -199,7 +199,7 @@ void ProximityGroup::_bind_methods() {
BIND_ENUM_CONSTANT(MODE_SIGNAL);
};
-ProximityGroup::ProximityGroup() {
+ProximityGroup3D::ProximityGroup3D() {
group_version = 0;
dispatch_mode = MODE_PROXY;
@@ -209,6 +209,6 @@ ProximityGroup::ProximityGroup() {
set_notify_transform(true);
};
-ProximityGroup::~ProximityGroup(){
+ProximityGroup3D::~ProximityGroup3D(){
};
diff --git a/scene/3d/proximity_group.h b/scene/3d/proximity_group_3d.h
index 9ff8853178..751bfbdb52 100644
--- a/scene/3d/proximity_group.h
+++ b/scene/3d/proximity_group_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* proximity_group.h */
+/* proximity_group_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,11 +31,11 @@
#ifndef PROXIMITY_GROUP_H
#define PROXIMITY_GROUP_H
-#include "spatial.h"
+#include "node_3d.h"
-class ProximityGroup : public Spatial {
+class ProximityGroup3D : public Node3D {
- GDCLASS(ProximityGroup, Spatial);
+ GDCLASS(ProximityGroup3D, Node3D);
OBJ_CATEGORY("3D");
public:
@@ -78,10 +78,10 @@ public:
void broadcast(String p_name, Variant p_params);
- ProximityGroup();
- ~ProximityGroup();
+ ProximityGroup3D();
+ ~ProximityGroup3D();
};
-VARIANT_ENUM_CAST(ProximityGroup::DispatchMode);
+VARIANT_ENUM_CAST(ProximityGroup3D::DispatchMode);
#endif
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast_3d.cpp
index f6eb3d954a..d00af3b128 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* ray_cast.cpp */
+/* ray_cast_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "ray_cast.h"
+#include "ray_cast_3d.h"
-#include "collision_object.h"
+#include "collision_object_3d.h"
#include "core/engine.h"
-#include "mesh_instance.h"
-#include "servers/physics_server.h"
+#include "mesh_instance_3d.h"
+#include "servers/physics_server_3d.h"
-void RayCast::set_cast_to(const Vector3 &p_point) {
+void RayCast3D::set_cast_to(const Vector3 &p_point) {
cast_to = p_point;
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
@@ -44,22 +44,22 @@ void RayCast::set_cast_to(const Vector3 &p_point) {
_update_debug_shape();
}
-Vector3 RayCast::get_cast_to() const {
+Vector3 RayCast3D::get_cast_to() const {
return cast_to;
}
-void RayCast::set_collision_mask(uint32_t p_mask) {
+void RayCast3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
}
-uint32_t RayCast::get_collision_mask() const {
+uint32_t RayCast3D::get_collision_mask() const {
return collision_mask;
}
-void RayCast::set_collision_mask_bit(int p_bit, bool p_value) {
+void RayCast3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
@@ -69,16 +69,16 @@ void RayCast::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool RayCast::get_collision_mask_bit(int p_bit) const {
+bool RayCast3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-bool RayCast::is_colliding() const {
+bool RayCast3D::is_colliding() const {
return collided;
}
-Object *RayCast::get_collider() const {
+Object *RayCast3D::get_collider() const {
if (against.is_null())
return NULL;
@@ -86,20 +86,20 @@ Object *RayCast::get_collider() const {
return ObjectDB::get_instance(against);
}
-int RayCast::get_collider_shape() const {
+int RayCast3D::get_collider_shape() const {
return against_shape;
}
-Vector3 RayCast::get_collision_point() const {
+Vector3 RayCast3D::get_collision_point() const {
return collision_point;
}
-Vector3 RayCast::get_collision_normal() const {
+Vector3 RayCast3D::get_collision_normal() const {
return collision_normal;
}
-void RayCast::set_enabled(bool p_enabled) {
+void RayCast3D::set_enabled(bool p_enabled) {
enabled = p_enabled;
update_gizmo();
@@ -117,12 +117,12 @@ void RayCast::set_enabled(bool p_enabled) {
}
}
-bool RayCast::is_enabled() const {
+bool RayCast3D::is_enabled() const {
return enabled;
}
-void RayCast::set_exclude_parent_body(bool p_exclude_parent_body) {
+void RayCast3D::set_exclude_parent_body(bool p_exclude_parent_body) {
if (exclude_parent_body == p_exclude_parent_body)
return;
@@ -132,20 +132,20 @@ void RayCast::set_exclude_parent_body(bool p_exclude_parent_body) {
if (!is_inside_tree())
return;
- if (Object::cast_to<CollisionObject>(get_parent())) {
+ if (Object::cast_to<CollisionObject3D>(get_parent())) {
if (exclude_parent_body)
- exclude.insert(Object::cast_to<CollisionObject>(get_parent())->get_rid());
+ exclude.insert(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
else
- exclude.erase(Object::cast_to<CollisionObject>(get_parent())->get_rid());
+ exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
}
}
-bool RayCast::get_exclude_parent_body() const {
+bool RayCast3D::get_exclude_parent_body() const {
return exclude_parent_body;
}
-void RayCast::_notification(int p_what) {
+void RayCast3D::_notification(int p_what) {
switch (p_what) {
@@ -159,11 +159,11 @@ void RayCast::_notification(int p_what) {
} else
set_physics_process_internal(false);
- if (Object::cast_to<CollisionObject>(get_parent())) {
+ if (Object::cast_to<CollisionObject3D>(get_parent())) {
if (exclude_parent_body)
- exclude.insert(Object::cast_to<CollisionObject>(get_parent())->get_rid());
+ exclude.insert(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
else
- exclude.erase(Object::cast_to<CollisionObject>(get_parent())->get_rid());
+ exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
}
} break;
@@ -195,11 +195,11 @@ void RayCast::_notification(int p_what) {
}
}
-void RayCast::_update_raycast_state() {
- Ref<World> w3d = get_world();
+void RayCast3D::_update_raycast_state() {
+ Ref<World3D> w3d = get_world();
ERR_FAIL_COND(w3d.is_null());
- PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
+ PhysicsDirectSpaceState3D *dss = PhysicsServer3D::get_singleton()->space_get_direct_state(w3d->get_space());
ERR_FAIL_COND(!dss);
Transform gt = get_global_transform();
@@ -208,7 +208,7 @@ void RayCast::_update_raycast_state() {
if (to == Vector3())
to = Vector3(0, 0.01, 0);
- PhysicsDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState3D::RayResult rr;
if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) {
@@ -224,101 +224,101 @@ void RayCast::_update_raycast_state() {
}
}
-void RayCast::force_raycast_update() {
+void RayCast3D::force_raycast_update() {
_update_raycast_state();
}
-void RayCast::add_exception_rid(const RID &p_rid) {
+void RayCast3D::add_exception_rid(const RID &p_rid) {
exclude.insert(p_rid);
}
-void RayCast::add_exception(const Object *p_object) {
+void RayCast3D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
+ const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
if (!co)
return;
add_exception_rid(co->get_rid());
}
-void RayCast::remove_exception_rid(const RID &p_rid) {
+void RayCast3D::remove_exception_rid(const RID &p_rid) {
exclude.erase(p_rid);
}
-void RayCast::remove_exception(const Object *p_object) {
+void RayCast3D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
+ const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
if (!co)
return;
remove_exception_rid(co->get_rid());
}
-void RayCast::clear_exceptions() {
+void RayCast3D::clear_exceptions() {
exclude.clear();
}
-void RayCast::set_collide_with_areas(bool p_clip) {
+void RayCast3D::set_collide_with_areas(bool p_clip) {
collide_with_areas = p_clip;
}
-bool RayCast::is_collide_with_areas_enabled() const {
+bool RayCast3D::is_collide_with_areas_enabled() const {
return collide_with_areas;
}
-void RayCast::set_collide_with_bodies(bool p_clip) {
+void RayCast3D::set_collide_with_bodies(bool p_clip) {
collide_with_bodies = p_clip;
}
-bool RayCast::is_collide_with_bodies_enabled() const {
+bool RayCast3D::is_collide_with_bodies_enabled() const {
return collide_with_bodies;
}
-void RayCast::_bind_methods() {
+void RayCast3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &RayCast::set_enabled);
- ClassDB::bind_method(D_METHOD("is_enabled"), &RayCast::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &RayCast3D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"), &RayCast3D::is_enabled);
- ClassDB::bind_method(D_METHOD("set_cast_to", "local_point"), &RayCast::set_cast_to);
- ClassDB::bind_method(D_METHOD("get_cast_to"), &RayCast::get_cast_to);
+ ClassDB::bind_method(D_METHOD("set_cast_to", "local_point"), &RayCast3D::set_cast_to);
+ ClassDB::bind_method(D_METHOD("get_cast_to"), &RayCast3D::get_cast_to);
- ClassDB::bind_method(D_METHOD("is_colliding"), &RayCast::is_colliding);
- ClassDB::bind_method(D_METHOD("force_raycast_update"), &RayCast::force_raycast_update);
+ ClassDB::bind_method(D_METHOD("is_colliding"), &RayCast3D::is_colliding);
+ ClassDB::bind_method(D_METHOD("force_raycast_update"), &RayCast3D::force_raycast_update);
- ClassDB::bind_method(D_METHOD("get_collider"), &RayCast::get_collider);
- ClassDB::bind_method(D_METHOD("get_collider_shape"), &RayCast::get_collider_shape);
- ClassDB::bind_method(D_METHOD("get_collision_point"), &RayCast::get_collision_point);
- ClassDB::bind_method(D_METHOD("get_collision_normal"), &RayCast::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider"), &RayCast3D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &RayCast3D::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_point"), &RayCast3D::get_collision_point);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"), &RayCast3D::get_collision_normal);
- ClassDB::bind_method(D_METHOD("add_exception_rid", "rid"), &RayCast::add_exception_rid);
- ClassDB::bind_method(D_METHOD("add_exception", "node"), &RayCast::add_exception);
+ ClassDB::bind_method(D_METHOD("add_exception_rid", "rid"), &RayCast3D::add_exception_rid);
+ ClassDB::bind_method(D_METHOD("add_exception", "node"), &RayCast3D::add_exception);
- ClassDB::bind_method(D_METHOD("remove_exception_rid", "rid"), &RayCast::remove_exception_rid);
- ClassDB::bind_method(D_METHOD("remove_exception", "node"), &RayCast::remove_exception);
+ ClassDB::bind_method(D_METHOD("remove_exception_rid", "rid"), &RayCast3D::remove_exception_rid);
+ ClassDB::bind_method(D_METHOD("remove_exception", "node"), &RayCast3D::remove_exception);
- ClassDB::bind_method(D_METHOD("clear_exceptions"), &RayCast::clear_exceptions);
+ ClassDB::bind_method(D_METHOD("clear_exceptions"), &RayCast3D::clear_exceptions);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("set_exclude_parent_body", "mask"), &RayCast::set_exclude_parent_body);
- ClassDB::bind_method(D_METHOD("get_exclude_parent_body"), &RayCast::get_exclude_parent_body);
+ ClassDB::bind_method(D_METHOD("set_exclude_parent_body", "mask"), &RayCast3D::set_exclude_parent_body);
+ ClassDB::bind_method(D_METHOD("get_exclude_parent_body"), &RayCast3D::get_exclude_parent_body);
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &RayCast::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &RayCast::is_collide_with_areas_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &RayCast3D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &RayCast3D::is_collide_with_areas_enabled);
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &RayCast::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &RayCast::is_collide_with_bodies_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &RayCast3D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &RayCast3D::is_collide_with_bodies_enabled);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclude_parent"), "set_exclude_parent_body", "get_exclude_parent_body");
@@ -330,7 +330,7 @@ void RayCast::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collide_with_bodies", "is_collide_with_bodies_enabled");
}
-void RayCast::_create_debug_shape() {
+void RayCast3D::_create_debug_shape() {
if (!debug_material.is_valid()) {
debug_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
@@ -342,14 +342,14 @@ void RayCast::_create_debug_shape() {
Ref<ArrayMesh> mesh = memnew(ArrayMesh);
- MeshInstance *mi = memnew(MeshInstance);
+ MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(mesh);
add_child(mi);
debug_shape = mi;
}
-void RayCast::_update_debug_shape() {
+void RayCast3D::_update_debug_shape() {
if (!enabled)
return;
@@ -357,7 +357,7 @@ void RayCast::_update_debug_shape() {
if (!debug_shape)
_create_debug_shape();
- MeshInstance *mi = static_cast<MeshInstance *>(debug_shape);
+ MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape);
if (!mi->get_mesh().is_valid())
return;
@@ -376,12 +376,12 @@ void RayCast::_update_debug_shape() {
mesh->surface_set_material(0, debug_material);
}
-void RayCast::_clear_debug_shape() {
+void RayCast3D::_clear_debug_shape() {
if (!debug_shape)
return;
- MeshInstance *mi = static_cast<MeshInstance *>(debug_shape);
+ MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape);
if (mi->is_inside_tree())
mi->queue_delete();
else
@@ -390,7 +390,7 @@ void RayCast::_clear_debug_shape() {
debug_shape = NULL;
}
-RayCast::RayCast() {
+RayCast3D::RayCast3D() {
enabled = false;
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast_3d.h
index 5cebfe3ac2..f8bfb7846a 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* ray_cast.h */
+/* ray_cast_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef RAY_CAST_H
-#define RAY_CAST_H
+#ifndef RAY_CAST_3D_H
+#define RAY_CAST_3D_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
-class RayCast : public Spatial {
+class RayCast3D : public Node3D {
- GDCLASS(RayCast, Spatial);
+ GDCLASS(RayCast3D, Node3D);
bool enabled;
bool collided;
@@ -100,7 +100,7 @@ public:
void remove_exception(const Object *p_object);
void clear_exceptions();
- RayCast();
+ RayCast3D();
};
#endif // RAY_CAST_H
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 3cf8e43ec2..24bf8b43d1 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -33,7 +33,7 @@
void ReflectionProbe::set_intensity(float p_intensity) {
intensity = p_intensity;
- VS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity);
+ RS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity);
}
float ReflectionProbe::get_intensity() const {
@@ -44,12 +44,12 @@ float ReflectionProbe::get_intensity() const {
void ReflectionProbe::set_interior_ambient(Color p_ambient) {
interior_ambient = p_ambient;
- VS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient);
+ RS::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);
+ RS::get_singleton()->reflection_probe_set_interior_ambient_energy(probe, p_energy);
}
float ReflectionProbe::get_interior_ambient_energy() const {
@@ -64,7 +64,7 @@ Color ReflectionProbe::get_interior_ambient() const {
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);
+ RS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution);
}
float ReflectionProbe::get_interior_ambient_probe_contribution() const {
@@ -75,7 +75,7 @@ float ReflectionProbe::get_interior_ambient_probe_contribution() const {
void ReflectionProbe::set_max_distance(float p_distance) {
max_distance = p_distance;
- VS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance);
+ RS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance);
}
float ReflectionProbe::get_max_distance() const {
@@ -97,8 +97,8 @@ void ReflectionProbe::set_extents(const Vector3 &p_extents) {
}
}
- VS::get_singleton()->reflection_probe_set_extents(probe, extents);
- VS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
+ RS::get_singleton()->reflection_probe_set_extents(probe, extents);
+ RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
_change_notify("extents");
update_gizmo();
}
@@ -117,8 +117,8 @@ void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) {
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);
+ RS::get_singleton()->reflection_probe_set_extents(probe, extents);
+ RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset);
_change_notify("origin_offset");
update_gizmo();
@@ -131,7 +131,7 @@ Vector3 ReflectionProbe::get_origin_offset() const {
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);
+ RS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable);
}
bool ReflectionProbe::is_box_projection_enabled() const {
@@ -141,7 +141,7 @@ bool ReflectionProbe::is_box_projection_enabled() const {
void ReflectionProbe::set_as_interior(bool p_enable) {
interior = p_enable;
- VS::get_singleton()->reflection_probe_set_as_interior(probe, interior);
+ RS::get_singleton()->reflection_probe_set_as_interior(probe, interior);
_change_notify();
}
@@ -153,7 +153,7 @@ bool ReflectionProbe::is_set_as_interior() const {
void ReflectionProbe::set_enable_shadows(bool p_enable) {
enable_shadows = p_enable;
- VS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable);
+ RS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable);
}
bool ReflectionProbe::are_shadows_enabled() const {
@@ -163,7 +163,7 @@ bool ReflectionProbe::are_shadows_enabled() const {
void ReflectionProbe::set_cull_mask(uint32_t p_layers) {
cull_mask = p_layers;
- VS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
+ RS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
}
uint32_t ReflectionProbe::get_cull_mask() const {
@@ -172,7 +172,7 @@ uint32_t ReflectionProbe::get_cull_mask() const {
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));
+ RS::get_singleton()->reflection_probe_set_update_mode(probe, RS::ReflectionProbeUpdateMode(p_mode));
}
ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
@@ -272,12 +272,12 @@ ReflectionProbe::ReflectionProbe() {
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);
+ probe = RenderingServer::get_singleton()->reflection_probe_create();
+ RS::get_singleton()->instance_set_base(get_instance(), probe);
set_disable_scale(true);
}
ReflectionProbe::~ReflectionProbe() {
- VS::get_singleton()->free(probe);
+ RS::get_singleton()->free(probe);
}
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index 57c1b0a320..3867d13435 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -31,13 +31,13 @@
#ifndef REFLECTIONPROBE_H
#define REFLECTIONPROBE_H
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/sky.h"
#include "scene/resources/texture.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
-class ReflectionProbe : public VisualInstance {
- GDCLASS(ReflectionProbe, VisualInstance);
+class ReflectionProbe : public VisualInstance3D {
+ GDCLASS(ReflectionProbe, VisualInstance3D);
public:
enum UpdateMode {
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform_3d.cpp
index 9ef43647ba..38792bbb58 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* remote_transform.cpp */
+/* remote_transform_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,9 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "remote_transform.h"
+#include "remote_transform_3d.h"
-void RemoteTransform::_update_cache() {
+void RemoteTransform3D::_update_cache() {
cache = ObjectID();
if (has_node(remote_node)) {
Node *node = get_node(remote_node);
@@ -42,7 +42,7 @@ void RemoteTransform::_update_cache() {
}
}
-void RemoteTransform::_update_remote() {
+void RemoteTransform3D::_update_remote() {
if (!is_inside_tree())
return;
@@ -50,7 +50,7 @@ void RemoteTransform::_update_remote() {
if (cache.is_null())
return;
- Spatial *n = Object::cast_to<Spatial>(ObjectDB::get_instance(cache));
+ Node3D *n = Object::cast_to<Node3D>(ObjectDB::get_instance(cache));
if (!n)
return;
@@ -101,7 +101,7 @@ void RemoteTransform::_update_remote() {
}
}
-void RemoteTransform::_notification(int p_what) {
+void RemoteTransform3D::_notification(int p_what) {
switch (p_what) {
@@ -123,7 +123,7 @@ void RemoteTransform::_notification(int p_what) {
}
}
-void RemoteTransform::set_remote_node(const NodePath &p_remote_node) {
+void RemoteTransform3D::set_remote_node(const NodePath &p_remote_node) {
remote_node = p_remote_node;
if (is_inside_tree()) {
@@ -134,76 +134,76 @@ void RemoteTransform::set_remote_node(const NodePath &p_remote_node) {
update_configuration_warning();
}
-NodePath RemoteTransform::get_remote_node() const {
+NodePath RemoteTransform3D::get_remote_node() const {
return remote_node;
}
-void RemoteTransform::set_use_global_coordinates(const bool p_enable) {
+void RemoteTransform3D::set_use_global_coordinates(const bool p_enable) {
use_global_coordinates = p_enable;
}
-bool RemoteTransform::get_use_global_coordinates() const {
+bool RemoteTransform3D::get_use_global_coordinates() const {
return use_global_coordinates;
}
-void RemoteTransform::set_update_position(const bool p_update) {
+void RemoteTransform3D::set_update_position(const bool p_update) {
update_remote_position = p_update;
_update_remote();
}
-bool RemoteTransform::get_update_position() const {
+bool RemoteTransform3D::get_update_position() const {
return update_remote_position;
}
-void RemoteTransform::set_update_rotation(const bool p_update) {
+void RemoteTransform3D::set_update_rotation(const bool p_update) {
update_remote_rotation = p_update;
_update_remote();
}
-bool RemoteTransform::get_update_rotation() const {
+bool RemoteTransform3D::get_update_rotation() const {
return update_remote_rotation;
}
-void RemoteTransform::set_update_scale(const bool p_update) {
+void RemoteTransform3D::set_update_scale(const bool p_update) {
update_remote_scale = p_update;
_update_remote();
}
-bool RemoteTransform::get_update_scale() const {
+bool RemoteTransform3D::get_update_scale() const {
return update_remote_scale;
}
-void RemoteTransform::force_update_cache() {
+void RemoteTransform3D::force_update_cache() {
_update_cache();
}
-String RemoteTransform::get_configuration_warning() const {
+String RemoteTransform3D::get_configuration_warning() const {
- if (!has_node(remote_node) || !Object::cast_to<Spatial>(get_node(remote_node))) {
- return TTR("The \"Remote Path\" property must point to a valid Spatial or Spatial-derived node to work.");
+ if (!has_node(remote_node) || !Object::cast_to<Node3D>(get_node(remote_node))) {
+ return TTR("The \"Remote Path\" property must point to a valid Node3D or Node3D-derived node to work.");
}
return String();
}
-void RemoteTransform::_bind_methods() {
+void RemoteTransform3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform::set_remote_node);
- ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform::get_remote_node);
- ClassDB::bind_method(D_METHOD("force_update_cache"), &RemoteTransform::force_update_cache);
+ ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform3D::set_remote_node);
+ ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform3D::get_remote_node);
+ ClassDB::bind_method(D_METHOD("force_update_cache"), &RemoteTransform3D::force_update_cache);
- ClassDB::bind_method(D_METHOD("set_use_global_coordinates", "use_global_coordinates"), &RemoteTransform::set_use_global_coordinates);
- ClassDB::bind_method(D_METHOD("get_use_global_coordinates"), &RemoteTransform::get_use_global_coordinates);
+ ClassDB::bind_method(D_METHOD("set_use_global_coordinates", "use_global_coordinates"), &RemoteTransform3D::set_use_global_coordinates);
+ ClassDB::bind_method(D_METHOD("get_use_global_coordinates"), &RemoteTransform3D::get_use_global_coordinates);
- ClassDB::bind_method(D_METHOD("set_update_position", "update_remote_position"), &RemoteTransform::set_update_position);
- ClassDB::bind_method(D_METHOD("get_update_position"), &RemoteTransform::get_update_position);
- ClassDB::bind_method(D_METHOD("set_update_rotation", "update_remote_rotation"), &RemoteTransform::set_update_rotation);
- ClassDB::bind_method(D_METHOD("get_update_rotation"), &RemoteTransform::get_update_rotation);
- ClassDB::bind_method(D_METHOD("set_update_scale", "update_remote_scale"), &RemoteTransform::set_update_scale);
- ClassDB::bind_method(D_METHOD("get_update_scale"), &RemoteTransform::get_update_scale);
+ ClassDB::bind_method(D_METHOD("set_update_position", "update_remote_position"), &RemoteTransform3D::set_update_position);
+ ClassDB::bind_method(D_METHOD("get_update_position"), &RemoteTransform3D::get_update_position);
+ ClassDB::bind_method(D_METHOD("set_update_rotation", "update_remote_rotation"), &RemoteTransform3D::set_update_rotation);
+ ClassDB::bind_method(D_METHOD("get_update_rotation"), &RemoteTransform3D::get_update_rotation);
+ ClassDB::bind_method(D_METHOD("set_update_scale", "update_remote_scale"), &RemoteTransform3D::set_update_scale);
+ ClassDB::bind_method(D_METHOD("get_update_scale"), &RemoteTransform3D::get_update_scale);
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "remote_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Spatial"), "set_remote_node", "get_remote_node");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "remote_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Node3D"), "set_remote_node", "get_remote_node");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_global_coordinates"), "set_use_global_coordinates", "get_use_global_coordinates");
ADD_GROUP("Update", "update_");
@@ -212,7 +212,7 @@ void RemoteTransform::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "update_scale"), "set_update_scale", "get_update_scale");
}
-RemoteTransform::RemoteTransform() {
+RemoteTransform3D::RemoteTransform3D() {
use_global_coordinates = true;
update_remote_position = true;
diff --git a/scene/3d/remote_transform.h b/scene/3d/remote_transform_3d.h
index 02e448832f..50d7c5a9b2 100644
--- a/scene/3d/remote_transform.h
+++ b/scene/3d/remote_transform_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* remote_transform.h */
+/* remote_transform_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,10 +31,10 @@
#ifndef REMOTETRANSFORM_H
#define REMOTETRANSFORM_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
-class RemoteTransform : public Spatial {
- GDCLASS(RemoteTransform, Spatial);
+class RemoteTransform3D : public Node3D {
+ GDCLASS(RemoteTransform3D, Node3D);
NodePath remote_node;
@@ -72,7 +72,7 @@ public:
virtual String get_configuration_warning() const;
- RemoteTransform();
+ RemoteTransform3D();
};
#endif // REMOTETRANSFORM_H
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton_3d.cpp
index b2252bcb04..1b05641c9d 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton.cpp */
+/* skeleton_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "skeleton.h"
+#include "skeleton_3d.h"
#include "core/engine.h"
#include "core/message_queue.h"
#include "core/project_settings.h"
-#include "scene/3d/physics_body.h"
+#include "scene/3d/physics_body_3d.h"
#include "scene/resources/surface_tool.h"
void SkinReference::_skin_changed() {
@@ -62,10 +62,10 @@ SkinReference::~SkinReference() {
skeleton_node->skin_bindings.erase(this);
}
- VS::get_singleton()->free(skeleton);
+ RS::get_singleton()->free(skeleton);
}
-bool Skeleton::_set(const StringName &p_path, const Variant &p_value) {
+bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
@@ -113,7 +113,7 @@ bool Skeleton::_set(const StringName &p_path, const Variant &p_value) {
return true;
}
-bool Skeleton::_get(const StringName &p_path, Variant &r_ret) const {
+bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path;
@@ -154,7 +154,7 @@ bool Skeleton::_get(const StringName &p_path, Variant &r_ret) const {
return true;
}
-void Skeleton::_get_property_list(List<PropertyInfo> *p_list) const {
+void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < bones.size(); i++) {
@@ -168,7 +168,7 @@ void Skeleton::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-void Skeleton::_update_process_order() {
+void Skeleton3D::_update_process_order() {
if (!process_order_dirty)
return;
@@ -221,13 +221,13 @@ void Skeleton::_update_process_order() {
process_order_dirty = false;
}
-void Skeleton::_notification(int p_what) {
+void Skeleton3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_UPDATE_SKELETON: {
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
Bone *bonesptr = bones.ptrw();
int len = bones.size();
@@ -306,7 +306,7 @@ void Skeleton::_notification(int p_what) {
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- Spatial *sp = Object::cast_to<Spatial>(obj);
+ Node3D *sp = Object::cast_to<Node3D>(obj);
ERR_CONTINUE(!sp);
sp->set_transform(b.pose_global);
}
@@ -320,7 +320,7 @@ void Skeleton::_notification(int p_what) {
uint32_t bind_count = skin->get_bind_count();
if (E->get()->bind_count != bind_count) {
- VS::get_singleton()->skeleton_allocate(skeleton, bind_count);
+ RS::get_singleton()->skeleton_allocate(skeleton, bind_count);
E->get()->bind_count = bind_count;
E->get()->skin_bone_indices.resize(bind_count);
E->get()->skin_bone_indices_ptrs = E->get()->skin_bone_indices.ptrw();
@@ -396,7 +396,14 @@ void Skeleton::_notification(int p_what) {
}
}
-void Skeleton::set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent) {
+void Skeleton3D::clear_bones_global_pose_override() {
+ for (int i = 0; i < bones.size(); i += 1) {
+ bones.write[i].global_pose_override_amount = 0;
+ }
+ _make_dirty();
+}
+
+void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent) {
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].global_pose_override_amount = p_amount;
@@ -405,16 +412,16 @@ void Skeleton::set_bone_global_pose_override(int p_bone, const Transform &p_pose
_make_dirty();
}
-Transform Skeleton::get_bone_global_pose(int p_bone) const {
+Transform Skeleton3D::get_bone_global_pose(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
if (dirty)
- const_cast<Skeleton *>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
+ const_cast<Skeleton3D *>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
return bones[p_bone].pose_global;
}
// skeleton creation api
-void Skeleton::add_bone(const String &p_name) {
+void Skeleton3D::add_bone(const String &p_name) {
ERR_FAIL_COND(p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1);
@@ -431,7 +438,7 @@ void Skeleton::add_bone(const String &p_name) {
_make_dirty();
update_gizmo();
}
-int Skeleton::find_bone(const String &p_name) const {
+int Skeleton3D::find_bone(const String &p_name) const {
for (int i = 0; i < bones.size(); i++) {
@@ -441,14 +448,14 @@ int Skeleton::find_bone(const String &p_name) const {
return -1;
}
-String Skeleton::get_bone_name(int p_bone) const {
+String Skeleton3D::get_bone_name(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), "");
return bones[p_bone].name;
}
-bool Skeleton::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {
+bool Skeleton3D::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {
int parent_of_bone = get_bone_parent(p_bone);
@@ -461,12 +468,12 @@ bool Skeleton::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {
return is_bone_parent_of(parent_of_bone, p_parent_bone_id);
}
-int Skeleton::get_bone_count() const {
+int Skeleton3D::get_bone_count() const {
return bones.size();
}
-void Skeleton::set_bone_parent(int p_bone, int p_parent) {
+void Skeleton3D::set_bone_parent(int p_bone, int p_parent) {
ERR_FAIL_INDEX(p_bone, bones.size());
ERR_FAIL_COND(p_parent != -1 && (p_parent < 0));
@@ -476,7 +483,7 @@ void Skeleton::set_bone_parent(int p_bone, int p_parent) {
_make_dirty();
}
-void Skeleton::unparent_bone_and_rest(int p_bone) {
+void Skeleton3D::unparent_bone_and_rest(int p_bone) {
ERR_FAIL_INDEX(p_bone, bones.size());
@@ -494,53 +501,53 @@ void Skeleton::unparent_bone_and_rest(int p_bone) {
_make_dirty();
}
-void Skeleton::set_bone_disable_rest(int p_bone, bool p_disable) {
+void Skeleton3D::set_bone_disable_rest(int p_bone, bool p_disable) {
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].disable_rest = p_disable;
}
-bool Skeleton::is_bone_rest_disabled(int p_bone) const {
+bool Skeleton3D::is_bone_rest_disabled(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), false);
return bones[p_bone].disable_rest;
}
-int Skeleton::get_bone_parent(int p_bone) const {
+int Skeleton3D::get_bone_parent(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), -1);
return bones[p_bone].parent;
}
-void Skeleton::set_bone_rest(int p_bone, const Transform &p_rest) {
+void Skeleton3D::set_bone_rest(int p_bone, const Transform &p_rest) {
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].rest = p_rest;
_make_dirty();
}
-Transform Skeleton::get_bone_rest(int p_bone) const {
+Transform Skeleton3D::get_bone_rest(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].rest;
}
-void Skeleton::set_bone_enabled(int p_bone, bool p_enabled) {
+void Skeleton3D::set_bone_enabled(int p_bone, bool p_enabled) {
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].enabled = p_enabled;
_make_dirty();
}
-bool Skeleton::is_bone_enabled(int p_bone) const {
+bool Skeleton3D::is_bone_enabled(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), false);
return bones[p_bone].enabled;
}
-void Skeleton::bind_child_node_to_bone(int p_bone, Node *p_node) {
+void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX(p_bone, bones.size());
@@ -555,7 +562,7 @@ void Skeleton::bind_child_node_to_bone(int p_bone, Node *p_node) {
bones.write[p_bone].nodes_bound.push_back(id);
}
-void Skeleton::unbind_child_node_from_bone(int p_bone, Node *p_node) {
+void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX(p_bone, bones.size());
@@ -563,7 +570,7 @@ void Skeleton::unbind_child_node_from_bone(int p_bone, Node *p_node) {
ObjectID id = p_node->get_instance_id();
bones.write[p_bone].nodes_bound.erase(id);
}
-void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const {
+void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const {
ERR_FAIL_INDEX(p_bone, bones.size());
@@ -575,7 +582,7 @@ void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound)
}
}
-void Skeleton::clear_bones() {
+void Skeleton3D::clear_bones() {
bones.clear();
process_order_dirty = true;
@@ -585,7 +592,7 @@ void Skeleton::clear_bones() {
// posing api
-void Skeleton::set_bone_pose(int p_bone, const Transform &p_pose) {
+void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) {
ERR_FAIL_INDEX(p_bone, bones.size());
@@ -594,13 +601,13 @@ void Skeleton::set_bone_pose(int p_bone, const Transform &p_pose) {
_make_dirty();
}
}
-Transform Skeleton::get_bone_pose(int p_bone) const {
+Transform Skeleton3D::get_bone_pose(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].pose;
}
-void Skeleton::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose) {
+void Skeleton3D::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() );
@@ -611,13 +618,13 @@ void Skeleton::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose)
_make_dirty();
}
-Transform Skeleton::get_bone_custom_pose(int p_bone) const {
+Transform Skeleton3D::get_bone_custom_pose(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].custom_pose;
}
-void Skeleton::_make_dirty() {
+void Skeleton3D::_make_dirty() {
if (dirty)
return;
@@ -626,13 +633,13 @@ void Skeleton::_make_dirty() {
dirty = true;
}
-int Skeleton::get_process_order(int p_idx) {
+int Skeleton3D::get_process_order(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, bones.size(), -1);
_update_process_order();
return process_order[p_idx];
}
-void Skeleton::localize_rests() {
+void Skeleton3D::localize_rests() {
_update_process_order();
@@ -646,7 +653,7 @@ void Skeleton::localize_rests() {
#ifndef _3D_DISABLED
-void Skeleton::set_animate_physical_bones(bool p_animate) {
+void Skeleton3D::set_animate_physical_bones(bool p_animate) {
animate_physical_bones = p_animate;
if (Engine::get_singleton()->is_editor_hint() == false) {
@@ -663,11 +670,11 @@ void Skeleton::set_animate_physical_bones(bool p_animate) {
}
}
-bool Skeleton::get_animate_physical_bones() const {
+bool Skeleton3D::get_animate_physical_bones() const {
return animate_physical_bones;
}
-void Skeleton::bind_physical_bone_to_bone(int p_bone, PhysicalBone *p_physical_bone) {
+void Skeleton3D::bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physical_bone) {
ERR_FAIL_INDEX(p_bone, bones.size());
ERR_FAIL_COND(bones[p_bone].physical_bone);
ERR_FAIL_COND(!p_physical_bone);
@@ -676,20 +683,20 @@ void Skeleton::bind_physical_bone_to_bone(int p_bone, PhysicalBone *p_physical_b
_rebuild_physical_bones_cache();
}
-void Skeleton::unbind_physical_bone_from_bone(int p_bone) {
+void Skeleton3D::unbind_physical_bone_from_bone(int p_bone) {
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].physical_bone = NULL;
_rebuild_physical_bones_cache();
}
-PhysicalBone *Skeleton::get_physical_bone(int p_bone) {
+PhysicalBone3D *Skeleton3D::get_physical_bone(int p_bone) {
ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL);
return bones[p_bone].physical_bone;
}
-PhysicalBone *Skeleton::get_physical_bone_parent(int p_bone) {
+PhysicalBone3D *Skeleton3D::get_physical_bone_parent(int p_bone) {
ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL);
if (bones[p_bone].cache_parent_physical_bone) {
@@ -699,7 +706,7 @@ PhysicalBone *Skeleton::get_physical_bone_parent(int p_bone) {
return _get_physical_bone_parent(p_bone);
}
-PhysicalBone *Skeleton::_get_physical_bone_parent(int p_bone) {
+PhysicalBone3D *Skeleton3D::_get_physical_bone_parent(int p_bone) {
ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL);
const int parent_bone = bones[p_bone].parent;
@@ -707,7 +714,7 @@ PhysicalBone *Skeleton::_get_physical_bone_parent(int p_bone) {
return NULL;
}
- PhysicalBone *pb = bones[parent_bone].physical_bone;
+ PhysicalBone3D *pb = bones[parent_bone].physical_bone;
if (pb) {
return pb;
} else {
@@ -715,10 +722,10 @@ PhysicalBone *Skeleton::_get_physical_bone_parent(int p_bone) {
}
}
-void Skeleton::_rebuild_physical_bones_cache() {
+void Skeleton3D::_rebuild_physical_bones_cache() {
const int b_size = bones.size();
for (int i = 0; i < b_size; ++i) {
- PhysicalBone *parent_pb = _get_physical_bone_parent(i);
+ PhysicalBone3D *parent_pb = _get_physical_bone_parent(i);
if (parent_pb != bones[i].physical_bone) {
bones.write[i].cache_parent_physical_bone = parent_pb;
if (bones[i].physical_bone)
@@ -733,26 +740,26 @@ void _pb_stop_simulation(Node *p_node) {
_pb_stop_simulation(p_node->get_child(i));
}
- PhysicalBone *pb = Object::cast_to<PhysicalBone>(p_node);
+ PhysicalBone3D *pb = Object::cast_to<PhysicalBone3D>(p_node);
if (pb) {
pb->set_simulate_physics(false);
}
}
-void Skeleton::physical_bones_stop_simulation() {
+void Skeleton3D::physical_bones_stop_simulation() {
_pb_stop_simulation(this);
if (Engine::get_singleton()->is_editor_hint() == false && animate_physical_bones) {
set_physics_process_internal(true);
}
}
-void _pb_start_simulation(const Skeleton *p_skeleton, Node *p_node, const Vector<int> &p_sim_bones) {
+void _pb_start_simulation(const Skeleton3D *p_skeleton, Node *p_node, const Vector<int> &p_sim_bones) {
for (int i = p_node->get_child_count() - 1; 0 <= i; --i) {
_pb_start_simulation(p_skeleton, p_node->get_child(i), p_sim_bones);
}
- PhysicalBone *pb = Object::cast_to<PhysicalBone>(p_node);
+ PhysicalBone3D *pb = Object::cast_to<PhysicalBone3D>(p_node);
if (pb) {
for (int i = p_sim_bones.size() - 1; 0 <= i; --i) {
if (p_sim_bones[i] == pb->get_bone_id() || p_skeleton->is_bone_parent_of(pb->get_bone_id(), p_sim_bones[i])) {
@@ -763,7 +770,7 @@ void _pb_start_simulation(const Skeleton *p_skeleton, Node *p_node, const Vector
}
}
-void Skeleton::physical_bones_start_simulation_on(const Array &p_bones) {
+void Skeleton3D::physical_bones_start_simulation_on(const Array &p_bones) {
set_physics_process_internal(false);
Vector<int> sim_bones;
@@ -792,31 +799,31 @@ void _physical_bones_add_remove_collision_exception(bool p_add, Node *p_node, RI
_physical_bones_add_remove_collision_exception(p_add, p_node->get_child(i), p_exception);
}
- CollisionObject *co = Object::cast_to<CollisionObject>(p_node);
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_node);
if (co) {
if (p_add) {
- PhysicsServer::get_singleton()->body_add_collision_exception(co->get_rid(), p_exception);
+ PhysicsServer3D::get_singleton()->body_add_collision_exception(co->get_rid(), p_exception);
} else {
- PhysicsServer::get_singleton()->body_remove_collision_exception(co->get_rid(), p_exception);
+ PhysicsServer3D::get_singleton()->body_remove_collision_exception(co->get_rid(), p_exception);
}
}
}
-void Skeleton::physical_bones_add_collision_exception(RID p_exception) {
+void Skeleton3D::physical_bones_add_collision_exception(RID p_exception) {
_physical_bones_add_remove_collision_exception(true, this, p_exception);
}
-void Skeleton::physical_bones_remove_collision_exception(RID p_exception) {
+void Skeleton3D::physical_bones_remove_collision_exception(RID p_exception) {
_physical_bones_add_remove_collision_exception(false, this, p_exception);
}
#endif // _3D_DISABLED
-void Skeleton::_skin_changed() {
+void Skeleton3D::_skin_changed() {
_make_dirty();
}
-Ref<SkinReference> Skeleton::register_skin(const Ref<Skin> &p_skin) {
+Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
if (E->get()->skin == p_skin) {
@@ -864,7 +871,7 @@ Ref<SkinReference> Skeleton::register_skin(const Ref<Skin> &p_skin) {
skin_ref->skeleton_node = this;
skin_ref->bind_count = 0;
- skin_ref->skeleton = VisualServer::get_singleton()->skeleton_create();
+ skin_ref->skeleton = RenderingServer::get_singleton()->skeleton_create();
skin_ref->skeleton_node = this;
skin_ref->skin = skin;
@@ -877,53 +884,54 @@ Ref<SkinReference> Skeleton::register_skin(const Ref<Skin> &p_skin) {
return skin_ref;
}
-void Skeleton::_bind_methods() {
+void Skeleton3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton::add_bone);
- ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton::find_bone);
- ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton::get_bone_name);
+ ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton3D::add_bone);
+ ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton3D::find_bone);
+ ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton3D::get_bone_name);
- ClassDB::bind_method(D_METHOD("get_bone_parent", "bone_idx"), &Skeleton::get_bone_parent);
- ClassDB::bind_method(D_METHOD("set_bone_parent", "bone_idx", "parent_idx"), &Skeleton::set_bone_parent);
+ ClassDB::bind_method(D_METHOD("get_bone_parent", "bone_idx"), &Skeleton3D::get_bone_parent);
+ ClassDB::bind_method(D_METHOD("set_bone_parent", "bone_idx", "parent_idx"), &Skeleton3D::set_bone_parent);
- ClassDB::bind_method(D_METHOD("get_bone_count"), &Skeleton::get_bone_count);
+ ClassDB::bind_method(D_METHOD("get_bone_count"), &Skeleton3D::get_bone_count);
- ClassDB::bind_method(D_METHOD("unparent_bone_and_rest", "bone_idx"), &Skeleton::unparent_bone_and_rest);
+ ClassDB::bind_method(D_METHOD("unparent_bone_and_rest", "bone_idx"), &Skeleton3D::unparent_bone_and_rest);
- ClassDB::bind_method(D_METHOD("get_bone_rest", "bone_idx"), &Skeleton::get_bone_rest);
- ClassDB::bind_method(D_METHOD("set_bone_rest", "bone_idx", "rest"), &Skeleton::set_bone_rest);
+ ClassDB::bind_method(D_METHOD("get_bone_rest", "bone_idx"), &Skeleton3D::get_bone_rest);
+ ClassDB::bind_method(D_METHOD("set_bone_rest", "bone_idx", "rest"), &Skeleton3D::set_bone_rest);
- ClassDB::bind_method(D_METHOD("register_skin", "skin"), &Skeleton::register_skin);
+ ClassDB::bind_method(D_METHOD("register_skin", "skin"), &Skeleton3D::register_skin);
- ClassDB::bind_method(D_METHOD("localize_rests"), &Skeleton::localize_rests);
+ ClassDB::bind_method(D_METHOD("localize_rests"), &Skeleton3D::localize_rests);
- ClassDB::bind_method(D_METHOD("set_bone_disable_rest", "bone_idx", "disable"), &Skeleton::set_bone_disable_rest);
- ClassDB::bind_method(D_METHOD("is_bone_rest_disabled", "bone_idx"), &Skeleton::is_bone_rest_disabled);
+ ClassDB::bind_method(D_METHOD("set_bone_disable_rest", "bone_idx", "disable"), &Skeleton3D::set_bone_disable_rest);
+ ClassDB::bind_method(D_METHOD("is_bone_rest_disabled", "bone_idx"), &Skeleton3D::is_bone_rest_disabled);
- ClassDB::bind_method(D_METHOD("bind_child_node_to_bone", "bone_idx", "node"), &Skeleton::bind_child_node_to_bone);
- ClassDB::bind_method(D_METHOD("unbind_child_node_from_bone", "bone_idx", "node"), &Skeleton::unbind_child_node_from_bone);
- ClassDB::bind_method(D_METHOD("get_bound_child_nodes_to_bone", "bone_idx"), &Skeleton::_get_bound_child_nodes_to_bone);
+ ClassDB::bind_method(D_METHOD("bind_child_node_to_bone", "bone_idx", "node"), &Skeleton3D::bind_child_node_to_bone);
+ ClassDB::bind_method(D_METHOD("unbind_child_node_from_bone", "bone_idx", "node"), &Skeleton3D::unbind_child_node_from_bone);
+ ClassDB::bind_method(D_METHOD("get_bound_child_nodes_to_bone", "bone_idx"), &Skeleton3D::_get_bound_child_nodes_to_bone);
- ClassDB::bind_method(D_METHOD("clear_bones"), &Skeleton::clear_bones);
+ ClassDB::bind_method(D_METHOD("clear_bones"), &Skeleton3D::clear_bones);
- ClassDB::bind_method(D_METHOD("get_bone_pose", "bone_idx"), &Skeleton::get_bone_pose);
- ClassDB::bind_method(D_METHOD("set_bone_pose", "bone_idx", "pose"), &Skeleton::set_bone_pose);
+ ClassDB::bind_method(D_METHOD("get_bone_pose", "bone_idx"), &Skeleton3D::get_bone_pose);
+ ClassDB::bind_method(D_METHOD("set_bone_pose", "bone_idx", "pose"), &Skeleton3D::set_bone_pose);
- ClassDB::bind_method(D_METHOD("set_bone_global_pose_override", "bone_idx", "pose", "amount", "persistent"), &Skeleton::set_bone_global_pose_override, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("get_bone_global_pose", "bone_idx"), &Skeleton::get_bone_global_pose);
+ ClassDB::bind_method(D_METHOD("clear_bones_global_pose_override"), &Skeleton3D::clear_bones_global_pose_override);
+ ClassDB::bind_method(D_METHOD("set_bone_global_pose_override", "bone_idx", "pose", "amount", "persistent"), &Skeleton3D::set_bone_global_pose_override, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_bone_global_pose", "bone_idx"), &Skeleton3D::get_bone_global_pose);
- ClassDB::bind_method(D_METHOD("get_bone_custom_pose", "bone_idx"), &Skeleton::get_bone_custom_pose);
- ClassDB::bind_method(D_METHOD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton::set_bone_custom_pose);
+ ClassDB::bind_method(D_METHOD("get_bone_custom_pose", "bone_idx"), &Skeleton3D::get_bone_custom_pose);
+ ClassDB::bind_method(D_METHOD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton3D::set_bone_custom_pose);
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("set_animate_physical_bones"), &Skeleton::set_animate_physical_bones);
- ClassDB::bind_method(D_METHOD("get_animate_physical_bones"), &Skeleton::get_animate_physical_bones);
+ ClassDB::bind_method(D_METHOD("set_animate_physical_bones"), &Skeleton3D::set_animate_physical_bones);
+ ClassDB::bind_method(D_METHOD("get_animate_physical_bones"), &Skeleton3D::get_animate_physical_bones);
- ClassDB::bind_method(D_METHOD("physical_bones_stop_simulation"), &Skeleton::physical_bones_stop_simulation);
- ClassDB::bind_method(D_METHOD("physical_bones_start_simulation", "bones"), &Skeleton::physical_bones_start_simulation_on, DEFVAL(Array()));
- ClassDB::bind_method(D_METHOD("physical_bones_add_collision_exception", "exception"), &Skeleton::physical_bones_add_collision_exception);
- ClassDB::bind_method(D_METHOD("physical_bones_remove_collision_exception", "exception"), &Skeleton::physical_bones_remove_collision_exception);
+ ClassDB::bind_method(D_METHOD("physical_bones_stop_simulation"), &Skeleton3D::physical_bones_stop_simulation);
+ ClassDB::bind_method(D_METHOD("physical_bones_start_simulation", "bones"), &Skeleton3D::physical_bones_start_simulation_on, DEFVAL(Array()));
+ ClassDB::bind_method(D_METHOD("physical_bones_add_collision_exception", "exception"), &Skeleton3D::physical_bones_add_collision_exception);
+ ClassDB::bind_method(D_METHOD("physical_bones_remove_collision_exception", "exception"), &Skeleton3D::physical_bones_remove_collision_exception);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones");
#endif // _3D_DISABLED
@@ -931,7 +939,7 @@ void Skeleton::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON);
}
-Skeleton::Skeleton() {
+Skeleton3D::Skeleton3D() {
animate_physical_bones = true;
dirty = false;
@@ -939,7 +947,7 @@ Skeleton::Skeleton() {
process_order_dirty = true;
}
-Skeleton::~Skeleton() {
+Skeleton3D::~Skeleton3D() {
//some skins may remain bound
for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton_3d.h
index 76fd96f30a..2ae04aa575 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton.h */
+/* skeleton_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,26 +28,26 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SKELETON_H
-#define SKELETON_H
+#ifndef SKELETON_3D_H
+#define SKELETON_3D_H
#include "core/rid.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/skin.h"
#ifndef _3D_DISABLED
typedef int BoneId;
-class PhysicalBone;
+class PhysicalBone3D;
#endif // _3D_DISABLED
-class Skeleton;
+class Skeleton3D;
class SkinReference : public Reference {
GDCLASS(SkinReference, Reference)
- friend class Skeleton;
+ friend class Skeleton3D;
- Skeleton *skeleton_node;
+ Skeleton3D *skeleton_node;
RID skeleton;
Ref<Skin> skin;
uint32_t bind_count = 0;
@@ -65,9 +65,9 @@ public:
~SkinReference();
};
-class Skeleton : public Spatial {
+class Skeleton3D : public Node3D {
- GDCLASS(Skeleton, Spatial);
+ GDCLASS(Skeleton3D, Node3D);
private:
friend class SkinReference;
@@ -98,8 +98,8 @@ private:
Transform global_pose_override;
#ifndef _3D_DISABLED
- PhysicalBone *physical_bone;
- PhysicalBone *cache_parent_physical_bone;
+ PhysicalBone3D *physical_bone;
+ PhysicalBone3D *cache_parent_physical_bone;
#endif // _3D_DISABLED
List<ObjectID> nodes_bound;
@@ -178,6 +178,7 @@ public:
Transform get_bone_rest(int p_bone) const;
Transform get_bone_global_pose(int p_bone) const;
+ void clear_bones_global_pose_override();
void set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent = false);
void set_bone_enabled(int p_bone, bool p_enabled);
@@ -208,15 +209,15 @@ public:
void set_animate_physical_bones(bool p_animate);
bool get_animate_physical_bones() const;
- void bind_physical_bone_to_bone(int p_bone, PhysicalBone *p_physical_bone);
+ void bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physical_bone);
void unbind_physical_bone_from_bone(int p_bone);
- PhysicalBone *get_physical_bone(int p_bone);
- PhysicalBone *get_physical_bone_parent(int p_bone);
+ PhysicalBone3D *get_physical_bone(int p_bone);
+ PhysicalBone3D *get_physical_bone_parent(int p_bone);
private:
/// This is a slow API os it's cached
- PhysicalBone *_get_physical_bone_parent(int p_bone);
+ PhysicalBone3D *_get_physical_bone_parent(int p_bone);
void _rebuild_physical_bones_cache();
public:
@@ -227,8 +228,8 @@ public:
#endif // _3D_DISABLED
public:
- Skeleton();
- ~Skeleton();
+ Skeleton3D();
+ ~Skeleton3D();
};
#endif
diff --git a/scene/animation/skeleton_ik.cpp b/scene/3d/skeleton_ik_3d.cpp
index 5cdb38b5c2..a6c3e25399 100644
--- a/scene/animation/skeleton_ik.cpp
+++ b/scene/3d/skeleton_ik_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton_ik.cpp */
+/* skeleton_ik_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,7 +32,7 @@
* @author AndreaCatania
*/
-#include "skeleton_ik.h"
+#include "skeleton_ik_3d.h"
#ifndef _3D_DISABLED
@@ -136,7 +136,7 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
return true;
}
-void FabrikInverseKinematic::update_chain(const Skeleton *p_sk, ChainItem *p_chain_item) {
+void FabrikInverseKinematic::update_chain(const Skeleton3D *p_sk, ChainItem *p_chain_item) {
if (!p_chain_item)
return;
@@ -144,8 +144,9 @@ void FabrikInverseKinematic::update_chain(const Skeleton *p_sk, ChainItem *p_cha
p_chain_item->initial_transform = p_sk->get_bone_global_pose(p_chain_item->bone);
p_chain_item->current_pos = p_chain_item->initial_transform.origin;
- for (int i = p_chain_item->children.size() - 1; 0 <= i; --i) {
- update_chain(p_sk, &p_chain_item->children.write[i]);
+ ChainItem *items = p_chain_item->children.ptrw();
+ for (int i = 0; i < p_chain_item->children.size(); i += 1) {
+ update_chain(p_sk, items + i);
}
}
@@ -237,7 +238,7 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_
}
}
-FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleton *p_sk, BoneId root_bone, BoneId tip_bone, const Transform &goal_transform) {
+FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleton3D *p_sk, BoneId root_bone, BoneId tip_bone, const Transform &goal_transform) {
FabrikInverseKinematic::EndEffector ee;
ee.tip_bone = tip_bone;
@@ -286,6 +287,8 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
return; // Skip solving
}
+ p_task->skeleton->clear_bones_global_pose_override();
+
make_goal(p_task, p_task->skeleton->get_global_transform().affine_inverse().scaled(p_task->skeleton->get_global_transform().get_basis().get_scale()), blending_delta);
update_chain(p_task->skeleton, &p_task->chain.chain_root);
@@ -329,7 +332,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
}
}
-void SkeletonIK::_validate_property(PropertyInfo &property) const {
+void SkeletonIK3D::_validate_property(PropertyInfo &property) const {
if (property.name == "root_bone" || property.name == "tip_bone") {
@@ -352,43 +355,43 @@ void SkeletonIK::_validate_property(PropertyInfo &property) const {
}
}
-void SkeletonIK::_bind_methods() {
+void SkeletonIK3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_root_bone", "root_bone"), &SkeletonIK::set_root_bone);
- ClassDB::bind_method(D_METHOD("get_root_bone"), &SkeletonIK::get_root_bone);
+ ClassDB::bind_method(D_METHOD("set_root_bone", "root_bone"), &SkeletonIK3D::set_root_bone);
+ ClassDB::bind_method(D_METHOD("get_root_bone"), &SkeletonIK3D::get_root_bone);
- ClassDB::bind_method(D_METHOD("set_tip_bone", "tip_bone"), &SkeletonIK::set_tip_bone);
- ClassDB::bind_method(D_METHOD("get_tip_bone"), &SkeletonIK::get_tip_bone);
+ ClassDB::bind_method(D_METHOD("set_tip_bone", "tip_bone"), &SkeletonIK3D::set_tip_bone);
+ ClassDB::bind_method(D_METHOD("get_tip_bone"), &SkeletonIK3D::get_tip_bone);
- ClassDB::bind_method(D_METHOD("set_interpolation", "interpolation"), &SkeletonIK::set_interpolation);
- ClassDB::bind_method(D_METHOD("get_interpolation"), &SkeletonIK::get_interpolation);
+ ClassDB::bind_method(D_METHOD("set_interpolation", "interpolation"), &SkeletonIK3D::set_interpolation);
+ ClassDB::bind_method(D_METHOD("get_interpolation"), &SkeletonIK3D::get_interpolation);
- ClassDB::bind_method(D_METHOD("set_target_transform", "target"), &SkeletonIK::set_target_transform);
- ClassDB::bind_method(D_METHOD("get_target_transform"), &SkeletonIK::get_target_transform);
+ ClassDB::bind_method(D_METHOD("set_target_transform", "target"), &SkeletonIK3D::set_target_transform);
+ ClassDB::bind_method(D_METHOD("get_target_transform"), &SkeletonIK3D::get_target_transform);
- ClassDB::bind_method(D_METHOD("set_target_node", "node"), &SkeletonIK::set_target_node);
- ClassDB::bind_method(D_METHOD("get_target_node"), &SkeletonIK::get_target_node);
+ ClassDB::bind_method(D_METHOD("set_target_node", "node"), &SkeletonIK3D::set_target_node);
+ ClassDB::bind_method(D_METHOD("get_target_node"), &SkeletonIK3D::get_target_node);
- ClassDB::bind_method(D_METHOD("set_override_tip_basis", "override"), &SkeletonIK::set_override_tip_basis);
- ClassDB::bind_method(D_METHOD("is_override_tip_basis"), &SkeletonIK::is_override_tip_basis);
+ ClassDB::bind_method(D_METHOD("set_override_tip_basis", "override"), &SkeletonIK3D::set_override_tip_basis);
+ ClassDB::bind_method(D_METHOD("is_override_tip_basis"), &SkeletonIK3D::is_override_tip_basis);
- ClassDB::bind_method(D_METHOD("set_use_magnet", "use"), &SkeletonIK::set_use_magnet);
- ClassDB::bind_method(D_METHOD("is_using_magnet"), &SkeletonIK::is_using_magnet);
+ ClassDB::bind_method(D_METHOD("set_use_magnet", "use"), &SkeletonIK3D::set_use_magnet);
+ ClassDB::bind_method(D_METHOD("is_using_magnet"), &SkeletonIK3D::is_using_magnet);
- ClassDB::bind_method(D_METHOD("set_magnet_position", "local_position"), &SkeletonIK::set_magnet_position);
- ClassDB::bind_method(D_METHOD("get_magnet_position"), &SkeletonIK::get_magnet_position);
+ ClassDB::bind_method(D_METHOD("set_magnet_position", "local_position"), &SkeletonIK3D::set_magnet_position);
+ ClassDB::bind_method(D_METHOD("get_magnet_position"), &SkeletonIK3D::get_magnet_position);
- ClassDB::bind_method(D_METHOD("get_parent_skeleton"), &SkeletonIK::get_parent_skeleton);
- ClassDB::bind_method(D_METHOD("is_running"), &SkeletonIK::is_running);
+ ClassDB::bind_method(D_METHOD("get_parent_skeleton"), &SkeletonIK3D::get_parent_skeleton);
+ ClassDB::bind_method(D_METHOD("is_running"), &SkeletonIK3D::is_running);
- ClassDB::bind_method(D_METHOD("set_min_distance", "min_distance"), &SkeletonIK::set_min_distance);
- ClassDB::bind_method(D_METHOD("get_min_distance"), &SkeletonIK::get_min_distance);
+ ClassDB::bind_method(D_METHOD("set_min_distance", "min_distance"), &SkeletonIK3D::set_min_distance);
+ ClassDB::bind_method(D_METHOD("get_min_distance"), &SkeletonIK3D::get_min_distance);
- ClassDB::bind_method(D_METHOD("set_max_iterations", "iterations"), &SkeletonIK::set_max_iterations);
- ClassDB::bind_method(D_METHOD("get_max_iterations"), &SkeletonIK::get_max_iterations);
+ ClassDB::bind_method(D_METHOD("set_max_iterations", "iterations"), &SkeletonIK3D::set_max_iterations);
+ ClassDB::bind_method(D_METHOD("get_max_iterations"), &SkeletonIK3D::get_max_iterations);
- ClassDB::bind_method(D_METHOD("start", "one_time"), &SkeletonIK::start, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("stop"), &SkeletonIK::stop);
+ ClassDB::bind_method(D_METHOD("start", "one_time"), &SkeletonIK3D::start, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("stop"), &SkeletonIK3D::stop);
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "root_bone"), "set_root_bone", "get_root_bone");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "tip_bone"), "set_tip_bone", "get_tip_bone");
@@ -402,10 +405,10 @@ void SkeletonIK::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_iterations"), "set_max_iterations", "get_max_iterations");
}
-void SkeletonIK::_notification(int p_what) {
+void SkeletonIK3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- skeleton = Object::cast_to<Skeleton>(get_parent());
+ skeleton = Object::cast_to<Skeleton3D>(get_parent());
set_process_priority(1);
reload_chain();
} break;
@@ -423,7 +426,7 @@ void SkeletonIK::_notification(int p_what) {
}
}
-SkeletonIK::SkeletonIK() :
+SkeletonIK3D::SkeletonIK3D() :
interpolation(1),
override_tip_basis(true),
use_magnet(false),
@@ -434,93 +437,93 @@ SkeletonIK::SkeletonIK() :
task(NULL) {
}
-SkeletonIK::~SkeletonIK() {
+SkeletonIK3D::~SkeletonIK3D() {
FabrikInverseKinematic::free_task(task);
task = NULL;
}
-void SkeletonIK::set_root_bone(const StringName &p_root_bone) {
+void SkeletonIK3D::set_root_bone(const StringName &p_root_bone) {
root_bone = p_root_bone;
reload_chain();
}
-StringName SkeletonIK::get_root_bone() const {
+StringName SkeletonIK3D::get_root_bone() const {
return root_bone;
}
-void SkeletonIK::set_tip_bone(const StringName &p_tip_bone) {
+void SkeletonIK3D::set_tip_bone(const StringName &p_tip_bone) {
tip_bone = p_tip_bone;
reload_chain();
}
-StringName SkeletonIK::get_tip_bone() const {
+StringName SkeletonIK3D::get_tip_bone() const {
return tip_bone;
}
-void SkeletonIK::set_interpolation(real_t p_interpolation) {
+void SkeletonIK3D::set_interpolation(real_t p_interpolation) {
interpolation = p_interpolation;
}
-real_t SkeletonIK::get_interpolation() const {
+real_t SkeletonIK3D::get_interpolation() const {
return interpolation;
}
-void SkeletonIK::set_target_transform(const Transform &p_target) {
+void SkeletonIK3D::set_target_transform(const Transform &p_target) {
target = p_target;
reload_goal();
}
-const Transform &SkeletonIK::get_target_transform() const {
+const Transform &SkeletonIK3D::get_target_transform() const {
return target;
}
-void SkeletonIK::set_target_node(const NodePath &p_node) {
+void SkeletonIK3D::set_target_node(const NodePath &p_node) {
target_node_path_override = p_node;
target_node_override = NULL;
reload_goal();
}
-NodePath SkeletonIK::get_target_node() {
+NodePath SkeletonIK3D::get_target_node() {
return target_node_path_override;
}
-void SkeletonIK::set_override_tip_basis(bool p_override) {
+void SkeletonIK3D::set_override_tip_basis(bool p_override) {
override_tip_basis = p_override;
}
-bool SkeletonIK::is_override_tip_basis() const {
+bool SkeletonIK3D::is_override_tip_basis() const {
return override_tip_basis;
}
-void SkeletonIK::set_use_magnet(bool p_use) {
+void SkeletonIK3D::set_use_magnet(bool p_use) {
use_magnet = p_use;
}
-bool SkeletonIK::is_using_magnet() const {
+bool SkeletonIK3D::is_using_magnet() const {
return use_magnet;
}
-void SkeletonIK::set_magnet_position(const Vector3 &p_local_position) {
+void SkeletonIK3D::set_magnet_position(const Vector3 &p_local_position) {
magnet_position = p_local_position;
}
-const Vector3 &SkeletonIK::get_magnet_position() const {
+const Vector3 &SkeletonIK3D::get_magnet_position() const {
return magnet_position;
}
-void SkeletonIK::set_min_distance(real_t p_min_distance) {
+void SkeletonIK3D::set_min_distance(real_t p_min_distance) {
min_distance = p_min_distance;
}
-void SkeletonIK::set_max_iterations(int p_iterations) {
+void SkeletonIK3D::set_max_iterations(int p_iterations) {
max_iterations = p_iterations;
}
-bool SkeletonIK::is_running() {
+bool SkeletonIK3D::is_running() {
return is_processing_internal();
}
-void SkeletonIK::start(bool p_one_time) {
+void SkeletonIK3D::start(bool p_one_time) {
if (p_one_time) {
set_process_internal(false);
_solve_chain();
@@ -529,14 +532,14 @@ void SkeletonIK::start(bool p_one_time) {
}
}
-void SkeletonIK::stop() {
+void SkeletonIK3D::stop() {
set_process_internal(false);
}
-Transform SkeletonIK::_get_target_transform() {
+Transform SkeletonIK3D::_get_target_transform() {
if (!target_node_override && !target_node_path_override.is_empty())
- target_node_override = Object::cast_to<Spatial>(get_node(target_node_path_override));
+ target_node_override = Object::cast_to<Node3D>(get_node(target_node_path_override));
if (target_node_override)
return target_node_override->get_global_transform();
@@ -544,7 +547,7 @@ Transform SkeletonIK::_get_target_transform() {
return target;
}
-void SkeletonIK::reload_chain() {
+void SkeletonIK3D::reload_chain() {
FabrikInverseKinematic::free_task(task);
task = NULL;
@@ -559,14 +562,14 @@ void SkeletonIK::reload_chain() {
}
}
-void SkeletonIK::reload_goal() {
+void SkeletonIK3D::reload_goal() {
if (!task)
return;
FabrikInverseKinematic::set_goal(task, _get_target_transform());
}
-void SkeletonIK::_solve_chain() {
+void SkeletonIK3D::_solve_chain() {
if (!task)
return;
FabrikInverseKinematic::solve(task, interpolation, override_tip_basis, use_magnet, magnet_position);
diff --git a/scene/animation/skeleton_ik.h b/scene/3d/skeleton_ik_3d.h
index 02d5aba5ba..ebfebd1e66 100644
--- a/scene/animation/skeleton_ik.h
+++ b/scene/3d/skeleton_ik_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* skeleton_ik.h */
+/* skeleton_ik_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -38,7 +38,7 @@
*/
#include "core/math/transform.h"
-#include "scene/3d/skeleton.h"
+#include "scene/3d/skeleton_3d.h"
class FabrikInverseKinematic {
@@ -54,7 +54,7 @@ class FabrikInverseKinematic {
// Bone info
BoneId bone;
- PhysicalBone *pb;
+ PhysicalBone3D *pb;
real_t length;
/// Positions relative to root bone
@@ -100,7 +100,7 @@ class FabrikInverseKinematic {
public:
struct Task {
RID self;
- Skeleton *skeleton;
+ Skeleton3D *skeleton;
Chain chain;
@@ -125,7 +125,7 @@ private:
/// Init a chain that starts from the root to tip
static bool build_chain(Task *p_task, bool p_force_simple_chain = true);
- static void update_chain(const Skeleton *p_sk, ChainItem *p_chain_item);
+ static void update_chain(const Skeleton3D *p_sk, ChainItem *p_chain_item);
static void solve_simple(Task *p_task, bool p_solve_magnet);
/// Special solvers that solve only chains with one end effector
@@ -133,7 +133,7 @@ private:
static void solve_simple_forwards(Chain &r_chain, bool p_solve_magnet);
public:
- static Task *create_simple_task(Skeleton *p_sk, BoneId root_bone, BoneId tip_bone, const Transform &goal_transform);
+ static Task *create_simple_task(Skeleton3D *p_sk, BoneId root_bone, BoneId tip_bone, const Transform &goal_transform);
static void free_task(Task *p_task);
// The goal of chain should be always in local space
static void set_goal(Task *p_task, const Transform &p_goal);
@@ -141,8 +141,8 @@ public:
static void solve(Task *p_task, real_t blending_delta, bool override_tip_basis, bool p_use_magnet, const Vector3 &p_magnet_position);
};
-class SkeletonIK : public Node {
- GDCLASS(SkeletonIK, Node);
+class SkeletonIK3D : public Node {
+ GDCLASS(SkeletonIK3D, Node);
StringName root_bone;
StringName tip_bone;
@@ -156,8 +156,8 @@ class SkeletonIK : public Node {
real_t min_distance;
int max_iterations;
- Skeleton *skeleton;
- Spatial *target_node_override;
+ Skeleton3D *skeleton;
+ Node3D *target_node_override;
FabrikInverseKinematic::Task *task;
protected:
@@ -168,8 +168,8 @@ protected:
virtual void _notification(int p_what);
public:
- SkeletonIK();
- virtual ~SkeletonIK();
+ SkeletonIK3D();
+ virtual ~SkeletonIK3D();
void set_root_bone(const StringName &p_root_bone);
StringName get_root_bone() const;
@@ -201,7 +201,7 @@ public:
void set_max_iterations(int p_iterations);
int get_max_iterations() const { return max_iterations; }
- Skeleton *get_parent_skeleton() const { return skeleton; }
+ Skeleton3D *get_parent_skeleton() const { return skeleton; }
bool is_running();
diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body_3d.cpp
index 65f868aed4..ee9ce1dd71 100644
--- a/scene/3d/soft_body.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* soft_body.cpp */
+/* soft_body_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,19 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "soft_body.h"
+#include "soft_body_3d.h"
#include "core/list.h"
#include "core/object.h"
#include "core/os/os.h"
#include "core/rid.h"
-#include "scene/3d/collision_object.h"
-#include "scene/3d/physics_body.h"
-#include "scene/3d/skeleton.h"
-#include "servers/physics_server.h"
+#include "scene/3d/collision_object_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/3d/skeleton_3d.h"
+#include "servers/physics_server_3d.h"
-SoftBodyVisualServerHandler::SoftBodyVisualServerHandler() {}
+SoftBodyRenderingServerHandler::SoftBodyRenderingServerHandler() {}
-void SoftBodyVisualServerHandler::prepare(RID p_mesh, int p_surface) {
+void SoftBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) {
clear();
ERR_FAIL_COND(!p_mesh.is_valid());
@@ -51,19 +51,19 @@ void SoftBodyVisualServerHandler::prepare(RID p_mesh, int p_surface) {
#warning Softbody is not working, needs to be redone considering that these functions no longer exist
#endif
#if 0
- const uint32_t surface_format = VS::get_singleton()->mesh_surface_get_format(mesh, surface);
- const int surface_vertex_len = VS::get_singleton()->mesh_surface_get_array_len(mesh, p_surface);
- const int surface_index_len = VS::get_singleton()->mesh_surface_get_array_index_len(mesh, p_surface);
- uint32_t surface_offsets[VS::ARRAY_MAX];
-
- buffer = VS::get_singleton()->mesh_surface_get_array(mesh, surface);
- stride = VS::get_singleton()->mesh_surface_make_offsets_from_format(surface_format, surface_vertex_len, surface_index_len, surface_offsets);
- offset_vertices = surface_offsets[VS::ARRAY_VERTEX];
- offset_normal = surface_offsets[VS::ARRAY_NORMAL];
+ const uint32_t surface_format = RS::get_singleton()->mesh_surface_get_format(mesh, surface);
+ const int surface_vertex_len = RS::get_singleton()->mesh_surface_get_array_len(mesh, p_surface);
+ const int surface_index_len = RS::get_singleton()->mesh_surface_get_array_index_len(mesh, p_surface);
+ uint32_t surface_offsets[RS::ARRAY_MAX];
+
+ buffer = RS::get_singleton()->mesh_surface_get_array(mesh, surface);
+ stride = RS::get_singleton()->mesh_surface_make_offsets_from_format(surface_format, surface_vertex_len, surface_index_len, surface_offsets);
+ offset_vertices = surface_offsets[RS::ARRAY_VERTEX];
+ offset_normal = surface_offsets[RS::ARRAY_NORMAL];
#endif
}
-void SoftBodyVisualServerHandler::clear() {
+void SoftBodyRenderingServerHandler::clear() {
if (mesh.is_valid()) {
buffer.resize(0);
@@ -72,43 +72,43 @@ void SoftBodyVisualServerHandler::clear() {
mesh = RID();
}
-void SoftBodyVisualServerHandler::open() {
+void SoftBodyRenderingServerHandler::open() {
write_buffer = buffer.ptrw();
}
-void SoftBodyVisualServerHandler::close() {
+void SoftBodyRenderingServerHandler::close() {
//write_buffer.release();
}
-void SoftBodyVisualServerHandler::commit_changes() {
- VS::get_singleton()->mesh_surface_update_region(mesh, surface, 0, buffer);
+void SoftBodyRenderingServerHandler::commit_changes() {
+ RS::get_singleton()->mesh_surface_update_region(mesh, surface, 0, buffer);
}
-void SoftBodyVisualServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) {
+void SoftBodyRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) {
copymem(&write_buffer[p_vertex_id * stride + offset_vertices], p_vector3, sizeof(float) * 3);
}
-void SoftBodyVisualServerHandler::set_normal(int p_vertex_id, const void *p_vector3) {
+void SoftBodyRenderingServerHandler::set_normal(int p_vertex_id, const void *p_vector3) {
copymem(&write_buffer[p_vertex_id * stride + offset_normal], p_vector3, sizeof(float) * 3);
}
-void SoftBodyVisualServerHandler::set_aabb(const AABB &p_aabb) {
- VS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb);
+void SoftBodyRenderingServerHandler::set_aabb(const AABB &p_aabb) {
+ RS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb);
}
-SoftBody::PinnedPoint::PinnedPoint() :
+SoftBody3D::PinnedPoint::PinnedPoint() :
point_index(-1),
spatial_attachment(NULL) {
}
-SoftBody::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) {
+SoftBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) {
point_index = obj_tocopy.point_index;
spatial_attachment_path = obj_tocopy.spatial_attachment_path;
spatial_attachment = obj_tocopy.spatial_attachment;
offset = obj_tocopy.offset;
}
-SoftBody::PinnedPoint SoftBody::PinnedPoint::operator=(const PinnedPoint &obj) {
+SoftBody3D::PinnedPoint SoftBody3D::PinnedPoint::operator=(const PinnedPoint &obj) {
point_index = obj.point_index;
spatial_attachment_path = obj.spatial_attachment_path;
spatial_attachment = obj.spatial_attachment;
@@ -116,14 +116,14 @@ SoftBody::PinnedPoint SoftBody::PinnedPoint::operator=(const PinnedPoint &obj) {
return *this;
}
-void SoftBody::_update_pickable() {
+void SoftBody3D::_update_pickable() {
if (!is_inside_tree())
return;
bool pickable = ray_pickable && is_visible_in_tree();
- PhysicsServer::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
+ PhysicsServer3D::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
}
-bool SoftBody::_set(const StringName &p_name, const Variant &p_value) {
+bool SoftBody3D::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
String which = name.get_slicec('/', 0);
@@ -142,7 +142,7 @@ bool SoftBody::_set(const StringName &p_name, const Variant &p_value) {
return false;
}
-bool SoftBody::_get(const StringName &p_name, Variant &r_ret) const {
+bool SoftBody3D::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name;
String which = name.get_slicec('/', 0);
@@ -170,7 +170,7 @@ bool SoftBody::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void SoftBody::_get_property_list(List<PropertyInfo> *p_list) const {
+void SoftBody3D::_get_property_list(List<PropertyInfo> *p_list) const {
const int pinned_points_indices_size = pinned_points.size();
@@ -183,7 +183,7 @@ void SoftBody::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-bool SoftBody::_set_property_pinned_points_indices(const Array &p_indices) {
+bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) {
const int p_indices_size = p_indices.size();
@@ -212,7 +212,7 @@ bool SoftBody::_set_property_pinned_points_indices(const Array &p_indices) {
return true;
}
-bool SoftBody::_set_property_pinned_points_attachment(int p_item, const String &p_what, const Variant &p_value) {
+bool SoftBody3D::_set_property_pinned_points_attachment(int p_item, const String &p_what, const Variant &p_value) {
if (pinned_points.size() <= p_item) {
return false;
}
@@ -231,7 +231,7 @@ bool SoftBody::_set_property_pinned_points_attachment(int p_item, const String &
return true;
}
-bool SoftBody::_get_property_pinned_points(int p_item, const String &p_what, Variant &r_ret) const {
+bool SoftBody3D::_get_property_pinned_points(int p_item, const String &p_what, Variant &r_ret) const {
if (pinned_points.size() <= p_item) {
return false;
}
@@ -250,7 +250,7 @@ bool SoftBody::_get_property_pinned_points(int p_item, const String &p_what, Var
return true;
}
-void SoftBody::_changed_callback(Object *p_changed, const char *p_prop) {
+void SoftBody3D::_changed_callback(Object *p_changed, const char *p_prop) {
prepare_physics_server();
_reset_points_offsets();
#ifdef TOOLS_ENABLED
@@ -260,7 +260,7 @@ void SoftBody::_changed_callback(Object *p_changed, const char *p_prop) {
#endif
}
-void SoftBody::_notification(int p_what) {
+void SoftBody3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
@@ -270,7 +270,7 @@ void SoftBody::_notification(int p_what) {
}
RID space = get_world()->get_space();
- PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space);
+ PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, space);
prepare_physics_server();
} break;
case NOTIFICATION_READY: {
@@ -285,10 +285,10 @@ void SoftBody::_notification(int p_what) {
return;
}
- PhysicsServer::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform());
+ PhysicsServer3D::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform());
set_notify_transform(false);
- // Required to be top level with Transform at center of world in order to modify VisualServer only to support custom Transform
+ // Required to be top level with Transform at center of world in order to modify RenderingServer only to support custom Transform
set_as_toplevel(true);
set_transform(Transform());
set_notify_transform(true);
@@ -301,7 +301,7 @@ void SoftBody::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_WORLD: {
- PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, RID());
+ PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, RID());
} break;
}
@@ -317,56 +317,56 @@ void SoftBody::_notification(int p_what) {
#endif
}
-void SoftBody::_bind_methods() {
+void SoftBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &SoftBody::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &SoftBody::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &SoftBody3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &SoftBody3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &SoftBody::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &SoftBody::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &SoftBody3D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &SoftBody3D::get_collision_layer);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &SoftBody::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &SoftBody::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &SoftBody3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &SoftBody3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &SoftBody::set_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &SoftBody::get_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &SoftBody3D::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &SoftBody3D::get_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("set_parent_collision_ignore", "parent_collision_ignore"), &SoftBody::set_parent_collision_ignore);
- ClassDB::bind_method(D_METHOD("get_parent_collision_ignore"), &SoftBody::get_parent_collision_ignore);
+ ClassDB::bind_method(D_METHOD("set_parent_collision_ignore", "parent_collision_ignore"), &SoftBody3D::set_parent_collision_ignore);
+ ClassDB::bind_method(D_METHOD("get_parent_collision_ignore"), &SoftBody3D::get_parent_collision_ignore);
- ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &SoftBody::get_collision_exceptions);
- ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &SoftBody::add_collision_exception_with);
- ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &SoftBody::remove_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &SoftBody3D::get_collision_exceptions);
+ ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &SoftBody3D::add_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &SoftBody3D::remove_collision_exception_with);
- ClassDB::bind_method(D_METHOD("set_simulation_precision", "simulation_precision"), &SoftBody::set_simulation_precision);
- ClassDB::bind_method(D_METHOD("get_simulation_precision"), &SoftBody::get_simulation_precision);
+ ClassDB::bind_method(D_METHOD("set_simulation_precision", "simulation_precision"), &SoftBody3D::set_simulation_precision);
+ ClassDB::bind_method(D_METHOD("get_simulation_precision"), &SoftBody3D::get_simulation_precision);
- ClassDB::bind_method(D_METHOD("set_total_mass", "mass"), &SoftBody::set_total_mass);
- ClassDB::bind_method(D_METHOD("get_total_mass"), &SoftBody::get_total_mass);
+ ClassDB::bind_method(D_METHOD("set_total_mass", "mass"), &SoftBody3D::set_total_mass);
+ ClassDB::bind_method(D_METHOD("get_total_mass"), &SoftBody3D::get_total_mass);
- ClassDB::bind_method(D_METHOD("set_linear_stiffness", "linear_stiffness"), &SoftBody::set_linear_stiffness);
- ClassDB::bind_method(D_METHOD("get_linear_stiffness"), &SoftBody::get_linear_stiffness);
+ ClassDB::bind_method(D_METHOD("set_linear_stiffness", "linear_stiffness"), &SoftBody3D::set_linear_stiffness);
+ ClassDB::bind_method(D_METHOD("get_linear_stiffness"), &SoftBody3D::get_linear_stiffness);
- ClassDB::bind_method(D_METHOD("set_areaAngular_stiffness", "areaAngular_stiffness"), &SoftBody::set_areaAngular_stiffness);
- ClassDB::bind_method(D_METHOD("get_areaAngular_stiffness"), &SoftBody::get_areaAngular_stiffness);
+ ClassDB::bind_method(D_METHOD("set_areaAngular_stiffness", "areaAngular_stiffness"), &SoftBody3D::set_areaAngular_stiffness);
+ ClassDB::bind_method(D_METHOD("get_areaAngular_stiffness"), &SoftBody3D::get_areaAngular_stiffness);
- ClassDB::bind_method(D_METHOD("set_volume_stiffness", "volume_stiffness"), &SoftBody::set_volume_stiffness);
- ClassDB::bind_method(D_METHOD("get_volume_stiffness"), &SoftBody::get_volume_stiffness);
+ ClassDB::bind_method(D_METHOD("set_volume_stiffness", "volume_stiffness"), &SoftBody3D::set_volume_stiffness);
+ ClassDB::bind_method(D_METHOD("get_volume_stiffness"), &SoftBody3D::get_volume_stiffness);
- ClassDB::bind_method(D_METHOD("set_pressure_coefficient", "pressure_coefficient"), &SoftBody::set_pressure_coefficient);
- ClassDB::bind_method(D_METHOD("get_pressure_coefficient"), &SoftBody::get_pressure_coefficient);
+ ClassDB::bind_method(D_METHOD("set_pressure_coefficient", "pressure_coefficient"), &SoftBody3D::set_pressure_coefficient);
+ ClassDB::bind_method(D_METHOD("get_pressure_coefficient"), &SoftBody3D::get_pressure_coefficient);
- ClassDB::bind_method(D_METHOD("set_pose_matching_coefficient", "pose_matching_coefficient"), &SoftBody::set_pose_matching_coefficient);
- ClassDB::bind_method(D_METHOD("get_pose_matching_coefficient"), &SoftBody::get_pose_matching_coefficient);
+ ClassDB::bind_method(D_METHOD("set_pose_matching_coefficient", "pose_matching_coefficient"), &SoftBody3D::set_pose_matching_coefficient);
+ ClassDB::bind_method(D_METHOD("get_pose_matching_coefficient"), &SoftBody3D::get_pose_matching_coefficient);
- ClassDB::bind_method(D_METHOD("set_damping_coefficient", "damping_coefficient"), &SoftBody::set_damping_coefficient);
- ClassDB::bind_method(D_METHOD("get_damping_coefficient"), &SoftBody::get_damping_coefficient);
+ ClassDB::bind_method(D_METHOD("set_damping_coefficient", "damping_coefficient"), &SoftBody3D::set_damping_coefficient);
+ ClassDB::bind_method(D_METHOD("get_damping_coefficient"), &SoftBody3D::get_damping_coefficient);
- ClassDB::bind_method(D_METHOD("set_drag_coefficient", "drag_coefficient"), &SoftBody::set_drag_coefficient);
- ClassDB::bind_method(D_METHOD("get_drag_coefficient"), &SoftBody::get_drag_coefficient);
+ ClassDB::bind_method(D_METHOD("set_drag_coefficient", "drag_coefficient"), &SoftBody3D::set_drag_coefficient);
+ ClassDB::bind_method(D_METHOD("get_drag_coefficient"), &SoftBody3D::get_drag_coefficient);
- ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &SoftBody::set_ray_pickable);
- ClassDB::bind_method(D_METHOD("is_ray_pickable"), &SoftBody::is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &SoftBody3D::set_ray_pickable);
+ ClassDB::bind_method(D_METHOD("is_ray_pickable"), &SoftBody3D::is_ray_pickable);
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
@@ -386,9 +386,9 @@ void SoftBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ray_pickable"), "set_ray_pickable", "is_ray_pickable");
}
-String SoftBody::get_configuration_warning() const {
+String SoftBody3D::get_configuration_warning() const {
- String warning = MeshInstance::get_configuration_warning();
+ String warning = MeshInstance3D::get_configuration_warning();
if (get_mesh().is_null()) {
if (!warning.empty())
@@ -408,7 +408,7 @@ String SoftBody::get_configuration_warning() const {
return warning;
}
-void SoftBody::_update_physics_server() {
+void SoftBody3D::_update_physics_server() {
if (!simulation_started)
return;
@@ -418,18 +418,18 @@ void SoftBody::_update_physics_server() {
const PinnedPoint *r = pinned_points.ptr();
for (int i = 0; i < pinned_points_indices_size; ++i) {
if (r[i].spatial_attachment) {
- PhysicsServer::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, r[i].spatial_attachment->get_global_transform().xform(r[i].offset));
+ PhysicsServer3D::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, r[i].spatial_attachment->get_global_transform().xform(r[i].offset));
}
}
}
-void SoftBody::_draw_soft_mesh() {
+void SoftBody3D::_draw_soft_mesh() {
if (get_mesh().is_null())
return;
- if (!visual_server_handler.is_ready()) {
+ if (!rendering_server_handler.is_ready()) {
- visual_server_handler.prepare(get_mesh()->get_rid(), 0);
+ rendering_server_handler.prepare(get_mesh()->get_rid(), 0);
/// Necessary in order to render the mesh correctly (Soft body nodes are in global space)
simulation_started = true;
@@ -439,21 +439,21 @@ void SoftBody::_draw_soft_mesh() {
_update_physics_server();
- visual_server_handler.open();
- PhysicsServer::get_singleton()->soft_body_update_visual_server(physics_rid, &visual_server_handler);
- visual_server_handler.close();
+ rendering_server_handler.open();
+ PhysicsServer3D::get_singleton()->soft_body_update_rendering_server(physics_rid, &rendering_server_handler);
+ rendering_server_handler.close();
- visual_server_handler.commit_changes();
+ rendering_server_handler.commit_changes();
}
-void SoftBody::prepare_physics_server() {
+void SoftBody3D::prepare_physics_server() {
if (Engine::get_singleton()->is_editor_hint()) {
if (get_mesh().is_valid())
- PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
+ PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
else
- PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, NULL);
+ PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, NULL);
return;
}
@@ -461,18 +461,18 @@ void SoftBody::prepare_physics_server() {
if (get_mesh().is_valid()) {
become_mesh_owner();
- PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
- VS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody::_draw_soft_mesh));
+ PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
+ RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh));
} else {
- PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, NULL);
- if (VS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody::_draw_soft_mesh))) {
- VS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody::_draw_soft_mesh));
+ PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, NULL);
+ if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) {
+ RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh));
}
}
}
-void SoftBody::become_mesh_owner() {
+void SoftBody3D::become_mesh_owner() {
if (mesh.is_null())
return;
@@ -506,24 +506,24 @@ void SoftBody::become_mesh_owner() {
}
}
-void SoftBody::set_collision_mask(uint32_t p_mask) {
+void SoftBody3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- PhysicsServer::get_singleton()->soft_body_set_collision_mask(physics_rid, p_mask);
+ PhysicsServer3D::get_singleton()->soft_body_set_collision_mask(physics_rid, p_mask);
}
-uint32_t SoftBody::get_collision_mask() const {
+uint32_t SoftBody3D::get_collision_mask() const {
return collision_mask;
}
-void SoftBody::set_collision_layer(uint32_t p_layer) {
+void SoftBody3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- PhysicsServer::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer);
+ PhysicsServer3D::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer);
}
-uint32_t SoftBody::get_collision_layer() const {
+uint32_t SoftBody3D::get_collision_layer() const {
return collision_layer;
}
-void SoftBody::set_collision_mask_bit(int p_bit, bool p_value) {
+void SoftBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
mask |= 1 << p_bit;
@@ -532,11 +532,11 @@ void SoftBody::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool SoftBody::get_collision_mask_bit(int p_bit) const {
+bool SoftBody3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-void SoftBody::set_collision_layer_bit(int p_bit, bool p_value) {
+void SoftBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t layer = get_collision_layer();
if (p_value)
layer |= 1 << p_bit;
@@ -545,138 +545,138 @@ void SoftBody::set_collision_layer_bit(int p_bit, bool p_value) {
set_collision_layer(layer);
}
-bool SoftBody::get_collision_layer_bit(int p_bit) const {
+bool SoftBody3D::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
-void SoftBody::set_parent_collision_ignore(const NodePath &p_parent_collision_ignore) {
+void SoftBody3D::set_parent_collision_ignore(const NodePath &p_parent_collision_ignore) {
parent_collision_ignore = p_parent_collision_ignore;
}
-const NodePath &SoftBody::get_parent_collision_ignore() const {
+const NodePath &SoftBody3D::get_parent_collision_ignore() const {
return parent_collision_ignore;
}
-void SoftBody::set_pinned_points_indices(Vector<SoftBody::PinnedPoint> p_pinned_points_indices) {
+void SoftBody3D::set_pinned_points_indices(Vector<SoftBody3D::PinnedPoint> p_pinned_points_indices) {
pinned_points = p_pinned_points_indices;
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
pin_point(p_pinned_points_indices[i].point_index, true);
}
}
-Vector<SoftBody::PinnedPoint> SoftBody::get_pinned_points_indices() {
+Vector<SoftBody3D::PinnedPoint> SoftBody3D::get_pinned_points_indices() {
return pinned_points;
}
-Array SoftBody::get_collision_exceptions() {
+Array SoftBody3D::get_collision_exceptions() {
List<RID> exceptions;
- PhysicsServer::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions);
+ PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions);
Array ret;
for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) {
RID body = E->get();
- ObjectID instance_id = PhysicsServer::get_singleton()->body_get_object_instance_id(body);
+ ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body);
Object *obj = ObjectDB::get_instance(instance_id);
- PhysicsBody *physics_body = Object::cast_to<PhysicsBody>(obj);
+ PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj);
ret.append(physics_body);
}
return ret;
}
-void SoftBody::add_collision_exception_with(Node *p_node) {
+void SoftBody3D::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- CollisionObject *collision_object = Object::cast_to<CollisionObject>(p_node);
+ CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject.");
- PhysicsServer::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid());
+ PhysicsServer3D::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid());
}
-void SoftBody::remove_collision_exception_with(Node *p_node) {
+void SoftBody3D::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- CollisionObject *collision_object = Object::cast_to<CollisionObject>(p_node);
+ CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject.");
- PhysicsServer::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid());
+ PhysicsServer3D::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid());
}
-int SoftBody::get_simulation_precision() {
- return PhysicsServer::get_singleton()->soft_body_get_simulation_precision(physics_rid);
+int SoftBody3D::get_simulation_precision() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_simulation_precision(physics_rid);
}
-void SoftBody::set_simulation_precision(int p_simulation_precision) {
- PhysicsServer::get_singleton()->soft_body_set_simulation_precision(physics_rid, p_simulation_precision);
+void SoftBody3D::set_simulation_precision(int p_simulation_precision) {
+ PhysicsServer3D::get_singleton()->soft_body_set_simulation_precision(physics_rid, p_simulation_precision);
}
-real_t SoftBody::get_total_mass() {
- return PhysicsServer::get_singleton()->soft_body_get_total_mass(physics_rid);
+real_t SoftBody3D::get_total_mass() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_total_mass(physics_rid);
}
-void SoftBody::set_total_mass(real_t p_total_mass) {
- PhysicsServer::get_singleton()->soft_body_set_total_mass(physics_rid, p_total_mass);
+void SoftBody3D::set_total_mass(real_t p_total_mass) {
+ PhysicsServer3D::get_singleton()->soft_body_set_total_mass(physics_rid, p_total_mass);
}
-void SoftBody::set_linear_stiffness(real_t p_linear_stiffness) {
- PhysicsServer::get_singleton()->soft_body_set_linear_stiffness(physics_rid, p_linear_stiffness);
+void SoftBody3D::set_linear_stiffness(real_t p_linear_stiffness) {
+ PhysicsServer3D::get_singleton()->soft_body_set_linear_stiffness(physics_rid, p_linear_stiffness);
}
-real_t SoftBody::get_linear_stiffness() {
- return PhysicsServer::get_singleton()->soft_body_get_linear_stiffness(physics_rid);
+real_t SoftBody3D::get_linear_stiffness() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_linear_stiffness(physics_rid);
}
-void SoftBody::set_areaAngular_stiffness(real_t p_areaAngular_stiffness) {
- PhysicsServer::get_singleton()->soft_body_set_areaAngular_stiffness(physics_rid, p_areaAngular_stiffness);
+void SoftBody3D::set_areaAngular_stiffness(real_t p_areaAngular_stiffness) {
+ PhysicsServer3D::get_singleton()->soft_body_set_areaAngular_stiffness(physics_rid, p_areaAngular_stiffness);
}
-real_t SoftBody::get_areaAngular_stiffness() {
- return PhysicsServer::get_singleton()->soft_body_get_areaAngular_stiffness(physics_rid);
+real_t SoftBody3D::get_areaAngular_stiffness() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_areaAngular_stiffness(physics_rid);
}
-void SoftBody::set_volume_stiffness(real_t p_volume_stiffness) {
- PhysicsServer::get_singleton()->soft_body_set_volume_stiffness(physics_rid, p_volume_stiffness);
+void SoftBody3D::set_volume_stiffness(real_t p_volume_stiffness) {
+ PhysicsServer3D::get_singleton()->soft_body_set_volume_stiffness(physics_rid, p_volume_stiffness);
}
-real_t SoftBody::get_volume_stiffness() {
- return PhysicsServer::get_singleton()->soft_body_get_volume_stiffness(physics_rid);
+real_t SoftBody3D::get_volume_stiffness() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_volume_stiffness(physics_rid);
}
-real_t SoftBody::get_pressure_coefficient() {
- return PhysicsServer::get_singleton()->soft_body_get_pressure_coefficient(physics_rid);
+real_t SoftBody3D::get_pressure_coefficient() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_pressure_coefficient(physics_rid);
}
-void SoftBody::set_pose_matching_coefficient(real_t p_pose_matching_coefficient) {
- PhysicsServer::get_singleton()->soft_body_set_pose_matching_coefficient(physics_rid, p_pose_matching_coefficient);
+void SoftBody3D::set_pose_matching_coefficient(real_t p_pose_matching_coefficient) {
+ PhysicsServer3D::get_singleton()->soft_body_set_pose_matching_coefficient(physics_rid, p_pose_matching_coefficient);
}
-real_t SoftBody::get_pose_matching_coefficient() {
- return PhysicsServer::get_singleton()->soft_body_get_pose_matching_coefficient(physics_rid);
+real_t SoftBody3D::get_pose_matching_coefficient() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_pose_matching_coefficient(physics_rid);
}
-void SoftBody::set_pressure_coefficient(real_t p_pressure_coefficient) {
- PhysicsServer::get_singleton()->soft_body_set_pressure_coefficient(physics_rid, p_pressure_coefficient);
+void SoftBody3D::set_pressure_coefficient(real_t p_pressure_coefficient) {
+ PhysicsServer3D::get_singleton()->soft_body_set_pressure_coefficient(physics_rid, p_pressure_coefficient);
}
-real_t SoftBody::get_damping_coefficient() {
- return PhysicsServer::get_singleton()->soft_body_get_damping_coefficient(physics_rid);
+real_t SoftBody3D::get_damping_coefficient() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_damping_coefficient(physics_rid);
}
-void SoftBody::set_damping_coefficient(real_t p_damping_coefficient) {
- PhysicsServer::get_singleton()->soft_body_set_damping_coefficient(physics_rid, p_damping_coefficient);
+void SoftBody3D::set_damping_coefficient(real_t p_damping_coefficient) {
+ PhysicsServer3D::get_singleton()->soft_body_set_damping_coefficient(physics_rid, p_damping_coefficient);
}
-real_t SoftBody::get_drag_coefficient() {
- return PhysicsServer::get_singleton()->soft_body_get_drag_coefficient(physics_rid);
+real_t SoftBody3D::get_drag_coefficient() {
+ return PhysicsServer3D::get_singleton()->soft_body_get_drag_coefficient(physics_rid);
}
-void SoftBody::set_drag_coefficient(real_t p_drag_coefficient) {
- PhysicsServer::get_singleton()->soft_body_set_drag_coefficient(physics_rid, p_drag_coefficient);
+void SoftBody3D::set_drag_coefficient(real_t p_drag_coefficient) {
+ PhysicsServer3D::get_singleton()->soft_body_set_drag_coefficient(physics_rid, p_drag_coefficient);
}
-Vector3 SoftBody::get_point_transform(int p_point_index) {
- return PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index);
+Vector3 SoftBody3D::get_point_transform(int p_point_index) {
+ return PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index);
}
-void SoftBody::pin_point_toggle(int p_point_index) {
+void SoftBody3D::pin_point_toggle(int p_point_index) {
pin_point(p_point_index, !(-1 != _has_pinned_point(p_point_index)));
}
-void SoftBody::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path) {
+void SoftBody3D::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path) {
_pin_point_on_physics_server(p_point_index, pin);
if (pin) {
_add_pinned_point(p_point_index, p_spatial_attachment_path);
@@ -685,23 +685,23 @@ void SoftBody::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_
}
}
-bool SoftBody::is_point_pinned(int p_point_index) const {
+bool SoftBody3D::is_point_pinned(int p_point_index) const {
return -1 != _has_pinned_point(p_point_index);
}
-void SoftBody::set_ray_pickable(bool p_ray_pickable) {
+void SoftBody3D::set_ray_pickable(bool p_ray_pickable) {
ray_pickable = p_ray_pickable;
_update_pickable();
}
-bool SoftBody::is_ray_pickable() const {
+bool SoftBody3D::is_ray_pickable() const {
return ray_pickable;
}
-SoftBody::SoftBody() :
- physics_rid(PhysicsServer::get_singleton()->soft_body_create()),
+SoftBody3D::SoftBody3D() :
+ physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()),
mesh_owner(false),
collision_mask(1),
collision_layer(1),
@@ -709,26 +709,26 @@ SoftBody::SoftBody() :
pinned_points_cache_dirty(true),
ray_pickable(true) {
- PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
}
-SoftBody::~SoftBody() {
- PhysicsServer::get_singleton()->free(physics_rid);
+SoftBody3D::~SoftBody3D() {
+ PhysicsServer3D::get_singleton()->free(physics_rid);
}
-void SoftBody::reset_softbody_pin() {
- PhysicsServer::get_singleton()->soft_body_remove_all_pinned_points(physics_rid);
+void SoftBody3D::reset_softbody_pin() {
+ PhysicsServer3D::get_singleton()->soft_body_remove_all_pinned_points(physics_rid);
const PinnedPoint *pps = pinned_points.ptr();
for (int i = pinned_points.size() - 1; 0 < i; --i) {
- PhysicsServer::get_singleton()->soft_body_pin_point(physics_rid, pps[i].point_index, true);
+ PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, pps[i].point_index, true);
}
}
-void SoftBody::_make_cache_dirty() {
+void SoftBody3D::_make_cache_dirty() {
pinned_points_cache_dirty = true;
}
-void SoftBody::_update_cache_pin_points_datas() {
+void SoftBody3D::_update_cache_pin_points_datas() {
if (!pinned_points_cache_dirty)
return;
@@ -738,20 +738,20 @@ void SoftBody::_update_cache_pin_points_datas() {
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
if (!w[i].spatial_attachment_path.is_empty()) {
- w[i].spatial_attachment = Object::cast_to<Spatial>(get_node(w[i].spatial_attachment_path));
+ w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(w[i].spatial_attachment_path));
}
if (!w[i].spatial_attachment) {
- ERR_PRINT("Spatial node not defined in the pinned point, Softbody undefined behaviour!");
+ ERR_PRINT("Node3D node not defined in the pinned point, Softbody undefined behaviour!");
}
}
}
-void SoftBody::_pin_point_on_physics_server(int p_point_index, bool pin) {
- PhysicsServer::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin);
+void SoftBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) {
+ PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin);
}
-void SoftBody::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) {
- SoftBody::PinnedPoint *pinned_point;
+void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) {
+ SoftBody3D::PinnedPoint *pinned_point;
if (-1 == _get_pinned_point(p_point_index, pinned_point)) {
// Create new
@@ -760,8 +760,8 @@ void SoftBody::_add_pinned_point(int p_point_index, const NodePath &p_spatial_at
pp.spatial_attachment_path = p_spatial_attachment_path;
if (!p_spatial_attachment_path.is_empty() && has_node(p_spatial_attachment_path)) {
- pp.spatial_attachment = Object::cast_to<Spatial>(get_node(p_spatial_attachment_path));
- pp.offset = (pp.spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, pp.point_index));
+ pp.spatial_attachment = Object::cast_to<Node3D>(get_node(p_spatial_attachment_path));
+ pp.offset = (pp.spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, pp.point_index));
}
pinned_points.push_back(pp);
@@ -772,13 +772,13 @@ void SoftBody::_add_pinned_point(int p_point_index, const NodePath &p_spatial_at
pinned_point->spatial_attachment_path = p_spatial_attachment_path;
if (!p_spatial_attachment_path.is_empty() && has_node(p_spatial_attachment_path)) {
- pinned_point->spatial_attachment = Object::cast_to<Spatial>(get_node(p_spatial_attachment_path));
- pinned_point->offset = (pinned_point->spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, pinned_point->point_index));
+ pinned_point->spatial_attachment = Object::cast_to<Node3D>(get_node(p_spatial_attachment_path));
+ pinned_point->offset = (pinned_point->spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, pinned_point->point_index));
}
}
}
-void SoftBody::_reset_points_offsets() {
+void SoftBody3D::_reset_points_offsets() {
if (!Engine::get_singleton()->is_editor_hint())
return;
@@ -788,34 +788,34 @@ void SoftBody::_reset_points_offsets() {
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
if (!r[i].spatial_attachment)
- w[i].spatial_attachment = Object::cast_to<Spatial>(get_node(r[i].spatial_attachment_path));
+ w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(r[i].spatial_attachment_path));
if (!r[i].spatial_attachment)
continue;
- w[i].offset = (r[i].spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, r[i].point_index));
+ w[i].offset = (r[i].spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, r[i].point_index));
}
}
-void SoftBody::_remove_pinned_point(int p_point_index) {
+void SoftBody3D::_remove_pinned_point(int p_point_index) {
const int id(_has_pinned_point(p_point_index));
if (-1 != id) {
pinned_points.remove(id);
}
}
-int SoftBody::_get_pinned_point(int p_point_index, SoftBody::PinnedPoint *&r_point) const {
+int SoftBody3D::_get_pinned_point(int p_point_index, SoftBody3D::PinnedPoint *&r_point) const {
const int id = _has_pinned_point(p_point_index);
if (-1 == id) {
r_point = NULL;
return -1;
} else {
- r_point = const_cast<SoftBody::PinnedPoint *>(&pinned_points.ptr()[id]);
+ r_point = const_cast<SoftBody3D::PinnedPoint *>(&pinned_points.ptr()[id]);
return id;
}
}
-int SoftBody::_has_pinned_point(int p_point_index) const {
+int SoftBody3D::_has_pinned_point(int p_point_index) const {
const PinnedPoint *r = pinned_points.ptr();
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
if (p_point_index == r[i].point_index) {
diff --git a/scene/3d/soft_body.h b/scene/3d/soft_body_3d.h
index d6c35a5989..7dd5880985 100644
--- a/scene/3d/soft_body.h
+++ b/scene/3d/soft_body_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* soft_body.h */
+/* soft_body_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,13 +31,13 @@
#ifndef SOFT_PHYSICS_BODY_H
#define SOFT_PHYSICS_BODY_H
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/mesh_instance_3d.h"
-class SoftBody;
+class SoftBody3D;
-class SoftBodyVisualServerHandler {
+class SoftBodyRenderingServerHandler {
- friend class SoftBody;
+ friend class SoftBody3D;
RID mesh;
int surface;
@@ -49,7 +49,7 @@ class SoftBodyVisualServerHandler {
uint8_t *write_buffer;
private:
- SoftBodyVisualServerHandler();
+ SoftBodyRenderingServerHandler();
bool is_ready() { return mesh.is_valid(); }
void prepare(RID p_mesh_rid, int p_surface);
void clear();
@@ -63,14 +63,14 @@ public:
void set_aabb(const AABB &p_aabb);
};
-class SoftBody : public MeshInstance {
- GDCLASS(SoftBody, MeshInstance);
+class SoftBody3D : public MeshInstance3D {
+ GDCLASS(SoftBody3D, MeshInstance3D);
public:
struct PinnedPoint {
int point_index;
NodePath spatial_attachment_path;
- Spatial *spatial_attachment; // Cache
+ Node3D *spatial_attachment; // Cache
Vector3 offset;
PinnedPoint();
@@ -79,7 +79,7 @@ public:
};
private:
- SoftBodyVisualServerHandler visual_server_handler;
+ SoftBodyRenderingServerHandler rendering_server_handler;
RID physics_rid;
@@ -92,7 +92,7 @@ private:
bool pinned_points_cache_dirty;
Ref<ArrayMesh> debug_mesh_cache;
- class MeshInstance *debug_mesh;
+ class MeshInstance3D *debug_mesh;
bool capture_input_on_drag;
bool ray_pickable;
@@ -181,8 +181,8 @@ public:
void set_ray_pickable(bool p_ray_pickable);
bool is_ray_pickable() const;
- SoftBody();
- ~SoftBody();
+ SoftBody3D();
+ ~SoftBody3D();
private:
void reset_softbody_pin();
diff --git a/scene/3d/spring_arm.cpp b/scene/3d/spring_arm_3d.cpp
index ce277dae5b..281be3f7d3 100644
--- a/scene/3d/spring_arm.cpp
+++ b/scene/3d/spring_arm_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spring_arm.cpp */
+/* spring_arm_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,20 +28,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "spring_arm.h"
+#include "spring_arm_3d.h"
#include "core/engine.h"
-#include "scene/3d/collision_object.h"
-#include "scene/resources/sphere_shape.h"
-#include "servers/physics_server.h"
+#include "scene/3d/collision_object_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
+#include "servers/physics_server_3d.h"
-SpringArm::SpringArm() :
+SpringArm3D::SpringArm3D() :
spring_length(1),
current_spring_length(0),
keep_child_basis(false),
mask(1),
margin(0.01) {}
-void SpringArm::_notification(int p_what) {
+void SpringArm3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
if (!Engine::get_singleton()->is_editor_hint()) {
@@ -59,84 +59,84 @@ void SpringArm::_notification(int p_what) {
}
}
-void SpringArm::_bind_methods() {
+void SpringArm3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_hit_length"), &SpringArm::get_hit_length);
+ ClassDB::bind_method(D_METHOD("get_hit_length"), &SpringArm3D::get_hit_length);
- ClassDB::bind_method(D_METHOD("set_length", "length"), &SpringArm::set_length);
- ClassDB::bind_method(D_METHOD("get_length"), &SpringArm::get_length);
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &SpringArm3D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &SpringArm3D::get_length);
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &SpringArm::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &SpringArm::get_shape);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape"), &SpringArm3D::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape"), &SpringArm3D::get_shape);
- ClassDB::bind_method(D_METHOD("add_excluded_object", "RID"), &SpringArm::add_excluded_object);
- ClassDB::bind_method(D_METHOD("remove_excluded_object", "RID"), &SpringArm::remove_excluded_object);
- ClassDB::bind_method(D_METHOD("clear_excluded_objects"), &SpringArm::clear_excluded_objects);
+ ClassDB::bind_method(D_METHOD("add_excluded_object", "RID"), &SpringArm3D::add_excluded_object);
+ ClassDB::bind_method(D_METHOD("remove_excluded_object", "RID"), &SpringArm3D::remove_excluded_object);
+ ClassDB::bind_method(D_METHOD("clear_excluded_objects"), &SpringArm3D::clear_excluded_objects);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &SpringArm::set_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &SpringArm::get_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &SpringArm3D::set_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &SpringArm3D::get_mask);
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &SpringArm::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &SpringArm::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &SpringArm3D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &SpringArm3D::get_margin);
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), "set_shape", "get_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape3D"), "set_shape", "get_shape");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "spring_length"), "set_length", "get_length");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin"), "set_margin", "get_margin");
}
-float SpringArm::get_length() const {
+float SpringArm3D::get_length() const {
return spring_length;
}
-void SpringArm::set_length(float p_length) {
+void SpringArm3D::set_length(float p_length) {
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
update_gizmo();
spring_length = p_length;
}
-void SpringArm::set_shape(Ref<Shape> p_shape) {
+void SpringArm3D::set_shape(Ref<Shape3D> p_shape) {
shape = p_shape;
}
-Ref<Shape> SpringArm::get_shape() const {
+Ref<Shape3D> SpringArm3D::get_shape() const {
return shape;
}
-void SpringArm::set_mask(uint32_t p_mask) {
+void SpringArm3D::set_mask(uint32_t p_mask) {
mask = p_mask;
}
-uint32_t SpringArm::get_mask() {
+uint32_t SpringArm3D::get_mask() {
return mask;
}
-float SpringArm::get_margin() {
+float SpringArm3D::get_margin() {
return margin;
}
-void SpringArm::set_margin(float p_margin) {
+void SpringArm3D::set_margin(float p_margin) {
margin = p_margin;
}
-void SpringArm::add_excluded_object(RID p_rid) {
+void SpringArm3D::add_excluded_object(RID p_rid) {
excluded_objects.insert(p_rid);
}
-bool SpringArm::remove_excluded_object(RID p_rid) {
+bool SpringArm3D::remove_excluded_object(RID p_rid) {
return excluded_objects.erase(p_rid);
}
-void SpringArm::clear_excluded_objects() {
+void SpringArm3D::clear_excluded_objects() {
excluded_objects.clear();
}
-float SpringArm::get_hit_length() {
+float SpringArm3D::get_hit_length() {
return current_spring_length;
}
-void SpringArm::process_spring() {
+void SpringArm3D::process_spring() {
// From
real_t motion_delta(1);
real_t motion_delta_unsafe(1);
@@ -146,7 +146,7 @@ void SpringArm::process_spring() {
if (shape.is_null()) {
motion = Vector3(cast_direction * (spring_length));
- PhysicsDirectSpaceState::RayResult r;
+ PhysicsDirectSpaceState3D::RayResult r;
bool intersected = get_world()->get_direct_space_state()->intersect_ray(get_global_transform().origin, get_global_transform().origin + motion, r, excluded_objects, mask);
if (intersected) {
float dist = get_global_transform().origin.distance_to(r.position);
@@ -164,7 +164,7 @@ void SpringArm::process_spring() {
for (int i = get_child_count() - 1; 0 <= i; --i) {
- Spatial *child = Object::cast_to<Spatial>(get_child(i));
+ Node3D *child = Object::cast_to<Node3D>(get_child(i));
if (child) {
childs_transform.basis = child->get_global_transform().basis;
child->set_global_transform(childs_transform);
diff --git a/scene/3d/spring_arm.h b/scene/3d/spring_arm_3d.h
index 1a12370564..cb8a00ecf9 100644
--- a/scene/3d/spring_arm.h
+++ b/scene/3d/spring_arm_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spring_arm.h */
+/* spring_arm_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,12 +31,12 @@
#ifndef SPRING_ARM_H
#define SPRING_ARM_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
-class SpringArm : public Spatial {
- GDCLASS(SpringArm, Spatial);
+class SpringArm3D : public Node3D {
+ GDCLASS(SpringArm3D, Node3D);
- Ref<Shape> shape;
+ Ref<Shape3D> shape;
Set<RID> excluded_objects;
float spring_length;
float current_spring_length;
@@ -51,8 +51,8 @@ protected:
public:
void set_length(float p_length);
float get_length() const;
- void set_shape(Ref<Shape> p_shape);
- Ref<Shape> get_shape() const;
+ void set_shape(Ref<Shape3D> p_shape);
+ Ref<Shape3D> get_shape() const;
void set_mask(uint32_t p_mask);
uint32_t get_mask();
void add_excluded_object(RID p_rid);
@@ -62,7 +62,7 @@ public:
void set_margin(float p_margin);
float get_margin();
- SpringArm();
+ SpringArm3D();
private:
void process_spring();
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index fd22076091..360e95e76a 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -377,13 +377,13 @@ SpriteBase3D::SpriteBase3D() {
modulate = Color(1, 1, 1, 1);
pending_update = false;
opacity = 1.0;
- immediate = VisualServer::get_singleton()->immediate_create();
+ immediate = RenderingServer::get_singleton()->immediate_create();
set_base(immediate);
}
SpriteBase3D::~SpriteBase3D() {
- VisualServer::get_singleton()->free(immediate);
+ RenderingServer::get_singleton()->free(immediate);
}
///////////////////////////////////////////
@@ -392,7 +392,7 @@ void Sprite3D::_draw() {
RID immediate = get_immediate();
- VS::get_singleton()->immediate_clear(immediate);
+ RS::get_singleton()->immediate_clear(immediate);
if (!texture.is_valid())
return;
Vector2 tsize = texture->get_size();
@@ -475,9 +475,9 @@ void Sprite3D::_draw() {
}
RID mat = StandardMaterial3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y);
- VS::get_singleton()->immediate_set_material(immediate, mat);
+ RS::get_singleton()->immediate_set_material(immediate, mat);
- VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid());
+ RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_TRIANGLES, texture->get_rid());
int x_axis = ((axis + 1) % 3);
int y_axis = ((axis + 2) % 3);
@@ -502,15 +502,15 @@ void Sprite3D::_draw() {
static const int index[6] = { 0, 1, 2, 0, 2, 3 };
- VS::get_singleton()->immediate_normal(immediate, normal);
- VS::get_singleton()->immediate_tangent(immediate, tangent);
- VS::get_singleton()->immediate_color(immediate, color);
- VS::get_singleton()->immediate_uv(immediate, uvs[i]);
+ RS::get_singleton()->immediate_normal(immediate, normal);
+ RS::get_singleton()->immediate_tangent(immediate, tangent);
+ RS::get_singleton()->immediate_color(immediate, color);
+ RS::get_singleton()->immediate_uv(immediate, uvs[i]);
Vector3 vtx;
vtx[x_axis] = vertices[index[i]][0];
vtx[y_axis] = vertices[index[i]][1];
- VS::get_singleton()->immediate_vertex(immediate, vtx);
+ RS::get_singleton()->immediate_vertex(immediate, vtx);
if (i == 0) {
aabb.position = vtx;
aabb.size = Vector3();
@@ -519,7 +519,7 @@ void Sprite3D::_draw() {
}
}
set_aabb(aabb);
- VS::get_singleton()->immediate_end(immediate);
+ RS::get_singleton()->immediate_end(immediate);
}
void Sprite3D::_texture_changed() {
@@ -717,7 +717,7 @@ Sprite3D::Sprite3D() {
void AnimatedSprite3D::_draw() {
RID immediate = get_immediate();
- VS::get_singleton()->immediate_clear(immediate);
+ RS::get_singleton()->immediate_clear(immediate);
if (frames.is_null()) {
return;
@@ -810,9 +810,9 @@ void AnimatedSprite3D::_draw() {
RID mat = StandardMaterial3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y);
- VS::get_singleton()->immediate_set_material(immediate, mat);
+ RS::get_singleton()->immediate_set_material(immediate, mat);
- VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid());
+ RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_TRIANGLES, texture->get_rid());
int x_axis = ((axis + 1) % 3);
int y_axis = ((axis + 2) % 3);
@@ -840,15 +840,15 @@ void AnimatedSprite3D::_draw() {
0, 2, 3
};
- VS::get_singleton()->immediate_normal(immediate, normal);
- VS::get_singleton()->immediate_tangent(immediate, tangent);
- VS::get_singleton()->immediate_color(immediate, color);
- VS::get_singleton()->immediate_uv(immediate, uvs[i]);
+ RS::get_singleton()->immediate_normal(immediate, normal);
+ RS::get_singleton()->immediate_tangent(immediate, tangent);
+ RS::get_singleton()->immediate_color(immediate, color);
+ RS::get_singleton()->immediate_uv(immediate, uvs[i]);
Vector3 vtx;
vtx[x_axis] = vertices[indices[i]][0];
vtx[y_axis] = vertices[indices[i]][1];
- VS::get_singleton()->immediate_vertex(immediate, vtx);
+ RS::get_singleton()->immediate_vertex(immediate, vtx);
if (i == 0) {
aabb.position = vtx;
aabb.size = Vector3();
@@ -857,7 +857,7 @@ void AnimatedSprite3D::_draw() {
}
}
set_aabb(aabb);
- VS::get_singleton()->immediate_end(immediate);
+ RS::get_singleton()->immediate_end(immediate);
}
void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 082884c83b..64bef41fd8 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -31,12 +31,12 @@
#ifndef SPRITE_3D_H
#define SPRITE_3D_H
-#include "scene/2d/animated_sprite.h"
-#include "scene/3d/visual_instance.h"
+#include "scene/2d/animated_sprite_2d.h"
+#include "scene/3d/visual_instance_3d.h"
-class SpriteBase3D : public GeometryInstance {
+class SpriteBase3D : public GeometryInstance3D {
- GDCLASS(SpriteBase3D, GeometryInstance);
+ GDCLASS(SpriteBase3D, GeometryInstance3D);
mutable Ref<TriangleMesh> triangle_mesh; //cached
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body_3d.cpp
index c249d844d1..5984b776b2 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* vehicle_body.cpp */
+/* vehicle_body_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "vehicle_body.h"
+#include "vehicle_body_3d.h"
#define ROLLING_INFLUENCE_FIX
@@ -78,11 +78,11 @@ public:
}
};
-void VehicleWheel::_notification(int p_what) {
+void VehicleWheel3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- VehicleBody *cb = Object::cast_to<VehicleBody>(get_parent());
+ VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
if (!cb)
return;
body = cb;
@@ -95,7 +95,7 @@ void VehicleWheel::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
- VehicleBody *cb = Object::cast_to<VehicleBody>(get_parent());
+ VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
if (!cb)
return;
cb->wheels.erase(this);
@@ -103,15 +103,15 @@ void VehicleWheel::_notification(int p_what) {
}
}
-String VehicleWheel::get_configuration_warning() const {
- if (!Object::cast_to<VehicleBody>(get_parent())) {
+String VehicleWheel3D::get_configuration_warning() const {
+ if (!Object::cast_to<VehicleBody3D>(get_parent())) {
return TTR("VehicleWheel serves to provide a wheel system to a VehicleBody. Please use it as a child of a VehicleBody.");
}
return String();
}
-void VehicleWheel::_update(PhysicsDirectBodyState *s) {
+void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) {
if (m_raycastInfo.m_isInContact)
@@ -144,142 +144,142 @@ void VehicleWheel::_update(PhysicsDirectBodyState *s) {
}
}
-void VehicleWheel::set_radius(float p_radius) {
+void VehicleWheel3D::set_radius(float p_radius) {
m_wheelRadius = p_radius;
update_gizmo();
}
-float VehicleWheel::get_radius() const {
+float VehicleWheel3D::get_radius() const {
return m_wheelRadius;
}
-void VehicleWheel::set_suspension_rest_length(float p_length) {
+void VehicleWheel3D::set_suspension_rest_length(float p_length) {
m_suspensionRestLength = p_length;
update_gizmo();
}
-float VehicleWheel::get_suspension_rest_length() const {
+float VehicleWheel3D::get_suspension_rest_length() const {
return m_suspensionRestLength;
}
-void VehicleWheel::set_suspension_travel(float p_length) {
+void VehicleWheel3D::set_suspension_travel(float p_length) {
m_maxSuspensionTravelCm = p_length / 0.01;
}
-float VehicleWheel::get_suspension_travel() const {
+float VehicleWheel3D::get_suspension_travel() const {
return m_maxSuspensionTravelCm * 0.01;
}
-void VehicleWheel::set_suspension_stiffness(float p_value) {
+void VehicleWheel3D::set_suspension_stiffness(float p_value) {
m_suspensionStiffness = p_value;
}
-float VehicleWheel::get_suspension_stiffness() const {
+float VehicleWheel3D::get_suspension_stiffness() const {
return m_suspensionStiffness;
}
-void VehicleWheel::set_suspension_max_force(float p_value) {
+void VehicleWheel3D::set_suspension_max_force(float p_value) {
m_maxSuspensionForce = p_value;
}
-float VehicleWheel::get_suspension_max_force() const {
+float VehicleWheel3D::get_suspension_max_force() const {
return m_maxSuspensionForce;
}
-void VehicleWheel::set_damping_compression(float p_value) {
+void VehicleWheel3D::set_damping_compression(float p_value) {
m_wheelsDampingCompression = p_value;
}
-float VehicleWheel::get_damping_compression() const {
+float VehicleWheel3D::get_damping_compression() const {
return m_wheelsDampingCompression;
}
-void VehicleWheel::set_damping_relaxation(float p_value) {
+void VehicleWheel3D::set_damping_relaxation(float p_value) {
m_wheelsDampingRelaxation = p_value;
}
-float VehicleWheel::get_damping_relaxation() const {
+float VehicleWheel3D::get_damping_relaxation() const {
return m_wheelsDampingRelaxation;
}
-void VehicleWheel::set_friction_slip(float p_value) {
+void VehicleWheel3D::set_friction_slip(float p_value) {
m_frictionSlip = p_value;
}
-float VehicleWheel::get_friction_slip() const {
+float VehicleWheel3D::get_friction_slip() const {
return m_frictionSlip;
}
-void VehicleWheel::set_roll_influence(float p_value) {
+void VehicleWheel3D::set_roll_influence(float p_value) {
m_rollInfluence = p_value;
}
-float VehicleWheel::get_roll_influence() const {
+float VehicleWheel3D::get_roll_influence() const {
return m_rollInfluence;
}
-bool VehicleWheel::is_in_contact() const {
+bool VehicleWheel3D::is_in_contact() const {
return m_raycastInfo.m_isInContact;
}
-void VehicleWheel::_bind_methods() {
+void VehicleWheel3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel3D::get_radius);
- ClassDB::bind_method(D_METHOD("set_suspension_rest_length", "length"), &VehicleWheel::set_suspension_rest_length);
- ClassDB::bind_method(D_METHOD("get_suspension_rest_length"), &VehicleWheel::get_suspension_rest_length);
+ ClassDB::bind_method(D_METHOD("set_suspension_rest_length", "length"), &VehicleWheel3D::set_suspension_rest_length);
+ ClassDB::bind_method(D_METHOD("get_suspension_rest_length"), &VehicleWheel3D::get_suspension_rest_length);
- ClassDB::bind_method(D_METHOD("set_suspension_travel", "length"), &VehicleWheel::set_suspension_travel);
- ClassDB::bind_method(D_METHOD("get_suspension_travel"), &VehicleWheel::get_suspension_travel);
+ ClassDB::bind_method(D_METHOD("set_suspension_travel", "length"), &VehicleWheel3D::set_suspension_travel);
+ ClassDB::bind_method(D_METHOD("get_suspension_travel"), &VehicleWheel3D::get_suspension_travel);
- ClassDB::bind_method(D_METHOD("set_suspension_stiffness", "length"), &VehicleWheel::set_suspension_stiffness);
- ClassDB::bind_method(D_METHOD("get_suspension_stiffness"), &VehicleWheel::get_suspension_stiffness);
+ ClassDB::bind_method(D_METHOD("set_suspension_stiffness", "length"), &VehicleWheel3D::set_suspension_stiffness);
+ ClassDB::bind_method(D_METHOD("get_suspension_stiffness"), &VehicleWheel3D::get_suspension_stiffness);
- ClassDB::bind_method(D_METHOD("set_suspension_max_force", "length"), &VehicleWheel::set_suspension_max_force);
- ClassDB::bind_method(D_METHOD("get_suspension_max_force"), &VehicleWheel::get_suspension_max_force);
+ ClassDB::bind_method(D_METHOD("set_suspension_max_force", "length"), &VehicleWheel3D::set_suspension_max_force);
+ ClassDB::bind_method(D_METHOD("get_suspension_max_force"), &VehicleWheel3D::get_suspension_max_force);
- ClassDB::bind_method(D_METHOD("set_damping_compression", "length"), &VehicleWheel::set_damping_compression);
- ClassDB::bind_method(D_METHOD("get_damping_compression"), &VehicleWheel::get_damping_compression);
+ ClassDB::bind_method(D_METHOD("set_damping_compression", "length"), &VehicleWheel3D::set_damping_compression);
+ ClassDB::bind_method(D_METHOD("get_damping_compression"), &VehicleWheel3D::get_damping_compression);
- ClassDB::bind_method(D_METHOD("set_damping_relaxation", "length"), &VehicleWheel::set_damping_relaxation);
- ClassDB::bind_method(D_METHOD("get_damping_relaxation"), &VehicleWheel::get_damping_relaxation);
+ ClassDB::bind_method(D_METHOD("set_damping_relaxation", "length"), &VehicleWheel3D::set_damping_relaxation);
+ ClassDB::bind_method(D_METHOD("get_damping_relaxation"), &VehicleWheel3D::get_damping_relaxation);
- ClassDB::bind_method(D_METHOD("set_use_as_traction", "enable"), &VehicleWheel::set_use_as_traction);
- ClassDB::bind_method(D_METHOD("is_used_as_traction"), &VehicleWheel::is_used_as_traction);
+ ClassDB::bind_method(D_METHOD("set_use_as_traction", "enable"), &VehicleWheel3D::set_use_as_traction);
+ ClassDB::bind_method(D_METHOD("is_used_as_traction"), &VehicleWheel3D::is_used_as_traction);
- ClassDB::bind_method(D_METHOD("set_use_as_steering", "enable"), &VehicleWheel::set_use_as_steering);
- ClassDB::bind_method(D_METHOD("is_used_as_steering"), &VehicleWheel::is_used_as_steering);
+ ClassDB::bind_method(D_METHOD("set_use_as_steering", "enable"), &VehicleWheel3D::set_use_as_steering);
+ ClassDB::bind_method(D_METHOD("is_used_as_steering"), &VehicleWheel3D::is_used_as_steering);
- ClassDB::bind_method(D_METHOD("set_friction_slip", "length"), &VehicleWheel::set_friction_slip);
- ClassDB::bind_method(D_METHOD("get_friction_slip"), &VehicleWheel::get_friction_slip);
+ ClassDB::bind_method(D_METHOD("set_friction_slip", "length"), &VehicleWheel3D::set_friction_slip);
+ ClassDB::bind_method(D_METHOD("get_friction_slip"), &VehicleWheel3D::get_friction_slip);
- ClassDB::bind_method(D_METHOD("is_in_contact"), &VehicleWheel::is_in_contact);
+ ClassDB::bind_method(D_METHOD("is_in_contact"), &VehicleWheel3D::is_in_contact);
- ClassDB::bind_method(D_METHOD("set_roll_influence", "roll_influence"), &VehicleWheel::set_roll_influence);
- ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel::get_roll_influence);
+ ClassDB::bind_method(D_METHOD("set_roll_influence", "roll_influence"), &VehicleWheel3D::set_roll_influence);
+ ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel3D::get_roll_influence);
- ClassDB::bind_method(D_METHOD("get_skidinfo"), &VehicleWheel::get_skidinfo);
+ ClassDB::bind_method(D_METHOD("get_skidinfo"), &VehicleWheel3D::get_skidinfo);
- ClassDB::bind_method(D_METHOD("get_rpm"), &VehicleWheel::get_rpm);
+ ClassDB::bind_method(D_METHOD("get_rpm"), &VehicleWheel3D::get_rpm);
- ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleWheel::set_engine_force);
- ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleWheel::get_engine_force);
+ ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleWheel3D::set_engine_force);
+ ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleWheel3D::get_engine_force);
- ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleWheel::set_brake);
- ClassDB::bind_method(D_METHOD("get_brake"), &VehicleWheel::get_brake);
+ ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleWheel3D::set_brake);
+ ClassDB::bind_method(D_METHOD("get_brake"), &VehicleWheel3D::get_brake);
- ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleWheel::set_steering);
- ClassDB::bind_method(D_METHOD("get_steering"), &VehicleWheel::get_steering);
+ ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleWheel3D::set_steering);
+ ClassDB::bind_method(D_METHOD("get_steering"), &VehicleWheel3D::get_steering);
ADD_GROUP("Per-Wheel Motion", "");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force");
@@ -302,65 +302,65 @@ void VehicleWheel::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "damping_relaxation"), "set_damping_relaxation", "get_damping_relaxation");
}
-void VehicleWheel::set_engine_force(float p_engine_force) {
+void VehicleWheel3D::set_engine_force(float p_engine_force) {
m_engineForce = p_engine_force;
}
-float VehicleWheel::get_engine_force() const {
+float VehicleWheel3D::get_engine_force() const {
return m_engineForce;
}
-void VehicleWheel::set_brake(float p_brake) {
+void VehicleWheel3D::set_brake(float p_brake) {
m_brake = p_brake;
}
-float VehicleWheel::get_brake() const {
+float VehicleWheel3D::get_brake() const {
return m_brake;
}
-void VehicleWheel::set_steering(float p_steering) {
+void VehicleWheel3D::set_steering(float p_steering) {
m_steering = p_steering;
}
-float VehicleWheel::get_steering() const {
+float VehicleWheel3D::get_steering() const {
return m_steering;
}
-void VehicleWheel::set_use_as_traction(bool p_enable) {
+void VehicleWheel3D::set_use_as_traction(bool p_enable) {
engine_traction = p_enable;
}
-bool VehicleWheel::is_used_as_traction() const {
+bool VehicleWheel3D::is_used_as_traction() const {
return engine_traction;
}
-void VehicleWheel::set_use_as_steering(bool p_enabled) {
+void VehicleWheel3D::set_use_as_steering(bool p_enabled) {
steers = p_enabled;
}
-bool VehicleWheel::is_used_as_steering() const {
+bool VehicleWheel3D::is_used_as_steering() const {
return steers;
}
-float VehicleWheel::get_skidinfo() const {
+float VehicleWheel3D::get_skidinfo() const {
return m_skidInfo;
}
-float VehicleWheel::get_rpm() const {
+float VehicleWheel3D::get_rpm() const {
return m_rpm;
}
-VehicleWheel::VehicleWheel() {
+VehicleWheel3D::VehicleWheel3D() {
steers = false;
engine_traction = false;
@@ -388,7 +388,7 @@ VehicleWheel::VehicleWheel() {
body = NULL;
}
-void VehicleBody::_update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBodyState *s) {
+void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s) {
wheel.m_raycastInfo.m_isInContact = false;
@@ -405,9 +405,9 @@ void VehicleBody::_update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBody
wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.get_basis().xform(wheel.m_wheelAxleCS).normalized();
}
-void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
+void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState3D *s) {
- VehicleWheel &wheel = *wheels[p_idx];
+ VehicleWheel3D &wheel = *wheels[p_idx];
_update_wheel_transform(wheel, s);
Vector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS;
@@ -430,9 +430,9 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength);
}
-real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
+real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
- VehicleWheel &wheel = *wheels[p_idx];
+ VehicleWheel3D &wheel = *wheels[p_idx];
_update_wheel_transform(wheel, s);
@@ -448,9 +448,9 @@ real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
real_t param = real_t(0.);
- PhysicsDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState3D::RayResult rr;
- PhysicsDirectSpaceState *ss = s->get_space_state();
+ PhysicsDirectSpaceState3D *ss = s->get_space_state();
bool col = ss->intersect_ray(source, target, rr, exclude);
@@ -463,7 +463,7 @@ real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
wheel.m_raycastInfo.m_isInContact = true;
if (rr.collider)
- wheel.m_raycastInfo.m_groundObject = Object::cast_to<PhysicsBody>(rr.collider);
+ wheel.m_raycastInfo.m_groundObject = Object::cast_to<PhysicsBody3D>(rr.collider);
real_t hitDistance = param * raylen;
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
@@ -513,12 +513,12 @@ real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
return depth;
}
-void VehicleBody::_update_suspension(PhysicsDirectBodyState *s) {
+void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) {
real_t chassisMass = mass;
for (int w_it = 0; w_it < wheels.size(); w_it++) {
- VehicleWheel &wheel_info = *wheels[w_it];
+ VehicleWheel3D &wheel_info = *wheels[w_it];
if (wheel_info.m_raycastInfo.m_isInContact) {
real_t force;
@@ -558,8 +558,8 @@ void VehicleBody::_update_suspension(PhysicsDirectBodyState *s) {
}
//bilateral constraint between two dynamic objects
-void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1,
- PhysicsBody *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence) {
+void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const Vector3 &pos1,
+ PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence) {
real_t normalLenSqr = normal.length_squared();
//ERR_FAIL_COND( normalLenSqr < real_t(1.1));
@@ -636,7 +636,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
#endif
}
-VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) :
+VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState3D *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) :
m_s(s),
m_body1(body1),
m_frictionPositionWorld(frictionPosWorld),
@@ -667,7 +667,7 @@ VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirec
m_jacDiagABInv = relaxation / (denom0 + denom1);
}
-real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) {
+real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) {
real_t j1 = 0.f;
@@ -698,7 +698,7 @@ real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint &contactPo
}
static const real_t sideFrictionStiffness2 = real_t(1.0);
-void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
+void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
//calculate the impulse, so that the wheels don't move sidewards
int numWheel = wheels.size();
@@ -720,7 +720,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
for (int i = 0; i < wheels.size(); i++) {
- VehicleWheel &wheelInfo = *wheels[i];
+ VehicleWheel3D &wheelInfo = *wheels[i];
if (wheelInfo.m_raycastInfo.m_isInContact) {
@@ -754,7 +754,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
bool sliding = false;
{
for (int wheel = 0; wheel < wheels.size(); wheel++) {
- VehicleWheel &wheelInfo = *wheels[wheel];
+ VehicleWheel3D &wheelInfo = *wheels[wheel];
//class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
@@ -816,7 +816,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
// apply the impulses
{
for (int wheel = 0; wheel < wheels.size(); wheel++) {
- VehicleWheel &wheelInfo = *wheels[wheel];
+ VehicleWheel3D &wheelInfo = *wheels[wheel];
Vector3 rel_pos = wheelInfo.m_raycastInfo.m_contactPointWS -
s->get_transform().origin;
@@ -825,7 +825,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
s->apply_impulse(rel_pos, m_forwardWS[wheel] * (m_forwardImpulse[wheel]));
}
if (m_sideImpulse[wheel] != real_t(0.)) {
- PhysicsBody *groundObject = wheelInfo.m_raycastInfo.m_groundObject;
+ PhysicsBody3D *groundObject = wheelInfo.m_raycastInfo.m_groundObject;
Vector3 rel_pos2;
if (groundObject) {
@@ -850,11 +850,11 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
}
}
-void VehicleBody::_direct_state_changed(Object *p_state) {
+void VehicleBody3D::_direct_state_changed(Object *p_state) {
- RigidBody::_direct_state_changed(p_state);
+ RigidBody3D::_direct_state_changed(p_state);
- state = Object::cast_to<PhysicsDirectBodyState>(p_state);
+ state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
float step = state->get_step();
@@ -874,7 +874,7 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
for (int i = 0; i < wheels.size(); i++) {
//apply suspension force
- VehicleWheel &wheel = *wheels[i];
+ VehicleWheel3D &wheel = *wheels[i];
real_t suspensionForce = wheel.m_wheelsSuspensionForce;
@@ -891,7 +891,7 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
_update_friction(state);
for (int i = 0; i < wheels.size(); i++) {
- VehicleWheel &wheel = *wheels[i];
+ VehicleWheel3D &wheel = *wheels[i];
Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - state->get_transform().origin;
Vector3 vel = state->get_linear_velocity() + (state->get_angular_velocity()).cross(relpos); // * mPos);
@@ -920,58 +920,58 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
state = NULL;
}
-void VehicleBody::set_engine_force(float p_engine_force) {
+void VehicleBody3D::set_engine_force(float p_engine_force) {
engine_force = p_engine_force;
for (int i = 0; i < wheels.size(); i++) {
- VehicleWheel &wheelInfo = *wheels[i];
+ VehicleWheel3D &wheelInfo = *wheels[i];
if (wheelInfo.engine_traction)
wheelInfo.m_engineForce = p_engine_force;
}
}
-float VehicleBody::get_engine_force() const {
+float VehicleBody3D::get_engine_force() const {
return engine_force;
}
-void VehicleBody::set_brake(float p_brake) {
+void VehicleBody3D::set_brake(float p_brake) {
brake = p_brake;
for (int i = 0; i < wheels.size(); i++) {
- VehicleWheel &wheelInfo = *wheels[i];
+ VehicleWheel3D &wheelInfo = *wheels[i];
wheelInfo.m_brake = p_brake;
}
}
-float VehicleBody::get_brake() const {
+float VehicleBody3D::get_brake() const {
return brake;
}
-void VehicleBody::set_steering(float p_steering) {
+void VehicleBody3D::set_steering(float p_steering) {
m_steeringValue = p_steering;
for (int i = 0; i < wheels.size(); i++) {
- VehicleWheel &wheelInfo = *wheels[i];
+ VehicleWheel3D &wheelInfo = *wheels[i];
if (wheelInfo.steers)
wheelInfo.m_steering = p_steering;
}
}
-float VehicleBody::get_steering() const {
+float VehicleBody3D::get_steering() const {
return m_steeringValue;
}
-void VehicleBody::_bind_methods() {
+void VehicleBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody::set_engine_force);
- ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody::get_engine_force);
+ ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody3D::set_engine_force);
+ ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody3D::get_engine_force);
- ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleBody::set_brake);
- ClassDB::bind_method(D_METHOD("get_brake"), &VehicleBody::get_brake);
+ ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleBody3D::set_brake);
+ ClassDB::bind_method(D_METHOD("get_brake"), &VehicleBody3D::get_brake);
- ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody::set_steering);
- ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody::get_steering);
+ ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody3D::set_steering);
+ ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody3D::get_steering);
ADD_GROUP("Motion", "");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force");
@@ -979,7 +979,7 @@ void VehicleBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering");
}
-VehicleBody::VehicleBody() {
+VehicleBody3D::VehicleBody3D() {
m_pitchControl = 0;
m_currentVehicleSpeedKmHour = real_t(0.);
@@ -992,7 +992,7 @@ VehicleBody::VehicleBody() {
ccd = false;
exclude.insert(get_rid());
- //PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ //PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
set_mass(40);
}
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body_3d.h
index c05ea30f94..d5e896263d 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* vehicle_body.h */
+/* vehicle_body_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,15 +31,15 @@
#ifndef VEHICLE_BODY_H
#define VEHICLE_BODY_H
-#include "scene/3d/physics_body.h"
+#include "scene/3d/physics_body_3d.h"
-class VehicleBody;
+class VehicleBody3D;
-class VehicleWheel : public Spatial {
+class VehicleWheel3D : public Node3D {
- GDCLASS(VehicleWheel, Spatial);
+ GDCLASS(VehicleWheel3D, Node3D);
- friend class VehicleBody;
+ friend class VehicleBody3D;
Transform m_worldTransform;
Transform local_xform;
@@ -61,7 +61,7 @@ class VehicleWheel : public Spatial {
real_t m_maxSuspensionForce;
bool m_bIsFrontWheel;
- VehicleBody *body;
+ VehicleBody3D *body;
//btVector3 m_wheelAxleCS; // const or modified by steering ?
@@ -88,10 +88,10 @@ class VehicleWheel : public Spatial {
Vector3 m_wheelDirectionWS; //direction in worldspace
Vector3 m_wheelAxleWS; // axle in worldspace
bool m_isInContact;
- PhysicsBody *m_groundObject; //could be general void* ptr
+ PhysicsBody3D *m_groundObject; //could be general void* ptr
} m_raycastInfo;
- void _update(PhysicsDirectBodyState *s);
+ void _update(PhysicsDirectBodyState3D *s);
protected:
void _notification(int p_what);
@@ -148,12 +148,12 @@ public:
String get_configuration_warning() const;
- VehicleWheel();
+ VehicleWheel3D();
};
-class VehicleBody : public RigidBody {
+class VehicleBody3D : public RigidBody3D {
- GDCLASS(VehicleBody, RigidBody);
+ GDCLASS(VehicleBody3D, RigidBody3D);
float engine_force;
float brake;
@@ -170,27 +170,27 @@ class VehicleBody : public RigidBody {
Vector<real_t> m_sideImpulse;
struct btVehicleWheelContactPoint {
- PhysicsDirectBodyState *m_s;
- PhysicsBody *m_body1;
+ PhysicsDirectBodyState3D *m_s;
+ PhysicsBody3D *m_body1;
Vector3 m_frictionPositionWorld;
Vector3 m_frictionDirectionWorld;
real_t m_jacDiagABInv;
real_t m_maxImpulse;
- btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse);
+ btVehicleWheelContactPoint(PhysicsDirectBodyState3D *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse);
};
- void _resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1, PhysicsBody *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence);
+ void _resolve_single_bilateral(PhysicsDirectBodyState3D *s, const Vector3 &pos1, PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence);
real_t _calc_rolling_friction(btVehicleWheelContactPoint &contactPoint);
- void _update_friction(PhysicsDirectBodyState *s);
- void _update_suspension(PhysicsDirectBodyState *s);
- real_t _ray_cast(int p_idx, PhysicsDirectBodyState *s);
- void _update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBodyState *s);
- void _update_wheel(int p_idx, PhysicsDirectBodyState *s);
+ void _update_friction(PhysicsDirectBodyState3D *s);
+ void _update_suspension(PhysicsDirectBodyState3D *s);
+ real_t _ray_cast(int p_idx, PhysicsDirectBodyState3D *s);
+ void _update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s);
+ void _update_wheel(int p_idx, PhysicsDirectBodyState3D *s);
- friend class VehicleWheel;
- Vector<VehicleWheel *> wheels;
+ friend class VehicleWheel3D;
+ Vector<VehicleWheel3D *> wheels;
static void _bind_methods();
@@ -206,7 +206,7 @@ public:
void set_steering(float p_steering);
float get_steering() const;
- VehicleBody();
+ VehicleBody3D();
};
#endif // VEHICLE_BODY_H
diff --git a/scene/3d/spatial_velocity_tracker.cpp b/scene/3d/velocity_tracker_3d.cpp
index ec1bb1f991..c9b95e6397 100644
--- a/scene/3d/spatial_velocity_tracker.cpp
+++ b/scene/3d/velocity_tracker_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial_velocity_tracker.cpp */
+/* velocity_tracker_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,19 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "spatial_velocity_tracker.h"
+#include "velocity_tracker_3d.h"
#include "core/engine.h"
-void SpatialVelocityTracker::set_track_physics_step(bool p_track_physics_step) {
+void VelocityTracker3D::set_track_physics_step(bool p_track_physics_step) {
physics_step = p_track_physics_step;
}
-bool SpatialVelocityTracker::is_tracking_physics_step() const {
+bool VelocityTracker3D::is_tracking_physics_step() const {
return physics_step;
}
-void SpatialVelocityTracker::update_position(const Vector3 &p_position) {
+void VelocityTracker3D::update_position(const Vector3 &p_position) {
PositionHistory ph;
ph.position = p_position;
@@ -59,7 +59,7 @@ void SpatialVelocityTracker::update_position(const Vector3 &p_position) {
position_history.write[0] = ph;
}
-Vector3 SpatialVelocityTracker::get_tracked_linear_velocity() const {
+Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
Vector3 linear_velocity;
@@ -104,7 +104,7 @@ Vector3 SpatialVelocityTracker::get_tracked_linear_velocity() const {
return linear_velocity;
}
-void SpatialVelocityTracker::reset(const Vector3 &p_new_pos) {
+void VelocityTracker3D::reset(const Vector3 &p_new_pos) {
PositionHistory ph;
ph.position = p_new_pos;
@@ -118,18 +118,18 @@ void SpatialVelocityTracker::reset(const Vector3 &p_new_pos) {
position_history_len = 1;
}
-void SpatialVelocityTracker::_bind_methods() {
+void VelocityTracker3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_track_physics_step", "enable"), &SpatialVelocityTracker::set_track_physics_step);
- ClassDB::bind_method(D_METHOD("is_tracking_physics_step"), &SpatialVelocityTracker::is_tracking_physics_step);
- ClassDB::bind_method(D_METHOD("update_position", "position"), &SpatialVelocityTracker::update_position);
- ClassDB::bind_method(D_METHOD("get_tracked_linear_velocity"), &SpatialVelocityTracker::get_tracked_linear_velocity);
- ClassDB::bind_method(D_METHOD("reset", "position"), &SpatialVelocityTracker::reset);
+ ClassDB::bind_method(D_METHOD("set_track_physics_step", "enable"), &VelocityTracker3D::set_track_physics_step);
+ ClassDB::bind_method(D_METHOD("is_tracking_physics_step"), &VelocityTracker3D::is_tracking_physics_step);
+ ClassDB::bind_method(D_METHOD("update_position", "position"), &VelocityTracker3D::update_position);
+ ClassDB::bind_method(D_METHOD("get_tracked_linear_velocity"), &VelocityTracker3D::get_tracked_linear_velocity);
+ ClassDB::bind_method(D_METHOD("reset", "position"), &VelocityTracker3D::reset);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "track_physics_step"), "set_track_physics_step", "is_tracking_physics_step");
}
-SpatialVelocityTracker::SpatialVelocityTracker() {
+VelocityTracker3D::VelocityTracker3D() {
position_history.resize(4); // should be configurable
position_history_len = 0;
physics_step = false;
diff --git a/scene/3d/spatial_velocity_tracker.h b/scene/3d/velocity_tracker_3d.h
index 92b527b93c..a7ab3dce4d 100644
--- a/scene/3d/spatial_velocity_tracker.h
+++ b/scene/3d/velocity_tracker_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* spatial_velocity_tracker.h */
+/* velocity_tracker_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,10 +31,10 @@
#ifndef SPATIAL_VELOCITY_TRACKER_H
#define SPATIAL_VELOCITY_TRACKER_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
-class SpatialVelocityTracker : public Reference {
- GDCLASS(SpatialVelocityTracker, Reference);
+class VelocityTracker3D : public Reference {
+ GDCLASS(VelocityTracker3D, Reference);
struct PositionHistory {
uint64_t frame;
@@ -55,7 +55,7 @@ public:
void update_position(const Vector3 &p_position);
Vector3 get_tracked_linear_velocity() const;
- SpatialVelocityTracker();
+ VelocityTracker3D();
};
#endif // SPATIAL_VELOCITY_TRACKER_H
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier_3d.cpp
index 5bc568bd5d..2f657fe7b1 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visibility_notifier.cpp */
+/* visibility_notifier_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visibility_notifier.h"
+#include "visibility_notifier_3d.h"
#include "core/engine.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/physics_body.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/physics_body_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
-void VisibilityNotifier::_enter_camera(Camera *p_camera) {
+void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) {
ERR_FAIL_COND(cameras.has(p_camera));
cameras.insert(p_camera);
@@ -48,7 +48,7 @@ void VisibilityNotifier::_enter_camera(Camera *p_camera) {
emit_signal(SceneStringNames::get_singleton()->camera_entered, p_camera);
}
-void VisibilityNotifier::_exit_camera(Camera *p_camera) {
+void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) {
ERR_FAIL_COND(!cameras.has(p_camera));
cameras.erase(p_camera);
@@ -61,7 +61,7 @@ void VisibilityNotifier::_exit_camera(Camera *p_camera) {
}
}
-void VisibilityNotifier::set_aabb(const AABB &p_aabb) {
+void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) {
if (aabb == p_aabb)
return;
@@ -75,12 +75,12 @@ void VisibilityNotifier::set_aabb(const AABB &p_aabb) {
update_gizmo();
}
-AABB VisibilityNotifier::get_aabb() const {
+AABB VisibilityNotifier3D::get_aabb() const {
return aabb;
}
-void VisibilityNotifier::_notification(int p_what) {
+void VisibilityNotifier3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
@@ -98,26 +98,26 @@ void VisibilityNotifier::_notification(int p_what) {
}
}
-bool VisibilityNotifier::is_on_screen() const {
+bool VisibilityNotifier3D::is_on_screen() const {
return cameras.size() != 0;
}
-void VisibilityNotifier::_bind_methods() {
+void VisibilityNotifier3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibilityNotifier::set_aabb);
- ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier::get_aabb);
- ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier::is_on_screen);
+ ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibilityNotifier3D::set_aabb);
+ ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier3D::get_aabb);
+ ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier3D::is_on_screen);
ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb");
- ADD_SIGNAL(MethodInfo("camera_entered", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
- ADD_SIGNAL(MethodInfo("camera_exited", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
+ ADD_SIGNAL(MethodInfo("camera_entered", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D")));
+ ADD_SIGNAL(MethodInfo("camera_exited", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D")));
ADD_SIGNAL(MethodInfo("screen_entered"));
ADD_SIGNAL(MethodInfo("screen_exited"));
}
-VisibilityNotifier::VisibilityNotifier() {
+VisibilityNotifier3D::VisibilityNotifier3D() {
aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
set_notify_transform(true);
@@ -125,7 +125,7 @@ VisibilityNotifier::VisibilityNotifier() {
//////////////////////////////////////
-void VisibilityEnabler::_screen_enter() {
+void VisibilityEnabler3D::_screen_enter() {
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
@@ -135,7 +135,7 @@ void VisibilityEnabler::_screen_enter() {
visible = true;
}
-void VisibilityEnabler::_screen_exit() {
+void VisibilityEnabler3D::_screen_exit() {
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
@@ -145,14 +145,14 @@ void VisibilityEnabler::_screen_exit() {
visible = false;
}
-void VisibilityEnabler::_find_nodes(Node *p_node) {
+void VisibilityEnabler3D::_find_nodes(Node *p_node) {
bool add = false;
Variant meta;
{
- RigidBody *rb = Object::cast_to<RigidBody>(p_node);
- if (rb && ((rb->get_mode() == RigidBody::MODE_CHARACTER || rb->get_mode() == RigidBody::MODE_RIGID))) {
+ RigidBody3D *rb = Object::cast_to<RigidBody3D>(p_node);
+ if (rb && ((rb->get_mode() == RigidBody3D::MODE_CHARACTER || rb->get_mode() == RigidBody3D::MODE_RIGID))) {
add = true;
meta = rb->get_mode();
@@ -168,7 +168,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
if (add) {
- p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler::_node_removed), varray(p_node), CONNECT_ONESHOT);
+ p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed), varray(p_node), CONNECT_ONESHOT);
nodes[p_node] = meta;
_change_node_state(p_node, false);
}
@@ -182,7 +182,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
}
}
-void VisibilityEnabler::_notification(int p_what) {
+void VisibilityEnabler3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -206,19 +206,19 @@ void VisibilityEnabler::_notification(int p_what) {
if (!visible)
_change_node_state(E->key(), true);
- E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler::_node_removed));
+ E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed));
}
nodes.clear();
}
}
-void VisibilityEnabler::_change_node_state(Node *p_node, bool p_enabled) {
+void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) {
ERR_FAIL_COND(!nodes.has(p_node));
if (enabler[ENABLER_FREEZE_BODIES]) {
- RigidBody *rb = Object::cast_to<RigidBody>(p_node);
+ RigidBody3D *rb = Object::cast_to<RigidBody3D>(p_node);
if (rb)
rb->set_sleeping(!p_enabled);
@@ -234,17 +234,17 @@ void VisibilityEnabler::_change_node_state(Node *p_node, bool p_enabled) {
}
}
-void VisibilityEnabler::_node_removed(Node *p_node) {
+void VisibilityEnabler3D::_node_removed(Node *p_node) {
if (!visible)
_change_node_state(p_node, true);
nodes.erase(p_node);
}
-void VisibilityEnabler::_bind_methods() {
+void VisibilityEnabler3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler::set_enabler);
- ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler::is_enabler_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler3D::set_enabler);
+ ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler3D::is_enabler_enabled);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "pause_animations"), "set_enabler", "is_enabler_enabled", ENABLER_PAUSE_ANIMATIONS);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "freeze_bodies"), "set_enabler", "is_enabler_enabled", ENABLER_FREEZE_BODIES);
@@ -254,18 +254,18 @@ void VisibilityEnabler::_bind_methods() {
BIND_ENUM_CONSTANT(ENABLER_MAX);
}
-void VisibilityEnabler::set_enabler(Enabler p_enabler, bool p_enable) {
+void VisibilityEnabler3D::set_enabler(Enabler p_enabler, bool p_enable) {
ERR_FAIL_INDEX(p_enabler, ENABLER_MAX);
enabler[p_enabler] = p_enable;
}
-bool VisibilityEnabler::is_enabler_enabled(Enabler p_enabler) const {
+bool VisibilityEnabler3D::is_enabler_enabled(Enabler p_enabler) const {
ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false);
return enabler[p_enabler];
}
-VisibilityEnabler::VisibilityEnabler() {
+VisibilityEnabler3D::VisibilityEnabler3D() {
for (int i = 0; i < ENABLER_MAX; i++)
enabler[i] = true;
diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier_3d.h
index 71fdfdb78c..19204a6a4e 100644
--- a/scene/3d/visibility_notifier.h
+++ b/scene/3d/visibility_notifier_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visibility_notifier.h */
+/* visibility_notifier_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,14 +31,14 @@
#ifndef VISIBILITY_NOTIFIER_H
#define VISIBILITY_NOTIFIER_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
-class Camera;
-class VisibilityNotifier : public Spatial {
+class Camera3D;
+class VisibilityNotifier3D : public Node3D {
- GDCLASS(VisibilityNotifier, Spatial);
+ GDCLASS(VisibilityNotifier3D, Node3D);
- Set<Camera *> cameras;
+ Set<Camera3D *> cameras;
AABB aabb;
@@ -50,20 +50,20 @@ protected:
static void _bind_methods();
friend struct SpatialIndexer;
- void _enter_camera(Camera *p_camera);
- void _exit_camera(Camera *p_camera);
+ void _enter_camera(Camera3D *p_camera);
+ void _exit_camera(Camera3D *p_camera);
public:
void set_aabb(const AABB &p_aabb);
AABB get_aabb() const;
bool is_on_screen() const;
- VisibilityNotifier();
+ VisibilityNotifier3D();
};
-class VisibilityEnabler : public VisibilityNotifier {
+class VisibilityEnabler3D : public VisibilityNotifier3D {
- GDCLASS(VisibilityEnabler, VisibilityNotifier);
+ GDCLASS(VisibilityEnabler3D, VisibilityNotifier3D);
public:
enum Enabler {
@@ -93,9 +93,9 @@ public:
void set_enabler(Enabler p_enabler, bool p_enable);
bool is_enabler_enabled(Enabler p_enabler) const;
- VisibilityEnabler();
+ VisibilityEnabler3D();
};
-VARIANT_ENUM_CAST(VisibilityEnabler::Enabler);
+VARIANT_ENUM_CAST(VisibilityEnabler3D::Enabler);
#endif // VISIBILITY_NOTIFIER_H
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance_3d.cpp
index 105ce9ca74..775a9b76e2 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_instance.cpp */
+/* visual_instance_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,27 +28,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_instance.h"
+#include "visual_instance_3d.h"
#include "scene/scene_string_names.h"
-#include "servers/visual_server.h"
-#include "skeleton.h"
+#include "servers/rendering_server.h"
+#include "skeleton_3d.h"
-AABB VisualInstance::get_transformed_aabb() const {
+AABB VisualInstance3D::get_transformed_aabb() const {
return get_global_transform().xform(get_aabb());
}
-void VisualInstance::_update_visibility() {
+void VisualInstance3D::_update_visibility() {
if (!is_inside_tree())
return;
_change_notify("visible");
- VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree());
+ RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree());
}
-void VisualInstance::_notification(int p_what) {
+void VisualInstance3D::_notification(int p_what) {
switch (p_what) {
@@ -58,23 +58,23 @@ void VisualInstance::_notification(int p_what) {
/*
Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent());
if (skeleton)
- VisualServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
+ RenderingServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
*/
ERR_FAIL_COND(get_world().is_null());
- VisualServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
+ RenderingServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
_update_visibility();
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
Transform gt = get_global_transform();
- VisualServer::get_singleton()->instance_set_transform(instance, gt);
+ RenderingServer::get_singleton()->instance_set_transform(instance, gt);
} break;
case NOTIFICATION_EXIT_WORLD: {
- VisualServer::get_singleton()->instance_set_scenario(instance, RID());
- VisualServer::get_singleton()->instance_attach_skeleton(instance, RID());
- //VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
+ RenderingServer::get_singleton()->instance_set_scenario(instance, RID());
+ RenderingServer::get_singleton()->instance_attach_skeleton(instance, RID());
+ //RS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -84,28 +84,28 @@ void VisualInstance::_notification(int p_what) {
}
}
-RID VisualInstance::get_instance() const {
+RID VisualInstance3D::get_instance() const {
return instance;
}
-RID VisualInstance::_get_visual_instance_rid() const {
+RID VisualInstance3D::_get_visual_instance_rid() const {
return instance;
}
-void VisualInstance::set_layer_mask(uint32_t p_mask) {
+void VisualInstance3D::set_layer_mask(uint32_t p_mask) {
layers = p_mask;
- VisualServer::get_singleton()->instance_set_layer_mask(instance, p_mask);
+ RenderingServer::get_singleton()->instance_set_layer_mask(instance, p_mask);
}
-uint32_t VisualInstance::get_layer_mask() const {
+uint32_t VisualInstance3D::get_layer_mask() const {
return layers;
}
-void VisualInstance::set_layer_mask_bit(int p_layer, bool p_enable) {
+void VisualInstance3D::set_layer_mask_bit(int p_layer, bool p_enable) {
ERR_FAIL_INDEX(p_layer, 32);
if (p_enable) {
set_layer_mask(layers | (1 << p_layer));
@@ -114,184 +114,184 @@ void VisualInstance::set_layer_mask_bit(int p_layer, bool p_enable) {
}
}
-bool VisualInstance::get_layer_mask_bit(int p_layer) const {
+bool VisualInstance3D::get_layer_mask_bit(int p_layer) const {
ERR_FAIL_INDEX_V(p_layer, 32, false);
return (layers & (1 << p_layer));
}
-void VisualInstance::_bind_methods() {
+void VisualInstance3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance::_get_visual_instance_rid);
- ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance::set_base);
- ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance::get_base);
- ClassDB::bind_method(D_METHOD("get_instance"), &VisualInstance::get_instance);
- ClassDB::bind_method(D_METHOD("set_layer_mask", "mask"), &VisualInstance::set_layer_mask);
- ClassDB::bind_method(D_METHOD("get_layer_mask"), &VisualInstance::get_layer_mask);
- ClassDB::bind_method(D_METHOD("set_layer_mask_bit", "layer", "enabled"), &VisualInstance::set_layer_mask_bit);
- ClassDB::bind_method(D_METHOD("get_layer_mask_bit", "layer"), &VisualInstance::get_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance3D::_get_visual_instance_rid);
+ ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance3D::set_base);
+ ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance3D::get_base);
+ ClassDB::bind_method(D_METHOD("get_instance"), &VisualInstance3D::get_instance);
+ ClassDB::bind_method(D_METHOD("set_layer_mask", "mask"), &VisualInstance3D::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"), &VisualInstance3D::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask_bit", "layer", "enabled"), &VisualInstance3D::set_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_layer_mask_bit", "layer"), &VisualInstance3D::get_layer_mask_bit);
- ClassDB::bind_method(D_METHOD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
+ ClassDB::bind_method(D_METHOD("get_transformed_aabb"), &VisualInstance3D::get_transformed_aabb);
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_LAYERS_3D_RENDER), "set_layer_mask", "get_layer_mask");
}
-void VisualInstance::set_base(const RID &p_base) {
+void VisualInstance3D::set_base(const RID &p_base) {
- VisualServer::get_singleton()->instance_set_base(instance, p_base);
+ RenderingServer::get_singleton()->instance_set_base(instance, p_base);
base = p_base;
}
-RID VisualInstance::get_base() const {
+RID VisualInstance3D::get_base() const {
return base;
}
-VisualInstance::VisualInstance() {
+VisualInstance3D::VisualInstance3D() {
- instance = VisualServer::get_singleton()->instance_create();
- VisualServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id());
+ instance = RenderingServer::get_singleton()->instance_create();
+ RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id());
layers = 1;
set_notify_transform(true);
}
-VisualInstance::~VisualInstance() {
+VisualInstance3D::~VisualInstance3D() {
- VisualServer::get_singleton()->free(instance);
+ RenderingServer::get_singleton()->free(instance);
}
-void GeometryInstance::set_material_override(const Ref<Material> &p_material) {
+void GeometryInstance3D::set_material_override(const Ref<Material> &p_material) {
material_override = p_material;
- VS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID());
+ RS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID());
}
-Ref<Material> GeometryInstance::get_material_override() const {
+Ref<Material> GeometryInstance3D::get_material_override() const {
return material_override;
}
-void GeometryInstance::set_lod_min_distance(float p_dist) {
+void GeometryInstance3D::set_lod_min_distance(float p_dist) {
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);
+ RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
-float GeometryInstance::get_lod_min_distance() const {
+float GeometryInstance3D::get_lod_min_distance() const {
return lod_min_distance;
}
-void GeometryInstance::set_lod_max_distance(float p_dist) {
+void GeometryInstance3D::set_lod_max_distance(float p_dist) {
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);
+ RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
-float GeometryInstance::get_lod_max_distance() const {
+float GeometryInstance3D::get_lod_max_distance() const {
return lod_max_distance;
}
-void GeometryInstance::set_lod_min_hysteresis(float p_dist) {
+void GeometryInstance3D::set_lod_min_hysteresis(float p_dist) {
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);
+ RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
-float GeometryInstance::get_lod_min_hysteresis() const {
+float GeometryInstance3D::get_lod_min_hysteresis() const {
return lod_min_hysteresis;
}
-void GeometryInstance::set_lod_max_hysteresis(float p_dist) {
+void GeometryInstance3D::set_lod_max_hysteresis(float p_dist) {
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);
+ RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
-float GeometryInstance::get_lod_max_hysteresis() const {
+float GeometryInstance3D::get_lod_max_hysteresis() const {
return lod_max_hysteresis;
}
-void GeometryInstance::_notification(int p_what) {
+void GeometryInstance3D::_notification(int p_what) {
}
-void GeometryInstance::set_flag(Flags p_flag, bool p_value) {
+void GeometryInstance3D::set_flag(Flags p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
if (flags[p_flag] == p_value)
return;
flags[p_flag] = p_value;
- VS::get_singleton()->instance_geometry_set_flag(get_instance(), (VS::InstanceFlags)p_flag, p_value);
+ RS::get_singleton()->instance_geometry_set_flag(get_instance(), (RS::InstanceFlags)p_flag, p_value);
}
-bool GeometryInstance::get_flag(Flags p_flag) const {
+bool GeometryInstance3D::get_flag(Flags p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
-void GeometryInstance::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
+void GeometryInstance3D::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
shadow_casting_setting = p_shadow_casting_setting;
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (VS::ShadowCastingSetting)p_shadow_casting_setting);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (RS::ShadowCastingSetting)p_shadow_casting_setting);
}
-GeometryInstance::ShadowCastingSetting GeometryInstance::get_cast_shadows_setting() const {
+GeometryInstance3D::ShadowCastingSetting GeometryInstance3D::get_cast_shadows_setting() const {
return shadow_casting_setting;
}
-void GeometryInstance::set_extra_cull_margin(float p_margin) {
+void GeometryInstance3D::set_extra_cull_margin(float p_margin) {
ERR_FAIL_COND(p_margin < 0);
extra_cull_margin = p_margin;
- VS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin);
+ RS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin);
}
-float GeometryInstance::get_extra_cull_margin() const {
+float GeometryInstance3D::get_extra_cull_margin() const {
return extra_cull_margin;
}
-void GeometryInstance::set_custom_aabb(AABB aabb) {
+void GeometryInstance3D::set_custom_aabb(AABB aabb) {
- VS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb);
+ RS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb);
}
-void GeometryInstance::_bind_methods() {
+void GeometryInstance3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance::set_material_override);
- ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance::get_material_override);
+ ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override);
+ ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override);
- ClassDB::bind_method(D_METHOD("set_flag", "flag", "value"), &GeometryInstance::set_flag);
- ClassDB::bind_method(D_METHOD("get_flag", "flag"), &GeometryInstance::get_flag);
+ ClassDB::bind_method(D_METHOD("set_flag", "flag", "value"), &GeometryInstance3D::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag", "flag"), &GeometryInstance3D::get_flag);
- ClassDB::bind_method(D_METHOD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
- ClassDB::bind_method(D_METHOD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
+ ClassDB::bind_method(D_METHOD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance3D::set_cast_shadows_setting);
+ ClassDB::bind_method(D_METHOD("get_cast_shadows_setting"), &GeometryInstance3D::get_cast_shadows_setting);
- ClassDB::bind_method(D_METHOD("set_lod_max_hysteresis", "mode"), &GeometryInstance::set_lod_max_hysteresis);
- ClassDB::bind_method(D_METHOD("get_lod_max_hysteresis"), &GeometryInstance::get_lod_max_hysteresis);
+ ClassDB::bind_method(D_METHOD("set_lod_max_hysteresis", "mode"), &GeometryInstance3D::set_lod_max_hysteresis);
+ ClassDB::bind_method(D_METHOD("get_lod_max_hysteresis"), &GeometryInstance3D::get_lod_max_hysteresis);
- ClassDB::bind_method(D_METHOD("set_lod_max_distance", "mode"), &GeometryInstance::set_lod_max_distance);
- ClassDB::bind_method(D_METHOD("get_lod_max_distance"), &GeometryInstance::get_lod_max_distance);
+ ClassDB::bind_method(D_METHOD("set_lod_max_distance", "mode"), &GeometryInstance3D::set_lod_max_distance);
+ ClassDB::bind_method(D_METHOD("get_lod_max_distance"), &GeometryInstance3D::get_lod_max_distance);
- ClassDB::bind_method(D_METHOD("set_lod_min_hysteresis", "mode"), &GeometryInstance::set_lod_min_hysteresis);
- ClassDB::bind_method(D_METHOD("get_lod_min_hysteresis"), &GeometryInstance::get_lod_min_hysteresis);
+ ClassDB::bind_method(D_METHOD("set_lod_min_hysteresis", "mode"), &GeometryInstance3D::set_lod_min_hysteresis);
+ ClassDB::bind_method(D_METHOD("get_lod_min_hysteresis"), &GeometryInstance3D::get_lod_min_hysteresis);
- ClassDB::bind_method(D_METHOD("set_lod_min_distance", "mode"), &GeometryInstance::set_lod_min_distance);
- ClassDB::bind_method(D_METHOD("get_lod_min_distance"), &GeometryInstance::get_lod_min_distance);
+ ClassDB::bind_method(D_METHOD("set_lod_min_distance", "mode"), &GeometryInstance3D::set_lod_min_distance);
+ ClassDB::bind_method(D_METHOD("get_lod_min_distance"), &GeometryInstance3D::get_lod_min_distance);
- ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &GeometryInstance::set_extra_cull_margin);
- ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
+ ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &GeometryInstance3D::set_extra_cull_margin);
+ ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance3D::get_extra_cull_margin);
- ClassDB::bind_method(D_METHOD("set_custom_aabb", "aabb"), &GeometryInstance::set_custom_aabb);
+ ClassDB::bind_method(D_METHOD("set_custom_aabb", "aabb"), &GeometryInstance3D::set_custom_aabb);
- ClassDB::bind_method(D_METHOD("get_aabb"), &GeometryInstance::get_aabb);
+ ClassDB::bind_method(D_METHOD("get_aabb"), &GeometryInstance3D::get_aabb);
ADD_GROUP("Geometry", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE), "set_material_override", "get_material_override");
@@ -319,7 +319,7 @@ void GeometryInstance::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
}
-GeometryInstance::GeometryInstance() {
+GeometryInstance3D::GeometryInstance3D() {
lod_min_distance = 0;
lod_max_distance = 0;
lod_min_hysteresis = 0;
@@ -331,5 +331,5 @@ GeometryInstance::GeometryInstance() {
shadow_casting_setting = SHADOW_CASTING_SETTING_ON;
extra_cull_margin = 0;
- //VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
+ //RS::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_3d.h
index fee6787c87..9476c28848 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_instance.h */
+/* visual_instance_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,12 +33,12 @@
#include "core/math/face3.h"
#include "core/rid.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/material.h"
-class VisualInstance : public Spatial {
+class VisualInstance3D : public Node3D {
- GDCLASS(VisualInstance, Spatial);
+ GDCLASS(VisualInstance3D, Node3D);
OBJ_CATEGORY("3D Visual Nodes");
RID base;
@@ -76,27 +76,27 @@ public:
void set_layer_mask_bit(int p_layer, bool p_enable);
bool get_layer_mask_bit(int p_layer) const;
- VisualInstance();
- ~VisualInstance();
+ VisualInstance3D();
+ ~VisualInstance3D();
};
-class GeometryInstance : public VisualInstance {
+class GeometryInstance3D : public VisualInstance3D {
- GDCLASS(GeometryInstance, VisualInstance);
+ GDCLASS(GeometryInstance3D, VisualInstance3D);
public:
enum Flags {
- FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
- FLAG_USE_DYNAMIC_GI = VS::INSTANCE_FLAG_USE_DYNAMIC_GI,
- FLAG_DRAW_NEXT_FRAME_IF_VISIBLE = VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE,
- FLAG_MAX = VS::INSTANCE_FLAG_MAX,
+ FLAG_USE_BAKED_LIGHT = RS::INSTANCE_FLAG_USE_BAKED_LIGHT,
+ FLAG_USE_DYNAMIC_GI = RS::INSTANCE_FLAG_USE_DYNAMIC_GI,
+ FLAG_DRAW_NEXT_FRAME_IF_VISIBLE = RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE,
+ FLAG_MAX = RS::INSTANCE_FLAG_MAX,
};
enum ShadowCastingSetting {
- SHADOW_CASTING_SETTING_OFF = VS::SHADOW_CASTING_SETTING_OFF,
- SHADOW_CASTING_SETTING_ON = VS::SHADOW_CASTING_SETTING_ON,
- SHADOW_CASTING_SETTING_DOUBLE_SIDED = VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED,
- SHADOW_CASTING_SETTING_SHADOWS_ONLY = VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY
+ SHADOW_CASTING_SETTING_OFF = RS::SHADOW_CASTING_SETTING_OFF,
+ SHADOW_CASTING_SETTING_ON = RS::SHADOW_CASTING_SETTING_ON,
+ SHADOW_CASTING_SETTING_DOUBLE_SIDED = RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED,
+ SHADOW_CASTING_SETTING_SHADOWS_ONLY = RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY
};
private:
@@ -141,10 +141,10 @@ public:
void set_custom_aabb(AABB aabb);
- GeometryInstance();
+ GeometryInstance3D();
};
-VARIANT_ENUM_CAST(GeometryInstance::Flags);
-VARIANT_ENUM_CAST(GeometryInstance::ShadowCastingSetting);
+VARIANT_ENUM_CAST(GeometryInstance3D::Flags);
+VARIANT_ENUM_CAST(GeometryInstance3D::ShadowCastingSetting);
#endif
diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h
index af9237ae7b..1fde6237a2 100644
--- a/scene/3d/voxelizer.h
+++ b/scene/3d/voxelizer.h
@@ -32,7 +32,7 @@
#define VOXEL_LIGHT_BAKER_H
#include "core/math/vector3i.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/resources/multimesh.h"
class Voxelizer {
diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp
index 83a7243906..8cf4554653 100644
--- a/scene/3d/world_environment.cpp
+++ b/scene/3d/world_environment.cpp
@@ -29,11 +29,11 @@
/*************************************************************************/
#include "world_environment.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void WorldEnvironment::_notification(int p_what) {
- if (p_what == Spatial::NOTIFICATION_ENTER_WORLD || p_what == Spatial::NOTIFICATION_ENTER_TREE) {
+ if (p_what == Node3D::NOTIFICATION_ENTER_WORLD || p_what == Node3D::NOTIFICATION_ENTER_TREE) {
if (environment.is_valid()) {
if (get_viewport()->find_world()->get_environment().is_valid()) {
@@ -51,7 +51,7 @@ void WorldEnvironment::_notification(int p_what) {
add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world()->get_scenario().get_id()));
}
- } else if (p_what == Spatial::NOTIFICATION_EXIT_WORLD || p_what == Spatial::NOTIFICATION_EXIT_TREE) {
+ } else if (p_what == Node3D::NOTIFICATION_EXIT_WORLD || p_what == Node3D::NOTIFICATION_EXIT_TREE) {
if (environment.is_valid() && get_viewport()->find_world()->get_environment() == environment) {
get_viewport()->find_world()->set_environment(Ref<Environment>());
diff --git a/scene/3d/world_environment.h b/scene/3d/world_environment.h
index 0c590bfc07..e4c9fc071d 100644
--- a/scene/3d/world_environment.h
+++ b/scene/3d/world_environment.h
@@ -31,7 +31,7 @@
#ifndef SCENARIO_FX_H
#define SCENARIO_FX_H
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
class WorldEnvironment : public Node {
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index 9ed8155bdc..79a7c36e7f 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -94,19 +94,19 @@ void AnimationCache::_update_cache() {
ERR_CONTINUE_MSG(animation->track_get_type(i) == Animation::TYPE_TRANSFORM, "Transform tracks can't have a subpath '" + np + "'.");
}
- Spatial *sp = Object::cast_to<Spatial>(node);
+ Node3D *sp = Object::cast_to<Node3D>(node);
if (!sp) {
path_cache.push_back(Path());
- ERR_CONTINUE_MSG(!sp, "Transform track not of type Spatial '" + np + "'.");
+ ERR_CONTINUE_MSG(!sp, "Transform track not of type Node3D '" + np + "'.");
}
if (np.get_subname_count() == 1) {
StringName property = np.get_subname(0);
String ps = property;
- Skeleton *sk = Object::cast_to<Skeleton>(node);
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(node);
if (!sk) {
path_cache.push_back(Path());
diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h
index e73b9e2498..20147f060b 100644
--- a/scene/animation/animation_cache.h
+++ b/scene/animation/animation_cache.h
@@ -31,7 +31,7 @@
#ifndef ANIMATION_CACHE_H
#define ANIMATION_CACHE_H
-#include "scene/3d/skeleton.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/resources/animation.h"
class AnimationCache : public Object {
@@ -42,9 +42,9 @@ class AnimationCache : public Object {
RES resource;
Object *object;
- Skeleton *skeleton; // haxor
+ Skeleton3D *skeleton; // haxor
Node *node;
- Spatial *spatial;
+ Node3D *spatial;
int bone_idx;
Vector<StringName> subpath;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 587485669e..6c870682a6 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -44,7 +44,7 @@ void AnimatedValuesBackup::update_skeletons() {
for (int i = 0; i < entries.size(); i++) {
if (entries[i].bone_idx != -1) {
// 3D bone
- Object::cast_to<Skeleton>(entries[i].object)->notification(Skeleton::NOTIFICATION_UPDATE_SKELETON);
+ Object::cast_to<Skeleton3D>(entries[i].object)->notification(Skeleton3D::NOTIFICATION_UPDATE_SKELETON);
} else {
Bone2D *bone = Object::cast_to<Bone2D>(entries[i].object);
if (bone && bone->skeleton) {
@@ -252,9 +252,9 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
ObjectID id = resource.is_valid() ? resource->get_instance_id() : child->get_instance_id();
int bone_idx = -1;
- if (a->track_get_path(i).get_subname_count() == 1 && Object::cast_to<Skeleton>(child)) {
+ if (a->track_get_path(i).get_subname_count() == 1 && Object::cast_to<Skeleton3D>(child)) {
- Skeleton *sk = Object::cast_to<Skeleton>(child);
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(child);
bone_idx = sk->find_bone(a->track_get_path(i).get_subname(0));
if (bone_idx == -1) {
@@ -283,9 +283,9 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
// special cases and caches for transform tracks
// cache spatial
- p_anim->node_cache[i]->spatial = Object::cast_to<Spatial>(child);
+ p_anim->node_cache[i]->spatial = Object::cast_to<Node3D>(child);
// cache skeleton
- p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child);
+ p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton3D>(child);
if (p_anim->node_cache[i]->skeleton) {
if (a->track_get_path(i).get_subname_count() == 1) {
StringName bone_name = a->track_get_path(i).get_subname(0);
@@ -1612,7 +1612,7 @@ void AnimationPlayer::restore_animated_values(const AnimatedValuesBackup &p_back
if (entry->bone_idx == -1) {
entry->object->set_indexed(entry->subpath, entry->value);
} else {
- Object::cast_to<Skeleton>(entry->object)->set_bone_pose(entry->bone_idx, entry->value);
+ Object::cast_to<Skeleton3D>(entry->object)->set_bone_pose(entry->bone_idx, entry->value);
}
}
}
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 24f60363ed..32bed6f4d6 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -32,8 +32,8 @@
#define ANIMATION_PLAYER_H
#include "scene/2d/node_2d.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/resources/animation.h"
#ifdef TOOLS_ENABLED
@@ -90,9 +90,9 @@ private:
uint32_t id;
RES resource;
Node *node;
- Spatial *spatial;
+ Node3D *spatial;
Node2D *node_2d;
- Skeleton *skeleton;
+ Skeleton3D *skeleton;
int bone_idx;
// accumulated transforms
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 95afd74ee5..0e1089cc6a 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -605,7 +605,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_TRANSFORM: {
- Spatial *spatial = Object::cast_to<Spatial>(child);
+ Node3D *spatial = Object::cast_to<Node3D>(child);
if (!spatial) {
ERR_PRINT("AnimationTree: '" + String(E->get()) + "', transform track does not point to spatial: '" + String(path) + "'");
@@ -618,9 +618,9 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_xform->skeleton = NULL;
track_xform->bone_idx = -1;
- if (path.get_subname_count() == 1 && Object::cast_to<Skeleton>(spatial)) {
+ if (path.get_subname_count() == 1 && Object::cast_to<Skeleton3D>(spatial)) {
- Skeleton *sk = Object::cast_to<Skeleton>(spatial);
+ Skeleton3D *sk = Object::cast_to<Skeleton3D>(spatial);
int bone_idx = sk->find_bone(path.get_subname(0));
if (bone_idx != -1) {
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index 742942fcda..faf4333f1d 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -32,8 +32,8 @@
#define ANIMATION_GRAPH_PLAYER_H
#include "animation_player.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/resources/animation.h"
class AnimationNodeBlendTree;
@@ -192,8 +192,8 @@ private:
};
struct TrackCacheTransform : public TrackCache {
- Spatial *spatial;
- Skeleton *skeleton;
+ Node3D *spatial;
+ Skeleton3D *skeleton;
int bone_idx;
Vector3 loc;
Quat rot;
diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp
index ce9b8bd213..f993127b07 100644
--- a/scene/animation/root_motion_view.cpp
+++ b/scene/animation/root_motion_view.cpp
@@ -79,7 +79,7 @@ void RootMotionView::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- VS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false));
+ RS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false));
first = true;
}
@@ -122,11 +122,11 @@ void RootMotionView::_notification(int p_what) {
}
accumulated.origin.z = Math::fposmod(accumulated.origin.z, cell_size);
- VS::get_singleton()->immediate_clear(immediate);
+ RS::get_singleton()->immediate_clear(immediate);
int cells_in_radius = int((radius / cell_size) + 1.0);
- VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_LINES);
+ RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_LINES);
for (int i = -cells_in_radius; i < cells_in_radius; i++) {
for (int j = -cells_in_radius; j < cells_in_radius; j++) {
@@ -142,21 +142,21 @@ void RootMotionView::_notification(int p_what) {
c_i.a *= MAX(0, 1.0 - from_i.length() / radius);
c_j.a *= MAX(0, 1.0 - from_j.length() / radius);
- VS::get_singleton()->immediate_color(immediate, c);
- VS::get_singleton()->immediate_vertex(immediate, from);
+ RS::get_singleton()->immediate_color(immediate, c);
+ RS::get_singleton()->immediate_vertex(immediate, from);
- VS::get_singleton()->immediate_color(immediate, c_i);
- VS::get_singleton()->immediate_vertex(immediate, from_i);
+ RS::get_singleton()->immediate_color(immediate, c_i);
+ RS::get_singleton()->immediate_vertex(immediate, from_i);
- VS::get_singleton()->immediate_color(immediate, c);
- VS::get_singleton()->immediate_vertex(immediate, from);
+ RS::get_singleton()->immediate_color(immediate, c);
+ RS::get_singleton()->immediate_vertex(immediate, from);
- VS::get_singleton()->immediate_color(immediate, c_j);
- VS::get_singleton()->immediate_vertex(immediate, from_j);
+ RS::get_singleton()->immediate_color(immediate, c_j);
+ RS::get_singleton()->immediate_vertex(immediate, from_j);
}
}
- VS::get_singleton()->immediate_end(immediate);
+ RS::get_singleton()->immediate_end(immediate);
}
}
@@ -197,12 +197,12 @@ RootMotionView::RootMotionView() {
radius = 10;
cell_size = 1;
set_process_internal(true);
- immediate = VisualServer::get_singleton()->immediate_create();
+ immediate = RenderingServer::get_singleton()->immediate_create();
set_base(immediate);
color = Color(0.5, 0.5, 1.0);
}
RootMotionView::~RootMotionView() {
set_base(RID());
- VisualServer::get_singleton()->free(immediate);
+ RenderingServer::get_singleton()->free(immediate);
}
diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h
index 42950dde42..c8a755a854 100644
--- a/scene/animation/root_motion_view.h
+++ b/scene/animation/root_motion_view.h
@@ -31,10 +31,10 @@
#ifndef ROOT_MOTION_VIEW_H
#define ROOT_MOTION_VIEW_H
-#include "scene/3d/visual_instance.h"
+#include "scene/3d/visual_instance_3d.h"
-class RootMotionView : public VisualInstance {
- GDCLASS(RootMotionView, VisualInstance);
+class RootMotionView : public VisualInstance3D {
+ GDCLASS(RootMotionView, VisualInstance3D);
public:
RID immediate;
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 7a184adc55..359f936793 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -34,7 +34,7 @@
#include "core/io/marshalls.h"
#include "core/script_language.h"
#include "scene/main/scene_tree.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
void SceneDebugger::initialize() {
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index b2020d44e8..a05ac08e9d 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -31,7 +31,7 @@
#include "base_button.h"
#include "core/os/keyboard.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
void BaseButton::_unpress_group() {
@@ -357,9 +357,6 @@ void BaseButton::_unhandled_input(Ref<InputEvent> p_event) {
if (!is_disabled() && is_visible_in_tree() && !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
-
on_action_event(p_event);
}
}
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index e0bfeac9f7..0da6e0fdfa 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -45,7 +45,7 @@ void BoxContainer::_resort() {
Size2i new_size = get_size();
- int sep = get_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
+ int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
bool first = true;
int children_count = 0;
@@ -206,7 +206,7 @@ Size2 BoxContainer::get_minimum_size() const {
/* Calculate MINIMUM SIZE */
Size2i minimum;
- int sep = get_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
+ int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
bool first = true;
@@ -310,7 +310,7 @@ MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control
l->set_text(p_label);
add_child(l);
MarginContainer *mc = memnew(MarginContainer);
- mc->add_constant_override("margin_left", 0);
+ mc->add_theme_constant_override("margin_left", 0);
mc->add_child(p_control);
add_child(mc);
if (p_expand)
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 784d298bff..1f8487c173 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -31,18 +31,18 @@
#include "button.h"
#include "core/translation.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
Size2 Button::get_minimum_size() const {
- Size2 minsize = get_font("font")->get_string_size(xl_text);
+ Size2 minsize = get_theme_font("font")->get_string_size(xl_text);
if (clip_text)
minsize.width = 0;
if (!expand_icon) {
Ref<Texture2D> _icon;
- if (icon.is_null() && has_icon("icon"))
- _icon = Control::get_icon("icon");
+ if (icon.is_null() && has_theme_icon("icon"))
+ _icon = Control::get_theme_icon("icon");
else
_icon = icon;
@@ -51,11 +51,11 @@ Size2 Button::get_minimum_size() const {
minsize.height = MAX(minsize.height, _icon->get_height());
minsize.width += _icon->get_width();
if (xl_text != "")
- minsize.width += get_constant("hseparation");
+ minsize.width += get_theme_constant("hseparation");
}
}
- return get_stylebox("normal")->get_minimum_size() + minsize;
+ return get_theme_stylebox("normal")->get_minimum_size() + minsize;
}
void Button::_set_internal_margin(Margin p_margin, float p_value) {
@@ -79,30 +79,30 @@ void Button::_notification(int p_what) {
Color color;
Color color_icon(1, 1, 1, 1);
- Ref<StyleBox> style = get_stylebox("normal");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
switch (get_draw_mode()) {
case DRAW_NORMAL: {
- style = get_stylebox("normal");
+ style = get_theme_stylebox("normal");
if (!flat)
style->draw(ci, Rect2(Point2(0, 0), size));
- color = get_color("font_color");
- if (has_color("icon_color_normal"))
- color_icon = get_color("icon_color_normal");
+ color = get_theme_color("font_color");
+ if (has_theme_color("icon_color_normal"))
+ color_icon = get_theme_color("icon_color_normal");
} break;
case DRAW_HOVER_PRESSED: {
- if (has_stylebox("hover_pressed") && has_stylebox_override("hover_pressed")) {
- style = get_stylebox("hover_pressed");
+ if (has_theme_stylebox("hover_pressed") && has_theme_stylebox_override("hover_pressed")) {
+ style = get_theme_stylebox("hover_pressed");
if (!flat)
style->draw(ci, Rect2(Point2(0, 0), size));
- if (has_color("font_color_hover_pressed"))
- color = get_color("font_color_hover_pressed");
+ if (has_theme_color("font_color_hover_pressed"))
+ color = get_theme_color("font_color_hover_pressed");
else
- color = get_color("font_color");
- if (has_color("icon_color_hover_pressed"))
- color_icon = get_color("icon_color_hover_pressed");
+ color = get_theme_color("font_color");
+ if (has_theme_color("icon_color_hover_pressed"))
+ color_icon = get_theme_color("icon_color_hover_pressed");
break;
}
@@ -110,49 +110,49 @@ void Button::_notification(int p_what) {
}
case DRAW_PRESSED: {
- style = get_stylebox("pressed");
+ style = get_theme_stylebox("pressed");
if (!flat)
style->draw(ci, Rect2(Point2(0, 0), size));
- if (has_color("font_color_pressed"))
- color = get_color("font_color_pressed");
+ if (has_theme_color("font_color_pressed"))
+ color = get_theme_color("font_color_pressed");
else
- color = get_color("font_color");
- if (has_color("icon_color_pressed"))
- color_icon = get_color("icon_color_pressed");
+ color = get_theme_color("font_color");
+ if (has_theme_color("icon_color_pressed"))
+ color_icon = get_theme_color("icon_color_pressed");
} break;
case DRAW_HOVER: {
- style = get_stylebox("hover");
+ style = get_theme_stylebox("hover");
if (!flat)
style->draw(ci, Rect2(Point2(0, 0), size));
- color = get_color("font_color_hover");
- if (has_color("icon_color_hover"))
- color_icon = get_color("icon_color_hover");
+ color = get_theme_color("font_color_hover");
+ if (has_theme_color("icon_color_hover"))
+ color_icon = get_theme_color("icon_color_hover");
} break;
case DRAW_DISABLED: {
- style = get_stylebox("disabled");
+ style = get_theme_stylebox("disabled");
if (!flat)
style->draw(ci, Rect2(Point2(0, 0), size));
- color = get_color("font_color_disabled");
- if (has_color("icon_color_disabled"))
- color_icon = get_color("icon_color_disabled");
+ color = get_theme_color("font_color_disabled");
+ if (has_theme_color("icon_color_disabled"))
+ color_icon = get_theme_color("icon_color_disabled");
} break;
}
if (has_focus()) {
- Ref<StyleBox> style2 = get_stylebox("focus");
+ Ref<StyleBox> style2 = get_theme_stylebox("focus");
style2->draw(ci, Rect2(Point2(), size));
}
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
Ref<Texture2D> _icon;
- if (icon.is_null() && has_icon("icon"))
- _icon = Control::get_icon("icon");
+ if (icon.is_null() && has_theme_icon("icon"))
+ _icon = Control::get_theme_icon("icon");
else
_icon = icon;
@@ -166,14 +166,14 @@ void Button::_notification(int p_what) {
float icon_ofs_region = 0;
if (_internal_margin[MARGIN_LEFT] > 0) {
- icon_ofs_region = _internal_margin[MARGIN_LEFT] + get_constant("hseparation");
+ icon_ofs_region = _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation");
}
if (expand_icon) {
Size2 _size = get_size() - style->get_offset() * 2;
- _size.width -= get_constant("hseparation") + icon_ofs_region;
+ _size.width -= get_theme_constant("hseparation") + icon_ofs_region;
if (!clip_text)
- _size.width -= get_font("font")->get_string_size(xl_text).width;
+ _size.width -= get_theme_font("font")->get_string_size(xl_text).width;
float icon_width = _icon->get_width() * _size.height / _icon->get_height();
float icon_height = _size.height;
@@ -188,13 +188,13 @@ void Button::_notification(int p_what) {
}
}
- Point2 icon_ofs = !_icon.is_null() ? Point2(icon_region.size.width + get_constant("hseparation"), 0) : Point2();
+ Point2 icon_ofs = !_icon.is_null() ? Point2(icon_region.size.width + get_theme_constant("hseparation"), 0) : Point2();
int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width;
if (_internal_margin[MARGIN_LEFT] > 0) {
- text_clip -= _internal_margin[MARGIN_LEFT] + get_constant("hseparation");
+ text_clip -= _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation");
}
if (_internal_margin[MARGIN_RIGHT] > 0) {
- text_clip -= _internal_margin[MARGIN_RIGHT] + get_constant("hseparation");
+ text_clip -= _internal_margin[MARGIN_RIGHT] + get_theme_constant("hseparation");
}
Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size(xl_text) - Point2(_internal_margin[MARGIN_RIGHT] - _internal_margin[MARGIN_LEFT], 0)) / 2.0;
@@ -202,7 +202,7 @@ void Button::_notification(int p_what) {
switch (align) {
case ALIGN_LEFT: {
if (_internal_margin[MARGIN_LEFT] > 0) {
- text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x + _internal_margin[MARGIN_LEFT] + get_constant("hseparation");
+ text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x + _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation");
} else {
text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x;
}
@@ -216,7 +216,7 @@ void Button::_notification(int p_what) {
} break;
case ALIGN_RIGHT: {
if (_internal_margin[MARGIN_RIGHT] > 0) {
- text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size(xl_text).x - _internal_margin[MARGIN_RIGHT] - get_constant("hseparation");
+ text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size(xl_text).x - _internal_margin[MARGIN_RIGHT] - get_theme_constant("hseparation");
} else {
text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size(xl_text).x;
}
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 89bd8ab0dd..470450e3ed 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -30,13 +30,13 @@
#include "check_box.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
Size2 CheckBox::get_icon_size() const {
- Ref<Texture2D> checked = Control::get_icon("checked");
- Ref<Texture2D> unchecked = Control::get_icon("unchecked");
- Ref<Texture2D> radio_checked = Control::get_icon("radio_checked");
- Ref<Texture2D> radio_unchecked = Control::get_icon("radio_unchecked");
+ Ref<Texture2D> checked = Control::get_theme_icon("checked");
+ Ref<Texture2D> unchecked = Control::get_theme_icon("unchecked");
+ Ref<Texture2D> radio_checked = Control::get_theme_icon("radio_checked");
+ Ref<Texture2D> radio_unchecked = Control::get_theme_icon("radio_unchecked");
Size2 tex_size = Size2(0, 0);
if (!checked.is_null())
@@ -56,9 +56,9 @@ Size2 CheckBox::get_minimum_size() const {
Size2 tex_size = get_icon_size();
minsize.width += tex_size.width;
if (get_text().length() > 0) {
- minsize.width += get_constant("hseparation");
+ minsize.width += get_theme_constant("hseparation");
}
- Ref<StyleBox> sb = get_stylebox("normal");
+ Ref<StyleBox> sb = get_theme_stylebox("normal");
minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM));
return minsize;
@@ -73,13 +73,13 @@ void CheckBox::_notification(int p_what) {
RID ci = get_canvas_item();
- Ref<Texture2D> on = Control::get_icon(is_radio() ? "radio_checked" : "checked");
- Ref<Texture2D> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked");
- Ref<StyleBox> sb = get_stylebox("normal");
+ Ref<Texture2D> on = Control::get_theme_icon(is_radio() ? "radio_checked" : "checked");
+ Ref<Texture2D> off = Control::get_theme_icon(is_radio() ? "radio_unchecked" : "unchecked");
+ Ref<StyleBox> sb = get_theme_stylebox("normal");
Vector2 ofs;
ofs.x = sb->get_margin(MARGIN_LEFT);
- ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_constant("check_vadjust");
+ ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_theme_constant("check_vadjust");
if (is_pressed())
on->draw(ci, ofs);
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index 0b093ce850..96484424f8 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -31,12 +31,12 @@
#include "check_button.h"
#include "core/print_string.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
Size2 CheckButton::get_icon_size() const {
- Ref<Texture2D> on = Control::get_icon(is_disabled() ? "on_disabled" : "on");
- Ref<Texture2D> off = Control::get_icon(is_disabled() ? "off_disabled" : "off");
+ Ref<Texture2D> on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on");
+ Ref<Texture2D> off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off");
Size2 tex_size = Size2(0, 0);
if (!on.is_null())
tex_size = Size2(on->get_width(), on->get_height());
@@ -52,8 +52,8 @@ Size2 CheckButton::get_minimum_size() const {
Size2 tex_size = get_icon_size();
minsize.width += tex_size.width;
if (get_text().length() > 0)
- minsize.width += get_constant("hseparation");
- Ref<StyleBox> sb = get_stylebox("normal");
+ minsize.width += get_theme_constant("hseparation");
+ Ref<StyleBox> sb = get_theme_stylebox("normal");
minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM));
return minsize;
@@ -68,15 +68,15 @@ void CheckButton::_notification(int p_what) {
RID ci = get_canvas_item();
- Ref<Texture2D> on = Control::get_icon(is_disabled() ? "on_disabled" : "on");
- Ref<Texture2D> off = Control::get_icon(is_disabled() ? "off_disabled" : "off");
+ Ref<Texture2D> on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on");
+ Ref<Texture2D> off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off");
- Ref<StyleBox> sb = get_stylebox("normal");
+ Ref<StyleBox> sb = get_theme_stylebox("normal");
Vector2 ofs;
Size2 tex_size = get_icon_size();
ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT));
- ofs.y = (get_size().height - tex_size.height) / 2 + get_constant("check_vadjust");
+ ofs.y = (get_size().height - tex_size.height) / 2 + get_theme_constant("check_vadjust");
if (is_pressed())
on->draw(ci, ofs);
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index cbbad79811..2ec9bb2292 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -30,7 +30,7 @@
#include "color_picker.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -38,22 +38,22 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#endif
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void ColorPicker::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
- btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
- bt_add_preset->set_icon(get_icon("add_preset"));
+ btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker"));
+ bt_add_preset->set_icon(get_theme_icon("add_preset"));
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
- btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
- bt_add_preset->set_icon(get_icon("add_preset"));
+ btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker"));
+ bt_add_preset->set_icon(get_theme_icon("add_preset"));
_update_color();
@@ -70,15 +70,15 @@ void ColorPicker::_notification(int p_what) {
case NOTIFICATION_PARENTED: {
for (int i = 0; i < 4; i++)
- set_margin((Margin)i, get_constant("margin"));
+ set_margin((Margin)i, get_theme_constant("margin"));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
Popup *p = Object::cast_to<Popup>(get_parent());
if (p)
- p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
+ p->set_size(Size2(get_combined_minimum_size().width + get_theme_constant("margin") * 2, get_combined_minimum_size().height + get_theme_constant("margin") * 2));
} break;
- case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
+ case NOTIFICATION_WM_CLOSE_REQUEST: {
if (screen != NULL && screen->is_visible())
screen->hide();
@@ -247,6 +247,9 @@ void ColorPicker::_update_color(bool p_update_sliders) {
}
void ColorPicker::_update_presets() {
+ return;
+ //presets should be shown using buttons or something else, this method is not a good idea
+
presets_per_row = 10;
Size2 size = bt_add_preset->get_size();
Size2 preset_size = Size2(MIN(size.width * presets.size(), presets_per_row * size.width), size.height * (Math::ceil((float)presets.size() / presets_per_row)));
@@ -267,7 +270,7 @@ void ColorPicker::_text_type_toggled() {
text_is_constructor = !text_is_constructor;
if (text_is_constructor) {
text_type->set_text("");
- text_type->set_icon(get_icon("Script", "EditorIcons"));
+ text_type->set_icon(get_theme_icon("Script", "EditorIcons"));
c_text->set_editable(false);
} else {
@@ -399,14 +402,14 @@ void ColorPicker::_sample_draw() {
const Rect2 r = Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95));
if (color.a < 1.0) {
- sample->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), r, true);
+ sample->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), r, true);
}
sample->draw_rect(r, color);
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
- sample->draw_texture(get_icon("overbright_indicator", "ColorPicker"), Point2());
+ sample->draw_texture(get_theme_icon("overbright_indicator", "ColorPicker"), Point2());
}
}
@@ -445,7 +448,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) {
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_which == 1) {
- Ref<Texture2D> hue = get_icon("color_hue", "ColorPicker");
+ Ref<Texture2D> hue = get_theme_icon("color_hue", "ColorPicker");
c->draw_texture_rect(hue, Rect2(Point2(), c->get_size()));
int y = c->get_size().y - c->get_size().y * (1.0 - h);
Color col = Color();
@@ -620,30 +623,40 @@ void ColorPicker::_screen_pick_pressed() {
screen->call_deferred("connect", "hide", Callable(btn_pick, "set_pressed"), varray(false));
}
screen->raise();
- screen->show_modal();
+#ifndef _MSC_VER
+#warning show modal no longer works, needs to be converted to a popup
+#endif
+ //screen->show_modal();
}
void ColorPicker::_focus_enter() {
- if (c_text->has_focus()) {
+ bool has_ctext_focus = c_text->has_focus();
+ if (has_ctext_focus) {
c_text->select_all();
- return;
+ } else {
+ c_text->select(0, 0);
}
+
for (int i = 0; i < 4; i++) {
- if (values[i]->get_line_edit()->has_focus()) {
+ if (values[i]->get_line_edit()->has_focus() && !has_ctext_focus) {
values[i]->get_line_edit()->select_all();
- break;
+ } else {
+ values[i]->get_line_edit()->select(0, 0);
}
}
}
void ColorPicker::_focus_exit() {
for (int i = 0; i < 4; i++) {
- values[i]->get_line_edit()->select(0, 0);
+ if (!values[i]->get_line_edit()->get_menu()->is_visible())
+ values[i]->get_line_edit()->select(0, 0);
}
c_text->select(0, 0);
}
void ColorPicker::_html_focus_exit() {
+ if (c_text->get_menu()->is_visible())
+ return;
_html_entered(c_text->get_text());
_focus_exit();
}
@@ -731,12 +744,12 @@ ColorPicker::ColorPicker() :
uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
uv_edit->set_h_size_flags(SIZE_EXPAND_FILL);
uv_edit->set_v_size_flags(SIZE_EXPAND_FILL);
- uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height")));
+ uv_edit->set_custom_minimum_size(Size2(get_theme_constant("sv_width"), get_theme_constant("sv_height")));
uv_edit->connect("draw", callable_mp(this, &ColorPicker::_hsv_draw), make_binds(0, uv_edit));
w_edit = memnew(Control);
hb_edit->add_child(w_edit);
- w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
+ w_edit->set_custom_minimum_size(Size2(get_theme_constant("h_width"), 0));
w_edit->set_h_size_flags(SIZE_FILL);
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
w_edit->connect("gui_input", callable_mp(this, &ColorPicker::_w_input));
@@ -770,7 +783,7 @@ ColorPicker::ColorPicker() :
HBoxContainer *hbc = memnew(HBoxContainer);
labels[i] = memnew(Label());
- labels[i]->set_custom_minimum_size(Size2(get_constant("label_width"), 0));
+ labels[i]->set_custom_minimum_size(Size2(get_theme_constant("label_width"), 0));
labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
hbc->add_child(labels[i]);
@@ -874,8 +887,32 @@ void ColorPickerButton::_modal_closed() {
void ColorPickerButton::pressed() {
_update_picker();
- popup->set_position(get_global_position() - picker->get_combined_minimum_size() * get_global_transform().get_scale());
- popup->set_scale(get_global_transform().get_scale());
+
+ popup->set_as_minsize();
+
+ Rect2i usable_rect = popup->get_usable_parent_rect();
+ //let's try different positions to see which one we can use
+
+ Rect2i cp_rect(Point2i(), popup->get_size());
+ for (int i = 0; i < 4; i++) {
+ if (i > 1) {
+ cp_rect.position.y = get_screen_position().y - cp_rect.size.y;
+ } else {
+ cp_rect.position.y = get_screen_position().y + get_size().height;
+ }
+
+ if (i & 1) {
+ cp_rect.position.x = get_screen_position().x;
+ } else {
+
+ cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - get_size().x));
+ }
+
+ if (usable_rect.encloses(cp_rect)) {
+ break;
+ }
+ }
+ popup->set_position(cp_rect.position);
popup->popup();
picker->set_focus_on_line_edit();
}
@@ -885,17 +922,17 @@ void ColorPickerButton::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
- const Ref<StyleBox> normal = get_stylebox("normal");
+ const Ref<StyleBox> normal = get_theme_stylebox("normal");
const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
- draw_texture_rect(Control::get_icon("bg", "ColorPickerButton"), r, true);
+ draw_texture_rect(Control::get_theme_icon("bg", "ColorPickerButton"), r, true);
draw_rect(r, color);
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
- draw_texture(Control::get_icon("overbright_indicator", "ColorPicker"), normal->get_offset());
+ draw_texture(Control::get_theme_icon("overbright_indicator", "ColorPicker"), normal->get_offset());
}
} break;
- case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
+ case NOTIFICATION_WM_CLOSE_REQUEST: {
if (popup)
popup->hide();
@@ -951,12 +988,14 @@ PopupPanel *ColorPickerButton::get_popup() {
void ColorPickerButton::_update_picker() {
if (!picker) {
popup = memnew(PopupPanel);
+ popup->set_wrap_controls(true);
picker = memnew(ColorPicker);
+ picker->set_anchors_and_margins_preset(PRESET_WIDE);
popup->add_child(picker);
add_child(popup);
picker->connect("color_changed", callable_mp(this, &ColorPickerButton::_color_changed));
popup->connect("modal_closed", callable_mp(this, &ColorPickerButton::_modal_closed));
- popup->connect("about_to_show", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true));
+ popup->connect("about_to_popup", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true));
popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false));
picker->set_pick_color(color);
picker->set_edit_alpha(edit_alpha);
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 1a231e368b..0d982dbc02 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -38,9 +38,9 @@
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
#include "scene/main/canvas_layer.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/scene_string_names.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
@@ -260,22 +260,22 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) {
} else {
if (name.begins_with("custom_icons/")) {
String dname = name.get_slicec('/', 1);
- add_icon_override(dname, p_value);
+ add_theme_icon_override(dname, p_value);
} else if (name.begins_with("custom_shaders/")) {
String dname = name.get_slicec('/', 1);
- add_shader_override(dname, p_value);
+ add_theme_shader_override(dname, p_value);
} else if (name.begins_with("custom_styles/")) {
String dname = name.get_slicec('/', 1);
- add_style_override(dname, p_value);
+ add_theme_style_override(dname, p_value);
} else if (name.begins_with("custom_fonts/")) {
String dname = name.get_slicec('/', 1);
- add_font_override(dname, p_value);
+ add_theme_font_override(dname, p_value);
} else if (name.begins_with("custom_colors/")) {
String dname = name.get_slicec('/', 1);
- add_color_override(dname, p_value);
+ add_theme_color_override(dname, p_value);
} else if (name.begins_with("custom_constants/")) {
String dname = name.get_slicec('/', 1);
- add_constant_override(dname, p_value);
+ add_theme_constant_override(dname, p_value);
} else
return false;
}
@@ -438,22 +438,30 @@ void Control::_resize(const Size2 &p_size) {
void Control::add_child_notify(Node *p_child) {
Control *child_c = Object::cast_to<Control>(p_child);
- if (!child_c)
- return;
- if (child_c->data.theme.is_null() && data.theme_owner) {
- _propagate_theme_changed(child_c, data.theme_owner); //need to propagate here, since many controls may require setting up stuff
+ if (child_c && child_c->data.theme.is_null() && (data.theme_owner || data.theme_owner_window)) {
+ _propagate_theme_changed(child_c, data.theme_owner, data.theme_owner_window); //need to propagate here, since many controls may require setting up stuff
+ }
+
+ Window *child_w = Object::cast_to<Window>(p_child);
+
+ if (child_w && child_w->theme.is_null() && (data.theme_owner || data.theme_owner_window)) {
+ _propagate_theme_changed(child_w, data.theme_owner, data.theme_owner_window); //need to propagate here, since many controls may require setting up stuff
}
}
void Control::remove_child_notify(Node *p_child) {
Control *child_c = Object::cast_to<Control>(p_child);
- if (!child_c)
- return;
- if (child_c->data.theme_owner && child_c->data.theme.is_null()) {
- _propagate_theme_changed(child_c, NULL);
+ if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) {
+ _propagate_theme_changed(child_c, NULL, NULL);
+ }
+
+ Window *child_w = Object::cast_to<Window>(p_child);
+
+ if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) {
+ _propagate_theme_changed(child_w, NULL, NULL);
}
}
@@ -462,7 +470,7 @@ void Control::_update_canvas_item_transform() {
Transform2D xform = _get_internal_transform();
xform[2] += get_position();
- VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
+ RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
}
void Control::_notification(int p_notification) {
@@ -486,76 +494,54 @@ void Control::_notification(int p_notification) {
data.parent = Object::cast_to<Control>(get_parent());
- 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) {
- data.theme_owner = data.parent->data.theme_owner;
- notification(NOTIFICATION_THEME_CHANGED);
- }
-
- } else {
-
- Node *parent = this; //meh
- Control *parent_control = NULL;
- bool subwindow = false;
+ Node *parent = this; //meh
+ Control *parent_control = NULL;
+ bool subwindow = false;
- while (parent) {
-
- parent = parent->get_parent();
-
- if (!parent)
- break;
-
- CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
- if (ci && ci->is_set_as_toplevel()) {
- subwindow = true;
- break;
- }
+ while (parent) {
- parent_control = Object::cast_to<Control>(parent);
+ parent = parent->get_parent();
- if (parent_control) {
- break;
- } else if (ci) {
+ if (!parent)
+ break;
- } else {
- break;
- }
+ CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
+ if (ci && ci->is_set_as_toplevel()) {
+ subwindow = true;
+ break;
}
- if (parent_control) {
- //do nothing, has a parent control
- 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);
- } else {
- //is a regular root control
- data.RI = get_viewport()->_gui_add_root_control(this);
- }
+ parent_control = Object::cast_to<Control>(parent);
- data.parent_canvas_item = get_parent_item();
-
- if (data.parent_canvas_item) {
+ if (parent_control) {
+ break;
+ } else if (ci) {
- data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed));
} else {
- //connect viewport
- get_viewport()->connect("size_changed", callable_mp(this, &Control::_size_changed));
+ break;
}
}
- /*
- 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 (parent_control && !subwindow) {
+ //do nothing, has a parent control and not toplevel
+ if (data.theme.is_null() && parent_control->data.theme_owner) {
+ data.theme_owner = parent_control->data.theme_owner;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ } else {
+ //is a regular root control or toplevel
+ data.RI = get_viewport()->_gui_add_root_control(this);
}
- */
+ data.parent_canvas_item = get_parent_item();
+
+ if (data.parent_canvas_item) {
+
+ data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed));
+ } else {
+ //connect viewport
+ get_viewport()->connect("size_changed", callable_mp(this, &Control::_size_changed));
+ }
} break;
case NOTIFICATION_EXIT_CANVAS: {
@@ -568,16 +554,6 @@ void Control::_notification(int p_notification) {
get_viewport()->disconnect("size_changed", callable_mp(this, &Control::_size_changed));
}
- if (data.MI) {
- get_viewport()->_gui_remove_modal_control(data.MI);
- data.MI = NULL;
- }
-
- if (data.SI) {
- get_viewport()->_gui_remove_subwindow_control(data.SI);
- data.SI = NULL;
- }
-
if (data.RI) {
get_viewport()->_gui_remove_root_control(data.RI);
data.RI = NULL;
@@ -600,9 +576,6 @@ void Control::_notification(int p_notification) {
data.parent->update();
update();
- if (data.SI) {
- get_viewport()->_gui_set_subwindow_order_dirty();
- }
if (data.RI) {
get_viewport()->_gui_set_root_order_dirty();
}
@@ -615,8 +588,8 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_DRAW: {
_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);
+ RenderingServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), !data.disable_visibility_clip, Rect2(Point2(), get_size()));
+ RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), data.clip_contents);
//emit_signal(SceneStringNames::get_singleton()->draw);
} break;
@@ -644,10 +617,6 @@ void Control::_notification(int p_notification) {
minimum_size_changed();
update();
} break;
- case NOTIFICATION_MODAL_CLOSE: {
-
- emit_signal("modal_closed");
- } break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible_in_tree()) {
@@ -655,23 +624,14 @@ void Control::_notification(int p_notification) {
if (get_viewport() != NULL)
get_viewport()->_gui_hid_control(this);
- if (is_inside_tree()) {
- _modal_stack_remove();
- }
-
//remove key focus
- //remove modalness
+
} else {
data.minimum_size_valid = false;
_size_changed();
}
} break;
- case SceneTree::NOTIFICATION_WM_UNFOCUS_REQUEST: {
-
- get_viewport()->_gui_unfocus_control(this);
-
- } break;
}
}
@@ -787,19 +747,6 @@ void Control::set_drag_preview(Control *p_control) {
get_viewport()->_gui_set_drag_preview(this, p_control);
}
-bool Control::is_window_modal_on_top() const {
-
- if (!is_inside_tree())
- return false;
-
- return get_viewport()->_gui_is_modal_on_top(this);
-}
-
-uint64_t Control::get_modal_frame() const {
-
- return data.modal_frame;
-}
-
Size2 Control::get_minimum_size() const {
ScriptInstance *si = const_cast<Control *>(this)->get_script_instance();
@@ -813,50 +760,130 @@ Size2 Control::get_minimum_size() const {
return Size2();
}
-Ref<Texture2D> Control::get_icon(const StringName &p_name, const StringName &p_type) const {
+template <class T>
+bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, T &r_ret, T (Theme::*get_func)(const StringName &, const StringName &) const, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) {
- if (p_type == StringName() || p_type == get_class_name()) {
+ // try with custom themes
+ Control *theme_owner = p_theme_owner;
+ Window *theme_owner_window = p_theme_owner_window;
- const Ref<Texture2D> *tex = data.icon_override.getptr(p_name);
- if (tex)
- return *tex;
+ while (theme_owner || theme_owner_window) {
+
+ StringName class_name = p_type;
+
+ while (class_name != StringName()) {
+ if (theme_owner && (theme_owner->data.theme.operator->()->*has_func)(p_name, class_name)) {
+ r_ret = (theme_owner->data.theme.operator->()->*get_func)(p_name, class_name);
+ return true;
+ }
+
+ if (theme_owner_window && (theme_owner_window->theme.operator->()->*has_func)(p_name, class_name)) {
+ r_ret = (theme_owner_window->theme.operator->()->*get_func)(p_name, class_name);
+ return true;
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
+ Node *parent = theme_owner ? theme_owner->get_parent() : theme_owner_window->get_parent();
+
+ Control *parent_c = Object::cast_to<Control>(parent);
+
+ if (parent_c) {
+ theme_owner = parent_c->data.theme_owner;
+ theme_owner_window = parent_c->data.theme_owner_window;
+ } else {
+ Window *parent_w = Object::cast_to<Window>(parent);
+ if (parent_w) {
+ theme_owner = parent_w->theme_owner;
+ theme_owner_window = parent_w->theme_owner_window;
+ } else {
+
+ theme_owner = NULL;
+ theme_owner_window = NULL;
+ }
+ }
}
+ return false;
+}
- StringName type = p_type ? p_type : get_class_name();
+bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) {
// try with custom themes
- Control *theme_owner = data.theme_owner;
+ Control *theme_owner = p_theme_owner;
+ Window *theme_owner_window = p_theme_owner_window;
- while (theme_owner) {
+ while (theme_owner || theme_owner_window) {
- StringName class_name = type;
+ StringName class_name = p_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);
+ if (theme_owner && (theme_owner->data.theme.operator->()->*has_func)(p_name, class_name)) {
+ return true;
+ }
+
+ if (theme_owner_window && (theme_owner_window->theme.operator->()->*has_func)(p_name, class_name)) {
+ return true;
}
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
+ Node *parent = theme_owner ? theme_owner->get_parent() : theme_owner_window->get_parent();
+
+ Control *parent_c = Object::cast_to<Control>(parent);
+
+ if (parent_c) {
+ theme_owner = parent_c->data.theme_owner;
+ theme_owner_window = parent_c->data.theme_owner_window;
+ } else {
+ Window *parent_w = Object::cast_to<Window>(parent);
+ if (parent_w) {
+ theme_owner = parent_w->theme_owner;
+ theme_owner_window = parent_w->theme_owner_window;
+ } else {
+
+ theme_owner = NULL;
+ theme_owner_window = NULL;
+ }
+ }
+ }
+ return false;
+}
+
+Ref<Texture2D> Control::get_theme_icon(const StringName &p_name, const StringName &p_type) const {
+
+ if (p_type == StringName() || p_type == get_class_name()) {
+
+ const Ref<Texture2D> *tex = data.icon_override.getptr(p_name);
+ if (tex)
+ return *tex;
+ }
+
+ StringName type = p_type ? p_type : get_class_name();
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ return get_icons(data.theme_owner, data.theme_owner_window, p_name, type);
+}
+
+Ref<Texture2D> Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
+
+ Ref<Texture2D> icon;
+
+ if (_find_theme_item(p_theme_owner, p_theme_owner_window, icon, &Theme::get_icon, &Theme::has_icon, p_name, p_type)) {
+ return icon;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_icon(p_name, type)) {
- return Theme::get_project_default()->get_icon(p_name, type);
+ if (Theme::get_project_default()->has_icon(p_name, p_type)) {
+ return Theme::get_project_default()->get_icon(p_name, p_type);
}
}
- return Theme::get_default()->get_icon(p_name, type);
+ return Theme::get_default()->get_icon(p_name, p_type);
}
-Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_type) const {
+Ref<Shader> Control::get_theme_shader(const StringName &p_name, const StringName &p_type) const {
+
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
@@ -866,39 +893,27 @@ Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_ty
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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);
- }
+ return get_shaders(data.theme_owner, data.theme_owner_window, p_name, type);
+}
- class_name = ClassDB::get_parent_class_nocheck(class_name);
- }
+Ref<Shader> Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
+ Ref<Shader> shader;
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_find_theme_item(p_theme_owner, p_theme_owner_window, shader, &Theme::get_shader, &Theme::has_shader, p_name, p_type)) {
+ return shader;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_shader(p_name, type)) {
- return Theme::get_project_default()->get_shader(p_name, type);
+ if (Theme::get_project_default()->has_shader(p_name, p_type)) {
+ return Theme::get_project_default()->get_shader(p_name, p_type);
}
}
- return Theme::get_default()->get_shader(p_name, type);
+ return Theme::get_default()->get_shader(p_name, p_type);
}
-Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName &p_type) const {
+Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<StyleBox> *style = data.style_override.getptr(p_name);
@@ -908,43 +923,27 @@ Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName &
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
+ return get_styleboxs(data.theme_owner, data.theme_owner_window, p_name, type);
+}
- StringName class_name = type;
+Ref<StyleBox> Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- while (theme_owner) {
+ Ref<StyleBox> stylebox;
- 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);
- }
+ if (_find_theme_item(p_theme_owner, p_theme_owner_window, stylebox, &Theme::get_stylebox, &Theme::has_stylebox, p_name, p_type)) {
+ return stylebox;
+ }
- class_name = ClassDB::get_parent_class_nocheck(class_name);
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_stylebox(p_name, p_type)) {
+ return Theme::get_project_default()->get_stylebox(p_name, p_type);
}
-
- class_name = type;
-
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
-
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
}
- while (class_name != StringName()) {
- if (Theme::get_project_default().is_valid() && Theme::get_project_default()->has_stylebox(p_name, type))
- return Theme::get_project_default()->get_stylebox(p_name, type);
-
- if (Theme::get_default()->has_stylebox(p_name, class_name))
- return Theme::get_default()->get_stylebox(p_name, class_name);
-
- class_name = ClassDB::get_parent_class_nocheck(class_name);
- }
- return Theme::get_default()->get_stylebox(p_name, type);
+ return Theme::get_default()->get_stylebox(p_name, p_type);
}
-Ref<Font> Control::get_font(const StringName &p_name, const StringName &p_type) const {
+
+Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<Font> *font = data.font_override.getptr(p_name);
@@ -954,34 +953,27 @@ Ref<Font> Control::get_font(const StringName &p_name, const StringName &p_type)
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
+ return get_fonts(data.theme_owner, data.theme_owner_window, p_name, type);
+}
- while (theme_owner) {
+Ref<Font> Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- StringName class_name = type;
+ Ref<Font> font;
- 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);
- }
+ if (_find_theme_item(p_theme_owner, p_theme_owner_window, font, &Theme::get_font, &Theme::has_font, p_name, p_type)) {
+ return font;
+ }
- class_name = ClassDB::get_parent_class_nocheck(class_name);
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_font(p_name, p_type)) {
+ return Theme::get_project_default()->get_font(p_name, p_type);
}
-
- if (theme_owner->data.theme->get_default_theme_font().is_valid())
- return theme_owner->data.theme->get_default_theme_font();
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
-
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
}
- return Theme::get_default()->get_font(p_name, type);
+ return Theme::get_default()->get_font(p_name, p_type);
}
-Color Control::get_color(const StringName &p_name, const StringName &p_type) const {
+
+Color Control::get_theme_color(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const Color *color = data.color_override.getptr(p_name);
@@ -990,38 +982,27 @@ Color Control::get_color(const StringName &p_name, const StringName &p_type) con
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
- StringName class_name = type;
+ return get_colors(data.theme_owner, data.theme_owner_window, p_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);
- }
+Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- class_name = ClassDB::get_parent_class_nocheck(class_name);
- }
+ Color color;
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
-
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_find_theme_item(p_theme_owner, p_theme_owner_window, color, &Theme::get_color, &Theme::has_color, p_name, p_type)) {
+ return color;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_color(p_name, type)) {
- return Theme::get_project_default()->get_color(p_name, type);
+ if (Theme::get_project_default()->has_color(p_name, p_type)) {
+ return Theme::get_project_default()->get_color(p_name, p_type);
}
}
- return Theme::get_default()->get_color(p_name, type);
+ return Theme::get_default()->get_color(p_name, p_type);
}
-int Control::get_constant(const StringName &p_name, const StringName &p_type) const {
+int Control::get_theme_constant(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
const int *constant = data.constant_override.getptr(p_name);
@@ -1030,303 +1011,213 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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);
- }
+ return get_constants(data.theme_owner, data.theme_owner_window, p_name, type);
+}
- class_name = ClassDB::get_parent_class_nocheck(class_name);
- }
+int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
+ int constant;
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_find_theme_item(p_theme_owner, p_theme_owner_window, constant, &Theme::get_constant, &Theme::has_constant, p_name, p_type)) {
+ return constant;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_constant(p_name, type)) {
- return Theme::get_project_default()->get_constant(p_name, type);
+ if (Theme::get_project_default()->has_constant(p_name, p_type)) {
+ return Theme::get_project_default()->get_constant(p_name, p_type);
}
}
- return Theme::get_default()->get_constant(p_name, type);
+ return Theme::get_default()->get_constant(p_name, p_type);
}
-bool Control::has_icon_override(const StringName &p_name) const {
+bool Control::has_theme_icon_override(const StringName &p_name) const {
const Ref<Texture2D> *tex = data.icon_override.getptr(p_name);
return tex != NULL;
}
-bool Control::has_shader_override(const StringName &p_name) const {
+bool Control::has_theme_shader_override(const StringName &p_name) const {
const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
return sdr != NULL;
}
-bool Control::has_stylebox_override(const StringName &p_name) const {
+bool Control::has_theme_stylebox_override(const StringName &p_name) const {
const Ref<StyleBox> *style = data.style_override.getptr(p_name);
return style != NULL;
}
-bool Control::has_font_override(const StringName &p_name) const {
+bool Control::has_theme_font_override(const StringName &p_name) const {
const Ref<Font> *font = data.font_override.getptr(p_name);
return font != NULL;
}
-bool Control::has_color_override(const StringName &p_name) const {
+bool Control::has_theme_color_override(const StringName &p_name) const {
const Color *color = data.color_override.getptr(p_name);
return color != NULL;
}
-bool Control::has_constant_override(const StringName &p_name) const {
+bool Control::has_theme_constant_override(const StringName &p_name) const {
const int *constant = data.constant_override.getptr(p_name);
return constant != NULL;
}
-bool Control::has_icon(const StringName &p_name, const StringName &p_type) const {
+bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_icon_override(p_name))
+ if (has_theme_icon_override(p_name))
return true;
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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);
- }
+ return has_icons(data.theme_owner, data.theme_owner_window, p_name, type);
+}
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
+bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_icon, p_name, p_type)) {
+ return true;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_color(p_name, type)) {
+ if (Theme::get_project_default()->has_color(p_name, p_type)) {
return true;
}
}
- return Theme::get_default()->has_icon(p_name, type);
+ return Theme::get_default()->has_icon(p_name, p_type);
}
-bool Control::has_shader(const StringName &p_name, const StringName &p_type) const {
+bool Control::has_theme_shader(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_shader_override(p_name))
+ if (has_theme_shader_override(p_name))
return true;
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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 = Object::cast_to<Control>(theme_owner->get_parent());
+ return has_shaders(data.theme_owner, data.theme_owner_window, p_name, type);
+}
+bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_shader, p_name, p_type)) {
+ return true;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_shader(p_name, type)) {
+ if (Theme::get_project_default()->has_shader(p_name, p_type)) {
return true;
}
}
- return Theme::get_default()->has_shader(p_name, type);
+ return Theme::get_default()->has_shader(p_name, p_type);
}
-bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const {
+
+bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_stylebox_override(p_name))
+ if (has_theme_stylebox_override(p_name))
return true;
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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);
- }
+ return has_styleboxs(data.theme_owner, data.theme_owner_window, p_name, type);
+}
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
+bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_stylebox, p_name, p_type)) {
+ return true;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_stylebox(p_name, type)) {
+ if (Theme::get_project_default()->has_stylebox(p_name, p_type)) {
return true;
}
}
- return Theme::get_default()->has_stylebox(p_name, type);
+ return Theme::get_default()->has_stylebox(p_name, p_type);
}
-bool Control::has_font(const StringName &p_name, const StringName &p_type) const {
+
+bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_font_override(p_name))
+ if (has_theme_font_override(p_name))
return true;
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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 = Object::cast_to<Control>(theme_owner->get_parent());
+ return has_fonts(data.theme_owner, data.theme_owner_window, p_name, type);
+}
+bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_font, p_name, p_type)) {
+ return true;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_font(p_name, type)) {
+ if (Theme::get_project_default()->has_font(p_name, p_type)) {
return true;
}
}
- return Theme::get_default()->has_font(p_name, type);
+ return Theme::get_default()->has_font(p_name, p_type);
}
-bool Control::has_color(const StringName &p_name, const StringName &p_type) const {
+bool Control::has_theme_color(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_color_override(p_name))
+ if (has_theme_color_override(p_name))
return true;
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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 = Object::cast_to<Control>(theme_owner->get_parent());
+ return has_colors(data.theme_owner, data.theme_owner_window, p_name, type);
+}
+bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_color, p_name, p_type)) {
+ return true;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_color(p_name, type)) {
+ if (Theme::get_project_default()->has_color(p_name, p_type)) {
return true;
}
}
- return Theme::get_default()->has_color(p_name, type);
+ return Theme::get_default()->has_color(p_name, p_type);
}
-bool Control::has_constant(const StringName &p_name, const StringName &p_type) const {
+bool Control::has_theme_constant(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_constant_override(p_name))
+ if (has_theme_constant_override(p_name))
return true;
}
StringName type = p_type ? p_type : get_class_name();
- // try with custom themes
- Control *theme_owner = data.theme_owner;
-
- while (theme_owner) {
-
- 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);
- }
+ return has_constants(data.theme_owner, data.theme_owner_window, p_name, p_type);
+}
- Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
+bool Control::has_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
- if (parent)
- theme_owner = parent->data.theme_owner;
- else
- theme_owner = NULL;
+ if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_constant, p_name, p_type)) {
+ return true;
}
if (Theme::get_project_default().is_valid()) {
- if (Theme::get_project_default()->has_constant(p_name, type)) {
+ if (Theme::get_project_default()->has_constant(p_name, p_type)) {
return true;
}
}
- return Theme::get_default()->has_constant(p_name, type);
+ return Theme::get_default()->has_constant(p_name, p_type);
}
Rect2 Control::get_parent_anchorable_rect() const {
@@ -1769,6 +1660,17 @@ Point2 Control::get_global_position() const {
return get_global_transform().get_origin();
}
+Point2 Control::get_screen_position() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), Point2());
+ Point2 global_pos = get_global_position();
+ Window *w = Object::cast_to<Window>(get_viewport());
+ if (w && !w->is_embedding_subwindows()) {
+ global_pos += w->get_position();
+ }
+
+ return global_pos;
+}
+
void Control::_set_global_position(const Point2 &p_point) {
set_global_position(p_point);
}
@@ -1863,6 +1765,20 @@ Rect2 Control::get_global_rect() const {
return Rect2(get_global_position(), get_size());
}
+Rect2 Control::get_screen_rect() const {
+
+ ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
+
+ Rect2 r(get_global_position(), get_size());
+
+ Window *w = Object::cast_to<Window>(get_viewport());
+ if (w && !w->is_embedding_subwindows()) {
+ r.position += w->get_position();
+ }
+
+ return r;
+}
+
Rect2 Control::get_window_rect() const {
ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
Rect2 gr = get_global_rect();
@@ -1880,7 +1796,7 @@ Rect2 Control::get_anchorable_rect() const {
return Rect2(Point2(), get_size());
}
-void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) {
+void Control::add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) {
if (data.icon_override.has(p_name)) {
data.icon_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
@@ -1898,7 +1814,7 @@ void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> &
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader) {
+void Control::add_theme_shader_override(const StringName &p_name, const Ref<Shader> &p_shader) {
if (data.shader_override.has(p_name)) {
data.shader_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
@@ -1915,7 +1831,7 @@ void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p
}
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {
+void Control::add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {
if (data.style_override.has(p_name)) {
data.style_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
@@ -1933,7 +1849,7 @@ void Control::add_style_override(const StringName &p_name, const Ref<StyleBox> &
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_font_override(const StringName &p_name, const Ref<Font> &p_font) {
+void Control::add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font) {
if (data.font_override.has(p_name)) {
data.font_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
@@ -1950,12 +1866,12 @@ void Control::add_font_override(const StringName &p_name, const Ref<Font> &p_fon
}
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_color_override(const StringName &p_name, const Color &p_color) {
+void Control::add_theme_color_override(const StringName &p_name, const Color &p_color) {
data.color_override[p_name] = p_color;
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_constant_override(const StringName &p_name, int p_constant) {
+void Control::add_theme_constant_override(const StringName &p_name, int p_constant) {
data.constant_override[p_name] = p_constant;
notification(NOTIFICATION_THEME_CHANGED);
@@ -2049,7 +1965,7 @@ Control *Control::find_next_valid_focus() const {
next_child = const_cast<Control *>(this);
while (next_child) {
- if (next_child->data.SI || next_child->data.RI)
+ if (next_child->data.RI)
break;
next_child = next_child->get_parent_control();
}
@@ -2192,53 +2108,29 @@ bool Control::is_toplevel_control() const {
return is_inside_tree() && (!data.parent_canvas_item && !data.RI && is_set_as_toplevel());
}
-void Control::show_modal(bool p_exclusive) {
-
- ERR_FAIL_COND(!is_inside_tree());
- ERR_FAIL_COND(!data.SI);
-
- if (is_visible_in_tree())
- hide();
-
- ERR_FAIL_COND(data.MI != NULL);
- show();
- raise();
- data.modal_exclusive = p_exclusive;
- data.MI = get_viewport()->_gui_show_modal(this);
- data.modal_frame = Engine::get_singleton()->get_frames_drawn();
-}
+void Control::_propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_owner_window, bool p_assign) {
-void Control::_modal_set_prev_focus_owner(ObjectID p_prev) {
- data.modal_prev_focus_owner = p_prev;
-}
-
-void Control::_modal_stack_remove() {
-
- ERR_FAIL_COND(!is_inside_tree());
+ Control *c = Object::cast_to<Control>(p_at);
- if (!data.MI)
+ if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
return;
- List<Control *>::Element *element = data.MI;
- data.MI = NULL;
-
- get_viewport()->_gui_remove_from_modal_stack(element, data.modal_prev_focus_owner);
-
- data.modal_prev_focus_owner = ObjectID();
-}
+ Window *w = c == nullptr ? Object::cast_to<Window>(p_at) : nullptr;
-void Control::_propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign) {
-
- Control *c = Object::cast_to<Control>(p_at);
-
- if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
+ if (w && w != p_owner_window && w->theme.is_valid()) // has a theme, this can't be propagated
return;
for (int i = 0; i < p_at->get_child_count(); i++) {
CanvasItem *child = Object::cast_to<CanvasItem>(p_at->get_child(i));
if (child) {
- _propagate_theme_changed(child, p_owner, p_assign);
+ _propagate_theme_changed(child, p_owner, p_owner_window, p_assign);
+ } else {
+
+ Window *window = Object::cast_to<Window>(p_at->get_child(i));
+ if (window) {
+ _propagate_theme_changed(window, p_owner, p_owner_window, p_assign);
+ }
}
}
@@ -2246,14 +2138,26 @@ void Control::_propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool
if (p_assign) {
c->data.theme_owner = p_owner;
+ c->data.theme_owner_window = p_owner_window;
+ }
+ c->notification(Control::NOTIFICATION_THEME_CHANGED);
+ c->emit_signal(SceneStringNames::get_singleton()->theme_changed);
+ }
+
+ if (w) {
+
+ if (p_assign) {
+ w->theme_owner = p_owner;
+ w->theme_owner_window = p_owner_window;
}
- c->notification(NOTIFICATION_THEME_CHANGED);
+ w->notification(Window::NOTIFICATION_THEME_CHANGED);
+ w->emit_signal(SceneStringNames::get_singleton()->theme_changed);
}
}
void Control::_theme_changed() {
- _propagate_theme_changed(this, this, false);
+ _propagate_theme_changed(this, this, nullptr, false);
}
void Control::set_theme(const Ref<Theme> &p_theme) {
@@ -2269,15 +2173,21 @@ void Control::set_theme(const Ref<Theme> &p_theme) {
if (!p_theme.is_null()) {
data.theme_owner = this;
- _propagate_theme_changed(this, this);
+ data.theme_owner_window = nullptr;
+ _propagate_theme_changed(this, this, nullptr);
} else {
- Control *parent = cast_to<Control>(get_parent());
- if (parent && parent->data.theme_owner) {
- _propagate_theme_changed(this, parent->data.theme_owner);
- } else {
+ Control *parent_c = Object::cast_to<Control>(get_parent());
- _propagate_theme_changed(this, NULL);
+ if (parent_c && (parent_c->data.theme_owner || parent_c->data.theme_owner_window)) {
+ Control::_propagate_theme_changed(this, parent_c->data.theme_owner, parent_c->data.theme_owner_window);
+ } else {
+ Window *parent_w = cast_to<Window>(get_parent());
+ if (parent_w && (parent_w->theme_owner || parent_w->theme_owner_window)) {
+ Control::_propagate_theme_changed(this, parent_w->theme_owner, parent_w->theme_owner_window);
+ } else {
+ Control::_propagate_theme_changed(this, nullptr, nullptr);
+ }
}
}
@@ -2440,8 +2350,6 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
Control *c = Object::cast_to<Control>(base);
if (c) {
- if (c->data.SI)
- break;
if (c->data.RI)
break;
}
@@ -2511,7 +2419,7 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
Node *child = p_at->get_child(i);
Control *childc = Object::cast_to<Control>(child);
- if (childc && childc->data.SI)
+ if (childc && childc->data.RI)
continue; //subwindow, ignore
_window_find_focus_neighbour(p_dir, p_at->get_child(i), p_points, p_min, r_closest_dist, r_closest);
}
@@ -2569,6 +2477,12 @@ void Control::minimum_size_changed() {
invalidate->data.minimum_size_valid = false;
if (invalidate->is_set_as_toplevel())
break; // do not go further up
+ if (!invalidate->data.parent && get_parent()) {
+ Window *parent_window = Object::cast_to<Window>(get_parent());
+ if (parent_window && parent_window->is_wrapping_controls()) {
+ parent_window->child_controls_changed();
+ }
+ }
invalidate = invalidate->data.parent;
}
@@ -2599,16 +2513,6 @@ Control::MouseFilter Control::get_mouse_filter() const {
return data.mouse_filter;
}
-void Control::set_pass_on_modal_close_click(bool p_pass_on) {
-
- data.pass_on_modal_close_click = p_pass_on;
-}
-
-bool Control::pass_on_modal_close_click() const {
-
- return data.pass_on_modal_close_click;
-}
-
Control *Control::get_focus_owner() const {
ERR_FAIL_COND_V(!is_inside_tree(), NULL);
@@ -2658,6 +2562,7 @@ float Control::get_rotation_degrees() const {
void Control::_override_changed() {
notification(NOTIFICATION_THEME_CHANGED);
+ emit_signal(SceneStringNames::get_singleton()->theme_changed);
minimum_size_changed(); // overrides are likely to affect minimum size
}
@@ -2701,7 +2606,7 @@ Control *Control::get_root_parent_control() const {
if (c) {
root = c;
- if (c->data.RI || c->data.MI || c->is_toplevel_control())
+ if (c->data.RI || c->is_toplevel_control())
break;
}
@@ -2853,7 +2758,6 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_global_position"), &Control::get_global_position);
ClassDB::bind_method(D_METHOD("get_rect"), &Control::get_rect);
ClassDB::bind_method(D_METHOD("get_global_rect"), &Control::get_global_rect);
- ClassDB::bind_method(D_METHOD("show_modal", "exclusive"), &Control::show_modal, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_focus_mode", "mode"), &Control::set_focus_mode);
ClassDB::bind_method(D_METHOD("get_focus_mode"), &Control::get_focus_mode);
ClassDB::bind_method(D_METHOD("has_focus"), &Control::has_focus);
@@ -2873,31 +2777,31 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_theme", "theme"), &Control::set_theme);
ClassDB::bind_method(D_METHOD("get_theme"), &Control::get_theme);
- ClassDB::bind_method(D_METHOD("add_icon_override", "name", "texture"), &Control::add_icon_override);
- ClassDB::bind_method(D_METHOD("add_shader_override", "name", "shader"), &Control::add_shader_override);
- ClassDB::bind_method(D_METHOD("add_stylebox_override", "name", "stylebox"), &Control::add_style_override);
- ClassDB::bind_method(D_METHOD("add_font_override", "name", "font"), &Control::add_font_override);
- ClassDB::bind_method(D_METHOD("add_color_override", "name", "color"), &Control::add_color_override);
- ClassDB::bind_method(D_METHOD("add_constant_override", "name", "constant"), &Control::add_constant_override);
-
- ClassDB::bind_method(D_METHOD("get_icon", "name", "type"), &Control::get_icon, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("get_stylebox", "name", "type"), &Control::get_stylebox, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("get_font", "name", "type"), &Control::get_font, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("get_color", "name", "type"), &Control::get_color, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("get_constant", "name", "type"), &Control::get_constant, DEFVAL(""));
-
- ClassDB::bind_method(D_METHOD("has_icon_override", "name"), &Control::has_icon_override);
- ClassDB::bind_method(D_METHOD("has_shader_override", "name"), &Control::has_shader_override);
- ClassDB::bind_method(D_METHOD("has_stylebox_override", "name"), &Control::has_stylebox_override);
- ClassDB::bind_method(D_METHOD("has_font_override", "name"), &Control::has_font_override);
- ClassDB::bind_method(D_METHOD("has_color_override", "name"), &Control::has_color_override);
- ClassDB::bind_method(D_METHOD("has_constant_override", "name"), &Control::has_constant_override);
-
- ClassDB::bind_method(D_METHOD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("add_theme_icon_override", "name", "texture"), &Control::add_theme_icon_override);
+ ClassDB::bind_method(D_METHOD("add_theme_shader_override", "name", "shader"), &Control::add_theme_shader_override);
+ ClassDB::bind_method(D_METHOD("add_theme_stylebox_override", "name", "stylebox"), &Control::add_theme_style_override);
+ ClassDB::bind_method(D_METHOD("add_theme_font_override", "name", "font"), &Control::add_theme_font_override);
+ ClassDB::bind_method(D_METHOD("add_theme_color_override", "name", "color"), &Control::add_theme_color_override);
+ ClassDB::bind_method(D_METHOD("add_theme_constant_override", "name", "constant"), &Control::add_theme_constant_override);
+
+ ClassDB::bind_method(D_METHOD("get_theme_icon", "name", "type"), &Control::get_theme_icon, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_stylebox", "name", "type"), &Control::get_theme_stylebox, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_font", "name", "type"), &Control::get_theme_font, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_color", "name", "type"), &Control::get_theme_color, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_constant", "name", "type"), &Control::get_theme_constant, DEFVAL(""));
+
+ ClassDB::bind_method(D_METHOD("has_theme_icon_override", "name"), &Control::has_theme_icon_override);
+ ClassDB::bind_method(D_METHOD("has_theme_shader_override", "name"), &Control::has_theme_shader_override);
+ ClassDB::bind_method(D_METHOD("has_theme_stylebox_override", "name"), &Control::has_theme_stylebox_override);
+ ClassDB::bind_method(D_METHOD("has_theme_font_override", "name"), &Control::has_theme_font_override);
+ ClassDB::bind_method(D_METHOD("has_theme_color_override", "name"), &Control::has_theme_color_override);
+ ClassDB::bind_method(D_METHOD("has_theme_constant_override", "name"), &Control::has_theme_constant_override);
+
+ ClassDB::bind_method(D_METHOD("has_theme_icon", "name", "type"), &Control::has_theme_icon, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_stylebox", "name", "type"), &Control::has_theme_stylebox, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_font", "name", "type"), &Control::has_theme_font, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_color", "name", "type"), &Control::has_theme_color, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_constant", "name", "type"), &Control::has_theme_constant, DEFVAL(""));
ClassDB::bind_method(D_METHOD("get_parent_control"), &Control::get_parent_control);
@@ -3013,7 +2917,6 @@ void Control::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_FOCUS_ENTER);
BIND_CONSTANT(NOTIFICATION_FOCUS_EXIT);
BIND_CONSTANT(NOTIFICATION_THEME_CHANGED);
- BIND_CONSTANT(NOTIFICATION_MODAL_CLOSE);
BIND_CONSTANT(NOTIFICATION_SCROLL_BEGIN);
BIND_CONSTANT(NOTIFICATION_SCROLL_END);
@@ -3082,7 +2985,7 @@ void Control::_bind_methods() {
ADD_SIGNAL(MethodInfo("focus_exited"));
ADD_SIGNAL(MethodInfo("size_flags_changed"));
ADD_SIGNAL(MethodInfo("minimum_size_changed"));
- ADD_SIGNAL(MethodInfo("modal_closed"));
+ ADD_SIGNAL(MethodInfo("theme_changed"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_point", PropertyInfo(Variant::VECTOR2, "point")));
}
@@ -3091,13 +2994,10 @@ Control::Control() {
data.parent = NULL;
data.mouse_filter = MOUSE_FILTER_STOP;
- data.pass_on_modal_close_click = true;
- data.SI = NULL;
- data.MI = NULL;
data.RI = NULL;
data.theme_owner = NULL;
- data.modal_exclusive = false;
+ data.theme_owner_window = NULL;
data.default_cursor = CURSOR_ARROW;
data.h_size_flags = SIZE_FILL;
data.v_size_flags = SIZE_FILL;
@@ -3106,7 +3006,6 @@ Control::Control() {
data.parent_canvas_item = NULL;
data.scale = Vector2(1, 1);
- data.modal_frame = 0;
data.block_minimum_size_adjust = false;
data.disable_visibility_clip = false;
data.h_grow = GROW_DIRECTION_END;
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 15a32b8f67..d02fea20a6 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -33,8 +33,8 @@
#include "core/math/transform_2d.h"
#include "core/rid.h"
-#include "scene/2d/canvas_item.h"
#include "scene/gui/shortcut.h"
+#include "scene/main/canvas_item.h"
#include "scene/main/node.h"
#include "scene/main/timer.h"
#include "scene/resources/theme.h"
@@ -168,8 +168,6 @@ private:
float expand;
Point2 custom_minimum_size;
- bool pass_on_modal_close_click;
-
MouseFilter mouse_filter;
bool clip_contents;
@@ -179,21 +177,16 @@ private:
Control *parent;
ObjectID drag_owner;
- bool modal_exclusive;
- uint64_t modal_frame; //frame used to put something as modal
Ref<Theme> theme;
Control *theme_owner;
+ Window *theme_owner_window;
String tooltip;
CursorShape default_cursor;
- List<Control *>::Element *MI; //modal item
- List<Control *>::Element *SI;
List<Control *>::Element *RI;
CanvasItem *parent_canvas_item;
- ObjectID modal_prev_focus_owner;
-
NodePath focus_neighbour[4];
NodePath focus_next;
NodePath focus_prev;
@@ -218,7 +211,6 @@ private:
void _set_global_position(const Point2 &p_point);
void _set_size(const Size2 &p_size);
- void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign = true);
void _theme_changed();
void _change_notify_margins();
@@ -240,10 +232,29 @@ private:
Transform2D _get_internal_transform() const;
friend class Viewport;
- void _modal_stack_remove();
- void _modal_set_prev_focus_owner(ObjectID p_prev);
void _update_minimum_size_cache();
+ friend class Window;
+ static void _propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_owner_window, bool p_assign = true);
+
+ template <class T>
+ _FORCE_INLINE_ static bool _find_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, T &, T (Theme::*get_func)(const StringName &, const StringName &) const, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type);
+
+ _FORCE_INLINE_ static bool _has_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type);
+
+ static Ref<Texture2D> get_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static Ref<Shader> get_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static Ref<StyleBox> get_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static Ref<Font> get_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static Color get_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static int get_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+
+ static bool has_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static bool has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static bool has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static bool has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static bool has_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
+ static bool has_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type = StringName());
protected:
virtual void add_child_notify(Node *p_child);
@@ -272,7 +283,6 @@ public:
NOTIFICATION_FOCUS_ENTER = 43,
NOTIFICATION_FOCUS_EXIT = 44,
NOTIFICATION_THEME_CHANGED = 45,
- NOTIFICATION_MODAL_CLOSE = 46,
NOTIFICATION_SCROLL_BEGIN = 47,
NOTIFICATION_SCROLL_END = 48,
@@ -320,9 +330,6 @@ public:
void set_custom_minimum_size(const Size2 &p_custom);
Size2 get_custom_minimum_size() const;
- bool is_window_modal_on_top() const;
- uint64_t get_modal_frame() const; //frame in which this was made modal
-
Control *get_parent_control() const;
/* POSITIONING */
@@ -349,12 +356,14 @@ public:
void set_global_position(const Point2 &p_point, bool p_keep_margins = false);
Point2 get_position() const;
Point2 get_global_position() const;
+ Point2 get_screen_position() const;
void set_size(const Size2 &p_size, bool p_keep_margins = false);
Size2 get_size() const;
Rect2 get_rect() const;
Rect2 get_global_rect() const;
+ Rect2 get_screen_rect() const;
Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server
Rect2 get_anchorable_rect() const;
@@ -375,8 +384,6 @@ public:
void set_scale(const Vector2 &p_scale);
Vector2 get_scale() const;
- void show_modal(bool p_exclusive = false);
-
void set_theme(const Ref<Theme> &p_theme);
Ref<Theme> get_theme() const;
@@ -415,38 +422,35 @@ public:
void set_mouse_filter(MouseFilter p_filter);
MouseFilter get_mouse_filter() const;
- void set_pass_on_modal_close_click(bool p_pass_on);
- bool pass_on_modal_close_click() const;
-
/* SKINNING */
- void add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon);
- void add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader);
- void add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
- void add_font_override(const StringName &p_name, const Ref<Font> &p_font);
- void add_color_override(const StringName &p_name, const Color &p_color);
- void add_constant_override(const StringName &p_name, int p_constant);
-
- Ref<Texture2D> get_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
- Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
- Ref<StyleBox> get_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
- Ref<Font> get_font(const StringName &p_name, const StringName &p_type = StringName()) const;
- Color get_color(const StringName &p_name, const StringName &p_type = StringName()) const;
- int get_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
-
- bool has_icon_override(const StringName &p_name) const;
- bool has_shader_override(const StringName &p_name) const;
- bool has_stylebox_override(const StringName &p_name) const;
- bool has_font_override(const StringName &p_name) const;
- bool has_color_override(const StringName &p_name) const;
- bool has_constant_override(const StringName &p_name) const;
-
- bool has_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
- bool has_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
- bool has_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
- bool has_font(const StringName &p_name, const StringName &p_type = StringName()) const;
- bool has_color(const StringName &p_name, const StringName &p_type = StringName()) const;
- bool has_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
+ void add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon);
+ void add_theme_shader_override(const StringName &p_name, const Ref<Shader> &p_shader);
+ void add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
+ void add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font);
+ void add_theme_color_override(const StringName &p_name, const Color &p_color);
+ void add_theme_constant_override(const StringName &p_name, int p_constant);
+
+ Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<Shader> get_theme_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<StyleBox> get_theme_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<Font> get_theme_font(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Color get_theme_color(const StringName &p_name, const StringName &p_type = StringName()) const;
+ int get_theme_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
+
+ bool has_theme_icon_override(const StringName &p_name) const;
+ bool has_theme_shader_override(const StringName &p_name) const;
+ bool has_theme_stylebox_override(const StringName &p_name) const;
+ bool has_theme_font_override(const StringName &p_name) const;
+ bool has_theme_color_override(const StringName &p_name) const;
+ bool has_theme_constant_override(const StringName &p_name) const;
+
+ bool has_theme_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_font(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_color(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
/* TOOLTIP */
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 6cadd0a63e..2e87a92969 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "dialogs.h"
+
+#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/translation.h"
#include "line_edit.h"
@@ -36,362 +38,61 @@
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
-#include "scene/main/viewport.h" // Only used to check for more modals when dimming the editor.
+#include "scene/main/window.h" // Only used to check for more modals when dimming the editor.
#endif
-// WindowDialog
-
-void WindowDialog::_post_popup() {
-
- drag_type = DRAG_NONE; // just in case
-}
-
-void WindowDialog::_fix_size() {
-
- // Perhaps this should be called when the viewport resizes as well or windows go out of bounds...
-
- // Ensure the whole window is visible.
- Point2i pos = get_global_position();
- Size2i size = get_size();
- Size2i viewport_size = get_viewport_rect().size;
-
- // Windows require additional padding to keep the window chrome visible.
- Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
- float top = 0;
- float left = 0;
- float bottom = 0;
- float right = 0;
- // Check validity, because the theme could contain a different type of StyleBox.
- if (panel->get_class() == "StyleBoxTexture") {
- Ref<StyleBoxTexture> panel_texture = Object::cast_to<StyleBoxTexture>(*panel);
- top = panel_texture->get_expand_margin_size(MARGIN_TOP);
- left = panel_texture->get_expand_margin_size(MARGIN_LEFT);
- bottom = panel_texture->get_expand_margin_size(MARGIN_BOTTOM);
- right = panel_texture->get_expand_margin_size(MARGIN_RIGHT);
- } else if (panel->get_class() == "StyleBoxFlat") {
- Ref<StyleBoxFlat> panel_flat = Object::cast_to<StyleBoxFlat>(*panel);
- top = panel_flat->get_expand_margin_size(MARGIN_TOP);
- left = panel_flat->get_expand_margin_size(MARGIN_LEFT);
- bottom = panel_flat->get_expand_margin_size(MARGIN_BOTTOM);
- right = panel_flat->get_expand_margin_size(MARGIN_RIGHT);
- }
-
- pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right));
- pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom));
- set_global_position(pos);
+// AcceptDialog
- if (resizable) {
- size.x = MIN(size.x, viewport_size.x - left - right);
- size.y = MIN(size.y, viewport_size.y - top - bottom);
- set_size(size);
+void AcceptDialog::_input_from_window(const Ref<InputEvent> &p_event) {
+ Ref<InputEventKey> key = p_event;
+ if (key.is_valid() && key->is_pressed() && key->get_keycode() == KEY_ESCAPE) {
+ _cancel_pressed();
}
}
-bool WindowDialog::has_point(const Point2 &p_point) const {
-
- Rect2 r(Point2(), get_size());
-
- // Enlarge upwards for title bar.
- int title_height = get_constant("title_height", "WindowDialog");
- r.position.y -= title_height;
- r.size.y += title_height;
-
- // Inflate by the resizable border thickness.
- if (resizable) {
- int scaleborder_size = get_constant("scaleborder_size", "WindowDialog");
- r.position.x -= scaleborder_size;
- r.size.width += scaleborder_size * 2;
- r.position.y -= scaleborder_size;
- r.size.height += scaleborder_size * 2;
- }
-
- return r.has_point(p_point);
+void AcceptDialog::_parent_focused() {
+ _cancel_pressed();
}
-void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) {
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
-
- if (mb->is_pressed()) {
- // Begin a possible dragging operation.
- drag_type = _drag_hit_test(Point2(mb->get_position().x, mb->get_position().y));
- if (drag_type != DRAG_NONE)
- drag_offset = get_global_mouse_position() - get_position();
- drag_offset_far = get_position() + get_size() - get_global_mouse_position();
- } else if (drag_type != DRAG_NONE && !mb->is_pressed()) {
- // End a dragging operation.
- drag_type = DRAG_NONE;
- }
- }
+void AcceptDialog::_notification(int p_what) {
- Ref<InputEventMouseMotion> mm = p_event;
-
- if (mm.is_valid()) {
-
- if (drag_type == DRAG_NONE) {
- // Update the cursor while moving along the borders.
- CursorShape cursor = CURSOR_ARROW;
- if (resizable) {
- int preview_drag_type = _drag_hit_test(Point2(mm->get_position().x, mm->get_position().y));
- switch (preview_drag_type) {
- case DRAG_RESIZE_TOP:
- case DRAG_RESIZE_BOTTOM:
- cursor = CURSOR_VSIZE;
- break;
- case DRAG_RESIZE_LEFT:
- case DRAG_RESIZE_RIGHT:
- cursor = CURSOR_HSIZE;
- break;
- case DRAG_RESIZE_TOP + DRAG_RESIZE_LEFT:
- case DRAG_RESIZE_BOTTOM + DRAG_RESIZE_RIGHT:
- cursor = CURSOR_FDIAGSIZE;
- break;
- case DRAG_RESIZE_TOP + DRAG_RESIZE_RIGHT:
- case DRAG_RESIZE_BOTTOM + DRAG_RESIZE_LEFT:
- cursor = CURSOR_BDIAGSIZE;
- break;
+ switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (is_visible()) {
+
+ get_ok()->grab_focus();
+ _update_child_rects();
+ parent_visible = get_parent_visible_window();
+ if (parent_visible) {
+ parent_visible->connect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
}
- }
- if (get_cursor_shape() != cursor)
- set_default_cursor_shape(cursor);
- } else {
- // Update while in a dragging operation.
- Point2 global_pos = get_global_mouse_position();
- global_pos.y = MAX(global_pos.y, 0); // Ensure title bar stays visible.
-
- Rect2 rect = get_rect();
- Size2 min_size = get_combined_minimum_size();
-
- if (drag_type == DRAG_MOVE) {
- rect.position = global_pos - drag_offset;
} else {
- if (drag_type & DRAG_RESIZE_TOP) {
- int bottom = rect.position.y + rect.size.height;
- int max_y = bottom - min_size.height;
- rect.position.y = MIN(global_pos.y - drag_offset.y, max_y);
- rect.size.height = bottom - rect.position.y;
- } else if (drag_type & DRAG_RESIZE_BOTTOM) {
- rect.size.height = global_pos.y - rect.position.y + drag_offset_far.y;
- }
- if (drag_type & DRAG_RESIZE_LEFT) {
- int right = rect.position.x + rect.size.width;
- int max_x = right - min_size.width;
- rect.position.x = MIN(global_pos.x - drag_offset.x, max_x);
- rect.size.width = right - rect.position.x;
- } else if (drag_type & DRAG_RESIZE_RIGHT) {
- rect.size.width = global_pos.x - rect.position.x + drag_offset_far.x;
+ if (parent_visible) {
+ parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
+ parent_visible = nullptr;
}
}
- set_size(rect.size);
- set_position(rect.position);
- }
- }
-}
-
-void WindowDialog::_notification(int p_what) {
-
- switch (p_what) {
- case NOTIFICATION_DRAW: {
- RID canvas = get_canvas_item();
-
- // Draw the background.
- Ref<StyleBox> panel = get_stylebox("panel");
- Size2 size = get_size();
- panel->draw(canvas, Rect2(0, 0, size.x, size.y));
-
- // Draw the title bar text.
- Ref<Font> title_font = get_font("title_font", "WindowDialog");
- Color title_color = get_color("title_color", "WindowDialog");
- int title_height = get_constant("title_height", "WindowDialog");
- int font_height = title_font->get_height() - title_font->get_descent() * 2;
- int x = (size.x - title_font->get_string_size(xl_title).x) / 2;
- int y = (-title_height + font_height) / 2;
- title_font->draw(canvas, Point2(x, y), xl_title, title_color, size.x - panel->get_minimum_size().x);
} break;
- case NOTIFICATION_THEME_CHANGED:
- case NOTIFICATION_ENTER_TREE: {
- close_button->set_normal_texture(get_icon("close", "WindowDialog"));
- close_button->set_pressed_texture(get_icon("close", "WindowDialog"));
- close_button->set_hover_texture(get_icon("close_highlight", "WindowDialog"));
- close_button->set_anchor(MARGIN_LEFT, ANCHOR_END);
- close_button->set_begin(Point2(-get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog")));
- } break;
-
- case NOTIFICATION_TRANSLATION_CHANGED: {
- String new_title = tr(title);
- if (new_title != xl_title) {
- xl_title = new_title;
- minimum_size_changed();
- update();
- }
+ case NOTIFICATION_THEME_CHANGED: {
+ bg->add_theme_style_override("panel", bg->get_theme_stylebox("panel", "AcceptDialog"));
} break;
- case NOTIFICATION_MOUSE_EXIT: {
- // Reset the mouse cursor when leaving the resizable window border.
- if (resizable && !drag_type) {
- if (get_default_cursor_shape() != CURSOR_ARROW)
- set_default_cursor_shape(CURSOR_ARROW);
+ case NOTIFICATION_EXIT_TREE: {
+ if (parent_visible) {
+ parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
+ parent_visible = nullptr;
}
} break;
-
-#ifdef TOOLS_ENABLED
- case NOTIFICATION_POST_POPUP: {
- if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton()) {
- was_editor_dimmed = EditorNode::get_singleton()->is_editor_dimmed();
- EditorNode::get_singleton()->dim_editor(true);
- }
- } break;
-
- case NOTIFICATION_POPUP_HIDE: {
- if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton() && !was_editor_dimmed) {
- EditorNode::get_singleton()->dim_editor(false);
- set_pass_on_modal_close_click(false);
+ case NOTIFICATION_READY:
+ case NOTIFICATION_WM_SIZE_CHANGED: {
+ if (is_visible()) {
+ _update_child_rects();
}
} break;
-#endif
- }
-}
-
-void WindowDialog::_closed() {
-
- _close_pressed();
- hide();
-}
-
-int WindowDialog::_drag_hit_test(const Point2 &pos) const {
- int drag_type = DRAG_NONE;
-
- if (resizable) {
- int title_height = get_constant("title_height", "WindowDialog");
- int scaleborder_size = get_constant("scaleborder_size", "WindowDialog");
-
- Rect2 rect = get_rect();
-
- if (pos.y < (-title_height + scaleborder_size))
- drag_type = DRAG_RESIZE_TOP;
- else if (pos.y >= (rect.size.height - scaleborder_size))
- drag_type = DRAG_RESIZE_BOTTOM;
- if (pos.x < scaleborder_size)
- drag_type |= DRAG_RESIZE_LEFT;
- else if (pos.x >= (rect.size.width - scaleborder_size))
- drag_type |= DRAG_RESIZE_RIGHT;
- }
-
- if (drag_type == DRAG_NONE && pos.y < 0)
- drag_type = DRAG_MOVE;
-
- return drag_type;
-}
-
-void WindowDialog::set_title(const String &p_title) {
-
- if (title != p_title) {
- title = p_title;
- xl_title = tr(p_title);
- minimum_size_changed();
- update();
- }
-}
-String WindowDialog::get_title() const {
-
- return title;
-}
-
-void WindowDialog::set_resizable(bool p_resizable) {
- resizable = p_resizable;
-}
-bool WindowDialog::get_resizable() const {
- return resizable;
-}
-
-Size2 WindowDialog::get_minimum_size() const {
-
- Ref<Font> font = get_font("title_font", "WindowDialog");
-
- const int button_width = close_button->get_combined_minimum_size().x;
- const int title_width = font->get_string_size(xl_title).x;
- const int padding = button_width / 2;
- const int button_area = button_width + padding;
-
- // As the title gets centered, title_width + close_button_width is not enough.
- // We want a width w, such that w / 2 - title_width / 2 >= button_area, i.e.
- // w >= 2 * button_area + title_width
-
- return Size2(2 * button_area + title_width, 1);
-}
-
-TextureButton *WindowDialog::get_close_button() {
-
- return close_button;
-}
-
-void WindowDialog::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_gui_input"), &WindowDialog::_gui_input);
- ClassDB::bind_method(D_METHOD("set_title", "title"), &WindowDialog::set_title);
- ClassDB::bind_method(D_METHOD("get_title"), &WindowDialog::get_title);
- ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &WindowDialog::set_resizable);
- ClassDB::bind_method(D_METHOD("get_resizable"), &WindowDialog::get_resizable);
- ClassDB::bind_method(D_METHOD("get_close_button"), &WindowDialog::get_close_button);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "window_title", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_title", "get_title");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_resizable", "get_resizable");
-}
-
-WindowDialog::WindowDialog() {
-
- drag_type = DRAG_NONE;
- resizable = false;
- close_button = memnew(TextureButton);
- add_child(close_button);
- close_button->connect("pressed", callable_mp(this, &WindowDialog::_closed));
-
-#ifdef TOOLS_ENABLED
- was_editor_dimmed = false;
-#endif
-}
-
-WindowDialog::~WindowDialog() {
-}
-
-// PopupDialog
-
-void PopupDialog::_notification(int p_what) {
-
- if (p_what == NOTIFICATION_DRAW) {
- RID ci = get_canvas_item();
- get_stylebox("panel")->draw(ci, Rect2(Point2(), get_size()));
- }
-}
-
-PopupDialog::PopupDialog() {
-}
-
-PopupDialog::~PopupDialog() {
-}
-
-// AcceptDialog
-
-void AcceptDialog::_post_popup() {
-
- WindowDialog::_post_popup();
- get_ok()->grab_focus();
-}
-
-void AcceptDialog::_notification(int p_what) {
-
- switch (p_what) {
- case NOTIFICATION_MODAL_CLOSE: {
- cancel_pressed();
- } break;
-
- case NOTIFICATION_READY:
- case NOTIFICATION_RESIZED: {
- _update_child_rects();
+ case NOTIFICATION_WM_CLOSE_REQUEST: {
+ _cancel_pressed();
} break;
}
}
@@ -404,20 +105,28 @@ void AcceptDialog::_text_entered(const String &p_text) {
void AcceptDialog::_ok_pressed() {
if (hide_on_ok)
- hide();
+ set_visible(false);
ok_pressed();
emit_signal("confirmed");
}
-void AcceptDialog::_close_pressed() {
+void AcceptDialog::_cancel_pressed() {
+
+ Window *parent_window = parent_visible;
+ if (parent_visible) {
+ parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
+ parent_visible = nullptr;
+ }
+
+ call_deferred("hide");
+
+ emit_signal("cancelled");
cancel_pressed();
-}
-// FIXME: This is redundant with _closed_pressed, but there's a slight behavior
-// change (WindowDialog's _closed() also calls hide()) which should be assessed.
-void AcceptDialog::_on_close_pressed() {
- _closed(); // From WindowDialog.
+ if (parent_window) {
+ //parent_window->grab_focus();
+ }
}
String AcceptDialog::get_text() const {
@@ -427,8 +136,10 @@ String AcceptDialog::get_text() const {
void AcceptDialog::set_text(String p_text) {
label->set_text(p_text);
- minimum_size_changed();
- _update_child_rects();
+ child_controls_changed();
+ if (is_visible()) {
+ _update_child_rects();
+ }
}
void AcceptDialog::set_hide_on_ok(bool p_hide) {
@@ -463,7 +174,7 @@ void AcceptDialog::_update_child_rects() {
if (label->get_text().empty()) {
label_size.height = 0;
}
- int margin = get_constant("margin", "Dialogs");
+ int margin = hbc->get_theme_constant("margin", "Dialogs");
Size2 size = get_size();
Size2 hminsize = hbc->get_combined_minimum_size();
@@ -475,7 +186,7 @@ void AcceptDialog::_update_child_rects() {
if (!c)
continue;
- if (c == hbc || c == label || c == get_close_button() || c->is_set_as_toplevel())
+ if (c == hbc || c == label || c == bg || c->is_set_as_toplevel())
continue;
c->set_position(cpos);
@@ -487,11 +198,14 @@ void AcceptDialog::_update_child_rects() {
hbc->set_position(cpos);
hbc->set_size(csize);
+
+ bg->set_position(Point2());
+ bg->set_size(size);
}
-Size2 AcceptDialog::get_minimum_size() const {
+Size2 AcceptDialog::_get_contents_minimum_size() const {
- int margin = get_constant("margin", "Dialogs");
+ int margin = hbc->get_theme_constant("margin", "Dialogs");
Size2 minsize = label->get_combined_minimum_size();
for (int i = 0; i < get_child_count(); i++) {
@@ -499,7 +213,7 @@ Size2 AcceptDialog::get_minimum_size() const {
if (!c)
continue;
- if (c == hbc || c == label || c == const_cast<AcceptDialog *>(this)->get_close_button() || c->is_set_as_toplevel())
+ if (c == hbc || c == label || c->is_set_as_toplevel())
continue;
Size2 cminsize = c->get_combined_minimum_size();
@@ -513,7 +227,7 @@ Size2 AcceptDialog::get_minimum_size() const {
minsize.x += margin * 2;
minsize.y += margin * 3; //one as separation between hbc and child
- Size2 wmsize = WindowDialog::get_minimum_size();
+ Size2 wmsize = get_min_size();
minsize.x = MAX(wmsize.x, minsize.x);
return minsize;
}
@@ -551,7 +265,7 @@ Button *AcceptDialog::add_cancel(const String &p_cancel) {
if (p_cancel == "")
c = RTR("Cancel");
Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c);
- b->connect("pressed", callable_mp(this, &AcceptDialog::_on_close_pressed));
+ b->connect("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed));
return b;
}
@@ -570,6 +284,7 @@ void AcceptDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_autowrap"), &AcceptDialog::has_autowrap);
ADD_SIGNAL(MethodInfo("confirmed"));
+ ADD_SIGNAL(MethodInfo("cancelled"));
ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING_NAME, "action")));
ADD_GROUP("Dialog", "dialog");
@@ -586,12 +301,23 @@ void AcceptDialog::set_swap_ok_cancel(bool p_swap) {
AcceptDialog::AcceptDialog() {
- int margin = get_constant("margin", "Dialogs");
- int button_margin = get_constant("button_margin", "Dialogs");
+ parent_visible = nullptr;
+
+ set_wrap_controls(true);
+ set_visible(false);
+ set_transient(true);
+
+ bg = memnew(Panel);
+ add_child(bg);
+
+ hbc = memnew(HBoxContainer);
+
+ int margin = hbc->get_theme_constant("margin", "Dialogs");
+ int button_margin = hbc->get_theme_constant("button_margin", "Dialogs");
label = memnew(Label);
- label->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- label->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ label->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
+ label->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END);
label->set_begin(Point2(margin, margin));
label->set_end(Point2(-margin, -button_margin - 10));
add_child(label);
@@ -606,10 +332,11 @@ AcceptDialog::AcceptDialog() {
hbc->add_spacer();
ok->connect("pressed", callable_mp(this, &AcceptDialog::_ok_pressed));
- set_as_toplevel(true);
hide_on_ok = true;
set_title(RTR("Alert!"));
+
+ connect("window_input", callable_mp(this, &AcceptDialog::_input_from_window));
}
AcceptDialog::~AcceptDialog() {
@@ -631,7 +358,7 @@ ConfirmationDialog::ConfirmationDialog() {
set_title(RTR("Please Confirm..."));
#ifdef TOOLS_ENABLED
- set_custom_minimum_size(Size2(200, 70) * EDSCALE);
+ set_min_size(Size2(200, 70) * EDSCALE);
#endif
cancel = add_cancel();
}
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index c474f7849d..b68b4297d7 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -37,91 +37,32 @@
#include "scene/gui/panel.h"
#include "scene/gui/popup.h"
#include "scene/gui/texture_button.h"
-
-class WindowDialog : public Popup {
-
- GDCLASS(WindowDialog, Popup);
-
- enum DRAG_TYPE {
- DRAG_NONE = 0,
- DRAG_MOVE = 1,
- DRAG_RESIZE_TOP = 1 << 1,
- DRAG_RESIZE_RIGHT = 1 << 2,
- DRAG_RESIZE_BOTTOM = 1 << 3,
- DRAG_RESIZE_LEFT = 1 << 4
- };
-
- TextureButton *close_button;
- String title;
- String xl_title;
- int drag_type;
- Point2 drag_offset;
- Point2 drag_offset_far;
- bool resizable;
-
-#ifdef TOOLS_ENABLED
- bool was_editor_dimmed;
-#endif
-
- void _gui_input(const Ref<InputEvent> &p_event);
- int _drag_hit_test(const Point2 &pos) const;
-
-protected:
- virtual void _post_popup();
- virtual void _fix_size();
- virtual void _close_pressed() {}
- virtual bool has_point(const Point2 &p_point) const;
- void _notification(int p_what);
- static void _bind_methods();
-
- // Not private since used by derived classes signal.
- void _closed();
-
-public:
- TextureButton *get_close_button();
-
- void set_title(const String &p_title);
- String get_title() const;
- void set_resizable(bool p_resizable);
- bool get_resizable() const;
-
- Size2 get_minimum_size() const;
-
- WindowDialog();
- ~WindowDialog();
-};
-
-class PopupDialog : public Popup {
-
- GDCLASS(PopupDialog, Popup);
-
-protected:
- void _notification(int p_what);
-
-public:
- PopupDialog();
- ~PopupDialog();
-};
+#include "scene/main/window.h"
class LineEdit;
-class AcceptDialog : public WindowDialog {
+class AcceptDialog : public Window {
- GDCLASS(AcceptDialog, WindowDialog);
+ GDCLASS(AcceptDialog, Window);
+ Window *parent_visible;
+ Panel *bg;
HBoxContainer *hbc;
Label *label;
Button *ok;
bool hide_on_ok;
void _custom_action(const String &p_action);
- void _close_pressed();
void _update_child_rects();
static bool swap_ok_cancel;
+ void _input_from_window(const Ref<InputEvent> &p_event);
+ void _parent_focused();
+
protected:
- virtual void _post_popup();
+ virtual Size2 _get_contents_minimum_size() const;
+
void _notification(int p_what);
static void _bind_methods();
virtual void ok_pressed() {}
@@ -131,11 +72,9 @@ protected:
// Not private since used by derived classes signal.
void _text_entered(const String &p_text);
void _ok_pressed();
- void _on_close_pressed();
+ void _cancel_pressed();
public:
- Size2 get_minimum_size() const;
-
Label *get_label() { return label; }
static void set_swap_ok_cancel(bool p_swap);
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 3be77ff4b3..a4f0338f00 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -44,42 +44,46 @@ VBoxContainer *FileDialog::get_vbox() {
return vbox;
}
-void FileDialog::_notification(int p_what) {
+void FileDialog::_theme_changed() {
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
+ Color font_color = vbc->get_theme_color("font_color", "ToolButton");
+ Color font_color_hover = vbc->get_theme_color("font_color_hover", "ToolButton");
+ Color font_color_pressed = vbc->get_theme_color("font_color_pressed", "ToolButton");
- if (p_what == NOTIFICATION_ENTER_TREE) {
- dir_up->set_icon(get_icon("parent_folder"));
- refresh->set_icon(get_icon("reload"));
- show_hidden->set_icon(get_icon("toggle_hidden"));
- }
+ dir_up->add_theme_color_override("icon_color_normal", font_color);
+ dir_up->add_theme_color_override("icon_color_hover", font_color_hover);
+ dir_up->add_theme_color_override("icon_color_pressed", font_color_pressed);
- Color font_color = get_color("font_color", "ToolButton");
- Color font_color_hover = get_color("font_color_hover", "ToolButton");
- Color font_color_pressed = get_color("font_color_pressed", "ToolButton");
+ refresh->add_theme_color_override("icon_color_normal", font_color);
+ refresh->add_theme_color_override("icon_color_hover", font_color_hover);
+ refresh->add_theme_color_override("icon_color_pressed", font_color_pressed);
- dir_up->add_color_override("icon_color_normal", font_color);
- dir_up->add_color_override("icon_color_hover", font_color_hover);
- dir_up->add_color_override("icon_color_pressed", font_color_pressed);
+ show_hidden->add_theme_color_override("icon_color_normal", font_color);
+ show_hidden->add_theme_color_override("icon_color_hover", font_color_hover);
+ show_hidden->add_theme_color_override("icon_color_pressed", font_color_pressed);
+}
- refresh->add_color_override("icon_color_normal", font_color);
- refresh->add_color_override("icon_color_hover", font_color_hover);
- refresh->add_color_override("icon_color_pressed", font_color_pressed);
+void FileDialog::_notification(int p_what) {
- show_hidden->add_color_override("icon_color_normal", font_color);
- show_hidden->add_color_override("icon_color_hover", font_color_hover);
- show_hidden->add_color_override("icon_color_pressed", font_color_pressed);
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ if (!is_visible()) {
- } else if (p_what == NOTIFICATION_POPUP_HIDE) {
+ set_process_unhandled_input(false);
+ }
+ }
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- set_process_unhandled_input(false);
+ dir_up->set_icon(vbc->get_theme_icon("parent_folder"));
+ refresh->set_icon(vbc->get_theme_icon("reload"));
+ show_hidden->set_icon(vbc->get_theme_icon("toggle_hidden"));
+ _theme_changed();
}
}
void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
- if (k.is_valid() && is_window_modal_on_top()) {
+ if (k.is_valid() && has_focus()) {
if (k->is_pressed()) {
@@ -110,7 +114,7 @@ void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
}
if (handled)
- accept_event();
+ set_input_as_handled();
}
}
}
@@ -171,7 +175,7 @@ void FileDialog::_post_popup() {
update_file_list();
invalidated = false;
}
- if (mode == MODE_SAVE_FILE)
+ if (mode == FILE_MODE_SAVE_FILE)
file->grab_focus();
else
tree->grab_focus();
@@ -179,7 +183,7 @@ void FileDialog::_post_popup() {
set_process_unhandled_input(true);
// For open dir mode, deselect all items on file dialog open.
- if (mode == MODE_OPEN_DIR) {
+ if (mode == FILE_MODE_OPEN_DIR) {
deselect_items();
file_box->set_visible(false);
} else {
@@ -189,7 +193,7 @@ void FileDialog::_post_popup() {
void FileDialog::_action_pressed() {
- if (mode == MODE_OPEN_FILES) {
+ if (mode == FILE_MODE_OPEN_FILES) {
TreeItem *ti = tree->get_next_selected(NULL);
String fbase = dir_access->get_current_dir();
@@ -211,10 +215,10 @@ void FileDialog::_action_pressed() {
String f = dir_access->get_current_dir().plus_file(file->get_text());
- if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
+ if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) {
emit_signal("file_selected", f);
hide();
- } else if (mode == MODE_OPEN_ANY || mode == MODE_OPEN_DIR) {
+ } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) {
String path = dir_access->get_current_dir();
@@ -231,7 +235,7 @@ void FileDialog::_action_pressed() {
hide();
}
- if (mode == MODE_SAVE_FILE) {
+ if (mode == FILE_MODE_SAVE_FILE) {
bool valid = false;
@@ -283,7 +287,7 @@ void FileDialog::_action_pressed() {
if (!valid) {
- exterr->popup_centered_minsize(Size2(250, 80));
+ exterr->popup_centered(Size2(250, 80));
return;
}
@@ -307,7 +311,7 @@ void FileDialog::_cancel_pressed() {
bool FileDialog::_is_open_should_be_disabled() {
- if (mode == MODE_OPEN_ANY || mode == MODE_SAVE_FILE)
+ if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE)
return false;
TreeItem *ti = tree->get_next_selected(tree->get_root());
@@ -319,13 +323,13 @@ bool FileDialog::_is_open_should_be_disabled() {
}
// We have something that we can't select?
if (!ti)
- return mode != MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder.
+ return mode != FILE_MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder.
Dictionary d = ti->get_metadata(0);
// Opening a file, but selected a folder? Forbidden.
- return ((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden.
- (mode == MODE_OPEN_DIR && !d["dir"]);
+ return ((mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden.
+ (mode == FILE_MODE_OPEN_DIR && !d["dir"]);
}
void FileDialog::_go_up() {
@@ -346,15 +350,15 @@ void FileDialog::deselect_items() {
switch (mode) {
- case MODE_OPEN_FILE:
- case MODE_OPEN_FILES:
+ case FILE_MODE_OPEN_FILE:
+ case FILE_MODE_OPEN_FILES:
get_ok()->set_text(RTR("Open"));
break;
- case MODE_OPEN_DIR:
+ case FILE_MODE_OPEN_DIR:
get_ok()->set_text(RTR("Select Current Folder"));
break;
- case MODE_OPEN_ANY:
- case MODE_SAVE_FILE:
+ case FILE_MODE_OPEN_ANY:
+ case FILE_MODE_SAVE_FILE:
// FIXME: Implement, or refactor to avoid duplication with set_mode
break;
}
@@ -375,7 +379,7 @@ void FileDialog::_tree_selected() {
if (!d["dir"]) {
file->set_text(d["name"]);
- } else if (mode == MODE_OPEN_DIR) {
+ } else if (mode == FILE_MODE_OPEN_DIR) {
get_ok()->set_text(RTR("Select This Folder"));
}
@@ -393,7 +397,7 @@ void FileDialog::_tree_item_activated() {
if (d["dir"]) {
dir_access->change_dir(d["name"]);
- if (mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES || mode == MODE_OPEN_DIR || mode == MODE_OPEN_ANY)
+ if (mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES || mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY)
file->set_text("");
call_deferred("_update_file_list");
call_deferred("_update_dir");
@@ -425,8 +429,8 @@ void FileDialog::update_file_list() {
dir_access->list_dir_begin();
TreeItem *root = tree->create_item();
- Ref<Texture2D> folder = get_icon("folder");
- const Color folder_color = get_color("folder_icon_modulate");
+ Ref<Texture2D> folder = vbc->get_theme_icon("folder");
+ const Color folder_color = vbc->get_theme_color("folder_icon_modulate");
List<String> files;
List<String> dirs;
@@ -523,8 +527,8 @@ void FileDialog::update_file_list() {
ti->set_icon(0, icon);
}
- if (mode == MODE_OPEN_DIR) {
- ti->set_custom_color(0, get_color("files_disabled"));
+ if (mode == FILE_MODE_OPEN_DIR) {
+ ti->set_custom_color(0, vbc->get_theme_color("files_disabled"));
ti->set_selectable(0, false);
}
Dictionary d;
@@ -661,38 +665,38 @@ bool FileDialog::is_mode_overriding_title() const {
return mode_overrides_title;
}
-void FileDialog::set_mode(Mode p_mode) {
+void FileDialog::set_file_mode(FileMode p_mode) {
ERR_FAIL_INDEX((int)p_mode, 5);
mode = p_mode;
switch (mode) {
- case MODE_OPEN_FILE:
+ case FILE_MODE_OPEN_FILE:
get_ok()->set_text(RTR("Open"));
if (mode_overrides_title)
set_title(RTR("Open a File"));
makedir->hide();
break;
- case MODE_OPEN_FILES:
+ case FILE_MODE_OPEN_FILES:
get_ok()->set_text(RTR("Open"));
if (mode_overrides_title)
set_title(RTR("Open File(s)"));
makedir->hide();
break;
- case MODE_OPEN_DIR:
+ case FILE_MODE_OPEN_DIR:
get_ok()->set_text(RTR("Select Current Folder"));
if (mode_overrides_title)
set_title(RTR("Open a Directory"));
makedir->show();
break;
- case MODE_OPEN_ANY:
+ case FILE_MODE_OPEN_ANY:
get_ok()->set_text(RTR("Open"));
if (mode_overrides_title)
set_title(RTR("Open a File or Directory"));
makedir->show();
break;
- case MODE_SAVE_FILE:
+ case FILE_MODE_SAVE_FILE:
get_ok()->set_text(RTR("Save"));
if (mode_overrides_title)
set_title(RTR("Save a File"));
@@ -700,14 +704,14 @@ void FileDialog::set_mode(Mode p_mode) {
break;
}
- if (mode == MODE_OPEN_FILES) {
+ if (mode == FILE_MODE_OPEN_FILES) {
tree->set_select_mode(Tree::SELECT_MULTI);
} else {
tree->set_select_mode(Tree::SELECT_SINGLE);
}
}
-FileDialog::Mode FileDialog::get_mode() const {
+FileDialog::FileMode FileDialog::get_file_mode() const {
return mode;
}
@@ -741,7 +745,7 @@ void FileDialog::set_access(Access p_access) {
void FileDialog::invalidate() {
- if (is_visible_in_tree()) {
+ if (is_visible()) {
update_file_list();
invalidated = false;
} else {
@@ -763,14 +767,14 @@ void FileDialog::_make_dir_confirm() {
update_filters();
update_dir();
} else {
- mkdirerr->popup_centered_minsize(Size2(250, 50));
+ mkdirerr->popup_centered(Size2(250, 50));
}
makedirname->set_text(""); // reset label
}
void FileDialog::_make_dir() {
- makedialog->popup_centered_minsize(Size2(250, 80));
+ makedialog->popup_centered(Size2(250, 80));
makedirname->grab_focus();
}
@@ -826,8 +830,8 @@ void FileDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_current_path", "path"), &FileDialog::set_current_path);
ClassDB::bind_method(D_METHOD("set_mode_overrides_title", "override"), &FileDialog::set_mode_overrides_title);
ClassDB::bind_method(D_METHOD("is_mode_overriding_title"), &FileDialog::is_mode_overriding_title);
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &FileDialog::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &FileDialog::get_mode);
+ ClassDB::bind_method(D_METHOD("set_file_mode", "mode"), &FileDialog::set_file_mode);
+ ClassDB::bind_method(D_METHOD("get_file_mode"), &FileDialog::get_file_mode);
ClassDB::bind_method(D_METHOD("get_vbox"), &FileDialog::get_vbox);
ClassDB::bind_method(D_METHOD("get_line_edit"), &FileDialog::get_line_edit);
ClassDB::bind_method(D_METHOD("set_access", "access"), &FileDialog::set_access);
@@ -842,7 +846,7 @@ void FileDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("invalidate"), &FileDialog::invalidate);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "mode_overrides_title"), "set_mode_overrides_title", "is_mode_overriding_title");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open File,Open Files,Open Folder,Open Any,Save"), "set_mode", "get_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "file_mode", PROPERTY_HINT_ENUM, "Open File,Open Files,Open Folder,Open Any,Save"), "set_file_mode", "get_file_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access");
ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "filters"), "set_filters", "get_filters");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), "set_show_hidden_files", "is_showing_hidden_files");
@@ -854,11 +858,11 @@ void FileDialog::_bind_methods() {
ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::PACKED_STRING_ARRAY, "paths")));
ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
- BIND_ENUM_CONSTANT(MODE_OPEN_FILE);
- BIND_ENUM_CONSTANT(MODE_OPEN_FILES);
- BIND_ENUM_CONSTANT(MODE_OPEN_DIR);
- BIND_ENUM_CONSTANT(MODE_OPEN_ANY);
- BIND_ENUM_CONSTANT(MODE_SAVE_FILE);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_FILE);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_FILES);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_DIR);
+ BIND_ENUM_CONSTANT(FILE_MODE_OPEN_ANY);
+ BIND_ENUM_CONSTANT(FILE_MODE_SAVE_FILE);
BIND_ENUM_CONSTANT(ACCESS_RESOURCES);
BIND_ENUM_CONSTANT(ACCESS_USERDATA);
@@ -884,10 +888,11 @@ FileDialog::FileDialog() {
mode_overrides_title = true;
- VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc = memnew(VBoxContainer);
add_child(vbc);
+ vbc->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed));
- mode = MODE_SAVE_FILE;
+ mode = FILE_MODE_SAVE_FILE;
set_title(RTR("Save a File"));
HBoxContainer *hbc = memnew(HBoxContainer);
@@ -907,7 +912,7 @@ FileDialog::FileDialog() {
dir = memnew(LineEdit);
hbc->add_child(dir);
- dir->set_h_size_flags(SIZE_EXPAND_FILL);
+ dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
refresh = memnew(ToolButton);
refresh->set_tooltip(RTR("Refresh files."));
@@ -938,11 +943,11 @@ FileDialog::FileDialog() {
file_box->add_child(memnew(Label(RTR("File:"))));
file = memnew(LineEdit);
file->set_stretch_ratio(4);
- file->set_h_size_flags(SIZE_EXPAND_FILL);
+ file->set_h_size_flags(Control::SIZE_EXPAND_FILL);
file_box->add_child(file);
filter = memnew(OptionButton);
filter->set_stretch_ratio(3);
- filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_clip_text(true); // too many extensions overflows it
file_box->add_child(filter);
vbc->add_child(file_box);
@@ -961,7 +966,7 @@ FileDialog::FileDialog() {
filter->connect("item_selected", callable_mp(this, &FileDialog::_filter_selected));
confirm_save = memnew(ConfirmationDialog);
- confirm_save->set_as_toplevel(true);
+ // confirm_save->set_as_toplevel(true);
add_child(confirm_save);
confirm_save->connect("confirmed", callable_mp(this, &FileDialog::_save_confirm_pressed));
@@ -1024,7 +1029,7 @@ LineEditFileChooser::LineEditFileChooser() {
line_edit = memnew(LineEdit);
add_child(line_edit);
- line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
+ line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
button = memnew(Button);
button->set_text(" .. ");
add_child(button);
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index a7dc101d12..295ae023d1 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -50,12 +50,12 @@ public:
ACCESS_FILESYSTEM
};
- enum Mode {
- MODE_OPEN_FILE,
- MODE_OPEN_FILES,
- MODE_OPEN_DIR,
- MODE_OPEN_ANY,
- MODE_SAVE_FILE
+ enum FileMode {
+ FILE_MODE_OPEN_FILE,
+ FILE_MODE_OPEN_FILES,
+ FILE_MODE_OPEN_DIR,
+ FILE_MODE_OPEN_ANY,
+ FILE_MODE_SAVE_FILE
};
typedef Ref<Texture2D> (*GetIconFunc)(const String &);
@@ -70,11 +70,12 @@ private:
ConfirmationDialog *makedialog;
LineEdit *makedirname;
+ VBoxContainer *vbc;
Button *makedir;
Access access;
//Button *action;
VBoxContainer *vbox;
- Mode mode;
+ FileMode mode;
LineEdit *dir;
HBoxContainer *drives_container;
HBoxContainer *shortcuts_container;
@@ -131,6 +132,8 @@ private:
virtual void _post_popup();
protected:
+ void _theme_changed();
+
void _notification(int p_what);
static void _bind_methods();
//bind helpers
@@ -153,8 +156,8 @@ public:
void set_mode_overrides_title(bool p_override);
bool is_mode_overriding_title() const;
- void set_mode(Mode p_mode);
- Mode get_mode() const;
+ void set_file_mode(FileMode p_mode);
+ FileMode get_file_mode() const;
VBoxContainer *get_vbox();
LineEdit *get_line_edit() { return file; }
@@ -196,7 +199,7 @@ public:
LineEditFileChooser();
};
-VARIANT_ENUM_CAST(FileDialog::Mode);
+VARIANT_ENUM_CAST(FileDialog::FileMode);
VARIANT_ENUM_CAST(FileDialog::Access);
#endif
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 6345bfe562..88107f754c 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -76,15 +76,15 @@ void GradientEdit::_show_color_picker() {
if (grabbed == -1)
return;
picker->set_pick_color(points[grabbed].color);
- Size2 minsize = popup->get_combined_minimum_size();
+ Size2 minsize = popup->get_contents_minimum_size();
bool show_above = false;
if (get_global_position().y + get_size().y + minsize.y > get_viewport_rect().size.y) {
show_above = true;
}
if (show_above) {
- popup->set_position(get_global_position() - Vector2(0, minsize.y));
+ popup->set_position(get_screen_position() - Vector2(0, minsize.y));
} else {
- popup->set_position(get_global_position() + Vector2(0, get_size().y));
+ popup->set_position(get_screen_position() + Vector2(0, get_size().y));
}
popup->popup();
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 4bc33b220e..fd7935b376 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -30,7 +30,7 @@
#include "graph_edit.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "scene/gui/box_container.h"
@@ -281,13 +281,13 @@ void GraphEdit::remove_child_notify(Node *p_child) {
void GraphEdit::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- port_grab_distance_horizontal = get_constant("port_grab_distance_horizontal");
- port_grab_distance_vertical = get_constant("port_grab_distance_vertical");
+ port_grab_distance_horizontal = get_theme_constant("port_grab_distance_horizontal");
+ port_grab_distance_vertical = get_theme_constant("port_grab_distance_vertical");
- zoom_minus->set_icon(get_icon("minus"));
- zoom_reset->set_icon(get_icon("reset"));
- zoom_plus->set_icon(get_icon("more"));
- snap_button->set_icon(get_icon("snap"));
+ zoom_minus->set_icon(get_theme_icon("minus"));
+ zoom_reset->set_icon(get_theme_icon("reset"));
+ zoom_plus->set_icon(get_theme_icon("more"));
+ snap_button->set_icon(get_theme_icon("snap"));
}
if (p_what == NOTIFICATION_READY) {
Size2 hmin = h_scroll->get_combined_minimum_size();
@@ -305,7 +305,7 @@ void GraphEdit::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
- draw_style_box(get_stylebox("bg"), Rect2(Point2(), get_size()));
+ draw_style_box(get_theme_stylebox("bg"), Rect2(Point2(), get_size()));
if (is_using_snap()) {
//draw grid
@@ -318,8 +318,8 @@ void GraphEdit::_notification(int p_what) {
Point2i from = (offset / float(snap)).floor();
Point2i len = (size / float(snap)).floor() + Vector2(1, 1);
- Color grid_minor = get_color("grid_minor");
- Color grid_major = get_color("grid_major");
+ Color grid_minor = get_theme_color("grid_minor");
+ Color grid_major = get_theme_color("grid_major");
for (int i = from.x; i < from.x + len.x; i++) {
@@ -357,7 +357,7 @@ void GraphEdit::_notification(int p_what) {
bool GraphEdit::_filter_input(const Point2 &p_point) {
- Ref<Texture2D> port = get_icon("port", "GraphNode");
+ Ref<Texture2D> port = get_theme_icon("port", "GraphNode");
for (int i = get_child_count() - 1; i >= 0; i--) {
@@ -389,7 +389,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseButton> mb = p_ev;
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
- Ref<Texture2D> port = get_icon("port", "GraphNode");
+ Ref<Texture2D> port = get_theme_icon("port", "GraphNode");
Vector2 mpos(mb->get_position().x, mb->get_position().y);
for (int i = get_child_count() - 1; i >= 0; i--) {
@@ -501,7 +501,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_target = false;
top_layer->update();
- Ref<Texture2D> port = get_icon("port", "GraphNode");
+ Ref<Texture2D> port = get_theme_icon("port", "GraphNode");
Vector2 mpos = mm->get_position();
for (int i = get_child_count() - 1; i >= 0; i--) {
@@ -666,8 +666,8 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
//cubic bezier code
float diff = p_to.x - p_from.x;
float cp_offset;
- int cp_len = get_constant("bezier_len_pos");
- int cp_neg_len = get_constant("bezier_len_neg");
+ int cp_len = get_theme_constant("bezier_len_pos");
+ int cp_neg_len = get_theme_constant("bezier_len_neg");
if (diff > 0) {
cp_offset = MIN(cp_len, diff * 0.5);
@@ -697,7 +697,7 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
void GraphEdit::_connections_layer_draw() {
- Color activity_color = get_color("activity");
+ Color activity_color = get_theme_color("activity");
//draw connections
List<List<Connection>::Element *> to_erase;
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
@@ -784,8 +784,8 @@ void GraphEdit::_top_layer_draw() {
}
if (box_selecting) {
- top_layer->draw_rect(box_selecting_rect, get_color("selection_fill"));
- top_layer->draw_rect(box_selecting_rect, get_color("selection_stroke"), false);
+ top_layer->draw_rect(box_selecting_rect, get_theme_color("selection_fill"));
+ top_layer->draw_rect(box_selecting_rect, get_theme_color("selection_stroke"), false);
}
}
@@ -804,7 +804,7 @@ void GraphEdit::set_selected(Node *p_child) {
void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
- if (mm.is_valid() && (mm->get_button_mask() & BUTTON_MASK_MIDDLE || (mm->get_button_mask() & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
+ if (mm.is_valid() && (mm->get_button_mask() & BUTTON_MASK_MIDDLE || (mm->get_button_mask() & BUTTON_MASK_LEFT && InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)))) {
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
}
@@ -823,7 +823,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
// Snapping can be toggled temporarily by holding down Ctrl.
// This is done here as to not toggle the grid when holding down Ctrl.
- if (is_using_snap() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (is_using_snap() ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
const int snap = get_snap();
pos = pos.snapped(Vector2(snap, snap));
}
@@ -886,7 +886,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (b->get_button_index() == BUTTON_LEFT && !b->is_pressed() && dragging) {
- if (!just_selected && drag_accum == Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (!just_selected && drag_accum == Vector2() && InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
//deselect current node
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
@@ -948,7 +948,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
drag_accum = Vector2();
drag_origin = get_local_mouse_position();
just_selected = !gn->is_selected();
- if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (!gn->is_selected() && !InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i));
if (o_gn)
@@ -968,7 +968,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
} else {
if (_filter_input(b->get_position()))
return;
- if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_SPACE))
return;
box_selecting = true;
@@ -1025,16 +1025,16 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
//too difficult to get right
//set_zoom(zoom/ZOOM_SCALE);
}
- if (b->get_button_index() == BUTTON_WHEEL_UP && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (b->get_button_index() == BUTTON_WHEEL_UP && !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8);
}
- if (b->get_button_index() == BUTTON_WHEEL_DOWN && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (b->get_button_index() == BUTTON_WHEEL_DOWN && !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) {
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b->get_factor() / 8);
}
- if (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_button_index() == BUTTON_WHEEL_DOWN && Input::get_singleton()->is_key_pressed(KEY_SHIFT))) {
+ if (b->get_button_index() == BUTTON_WHEEL_RIGHT || (b->get_button_index() == BUTTON_WHEEL_DOWN && InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT))) {
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * b->get_factor() / 8);
}
- if (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_button_index() == BUTTON_WHEEL_UP && Input::get_singleton()->is_key_pressed(KEY_SHIFT))) {
+ if (b->get_button_index() == BUTTON_WHEEL_LEFT || (b->get_button_index() == BUTTON_WHEEL_UP && InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT))) {
h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * b->get_factor() / 8);
}
}
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 82e890395a..c28a60ff87 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -117,8 +117,8 @@ void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
void GraphNode::_resort() {
- int sep = get_constant("separation");
- Ref<StyleBox> sb = get_stylebox("frame");
+ int sep = get_theme_constant("separation");
+ Ref<StyleBox> sb = get_theme_stylebox("frame");
bool first = true;
Size2 minsize;
@@ -169,8 +169,8 @@ void GraphNode::_resort() {
bool GraphNode::has_point(const Point2 &p_point) const {
if (comment) {
- Ref<StyleBox> comment = get_stylebox("comment");
- Ref<Texture2D> resizer = get_icon("resizer");
+ Ref<StyleBox> comment = get_theme_stylebox("comment");
+ Ref<Texture2D> resizer = get_theme_icon("resizer");
if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
return true;
@@ -195,28 +195,28 @@ void GraphNode::_notification(int p_what) {
Ref<StyleBox> sb;
if (comment) {
- sb = get_stylebox(selected ? "commentfocus" : "comment");
+ sb = get_theme_stylebox(selected ? "commentfocus" : "comment");
} else {
- sb = get_stylebox(selected ? "selectedframe" : "frame");
+ sb = get_theme_stylebox(selected ? "selectedframe" : "frame");
}
//sb=sb->duplicate();
//sb->call("set_modulate",modulate);
- Ref<Texture2D> port = get_icon("port");
- Ref<Texture2D> close = get_icon("close");
- Ref<Texture2D> resizer = get_icon("resizer");
- int close_offset = get_constant("close_offset");
- int close_h_offset = get_constant("close_h_offset");
- Color close_color = get_color("close_color");
- Color resizer_color = get_color("resizer_color");
- Ref<Font> title_font = get_font("title_font");
- int title_offset = get_constant("title_offset");
- int title_h_offset = get_constant("title_h_offset");
- Color title_color = get_color("title_color");
+ Ref<Texture2D> port = get_theme_icon("port");
+ Ref<Texture2D> close = get_theme_icon("close");
+ Ref<Texture2D> resizer = get_theme_icon("resizer");
+ int close_offset = get_theme_constant("close_offset");
+ int close_h_offset = get_theme_constant("close_h_offset");
+ Color close_color = get_theme_color("close_color");
+ Color resizer_color = get_theme_color("resizer_color");
+ Ref<Font> title_font = get_theme_font("title_font");
+ int title_offset = get_theme_constant("title_offset");
+ int title_h_offset = get_theme_constant("title_h_offset");
+ Color title_color = get_theme_color("title_color");
Point2i icofs = -port->get_size() * 0.5;
- int edgeofs = get_constant("port_offset");
+ int edgeofs = get_theme_constant("port_offset");
icofs.y += sb->get_margin(MARGIN_TOP);
draw_style_box(sb, Rect2(Point2(), get_size()));
@@ -227,10 +227,10 @@ void GraphNode::_notification(int p_what) {
} break;
case OVERLAY_BREAKPOINT: {
- draw_style_box(get_stylebox("breakpoint"), Rect2(Point2(), get_size()));
+ draw_style_box(get_theme_stylebox("breakpoint"), Rect2(Point2(), get_size()));
} break;
case OVERLAY_POSITION: {
- draw_style_box(get_stylebox("position"), Rect2(Point2(), get_size()));
+ draw_style_box(get_theme_stylebox("position"), Rect2(Point2(), get_size()));
} break;
}
@@ -370,16 +370,16 @@ Color GraphNode::get_slot_color_right(int p_idx) const {
Size2 GraphNode::get_minimum_size() const {
- Ref<Font> title_font = get_font("title_font");
+ Ref<Font> title_font = get_theme_font("title_font");
- int sep = get_constant("separation");
- Ref<StyleBox> sb = get_stylebox("frame");
+ int sep = get_theme_constant("separation");
+ Ref<StyleBox> sb = get_theme_stylebox("frame");
bool first = true;
Size2 minsize;
minsize.x = title_font->get_string_size(title).x;
if (show_close) {
- Ref<Texture2D> close = get_icon("close");
+ Ref<Texture2D> close = get_theme_icon("close");
minsize.x += sep + close->get_width();
}
@@ -464,10 +464,10 @@ bool GraphNode::is_close_button_visible() const {
void GraphNode::_connpos_update() {
- int edgeofs = get_constant("port_offset");
- int sep = get_constant("separation");
+ int edgeofs = get_theme_constant("port_offset");
+ int sep = get_theme_constant("separation");
- Ref<StyleBox> sb = get_stylebox("frame");
+ Ref<StyleBox> sb = get_theme_stylebox("frame");
conn_input_cache.clear();
conn_output_cache.clear();
int vofs = 0;
@@ -606,7 +606,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
return;
}
- Ref<Texture2D> resizer = get_icon("resizer");
+ Ref<Texture2D> resizer = get_theme_icon("resizer");
if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 0028093a95..16f6fd0111 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -41,8 +41,8 @@ void GridContainer::_notification(int p_what) {
Set<int> col_expanded; // Columns which have the SIZE_EXPAND flag set.
Set<int> row_expanded; // Rows which have the SIZE_EXPAND flag set.
- int hsep = get_constant("hseparation");
- int vsep = get_constant("vseparation");
+ int hsep = get_theme_constant("hseparation");
+ int vsep = get_theme_constant("vseparation");
int max_col = MIN(get_child_count(), columns);
int max_row = ceil((float)get_child_count() / (float)columns);
@@ -200,8 +200,8 @@ Size2 GridContainer::get_minimum_size() const {
Map<int, int> col_minw;
Map<int, int> row_minh;
- int hsep = get_constant("hseparation");
- int vsep = get_constant("vseparation");
+ int hsep = get_theme_constant("hseparation");
+ int vsep = get_theme_constant("vseparation");
int max_row = 0;
int max_col = 0;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 5e662b8df0..47a5ac68d2 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -495,7 +495,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
search_string = ""; //any mousepress cancels
Vector2 pos = mb->get_position();
- Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<StyleBox> bg = get_theme_stylebox("bg");
pos -= bg->get_offset();
pos.y += scroll_bar->get_value();
@@ -820,7 +820,7 @@ void ItemList::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<StyleBox> bg = get_theme_stylebox("bg");
int mw = scroll_bar->get_minimum_size().x;
scroll_bar->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -mw);
@@ -837,18 +837,18 @@ void ItemList::_notification(int p_what) {
draw_style_box(bg, Rect2(Point2(), size));
- int hseparation = get_constant("hseparation");
- int vseparation = get_constant("vseparation");
- int icon_margin = get_constant("icon_margin");
- int line_separation = get_constant("line_separation");
+ int hseparation = get_theme_constant("hseparation");
+ int vseparation = get_theme_constant("vseparation");
+ int icon_margin = get_theme_constant("icon_margin");
+ int line_separation = get_theme_constant("line_separation");
- Ref<StyleBox> sbsel = has_focus() ? get_stylebox("selected_focus") : get_stylebox("selected");
- Ref<StyleBox> cursor = has_focus() ? get_stylebox("cursor") : get_stylebox("cursor_unfocused");
+ Ref<StyleBox> sbsel = has_focus() ? get_theme_stylebox("selected_focus") : get_theme_stylebox("selected");
+ Ref<StyleBox> cursor = has_focus() ? get_theme_stylebox("cursor") : get_theme_stylebox("cursor_unfocused");
- Ref<Font> font = get_font("font");
- Color guide_color = get_color("guide_color");
- Color font_color = get_color("font_color");
- Color font_color_selected = get_color("font_color_selected");
+ Ref<Font> font = get_theme_font("font");
+ Color guide_color = get_theme_color("guide_color");
+ Color font_color = get_theme_color("font_color");
+ Color font_color_selected = get_theme_color("font_color_selected");
int font_height = font->get_height();
Vector<int> line_size_cache;
Vector<int> line_limit_cache;
@@ -859,9 +859,9 @@ void ItemList::_notification(int p_what) {
}
if (has_focus()) {
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true);
- draw_style_box(get_stylebox("bg_focus"), Rect2(Point2(), size));
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false);
+ RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true);
+ draw_style_box(get_theme_stylebox("bg_focus"), Rect2(Point2(), size));
+ RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false);
}
if (shape_changed) {
@@ -1251,7 +1251,7 @@ void ItemList::_scroll_changed(double) {
int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const {
Vector2 pos = p_pos;
- Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<StyleBox> bg = get_theme_stylebox("bg");
pos -= bg->get_offset();
pos.y += scroll_bar->get_value();
@@ -1286,7 +1286,7 @@ bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const {
return true;
Vector2 pos = p_pos;
- Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<StyleBox> bg = get_theme_stylebox("bg");
pos -= bg->get_offset();
pos.y += scroll_bar->get_value();
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index c900b35d65..1ffc9712cc 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -65,7 +65,7 @@ bool Label::is_uppercase() const {
int Label::get_line_height() const {
- return get_font("font")->get_height();
+ return get_theme_font("font")->get_height();
}
void Label::_notification(int p_what) {
@@ -84,7 +84,7 @@ void Label::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
if (clip) {
- VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
+ RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
}
if (word_cache_dirty)
@@ -94,18 +94,18 @@ void Label::_notification(int p_what) {
Size2 string_size;
Size2 size = get_size();
- Ref<StyleBox> style = get_stylebox("normal");
- Ref<Font> font = get_font("font");
- Color font_color = get_color("font_color");
- Color font_color_shadow = get_color("font_color_shadow");
- 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");
- Color font_outline_modulate = get_color("font_outline_modulate");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
+ Ref<Font> font = get_theme_font("font");
+ Color font_color = get_theme_color("font_color");
+ Color font_color_shadow = get_theme_color("font_color_shadow");
+ bool use_outline = get_theme_constant("shadow_as_outline");
+ Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y"));
+ int line_spacing = get_theme_constant("line_spacing");
+ Color font_outline_modulate = get_theme_color("font_outline_modulate");
style->draw(ci, Rect2(Point2(0, 0), get_size()));
- VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(), font.is_valid() && font->is_distance_field_hint());
+ RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(), font.is_valid() && font->is_distance_field_hint());
int font_h = font->get_height() + line_spacing;
@@ -300,7 +300,7 @@ void Label::_notification(int p_what) {
Size2 Label::get_minimum_size() const {
- Size2 min_style = get_stylebox("normal")->get_minimum_size();
+ Size2 min_style = get_theme_stylebox("normal")->get_minimum_size();
// don't want to mutable everything
if (word_cache_dirty) {
@@ -319,7 +319,7 @@ Size2 Label::get_minimum_size() const {
int Label::get_longest_line_width() const {
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
real_t max_line_width = 0;
real_t line_width = 0;
@@ -363,9 +363,9 @@ int Label::get_line_count() const {
int Label::get_visible_line_count() const {
- int line_spacing = get_constant("line_spacing");
- int font_h = get_font("font")->get_height() + line_spacing;
- int lines_visible = (get_size().height - get_stylebox("normal")->get_minimum_size().height + line_spacing) / font_h;
+ int line_spacing = get_theme_constant("line_spacing");
+ int font_h = get_theme_font("font")->get_height() + line_spacing;
+ int lines_visible = (get_size().height - get_theme_stylebox("normal")->get_minimum_size().height + line_spacing) / font_h;
if (lines_visible > line_count)
lines_visible = line_count;
@@ -387,20 +387,20 @@ void Label::regenerate_word_cache() {
int width;
if (autowrap) {
- Ref<StyleBox> style = get_stylebox("normal");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
width = MAX(get_size().width, get_custom_minimum_size().width) - style->get_minimum_size().width;
} else {
width = get_longest_line_width();
}
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
real_t current_word_size = 0;
int word_pos = 0;
real_t line_width = 0;
int space_count = 0;
real_t space_width = font->get_char_size(' ').width;
- int line_spacing = get_constant("line_spacing");
+ int line_spacing = get_theme_constant("line_spacing");
line_count = 1;
total_char_cache = 0;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 73380c6b1b..6c5f77f874 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -36,12 +36,12 @@
#include "core/print_string.h"
#include "core/translation.h"
#include "label.h"
-
+#include "servers/display_server.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#endif
-
+#include "scene/main/window.h"
static bool _is_text_char(CharType c) {
return !is_symbol(c);
@@ -56,7 +56,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
menu->set_position(get_global_transform().xform(get_local_mouse_position()));
menu->set_size(Vector2(1, 1));
- menu->set_scale(get_global_transform().get_scale());
+ //menu->set_scale(get_global_transform().get_scale());
menu->popup();
grab_focus();
accept_event();
@@ -127,8 +127,8 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
selection.creating = false;
selection.doubleclick = false;
- if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length);
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
}
update();
@@ -304,10 +304,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
case KEY_ENTER: {
emit_signal("text_entered", text);
- if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->hide_virtual_keyboard();
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ DisplayServer::get_singleton()->virtual_keyboard_hide();
- return;
} break;
case KEY_BACKSPACE: {
@@ -553,10 +552,10 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
} break;
case KEY_MENU: {
if (context_menu_enabled) {
- Point2 pos = Point2(get_cursor_pixel_pos(), (get_size().y + get_font("font")->get_height()) / 2);
+ Point2 pos = Point2(get_cursor_pixel_pos(), (get_size().y + get_theme_font("font")->get_height()) / 2);
menu->set_position(get_global_transform().xform(pos));
menu->set_size(Vector2(1, 1));
- menu->set_scale(get_global_transform().get_scale());
+ // menu->set_scale(get_global_transform().get_scale());
menu->popup();
menu->grab_focus();
}
@@ -630,10 +629,10 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
set_cursor_at_pixel_pos(p_point.x);
int selected = selection.end - selection.begin;
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
if (font != NULL) {
for (int i = selection.begin; i < selection.end; i++)
- cached_width -= font->get_char_size(text[i]).width;
+ cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width;
}
text.erase(selection.begin, selected);
@@ -655,8 +654,8 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const {
if (!clear_button_enabled || !has_point(p_pos)) {
return false;
}
- Ref<Texture2D> icon = Control::get_icon("clear");
- int x_ofs = get_stylebox("normal")->get_offset().x;
+ Ref<Texture2D> icon = Control::get_theme_icon("clear");
+ int x_ofs = get_theme_stylebox("normal")->get_offset().x;
return p_pos.x > get_size().width - icon->get_width() - x_ofs;
}
@@ -686,12 +685,12 @@ void LineEdit::_notification(int p_what) {
update_placeholder_width();
update();
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
window_has_focus = true;
draw_caret = true;
update();
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_WM_FOCUS_OUT: {
window_has_focus = false;
draw_caret = false;
update();
@@ -710,19 +709,19 @@ void LineEdit::_notification(int p_what) {
RID ci = get_canvas_item();
- Ref<StyleBox> style = get_stylebox("normal");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
if (!is_editable()) {
- style = get_stylebox("read_only");
+ style = get_theme_stylebox("read_only");
draw_caret = false;
}
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
style->draw(ci, Rect2(Point2(), size));
if (has_focus()) {
- get_stylebox("focus")->draw(ci, Rect2(Point2(), size));
+ get_theme_stylebox("focus")->draw(ci, Rect2(Point2(), size));
}
int x_ofs = 0;
@@ -757,10 +756,10 @@ void LineEdit::_notification(int p_what) {
int font_ascent = font->get_ascent();
- Color selection_color = get_color("selection_color");
- Color font_color = is_editable() ? get_color("font_color") : get_color("font_color_uneditable");
- Color font_color_selected = get_color("font_color_selected");
- Color cursor_color = get_color("cursor_color");
+ Color selection_color = get_theme_color("selection_color");
+ Color font_color = is_editable() ? get_theme_color("font_color") : get_theme_color("font_color_uneditable");
+ Color font_color_selected = get_theme_color("font_color_selected");
+ Color cursor_color = get_theme_color("cursor_color");
const String &t = using_placeholder ? placeholder_translated : text;
// Draw placeholder color.
@@ -769,13 +768,13 @@ void LineEdit::_notification(int p_what) {
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
- Ref<Texture2D> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
+ Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon;
Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9);
if (display_clear_icon) {
if (clear_button_status.press_attempt && clear_button_status.pressing_inside) {
- color_icon = get_color("clear_button_color_pressed");
+ color_icon = get_theme_color("clear_button_color_pressed");
} else {
- color_icon = get_color("clear_button_color");
+ color_icon = get_theme_color("clear_button_color");
}
}
@@ -816,9 +815,9 @@ void LineEdit::_notification(int p_what) {
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color);
}
drawer.draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, font_color);
@@ -840,7 +839,7 @@ 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, caret_height)), selection_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color);
int yofs = y_ofs + (caret_height - font->get_height()) / 2;
drawer.draw_char(ci, Point2(x_ofs, yofs + font_ascent), cchar, next, selected ? font_color_selected : font_color);
@@ -848,9 +847,9 @@ void LineEdit::_notification(int p_what) {
if (char_ofs == cursor_pos && draw_caret && !using_placeholder) {
if (ime_text.length() == 0) {
#ifdef TOOLS_ENABLED
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);
#else
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(1, caret_height)), cursor_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(1, caret_height)), cursor_color);
#endif
}
}
@@ -875,9 +874,9 @@ void LineEdit::_notification(int p_what) {
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color);
}
drawer.draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, font_color);
@@ -906,17 +905,18 @@ void LineEdit::_notification(int p_what) {
}
}
#ifdef TOOLS_ENABLED
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color);
#else
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(1, caret_height)), cursor_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(1, caret_height)), cursor_color);
#endif
}
}
if (has_focus()) {
-
- OS::get_singleton()->set_ime_active(true);
- OS::get_singleton()->set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height));
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + Point2(using_placeholder ? 0 : x_ofs, y_ofs + caret_height), get_viewport()->get_window_id());
+ }
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -927,12 +927,14 @@ void LineEdit::_notification(int p_what) {
draw_caret = true;
}
- OS::get_singleton()->set_ime_active(true);
- Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
- OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ Point2 cursor_pos = Point2(get_cursor_position(), 1) * get_minimum_size().height;
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ }
- if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(text, get_global_rect(), max_length);
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
} break;
case NOTIFICATION_FOCUS_EXIT: {
@@ -941,20 +943,22 @@ void LineEdit::_notification(int p_what) {
caret_blink_timer->stop();
}
- OS::get_singleton()->set_ime_position(Point2());
- OS::get_singleton()->set_ime_active(false);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ }
ime_text = "";
ime_selection = Point2();
- if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->hide_virtual_keyboard();
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ DisplayServer::get_singleton()->virtual_keyboard_hide();
} break;
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
if (has_focus()) {
- ime_text = OS::get_singleton()->get_ime_text();
- ime_selection = OS::get_singleton()->get_ime_selection();
+ ime_text = DisplayServer::get_singleton()->ime_get_text();
+ ime_selection = DisplayServer::get_singleton()->ime_get_selection();
update();
}
} break;
@@ -964,14 +968,14 @@ void LineEdit::_notification(int p_what) {
void LineEdit::copy_text() {
if (selection.enabled && !pass) {
- OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin));
+ DisplayServer::get_singleton()->clipboard_set(text.substr(selection.begin, selection.end - selection.begin));
}
}
void LineEdit::cut_text() {
if (selection.enabled && !pass) {
- OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin));
+ DisplayServer::get_singleton()->clipboard_set(text.substr(selection.begin, selection.end - selection.begin));
selection_delete();
}
}
@@ -979,7 +983,7 @@ void LineEdit::cut_text() {
void LineEdit::paste_text() {
// Strip escape characters like \n and \t as they can't be displayed on LineEdit.
- String paste_buffer = OS::get_singleton()->get_clipboard().strip_escapes();
+ String paste_buffer = DisplayServer::get_singleton()->clipboard_get().strip_escapes();
if (paste_buffer != "") {
@@ -1055,13 +1059,13 @@ void LineEdit::shift_selection_check_post(bool p_shift) {
void LineEdit::set_cursor_at_pixel_pos(int p_x) {
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
int ofs = window_pos;
- Ref<StyleBox> style = get_stylebox("normal");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
int pixel_ofs = 0;
Size2 size = get_size();
bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled;
- int r_icon_width = Control::get_icon("clear")->get_width();
+ int r_icon_width = Control::get_theme_icon("clear")->get_width();
switch (align) {
@@ -1093,11 +1097,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) {
int char_w = 0;
if (font != NULL) {
- if (is_secret()) {
- char_w = font->get_char_size(secret_character[0]).width;
- } else {
- char_w = font->get_char_size(text[ofs]).width;
- }
+ char_w = font->get_char_size(pass ? secret_character[0] : text[ofs]).width;
}
pixel_ofs += char_w;
@@ -1113,13 +1113,13 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) {
int LineEdit::get_cursor_pixel_pos() {
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
int ofs = window_pos;
- Ref<StyleBox> style = get_stylebox("normal");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
int pixel_ofs = 0;
Size2 size = get_size();
bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled;
- int r_icon_width = Control::get_icon("clear")->get_width();
+ int r_icon_width = Control::get_theme_icon("clear")->get_width();
switch (align) {
@@ -1149,7 +1149,7 @@ int LineEdit::get_cursor_pixel_pos() {
while (ofs < cursor_pos) {
if (font != NULL) {
- pixel_ofs += font->get_char_size(text[ofs]).width;
+ pixel_ofs += font->get_char_size(pass ? secret_character[0] : text[ofs]).width;
}
ofs++;
}
@@ -1206,9 +1206,9 @@ void LineEdit::delete_char() {
if ((text.length() <= 0) || (cursor_pos == 0)) return;
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
if (font != NULL) {
- cached_width -= font->get_char_size(text[cursor_pos - 1]).width;
+ cached_width -= font->get_char_size(pass ? secret_character[0] : text[cursor_pos - 1]).width;
}
text.erase(cursor_pos - 1, 1);
@@ -1225,10 +1225,10 @@ void LineEdit::delete_char() {
void LineEdit::delete_text(int p_from_column, int p_to_column) {
if (text.size() > 0) {
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
if (font != NULL) {
for (int i = p_from_column; i < p_to_column; i++)
- cached_width -= font->get_char_size(text[i]).width;
+ cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width;
}
} else {
cached_width = 0;
@@ -1323,8 +1323,8 @@ void LineEdit::set_cursor_position(int p_pos) {
return;
}
- Ref<StyleBox> style = get_stylebox("normal");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
+ Ref<Font> font = get_theme_font("font");
if (cursor_pos <= window_pos) {
// Adjust window if cursor goes too much to the left.
@@ -1334,7 +1334,7 @@ void LineEdit::set_cursor_position(int p_pos) {
int window_width = get_size().width - style->get_minimum_size().width;
bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
- Ref<Texture2D> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
+ Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon;
window_width -= r_icon->get_width();
}
@@ -1352,7 +1352,11 @@ void LineEdit::set_cursor_position(int p_pos) {
// Do not do this, because if the cursor is at the end, its just fine that it takes no space.
// accum_width = font->get_char_size(' ').width;
} else {
- accum_width += font->get_char_size(text[i], i + 1 < text.length() ? text[i + 1] : 0).width; // Anything should do.
+ if (pass) {
+ accum_width += font->get_char_size(secret_character[0], i + 1 < text.length() ? secret_character[0] : 0).width;
+ } else {
+ accum_width += font->get_char_size(text[i], i + 1 < text.length() ? text[i + 1] : 0).width; // Anything should do.
+ }
}
if (accum_width > window_width)
break;
@@ -1405,14 +1409,14 @@ void LineEdit::clear_internal() {
Size2 LineEdit::get_minimum_size() const {
- Ref<StyleBox> style = get_stylebox("normal");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
+ Ref<Font> font = get_theme_font("font");
Size2 min_size;
// Minimum size of text.
int space_size = font->get_char_size(' ').x;
- min_size.width = get_constant("minimum_spaces") * space_size;
+ min_size.width = get_theme_constant("minimum_spaces") * space_size;
if (expand_to_text_length) {
// Add a space because some fonts are too exact, and because cursor needs a bit more when at the end.
@@ -1423,8 +1427,8 @@ Size2 LineEdit::get_minimum_size() const {
// Take icons into account.
if (!text.empty() && is_editable() && clear_button_enabled) {
- min_size.width = MAX(min_size.width, Control::get_icon("clear")->get_width());
- min_size.height = MAX(min_size.height, Control::get_icon("clear")->get_height());
+ min_size.width = MAX(min_size.width, Control::get_theme_icon("clear")->get_width());
+ min_size.height = MAX(min_size.height, Control::get_theme_icon("clear")->get_height());
}
if (right_icon.is_valid()) {
min_size.width = MAX(min_size.width, right_icon->get_width());
@@ -1703,7 +1707,7 @@ void LineEdit::_emit_text_change() {
}
void LineEdit::update_cached_width() {
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
cached_width = 0;
if (font != NULL) {
String text = get_text();
@@ -1714,7 +1718,7 @@ void LineEdit::update_cached_width() {
}
void LineEdit::update_placeholder_width() {
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
cached_placeholder_width = 0;
if (font != NULL) {
for (int i = 0; i < placeholder_translated.length(); i++) {
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 4b8054bac6..3dffa06b49 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -54,7 +54,7 @@ LinkButton::UnderlineMode LinkButton::get_underline_mode() const {
Size2 LinkButton::get_minimum_size() const {
- return get_font("font")->get_string_size(text);
+ return get_theme_font("font")->get_string_size(text);
}
void LinkButton::_notification(int p_what) {
@@ -72,29 +72,29 @@ void LinkButton::_notification(int p_what) {
case DRAW_NORMAL: {
- color = get_color("font_color");
+ color = get_theme_color("font_color");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
case DRAW_HOVER_PRESSED:
case DRAW_PRESSED: {
- if (has_color("font_color_pressed"))
- color = get_color("font_color_pressed");
+ if (has_theme_color("font_color_pressed"))
+ color = get_theme_color("font_color_pressed");
else
- color = get_color("font_color");
+ color = get_theme_color("font_color");
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
- color = get_color("font_color_hover");
+ color = get_theme_color("font_color_hover");
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
- color = get_color("font_color_disabled");
+ color = get_theme_color("font_color_disabled");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
@@ -102,16 +102,16 @@ void LinkButton::_notification(int p_what) {
if (has_focus()) {
- Ref<StyleBox> style = get_stylebox("focus");
+ Ref<StyleBox> style = get_theme_stylebox("focus");
style->draw(ci, Rect2(Point2(), size));
}
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
draw_string(font, Vector2(0, font->get_ascent()), text, color);
if (do_underline) {
- int underline_spacing = get_constant("underline_spacing");
+ int underline_spacing = get_theme_constant("underline_spacing");
int width = font->get_string_size(text).width;
int y = font->get_ascent() + underline_spacing;
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 53373fc297..1cd4ff4ff8 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -32,10 +32,10 @@
Size2 MarginContainer::get_minimum_size() const {
- int margin_left = get_constant("margin_left");
- int margin_top = get_constant("margin_top");
- int margin_right = get_constant("margin_right");
- int margin_bottom = get_constant("margin_bottom");
+ int margin_left = get_theme_constant("margin_left");
+ int margin_top = get_theme_constant("margin_top");
+ int margin_right = get_theme_constant("margin_right");
+ int margin_bottom = get_theme_constant("margin_bottom");
Size2 max;
@@ -67,10 +67,10 @@ void MarginContainer::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
- int margin_left = get_constant("margin_left");
- int margin_top = get_constant("margin_top");
- int margin_right = get_constant("margin_right");
- int margin_bottom = get_constant("margin_bottom");
+ int margin_left = get_theme_constant("margin_left");
+ int margin_top = get_theme_constant("margin_top");
+ int margin_right = get_theme_constant("margin_right");
+ int margin_bottom = get_theme_constant("margin_bottom");
Size2 s = get_size();
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 2b163187c5..a7d1f64e93 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -31,7 +31,7 @@
#include "menu_button.h"
#include "core/os/keyboard.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
@@ -43,23 +43,34 @@ void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
if (!get_parent() || !is_visible_in_tree() || is_disabled())
return;
- bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));
-
- if (popup->activate_item_by_event(p_event, global_only))
+ //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, global_only))
+ // accept_event();
+ if (popup->activate_item_by_event(p_event, false))
accept_event();
}
}
void MenuButton::pressed() {
- emit_signal("about_to_show");
+ {
+ Window *w = Object::cast_to<Window>(get_viewport());
+ if (w && !w->is_embedding_subwindows()) {
+ print_line("windowpos: " + w->get_position());
+ }
+ }
Size2 size = get_size();
- Point2 gp = get_global_position();
- popup->set_global_position(gp + Size2(0, size.height * get_global_transform().get_scale().y));
+ Point2 gp = get_screen_position();
+
+ print_line("screenpos: " + gp);
+ gp.y += get_size().y;
+
+ popup->set_position(gp);
+
popup->set_size(Size2(size.width, 0));
- popup->set_scale(get_global_transform().get_scale());
- popup->set_parent_rect(Rect2(Point2(gp - popup->get_global_position()), get_size()));
+ popup->set_parent_rect(Rect2(Point2(gp - popup->get_position()), get_size()));
+ popup->take_mouse_focus();
popup->popup();
}
@@ -116,7 +127,7 @@ void MenuButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "switch_on_hover"), "set_switch_on_hover", "is_switch_on_hover");
- ADD_SIGNAL(MethodInfo("about_to_show"));
+ ADD_SIGNAL(MethodInfo("about_to_popup"));
}
void MenuButton::set_disable_shortcuts(bool p_disabled) {
@@ -137,8 +148,7 @@ MenuButton::MenuButton() {
popup = memnew(PopupMenu);
popup->hide();
add_child(popup);
- popup->set_pass_on_modal_close_click(false);
- popup->connect("about_to_show", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true)); // For when switching from another MenuButton.
+ popup->connect("about_to_popup", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true)); // For when switching from another MenuButton.
popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false));
}
diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp
index 0ef1f53006..cf10c4cfbd 100644
--- a/scene/gui/nine_patch_rect.cpp
+++ b/scene/gui/nine_patch_rect.cpp
@@ -30,7 +30,7 @@
#include "nine_patch_rect.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
void NinePatchRect::_notification(int p_what) {
@@ -45,7 +45,7 @@ void NinePatchRect::_notification(int p_what) {
texture->get_rect_region(rect, src_rect, rect, src_rect);
RID ci = get_canvas_item();
- VS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NinePatchAxisMode(axis_h), VS::NinePatchAxisMode(axis_v), draw_center);
+ RS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center);
}
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index c185761beb..30ecd651b1 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -36,12 +36,12 @@ Size2 OptionButton::get_minimum_size() const {
Size2 minsize = Button::get_minimum_size();
- if (has_icon("arrow")) {
- const Size2 padding = get_stylebox("normal")->get_minimum_size();
- const Size2 arrow_size = Control::get_icon("arrow")->get_size();
+ if (has_theme_icon("arrow")) {
+ const Size2 padding = get_theme_stylebox("normal")->get_minimum_size();
+ const Size2 arrow_size = Control::get_theme_icon("arrow")->get_size();
Size2 content_size = minsize - padding;
- content_size.width += arrow_size.width + get_constant("hseparation");
+ content_size.width += arrow_size.width + get_theme_constant("hseparation");
content_size.height = MAX(content_size.height, arrow_size.height);
minsize = content_size + padding;
@@ -55,37 +55,37 @@ void OptionButton::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
- if (!has_icon("arrow"))
+ if (!has_theme_icon("arrow"))
return;
RID ci = get_canvas_item();
- Ref<Texture2D> arrow = Control::get_icon("arrow");
+ Ref<Texture2D> arrow = Control::get_theme_icon("arrow");
Color clr = Color(1, 1, 1);
- if (get_constant("modulate_arrow")) {
+ if (get_theme_constant("modulate_arrow")) {
switch (get_draw_mode()) {
case DRAW_PRESSED:
- clr = get_color("font_color_pressed");
+ clr = get_theme_color("font_color_pressed");
break;
case DRAW_HOVER:
- clr = get_color("font_color_hover");
+ clr = get_theme_color("font_color_hover");
break;
case DRAW_DISABLED:
- clr = get_color("font_color_disabled");
+ clr = get_theme_color("font_color_disabled");
break;
default:
- clr = get_color("font_color");
+ clr = get_theme_color("font_color");
}
}
Size2 size = get_size();
- Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ Point2 ofs(size.width - arrow->get_width() - get_theme_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
arrow->draw(ci, ofs, clr);
} break;
case NOTIFICATION_THEME_CHANGED: {
- if (has_icon("arrow")) {
- _set_internal_margin(MARGIN_RIGHT, Control::get_icon("arrow")->get_width());
+ if (has_theme_icon("arrow")) {
+ _set_internal_margin(MARGIN_RIGHT, Control::get_theme_icon("arrow")->get_width());
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -109,9 +109,8 @@ void OptionButton::_selected(int p_which) {
void OptionButton::pressed() {
Size2 size = get_size();
- popup->set_global_position(get_global_position() + Size2(0, size.height * get_global_transform().get_scale().y));
+ popup->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
popup->set_size(Size2(size.width, 0));
- popup->set_scale(get_global_transform().get_scale());
popup->popup();
}
@@ -351,15 +350,15 @@ OptionButton::OptionButton() {
set_toggle_mode(true);
set_text_align(ALIGN_LEFT);
set_action_mode(ACTION_MODE_BUTTON_PRESS);
- if (has_icon("arrow")) {
- _set_internal_margin(MARGIN_RIGHT, Control::get_icon("arrow")->get_width());
+ if (has_theme_icon("arrow")) {
+ _set_internal_margin(MARGIN_RIGHT, Control::get_theme_icon("arrow")->get_width());
}
popup = memnew(PopupMenu);
popup->hide();
add_child(popup);
- popup->set_pass_on_modal_close_click(false);
- popup->set_notify_transform(true);
+ // popup->set_pass_on_modal_close_click(false);
+ // popup->set_notify_transform(true);
popup->set_allow_search(true);
popup->connect("index_pressed", callable_mp(this, &OptionButton::_selected));
popup->connect("id_focused", callable_mp(this, &OptionButton::_focused));
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index 0356607071..ae51463a15 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -36,11 +36,25 @@ void Panel::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
- Ref<StyleBox> style = get_stylebox("panel");
+ Ref<StyleBox> style = mode == MODE_BACKGROUND ? get_theme_stylebox("panel") : get_theme_stylebox("panel_fg");
style->draw(ci, Rect2(Point2(), get_size()));
}
}
+void Panel::set_mode(Mode p_mode) {
+ mode = p_mode;
+ update();
+}
+Panel::Mode Panel::get_mode() const {
+ return mode;
+}
+
+void Panel::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_mode", "mode"), &Panel::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"), &Panel::get_mode);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Background,Foreground"), "set_mode", "get_mode");
+}
Panel::Panel() {
// Has visible stylebox, so stop by default.
set_mouse_filter(MOUSE_FILTER_STOP);
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index 3538126d22..739c64c0a6 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -37,12 +37,26 @@ class Panel : public Control {
GDCLASS(Panel, Control);
+public:
+ enum Mode {
+ MODE_BACKGROUND,
+ MODE_FOREGROUND
+ };
+
+private:
+ Mode mode = MODE_BACKGROUND;
+
protected:
void _notification(int p_what);
+ static void _bind_methods();
public:
+ void set_mode(Mode p_mode);
+ Mode get_mode() const;
+
Panel();
~Panel();
};
+VARIANT_ENUM_CAST(Panel::Mode)
#endif
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index 6cf23b8a32..62b9296409 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -34,16 +34,16 @@ Size2 PanelContainer::get_minimum_size() const {
Ref<StyleBox> style;
- if (has_stylebox("panel"))
- style = get_stylebox("panel");
+ if (has_theme_stylebox("panel"))
+ style = get_theme_stylebox("panel");
else
- style = get_stylebox("panel", "PanelContainer");
+ style = get_theme_stylebox("panel", "PanelContainer");
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -65,10 +65,10 @@ void PanelContainer::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<StyleBox> style;
- if (has_stylebox("panel"))
- style = get_stylebox("panel");
+ if (has_theme_stylebox("panel"))
+ style = get_theme_stylebox("panel");
else
- style = get_stylebox("panel", "PanelContainer");
+ style = get_theme_stylebox("panel", "PanelContainer");
style->draw(ci, Rect2(Point2(), get_size()));
}
@@ -77,10 +77,10 @@ void PanelContainer::_notification(int p_what) {
Ref<StyleBox> style;
- if (has_stylebox("panel"))
- style = get_stylebox("panel");
+ if (has_theme_stylebox("panel"))
+ style = get_theme_stylebox("panel");
else
- style = get_stylebox("panel", "PanelContainer");
+ style = get_theme_stylebox("panel", "PanelContainer");
Size2 size = get_size();
Point2 ofs;
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 64ef4a01f6..6edafc65a0 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -32,227 +32,131 @@
#include "core/engine.h"
#include "core/os/keyboard.h"
+#include "scene/gui/panel.h"
-void Popup::_gui_input(Ref<InputEvent> p_event) {
-}
-
-void Popup::_notification(int p_what) {
-
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (popped_up && !is_visible_in_tree()) {
- popped_up = false;
- notification(NOTIFICATION_POPUP_HIDE);
- emit_signal("popup_hide");
- }
-
- update_configuration_warning();
- }
-
- if (p_what == NOTIFICATION_EXIT_TREE) {
- if (popped_up) {
- popped_up = false;
- notification(NOTIFICATION_POPUP_HIDE);
- emit_signal("popup_hide");
- }
- }
-
- if (p_what == NOTIFICATION_ENTER_TREE) {
-//small helper to make editing of these easier in editor
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
- //edited on editor
- set_as_toplevel(false);
- } else
-#endif
- if (is_visible()) {
- hide();
- }
+void Popup::_input_from_window(const Ref<InputEvent> &p_event) {
+ Ref<InputEventKey> key = p_event;
+ if (key.is_valid() && key->is_pressed() && key->get_keycode() == KEY_ESCAPE) {
+ _close_pressed();
}
}
-void Popup::_fix_size() {
-
- Point2 pos = get_global_position();
- Size2 size = get_size() * get_scale();
- Point2 window_size = get_viewport_rect().size - get_viewport_transform().get_origin();
-
- if (pos.x + size.width > window_size.width)
- pos.x = window_size.width - size.width;
- if (pos.x < 0)
- pos.x = 0;
+void Popup::_parent_focused() {
- if (pos.y + size.height > window_size.height)
- pos.y = window_size.height - size.height;
- if (pos.y < 0)
- pos.y = 0;
- if (pos != get_position())
- set_global_position(pos);
+ _close_pressed();
}
+void Popup::_notification(int p_what) {
-void Popup::set_as_minsize() {
-
- Size2 total_minsize;
-
- for (int i = 0; i < get_child_count(); i++) {
-
- Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
- continue;
- if (!c->is_visible())
- continue;
-
- Size2 minsize = c->get_combined_minimum_size();
-
- for (int j = 0; j < 2; j++) {
-
- Margin m_beg = Margin(0 + j);
- Margin m_end = Margin(2 + j);
-
- float margin_begin = c->get_margin(m_beg);
- float margin_end = c->get_margin(m_end);
- float anchor_begin = c->get_anchor(m_beg);
- float anchor_end = c->get_anchor(m_end);
-
- minsize[j] += margin_begin * (ANCHOR_END - anchor_begin) + margin_end * anchor_end;
- }
-
- total_minsize.width = MAX(total_minsize.width, minsize.width);
- total_minsize.height = MAX(total_minsize.height, minsize.height);
+ switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (is_visible()) {
+
+ parent_visible = get_parent_visible_window();
+ if (parent_visible) {
+ parent_visible->connect("focus_entered", callable_mp(this, &Popup::_parent_focused));
+ }
+ } else {
+ if (parent_visible) {
+ parent_visible->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
+ parent_visible = nullptr;
+ }
+
+ emit_signal("popup_hide");
+ }
+
+ } break;
+ case NOTIFICATION_EXIT_TREE: {
+ if (parent_visible) {
+ parent_visible->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
+ parent_visible = nullptr;
+ }
+ } break;
+ case NOTIFICATION_WM_CLOSE_REQUEST: {
+ _close_pressed();
+
+ } break;
}
-
- set_size(total_minsize);
}
-void Popup::popup_centered_clamped(const Size2 &p_size, float p_fallback_ratio) {
-
- Size2 popup_size = p_size;
- Size2 window_size = get_viewport_rect().size;
-
- // clamp popup size in each dimension if window size is too small (using fallback ratio)
- popup_size.x = MIN(window_size.x * p_fallback_ratio, popup_size.x);
- popup_size.y = MIN(window_size.y * p_fallback_ratio, popup_size.y);
-
- popup_centered(popup_size);
-}
+void Popup::_close_pressed() {
-void Popup::popup_centered_minsize(const Size2 &p_minsize) {
-
- set_custom_minimum_size(p_minsize);
- _fix_size();
- popup_centered();
-}
+ Window *parent_window = parent_visible;
+ if (parent_visible) {
+ parent_visible->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
+ parent_visible = nullptr;
+ }
-void Popup::popup_centered(const Size2 &p_size) {
+ call_deferred("hide");
- Rect2 rect;
- Size2 window_size = get_viewport_rect().size;
- rect.size = p_size == Size2() ? get_size() : p_size;
- rect.position = ((window_size - rect.size) / 2.0).floor();
+ emit_signal("cancelled");
- _popup(rect, true);
+ if (parent_window) {
+ //parent_window->grab_focus();
+ }
}
-void Popup::popup_centered_ratio(float p_screen_ratio) {
-
- Rect2 rect;
- Size2 window_size = get_viewport_rect().size;
- rect.size = (window_size * p_screen_ratio).floor();
- rect.position = ((window_size - rect.size) / 2.0).floor();
-
- _popup(rect, true);
+void Popup::set_as_minsize() {
+ set_size(get_contents_minimum_size());
}
+void Popup::_bind_methods() {
-void Popup::popup(const Rect2 &p_bounds) {
-
- _popup(p_bounds);
+ ADD_SIGNAL(MethodInfo("popup_hide"));
}
-void Popup::_popup(const Rect2 &p_bounds, const bool p_centered) {
-
- emit_signal("about_to_show");
- show_modal(exclusive);
-
- // Fit the popup into the optionally provided bounds.
- if (!p_bounds.has_no_area()) {
- set_size(p_bounds.size);
+Rect2i Popup::_popup_adjust_rect() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
+ Rect2i parent = get_usable_parent_rect();
- // check if p_bounds.size was using an outdated cached values
- if (p_centered && p_bounds.size != get_size()) {
- set_position(p_bounds.position - ((get_size() - p_bounds.size) / 2.0).floor());
- } else {
- set_position(p_bounds.position);
- }
+ if (parent == Rect2i()) {
+ return Rect2i();
}
- _fix_size();
-
- Control *focusable = find_next_valid_focus();
-
- if (focusable)
- focusable->grab_focus();
-
- _post_popup();
- notification(NOTIFICATION_POST_POPUP);
- popped_up = true;
-}
-void Popup::set_exclusive(bool p_exclusive) {
+ Rect2i current(get_position(), get_size());
- exclusive = p_exclusive;
-}
-
-bool Popup::is_exclusive() const {
+ if (current.position.x + current.size.x > parent.position.x + parent.size.x) {
+ current.position.x = parent.position.x + parent.size.x - current.size.x;
+ }
- return exclusive;
-}
+ if (current.position.x < parent.position.x) {
+ current.position.x = parent.position.x;
+ }
-void Popup::_bind_methods() {
+ if (current.position.y + current.size.y > parent.position.y + parent.size.y) {
+ current.position.y = parent.position.y + parent.size.y - current.size.y;
+ }
- ClassDB::bind_method(D_METHOD("set_as_minsize"), &Popup::set_as_minsize);
- ClassDB::bind_method(D_METHOD("popup_centered", "size"), &Popup::popup_centered, DEFVAL(Size2()));
- ClassDB::bind_method(D_METHOD("popup_centered_ratio", "ratio"), &Popup::popup_centered_ratio, DEFVAL(0.75));
- ClassDB::bind_method(D_METHOD("popup_centered_minsize", "minsize"), &Popup::popup_centered_minsize, DEFVAL(Size2()));
- ClassDB::bind_method(D_METHOD("popup_centered_clamped", "size", "fallback_ratio"), &Popup::popup_centered_clamped, DEFVAL(Size2()), DEFVAL(0.75));
- ClassDB::bind_method(D_METHOD("popup", "bounds"), &Popup::popup, DEFVAL(Rect2()));
- ClassDB::bind_method(D_METHOD("set_exclusive", "enable"), &Popup::set_exclusive);
- ClassDB::bind_method(D_METHOD("is_exclusive"), &Popup::is_exclusive);
- ADD_SIGNAL(MethodInfo("about_to_show"));
- ADD_SIGNAL(MethodInfo("popup_hide"));
- ADD_GROUP("Popup", "popup_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "popup_exclusive"), "set_exclusive", "is_exclusive");
+ if (current.position.y < parent.position.y) {
+ current.position.y = parent.position.y;
+ }
- BIND_CONSTANT(NOTIFICATION_POST_POPUP);
- BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
+ return current;
}
Popup::Popup() {
- set_as_toplevel(true);
- exclusive = false;
- popped_up = false;
- hide();
-}
-
-String Popup::get_configuration_warning() const {
+ parent_visible = nullptr;
- 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, but they will hide upon running.");
- }
+ set_wrap_controls(true);
+ set_visible(false);
+ set_transient(true);
+ set_flag(FLAG_BORDERLESS, true);
+ set_flag(FLAG_RESIZE_DISABLED, true);
- return String();
+ connect("window_input", callable_mp(this, &Popup::_input_from_window));
}
Popup::~Popup() {
}
-Size2 PopupPanel::get_minimum_size() const {
+Size2 PopupPanel::_get_contents_minimum_size() const {
- Ref<StyleBox> p = get_stylebox("panel");
+ Ref<StyleBox> p = get_theme_stylebox("panel", get_class_name());
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c || c == panel)
continue;
if (c->is_set_as_toplevel())
@@ -268,7 +172,7 @@ Size2 PopupPanel::get_minimum_size() const {
void PopupPanel::_update_child_rects() {
- Ref<StyleBox> p = get_stylebox("panel");
+ Ref<StyleBox> p = get_theme_stylebox("panel", get_class_name());
Vector2 cpos(p->get_offset());
Vector2 csize(get_size() - p->get_minimum_size());
@@ -281,24 +185,32 @@ void PopupPanel::_update_child_rects() {
if (c->is_set_as_toplevel())
continue;
- c->set_position(cpos);
- c->set_size(csize);
+ if (c == panel) {
+ c->set_position(Vector2());
+ c->set_size(get_size());
+ } else {
+ c->set_position(cpos);
+ c->set_size(csize);
+ }
}
}
void PopupPanel::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
-
- get_stylebox("panel")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
- } else if (p_what == NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
+ panel->add_theme_style_override("panel", get_theme_stylebox("panel", get_class_name()));
+ } else if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_ENTER_TREE) {
+ panel->add_theme_style_override("panel", get_theme_stylebox("panel", get_class_name()));
_update_child_rects();
- } else if (p_what == NOTIFICATION_RESIZED) {
+ } else if (p_what == NOTIFICATION_WM_SIZE_CHANGED) {
_update_child_rects();
}
}
PopupPanel::PopupPanel() {
+
+ panel = memnew(Panel);
+ add_child(panel);
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index ff472170b3..6cd2b4028f 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -31,44 +31,26 @@
#ifndef POPUP_H
#define POPUP_H
-#include "scene/gui/control.h"
+#include "scene/main/window.h"
-class Popup : public Control {
+class Popup : public Window {
- GDCLASS(Popup, Control);
+ GDCLASS(Popup, Window);
- bool exclusive;
- bool popped_up;
+ Window *parent_visible;
-private:
- void _popup(const Rect2 &p_bounds = Rect2(), const bool p_centered = false);
+ void _input_from_window(const Ref<InputEvent> &p_event);
+ void _parent_focused();
protected:
- virtual void _post_popup() {}
+ void _close_pressed();
+ virtual Rect2i _popup_adjust_rect() const;
- void _gui_input(Ref<InputEvent> p_event);
void _notification(int p_what);
- virtual void _fix_size();
static void _bind_methods();
public:
- enum {
- NOTIFICATION_POST_POPUP = 80,
- NOTIFICATION_POPUP_HIDE = 81
- };
-
- void set_exclusive(bool p_exclusive);
- bool is_exclusive() const;
-
- void popup_centered_ratio(float p_screen_ratio = 0.75);
- void popup_centered(const Size2 &p_size = Size2());
- void popup_centered_minsize(const Size2 &p_minsize = Size2());
void set_as_minsize();
- void popup_centered_clamped(const Size2 &p_size = Size2(), float p_fallback_ratio = 0.75);
- virtual void popup(const Rect2 &p_bounds = Rect2());
-
- virtual String get_configuration_warning() const;
-
Popup();
~Popup();
};
@@ -77,13 +59,16 @@ class PopupPanel : public Popup {
GDCLASS(PopupPanel, Popup);
+ Panel *panel;
+
protected:
void _update_child_rects();
void _notification(int p_what);
+ virtual Size2 _get_contents_minimum_size() const;
+
public:
void set_child_rect(Control *p_child);
- virtual Size2 get_minimum_size() const;
PopupPanel();
};
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index e75dadd5e0..c096dc94cb 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -30,11 +30,12 @@
#include "popup_menu.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/print_string.h"
#include "core/translation.h"
+#include "scene/gui/control.h"
String PopupMenu::_get_accel_text(int p_item) const {
@@ -47,18 +48,18 @@ String PopupMenu::_get_accel_text(int p_item) const {
return String();
}
-Size2 PopupMenu::get_minimum_size() const {
+Size2 PopupMenu::_get_contents_minimum_size() const {
- int vseparation = get_constant("vseparation");
- int hseparation = get_constant("hseparation");
+ int vseparation = get_theme_constant("vseparation");
+ int hseparation = get_theme_constant("hseparation");
- Size2 minsize = get_stylebox("panel")->get_minimum_size();
- Ref<Font> font = get_font("font");
+ Size2 minsize = get_theme_stylebox("panel")->get_minimum_size();
+ Ref<Font> font = get_theme_font("font");
float max_w = 0;
float icon_w = 0;
int font_h = font->get_height();
- int check_w = MAX(get_icon("checked")->get_width(), get_icon("radio_checked")->get_width()) + hseparation;
+ int check_w = MAX(get_theme_icon("checked")->get_width(), get_theme_icon("radio_checked")->get_width()) + hseparation;
int accel_max_w = 0;
bool has_check = false;
@@ -93,7 +94,7 @@ Size2 PopupMenu::get_minimum_size() const {
}
if (items[i].submenu != "")
- size.width += get_icon("submenu")->get_width();
+ size.width += get_theme_icon("submenu")->get_width();
max_w = MAX(max_w, size.width);
@@ -112,15 +113,15 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
if (p_over.x < 0 || p_over.x >= get_size().width)
return -1;
- Ref<StyleBox> style = get_stylebox("panel");
+ Ref<StyleBox> style = get_theme_stylebox("panel");
Point2 ofs = style->get_offset();
if (ofs.y > p_over.y)
return -1;
- Ref<Font> font = get_font("font");
- int vseparation = get_constant("vseparation");
+ Ref<Font> font = get_theme_font("font");
+ int vseparation = get_theme_constant("vseparation");
float font_h = font->get_height();
for (int i = 0; i < items.size(); i++) {
@@ -152,27 +153,27 @@ void PopupMenu::_activate_submenu(int over) {
ERR_FAIL_COND_MSG(!n, "Item subnode does not exist: " + items[over].submenu + ".");
Popup *pm = Object::cast_to<Popup>(n);
ERR_FAIL_COND_MSG(!pm, "Item subnode is not a Popup: " + items[over].submenu + ".");
- if (pm->is_visible_in_tree())
+ if (pm->is_visible())
return; //already visible!
- Point2 p = get_global_position();
+ Point2 p = get_position();
Rect2 pr(p, get_size());
- Ref<StyleBox> style = get_stylebox("panel");
+ Ref<StyleBox> style = get_theme_stylebox("panel");
- Point2 pos = p + Point2(get_size().width, items[over]._ofs_cache - style->get_offset().y) * get_global_transform().get_scale();
+ Point2 pos = p + Point2(get_size().width, items[over]._ofs_cache - style->get_offset().y);
Size2 size = pm->get_size();
// fix pos
- if (pos.x + size.width > get_viewport_rect().size.width)
+ if (pos.x + size.width > get_parent_rect().size.width)
pos.x = p.x - size.width;
pm->set_position(pos);
- pm->set_scale(get_global_transform().get_scale());
+ // pm->set_scale(get_global_transform().get_scale());
pm->popup();
PopupMenu *pum = Object::cast_to<PopupMenu>(pm);
if (pum) {
- pr.position -= pum->get_global_position();
+ pr.position -= pum->get_position();
pum->clear_autohide_areas();
pum->add_autohide_area(Rect2(pr.position.x, pr.position.y, pr.size.x, items[over]._ofs_cache));
if (over < items.size() - 1) {
@@ -184,6 +185,9 @@ void PopupMenu::_activate_submenu(int over) {
void PopupMenu::_submenu_timeout() {
+ //if (!has_focus()) {
+ // return; //do not activate if not has focus
+ //}
if (mouse_over == submenu_over)
_activate_submenu(mouse_over);
@@ -192,20 +196,27 @@ void PopupMenu::_submenu_timeout() {
void PopupMenu::_scroll(float p_factor, const Point2 &p_over) {
- int vseparation = get_constant("vseparation");
- Ref<Font> font = get_font("font");
+ int vseparation = get_theme_constant("vseparation");
+ Ref<Font> font = get_theme_font("font");
- float dy = (vseparation + font->get_height()) * 3 * p_factor * get_global_transform().get_scale().y;
+ Rect2 visible_rect = get_usable_parent_rect();
+
+ int dy = (vseparation + font->get_height()) * 3 * p_factor;
if (dy > 0) {
- const float global_top = get_global_position().y;
- const float limit = global_top < 0 ? -global_top : 0;
+ const float global_top = get_position().y;
+ const float limit = global_top < visible_rect.position.y ? visible_rect.position.y - global_top : 0;
dy = MIN(dy, limit);
} else if (dy < 0) {
- const float global_bottom = get_global_position().y + get_size().y * get_global_transform().get_scale().y;
- const float viewport_height = get_viewport_rect().size.y;
+ const float global_bottom = get_position().y + get_size().y;
+ const float viewport_height = visible_rect.position.y + visible_rect.size.y;
const float limit = global_bottom > viewport_height ? global_bottom - viewport_height : 0;
dy = -MIN(-dy, limit);
}
+
+ if (dy == 0) {
+ return;
+ }
+
set_position(get_position() + Vector2(0, dy));
Ref<InputEventMouseMotion> ie;
@@ -231,8 +242,8 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
mouse_over = i;
emit_signal("id_focused", i);
- update();
- accept_event();
+ control->update();
+ set_input_as_handled();
break;
}
}
@@ -251,8 +262,8 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
mouse_over = i;
emit_signal("id_focused", i);
- update();
- accept_event();
+ control->update();
+ set_input_as_handled();
break;
}
}
@@ -261,13 +272,13 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
Node *n = get_parent();
if (n && Object::cast_to<PopupMenu>(n)) {
hide();
- accept_event();
+ set_input_as_handled();
}
} else if (p_event->is_action("ui_right") && p_event->is_pressed()) {
if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator && items[mouse_over].submenu != "" && submenu_over != mouse_over) {
_activate_submenu(mouse_over);
- accept_event();
+ set_input_as_handled();
}
} else if (p_event->is_action("ui_accept") && p_event->is_pressed()) {
@@ -278,7 +289,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
} else {
activate_item(mouse_over);
}
- accept_event();
+ set_input_as_handled();
}
}
@@ -294,15 +305,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
case BUTTON_WHEEL_DOWN: {
- if (get_global_position().y + get_size().y * get_global_transform().get_scale().y > get_viewport_rect().size.y) {
- _scroll(-b->get_factor(), b->get_position());
- }
+ _scroll(-b->get_factor(), b->get_position());
} break;
case BUTTON_WHEEL_UP: {
- if (get_global_position().y < 0) {
- _scroll(b->get_factor(), b->get_position());
- }
+ _scroll(b->get_factor(), b->get_position());
} break;
default: {
// Allow activating item by releasing the LMB or any that was down when the popup appeared
@@ -338,7 +345,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
}
}
- //update();
+ //control->update();
}
Ref<InputEventMouseMotion> m = p_event;
@@ -354,7 +361,8 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) {
- call_deferred("hide");
+
+ _close_pressed();
return;
}
}
@@ -364,7 +372,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
if (id < 0) {
mouse_over = -1;
- update();
+ control->update();
return;
}
@@ -375,15 +383,13 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
if (over != mouse_over) {
mouse_over = over;
- update();
+ control->update();
}
}
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
- if (get_global_position().y + get_size().y > get_viewport_rect().size.y || get_global_position().y < 0) {
- _scroll(-pan_gesture->get_delta().y, pan_gesture->get_position());
- }
+ _scroll(-pan_gesture->get_delta().y, pan_gesture->get_position());
}
Ref<InputEventKey> k = p_event;
@@ -416,218 +422,227 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
if (items[i].text.findn(search_string) == 0) {
mouse_over = i;
emit_signal("id_focused", i);
- update();
- accept_event();
+ control->update();
+ set_input_as_handled();
break;
}
}
}
}
-bool PopupMenu::has_point(const Point2 &p_point) const {
+void PopupMenu::_draw() {
- if (parent_rect.has_point(p_point))
- return true;
- for (const List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
+ RID ci = control->get_canvas_item();
+ Size2 size = get_size();
- if (E->get().has_point(p_point))
- return true;
- }
+ Ref<StyleBox> style = get_theme_stylebox("panel");
+ Ref<StyleBox> hover = get_theme_stylebox("hover");
+ Ref<Font> font = get_theme_font("font");
+ // In Item::checkable_type enum order (less the non-checkable member)
+ Ref<Texture2D> check[] = { get_theme_icon("checked"), get_theme_icon("radio_checked") };
+ Ref<Texture2D> uncheck[] = { get_theme_icon("unchecked"), get_theme_icon("radio_unchecked") };
+ Ref<Texture2D> submenu = get_theme_icon("submenu");
+ Ref<StyleBox> separator = get_theme_stylebox("separator");
+ Ref<StyleBox> labeled_separator_left = get_theme_stylebox("labeled_separator_left");
+ Ref<StyleBox> labeled_separator_right = get_theme_stylebox("labeled_separator_right");
- return Control::has_point(p_point);
-}
-
-void PopupMenu::_notification(int p_what) {
+ style->draw(ci, Rect2(Point2(), get_size()));
+ Point2 ofs = style->get_offset();
+ int vseparation = get_theme_constant("vseparation");
+ int hseparation = get_theme_constant("hseparation");
+ Color font_color = get_theme_color("font_color");
+ Color font_color_disabled = get_theme_color("font_color_disabled");
+ Color font_color_accel = get_theme_color("font_color_accel");
+ Color font_color_hover = get_theme_color("font_color_hover");
+ float font_h = font->get_height();
- switch (p_what) {
+ // Add the check and the wider icon to the offset of all items.
+ float icon_ofs = 0.0;
+ bool has_check = false;
+ for (int i = 0; i < items.size(); i++) {
- case NOTIFICATION_ENTER_TREE: {
+ if (!items[i].icon.is_null())
+ icon_ofs = MAX(items[i].icon->get_size().width, icon_ofs);
- PopupMenu *pm = Object::cast_to<PopupMenu>(get_parent());
- if (pm) {
- // Inherit submenu's popup delay time from parent menu
- float pm_delay = pm->get_submenu_popup_delay();
- set_submenu_popup_delay(pm_delay);
- }
- } break;
- case NOTIFICATION_TRANSLATION_CHANGED: {
+ if (items[i].checkable_type)
+ has_check = true;
+ }
+ if (icon_ofs > 0.0)
+ icon_ofs += hseparation;
- for (int i = 0; i < items.size(); i++) {
- items.write[i].xl_text = tr(items[i].text);
- }
+ float check_ofs = 0.0;
+ if (has_check)
+ check_ofs = MAX(get_theme_icon("checked")->get_width(), get_theme_icon("radio_checked")->get_width()) + hseparation;
- minimum_size_changed();
- update();
- } break;
- case NOTIFICATION_DRAW: {
-
- RID ci = get_canvas_item();
- Size2 size = get_size();
-
- Ref<StyleBox> style = get_stylebox("panel");
- Ref<StyleBox> hover = get_stylebox("hover");
- Ref<Font> font = get_font("font");
- // In Item::checkable_type enum order (less the non-checkable member)
- Ref<Texture2D> check[] = { get_icon("checked"), get_icon("radio_checked") };
- Ref<Texture2D> uncheck[] = { get_icon("unchecked"), get_icon("radio_unchecked") };
- Ref<Texture2D> submenu = get_icon("submenu");
- Ref<StyleBox> separator = get_stylebox("separator");
- Ref<StyleBox> labeled_separator_left = get_stylebox("labeled_separator_left");
- Ref<StyleBox> labeled_separator_right = get_stylebox("labeled_separator_right");
-
- style->draw(ci, Rect2(Point2(), get_size()));
- Point2 ofs = style->get_offset();
- int vseparation = get_constant("vseparation");
- int hseparation = get_constant("hseparation");
- Color font_color = get_color("font_color");
- Color font_color_disabled = get_color("font_color_disabled");
- Color font_color_accel = get_color("font_color_accel");
- Color font_color_hover = get_color("font_color_hover");
- float font_h = font->get_height();
-
- // Add the check and the wider icon to the offset of all items.
- float icon_ofs = 0.0;
- bool has_check = false;
- for (int i = 0; i < items.size(); i++) {
+ for (int i = 0; i < items.size(); i++) {
- if (!items[i].icon.is_null())
- icon_ofs = MAX(items[i].icon->get_size().width, icon_ofs);
+ if (i > 0)
+ ofs.y += vseparation;
+ Point2 item_ofs = ofs;
+ Size2 icon_size;
+ float h;
- if (items[i].checkable_type)
- has_check = true;
- }
- if (icon_ofs > 0.0)
- icon_ofs += hseparation;
+ if (!items[i].icon.is_null()) {
- float check_ofs = 0.0;
- if (has_check)
- check_ofs = MAX(get_icon("checked")->get_width(), get_icon("radio_checked")->get_width()) + hseparation;
+ icon_size = items[i].icon->get_size();
+ h = MAX(icon_size.height, font_h);
+ } else {
- for (int i = 0; i < items.size(); i++) {
+ h = font_h;
+ }
- if (i > 0)
- ofs.y += vseparation;
- Point2 item_ofs = ofs;
- Size2 icon_size;
- float h;
+ if (i == mouse_over) {
- if (!items[i].icon.is_null()) {
+ hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation / 2), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation)));
+ }
- icon_size = items[i].icon->get_size();
- h = MAX(icon_size.height, font_h);
- } else {
+ String text = items[i].xl_text;
- h = font_h;
+ item_ofs.x += items[i].h_ofs;
+ if (items[i].separator) {
+
+ int sep_h = separator->get_center_size().height + separator->get_minimum_size().height;
+ if (text != String()) {
+ int ss = font->get_string_size(text).width;
+ int center = (get_size().width) / 2;
+ int l = center - ss / 2;
+ int r = center + ss / 2;
+ if (l > item_ofs.x) {
+ labeled_separator_left->draw(ci, Rect2(item_ofs + Point2(0, Math::floor((h - sep_h) / 2.0)), Size2(MAX(0, l - item_ofs.x), sep_h)));
}
-
- if (i == mouse_over) {
-
- hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation / 2), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation)));
+ if (r < get_size().width - style->get_margin(MARGIN_RIGHT)) {
+ labeled_separator_right->draw(ci, Rect2(Point2(r, item_ofs.y + Math::floor((h - sep_h) / 2.0)), Size2(MAX(0, get_size().width - style->get_margin(MARGIN_RIGHT) - r), sep_h)));
}
+ } else {
+ 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)));
+ }
+ }
- String text = items[i].xl_text;
+ Color icon_color(1, 1, 1, items[i].disabled ? 0.5 : 1);
- item_ofs.x += items[i].h_ofs;
- if (items[i].separator) {
+ if (items[i].checkable_type) {
+ Texture2D *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr();
+ icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon->get_height()) / 2.0)), icon_color);
+ }
- int sep_h = separator->get_center_size().height + separator->get_minimum_size().height;
- if (text != String()) {
- int ss = font->get_string_size(text).width;
- int center = (get_size().width) / 2;
- int l = center - ss / 2;
- int r = center + ss / 2;
- if (l > item_ofs.x) {
- labeled_separator_left->draw(ci, Rect2(item_ofs + Point2(0, Math::floor((h - sep_h) / 2.0)), Size2(MAX(0, l - item_ofs.x), sep_h)));
- }
- if (r < get_size().width - style->get_margin(MARGIN_RIGHT)) {
- labeled_separator_right->draw(ci, Rect2(Point2(r, item_ofs.y + Math::floor((h - sep_h) / 2.0)), Size2(MAX(0, get_size().width - style->get_margin(MARGIN_RIGHT) - r), sep_h)));
- }
- } else {
- 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)));
- }
- }
+ if (!items[i].icon.is_null()) {
+ items[i].icon->draw(ci, item_ofs + Size2(check_ofs, 0) + Point2(0, Math::floor((h - icon_size.height) / 2.0)), icon_color);
+ }
- Color icon_color(1, 1, 1, items[i].disabled ? 0.5 : 1);
+ if (items[i].submenu != "") {
+ submenu->draw(ci, Point2(size.width - style->get_margin(MARGIN_RIGHT) - submenu->get_width(), item_ofs.y + Math::floor(h - submenu->get_height()) / 2), icon_color);
+ }
- if (items[i].checkable_type) {
- Texture2D *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr();
- icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon->get_height()) / 2.0)), icon_color);
- }
+ item_ofs.y += font->get_ascent();
+ if (items[i].separator) {
- if (!items[i].icon.is_null()) {
- items[i].icon->draw(ci, item_ofs + Size2(check_ofs, 0) + Point2(0, Math::floor((h - icon_size.height) / 2.0)), icon_color);
- }
+ if (text != String()) {
+ int center = (get_size().width - font->get_string_size(text).width) / 2;
+ font->draw(ci, Point2(center, item_ofs.y + Math::floor((h - font_h) / 2.0)), text, font_color_disabled);
+ }
+ } else {
- if (items[i].submenu != "") {
- submenu->draw(ci, Point2(size.width - style->get_margin(MARGIN_RIGHT) - submenu->get_width(), item_ofs.y + Math::floor(h - submenu->get_height()) / 2), icon_color);
- }
+ item_ofs.x += icon_ofs + check_ofs;
+ 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));
+ }
- item_ofs.y += font->get_ascent();
- if (items[i].separator) {
+ if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
+ //accelerator
+ String text2 = _get_accel_text(i);
+ item_ofs.x = size.width - style->get_margin(MARGIN_RIGHT) - font->get_string_size(text2).width;
+ font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text2, i == mouse_over ? font_color_hover : font_color_accel);
+ }
- if (text != String()) {
- int center = (get_size().width - font->get_string_size(text).width) / 2;
- font->draw(ci, Point2(center, item_ofs.y + Math::floor((h - font_h) / 2.0)), text, font_color_disabled);
- }
- } else {
+ items.write[i]._ofs_cache = ofs.y;
- item_ofs.x += icon_ofs + check_ofs;
- 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));
- }
+ ofs.y += h;
+ }
+}
- if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
- //accelerator
- String text2 = _get_accel_text(i);
- item_ofs.x = size.width - style->get_margin(MARGIN_RIGHT) - font->get_string_size(text2).width;
- font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text2, i == mouse_over ? font_color_hover : font_color_accel);
- }
+void PopupMenu::_notification(int p_what) {
+
+ switch (p_what) {
- items.write[i]._ofs_cache = ofs.y;
+ case NOTIFICATION_ENTER_TREE: {
- ofs.y += h;
+ PopupMenu *pm = Object::cast_to<PopupMenu>(get_parent());
+ if (pm) {
+ // Inherit submenu's popup delay time from parent menu
+ float pm_delay = pm->get_submenu_popup_delay();
+ set_submenu_popup_delay(pm_delay);
}
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_TRANSLATION_CHANGED: {
- if (hide_on_window_lose_focus)
- hide();
+ for (int i = 0; i < items.size(); i++) {
+ items.write[i].xl_text = tr(items[i].text);
+ }
+
+ child_controls_changed();
+ control->update();
} break;
- case NOTIFICATION_MOUSE_ENTER: {
+ case NOTIFICATION_WM_MOUSE_ENTER: {
- grab_focus();
+ //grab_focus();
} break;
- case NOTIFICATION_MOUSE_EXIT: {
+ case NOTIFICATION_WM_MOUSE_EXIT: {
if (mouse_over >= 0 && (items[mouse_over].submenu == "" || submenu_over != -1)) {
mouse_over = -1;
- update();
+ control->update();
}
} break;
case NOTIFICATION_POST_POPUP: {
- initial_button_mask = Input::get_singleton()->get_mouse_button_mask();
+ initial_button_mask = InputFilter::get_singleton()->get_mouse_button_mask();
during_grabbed_click = (bool)initial_button_mask;
} break;
- case NOTIFICATION_POPUP_HIDE: {
+ case NOTIFICATION_WM_SIZE_CHANGED: {
- if (mouse_over >= 0) {
- mouse_over = -1;
- update();
+ } break;
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ //only used when using operating system windows
+ if (get_window_id() != DisplayServer::INVALID_WINDOW_ID && autohide_areas.size()) {
+ Point2 mouse_pos = DisplayServer::get_singleton()->mouse_get_position();
+ mouse_pos -= get_position();
+
+ for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
+
+ if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E->get().has_point(mouse_pos)) {
+ _close_pressed();
+ return;
+ }
+ }
}
+ } break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
- for (int i = 0; i < items.size(); i++) {
- if (items[i].submenu == "")
- continue;
+ if (!is_visible()) {
+ if (mouse_over >= 0) {
+ mouse_over = -1;
+ control->update();
+ }
+
+ for (int i = 0; i < items.size(); i++) {
+ if (items[i].submenu == "")
+ continue;
- Node *n = get_node(items[i].submenu);
- if (!n)
- continue;
+ Node *n = get_node(items[i].submenu);
+ if (!n)
+ continue;
- PopupMenu *pm = Object::cast_to<PopupMenu>(n);
- if (!pm || !pm->is_visible())
- continue;
+ PopupMenu *pm = Object::cast_to<PopupMenu>(n);
+ if (!pm || !pm->is_visible())
+ continue;
- pm->hide();
+ pm->hide();
+ }
+
+ set_process_internal(false);
+ } else {
+ if (get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ set_process_internal(true);
+ }
}
} break;
}
@@ -648,8 +663,8 @@ void PopupMenu::add_item(const String &p_label, int p_id, uint32_t p_accel) {
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) {
@@ -658,8 +673,8 @@ void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_labe
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.icon = p_icon;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_check_item(const String &p_label, int p_id, uint32_t p_accel) {
@@ -668,8 +683,8 @@ void PopupMenu::add_check_item(const String &p_label, int p_id, uint32_t p_accel
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) {
@@ -679,8 +694,8 @@ void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String &
item.icon = p_icon;
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_radio_check_item(const String &p_label, int p_id, uint32_t p_accel) {
@@ -689,8 +704,8 @@ void PopupMenu::add_radio_check_item(const String &p_label, int p_id, uint32_t p
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) {
@@ -700,8 +715,8 @@ void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const St
item.icon = p_icon;
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int p_default_state, int p_id, uint32_t p_accel) {
@@ -711,8 +726,8 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
item.max_states = p_max_states;
item.state = p_default_state;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
#define ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global) \
@@ -729,8 +744,8 @@ void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_g
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
@@ -739,8 +754,8 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortC
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
@@ -749,8 +764,8 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bo
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
@@ -760,8 +775,8 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<
item.icon = p_icon;
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
@@ -770,8 +785,8 @@ void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
@@ -781,8 +796,8 @@ void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, cons
item.icon = p_icon;
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, int p_id) {
@@ -793,8 +808,8 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
item.id = p_id == -1 ? items.size() : p_id;
item.submenu = p_submenu;
items.push_back(item);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
#undef ITEM_SETUP_WITH_ACCEL
@@ -808,16 +823,16 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) {
items.write[p_idx].text = p_text;
items.write[p_idx].xl_text = tr(p_text);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].icon = p_icon;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
@@ -825,16 +840,16 @@ void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
items.write[p_idx].checked = p_checked;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_id(int p_idx, int p_id) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].id = p_id;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
@@ -842,40 +857,40 @@ void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].accel = p_accel;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].metadata = p_meta;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].disabled = p_disabled;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].submenu = p_submenu;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::toggle_item_checked(int p_idx) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checked = !items[p_idx].checked;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
String PopupMenu::get_item_text(int p_idx) const {
@@ -968,7 +983,7 @@ void PopupMenu::set_item_as_separator(int p_idx, bool p_separator) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].separator = p_separator;
- update();
+ control->update();
}
bool PopupMenu::is_item_separator(int p_idx) const {
@@ -980,21 +995,21 @@ void PopupMenu::set_item_as_checkable(int p_idx, bool p_checkable) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checkable_type = p_checkable ? Item::CHECKABLE_TYPE_CHECK_BOX : Item::CHECKABLE_TYPE_NONE;
- update();
+ control->update();
}
void PopupMenu::set_item_as_radio_checkable(int p_idx, bool p_radio_checkable) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checkable_type = p_radio_checkable ? Item::CHECKABLE_TYPE_RADIO_BUTTON : Item::CHECKABLE_TYPE_NONE;
- update();
+ control->update();
}
void PopupMenu::set_item_tooltip(int p_idx, const String &p_tooltip) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].tooltip = p_tooltip;
- update();
+ control->update();
}
void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bool p_global) {
@@ -1009,29 +1024,29 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bo
_ref_shortcut(items[p_idx].shortcut);
}
- update();
+ control->update();
}
void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].h_ofs = p_offset;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::set_item_multistate(int p_idx, int p_state) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].state = p_state;
- update();
+ control->update();
}
void PopupMenu::set_item_shortcut_disabled(int p_idx, bool p_disabled) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].shortcut_is_disabled = p_disabled;
- update();
+ control->update();
}
void PopupMenu::toggle_item_multistate(int p_idx) {
@@ -1045,7 +1060,7 @@ void PopupMenu::toggle_item_multistate(int p_idx) {
if (items.write[p_idx].max_states <= items[p_idx].state)
items.write[p_idx].state = 0;
- update();
+ control->update();
}
bool PopupMenu::is_item_checkable(int p_idx) const {
@@ -1177,8 +1192,8 @@ void PopupMenu::remove_item(int p_idx) {
}
items.remove(p_idx);
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
void PopupMenu::add_separator(const String &p_text) {
@@ -1191,7 +1206,7 @@ void PopupMenu::add_separator(const String &p_text) {
sep.xl_text = tr(p_text);
}
items.push_back(sep);
- update();
+ control->update();
}
void PopupMenu::clear() {
@@ -1203,8 +1218,8 @@ void PopupMenu::clear() {
}
items.clear();
mouse_over = -1;
- update();
- minimum_size_changed();
+ control->update();
+ child_controls_changed();
}
Array PopupMenu::_get_items() const {
@@ -1345,16 +1360,6 @@ bool PopupMenu::get_allow_search() const {
return allow_search;
}
-void PopupMenu::set_hide_on_window_lose_focus(bool p_enabled) {
-
- hide_on_window_lose_focus = p_enabled;
-}
-
-bool PopupMenu::is_hide_on_window_lose_focus() const {
-
- return hide_on_window_lose_focus;
-}
-
String PopupMenu::get_tooltip(const Point2 &p_pos) const {
int over = _get_mouse_over(p_pos);
@@ -1387,6 +1392,14 @@ void PopupMenu::clear_autohide_areas() {
autohide_areas.clear();
}
+void PopupMenu::take_mouse_focus() {
+ ERR_FAIL_COND(!is_inside_tree());
+
+ if (get_parent()) {
+ get_parent()->get_viewport()->pass_mouse_focus_to(this, control);
+ }
+}
+
void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &PopupMenu::_gui_input);
@@ -1466,9 +1479,6 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_submenu_popup_delay", "seconds"), &PopupMenu::set_submenu_popup_delay);
ClassDB::bind_method(D_METHOD("get_submenu_popup_delay"), &PopupMenu::get_submenu_popup_delay);
- ClassDB::bind_method(D_METHOD("set_hide_on_window_lose_focus", "enable"), &PopupMenu::set_hide_on_window_lose_focus);
- ClassDB::bind_method(D_METHOD("is_hide_on_window_lose_focus"), &PopupMenu::is_hide_on_window_lose_focus);
-
ClassDB::bind_method(D_METHOD("set_allow_search", "allow"), &PopupMenu::set_allow_search);
ClassDB::bind_method(D_METHOD("get_allow_search"), &PopupMenu::get_allow_search);
@@ -1486,7 +1496,6 @@ void PopupMenu::_bind_methods() {
void PopupMenu::popup(const Rect2 &p_bounds) {
- grab_click_focus();
moved = Vector2();
invalidated_click = true;
Popup::popup(p_bounds);
@@ -1494,6 +1503,13 @@ void PopupMenu::popup(const Rect2 &p_bounds) {
PopupMenu::PopupMenu() {
+ control = memnew(Control);
+ add_child(control);
+
+ control->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ connect("window_input", callable_mp(this, &PopupMenu::_gui_input));
+ control->connect("draw", callable_mp(this, &PopupMenu::_draw));
+
mouse_over = -1;
submenu_over = -1;
initial_button_mask = 0;
@@ -1503,12 +1519,9 @@ PopupMenu::PopupMenu() {
search_time_msec = 0;
search_string = "";
- set_focus_mode(FOCUS_ALL);
- set_as_toplevel(true);
set_hide_on_item_selection(true);
set_hide_on_checkable_item_selection(true);
set_hide_on_multistate_item_selection(false);
- set_hide_on_window_lose_focus(true);
submenu_timer = memnew(Timer);
submenu_timer->set_wait_time(0.3);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index a3a858cfde..2eef1f009d 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -32,6 +32,7 @@
#define POPUP_MENU_H
#include "scene/gui/popup.h"
+#include "scene/gui/shortcut.h"
class PopupMenu : public Popup {
@@ -87,7 +88,7 @@ class PopupMenu : public Popup {
Rect2 parent_rect;
String _get_accel_text(int p_item) const;
int _get_mouse_over(const Point2 &p_over) const;
- virtual Size2 get_minimum_size() const;
+ virtual Size2 _get_contents_minimum_size() const;
void _scroll(float p_factor, const Point2 &p_over);
void _gui_input(const Ref<InputEvent> &p_event);
void _activate_submenu(int over);
@@ -97,7 +98,6 @@ class PopupMenu : public Popup {
bool hide_on_item_selection;
bool hide_on_checkable_item_selection;
bool hide_on_multistate_item_selection;
- bool hide_on_window_lose_focus;
Vector2 moved;
Array _get_items() const;
@@ -112,9 +112,11 @@ class PopupMenu : public Popup {
uint64_t search_time_msec;
String search_string;
-protected:
- virtual bool has_point(const Point2 &p_point) const;
+ Control *control;
+
+ void _draw();
+protected:
friend class MenuButton;
void _notification(int p_what);
static void _bind_methods();
@@ -213,8 +215,7 @@ public:
virtual void popup(const Rect2 &p_bounds = Rect2());
- void set_hide_on_window_lose_focus(bool p_enabled);
- bool is_hide_on_window_lose_focus() const;
+ void take_mouse_focus();
PopupMenu();
~PopupMenu();
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index e11295d7e7..362c45453d 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -32,9 +32,9 @@
Size2 ProgressBar::get_minimum_size() const {
- Ref<StyleBox> bg = get_stylebox("bg");
- Ref<StyleBox> fg = get_stylebox("fg");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> bg = get_theme_stylebox("bg");
+ Ref<StyleBox> fg = get_theme_stylebox("fg");
+ Ref<Font> font = get_theme_font("font");
Size2 minimum_size = bg->get_minimum_size();
minimum_size.height = MAX(minimum_size.height, fg->get_minimum_size().height);
@@ -52,10 +52,10 @@ void ProgressBar::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<StyleBox> bg = get_stylebox("bg");
- Ref<StyleBox> fg = get_stylebox("fg");
- Ref<Font> font = get_font("font");
- Color font_color = get_color("font_color");
+ Ref<StyleBox> bg = get_theme_stylebox("bg");
+ Ref<StyleBox> fg = get_theme_stylebox("fg");
+ Ref<Font> font = get_theme_font("font");
+ Color font_color = get_theme_color("font_color");
draw_style_box(bg, Rect2(Point2(), get_size()));
float r = get_as_ratio();
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index bc1510d6f6..d17eec4050 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -34,6 +34,7 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "scene/scene_string_names.h"
+#include "servers/display_server.h"
#include "modules/modules_enabled.gen.h"
#ifdef MODULE_REGEX_ENABLED
@@ -142,7 +143,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) {
}
Rect2 RichTextLabel::_get_text_rect() {
- Ref<StyleBox> style = get_stylebox("normal");
+ Ref<StyleBox> style = get_theme_stylebox("normal");
return Rect2(style->get_offset(), get_size() - style->get_minimum_size());
}
@@ -240,7 +241,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
l.space_caches.push_back(spaces); \
} \
line_wrapped = false; \
- y += line_height + get_constant(SceneStringNames::get_singleton()->line_separation); \
+ y += line_height + get_theme_constant(SceneStringNames::get_singleton()->line_separation); \
line_height = 0; \
line_ascent = 0; \
line_descent = 0; \
@@ -305,8 +306,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
Color selection_bg;
if (p_mode == PROCESS_DRAW) {
- selection_fg = get_color("font_color_selected");
- selection_bg = get_color("selection_color");
+ selection_fg = get_theme_color("font_color_selected");
+ selection_bg = get_theme_color("selection_color");
}
int rchar = 0;
@@ -602,7 +603,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
#ifdef TOOLS_ENABLED
underline_width *= EDSCALE;
#endif
- VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width);
+ RS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width);
} else if (strikethrough) {
Color uc = color;
uc.a *= 0.5;
@@ -611,7 +612,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
#ifdef TOOLS_ENABLED
strikethrough_width *= EDSCALE;
#endif
- VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width);
+ RS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width);
}
}
@@ -667,13 +668,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
lh = 0;
ItemTable *table = static_cast<ItemTable *>(it);
- int hseparation = get_constant("table_hseparation");
- int vseparation = get_constant("table_vseparation");
+ int hseparation = get_theme_constant("table_hseparation");
+ int vseparation = get_theme_constant("table_vseparation");
Color ccolor = _find_color(table, p_base_color);
Vector2 draw_ofs = Point2(wofs, y);
- Color font_color_shadow = get_color("font_color_shadow");
- bool use_outline = get_constant("shadow_as_outline");
- Point2 shadow_ofs2(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
+ Color font_color_shadow = get_theme_color("font_color_shadow");
+ bool use_outline = get_theme_constant("shadow_as_outline");
+ Point2 shadow_ofs2(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y"));
if (p_mode == PROCESS_CACHE) {
@@ -987,12 +988,12 @@ void RichTextLabel::_notification(int p_what) {
Size2 size = get_size();
Rect2 text_rect = _get_text_rect();
- draw_style_box(get_stylebox("normal"), Rect2(Point2(), size));
+ draw_style_box(get_theme_stylebox("normal"), Rect2(Point2(), size));
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);
+ RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
+ draw_style_box(get_theme_stylebox("focus"), Rect2(Point2(), size));
+ RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, false);
}
int ofs = vscroll->get_value();
@@ -1012,11 +1013,11 @@ void RichTextLabel::_notification(int p_what) {
if (from_line >= main->lines.size())
break; //nothing to draw
int y = (main->lines[from_line].height_accum_cache - main->lines[from_line].height_cache) - ofs;
- Ref<Font> base_font = get_font("normal_font");
- Color base_color = get_color("default_color");
- Color font_color_shadow = get_color("font_color_shadow");
- bool use_outline = get_constant("shadow_as_outline");
- Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
+ Ref<Font> base_font = get_theme_font("normal_font");
+ Color base_color = get_theme_color("default_color");
+ Color font_color_shadow = get_theme_color("font_color_shadow");
+ bool use_outline = get_theme_constant("shadow_as_outline");
+ Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y"));
visible_line_count = 0;
while (y < size.height && from_line < main->lines.size()) {
@@ -1043,9 +1044,9 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
Rect2 text_rect = _get_text_rect();
int ofs = vscroll->get_value();
- Color font_color_shadow = get_color("font_color_shadow");
- bool use_outline = get_constant("shadow_as_outline");
- Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
+ Color font_color_shadow = get_theme_color("font_color_shadow");
+ bool use_outline = get_theme_constant("shadow_as_outline");
+ Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y"));
//todo, change to binary search
int from_line = 0;
@@ -1061,8 +1062,8 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
return;
int y = (p_frame->lines[from_line].height_accum_cache - p_frame->lines[from_line].height_cache) - ofs;
- Ref<Font> base_font = get_font("normal_font");
- Color base_color = get_color("default_color");
+ Ref<Font> base_font = get_theme_font("normal_font");
+ Color base_color = get_theme_color("default_color");
while (y < text_rect.get_size().height && from_line < p_frame->lines.size()) {
@@ -1227,14 +1228,14 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
case KEY_UP: {
if (vscroll->is_visible_in_tree()) {
- vscroll->set_value(vscroll->get_value() - get_font("normal_font")->get_height());
+ vscroll->set_value(vscroll->get_value() - get_theme_font("normal_font")->get_height());
handled = true;
}
} break;
case KEY_DOWN: {
if (vscroll->is_visible_in_tree()) {
- vscroll->set_value(vscroll->get_value() + get_font("normal_font")->get_height());
+ vscroll->set_value(vscroll->get_value() + get_theme_font("normal_font")->get_height());
handled = true;
}
} break;
@@ -1525,11 +1526,11 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
size.width = fixed_width;
}
Rect2 text_rect = _get_text_rect();
- Color font_color_shadow = get_color("font_color_shadow");
- bool use_outline = get_constant("shadow_as_outline");
- Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
+ Color font_color_shadow = get_theme_color("font_color_shadow");
+ bool use_outline = get_theme_constant("shadow_as_outline");
+ Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y"));
- Ref<Font> base_font = get_font("normal_font");
+ Ref<Font> base_font = get_theme_font("normal_font");
for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) {
@@ -1544,7 +1545,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
int total_height = 0;
if (p_frame->lines.size())
- total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
+ total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache + get_theme_stylebox("normal")->get_minimum_size().height;
main->first_invalid_line = p_frame->lines.size();
@@ -1646,6 +1647,10 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline)
p_item->line = current_frame->lines.size() - 1;
_invalidate_current_line(current_frame);
+
+ if (fixed_width != -1) {
+ minimum_size_changed();
+ }
}
void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_subitem_line) {
@@ -1758,35 +1763,35 @@ void RichTextLabel::push_font(const Ref<Font> &p_font) {
}
void RichTextLabel::push_normal() {
- Ref<Font> normal_font = get_font("normal_font");
+ Ref<Font> normal_font = get_theme_font("normal_font");
ERR_FAIL_COND(normal_font.is_null());
push_font(normal_font);
}
void RichTextLabel::push_bold() {
- Ref<Font> bold_font = get_font("bold_font");
+ Ref<Font> bold_font = get_theme_font("bold_font");
ERR_FAIL_COND(bold_font.is_null());
push_font(bold_font);
}
void RichTextLabel::push_bold_italics() {
- Ref<Font> bold_italics_font = get_font("bold_italics_font");
+ Ref<Font> bold_italics_font = get_theme_font("bold_italics_font");
ERR_FAIL_COND(bold_italics_font.is_null());
push_font(bold_italics_font);
}
void RichTextLabel::push_italics() {
- Ref<Font> italics_font = get_font("italics_font");
+ Ref<Font> italics_font = get_theme_font("italics_font");
ERR_FAIL_COND(italics_font.is_null());
push_font(italics_font);
}
void RichTextLabel::push_mono() {
- Ref<Font> mono_font = get_font("mono_font");
+ Ref<Font> mono_font = get_theme_font("mono_font");
ERR_FAIL_COND(mono_font.is_null());
push_font(mono_font);
@@ -1967,6 +1972,10 @@ void RichTextLabel::clear() {
selection.click = NULL;
selection.active = false;
current_idx = 1;
+
+ if (fixed_width != -1) {
+ minimum_size_changed();
+ }
}
void RichTextLabel::set_tab_size(int p_spaces) {
@@ -2044,13 +2053,13 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
int pos = 0;
List<String> tag_stack;
- Ref<Font> normal_font = get_font("normal_font");
- Ref<Font> bold_font = get_font("bold_font");
- Ref<Font> italics_font = get_font("italics_font");
- Ref<Font> bold_italics_font = get_font("bold_italics_font");
- Ref<Font> mono_font = get_font("mono_font");
+ Ref<Font> normal_font = get_theme_font("normal_font");
+ Ref<Font> bold_font = get_theme_font("bold_font");
+ Ref<Font> italics_font = get_theme_font("italics_font");
+ Ref<Font> bold_italics_font = get_theme_font("bold_italics_font");
+ Ref<Font> mono_font = get_theme_font("mono_font");
- Color base_color = get_color("default_color");
+ Color base_color = get_theme_color("default_color");
int indent_level = 0;
@@ -2507,7 +2516,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
if (it->type == ITEM_TEXT) {
ItemText *t = static_cast<ItemText *>(it);
- int sp = t->text.find(p_string, charidx);
+ int sp = t->text.findn(p_string, charidx);
if (sp != -1) {
selection.from = it;
selection.from_char = sp;
@@ -2518,7 +2527,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
_validate_line_caches(main);
- int fh = _find_font(t).is_valid() ? _find_font(t)->get_height() : get_font("normal_font")->get_height();
+ int fh = _find_font(t).is_valid() ? _find_font(t)->get_height() : get_theme_font("normal_font")->get_height();
float offset = 0;
@@ -2584,7 +2593,7 @@ void RichTextLabel::selection_copy() {
}
if (text != "") {
- OS::get_singleton()->set_clipboard(text);
+ DisplayServer::get_singleton()->clipboard_set(text);
}
}
@@ -2692,7 +2701,7 @@ void RichTextLabel::install_effect(const Variant effect) {
int RichTextLabel::get_content_height() {
int total_height = 0;
if (main->lines.size())
- total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
+ total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_theme_stylebox("normal")->get_minimum_size().height;
return total_height;
}
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index fef5e00984..5e9541730e 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -33,6 +33,7 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/print_string.h"
+#include "scene/main/window.h"
bool ScrollBar::focus_by_default = false;
@@ -71,8 +72,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (b->is_pressed()) {
double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x;
- Ref<Texture2D> decr = get_icon("decrement");
- Ref<Texture2D> incr = get_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
+ Ref<Texture2D> incr = get_theme_icon("increment");
double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width();
@@ -148,7 +149,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (drag.active) {
double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x;
- Ref<Texture2D> decr = get_icon("decrement");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
ofs -= decr_size;
@@ -159,8 +160,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
} else {
double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x;
- Ref<Texture2D> decr = get_icon("decrement");
- Ref<Texture2D> incr = get_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
+ Ref<Texture2D> incr = get_theme_icon("increment");
double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width();
@@ -233,17 +234,17 @@ void ScrollBar::_notification(int p_what) {
RID ci = get_canvas_item();
- Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement");
- Ref<Texture2D> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment");
- Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll");
+ Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_theme_icon("decrement_highlight") : get_theme_icon("decrement");
+ Ref<Texture2D> incr = highlight == HIGHLIGHT_INCR ? get_theme_icon("increment_highlight") : get_theme_icon("increment");
+ Ref<StyleBox> bg = has_focus() ? get_theme_stylebox("scroll_focus") : get_theme_stylebox("scroll");
Ref<StyleBox> grabber;
if (drag.active)
- grabber = get_stylebox("grabber_pressed");
+ grabber = get_theme_stylebox("grabber_pressed");
else if (highlight == HIGHLIGHT_RANGE)
- grabber = get_stylebox("grabber_highlight");
+ grabber = get_theme_stylebox("grabber_highlight");
else
- grabber = get_stylebox("grabber");
+ grabber = get_theme_stylebox("grabber");
Point2 ofs;
@@ -416,7 +417,7 @@ void ScrollBar::_notification(int p_what) {
double ScrollBar::get_grabber_min_size() const {
- Ref<StyleBox> grabber = get_stylebox("grabber");
+ Ref<StyleBox> grabber = get_theme_stylebox("grabber");
Size2 gminsize = grabber->get_minimum_size() + grabber->get_center_size();
return (orientation == VERTICAL) ? gminsize.height : gminsize.width;
}
@@ -442,17 +443,17 @@ double ScrollBar::get_area_size() const {
switch (orientation) {
case VERTICAL: {
double area = get_size().height;
- area -= get_stylebox("scroll")->get_minimum_size().height;
- area -= get_icon("increment")->get_height();
- area -= get_icon("decrement")->get_height();
+ area -= get_theme_stylebox("scroll")->get_minimum_size().height;
+ area -= get_theme_icon("increment")->get_height();
+ area -= get_theme_icon("decrement")->get_height();
area -= get_grabber_min_size();
return area;
} break;
case HORIZONTAL: {
double area = get_size().width;
- area -= get_stylebox("scroll")->get_minimum_size().width;
- area -= get_icon("increment")->get_width();
- area -= get_icon("decrement")->get_width();
+ area -= get_theme_stylebox("scroll")->get_minimum_size().width;
+ area -= get_theme_icon("increment")->get_width();
+ area -= get_theme_icon("decrement")->get_width();
area -= get_grabber_min_size();
return area;
} break;
@@ -468,14 +469,14 @@ double ScrollBar::get_area_offset() const {
if (orientation == VERTICAL) {
- ofs += get_stylebox("hscroll")->get_margin(MARGIN_TOP);
- ofs += get_icon("decrement")->get_height();
+ ofs += get_theme_stylebox("hscroll")->get_margin(MARGIN_TOP);
+ ofs += get_theme_icon("decrement")->get_height();
}
if (orientation == HORIZONTAL) {
- ofs += get_stylebox("hscroll")->get_margin(MARGIN_LEFT);
- ofs += get_icon("decrement")->get_width();
+ ofs += get_theme_stylebox("hscroll")->get_margin(MARGIN_LEFT);
+ ofs += get_theme_icon("decrement")->get_width();
}
return ofs;
@@ -500,9 +501,9 @@ double ScrollBar::get_grabber_offset() const {
Size2 ScrollBar::get_minimum_size() const {
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
- Ref<StyleBox> bg = get_stylebox("scroll");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
+ Ref<StyleBox> bg = get_theme_stylebox("scroll");
Size2 minsize;
if (orientation == VERTICAL) {
@@ -559,8 +560,7 @@ void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
drag_node_accum = Vector2();
last_drag_node_accum = Vector2();
drag_node_from = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
-
- drag_node_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_node_touching = !DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id()));
drag_node_touching_deaccel = false;
time_since_motion = 0;
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index c25a6d5a0c..fb17adf96e 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -30,7 +30,7 @@
#include "scroll_container.h"
#include "core/os/os.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
bool ScrollContainer::clips_input() const {
@@ -39,7 +39,7 @@ bool ScrollContainer::clips_input() const {
Size2 ScrollContainer::get_minimum_size() const {
- Ref<StyleBox> sb = get_stylebox("bg");
+ Ref<StyleBox> sb = get_theme_stylebox("bg");
Size2 min_size;
for (int i = 0; i < get_child_count(); i++) {
@@ -129,7 +129,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll)
accept_event(); //accept event if scroll changed
- if (!OS::get_singleton()->has_touchscreen_ui_hint())
+ if (!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())))
return;
if (mb->get_button_index() != BUTTON_LEFT)
@@ -145,7 +145,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
drag_accum = Vector2();
last_drag_accum = Vector2();
drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value());
- drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_touching = !DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id()));
drag_touching_deaccel = false;
beyond_deadzone = false;
time_since_motion = 0;
@@ -276,7 +276,7 @@ void ScrollContainer::_notification(int p_what) {
Size2 size = get_size();
Point2 ofs;
- Ref<StyleBox> sb = get_stylebox("bg");
+ Ref<StyleBox> sb = get_theme_stylebox("bg");
size -= sb->get_minimum_size();
ofs += sb->get_offset();
@@ -323,7 +323,7 @@ void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<StyleBox> sb = get_stylebox("bg");
+ Ref<StyleBox> sb = get_theme_stylebox("bg");
draw_style_box(sb, Rect2(Vector2(), get_size()));
update_scrollbars();
@@ -404,7 +404,7 @@ void ScrollContainer::_notification(int p_what) {
void ScrollContainer::update_scrollbars() {
Size2 size = get_size();
- Ref<StyleBox> sb = get_stylebox("bg");
+ Ref<StyleBox> sb = get_theme_stylebox("bg");
size -= sb->get_minimum_size();
Size2 hmin;
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 4635efb233..75c4b7cce9 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -34,9 +34,9 @@ Size2 Separator::get_minimum_size() const {
Size2 ms(3, 3);
if (orientation == VERTICAL) {
- ms.x = get_constant("separation");
+ ms.x = get_theme_constant("separation");
} else { // HORIZONTAL
- ms.y = get_constant("separation");
+ ms.y = get_theme_constant("separation");
}
return ms;
}
@@ -48,7 +48,7 @@ void Separator::_notification(int p_what) {
case NOTIFICATION_DRAW: {
Size2i size = get_size();
- Ref<StyleBox> style = get_stylebox("separator");
+ Ref<StyleBox> style = get_theme_stylebox("separator");
Size2i ssize = style->get_minimum_size() + style->get_center_size();
if (orientation == VERTICAL) {
diff --git a/scene/gui/shortcut.h b/scene/gui/shortcut.h
index 59d3245db5..b22c3441c5 100644
--- a/scene/gui/shortcut.h
+++ b/scene/gui/shortcut.h
@@ -31,7 +31,7 @@
#ifndef SHORTCUT_H
#define SHORTCUT_H
-#include "core/os/input_event.h"
+#include "core/input/input_event.h"
#include "core/resource.h"
class ShortCut : public Resource {
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 85887ef7b1..e47e2b869d 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -33,10 +33,10 @@
Size2 Slider::get_minimum_size() const {
- Ref<StyleBox> style = get_stylebox("slider");
+ Ref<StyleBox> style = get_theme_stylebox("slider");
Size2i ss = style->get_minimum_size() + style->get_center_size();
- Ref<Texture2D> grabber = get_icon("grabber");
+ Ref<Texture2D> grabber = get_theme_icon("grabber");
Size2i rs = grabber->get_size();
if (orientation == HORIZONTAL)
@@ -57,7 +57,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) {
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
- Ref<Texture2D> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber");
+ Ref<Texture2D> grabber = get_theme_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber");
grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x;
double grab_width = (double)grabber->get_size().width;
@@ -87,7 +87,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) {
if (grab.active) {
Size2i size = get_size();
- Ref<Texture2D> grabber = get_icon("grabber");
+ Ref<Texture2D> grabber = get_theme_icon("grabber");
float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos;
if (orientation == VERTICAL)
motion = -motion;
@@ -165,10 +165,10 @@ void Slider::_notification(int p_what) {
case NOTIFICATION_DRAW: {
RID ci = get_canvas_item();
Size2i size = get_size();
- Ref<StyleBox> style = get_stylebox("slider");
- Ref<StyleBox> grabber_area = get_stylebox("grabber_area");
- Ref<Texture2D> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
- Ref<Texture2D> tick = get_icon("tick");
+ Ref<StyleBox> style = get_theme_stylebox("slider");
+ Ref<StyleBox> grabber_area = get_theme_stylebox("grabber_area");
+ Ref<Texture2D> grabber = get_theme_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
+ Ref<Texture2D> tick = get_theme_icon("tick");
double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio();
if (orientation == VERTICAL) {
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 576de98a4f..ccfa8ebf63 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -29,8 +29,9 @@
/*************************************************************************/
#include "spin_box.h"
+
+#include "core/input/input_filter.h"
#include "core/math/expression.h"
-#include "core/os/input.h"
Size2 SpinBox::get_minimum_size() const {
@@ -76,7 +77,7 @@ void SpinBox::_line_edit_input(const Ref<InputEvent> &p_event) {
void SpinBox::_range_click_timeout() {
- if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (!drag.enabled && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
bool up = get_local_mouse_position().y < (get_size().height / 2);
set_value(get_value() + (up ? get_step() : -get_step()));
@@ -148,7 +149,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
if (drag.enabled) {
drag.enabled = false;
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
warp_mouse(drag.capture_pos);
}
drag.allowed = false;
@@ -165,7 +166,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
set_value(CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max()));
} else if (drag.allowed && drag.capture_pos.distance_to(mm->get_position()) > 2) {
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_CAPTURED);
drag.enabled = true;
drag.base_val = get_value();
drag.diff_y = 0;
@@ -195,7 +196,7 @@ void SpinBox::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture2D> updown = get_icon("updown");
+ Ref<Texture2D> updown = get_theme_icon("updown");
_adjust_width_for_icon(updown);
@@ -209,7 +210,7 @@ void SpinBox::_notification(int p_what) {
//_value_changed(0);
} else if (p_what == NOTIFICATION_ENTER_TREE) {
- _adjust_width_for_icon(get_icon("updown"));
+ _adjust_width_for_icon(get_theme_icon("updown"));
_value_changed(0);
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 255278be2b..4eb614a9ac 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -74,8 +74,8 @@ void SplitContainer::_resort() {
bool second_expanded = (vertical ? second->get_v_size_flags() : second->get_h_size_flags()) & SIZE_EXPAND;
// Determine the separation between items
- Ref<Texture2D> g = get_icon("grabber");
- int sep = get_constant("separation");
+ Ref<Texture2D> g = get_theme_icon("grabber");
+ int sep = get_theme_constant("separation");
sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0;
// Compute the minimum size
@@ -123,8 +123,8 @@ Size2 SplitContainer::get_minimum_size() const {
/* Calculate MINIMUM SIZE */
Size2i minimum;
- Ref<Texture2D> g = get_icon("grabber");
- int sep = get_constant("separation");
+ Ref<Texture2D> g = get_theme_icon("grabber");
+ int sep = get_theme_constant("separation");
sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0;
for (int i = 0; i < 2; i++) {
@@ -167,7 +167,7 @@ void SplitContainer::_notification(int p_what) {
case NOTIFICATION_MOUSE_EXIT: {
mouse_inside = false;
- if (get_constant("autohide"))
+ if (get_theme_constant("autohide"))
update();
} break;
case NOTIFICATION_DRAW: {
@@ -175,14 +175,14 @@ void SplitContainer::_notification(int p_what) {
if (!_getch(0) || !_getch(1))
return;
- if (collapsed || (!dragging && !mouse_inside && get_constant("autohide")))
+ if (collapsed || (!dragging && !mouse_inside && get_theme_constant("autohide")))
return;
if (dragger_visibility != DRAGGER_VISIBLE)
return;
- int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_constant("separation") : 0;
- Ref<Texture2D> tex = get_icon("grabber");
+ int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_theme_constant("separation") : 0;
+ Ref<Texture2D> tex = get_theme_icon("grabber");
Size2 size = get_size();
if (vertical)
@@ -210,7 +210,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
if (mb->is_pressed()) {
- int sep = get_constant("separation");
+ int sep = get_theme_constant("separation");
if (vertical) {
@@ -242,14 +242,14 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
bool mouse_inside_state = false;
if (vertical)
- mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_constant("separation");
+ mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_theme_constant("separation");
else
- mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_constant("separation");
+ mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_theme_constant("separation");
if (mouse_inside != mouse_inside_state) {
mouse_inside = mouse_inside_state;
- if (get_constant("autohide"))
+ if (get_theme_constant("autohide"))
update();
}
@@ -270,7 +270,7 @@ Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const
if (!collapsed && _getch(0) && _getch(1) && dragger_visibility == DRAGGER_VISIBLE) {
- int sep = get_constant("separation");
+ int sep = get_theme_constant("separation");
if (vertical) {
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 6290d364fc..7cecbf7fa2 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -41,14 +41,14 @@ int TabContainer::_get_top_margin() const {
return 0;
// Respect the minimum tab height.
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
int tab_height = MAX(MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height), tab_disabled->get_minimum_size().height);
// Font height or higher icon wins.
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
int content_height = font->get_height();
Vector<Control *> tabs = _get_tabs();
@@ -81,15 +81,15 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
return;
// Handle menu button.
- Ref<Texture2D> menu = get_icon("menu");
+ Ref<Texture2D> menu = get_theme_icon("menu");
if (popup && pos.x > size.width - menu->get_width()) {
emit_signal("pre_popup_pressed");
- Vector2 popup_pos = get_global_position();
- popup_pos.x += size.width * get_global_transform().get_scale().x - popup->get_size().width * popup->get_global_transform().get_scale().x;
- popup_pos.y += menu->get_height() * get_global_transform().get_scale().y;
+ Vector2 popup_pos = get_screen_position();
+ popup_pos.x += size.width - popup->get_size().width;
+ popup_pos.y += menu->get_height();
- popup->set_global_position(popup_pos);
+ popup->set_position(popup_pos);
popup->popup();
return;
}
@@ -107,8 +107,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
popup_ofs = menu->get_width();
}
- Ref<Texture2D> increment = get_icon("increment");
- Ref<Texture2D> decrement = get_icon("decrement");
+ Ref<Texture2D> increment = get_theme_icon("increment");
+ Ref<Texture2D> decrement = get_theme_icon("decrement");
if (pos.x > size.width - increment->get_width() - popup_ofs) {
if (last_tab_cache < tabs.size() - 1) {
first_tab_cache += 1;
@@ -159,7 +159,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
return;
}
- Ref<Texture2D> menu = get_icon("menu");
+ Ref<Texture2D> menu = get_theme_icon("menu");
if (popup) {
if (pos.x >= size.width - menu->get_width()) {
@@ -191,8 +191,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
popup_ofs = menu->get_width();
}
- Ref<Texture2D> increment = get_icon("increment");
- Ref<Texture2D> decrement = get_icon("decrement");
+ Ref<Texture2D> increment = get_theme_icon("increment");
+ Ref<Texture2D> decrement = get_theme_icon("decrement");
if (pos.x >= size.width - increment->get_width() - popup_ofs) {
if (highlight_arrow != 1) {
@@ -224,10 +224,10 @@ void TabContainer::_notification(int p_what) {
case NOTIFICATION_RESIZED: {
Vector<Control *> tabs = _get_tabs();
- int side_margin = get_constant("side_margin");
- Ref<Texture2D> menu = get_icon("menu");
- Ref<Texture2D> increment = get_icon("increment");
- Ref<Texture2D> decrement = get_icon("decrement");
+ int side_margin = get_theme_constant("side_margin");
+ Ref<Texture2D> menu = get_theme_icon("menu");
+ Ref<Texture2D> increment = get_theme_icon("increment");
+ Ref<Texture2D> decrement = get_theme_icon("decrement");
int header_width = get_size().width - side_margin * 2;
// Find the width of the header area.
@@ -262,28 +262,28 @@ void TabContainer::_notification(int p_what) {
Size2 size = get_size();
// Draw only the tab area if the header is hidden.
- Ref<StyleBox> panel = get_stylebox("panel");
+ Ref<StyleBox> panel = get_theme_stylebox("panel");
if (!tabs_visible) {
panel->draw(canvas, Rect2(0, 0, size.width, size.height));
return;
}
Vector<Control *> tabs = _get_tabs();
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- Ref<Texture2D> increment = get_icon("increment");
- Ref<Texture2D> increment_hl = get_icon("increment_highlight");
- Ref<Texture2D> decrement = get_icon("decrement");
- Ref<Texture2D> decrement_hl = get_icon("decrement_highlight");
- Ref<Texture2D> menu = get_icon("menu");
- Ref<Texture2D> menu_hl = get_icon("menu_highlight");
- Ref<Font> font = get_font("font");
- Color font_color_fg = get_color("font_color_fg");
- Color font_color_bg = get_color("font_color_bg");
- Color font_color_disabled = get_color("font_color_disabled");
- int side_margin = get_constant("side_margin");
- int icon_text_distance = get_constant("hseparation");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
+ Ref<Texture2D> increment = get_theme_icon("increment");
+ Ref<Texture2D> increment_hl = get_theme_icon("increment_highlight");
+ Ref<Texture2D> decrement = get_theme_icon("decrement");
+ Ref<Texture2D> decrement_hl = get_theme_icon("decrement_highlight");
+ Ref<Texture2D> menu = get_theme_icon("menu");
+ Ref<Texture2D> menu_hl = get_theme_icon("menu_highlight");
+ Ref<Font> font = get_theme_font("font");
+ Color font_color_fg = get_theme_color("font_color_fg");
+ Color font_color_bg = get_theme_color("font_color_bg");
+ Color font_color_disabled = get_theme_color("font_color_disabled");
+ int side_margin = get_theme_constant("side_margin");
+ int icon_text_distance = get_theme_constant("hseparation");
// Find out start and width of the header area.
int header_x = side_margin;
@@ -458,7 +458,7 @@ int TabContainer::_get_tab_width(int p_index) const {
return 0;
// Get the width of the text displayed on the tab.
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int width = font->get_string_size(text).width;
@@ -468,14 +468,14 @@ int TabContainer::_get_tab_width(int p_index) const {
if (icon.is_valid()) {
width += icon->get_width();
if (text != "")
- width += get_constant("hseparation");
+ width += get_theme_constant("hseparation");
}
}
// Respect a minimum size.
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
if (get_tab_disabled(p_index)) {
width += tab_disabled->get_minimum_size().width;
} else if (p_index == current) {
@@ -530,7 +530,7 @@ void TabContainer::add_child_notify(Node *p_child) {
c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
if (tabs_visible)
c->set_margin(MARGIN_TOP, _get_top_margin());
- Ref<StyleBox> sb = get_stylebox("panel");
+ Ref<StyleBox> sb = get_theme_stylebox("panel");
c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
@@ -554,7 +554,7 @@ void TabContainer::set_current_tab(int p_current) {
int pending_previous = current;
current = p_current;
- Ref<StyleBox> sb = get_stylebox("panel");
+ Ref<StyleBox> sb = get_theme_stylebox("panel");
Vector<Control *> tabs = _get_tabs();
for (int i = 0; i < tabs.size(); i++) {
@@ -745,12 +745,12 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const {
int right_ofs = 0;
if (popup) {
- Ref<Texture2D> menu = get_icon("menu");
+ Ref<Texture2D> menu = get_theme_icon("menu");
right_ofs += menu->get_width();
}
if (buttons_visible_cache) {
- Ref<Texture2D> increment = get_icon("increment");
- Ref<Texture2D> decrement = get_icon("decrement");
+ Ref<Texture2D> increment = get_theme_icon("increment");
+ Ref<Texture2D> decrement = get_theme_icon("decrement");
right_ofs += increment->get_width() + decrement->get_width();
}
if (p_point.x > size.width - right_ofs) {
@@ -933,17 +933,17 @@ Size2 TabContainer::get_minimum_size() const {
ms.y = MAX(ms.y, cms.y);
}
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
+ Ref<Font> font = get_theme_font("font");
if (tabs_visible) {
ms.y += MAX(MAX(tab_bg->get_minimum_size().y, tab_fg->get_minimum_size().y), tab_disabled->get_minimum_size().y);
ms.y += font->get_height();
}
- Ref<StyleBox> sb = get_stylebox("panel");
+ Ref<StyleBox> sb = get_theme_stylebox("panel");
ms += sb->get_minimum_size();
return ms;
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 901408919a..ea6d44e3a7 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -37,10 +37,10 @@
Size2 Tabs::get_minimum_size() const {
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
+ Ref<Font> font = get_theme_font("font");
Size2 ms(0, MAX(MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height), tab_disabled->get_minimum_size().height) + font->get_height());
@@ -50,7 +50,7 @@ Size2 Tabs::get_minimum_size() const {
if (tex.is_valid()) {
ms.height = MAX(ms.height, tex->get_size().height);
if (tabs[i].text != "")
- ms.width += get_constant("hseparation");
+ ms.width += get_theme_constant("hseparation");
}
ms.width += Math::ceil(font->get_string_size(tabs[i].xl_text).width);
@@ -65,15 +65,15 @@ Size2 Tabs::get_minimum_size() const {
if (tabs[i].right_button.is_valid()) {
Ref<Texture2D> rb = tabs[i].right_button;
Size2 bms = rb->get_size();
- bms.width += get_constant("hseparation");
+ bms.width += get_theme_constant("hseparation");
ms.width += bms.width;
ms.height = MAX(bms.height + tab_bg->get_minimum_size().height, ms.height);
}
if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
- Ref<Texture2D> cb = get_icon("close");
+ Ref<Texture2D> cb = get_theme_icon("close");
Size2 bms = cb->get_size();
- bms.width += get_constant("hseparation");
+ bms.width += get_theme_constant("hseparation");
ms.width += bms.width;
ms.height = MAX(bms.height + tab_bg->get_minimum_size().height, ms.height);
}
@@ -94,8 +94,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
highlight_arrow = -1;
if (buttons_visible) {
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
int limit = get_size().width - incr->get_width() - decr->get_width();
@@ -163,8 +163,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
if (buttons_visible) {
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
int limit = get_size().width - incr->get_width() - decr->get_width();
@@ -238,14 +238,14 @@ void Tabs::_notification(int p_what) {
_update_cache();
RID ci = get_canvas_item();
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- Ref<Font> font = get_font("font");
- Color color_fg = get_color("font_color_fg");
- Color color_bg = get_color("font_color_bg");
- Color color_disabled = get_color("font_color_disabled");
- Ref<Texture2D> close = get_icon("close");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
+ Ref<Font> font = get_theme_font("font");
+ Color color_fg = get_theme_color("font_color_fg");
+ Color color_bg = get_theme_color("font_color_bg");
+ Color color_disabled = get_theme_color("font_color_disabled");
+ Ref<Texture2D> close = get_theme_icon("close");
int h = get_size().height;
int w = 0;
@@ -267,10 +267,10 @@ void Tabs::_notification(int p_what) {
w = 0;
}
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
- Ref<Texture2D> incr_hl = get_icon("increment_highlight");
- Ref<Texture2D> decr_hl = get_icon("decrement_highlight");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
+ Ref<Texture2D> incr_hl = get_theme_icon("increment_highlight");
+ Ref<Texture2D> decr_hl = get_theme_icon("decrement_highlight");
int limit = get_size().width - incr->get_size().width - decr->get_size().width;
@@ -318,7 +318,7 @@ void Tabs::_notification(int p_what) {
icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2));
if (tabs[i].text != "")
- w += icon->get_width() + get_constant("hseparation");
+ w += icon->get_width() + get_theme_constant("hseparation");
}
font->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), tabs[i].xl_text, col, tabs[i].size_text);
@@ -327,10 +327,10 @@ void Tabs::_notification(int p_what) {
if (tabs[i].right_button.is_valid()) {
- Ref<StyleBox> style = get_stylebox("button");
+ Ref<StyleBox> style = get_theme_stylebox("button");
Ref<Texture2D> rb = tabs[i].right_button;
- w += get_constant("hseparation");
+ w += get_theme_constant("hseparation");
Rect2 rb_rect;
rb_rect.size = style->get_minimum_size() + rb->get_size();
@@ -339,7 +339,7 @@ void Tabs::_notification(int p_what) {
if (rb_hover == i) {
if (rb_pressing)
- get_stylebox("button_pressed")->draw(ci, rb_rect);
+ get_theme_stylebox("button_pressed")->draw(ci, rb_rect);
else
style->draw(ci, rb_rect);
}
@@ -351,10 +351,10 @@ void Tabs::_notification(int p_what) {
if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
- Ref<StyleBox> style = get_stylebox("button");
+ Ref<StyleBox> style = get_theme_stylebox("button");
Ref<Texture2D> cb = close;
- w += get_constant("hseparation");
+ w += get_theme_constant("hseparation");
Rect2 cb_rect;
cb_rect.size = style->get_minimum_size() + cb->get_size();
@@ -363,7 +363,7 @@ void Tabs::_notification(int p_what) {
if (!tabs[i].disabled && cb_hover == i) {
if (cb_pressing)
- get_stylebox("button_pressed")->draw(ci, cb_rect);
+ get_theme_stylebox("button_pressed")->draw(ci, cb_rect);
else
style->draw(ci, cb_rect);
}
@@ -532,12 +532,12 @@ void Tabs::_update_hover() {
}
void Tabs::_update_cache() {
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<Font> font = get_font("font");
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<Font> font = get_theme_font("font");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
int limit = get_size().width - incr->get_width() - decr->get_width();
int w = 0;
@@ -577,12 +577,12 @@ void Tabs::_update_cache() {
slen = m_width - (sb->get_margin(MARGIN_LEFT) + sb->get_margin(MARGIN_RIGHT));
if (tabs[i].icon.is_valid()) {
slen -= tabs[i].icon->get_width();
- slen -= get_constant("hseparation");
+ slen -= get_theme_constant("hseparation");
}
if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
- Ref<Texture2D> cb = get_icon("close");
+ Ref<Texture2D> cb = get_theme_icon("close");
slen -= cb->get_width();
- slen -= get_constant("hseparation");
+ slen -= get_theme_constant("hseparation");
}
slen = MAX(slen, 1);
lsize = m_width;
@@ -799,10 +799,10 @@ int Tabs::get_tab_width(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0);
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
+ Ref<Font> font = get_theme_font("font");
int x = 0;
@@ -810,7 +810,7 @@ int Tabs::get_tab_width(int p_idx) const {
if (tex.is_valid()) {
x += tex->get_width();
if (tabs[p_idx].text != "")
- x += get_constant("hseparation");
+ x += get_theme_constant("hseparation");
}
x += Math::ceil(font->get_string_size(tabs[p_idx].xl_text).width);
@@ -825,13 +825,13 @@ int Tabs::get_tab_width(int p_idx) const {
if (tabs[p_idx].right_button.is_valid()) {
Ref<Texture2D> rb = tabs[p_idx].right_button;
x += rb->get_width();
- x += get_constant("hseparation");
+ x += get_theme_constant("hseparation");
}
if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && p_idx == current)) {
- Ref<Texture2D> cb = get_icon("close");
+ Ref<Texture2D> cb = get_theme_icon("close");
x += cb->get_width();
- x += get_constant("hseparation");
+ x += get_theme_constant("hseparation");
}
return x;
@@ -842,8 +842,8 @@ void Tabs::_ensure_no_over_offset() {
if (!is_inside_tree())
return;
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
int limit = get_size().width - incr->get_width() - decr->get_width();
@@ -885,8 +885,8 @@ void Tabs::ensure_tab_visible(int p_idx) {
}
int prev_offset = offset;
- Ref<Texture2D> incr = get_icon("increment");
- Ref<Texture2D> decr = get_icon("decrement");
+ Ref<Texture2D> incr = get_theme_icon("increment");
+ Ref<Texture2D> decr = get_theme_icon("decrement");
int limit = get_size().width - incr->get_width() - decr->get_width();
for (int i = offset; i <= p_idx; i++) {
if (tabs[i].ofs_cache + tabs[i].size_cache > limit) {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index cdc2430eb5..7071652f2a 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -30,13 +30,13 @@
#include "text_edit.h"
+#include "core/input/input_filter.h"
#include "core/message_queue.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "core/script_language.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
@@ -446,7 +446,7 @@ void TextEdit::_click_selection_held() {
// Warning: is_mouse_button_pressed(BUTTON_LEFT) returns false for double+ clicks, so this doesn't work for MODE_WORD
// and MODE_LINE. However, moving the mouse triggers _gui_input, which calls these functions too, so that's not a huge problem.
// I'm unsure if there's an actual fix that doesn't have a ton of side effects.
- if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode != Selection::MODE_NONE) {
+ if (InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode != Selection::MODE_NONE) {
switch (selection.selecting_mode) {
case Selection::MODE_POINTER: {
_update_selection_mode_pointer();
@@ -639,12 +639,12 @@ void TextEdit::_notification(int p_what) {
_update_wrap_at();
syntax_highlighting_cache.clear();
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
window_has_focus = true;
draw_caret = true;
update();
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_WM_FOCUS_OUT: {
window_has_focus = false;
draw_caret = false;
update();
@@ -728,7 +728,7 @@ void TextEdit::_notification(int p_what) {
_update_scrollbars();
RID ci = get_canvas_item();
- VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
+ RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT) - cache.minimap_width;
@@ -749,14 +749,14 @@ void TextEdit::_notification(int p_what) {
if (syntax_coloring) {
if (cache.background_color.a > 0.01) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), cache.background_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), cache.background_color);
}
}
if (line_length_guidelines) {
const int hard_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_hard_col - cursor.x_ofs;
if (hard_x > xmargin_beg && hard_x < xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color);
}
// Draw a "Soft" line length guideline, less visible than the hard line length guideline.
@@ -764,7 +764,7 @@ void TextEdit::_notification(int p_what) {
// Only drawn if its column differs from the hard line length guideline.
const int soft_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_soft_col - cursor.x_ofs;
if (hard_x != soft_x && soft_x > xmargin_beg && soft_x < xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5));
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5));
}
}
@@ -955,7 +955,7 @@ void TextEdit::_notification(int p_what) {
// draw the minimap
Color viewport_color = (cache.background_color.get_v() < 0.5) ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), viewport_offset_y, cache.minimap_width, viewport_height), viewport_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), viewport_offset_y, cache.minimap_width, viewport_height), viewport_color);
for (int i = 0; i < minimap_draw_amount; i++) {
minimap_line++;
@@ -1008,7 +1008,7 @@ void TextEdit::_notification(int p_what) {
}
if (minimap_line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), i * 3, cache.minimap_width, 2), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), i * 3, cache.minimap_width, 2), cache.current_line_color);
}
Color previous_color;
@@ -1057,7 +1057,7 @@ void TextEdit::_notification(int p_what) {
// take one for zero indexing, and if we hit whitespace / the end of a word.
int chars = MAX(0, (j - (characters - 1)) - (is_whitespace ? 1 : 0)) + 1;
int char_x_ofs = indent_px + ((xmargin_end + minimap_char_size.x) + (minimap_char_size.x * chars)) + tabs;
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_x_ofs, minimap_line_height * i), Point2(minimap_char_size.x * characters, minimap_char_size.y)), previous_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_x_ofs, minimap_line_height * i), Point2(minimap_char_size.x * characters, minimap_char_size.y)), previous_color);
}
if (out_of_bounds) {
@@ -1164,24 +1164,24 @@ void TextEdit::_notification(int p_what) {
}
if (text.is_marked(line)) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color);
}
if (str.length() == 0) {
// Draw line background if empty as we won't loop at at all.
if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, get_row_height()), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, get_row_height()), cache.current_line_color);
}
// Give visual indication of empty selected line.
if (selection.active && line >= selection.from_line && line <= selection.to_line && char_margin >= xmargin_beg) {
int char_w = cache.font->get_char_size(' ').width;
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color);
}
} else {
// If it has text, then draw current line marker in the margin, as line number etc will draw over it, draw the rest of line marker later.
if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_beg + ofs_x, get_row_height()), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_beg + ofs_x, get_row_height()), cache.current_line_color);
}
}
@@ -1190,9 +1190,9 @@ void TextEdit::_notification(int p_what) {
if (text.is_breakpoint(line) && !draw_breakpoint_gutter) {
#ifdef TOOLS_ENABLED
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color);
#else
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color);
#endif
}
@@ -1202,7 +1202,7 @@ void TextEdit::_notification(int p_what) {
int vertical_gap = (get_row_height() * 40) / 100;
int horizontal_gap = (cache.breakpoint_gutter_width * 30) / 100;
int marker_radius = get_row_height() - (vertical_gap * 2);
- VisualServer::get_singleton()->canvas_item_add_circle(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 + marker_radius / 2, ofs_y + vertical_gap + marker_radius / 2), marker_radius, Color(cache.bookmark_color.r, cache.bookmark_color.g, cache.bookmark_color.b));
+ RenderingServer::get_singleton()->canvas_item_add_circle(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 + marker_radius / 2, ofs_y + vertical_gap + marker_radius / 2), marker_radius, Color(cache.bookmark_color.r, cache.bookmark_color.g, cache.bookmark_color.b));
}
}
@@ -1214,7 +1214,7 @@ void TextEdit::_notification(int p_what) {
int marker_height = get_row_height() - (vertical_gap * 2);
int marker_width = cache.breakpoint_gutter_width - (horizontal_gap * 2);
// No transparency on marker.
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2, ofs_y + vertical_gap, marker_width, marker_height), Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b));
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2, ofs_y + vertical_gap, marker_width, marker_height), Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b));
}
}
@@ -1254,9 +1254,9 @@ void TextEdit::_notification(int p_what) {
cache.executing_icon->draw_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 - icon_extra_size / 2, ofs_y + vertical_gap - icon_extra_size / 2, marker_width, marker_height), false, Color(cache.executing_line_color.r, cache.executing_line_color.g, cache.executing_line_color.b));
} else {
#ifdef TOOLS_ENABLED
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.executing_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.executing_line_color);
#else
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.executing_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.executing_line_color);
#endif
}
}
@@ -1315,10 +1315,10 @@ void TextEdit::_notification(int p_what) {
if (j == str.length() - 1) {
// End of line when last char is skipped.
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color);
} else if ((char_ofs + char_margin) > xmargin_beg) {
// Char next to margin is skipped.
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, (char_ofs + char_margin) - (xmargin_beg + ofs_x), get_row_height()), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, (char_ofs + char_margin) - (xmargin_beg + ofs_x), get_row_height()), cache.current_line_color);
}
}
continue;
@@ -1338,7 +1338,7 @@ void TextEdit::_notification(int p_what) {
in_search_result = j >= search_text_col && j < search_text_col + search_text.length();
if (in_search_result) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.search_result_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.search_result_color);
}
}
@@ -1348,32 +1348,32 @@ void TextEdit::_notification(int p_what) {
if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) {
// Draw the wrap indent offset highlight.
if (line_wrap_index != 0 && j == 0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + ofs_x - indent_px, ofs_y, indent_px, get_row_height()), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + ofs_x - indent_px, ofs_y, indent_px, get_row_height()), cache.current_line_color);
}
// If its the last char draw to end of the line.
if (j == str.length() - 1) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color);
}
// Actual text.
if (!in_selection) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color);
}
}
if (in_selection) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color);
}
if (in_search_result) {
Color border_color = (line == search_result_line && j >= search_result_col && j < search_result_col + search_text.length()) ? cache.font_color : cache.search_result_border_color;
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, 1)), border_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, 1)), border_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color);
if (j == search_text_col)
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(1, get_row_height())), border_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(1, get_row_height())), border_color);
if (j == search_text_col + search_text.length() - 1)
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w + ofs_x - 1, ofs_y), Size2i(1, get_row_height())), border_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w + ofs_x - 1, ofs_y), Size2i(1, get_row_height())), border_color);
}
if (highlight_all_occurrences && !only_whitespaces_highlighted) {
@@ -1392,7 +1392,7 @@ void TextEdit::_notification(int p_what) {
}
if (in_highlighted_word) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color);
}
}
}
@@ -1449,9 +1449,9 @@ void TextEdit::_notification(int p_what) {
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color);
}
drawer.draw_char(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + ascent), cchar, next, color);
@@ -1468,7 +1468,7 @@ void TextEdit::_notification(int p_what) {
#else
int caret_h = (block_caret) ? 4 : 2;
#endif
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, caret_h)), cache.caret_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, caret_h)), cache.caret_color);
} else {
#ifdef TOOLS_ENABLED
caret_w = (block_caret) ? caret_w : 2 * EDSCALE;
@@ -1476,7 +1476,7 @@ void TextEdit::_notification(int p_what) {
caret_w = (block_caret) ? caret_w : 2;
#endif
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color);
}
}
}
@@ -1544,9 +1544,9 @@ void TextEdit::_notification(int p_what) {
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color);
}
drawer.draw_char(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + ascent), cchar, next, color);
@@ -1564,7 +1564,7 @@ void TextEdit::_notification(int p_what) {
#else
int caret_h = (block_caret) ? 4 : 2;
#endif
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(char_w, caret_h)), cache.caret_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(char_w, caret_h)), cache.caret_color);
} else {
int char_w = cache.font->get_char_size(' ').width;
#ifdef TOOLS_ENABLED
@@ -1573,7 +1573,7 @@ void TextEdit::_notification(int p_what) {
int caret_w = (block_caret) ? char_w : 2;
#endif
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color);
}
}
}
@@ -1584,11 +1584,11 @@ void TextEdit::_notification(int p_what) {
bool completion_below = false;
if (completion_active && completion_options.size() > 0) {
// Code completion box.
- Ref<StyleBox> csb = get_stylebox("completion");
- int maxlines = get_constant("completion_lines");
- int cmax_width = get_constant("completion_max_width") * cache.font->get_char_size('x').x;
- int scrollw = get_constant("completion_scroll_width");
- Color scrollc = get_color("completion_scroll_color");
+ Ref<StyleBox> csb = get_theme_stylebox("completion");
+ int maxlines = get_theme_constant("completion_lines");
+ int cmax_width = get_theme_constant("completion_max_width") * cache.font->get_char_size('x').x;
+ int scrollw = get_theme_constant("completion_scroll_width");
+ Color scrollc = get_theme_color("completion_scroll_color");
const int completion_options_size = completion_options.size();
int lines = MIN(completion_options_size, maxlines);
@@ -1607,7 +1607,7 @@ void TextEdit::_notification(int p_what) {
}
// Add space for completion icons.
- const int icon_hsep = get_constant("hseparation", "ItemList");
+ const int icon_hsep = get_theme_constant("hseparation", "ItemList");
Size2 icon_area_size(get_row_height(), get_row_height());
w += icon_area_size.width + icon_hsep;
@@ -1634,10 +1634,10 @@ void TextEdit::_notification(int p_what) {
draw_style_box(csb, Rect2(completion_rect.position - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0)));
if (cache.completion_background_color.a > 0.01) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color);
}
int line_from = CLAMP(completion_index - lines / 2, 0, completion_options_size - lines);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color);
draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(MIN(nofs, completion_rect.size.width - (icon_area_size.x + icon_hsep)), completion_rect.size.height)), cache.completion_existing_color);
for (int i = 0; i < lines; i++) {
@@ -1694,9 +1694,9 @@ void TextEdit::_notification(int p_what) {
if (show_hint) {
- Ref<StyleBox> sb = get_stylebox("panel", "TooltipPanel");
+ Ref<StyleBox> sb = get_theme_stylebox("panel", "TooltipPanel");
Ref<Font> font = cache.font;
- Color font_color = get_color("font_color", "TooltipLabel");
+ Color font_color = get_theme_color("font_color", "TooltipLabel");
int max_w = 0;
int sc = completion_hint.get_slice_count("\n");
@@ -1754,8 +1754,10 @@ void TextEdit::_notification(int p_what) {
}
if (has_focus()) {
- OS::get_singleton()->set_ime_active(true);
- OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()));
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos + Point2(0, get_row_height()), get_viewport()->get_window_id());
+ }
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -1766,12 +1768,14 @@ void TextEdit::_notification(int p_what) {
draw_caret = true;
}
- OS::get_singleton()->set_ime_active(true);
- Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
- OS::get_singleton()->set_ime_position(get_global_position() + cursor_pos);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id());
+ Point2 cursor_pos = Point2(cursor_get_column(), cursor_get_line()) * get_row_height();
+ DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
+ }
- if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect());
} break;
case NOTIFICATION_FOCUS_EXIT: {
@@ -1779,19 +1783,21 @@ void TextEdit::_notification(int p_what) {
caret_blink_timer->stop();
}
- OS::get_singleton()->set_ime_position(Point2());
- OS::get_singleton()->set_ime_active(false);
+ if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(Point2(), get_viewport()->get_window_id());
+ DisplayServer::get_singleton()->window_set_ime_active(false, get_viewport()->get_window_id());
+ }
ime_text = "";
ime_selection = Point2();
- if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->hide_virtual_keyboard();
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ DisplayServer::get_singleton()->virtual_keyboard_hide();
} break;
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
if (has_focus()) {
- ime_text = OS::get_singleton()->get_ime_text();
- ime_selection = OS::get_singleton()->get_ime_selection();
+ ime_text = DisplayServer::get_singleton()->ime_get_text();
+ ime_selection = DisplayServer::get_singleton()->ime_get_selection();
update();
}
} break;
@@ -2477,9 +2483,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- menu->set_position(get_global_transform().xform(get_local_mouse_position()));
+ menu->set_position(get_screen_transform().xform(get_local_mouse_position()));
menu->set_size(Vector2(1, 1));
- menu->set_scale(get_global_transform().get_scale());
+ // menu->set_scale(get_global_transform().get_scale());
menu->popup();
grab_focus();
}
@@ -2634,7 +2640,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (k->get_keycode() == KEY_PAGEUP) {
- completion_index -= get_constant("completion_lines");
+ completion_index -= get_theme_constant("completion_lines");
if (completion_index < 0)
completion_index = 0;
completion_current = completion_options[completion_index];
@@ -2645,7 +2651,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (k->get_keycode() == KEY_PAGEDOWN) {
- completion_index += get_constant("completion_lines");
+ completion_index += get_theme_constant("completion_lines");
if (completion_index >= completion_options.size())
completion_index = completion_options.size() - 1;
completion_current = completion_options[completion_index];
@@ -3735,7 +3741,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (context_menu_enabled) {
menu->set_position(get_global_transform().xform(_get_cursor_pixel_pos()));
menu->set_size(Vector2(1, 1));
- menu->set_scale(get_global_transform().get_scale());
+ // menu->set_scale(get_global_transform().get_scale());
menu->popup();
menu->grab_focus();
}
@@ -5026,51 +5032,51 @@ void TextEdit::_toggle_draw_caret() {
void TextEdit::_update_caches() {
- cache.style_normal = get_stylebox("normal");
- cache.style_focus = get_stylebox("focus");
- cache.style_readonly = get_stylebox("read_only");
- cache.completion_background_color = get_color("completion_background_color");
- cache.completion_selected_color = get_color("completion_selected_color");
- cache.completion_existing_color = get_color("completion_existing_color");
- cache.completion_font_color = get_color("completion_font_color");
- cache.font = get_font("font");
- cache.caret_color = get_color("caret_color");
- cache.caret_background_color = get_color("caret_background_color");
- cache.line_number_color = get_color("line_number_color");
- cache.safe_line_number_color = get_color("safe_line_number_color");
- cache.font_color = get_color("font_color");
- cache.font_color_selected = get_color("font_color_selected");
- cache.font_color_readonly = get_color("font_color_readonly");
- cache.keyword_color = get_color("keyword_color");
- cache.function_color = get_color("function_color");
- cache.member_variable_color = get_color("member_variable_color");
- cache.number_color = get_color("number_color");
- cache.selection_color = get_color("selection_color");
- cache.mark_color = get_color("mark_color");
- cache.current_line_color = get_color("current_line_color");
- cache.line_length_guideline_color = get_color("line_length_guideline_color");
- cache.bookmark_color = get_color("bookmark_color");
- cache.breakpoint_color = get_color("breakpoint_color");
- cache.executing_line_color = get_color("executing_line_color");
- cache.code_folding_color = get_color("code_folding_color");
- cache.brace_mismatch_color = get_color("brace_mismatch_color");
- 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.style_normal = get_theme_stylebox("normal");
+ cache.style_focus = get_theme_stylebox("focus");
+ cache.style_readonly = get_theme_stylebox("read_only");
+ cache.completion_background_color = get_theme_color("completion_background_color");
+ cache.completion_selected_color = get_theme_color("completion_selected_color");
+ cache.completion_existing_color = get_theme_color("completion_existing_color");
+ cache.completion_font_color = get_theme_color("completion_font_color");
+ cache.font = get_theme_font("font");
+ cache.caret_color = get_theme_color("caret_color");
+ cache.caret_background_color = get_theme_color("caret_background_color");
+ cache.line_number_color = get_theme_color("line_number_color");
+ cache.safe_line_number_color = get_theme_color("safe_line_number_color");
+ cache.font_color = get_theme_color("font_color");
+ cache.font_color_selected = get_theme_color("font_color_selected");
+ cache.font_color_readonly = get_theme_color("font_color_readonly");
+ cache.keyword_color = get_theme_color("keyword_color");
+ cache.function_color = get_theme_color("function_color");
+ cache.member_variable_color = get_theme_color("member_variable_color");
+ cache.number_color = get_theme_color("number_color");
+ cache.selection_color = get_theme_color("selection_color");
+ cache.mark_color = get_theme_color("mark_color");
+ cache.current_line_color = get_theme_color("current_line_color");
+ cache.line_length_guideline_color = get_theme_color("line_length_guideline_color");
+ cache.bookmark_color = get_theme_color("bookmark_color");
+ cache.breakpoint_color = get_theme_color("breakpoint_color");
+ cache.executing_line_color = get_theme_color("executing_line_color");
+ cache.code_folding_color = get_theme_color("code_folding_color");
+ cache.brace_mismatch_color = get_theme_color("brace_mismatch_color");
+ cache.word_highlighted_color = get_theme_color("word_highlighted_color");
+ cache.search_result_color = get_theme_color("search_result_color");
+ cache.search_result_border_color = get_theme_color("search_result_border_color");
+ cache.symbol_color = get_theme_color("symbol_color");
+ cache.background_color = get_theme_color("background_color");
#ifdef TOOLS_ENABLED
- cache.line_spacing = get_constant("line_spacing") * EDSCALE;
+ cache.line_spacing = get_theme_constant("line_spacing") * EDSCALE;
#else
- cache.line_spacing = get_constant("line_spacing");
+ cache.line_spacing = get_theme_constant("line_spacing");
#endif
cache.row_height = cache.font->get_height() + cache.line_spacing;
- cache.tab_icon = get_icon("tab");
- cache.space_icon = get_icon("space");
- cache.folded_icon = get_icon("folded");
- cache.can_fold_icon = get_icon("fold");
- cache.folded_eol_icon = get_icon("GuiEllipsis", "EditorIcons");
- cache.executing_icon = get_icon("MainPlay", "EditorIcons");
+ cache.tab_icon = get_theme_icon("tab");
+ cache.space_icon = get_theme_icon("space");
+ cache.folded_icon = get_theme_icon("folded");
+ cache.can_fold_icon = get_theme_icon("fold");
+ cache.folded_eol_icon = get_theme_icon("GuiEllipsis", "EditorIcons");
+ cache.executing_icon = get_theme_icon("MainPlay", "EditorIcons");
text.set_font(cache.font);
if (syntax_highlighter) {
@@ -5226,7 +5232,7 @@ void TextEdit::cut() {
if (!selection.active) {
String clipboard = text[cursor.line];
- OS::get_singleton()->set_clipboard(clipboard);
+ DisplayServer::get_singleton()->clipboard_set(clipboard);
cursor_set_line(cursor.line);
cursor_set_column(0);
@@ -5244,7 +5250,7 @@ void TextEdit::cut() {
} else {
String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
+ DisplayServer::get_singleton()->clipboard_set(clipboard);
_remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
cursor_set_line(selection.from_line); // Set afterwards else it causes the view to be offset.
@@ -5264,19 +5270,19 @@ void TextEdit::copy() {
if (text[cursor.line].length() != 0) {
String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
- OS::get_singleton()->set_clipboard(clipboard);
+ DisplayServer::get_singleton()->clipboard_set(clipboard);
cut_copy_line = clipboard;
}
} else {
String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
+ DisplayServer::get_singleton()->clipboard_set(clipboard);
cut_copy_line = "";
}
}
void TextEdit::paste() {
- String clipboard = OS::get_singleton()->get_clipboard();
+ String clipboard = DisplayServer::get_singleton()->clipboard_get();
begin_complex_operation();
if (selection.active) {
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index abf6b2ed49..0dd43e4a35 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -300,7 +300,7 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture,
p_texture->get_rect_region(dst_rect, src_rect, dst_rect, src_rect);
RID ci = get_canvas_item();
- VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, VS::NINE_PATCH_STRETCH, VS::NINE_PATCH_STRETCH, true, p_modulate);
+ RS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, true, p_modulate);
}
void TextureProgress::_notification(int p_what) {
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index 6dafd3bf4f..baa138847f 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -30,7 +30,7 @@
#include "texture_rect.h"
#include "core/core_string_names.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
void TextureRect::_notification(int p_what) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 12b3d56938..87425b49cd 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -30,13 +30,15 @@
#include "tree.h"
+#include "core/input/input_filter.h"
#include "core/math/math_funcs.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/print_string.h"
#include "core/project_settings.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
+
+#include "box_container.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_scale.h"
@@ -952,45 +954,45 @@ TreeItem::~TreeItem() {
void Tree::update_cache() {
- cache.font = get_font("font");
- cache.tb_font = get_font("title_button_font");
- cache.bg = get_stylebox("bg");
- cache.selected = get_stylebox("selected");
- cache.selected_focus = get_stylebox("selected_focus");
- cache.cursor = get_stylebox("cursor");
- cache.cursor_unfocus = get_stylebox("cursor_unfocused");
- cache.button_pressed = get_stylebox("button_pressed");
-
- cache.checked = get_icon("checked");
- cache.unchecked = get_icon("unchecked");
- cache.arrow_collapsed = get_icon("arrow_collapsed");
- cache.arrow = get_icon("arrow");
- cache.select_arrow = get_icon("select_arrow");
- cache.updown = get_icon("updown");
-
- cache.custom_button = get_stylebox("custom_button");
- cache.custom_button_hover = get_stylebox("custom_button_hover");
- cache.custom_button_pressed = get_stylebox("custom_button_pressed");
- cache.custom_button_font_highlight = get_color("custom_button_font_highlight");
-
- cache.font_color = get_color("font_color");
- cache.font_color_selected = get_color("font_color_selected");
- cache.guide_color = get_color("guide_color");
- cache.drop_position_color = get_color("drop_position_color");
- cache.hseparation = get_constant("hseparation");
- cache.vseparation = get_constant("vseparation");
- cache.item_margin = get_constant("item_margin");
- cache.button_margin = get_constant("button_margin");
- cache.draw_guides = get_constant("draw_guides");
- 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");
- cache.title_button_hover = get_stylebox("title_button_hover");
- cache.title_button_color = get_color("title_button_color");
+ cache.font = get_theme_font("font");
+ cache.tb_font = get_theme_font("title_button_font");
+ cache.bg = get_theme_stylebox("bg");
+ cache.selected = get_theme_stylebox("selected");
+ cache.selected_focus = get_theme_stylebox("selected_focus");
+ cache.cursor = get_theme_stylebox("cursor");
+ cache.cursor_unfocus = get_theme_stylebox("cursor_unfocused");
+ cache.button_pressed = get_theme_stylebox("button_pressed");
+
+ cache.checked = get_theme_icon("checked");
+ cache.unchecked = get_theme_icon("unchecked");
+ cache.arrow_collapsed = get_theme_icon("arrow_collapsed");
+ cache.arrow = get_theme_icon("arrow");
+ cache.select_arrow = get_theme_icon("select_arrow");
+ cache.updown = get_theme_icon("updown");
+
+ cache.custom_button = get_theme_stylebox("custom_button");
+ cache.custom_button_hover = get_theme_stylebox("custom_button_hover");
+ cache.custom_button_pressed = get_theme_stylebox("custom_button_pressed");
+ cache.custom_button_font_highlight = get_theme_color("custom_button_font_highlight");
+
+ cache.font_color = get_theme_color("font_color");
+ cache.font_color_selected = get_theme_color("font_color_selected");
+ cache.guide_color = get_theme_color("guide_color");
+ cache.drop_position_color = get_theme_color("drop_position_color");
+ cache.hseparation = get_theme_constant("hseparation");
+ cache.vseparation = get_theme_constant("vseparation");
+ cache.item_margin = get_theme_constant("item_margin");
+ cache.button_margin = get_theme_constant("button_margin");
+ cache.draw_guides = get_theme_constant("draw_guides");
+ cache.draw_relationship_lines = get_theme_constant("draw_relationship_lines");
+ cache.relationship_line_color = get_theme_color("relationship_line_color");
+ cache.scroll_border = get_theme_constant("scroll_border");
+ cache.scroll_speed = get_theme_constant("scroll_speed");
+
+ cache.title_button = get_theme_stylebox("title_button_normal");
+ cache.title_button_pressed = get_theme_stylebox("title_button_pressed");
+ cache.title_button_hover = get_theme_stylebox("title_button_hover");
+ cache.title_button_color = get_theme_color("title_button_color");
v_scroll->set_custom_step(cache.font->get_height());
}
@@ -1218,7 +1220,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (cache.draw_guides) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.position.x, cell_rect.position.y + cell_rect.size.height), cell_rect.position + cell_rect.size, cache.guide_color, 1);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.position.x, cell_rect.position.y + cell_rect.size.height), cell_rect.position + cell_rect.size, cache.guide_color, 1);
}
if (i == 0) {
@@ -1264,12 +1266,12 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
r.size.x += cache.hseparation;
}
if (p_item->cells[i].custom_bg_outline) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), p_item->cells[i].bg_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), p_item->cells[i].bg_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), p_item->cells[i].bg_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), p_item->cells[i].bg_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), p_item->cells[i].bg_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), p_item->cells[i].bg_color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, r, p_item->cells[i].bg_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, r, p_item->cells[i].bg_color);
}
}
@@ -1278,20 +1280,20 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
Rect2 r = cell_rect;
if (drop_mode_section == -1 || drop_mode_section == 0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color);
}
if (drop_mode_section == 0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color);
}
if (drop_mode_section == 1 || drop_mode_section == 0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color);
}
}
- Color col = p_item->cells[i].custom_color ? p_item->cells[i].color : get_color(p_item->cells[i].selected ? "font_color_selected" : "font_color");
+ Color col = p_item->cells[i].custom_color ? p_item->cells[i].color : get_theme_color(p_item->cells[i].selected ? "font_color_selected" : "font_color");
Color icon_col = p_item->cells[i].icon_color;
Point2i text_pos = item_rect.position;
@@ -1423,7 +1425,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
if (p_item->cells[i].custom_button) {
if (cache.hover_item == p_item && cache.hover_cell == i) {
- if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
draw_style_box(cache.custom_button_pressed, ir);
} else {
draw_style_box(cache.custom_button_hover, ir);
@@ -1507,8 +1509,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
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;
if (root_pos.y + line_width >= 0) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width);
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), Point2i(parent_pos.x, prev_ofs), cache.relationship_line_color, line_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), Point2i(parent_pos.x, prev_ofs), cache.relationship_line_color, line_width);
}
if (htotal < 0) {
@@ -1659,7 +1661,7 @@ Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) {
void Tree::_range_click_timeout() {
- if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (range_item_last && !range_drag_enabled && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
Point2 pos = get_local_mouse_position() - cache.bg->get_offset();
if (show_column_titles) {
@@ -2046,9 +2048,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
void Tree::_text_editor_modal_close() {
- if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
- Input::get_singleton()->is_key_pressed(KEY_KP_ENTER) ||
- Input::get_singleton()->is_key_pressed(KEY_ENTER)) {
+ if (InputFilter::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
+ InputFilter::get_singleton()->is_key_pressed(KEY_KP_ENTER) ||
+ InputFilter::get_singleton()->is_key_pressed(KEY_ENTER)) {
return;
}
@@ -2056,13 +2058,12 @@ void Tree::_text_editor_modal_close() {
if (value_editor->has_point(value_editor->get_local_mouse_position()))
return;
- text_editor_enter(text_editor->get_text());
+ _text_editor_enter(text_editor->get_text());
}
-void Tree::text_editor_enter(String p_text) {
+void Tree::_text_editor_enter(String p_text) {
- text_editor->hide();
- value_editor->hide();
+ popup_editor->hide();
if (!popup_edited_item)
return;
@@ -2531,7 +2532,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
range_drag_enabled = true;
range_drag_capture_pos = cpos;
range_drag_base = popup_edited_item->get_range(popup_edited_item_col);
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_CAPTURED);
}
} else {
@@ -2593,7 +2594,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
if (range_drag_enabled) {
range_drag_enabled = false;
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
} else {
Rect2 rect = get_selected()->get_meta("__focus_rect");
@@ -2703,7 +2704,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
drag_accum = 0;
//last_drag_accum=0;
drag_from = v_scroll->get_value();
- drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_touching = !DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id()));
drag_touching_deaccel = false;
if (drag_touching) {
set_physics_process_internal(true);
@@ -2806,20 +2807,23 @@ bool Tree::edit_selected() {
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) {
+ Rect2 popup_rect;
+
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
- Point2i textedpos = get_global_position() + rect.position - ofs;
+
+ Point2i textedpos = get_screen_position() + rect.position - ofs;
cache.text_editor_position = textedpos;
- text_editor->set_position(textedpos);
- text_editor->set_size(rect.size);
+ popup_rect.position = textedpos;
+ popup_rect.size = rect.size;
text_editor->clear();
text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
text_editor->select_all();
if (c.mode == TreeItem::CELL_MODE_RANGE) {
- value_editor->set_position(textedpos + Point2i(0, text_editor->get_size().height));
- value_editor->set_size(Size2(rect.size.width, 1));
- value_editor->show_modal();
+ popup_rect.size.y += value_editor->get_minimum_size().height;
+
+ value_editor->show();
updating_value_editor = true;
value_editor->set_min(c.min);
value_editor->set_max(c.max);
@@ -2827,10 +2831,17 @@ bool Tree::edit_selected() {
value_editor->set_value(c.val);
value_editor->set_exp_ratio(c.expr);
updating_value_editor = false;
+ } else {
+ value_editor->hide();
}
- text_editor->show_modal();
+ popup_editor->set_position(popup_rect.position);
+ popup_editor->set_size(popup_rect.size);
+ popup_editor->popup();
+ popup_editor->child_controls_changed();
+
text_editor->grab_focus();
+
return true;
}
@@ -3011,7 +3022,7 @@ void Tree::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<StyleBox> bg = cache.bg;
- Ref<StyleBox> bg_focus = get_stylebox("bg_focus");
+ Ref<StyleBox> bg_focus = get_theme_stylebox("bg_focus");
Point2 draw_ofs;
draw_ofs += bg->get_offset();
@@ -3019,9 +3030,9 @@ void Tree::_notification(int p_what) {
bg->draw(ci, Rect2(Point2(), get_size()));
if (has_focus()) {
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
+ RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
bg_focus->draw(ci, Rect2(Point2(), get_size()));
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false);
+ RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, false);
}
int tbh = _get_title_button_height();
@@ -3234,7 +3245,7 @@ void Tree::clear() {
if (pressing_for_editor) {
if (range_drag_enabled) {
range_drag_enabled = false;
- Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
}
pressing_for_editor = false;
@@ -4020,14 +4031,23 @@ Tree::Tree() {
popup_menu = memnew(PopupMenu);
popup_menu->hide();
add_child(popup_menu);
- popup_menu->set_as_toplevel(true);
+ // popup_menu->set_as_toplevel(true);
+
+ popup_editor = memnew(PopupPanel);
+ popup_editor->set_wrap_controls(true);
+ add_child(popup_editor);
+ popup_editor_vb = memnew(VBoxContainer);
+ popup_editor->add_child(popup_editor_vb);
+ popup_editor_vb->add_theme_constant_override("separation", 0);
+ popup_editor_vb->set_anchors_and_margins_preset(PRESET_WIDE);
text_editor = memnew(LineEdit);
- add_child(text_editor);
- text_editor->set_as_toplevel(true);
- text_editor->hide();
+ popup_editor_vb->add_child(text_editor);
+ text_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ text_editor->set_h_size_flags(SIZE_EXPAND_FILL);
value_editor = memnew(HSlider);
- add_child(value_editor);
- value_editor->set_as_toplevel(true);
+ value_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ value_editor->set_h_size_flags(SIZE_EXPAND_FILL);
+ popup_editor_vb->add_child(value_editor);
value_editor->hide();
h_scroll = memnew(HScrollBar);
@@ -4042,13 +4062,11 @@ Tree::Tree() {
h_scroll->connect("value_changed", callable_mp(this, &Tree::_scroll_moved));
v_scroll->connect("value_changed", callable_mp(this, &Tree::_scroll_moved));
- text_editor->connect("text_entered", callable_mp(this, &Tree::text_editor_enter));
- text_editor->connect("modal_closed", callable_mp(this, &Tree::_text_editor_modal_close));
+ text_editor->connect("text_entered", callable_mp(this, &Tree::_text_editor_enter));
+ popup_editor->connect("popup_hide", callable_mp(this, &Tree::_text_editor_modal_close));
popup_menu->connect("id_pressed", callable_mp(this, &Tree::popup_select));
value_editor->connect("value_changed", callable_mp(this, &Tree::value_editor_changed));
- value_editor->set_as_toplevel(true);
- text_editor->set_as_toplevel(true);
set_notify_transform(true);
updating_value_editor = false;
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index b179c5bcba..becbe76598 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -290,6 +290,8 @@ public:
VARIANT_ENUM_CAST(TreeItem::TreeCellMode);
VARIANT_ENUM_CAST(TreeItem::TextAlign);
+class VBoxContainer;
+
class Tree : public Control {
GDCLASS(Tree, Control);
@@ -359,6 +361,10 @@ private:
};
bool show_column_titles;
+
+ VBoxContainer *popup_editor_vb;
+
+ PopupPanel *popup_editor;
LineEdit *text_editor;
HSlider *value_editor;
bool updating_value_editor;
@@ -379,7 +385,7 @@ private:
int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item);
void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false);
int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod);
- void text_editor_enter(String p_text);
+ void _text_editor_enter(String p_text);
void _text_editor_modal_close();
void value_editor_changed(double p_value);
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp
index a76f2924d3..7ce1d9e551 100644
--- a/scene/gui/viewport_container.cpp
+++ b/scene/gui/viewport_container.cpp
@@ -40,7 +40,7 @@ Size2 ViewportContainer::get_minimum_size() const {
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c)
continue;
@@ -77,7 +77,7 @@ void ViewportContainer::set_stretch_shrink(int p_shrink) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c)
continue;
@@ -101,7 +101,7 @@ void ViewportContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c)
continue;
@@ -113,14 +113,14 @@ void ViewportContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c)
continue;
if (is_visible_in_tree())
- c->set_update_mode(Viewport::UPDATE_ALWAYS);
+ c->set_update_mode(SubViewport::UPDATE_ALWAYS);
else
- c->set_update_mode(Viewport::UPDATE_DISABLED);
+ c->set_update_mode(SubViewport::UPDATE_DISABLED);
c->set_handle_input_locally(false); //do not handle input locally here
}
@@ -130,7 +130,7 @@ void ViewportContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c)
continue;
@@ -159,7 +159,7 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c || c->is_input_disabled())
continue;
@@ -184,7 +184,7 @@ void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = Object::cast_to<Viewport>(get_child(i));
+ SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
if (!c || c->is_input_disabled())
continue;
diff --git a/scene/2d/canvas_item.cpp b/scene/main/canvas_item.cpp
index ef7aa9ba01..4a415415f1 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -29,17 +29,18 @@
/*************************************************************************/
#include "canvas_item.h"
+
+#include "core/input/input_filter.h"
#include "core/message_queue.h"
#include "core/method_bind_ext.gen.inc"
-#include "core/os/input.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/font.h"
#include "scene/resources/style_box.h"
#include "scene/resources/texture.h"
#include "scene/scene_string_names.h"
-#include "servers/visual/visual_server_raster.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
Mutex CanvasItemMaterial::material_mutex;
SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = NULL;
@@ -76,7 +77,7 @@ void CanvasItemMaterial::_update_shader() {
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);
+ RS::get_singleton()->free(shader_map[current_key].shader);
shader_map.erase(current_key);
}
}
@@ -85,7 +86,7 @@ void CanvasItemMaterial::_update_shader() {
if (shader_map.has(mk)) {
- VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
shader_map[mk].users++;
return;
}
@@ -136,14 +137,14 @@ void CanvasItemMaterial::_update_shader() {
}
ShaderData shader_data;
- shader_data.shader = VS::get_singleton()->shader_create();
+ shader_data.shader = RS::get_singleton()->shader_create();
shader_data.users = 1;
- VS::get_singleton()->shader_set_code(shader_data.shader, code);
+ RS::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);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
}
void CanvasItemMaterial::flush_changes() {
@@ -205,7 +206,7 @@ bool CanvasItemMaterial::get_particles_animation() const {
void CanvasItemMaterial::set_particles_anim_h_frames(int p_frames) {
particles_anim_h_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
}
int CanvasItemMaterial::get_particles_anim_h_frames() const {
@@ -215,7 +216,7 @@ int CanvasItemMaterial::get_particles_anim_h_frames() const {
void CanvasItemMaterial::set_particles_anim_v_frames(int p_frames) {
particles_anim_v_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
}
int CanvasItemMaterial::get_particles_anim_v_frames() const {
@@ -226,7 +227,7 @@ int CanvasItemMaterial::get_particles_anim_v_frames() const {
void CanvasItemMaterial::set_particles_anim_loop(bool p_loop) {
particles_anim_loop = p_loop;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
}
bool CanvasItemMaterial::get_particles_anim_loop() const {
@@ -314,11 +315,11 @@ CanvasItemMaterial::~CanvasItemMaterial() {
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);
+ RS::get_singleton()->free(shader_map[current_key].shader);
shader_map.erase(current_key);
}
- VS::get_singleton()->material_set_shader(_get_material(), RID());
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
}
}
@@ -347,6 +348,9 @@ bool CanvasItem::is_visible_in_tree() const {
while (p) {
if (!p->visible)
return false;
+ if (p->window && !p->window->is_visible()) {
+ return false;
+ }
p = p->get_parent_item();
}
@@ -383,7 +387,7 @@ void CanvasItem::show() {
return;
visible = true;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, true);
+ RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, true);
if (!is_inside_tree())
return;
@@ -398,7 +402,7 @@ void CanvasItem::hide() {
return;
visible = false;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, false);
+ RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, false);
if (!is_inside_tree())
return;
@@ -419,7 +423,7 @@ void CanvasItem::_update_callback() {
return;
}
- VisualServer::get_singleton()->canvas_item_clear(get_canvas_item());
+ RenderingServer::get_singleton()->canvas_item_clear(get_canvas_item());
//todo updating = true - only allow drawing here
if (is_visible_in_tree()) { //todo optimize this!!
if (first_draw) {
@@ -450,6 +454,21 @@ Transform2D CanvasItem::get_global_transform_with_canvas() const {
return get_global_transform();
}
+Transform2D CanvasItem::get_screen_transform() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), Transform2D());
+ Transform2D xform = get_global_transform_with_canvas();
+
+ Window *w = Object::cast_to<Window>(get_viewport());
+ if (w && !w->is_embedding_subwindows()) {
+ Transform2D s;
+ s.set_origin(w->get_position());
+
+ xform = s * xform;
+ }
+
+ return xform;
+}
+
Transform2D CanvasItem::get_global_transform() const {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V(!is_inside_tree(), get_transform());
@@ -474,9 +493,9 @@ void CanvasItem::_toplevel_raise_self() {
return;
if (canvas_layer)
- VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, canvas_layer->get_sort_index());
+ RenderingServer::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());
+ RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_viewport()->gui_get_canvas_sort_index());
}
void CanvasItem::_enter_canvas() {
@@ -505,7 +524,7 @@ void CanvasItem::_enter_canvas() {
else
canvas = get_viewport()->find_world_2d()->get_canvas();
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
+ RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
group = "root_canvas" + itos(canvas.get_id());
@@ -521,8 +540,8 @@ void CanvasItem::_enter_canvas() {
CanvasItem *parent = get_parent_item();
canvas_layer = parent->canvas_layer;
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item());
- VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
+ RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item());
+ RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
}
pending_update = false;
@@ -534,7 +553,7 @@ void CanvasItem::_enter_canvas() {
void CanvasItem::_exit_canvas() {
notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, RID());
+ RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID());
canvas_layer = NULL;
group = "";
}
@@ -548,10 +567,30 @@ void CanvasItem::_notification(int p_what) {
_update_texture_repeat_changed(false);
first_draw = true;
- if (get_parent()) {
- CanvasItem *ci = Object::cast_to<CanvasItem>(get_parent());
+ Node *parent = get_parent();
+ if (parent) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
if (ci)
C = ci->children_items.push_back(this);
+ if (!ci) {
+ //look for a window
+ Viewport *viewport = nullptr;
+
+ while (parent) {
+ viewport = Object::cast_to<Viewport>(parent);
+ if (viewport) {
+ break;
+ }
+ parent = parent->get_parent();
+ }
+
+ ERR_FAIL_COND(!viewport);
+
+ window = Object::cast_to<Window>(viewport);
+ if (window) {
+ window->connect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &CanvasItem::_window_visibility_changed));
+ }
+ }
}
_enter_canvas();
if (!block_transform_notify && !xform_change.in_list()) {
@@ -568,7 +607,7 @@ void CanvasItem::_notification(int p_what) {
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
- VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
+ RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
}
} break;
@@ -580,6 +619,9 @@ void CanvasItem::_notification(int p_what) {
Object::cast_to<CanvasItem>(get_parent())->children_items.erase(C);
C = NULL;
}
+ if (window) {
+ window->disconnect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &CanvasItem::_window_visibility_changed));
+ }
global_invalid = true;
} break;
case NOTIFICATION_DRAW:
@@ -600,6 +642,14 @@ void CanvasItem::set_visible(bool p_visible) {
else
hide();
}
+
+void CanvasItem::_window_visibility_changed() {
+
+ if (visible) {
+ _propagate_visibility_changed(window->is_visible());
+ }
+}
+
bool CanvasItem::is_visible() const {
return visible;
@@ -623,7 +673,7 @@ void CanvasItem::set_modulate(const Color &p_modulate) {
return;
modulate = p_modulate;
- VisualServer::get_singleton()->canvas_item_set_modulate(canvas_item, modulate);
+ RenderingServer::get_singleton()->canvas_item_set_modulate(canvas_item, modulate);
}
Color CanvasItem::get_modulate() const {
@@ -664,7 +714,7 @@ void CanvasItem::set_self_modulate(const Color &p_self_modulate) {
return;
self_modulate = p_self_modulate;
- VisualServer::get_singleton()->canvas_item_set_self_modulate(canvas_item, self_modulate);
+ RenderingServer::get_singleton()->canvas_item_set_self_modulate(canvas_item, self_modulate);
}
Color CanvasItem::get_self_modulate() const {
@@ -677,7 +727,7 @@ void CanvasItem::set_light_mask(int p_light_mask) {
return;
light_mask = p_light_mask;
- VS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask);
+ RS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask);
}
int CanvasItem::get_light_mask() const {
@@ -696,7 +746,7 @@ void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- VisualServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width);
+ RenderingServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width);
}
void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width) {
@@ -705,14 +755,14 @@ void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_co
Vector<Color> colors;
colors.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width);
+ RenderingServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width);
}
void CanvasItem::draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width);
+ RenderingServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width);
}
void CanvasItem::draw_arc(const Vector2 &p_center, float p_radius, float p_start_angle, float p_end_angle, int p_point_count, const Color &p_color, float p_width) {
@@ -734,14 +784,14 @@ void CanvasItem::draw_multiline(const Vector<Point2> &p_points, const Color &p_c
Vector<Color> colors;
colors.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, colors, p_width);
+ RenderingServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, colors, p_width);
}
void CanvasItem::draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- VisualServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, p_colors, p_width);
+ RenderingServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, p_colors, p_width);
}
void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled, float p_width) {
@@ -753,7 +803,7 @@ void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_fil
WARN_PRINT("The draw_rect() \"width\" argument has no effect when \"filled\" is \"true\".");
}
- VisualServer::get_singleton()->canvas_item_add_rect(canvas_item, p_rect, p_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(canvas_item, p_rect, p_color);
} else {
// Thick lines are offset depending on their width to avoid partial overlapping.
// Thin lines don't require an offset, so don't apply one in this case
@@ -764,25 +814,25 @@ void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_fil
offset = 0.0;
}
- VisualServer::get_singleton()->canvas_item_add_line(
+ RenderingServer::get_singleton()->canvas_item_add_line(
canvas_item,
p_rect.position + Size2(-offset, 0),
p_rect.position + Size2(p_rect.size.width + offset, 0),
p_color,
p_width);
- VisualServer::get_singleton()->canvas_item_add_line(
+ RenderingServer::get_singleton()->canvas_item_add_line(
canvas_item,
p_rect.position + Size2(p_rect.size.width, offset),
p_rect.position + Size2(p_rect.size.width, p_rect.size.height - offset),
p_color,
p_width);
- VisualServer::get_singleton()->canvas_item_add_line(
+ RenderingServer::get_singleton()->canvas_item_add_line(
canvas_item,
p_rect.position + Size2(p_rect.size.width + offset, p_rect.size.height),
p_rect.position + Size2(-offset, p_rect.size.height),
p_color,
p_width);
- VisualServer::get_singleton()->canvas_item_add_line(
+ RenderingServer::get_singleton()->canvas_item_add_line(
canvas_item,
p_rect.position + Size2(0, p_rect.size.height - offset),
p_rect.position + Size2(0, offset),
@@ -795,7 +845,7 @@ void CanvasItem::draw_circle(const Point2 &p_pos, float p_radius, const Color &p
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- VisualServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color);
+ RenderingServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color);
}
void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
@@ -804,7 +854,7 @@ void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_p
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map, p_specular_map, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
@@ -812,13 +862,13 @@ void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat), p_clip_uv);
+ p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat), p_clip_uv);
}
void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect) {
@@ -836,7 +886,7 @@ void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Col
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal, rid_specular, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ RenderingServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) {
@@ -844,14 +894,14 @@ void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const S
Transform2D xform(p_rot, p_offset);
xform.scale_basis(p_scale);
- VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, xform);
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(canvas_item, xform);
}
void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
- VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
+ RenderingServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
@@ -862,7 +912,7 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ RenderingServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
@@ -875,7 +925,7 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ RenderingServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, const Transform2D &p_transform, const Color &p_modulate, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
@@ -885,7 +935,7 @@ void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_text
RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_map_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ RenderingServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
@@ -894,7 +944,7 @@ void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Tex
RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_map_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat));
+ RenderingServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
@@ -1016,7 +1066,7 @@ void CanvasItem::set_draw_behind_parent(bool p_enable) {
if (behind == p_enable)
return;
behind = p_enable;
- VisualServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item, behind);
+ RenderingServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item, behind);
}
bool CanvasItem::is_draw_behind_parent_enabled() const {
@@ -1030,14 +1080,14 @@ void CanvasItem::set_material(const Ref<Material> &p_material) {
RID rid;
if (material.is_valid())
rid = material->get_rid();
- VS::get_singleton()->canvas_item_set_material(canvas_item, rid);
+ RS::get_singleton()->canvas_item_set_material(canvas_item, rid);
_change_notify(); //properties for material exposed
}
void CanvasItem::set_use_parent_material(bool p_use_parent_material) {
use_parent_material = p_use_parent_material;
- VS::get_singleton()->canvas_item_set_use_parent_material(canvas_item, p_use_parent_material);
+ RS::get_singleton()->canvas_item_set_use_parent_material(canvas_item, p_use_parent_material);
}
bool CanvasItem::get_use_parent_material() const {
@@ -1322,18 +1372,18 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) {
} else {
//from viewport
switch (get_viewport()->get_default_canvas_item_texture_filter()) {
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST; break;
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; break;
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; break;
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; break;
default: {
}
}
}
} else {
- texture_filter_cache = VS::CanvasItemTextureFilter(texture_filter);
+ texture_filter_cache = RS::CanvasItemTextureFilter(texture_filter);
}
- VS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache);
+ RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache);
update();
if (p_propagate) {
@@ -1371,17 +1421,17 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
} else {
//from viewport
switch (get_viewport()->get_default_canvas_item_texture_repeat()) {
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; break;
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; break;
- case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; break;
+ case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR; break;
default: {
}
}
}
} else {
- texture_repeat_cache = VS::CanvasItemTextureRepeat(texture_repeat);
+ texture_repeat_cache = RS::CanvasItemTextureRepeat(texture_repeat);
}
- VS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache);
+ RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache);
update();
if (p_propagate) {
for (List<CanvasItem *>::Element *E = children_items.front(); E; E = E->next()) {
@@ -1408,7 +1458,8 @@ CanvasItem::TextureRepeat CanvasItem::get_texture_repeat() const {
CanvasItem::CanvasItem() :
xform_change(this) {
- canvas_item = VisualServer::get_singleton()->canvas_item_create();
+ window = nullptr;
+ canvas_item = RenderingServer::get_singleton()->canvas_item_create();
visible = true;
pending_update = false;
modulate = Color(1, 1, 1, 1);
@@ -1427,13 +1478,13 @@ CanvasItem::CanvasItem() :
light_mask = 1;
texture_repeat = TEXTURE_REPEAT_PARENT_NODE;
texture_filter = TEXTURE_FILTER_PARENT_NODE;
- texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
- texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
+ texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
+ texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
C = NULL;
}
CanvasItem::~CanvasItem() {
- VisualServer::get_singleton()->free(canvas_item);
+ RenderingServer::get_singleton()->free(canvas_item);
}
diff --git a/scene/2d/canvas_item.h b/scene/main/canvas_item.h
index c7f9500ea1..dc17c5283b 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -201,6 +201,7 @@ private:
int light_mask;
+ Window *window;
bool first_draw;
bool visible;
bool pending_update;
@@ -212,8 +213,8 @@ private:
bool notify_local_transform;
bool notify_transform;
- VS::CanvasItemTextureFilter texture_filter_cache;
- VS::CanvasItemTextureRepeat texture_repeat_cache;
+ RS::CanvasItemTextureFilter texture_filter_cache;
+ RS::CanvasItemTextureRepeat texture_repeat_cache;
TextureFilter texture_filter;
TextureRepeat texture_repeat;
@@ -232,6 +233,8 @@ private:
void _enter_canvas();
void _exit_canvas();
+ void _window_visibility_changed();
+
void _notify_transform(CanvasItem *p_node);
void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); }
@@ -364,6 +367,7 @@ public:
virtual Transform2D get_global_transform() const;
virtual Transform2D get_global_transform_with_canvas() const;
+ virtual Transform2D get_screen_transform() const;
CanvasItem *get_toplevel() const;
_FORCE_INLINE_ RID get_canvas_item() const {
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 2085fa3a60..e6a665d035 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -35,7 +35,7 @@ void CanvasLayer::set_layer(int p_xform) {
layer = p_xform;
if (viewport.is_valid())
- VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
+ RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
}
int CanvasLayer::get_layer() const {
@@ -48,7 +48,7 @@ void CanvasLayer::set_transform(const Transform2D &p_xform) {
transform = p_xform;
locrotscale_dirty = true;
if (viewport.is_valid())
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
}
Transform2D CanvasLayer::get_transform() const {
@@ -61,7 +61,7 @@ void CanvasLayer::_update_xform() {
transform.set_rotation_and_scale(rot, scale);
transform.set_origin(ofs);
if (viewport.is_valid())
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
}
void CanvasLayer::_update_locrotscale() {
@@ -150,16 +150,16 @@ void CanvasLayer::_notification(int p_what) {
vp->_canvas_layer_add(this);
viewport = vp->get_viewport_rid();
- VisualServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
- VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
+ RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
+ RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
_update_follow_viewport();
} break;
case NOTIFICATION_EXIT_TREE: {
vp->_canvas_layer_remove(this);
- VisualServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
+ RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
viewport = RID();
_update_follow_viewport(false);
@@ -167,7 +167,7 @@ void CanvasLayer::_notification(int p_what) {
case NOTIFICATION_MOVED_IN_PARENT: {
if (is_inside_tree())
- VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
+ RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
} break;
}
@@ -191,7 +191,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
ERR_FAIL_NULL(p_viewport);
if (is_inside_tree()) {
vp->_canvas_layer_remove(this);
- VisualServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
+ RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
viewport = RID();
}
@@ -213,9 +213,9 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
vp->_canvas_layer_add(this);
viewport = vp->get_viewport_rid();
- VisualServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
- VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
+ RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
+ RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
}
}
@@ -266,9 +266,9 @@ void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
return;
}
if (p_force_exit || !follow_viewport) {
- VS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0);
+ RS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0);
} else {
- VS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale);
+ RS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale);
}
}
@@ -325,7 +325,7 @@ CanvasLayer::CanvasLayer() {
rot = 0;
locrotscale_dirty = false;
layer = 1;
- canvas = VS::get_singleton()->canvas_create();
+ canvas = RS::get_singleton()->canvas_create();
custom_viewport = NULL;
sort_index = 0;
@@ -335,5 +335,5 @@ CanvasLayer::CanvasLayer() {
CanvasLayer::~CanvasLayer() {
- VS::get_singleton()->free(canvas);
+ RS::get_singleton()->free(canvas);
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 973dff07d2..b882b9ead6 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2950,9 +2950,9 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_WM_MOUSE_EXIT);
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN);
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT);
- BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST);
+ BIND_CONSTANT(NOTIFICATION_WM_CLOSE_REQUEST);
BIND_CONSTANT(NOTIFICATION_WM_GO_BACK_REQUEST);
- BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST);
+ BIND_CONSTANT(NOTIFICATION_WM_SIZE_CHANGED);
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
diff --git a/scene/main/node.h b/scene/main/node.h
index d1f75b71ec..cf25a92be6 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -244,13 +244,16 @@ public:
NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26,
NOTIFICATION_POST_ENTER_TREE = 27,
//keep these linked to node
- NOTIFICATION_WM_MOUSE_ENTER = MainLoop::NOTIFICATION_WM_MOUSE_ENTER,
- NOTIFICATION_WM_MOUSE_EXIT = MainLoop::NOTIFICATION_WM_MOUSE_EXIT,
- NOTIFICATION_WM_FOCUS_IN = MainLoop::NOTIFICATION_WM_FOCUS_IN,
- NOTIFICATION_WM_FOCUS_OUT = MainLoop::NOTIFICATION_WM_FOCUS_OUT,
- NOTIFICATION_WM_QUIT_REQUEST = MainLoop::NOTIFICATION_WM_QUIT_REQUEST,
- NOTIFICATION_WM_GO_BACK_REQUEST = MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST,
- NOTIFICATION_WM_UNFOCUS_REQUEST = MainLoop::NOTIFICATION_WM_UNFOCUS_REQUEST,
+
+ NOTIFICATION_WM_MOUSE_ENTER = 1002,
+ NOTIFICATION_WM_MOUSE_EXIT = 1003,
+ NOTIFICATION_WM_FOCUS_IN = 1004,
+ NOTIFICATION_WM_FOCUS_OUT = 1005,
+ NOTIFICATION_WM_CLOSE_REQUEST = 1006,
+ NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
+ NOTIFICATION_WM_SIZE_CHANGED = 1008,
+ NOTIFICATION_WM_DPI_CHANGE = 1009,
+
NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING,
NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED,
NOTIFICATION_WM_ABOUT = MainLoop::NOTIFICATION_WM_ABOUT,
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index f472de220b..15c0a7666e 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -31,6 +31,7 @@
#include "scene_tree.h"
#include "core/debugger/engine_debugger.h"
+#include "core/input/input_filter.h"
#include "core/io/marshalls.h"
#include "core/io/resource_loader.h"
#include "core/message_queue.h"
@@ -39,7 +40,6 @@
#include "core/os/os.h"
#include "core/print_string.h"
#include "core/project_settings.h"
-#include "main/input_default.h"
#include "node.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/dynamic_font.h"
@@ -47,10 +47,11 @@
#include "scene/resources/mesh.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
-#include "servers/navigation_server.h"
-#include "servers/physics_2d_server.h"
-#include "servers/physics_server.h"
-#include "viewport.h"
+#include "servers/display_server.h"
+#include "servers/navigation_server_3d.h"
+#include "servers/physics_server_2d.h"
+#include "servers/physics_server_3d.h"
+#include "window.h"
#include <stdio.h>
@@ -397,69 +398,6 @@ void SceneTree::set_group(const StringName &p_group, const String &p_name, const
set_group_flags(0, p_group, p_name, p_value);
}
-void SceneTree::set_input_as_handled() {
-
- input_handled = true;
-}
-
-void SceneTree::input_text(const String &p_text) {
-
- root_lock++;
-
- 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--;
-}
-
-bool SceneTree::is_input_handled() {
- return input_handled;
-}
-
-void SceneTree::input_event(const Ref<InputEvent> &p_event) {
-
- if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_event)))
- return; //avoid joy input on editor
-
- current_event++;
- root_lock++;
-
- input_handled = false;
-
- // Don't make const ref unless you can find and fix what caused GH-34691.
- Ref<InputEvent> ev = p_event;
-
- MainLoop::input_event(ev);
-
- call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check
-
- if (EngineDebugger::is_active()) {
- //quit from game window using F8
- Ref<InputEventKey> k = ev;
- if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_F8) {
- EngineDebugger::get_singleton()->send_message("request_quit", Array());
- }
- }
-
- _flush_ugc();
- root_lock--;
- //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness
-
- root_lock++;
-
- if (!input_handled) {
- call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_unhandled_input", ev); //special one for GUI, as controls use their own process check
- _flush_ugc();
- // input_handled = true; - no reason to set this as handled
- root_lock--;
- //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness
- } else {
- // input_handled = true; - no reason to set this as handled
- root_lock--;
- }
-
- _call_idle_callbacks();
-}
-
void SceneTree::init() {
initialized = true;
root->_set_tree(this);
@@ -493,19 +431,11 @@ bool SceneTree::iteration(float p_time) {
return _quit;
}
-void SceneTree::_update_font_oversampling(float p_ratio) {
-
- if (use_font_oversampling) {
- DynamicFontAtSize::font_oversampling = p_ratio;
- DynamicFont::update_oversampling();
- }
-}
-
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("TEXTURE RAM: "+itos(RS::get_singleton()->get_render_info(RS::INFO_TEXTURE_MEM_USED)));
root_lock++;
@@ -526,15 +456,6 @@ bool SceneTree::idle(float p_time) {
_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_window_size().width, OS::get_singleton()->get_window_size().height);
-
- if (win_size != last_screen_size) {
-
- last_screen_size = win_size;
- _update_root_rect();
- emit_signal("screen_resized");
- }
-
_flush_ugc();
MessageQueue::get_singleton()->flush(); //small little hack
flush_transform_notifications(); //transforms after world update, to avoid unnecessary enter/exit notifications
@@ -642,59 +563,36 @@ void SceneTree::quit(int p_exit_code) {
_quit = true;
}
-void SceneTree::_notification(int p_notification) {
-
- switch (p_notification) {
-
- case NOTIFICATION_WM_QUIT_REQUEST: {
-
- get_root()->propagate_notification(p_notification);
-
- if (accept_quit) {
- _quit = true;
- break;
- }
- } break;
-
- case NOTIFICATION_WM_GO_BACK_REQUEST: {
-
- get_root()->propagate_notification(p_notification);
+void SceneTree::_main_window_close() {
- if (quit_on_go_back) {
- _quit = true;
- break;
- }
- } break;
+ if (accept_quit) {
+ _quit = true;
+ }
+}
+void SceneTree::_main_window_go_back() {
+ if (quit_on_go_back) {
+ _quit = true;
+ }
+}
- case NOTIFICATION_WM_FOCUS_IN: {
+void SceneTree::_main_window_focus_in() {
+ InputFilter *id = InputFilter::get_singleton();
+ if (id) {
+ id->ensure_touch_mouse_raised();
+ }
+}
- InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
- if (id) {
- id->ensure_touch_mouse_raised();
- }
+void SceneTree::_notification(int p_notification) {
- get_root()->propagate_notification(p_notification);
- } break;
+ switch (p_notification) {
case NOTIFICATION_TRANSLATION_CHANGED: {
if (!Engine::get_singleton()->is_editor_hint()) {
get_root()->propagate_notification(p_notification);
}
} break;
-
- case NOTIFICATION_WM_UNFOCUS_REQUEST: {
-
- notify_group_flags(GROUP_CALL_REALTIME | GROUP_CALL_MULTILEVEL, "input", NOTIFICATION_WM_UNFOCUS_REQUEST);
-
- get_root()->propagate_notification(p_notification);
-
- } break;
-
case NOTIFICATION_OS_MEMORY_WARNING:
case NOTIFICATION_OS_IME_UPDATE:
- case NOTIFICATION_WM_MOUSE_ENTER:
- case NOTIFICATION_WM_MOUSE_EXIT:
- case NOTIFICATION_WM_FOCUS_OUT:
case NOTIFICATION_WM_ABOUT:
case NOTIFICATION_CRASH:
case NOTIFICATION_APP_RESUMED:
@@ -898,9 +796,9 @@ void SceneTree::set_pause(bool p_enabled) {
if (p_enabled == pause)
return;
pause = p_enabled;
- NavigationServer::get_singleton()->set_active(!p_enabled);
- PhysicsServer::get_singleton()->set_active(!p_enabled);
- Physics2DServer::get_singleton()->set_active(!p_enabled);
+ NavigationServer3D::get_singleton()->set_active(!p_enabled);
+ PhysicsServer3D::get_singleton()->set_active(!p_enabled);
+ PhysicsServer2D::get_singleton()->set_active(!p_enabled);
if (get_root())
get_root()->propagate_notification(p_enabled ? Node::NOTIFICATION_PAUSED : Node::NOTIFICATION_UNPAUSED);
}
@@ -910,7 +808,7 @@ bool SceneTree::is_paused() const {
return pause;
}
-void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input) {
+void SceneTree::_notify_group_pause(const StringName &p_group, int p_notification) {
Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
@@ -919,7 +817,7 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
if (g.nodes.empty())
return;
- _update_group_order(g);
+ _update_group_order(g, p_notification == Node::NOTIFICATION_PROCESS || p_notification == Node::NOTIFICATION_INTERNAL_PROCESS || p_notification == Node::NOTIFICATION_PHYSICS_PROCESS || p_notification == Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
//copy, so copy on write happens in case something is removed from process while being called
//performance is not lost because only if something is added/removed the vector is copied.
@@ -928,15 +826,9 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
int node_count = nodes_copy.size();
Node **nodes = nodes_copy.ptrw();
- Variant arg = p_input;
- const Variant *v[1] = { &arg };
-
call_lock++;
- for (int i = node_count - 1; i >= 0; i--) {
-
- if (input_handled)
- break;
+ for (int i = 0; i < node_count; i++) {
Node *n = nodes[i];
if (call_lock && call_skip.has(n))
@@ -944,8 +836,10 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
if (!n->can_process())
continue;
+ if (!n->can_process_notification(p_notification))
+ continue;
- n->call_multilevel(p_method, (const Variant **)v, 1);
+ n->notification(p_notification);
//ERR_FAIL_COND(node_count != g.nodes.size());
}
@@ -954,7 +848,18 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
call_skip.clear();
}
-void SceneTree::_notify_group_pause(const StringName &p_group, int p_notification) {
+/*
+void SceneMainLoop::_update_listener_2d() {
+
+ if (listener_2d.is_valid()) {
+
+ SpatialSound2DServer::get_singleton()->listener_set_space( listener_2d, world_2d->get_sound_space() );
+ }
+
+}
+*/
+
+void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input, Viewport *p_viewport) {
Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
@@ -963,7 +868,7 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio
if (g.nodes.empty())
return;
- _update_group_order(g, p_notification == Node::NOTIFICATION_PROCESS || p_notification == Node::NOTIFICATION_INTERNAL_PROCESS || p_notification == Node::NOTIFICATION_PHYSICS_PROCESS || p_notification == Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
+ _update_group_order(g);
//copy, so copy on write happens in case something is removed from process while being called
//performance is not lost because only if something is added/removed the vector is copied.
@@ -972,9 +877,15 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio
int node_count = nodes_copy.size();
Node **nodes = nodes_copy.ptrw();
+ Variant arg = p_input;
+ const Variant *v[1] = { &arg };
+
call_lock++;
- for (int i = 0; i < node_count; i++) {
+ for (int i = node_count - 1; i >= 0; i--) {
+
+ if (p_viewport->is_input_handled())
+ break;
Node *n = nodes[i];
if (call_lock && call_skip.has(n))
@@ -982,10 +893,8 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio
if (!n->can_process())
continue;
- if (!n->can_process_notification(p_notification))
- continue;
- n->notification(p_notification);
+ n->call_multilevel(p_method, (const Variant **)v, 1);
//ERR_FAIL_COND(node_count != g.nodes.size());
}
@@ -993,18 +902,6 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio
if (call_lock == 0)
call_skip.clear();
}
-
-/*
-void SceneMainLoop::_update_listener_2d() {
-
- if (listener_2d.is_valid()) {
-
- SpatialSound2DServer::get_singleton()->listener_set_space( listener_2d, world_2d->get_sound_space() );
- }
-
-}
-*/
-
Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
@@ -1129,129 +1026,6 @@ int SceneTree::get_node_count() const {
return node_count;
}
-void SceneTree::_update_root_rect() {
-
- if (stretch_mode == STRETCH_MODE_DISABLED) {
-
- _update_font_oversampling(1.0);
- root->set_size((last_screen_size / stretch_shrink).floor());
- root->set_attach_to_screen_rect(Rect2(Point2(), last_screen_size));
- root->set_size_override_stretch(false);
- root->set_size_override(false, Size2());
- root->update_canvas_items();
- return; //user will take care
- }
-
- //actual screen video mode
- Size2 video_mode = Size2(OS::get_singleton()->get_window_size().width, OS::get_singleton()->get_window_size().height);
- Size2 desired_res = stretch_min;
-
- Size2 viewport_size;
- Size2 screen_size;
-
- float viewport_aspect = desired_res.aspect();
- float video_mode_aspect = video_mode.aspect();
-
- if (use_font_oversampling && stretch_aspect == STRETCH_ASPECT_IGNORE) {
- WARN_PRINT("Font oversampling only works with the resize modes 'Keep Width', 'Keep Height', and 'Expand'.");
- }
-
- if (stretch_aspect == STRETCH_ASPECT_IGNORE || Math::is_equal_approx(viewport_aspect, video_mode_aspect)) {
- //same aspect or ignore aspect
- viewport_size = desired_res;
- screen_size = video_mode;
- } else if (viewport_aspect < video_mode_aspect) {
- // screen ratio is smaller vertically
-
- if (stretch_aspect == STRETCH_ASPECT_KEEP_HEIGHT || stretch_aspect == STRETCH_ASPECT_EXPAND) {
-
- //will stretch horizontally
- viewport_size.x = desired_res.y * video_mode_aspect;
- viewport_size.y = desired_res.y;
- screen_size = video_mode;
-
- } else {
- //will need black bars
- viewport_size = desired_res;
- screen_size.x = video_mode.y * viewport_aspect;
- screen_size.y = video_mode.y;
- }
- } else {
- //screen ratio is smaller horizontally
- if (stretch_aspect == STRETCH_ASPECT_KEEP_WIDTH || stretch_aspect == STRETCH_ASPECT_EXPAND) {
-
- //will stretch horizontally
- viewport_size.x = desired_res.x;
- viewport_size.y = desired_res.x / video_mode_aspect;
- screen_size = video_mode;
-
- } else {
- //will need black bars
- viewport_size = desired_res;
- screen_size.x = video_mode.x;
- screen_size.y = video_mode.x / viewport_aspect;
- }
- }
-
- screen_size = screen_size.floor();
- viewport_size = viewport_size.floor();
-
- Size2 margin;
- Size2 offset;
- //black bars and margin
- if (stretch_aspect != STRETCH_ASPECT_EXPAND && screen_size.x < video_mode.x) {
- margin.x = Math::round((video_mode.x - screen_size.x) / 2.0);
- VisualServer::get_singleton()->black_bars_set_margins(margin.x, 0, margin.x, 0);
- offset.x = Math::round(margin.x * viewport_size.y / screen_size.y);
- } else if (stretch_aspect != STRETCH_ASPECT_EXPAND && screen_size.y < video_mode.y) {
- margin.y = Math::round((video_mode.y - screen_size.y) / 2.0);
- VisualServer::get_singleton()->black_bars_set_margins(0, margin.y, 0, margin.y);
- offset.y = Math::round(margin.y * viewport_size.x / screen_size.x);
- } else {
- VisualServer::get_singleton()->black_bars_set_margins(0, 0, 0, 0);
- }
-
- switch (stretch_mode) {
- case STRETCH_MODE_DISABLED: {
- // Already handled above
- _update_font_oversampling(1.0);
- } break;
- case STRETCH_MODE_2D: {
-
- _update_font_oversampling(screen_size.x / viewport_size.x); //screen / viewport radio drives oversampling
- root->set_size((screen_size / stretch_shrink).floor());
- root->set_attach_to_screen_rect(Rect2(margin, screen_size));
- root->set_size_override_stretch(true);
- root->set_size_override(true, (viewport_size / stretch_shrink).floor());
- root->update_canvas_items(); //force them to update just in case
-
- } break;
- case STRETCH_MODE_VIEWPORT: {
-
- _update_font_oversampling(1.0);
- root->set_size((viewport_size / stretch_shrink).floor());
- root->set_attach_to_screen_rect(Rect2(margin, screen_size));
- root->set_size_override_stretch(false);
- root->set_size_override(false, Size2());
- root->update_canvas_items(); //force them to update just in case
-
- if (use_font_oversampling) {
- WARN_PRINT("Font oversampling does not work in 'Viewport' stretch mode, only '2D'.");
- }
-
- } break;
- }
-}
-
-void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 &p_minsize, real_t p_shrink) {
-
- stretch_mode = p_mode;
- stretch_aspect = p_aspect;
- stretch_min = p_minsize;
- stretch_shrink = p_shrink;
- _update_root_rect();
-}
-
void SceneTree::set_edited_scene_root(Node *p_node) {
#ifdef TOOLS_ENABLED
edited_scene_root = p_node;
@@ -1330,18 +1104,6 @@ void SceneTree::add_current_scene(Node *p_current) {
root->add_child(p_current);
}
-void SceneTree::drop_files(const Vector<String> &p_files, int p_from_screen) {
-
- emit_signal("files_dropped", p_files, p_from_screen);
- MainLoop::drop_files(p_files, p_from_screen);
-}
-
-void SceneTree::global_menu_action(const Variant &p_id, const Variant &p_meta) {
-
- emit_signal("global_menu_action", p_id, p_meta);
- MainLoop::global_menu_action(p_id, p_meta);
-}
-
Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) {
Ref<SceneTreeTimer> stt;
@@ -1469,8 +1231,6 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pause", "enable"), &SceneTree::set_pause);
ClassDB::bind_method(D_METHOD("is_paused"), &SceneTree::is_paused);
- ClassDB::bind_method(D_METHOD("set_input_as_handled"), &SceneTree::set_input_as_handled);
- ClassDB::bind_method(D_METHOD("is_input_handled"), &SceneTree::is_input_handled);
ClassDB::bind_method(D_METHOD("create_timer", "time_sec", "pause_mode_process"), &SceneTree::create_timer, DEFVAL(true));
@@ -1478,8 +1238,6 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frame"), &SceneTree::get_frame);
ClassDB::bind_method(D_METHOD("quit", "exit_code"), &SceneTree::quit, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("set_screen_stretch", "mode", "aspect", "minsize", "shrink"), &SceneTree::set_screen_stretch, DEFVAL(1));
-
ClassDB::bind_method(D_METHOD("queue_delete", "obj"), &SceneTree::queue_delete);
MethodInfo mi;
@@ -1529,15 +1287,11 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &SceneTree::set_refuse_new_network_connections);
ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &SceneTree::is_refusing_new_network_connections);
- ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &SceneTree::set_use_font_oversampling);
- ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &SceneTree::is_using_font_oversampling);
-
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_collisions_hint"), "set_debug_collisions_hint", "is_debugging_collisions_hint");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_navigation_hint"), "set_debug_navigation_hint", "is_debugging_navigation_hint");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_font_oversampling"), "set_use_font_oversampling", "is_using_font_oversampling");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_edited_scene_root", "get_edited_scene_root");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_current_scene", "get_current_scene");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer");
@@ -1549,14 +1303,12 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("node_renamed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
- ADD_SIGNAL(MethodInfo("screen_resized"));
ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("idle_frame"));
ADD_SIGNAL(MethodInfo("physics_frame"));
ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
- ADD_SIGNAL(MethodInfo("global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
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"));
@@ -1567,16 +1319,6 @@ void SceneTree::_bind_methods() {
BIND_ENUM_CONSTANT(GROUP_CALL_REVERSE);
BIND_ENUM_CONSTANT(GROUP_CALL_REALTIME);
BIND_ENUM_CONSTANT(GROUP_CALL_UNIQUE);
-
- BIND_ENUM_CONSTANT(STRETCH_MODE_DISABLED);
- BIND_ENUM_CONSTANT(STRETCH_MODE_2D);
- BIND_ENUM_CONSTANT(STRETCH_MODE_VIEWPORT);
-
- BIND_ENUM_CONSTANT(STRETCH_ASPECT_IGNORE);
- BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP);
- BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_WIDTH);
- BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_HEIGHT);
- BIND_ENUM_CONSTANT(STRETCH_ASPECT_EXPAND);
}
SceneTree *SceneTree::singleton = NULL;
@@ -1596,19 +1338,6 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) {
idle_callbacks[idle_callback_count++] = p_callback;
}
-void SceneTree::set_use_font_oversampling(bool p_oversampling) {
-
- if (use_font_oversampling == p_oversampling)
- return;
-
- use_font_oversampling = p_oversampling;
- _update_root_rect();
-}
-
-bool SceneTree::is_using_font_oversampling() const {
- return use_font_oversampling;
-}
-
void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
if (p_function == "change_scene") {
@@ -1648,7 +1377,6 @@ SceneTree::SceneTree() {
accept_quit = true;
quit_on_go_back = true;
initialized = false;
- use_font_oversampling = false;
#ifdef DEBUG_ENABLED
debug_collisions_hint = false;
debug_navigation_hint = false;
@@ -1665,7 +1393,6 @@ SceneTree::SceneTree() {
idle_process_time = 1;
root = NULL;
- input_handled = false;
pause = false;
current_frame = 0;
current_event = 0;
@@ -1680,11 +1407,10 @@ SceneTree::SceneTree() {
//create with mainloop
- root = memnew(Viewport);
+ root = memnew(Window);
root->set_name("root");
- root->set_handle_input_locally(false);
if (!root->get_world().is_valid())
- root->set_world(Ref<World>(memnew(World)));
+ root->set_world(Ref<World3D>(memnew(World3D)));
// Initialize network state
multiplayer_poll = true;
@@ -1730,15 +1456,12 @@ SceneTree::SceneTree() {
}
}
- stretch_mode = STRETCH_MODE_DISABLED;
- stretch_aspect = STRETCH_ASPECT_IGNORE;
- stretch_shrink = 1;
-
- last_screen_size = Size2(OS::get_singleton()->get_window_size().width, OS::get_singleton()->get_window_size().height);
- _update_root_rect();
-
root->set_physics_object_picking(GLOBAL_DEF("physics/common/enable_object_picking", true));
+ root->connect("close_requested", callable_mp(this, &SceneTree::_main_window_close));
+ root->connect("go_back_requested", callable_mp(this, &SceneTree::_main_window_go_back));
+ root->connect("focus_entered", callable_mp(this, &SceneTree::_main_window_focus_in));
+
#ifdef TOOLS_ENABLED
edited_scene_root = NULL;
#endif
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 2f805d074f..319b5a7e74 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -36,12 +36,14 @@
#include "core/os/thread_safe.h"
#include "core/self_list.h"
#include "scene/resources/mesh.h"
-#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
+#include "scene/resources/world_3d.h"
+
+#undef Window
class PackedScene;
class Node;
-class Viewport;
+class Window;
class Material;
class Mesh;
class SceneDebugger;
@@ -76,22 +78,6 @@ class SceneTree : public MainLoop {
public:
typedef void (*IdleCallback)();
- enum StretchMode {
-
- STRETCH_MODE_DISABLED,
- STRETCH_MODE_2D,
- STRETCH_MODE_VIEWPORT,
- };
-
- enum StretchAspect {
-
- STRETCH_ASPECT_IGNORE,
- STRETCH_ASPECT_KEEP,
- STRETCH_ASPECT_KEEP_WIDTH,
- STRETCH_ASPECT_KEEP_HEIGHT,
- STRETCH_ASPECT_EXPAND,
- };
-
private:
struct Group {
@@ -101,7 +87,7 @@ private:
Group() { changed = false; };
};
- Viewport *root;
+ Window *root;
uint64_t tree_version;
float physics_process_time;
@@ -119,15 +105,12 @@ private:
Map<StringName, Group> group_map;
bool _quit;
bool initialized;
- bool input_handled;
- Size2 last_screen_size;
StringName tree_changed_name;
StringName node_added_name;
StringName node_removed_name;
StringName node_renamed_name;
- bool use_font_oversampling;
int64_t current_frame;
int64_t current_event;
int node_count;
@@ -147,14 +130,6 @@ private:
int call_lock;
Set<Node *> call_skip; //skip erased nodes
- StretchMode stretch_mode;
- StretchAspect stretch_aspect;
- Size2i stretch_min;
- real_t stretch_shrink;
-
- void _update_font_oversampling(float p_ratio);
- void _update_root_rect();
-
List<ObjectID> delete_queue;
Map<UGCall, Vector<Variant>> unique_group_calls;
@@ -208,14 +183,13 @@ private:
void make_group_changed(const StringName &p_group);
void _notify_group_pause(const StringName &p_group, int p_notification);
- void _call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input);
Variant _call_group_flags(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
Variant _call_group(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
void _flush_delete_queue();
//optimization
friend class CanvasItem;
- friend class Spatial;
+ friend class Node3D;
friend class Viewport;
SelfList<Node>::List xform_change_list;
@@ -232,6 +206,13 @@ private:
static int idle_callback_count;
void _call_idle_callbacks();
+ void _main_window_focus_in();
+ void _main_window_close();
+ void _main_window_go_back();
+
+ //used by viewport
+ void _call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input, Viewport *p_viewport);
+
protected:
void _notification(int p_notification);
static void _bind_methods();
@@ -249,7 +230,7 @@ public:
GROUP_CALL_MULTILEVEL = 8,
};
- _FORCE_INLINE_ Viewport *get_root() const { return root; }
+ _FORCE_INLINE_ Window *get_root() const { return root; }
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);
@@ -261,8 +242,6 @@ public:
void flush_transform_notifications();
- virtual void input_text(const String &p_text);
- virtual void input_event(const Ref<InputEvent> &p_event);
virtual void init();
virtual bool iteration(float p_time);
@@ -275,8 +254,6 @@ public:
void quit(int p_exit_code = -1);
- void set_input_as_handled();
- bool is_input_handled();
_FORCE_INLINE_ float get_physics_process_time() const { return physics_process_time; }
_FORCE_INLINE_ float get_idle_process_time() const { return idle_process_time; }
@@ -335,11 +312,6 @@ public:
void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list);
bool has_group(const StringName &p_identifier) const;
- void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 &p_minsize, real_t p_shrink = 1);
-
- void set_use_font_oversampling(bool p_oversampling);
- bool is_using_font_oversampling() const;
-
//void change_scene(const String& p_path);
//Node *get_loaded_scene();
@@ -359,8 +331,6 @@ public:
static SceneTree *get_singleton() { return singleton; }
- void drop_files(const Vector<String> &p_files, int p_from_screen = 0);
- void global_menu_action(const Variant &p_id, const Variant &p_meta);
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
//network API
@@ -388,8 +358,6 @@ public:
~SceneTree();
};
-VARIANT_ENUM_CAST(SceneTree::StretchMode);
-VARIANT_ENUM_CAST(SceneTree::StretchAspect);
VARIANT_ENUM_CAST(SceneTree::GroupCallFlags);
#endif
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 7c847095e1..7c847095e1 100755..100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
diff --git a/scene/main/timer.h b/scene/main/timer.h
index 044566738e..044566738e 100755..100644
--- a/scene/main/timer.h
+++ b/scene/main/timer.h
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8ef3bdd04e..b95e81a702 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -32,14 +32,14 @@
#include "core/core_string_names.h"
#include "core/debugger/engine_debugger.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "scene/2d/collision_object_2d.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/collision_object.h"
-#include "scene/3d/listener.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/collision_object_3d.h"
+#include "scene/3d/listener_3d.h"
+#include "scene/3d/node_3d.h"
#include "scene/3d/world_environment.h"
#include "scene/gui/control.h"
#include "scene/gui/label.h"
@@ -49,9 +49,11 @@
#include "scene/gui/popup_menu.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/timer.h"
+#include "scene/main/window.h"
#include "scene/resources/mesh.h"
#include "scene/scene_string_names.h"
-#include "servers/physics_2d_server.h"
+#include "servers/display_server.h"
+#include "servers/physics_server_2d.h"
void ViewportTexture::setup_local_to_scene() {
@@ -76,11 +78,11 @@ void ViewportTexture::setup_local_to_scene() {
vp->viewport_textures.insert(this);
if (proxy_ph.is_valid()) {
- VS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid);
- VS::get_singleton()->free(proxy_ph);
+ RS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid);
+ RS::get_singleton()->free(proxy_ph);
} else {
ERR_FAIL_COND(proxy.is_valid()); //should be invalid
- proxy = VS::get_singleton()->texture_proxy_create(vp->texture_rid);
+ proxy = RS::get_singleton()->texture_proxy_create(vp->texture_rid);
}
}
@@ -120,8 +122,8 @@ RID ViewportTexture::get_rid() const {
//ERR_FAIL_COND_V_MSG(!vp, RID(), "Viewport Texture must be set to use it.");
if (proxy.is_null()) {
- proxy_ph = VS::get_singleton()->texture_2d_placeholder_create();
- proxy = VS::get_singleton()->texture_proxy_create(proxy_ph);
+ proxy_ph = RS::get_singleton()->texture_2d_placeholder_create();
+ proxy = RS::get_singleton()->texture_proxy_create(proxy_ph);
}
return proxy;
}
@@ -133,7 +135,7 @@ bool ViewportTexture::has_alpha() const {
Ref<Image> ViewportTexture::get_data() const {
ERR_FAIL_COND_V_MSG(!vp, Ref<Image>(), "Viewport Texture must be set to use it.");
- return VS::get_singleton()->texture_2d_get(vp->texture_rid);
+ return RS::get_singleton()->texture_2d_get(vp->texture_rid);
}
void ViewportTexture::_bind_methods() {
@@ -141,7 +143,7 @@ void ViewportTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_viewport_path_in_scene", "path"), &ViewportTexture::set_viewport_path_in_scene);
ClassDB::bind_method(D_METHOD("get_viewport_path_in_scene"), &ViewportTexture::get_viewport_path_in_scene);
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "viewport_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Viewport", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT), "set_viewport_path_in_scene", "get_viewport_path_in_scene");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "viewport_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "SubViewport", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT), "set_viewport_path_in_scene", "get_viewport_path_in_scene");
}
ViewportTexture::ViewportTexture() {
@@ -157,18 +159,18 @@ ViewportTexture::~ViewportTexture() {
}
if (proxy_ph.is_valid()) {
- VS::get_singleton()->free(proxy_ph);
+ RS::get_singleton()->free(proxy_ph);
}
if (proxy.is_valid()) {
- VS::get_singleton()->free(proxy);
+ RS::get_singleton()->free(proxy);
}
}
/////////////////////////////////////
-class TooltipPanel : public PanelContainer {
+class TooltipPanel : public PopupPanel {
- GDCLASS(TooltipPanel, PanelContainer);
+ GDCLASS(TooltipPanel, PopupPanel);
public:
TooltipPanel(){};
@@ -184,39 +186,25 @@ public:
Viewport::GUI::GUI() {
+ embed_subwindows_hint = false;
+ embedding_subwindows = false;
+
dragging = false;
mouse_focus = NULL;
+ forced_mouse_focus = false;
mouse_click_grabber = NULL;
mouse_focus_mask = 0;
key_focus = NULL;
mouse_over = NULL;
+ drag_mouse_over = NULL;
tooltip = NULL;
tooltip_popup = NULL;
tooltip_label = NULL;
- subwindow_visibility_dirty = false;
- subwindow_order_dirty = false;
}
/////////////////////////////////////
-void Viewport::_update_stretch_transform() {
-
- if (size_override_stretch && size_override) {
-
- 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;
-
- } else {
-
- stretch_transform = Transform2D();
- }
-
- _update_global_transform();
-}
-
void Viewport::update_worlds() {
if (!is_inside_tree())
@@ -230,7 +218,7 @@ void Viewport::update_worlds() {
find_world()->_update(get_tree()->get_frame());
}
-void Viewport::_collision_object_input_event(CollisionObject *p_object, Camera *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
+void Viewport::_collision_object_input_event(CollisionObject3D *p_object, Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
Transform object_transform = p_object->get_global_transform();
Transform camera_transform = p_camera->get_global_transform();
@@ -249,6 +237,191 @@ void Viewport::_collision_object_input_event(CollisionObject *p_object, Camera *
physics_last_id = id;
}
+void Viewport::_sub_window_update_order() {
+
+ for (int i = 0; i < gui.sub_windows.size(); i++) {
+ RS::get_singleton()->canvas_item_set_draw_index(gui.sub_windows[i].canvas_item, i);
+ }
+}
+
+void Viewport::_sub_window_register(Window *p_window) {
+
+ ERR_FAIL_COND(!is_inside_tree());
+ for (int i = 0; i < gui.sub_windows.size(); i++) {
+ ERR_FAIL_COND(gui.sub_windows[i].window == p_window);
+ }
+
+ if (gui.sub_windows.size() == 0) {
+ subwindow_canvas = RS::get_singleton()->canvas_create();
+ RS::get_singleton()->viewport_attach_canvas(viewport, subwindow_canvas);
+ RS::get_singleton()->viewport_set_canvas_stacking(viewport, subwindow_canvas, SUBWINDOW_CANVAS_LAYER, 0);
+ }
+ SubWindow sw;
+ sw.canvas_item = RS::get_singleton()->canvas_item_create();
+ RS::get_singleton()->canvas_item_set_parent(sw.canvas_item, subwindow_canvas);
+ sw.window = p_window;
+ gui.sub_windows.push_back(sw);
+
+ _sub_window_grab_focus(p_window);
+
+ RenderingServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, viewport);
+}
+
+void Viewport::_sub_window_update(Window *p_window) {
+
+ int index = -1;
+ for (int i = 0; i < gui.sub_windows.size(); i++) {
+ if (gui.sub_windows[i].window == p_window) {
+ index = i;
+ break;
+ }
+ }
+
+ ERR_FAIL_COND(index == -1);
+
+ const SubWindow &sw = gui.sub_windows[index];
+
+ Transform2D pos;
+ pos.set_origin(p_window->get_position());
+ RS::get_singleton()->canvas_item_clear(sw.canvas_item);
+ Rect2i r = Rect2i(p_window->get_position(), sw.window->get_size());
+
+ if (!p_window->get_flag(Window::FLAG_BORDERLESS)) {
+ Ref<StyleBox> panel = p_window->get_theme_stylebox("panel_window");
+ panel->draw(sw.canvas_item, r);
+
+ // Draw the title bar text.
+ Ref<Font> title_font = p_window->get_theme_font("title_font");
+ Color title_color = p_window->get_theme_color("title_color");
+ int title_height = p_window->get_theme_constant("title_height");
+ int font_height = title_font->get_height() - title_font->get_descent() * 2;
+ int x = (r.size.width - title_font->get_string_size(p_window->get_title()).x) / 2;
+ int y = (-title_height + font_height) / 2;
+
+ int close_h_ofs = p_window->get_theme_constant("close_h_ofs");
+ int close_v_ofs = p_window->get_theme_constant("close_v_ofs");
+
+ title_font->draw(sw.canvas_item, r.position + Point2(x, y), p_window->get_title(), title_color, r.size.width - panel->get_minimum_size().x - close_h_ofs);
+
+ bool hl = gui.subwindow_focused == sw.window && gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE && gui.subwindow_drag_close_inside;
+
+ Ref<Texture2D> close_icon = p_window->get_theme_icon(hl ? "close_highlight" : "close");
+ close_icon->draw(sw.canvas_item, r.position + Vector2(r.size.width - close_h_ofs, -close_v_ofs));
+ }
+
+ RS::get_singleton()->canvas_item_add_texture_rect(sw.canvas_item, r, sw.window->get_texture()->get_rid());
+}
+
+void Viewport::_sub_window_grab_focus(Window *p_window) {
+
+ if (p_window == nullptr) {
+ //release current focus
+ if (gui.subwindow_focused) {
+ gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_OUT);
+ gui.subwindow_focused = nullptr;
+ gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
+ }
+
+ Window *this_window = Object::cast_to<Window>(this);
+ if (this_window) {
+ this_window->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_IN);
+ }
+
+ return;
+ }
+
+ int index = -1;
+ for (int i = 0; i < gui.sub_windows.size(); i++) {
+ if (gui.sub_windows[i].window == p_window) {
+ index = i;
+ break;
+ }
+ }
+
+ ERR_FAIL_COND(index == -1);
+
+ if (p_window->get_flag(Window::FLAG_NO_FOCUS)) {
+ //can only move to foreground, but no focus granted
+ SubWindow sw = gui.sub_windows[index];
+ gui.sub_windows.remove(index);
+ gui.sub_windows.push_back(sw);
+ index = gui.sub_windows.size() - 1;
+ _sub_window_update_order();
+ return; //i guess not...
+ }
+
+ if (gui.subwindow_focused) {
+ if (gui.subwindow_focused == p_window) {
+ return; //nothing to do
+ }
+ gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_OUT);
+ gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
+ } else {
+ Window *this_window = Object::cast_to<Window>(this);
+ if (this_window) {
+ this_window->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_OUT);
+ }
+ }
+
+ Window *old_focus = gui.subwindow_focused;
+
+ gui.subwindow_focused = p_window;
+
+ gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_IN);
+
+ { //move to foreground
+ SubWindow sw = gui.sub_windows[index];
+ gui.sub_windows.remove(index);
+ gui.sub_windows.push_back(sw);
+ index = gui.sub_windows.size() - 1;
+ _sub_window_update_order();
+ }
+
+ if (old_focus) {
+ _sub_window_update(old_focus);
+ }
+
+ _sub_window_update(p_window);
+}
+
+void Viewport::_sub_window_remove(Window *p_window) {
+
+ for (int i = 0; i < gui.sub_windows.size(); i++) {
+ if (gui.sub_windows[i].window == p_window) {
+ RS::get_singleton()->free(gui.sub_windows[i].canvas_item);
+ gui.sub_windows.remove(i);
+ break;
+ }
+ }
+
+ if (gui.sub_windows.size() == 0) {
+ RS::get_singleton()->free(subwindow_canvas);
+ subwindow_canvas = RID();
+ }
+
+ if (gui.subwindow_focused == p_window) {
+ Window *parent_visible = p_window->get_parent_visible_window();
+
+ gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
+
+ gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_OUT);
+
+ if (parent_visible && parent_visible != this) {
+
+ gui.subwindow_focused = parent_visible;
+ gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_IN);
+ } else {
+ gui.subwindow_focused = nullptr;
+ Window *this_window = Object::cast_to<Window>(this);
+ if (this_window) {
+ this_window->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_IN);
+ }
+ }
+ }
+
+ RenderingServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, p_window->parent ? p_window->parent->viewport : RID());
+}
+
void Viewport::_own_world_changed() {
ERR_FAIL_COND(world.is_null());
ERR_FAIL_COND(own_world.is_null());
@@ -264,7 +437,7 @@ void Viewport::_own_world_changed() {
}
if (is_inside_tree()) {
- VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
+ RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
}
_update_listener();
@@ -276,16 +449,18 @@ void Viewport::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
+ gui.embedding_subwindows = gui.embed_subwindows_hint;
+
if (get_parent()) {
parent = get_parent()->get_viewport();
- VisualServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid());
+ RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid());
} else {
parent = NULL;
}
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);
+ RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
+ RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
_update_listener();
_update_listener_2d();
@@ -295,28 +470,27 @@ void Viewport::_notification(int p_what) {
add_to_group("_viewports");
if (get_tree()->is_debugging_collisions_hint()) {
//2D
- Physics2DServer::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(), get_tree()->get_collision_debug_contact_count());
- contact_2d_debug = VisualServer::get_singleton()->canvas_item_create();
- VisualServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas());
+ PhysicsServer2D::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(), get_tree()->get_collision_debug_contact_count());
+ contact_2d_debug = RenderingServer::get_singleton()->canvas_item_create();
+ RenderingServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas());
//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_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), VS::MULTIMESH_TRANSFORM_3D, true);
- 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();
- VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
- VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario());
- //VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
- }
-
- VS::get_singleton()->viewport_set_active(viewport, true);
+ PhysicsServer3D::get_singleton()->space_set_debug_contacts(find_world()->get_space(), get_tree()->get_collision_debug_contact_count());
+ contact_3d_debug_multimesh = RenderingServer::get_singleton()->multimesh_create();
+ RenderingServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, true);
+ RenderingServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0);
+ RenderingServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid());
+ contact_3d_debug_instance = RenderingServer::get_singleton()->instance_create();
+ RenderingServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
+ RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario());
+ //RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
+ }
+
} break;
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
if (listeners.size() && !listener) {
- Listener *first = NULL;
- for (Set<Listener *>::Element *E = listeners.front(); E; E = E->next()) {
+ Listener3D *first = NULL;
+ for (Set<Listener3D *>::Element *E = listeners.front(); E; E = E->next()) {
if (first == NULL || first->is_greater_than(E->get())) {
first = E->get();
@@ -329,8 +503,8 @@ void Viewport::_notification(int p_what) {
if (cameras.size() && !camera) {
//there are cameras but no current camera, pick first in tree and make it current
- Camera *first = NULL;
- for (Set<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
+ Camera3D *first = NULL;
+ for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
if (first == NULL || first->is_greater_than(E->get())) {
first = E->get();
@@ -353,24 +527,24 @@ void Viewport::_notification(int p_what) {
if (world_2d.is_valid())
world_2d->_remove_viewport(this);
- VisualServer::get_singleton()->viewport_set_scenario(viewport, RID());
- // SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
- VisualServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
+ RenderingServer::get_singleton()->viewport_set_scenario(viewport, RID());
+ RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
if (contact_2d_debug.is_valid()) {
- VisualServer::get_singleton()->free(contact_2d_debug);
+ RenderingServer::get_singleton()->free(contact_2d_debug);
contact_2d_debug = RID();
}
if (contact_3d_debug_multimesh.is_valid()) {
- VisualServer::get_singleton()->free(contact_3d_debug_multimesh);
- VisualServer::get_singleton()->free(contact_3d_debug_instance);
+ RenderingServer::get_singleton()->free(contact_3d_debug_multimesh);
+ RenderingServer::get_singleton()->free(contact_3d_debug_instance);
contact_3d_debug_instance = RID();
contact_3d_debug_multimesh = RID();
}
remove_from_group("_viewports");
- VS::get_singleton()->viewport_set_active(viewport, false);
+ RS::get_singleton()->viewport_set_active(viewport, false);
+ RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID());
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
@@ -387,36 +561,36 @@ 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_set_draw_index(contact_2d_debug, 0xFFFFF); //very high index
+ RenderingServer::get_singleton()->canvas_item_clear(contact_2d_debug);
+ RenderingServer::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());
+ Vector<Vector2> points = PhysicsServer2D::get_singleton()->space_get_contacts(find_world_2d()->get_space());
+ int point_count = PhysicsServer2D::get_singleton()->space_get_contact_count(find_world_2d()->get_space());
Color ccol = get_tree()->get_debug_collision_contact_color();
for (int i = 0; i < point_count; i++) {
- VisualServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol);
+ RenderingServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol);
}
}
if (get_tree()->is_debugging_collisions_hint() && contact_3d_debug_multimesh.is_valid()) {
- Vector<Vector3> points = PhysicsServer::get_singleton()->space_get_contacts(find_world()->get_space());
- int point_count = PhysicsServer::get_singleton()->space_get_contact_count(find_world()->get_space());
+ Vector<Vector3> points = PhysicsServer3D::get_singleton()->space_get_contacts(find_world()->get_space());
+ int point_count = PhysicsServer3D::get_singleton()->space_get_contact_count(find_world()->get_space());
- VS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count);
+ RS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count);
}
- if (physics_object_picking && (to_screen_rect == Rect2() || Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED)) {
+ if (physics_object_picking && (to_screen_rect == Rect2i() || InputFilter::get_singleton()->get_mouse_mode() != InputFilter::MOUSE_MODE_CAPTURED)) {
#ifndef _3D_DISABLED
Vector2 last_pos(1e20, 1e20);
- CollisionObject *last_object = NULL;
+ CollisionObject3D *last_object = NULL;
ObjectID last_id;
#endif
- PhysicsDirectSpaceState::RayResult result;
- Physics2DDirectSpaceState *ss2d = Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
+ PhysicsDirectSpaceState3D::RayResult result;
+ PhysicsDirectSpaceState2D *ss2d = PhysicsServer2D::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
if (physics_has_last_mousepos) {
// if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved.
@@ -433,6 +607,7 @@ void Viewport::_notification(int p_what) {
if (!has_mouse_event) {
Ref<InputEventMouseMotion> mm;
mm.instance();
+
mm->set_device(InputEvent::DEVICE_ID_INTERNAL);
mm->set_global_position(physics_last_mousepos);
mm->set_position(physics_last_mousepos);
@@ -522,7 +697,7 @@ void Viewport::_notification(int p_what) {
uint64_t frame = get_tree()->get_frame();
- Physics2DDirectSpaceState::ShapeResult res[64];
+ PhysicsDirectSpaceState2D::ShapeResult res[64];
for (Set<CanvasLayer *>::Element *E = canvas_layers.front(); E; E = E->next()) {
Transform2D canvas_transform;
ObjectID canvas_layer_id;
@@ -597,7 +772,7 @@ void Viewport::_notification(int p_what) {
if (physics_object_capture.is_valid()) {
- CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_capture));
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_capture));
if (co && camera) {
_collision_object_input_event(co, camera, ev, Vector3(), Vector3(), 0);
captured = true;
@@ -630,14 +805,14 @@ void Viewport::_notification(int p_what) {
Vector3 from = camera->project_ray_origin(pos);
Vector3 dir = camera->project_ray_normal(pos);
- PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space());
+ PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world()->get_space());
if (space) {
bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true);
ObjectID new_collider;
if (col) {
- CollisionObject *co = Object::cast_to<CollisionObject>(result.collider);
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(result.collider);
if (co) {
_collision_object_input_event(co, camera, ev, result.position, result.normal, result.shape);
@@ -654,7 +829,7 @@ void Viewport::_notification(int p_what) {
if (physics_object_over.is_valid()) {
- CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_over));
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over));
if (co) {
co->_mouse_exit();
}
@@ -662,7 +837,7 @@ void Viewport::_notification(int p_what) {
if (new_collider.is_valid()) {
- CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(new_collider));
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(new_collider));
if (co) {
co->_mouse_enter();
}
@@ -680,13 +855,12 @@ void Viewport::_notification(int p_what) {
}
} break;
- case SceneTree::NOTIFICATION_WM_MOUSE_EXIT:
- case SceneTree::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_WM_MOUSE_EXIT:
+ case NOTIFICATION_WM_FOCUS_OUT: {
_drop_physics_mouseover();
- if (gui.mouse_focus) {
- //if mouse is being pressed, send a release event
+ if (gui.mouse_focus && !gui.forced_mouse_focus) {
_drop_mouse_focus();
}
} break;
@@ -698,16 +872,6 @@ RID Viewport::get_viewport_rid() const {
return viewport;
}
-void Viewport::set_use_arvr(bool p_use_arvr) {
- arvr = p_use_arvr;
-
- VS::get_singleton()->viewport_set_use_arvr(viewport, arvr);
-}
-
-bool Viewport::use_arvr() {
- return arvr;
-}
-
void Viewport::update_canvas_items() {
if (!is_inside_tree())
return;
@@ -715,48 +879,53 @@ void Viewport::update_canvas_items() {
_update_canvas_items(this);
}
-void Viewport::set_size(const Size2 &p_size) {
+void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated) {
- if (size == p_size.floor())
+ if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_override == size_override && to_screen_rect != p_to_screen_rect)
return;
- size = p_size.floor();
- VS::get_singleton()->viewport_set_size(viewport, size.width, size.height);
+ size = p_size;
+ size_allocated = p_allocated;
+ size_override = p_size_override;
+ stretch_transform = p_stretch_transform;
+ to_screen_rect = p_to_screen_rect;
+
+ if (p_allocated) {
+ RS::get_singleton()->viewport_set_size(viewport, size.width, size.height);
+ } else {
+ RS::get_singleton()->viewport_set_size(viewport, 0, 0);
+ }
+ _update_global_transform();
- _update_stretch_transform();
+ update_canvas_items();
emit_signal("size_changed");
}
+Size2i Viewport::_get_size() const {
+ return size;
+}
+bool Viewport::_is_size_allocated() const {
+ return size_allocated;
+}
+
Rect2 Viewport::get_visible_rect() const {
Rect2 r;
if (size == Size2()) {
- r = Rect2(Point2(), OS::get_singleton()->get_window_size());
+ r = Rect2(Point2(), DisplayServer::get_singleton()->window_get_size());
} else {
r = Rect2(Point2(), size);
}
- if (size_override) {
- r.size = size_override_size;
+ if (size_override != Size2i()) {
+ r.size = size_override;
}
return r;
}
-Size2 Viewport::get_size() const {
-
- return size;
-}
-
void Viewport::_update_listener() {
- /*
- if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (Object::cast_to<Control>(get_parent()) && Object::cast_to<Control>(get_parent())->is_visible_in_tree()))) {
- SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, find_world()->get_sound_space());
- } else {
- SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
- }
-*/
}
void Viewport::_update_listener_2d() {
@@ -805,9 +974,9 @@ void Viewport::enable_canvas_transform_override(bool p_enable) {
override_canvas_transform = p_enable;
if (p_enable) {
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override);
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override);
} else {
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform);
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform);
}
}
@@ -822,7 +991,7 @@ void Viewport::set_canvas_transform_override(const Transform2D &p_transform) {
canvas_transform_override = p_transform;
if (override_canvas_transform) {
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override);
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override);
}
}
@@ -835,7 +1004,7 @@ void Viewport::set_canvas_transform(const Transform2D &p_transform) {
canvas_transform = p_transform;
if (!override_canvas_transform) {
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform);
+ RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform);
}
}
@@ -848,7 +1017,7 @@ void Viewport::_update_global_transform() {
Transform2D sxform = stretch_transform * global_canvas_transform;
- VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform);
+ RenderingServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform);
}
void Viewport::set_global_canvas_transform(const Transform2D &p_transform) {
@@ -864,14 +1033,9 @@ Transform2D Viewport::get_global_canvas_transform() const {
}
void Viewport::_listener_transform_changed_notify() {
-
-#ifndef _3D_DISABLED
-//if (listener)
-// SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, listener->get_listener_transform());
-#endif
}
-void Viewport::_listener_set(Listener *p_listener) {
+void Viewport::_listener_set(Listener3D *p_listener) {
#ifndef _3D_DISABLED
@@ -885,13 +1049,13 @@ void Viewport::_listener_set(Listener *p_listener) {
#endif
}
-bool Viewport::_listener_add(Listener *p_listener) {
+bool Viewport::_listener_add(Listener3D *p_listener) {
listeners.insert(p_listener);
return listeners.size() == 1;
}
-void Viewport::_listener_remove(Listener *p_listener) {
+void Viewport::_listener_remove(Listener3D *p_listener) {
listeners.erase(p_listener);
if (listener == p_listener) {
@@ -900,10 +1064,10 @@ void Viewport::_listener_remove(Listener *p_listener) {
}
#ifndef _3D_DISABLED
-void Viewport::_listener_make_next_current(Listener *p_exclude) {
+void Viewport::_listener_make_next_current(Listener3D *p_exclude) {
if (listeners.size() > 0) {
- for (Set<Listener *>::Element *E = listeners.front(); E; E = E->next()) {
+ for (Set<Listener3D *>::Element *E = listeners.front(); E; E = E->next()) {
if (p_exclude == E->get())
continue;
@@ -927,13 +1091,10 @@ void Viewport::_listener_make_next_current(Listener *p_exclude) {
void Viewport::_camera_transform_changed_notify() {
#ifndef _3D_DISABLED
-// If there is an active listener in the scene, it takes priority over the camera
-// if (camera && !listener)
-// SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, camera->get_camera_transform());
#endif
}
-void Viewport::_camera_set(Camera *p_camera) {
+void Viewport::_camera_set(Camera3D *p_camera) {
#ifndef _3D_DISABLED
@@ -941,18 +1102,20 @@ void Viewport::_camera_set(Camera *p_camera) {
return;
if (camera) {
- camera->notification(Camera::NOTIFICATION_LOST_CURRENT);
+ camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT);
}
+
camera = p_camera;
+
if (!camera_override) {
if (camera)
- VisualServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera());
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera());
else
- VisualServer::get_singleton()->viewport_attach_camera(viewport, RID());
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID());
}
if (camera) {
- camera->notification(Camera::NOTIFICATION_BECAME_CURRENT);
+ camera->notification(Camera3D::NOTIFICATION_BECAME_CURRENT);
}
_update_listener();
@@ -960,25 +1123,25 @@ void Viewport::_camera_set(Camera *p_camera) {
#endif
}
-bool Viewport::_camera_add(Camera *p_camera) {
+bool Viewport::_camera_add(Camera3D *p_camera) {
cameras.insert(p_camera);
return cameras.size() == 1;
}
-void Viewport::_camera_remove(Camera *p_camera) {
+void Viewport::_camera_remove(Camera3D *p_camera) {
cameras.erase(p_camera);
if (camera == p_camera) {
- camera->notification(Camera::NOTIFICATION_LOST_CURRENT);
+ camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT);
camera = NULL;
}
}
#ifndef _3D_DISABLED
-void Viewport::_camera_make_next_current(Camera *p_exclude) {
+void Viewport::_camera_make_next_current(Camera3D *p_exclude) {
- for (Set<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
+ for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
if (p_exclude == E->get())
continue;
@@ -1005,7 +1168,7 @@ void Viewport::_canvas_layer_remove(CanvasLayer *p_canvas_layer) {
void Viewport::set_transparent_background(bool p_enable) {
transparent_bg = p_enable;
- VS::get_singleton()->viewport_set_transparent_background(viewport, p_enable);
+ RS::get_singleton()->viewport_set_transparent_background(viewport, p_enable);
}
bool Viewport::has_transparent_background() const {
@@ -1024,7 +1187,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
if (is_inside_tree()) {
find_world_2d()->_remove_viewport(this);
- VisualServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
+ RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
}
if (p_world_2d.is_valid())
@@ -1038,7 +1201,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
if (is_inside_tree()) {
current_canvas = find_world_2d()->get_canvas();
- VisualServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
+ RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
find_world_2d()->_register_viewport(this, Rect2());
}
}
@@ -1060,17 +1223,20 @@ void Viewport::_propagate_enter_world(Node *p_node) {
if (!p_node->is_inside_tree()) //may not have entered scene yet
return;
- if (Object::cast_to<Spatial>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
-
- p_node->notification(Spatial::NOTIFICATION_ENTER_WORLD);
+#ifndef _3D_DISABLED
+ if (Object::cast_to<Node3D>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
+ p_node->notification(Node3D::NOTIFICATION_ENTER_WORLD);
} else {
+#endif
Viewport *v = Object::cast_to<Viewport>(p_node);
if (v) {
if (v->world.is_valid() || v->own_world.is_valid())
return;
}
+#ifndef _3D_DISABLED
}
+#endif
}
for (int i = 0; i < p_node->get_child_count(); i++) {
@@ -1097,17 +1263,20 @@ void Viewport::_propagate_exit_world(Node *p_node) {
if (!p_node->is_inside_tree()) //may have exited scene already
return;
- if (Object::cast_to<Spatial>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
-
- p_node->notification(Spatial::NOTIFICATION_EXIT_WORLD);
+#ifndef _3D_DISABLED
+ if (Object::cast_to<Node3D>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
+ p_node->notification(Node3D::NOTIFICATION_EXIT_WORLD);
} else {
+#endif
Viewport *v = Object::cast_to<Viewport>(p_node);
if (v) {
if (v->world.is_valid() || v->own_world.is_valid())
return;
}
+#ifndef _3D_DISABLED
}
+#endif
}
for (int i = 0; i < p_node->get_child_count(); i++) {
@@ -1116,7 +1285,7 @@ void Viewport::_propagate_exit_world(Node *p_node) {
}
}
-void Viewport::set_world(const Ref<World> &p_world) {
+void Viewport::set_world(const Ref<World3D> &p_world) {
if (world == p_world)
return;
@@ -1135,7 +1304,7 @@ void Viewport::set_world(const Ref<World> &p_world) {
own_world = world->duplicate();
world->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
} else {
- own_world = Ref<World>(memnew(World));
+ own_world = Ref<World3D>(memnew(World3D));
}
}
@@ -1143,13 +1312,13 @@ void Viewport::set_world(const Ref<World> &p_world) {
_propagate_enter_world(this);
if (is_inside_tree()) {
- VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
+ RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
}
_update_listener();
}
-Ref<World> Viewport::get_world() const {
+Ref<World3D> Viewport::get_world() const {
return world;
}
@@ -1159,7 +1328,7 @@ Ref<World2D> Viewport::get_world_2d() const {
return world_2d;
}
-Ref<World> Viewport::find_world() const {
+Ref<World3D> Viewport::find_world() const {
if (own_world.is_valid())
return own_world;
@@ -1168,15 +1337,15 @@ Ref<World> Viewport::find_world() const {
else if (parent)
return parent->find_world();
else
- return Ref<World>();
+ return Ref<World3D>();
}
-Listener *Viewport::get_listener() const {
+Listener3D *Viewport::get_listener() const {
return listener;
}
-Camera *Viewport::get_camera() const {
+Camera3D *Viewport::get_camera() const {
return camera;
}
@@ -1188,18 +1357,18 @@ void Viewport::enable_camera_override(bool p_enable) {
}
if (p_enable) {
- camera_override.rid = VisualServer::get_singleton()->camera_create();
+ camera_override.rid = RenderingServer::get_singleton()->camera_create();
} else {
- VisualServer::get_singleton()->free(camera_override.rid);
+ RenderingServer::get_singleton()->free(camera_override.rid);
camera_override.rid = RID();
}
if (p_enable) {
- VisualServer::get_singleton()->viewport_attach_camera(viewport, camera_override.rid);
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera_override.rid);
} else if (camera) {
- VisualServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera());
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera());
} else {
- VisualServer::get_singleton()->viewport_attach_camera(viewport, RID());
+ RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID());
}
#endif
}
@@ -1211,7 +1380,7 @@ bool Viewport::is_camera_override_enabled() const {
void Viewport::set_camera_override_transform(const Transform &p_transform) {
if (camera_override) {
camera_override.transform = p_transform;
- VisualServer::get_singleton()->camera_set_transform(camera_override.rid, p_transform);
+ RenderingServer::get_singleton()->camera_set_transform(camera_override.rid, p_transform);
}
}
@@ -1234,7 +1403,7 @@ void Viewport::set_camera_override_perspective(float p_fovy_degrees, float p_z_n
camera_override.z_far = p_z_far;
camera_override.projection = CameraOverrideData::PROJECTION_PERSPECTIVE;
- VisualServer::get_singleton()->camera_set_perspective(camera_override.rid, camera_override.fov, camera_override.z_near, camera_override.z_far);
+ RenderingServer::get_singleton()->camera_set_perspective(camera_override.rid, camera_override.fov, camera_override.z_near, camera_override.z_far);
}
}
@@ -1249,7 +1418,7 @@ void Viewport::set_camera_override_orthogonal(float p_size, float p_z_near, floa
camera_override.z_far = p_z_far;
camera_override.projection = CameraOverrideData::PROJECTION_ORTHOGONAL;
- VisualServer::get_singleton()->camera_set_orthogonal(camera_override.rid, camera_override.size, camera_override.z_near, camera_override.z_far);
+ RenderingServer::get_singleton()->camera_set_orthogonal(camera_override.rid, camera_override.size, camera_override.z_near, camera_override.z_far);
}
}
@@ -1278,77 +1447,18 @@ void Viewport::_update_canvas_items(Node *p_node) {
}
}
-void Viewport::set_size_override(bool p_enable, const Size2 &p_size, const Vector2 &p_margin) {
-
- if (size_override == p_enable && p_size == size_override_size)
- return;
-
- size_override = p_enable;
- if (p_size.x >= 0 || p_size.y >= 0) {
- size_override_size = p_size;
- }
- size_override_margin = p_margin;
-
- _update_stretch_transform();
- emit_signal("size_changed");
-}
-
-Size2 Viewport::get_size_override() const {
-
- return size_override_size;
-}
-bool Viewport::is_size_override_enabled() const {
-
- return size_override;
-}
-void Viewport::set_size_override_stretch(bool p_enable) {
-
- if (p_enable == size_override_stretch)
- return;
-
- size_override_stretch = p_enable;
-
- _update_stretch_transform();
-}
-
-bool Viewport::is_size_override_stretch_enabled() const {
-
- return size_override_stretch;
-}
-
-void Viewport::set_update_mode(UpdateMode p_mode) {
-
- update_mode = p_mode;
- VS::get_singleton()->viewport_set_update_mode(viewport, VS::ViewportUpdateMode(p_mode));
-}
-Viewport::UpdateMode Viewport::get_update_mode() const {
-
- return update_mode;
-}
-
Ref<ViewportTexture> Viewport::get_texture() const {
return default_texture;
}
-void Viewport::set_clear_mode(ClearMode p_mode) {
-
- clear_mode = p_mode;
- VS::get_singleton()->viewport_set_clear_mode(viewport, VS::ViewportClearMode(p_mode));
-}
-
-Viewport::ClearMode Viewport::get_clear_mode() const {
-
- return clear_mode;
-}
-
void Viewport::set_shadow_atlas_size(int p_size) {
if (shadow_atlas_size == p_size)
return;
shadow_atlas_size = p_size;
- VS::get_singleton()->viewport_set_shadow_atlas_size(viewport, p_size);
+ RS::get_singleton()->viewport_set_shadow_atlas_size(viewport, p_size);
}
int Viewport::get_shadow_atlas_size() const {
@@ -1367,7 +1477,7 @@ void Viewport::set_shadow_atlas_quadrant_subdiv(int p_quadrant, ShadowAtlasQuadr
shadow_atlas_quadrant_subdiv[p_quadrant] = p_subdiv;
static const int subdiv[SHADOW_ATLAS_QUADRANT_SUBDIV_MAX] = { 0, 1, 4, 16, 64, 256, 1024 };
- VS::get_singleton()->viewport_set_shadow_atlas_quadrant_subdivision(viewport, p_quadrant, subdiv[p_subdiv]);
+ RS::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 {
@@ -1379,7 +1489,7 @@ Transform2D Viewport::_get_input_pre_xform() const {
Transform2D pre_xf;
- if (to_screen_rect != Rect2()) {
+ if (to_screen_rect.size.x != 0 && to_screen_rect.size.y != 0) {
pre_xf.elements[2] = -to_screen_rect.position;
pre_xf.scale(size / to_screen_rect.size);
@@ -1388,118 +1498,22 @@ Transform2D Viewport::_get_input_pre_xform() const {
return pre_xf;
}
-Vector2 Viewport::_get_window_offset() const {
-
- if (get_parent() && get_parent()->has_method("get_global_position")) {
- return get_parent()->call("get_global_position");
- }
- return Vector2();
-}
-
Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
- Vector2 vp_ofs = _get_window_offset();
Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
- return ev->xformed_by(ai, -vp_ofs);
-}
-
-void Viewport::_vp_input_text(const String &p_text) {
-
- if (gui.key_focus) {
- gui.key_focus->call("set_text", p_text);
- }
-}
-
-void Viewport::_vp_input(const Ref<InputEvent> &p_ev) {
-
- if (disable_input)
- return;
-
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
- return;
- }
-#endif
-
- 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
- //they are converted to viewport coordinates
-
- Ref<InputEvent> ev = _make_input_local(p_ev);
- input(ev);
-}
-
-void Viewport::_vp_unhandled_input(const Ref<InputEvent> &p_ev) {
-
- if (disable_input)
- return;
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
- return;
- }
-#endif
-
- /*
- if (parent_control && !parent_control->is_visible_in_tree())
- return;
- */
-
- 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
- //they are converted to viewport coordinates
-
- Ref<InputEvent> ev = _make_input_local(p_ev);
- unhandled_input(ev);
+ return ev->xformed_by(ai);
}
Vector2 Viewport::get_mouse_position() const {
- return (get_final_transform().affine_inverse() * _get_input_pre_xform()).xform(Input::get_singleton()->get_mouse_position() - _get_window_offset());
+ return gui.last_mouse_pos;
}
void Viewport::warp_mouse(const Vector2 &p_pos) {
Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos);
- Input::get_singleton()->warp_mouse_position(gpos);
-}
-
-void Viewport::_gui_prepare_subwindows() {
-
- if (gui.subwindow_visibility_dirty) {
-
- gui.subwindows.clear();
- for (List<Control *>::Element *E = gui.all_known_subwindows.front(); E; E = E->next()) {
- if (E->get()->is_visible_in_tree()) {
- gui.subwindows.push_back(E->get());
- }
- }
-
- gui.subwindow_visibility_dirty = false;
- gui.subwindow_order_dirty = true;
- }
-
- _gui_sort_subwindows();
-}
-
-void Viewport::_gui_sort_subwindows() {
-
- if (!gui.subwindow_order_dirty)
- return;
-
- gui.modal_stack.sort_custom<Control::CComparator>();
- gui.subwindows.sort_custom<Control::CComparator>();
-
- gui.subwindow_order_dirty = false;
-}
-
-void Viewport::_gui_sort_modal_stack() {
-
- gui.modal_stack.sort_custom<Control::CComparator>();
+ InputFilter::get_singleton()->warp_mouse_position(gpos);
}
void Viewport::_gui_sort_roots() {
@@ -1575,47 +1589,49 @@ void Viewport::_gui_show_tooltip() {
Control *rp = which;
- gui.tooltip_popup = which->make_custom_tooltip(tooltip);
-
- if (!gui.tooltip_popup) {
- gui.tooltip_popup = memnew(TooltipPanel);
+ Control *base_tooltip = which->make_custom_tooltip(tooltip);
+ if (!base_tooltip) {
gui.tooltip_label = memnew(TooltipLabel);
- gui.tooltip_popup->add_child(gui.tooltip_label);
-
- Ref<StyleBox> ttp = gui.tooltip_label->get_stylebox("panel", "TooltipPanel");
-
- gui.tooltip_label->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, ttp->get_margin(MARGIN_LEFT));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, ttp->get_margin(MARGIN_TOP));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -ttp->get_margin(MARGIN_RIGHT));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -ttp->get_margin(MARGIN_BOTTOM));
gui.tooltip_label->set_text(tooltip);
+ base_tooltip = gui.tooltip_label;
}
+ base_tooltip->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+
+ TooltipPanel *panel = memnew(TooltipPanel);
+ panel->set_transient(false);
+ panel->set_flag(Window::FLAG_NO_FOCUS, true);
+ panel->set_wrap_controls(true);
+ panel->add_child(base_tooltip);
+
+ gui.tooltip_popup = panel;
+
rp->add_child(gui.tooltip_popup);
- gui.tooltip_popup->force_parent_owned();
- gui.tooltip_popup->set_as_toplevel(true);
- if (gui.tooltip) // Avoids crash when rapidly switching controls.
- gui.tooltip_popup->set_scale(gui.tooltip->get_global_transform().get_scale());
+
+ //if (gui.tooltip) // Avoids crash when rapidly switching controls.
+ // gui.tooltip_popup->set_scale(gui.tooltip->get_global_transform().get_scale());
Point2 tooltip_offset = ProjectSettings::get_singleton()->get("display/mouse_cursor/tooltip_position_offset");
- Rect2 r(gui.tooltip_pos + tooltip_offset, gui.tooltip_popup->get_minimum_size());
- Rect2 vr = gui.tooltip_popup->get_viewport_rect();
- if (r.size.x * gui.tooltip_popup->get_scale().x + r.position.x > vr.size.x)
- r.position.x = vr.size.x - r.size.x * gui.tooltip_popup->get_scale().x;
- else if (r.position.x < 0)
- r.position.x = 0;
-
- if (r.size.y * gui.tooltip_popup->get_scale().y + r.position.y > vr.size.y)
- r.position.y = vr.size.y - r.size.y * gui.tooltip_popup->get_scale().y;
- else if (r.position.y < 0)
- r.position.y = 0;
-
- gui.tooltip_popup->set_global_position(r.position);
+ Rect2 r(gui.tooltip_pos + tooltip_offset, gui.tooltip_popup->get_contents_minimum_size());
+
+ Rect2i vr = gui.tooltip_popup->get_parent_visible_window()->get_usable_parent_rect();
+
+ if (r.size.x + r.position.x > vr.size.x + vr.position.x)
+ r.position.x = vr.position.x + vr.size.x - r.size.x;
+ else if (r.position.x < vr.position.x)
+ r.position.x = vr.position.x;
+
+ if (r.size.y + r.position.y > vr.size.y + vr.position.y)
+ r.position.y = vr.position.y + vr.size.y - r.size.y;
+ else if (r.position.y < vr.position.y)
+ r.position.y = vr.position.y;
+
+ gui.tooltip_popup->set_position(r.position);
gui.tooltip_popup->set_size(r.size);
- gui.tooltip_popup->raise();
gui.tooltip_popup->show();
+ gui.tooltip_popup->child_controls_changed();
}
void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_input) {
@@ -1704,26 +1720,7 @@ void Viewport::_gui_call_notification(Control *p_control, int p_what) {
}
Control *Viewport::_gui_find_control(const Point2 &p_global) {
- _gui_prepare_subwindows();
-
- for (List<Control *>::Element *E = gui.subwindows.back(); E; E = E->prev()) {
-
- Control *sw = E->get();
- if (!sw->is_visible_in_tree())
- continue;
-
- Transform2D xform;
- CanvasItem *pci = sw->get_parent_item();
- if (pci)
- xform = pci->get_global_transform_with_canvas();
- else
- xform = sw->get_canvas_transform();
-
- Control *ret = _gui_find_control_at_pos(sw, p_global, xform, gui.focus_inv_xform);
- if (ret)
- return ret;
- }
-
+ //aca va subwindows
_gui_sort_roots();
for (List<Control *>::Element *E = gui.roots.back(); E; E = E->prev()) {
@@ -1752,8 +1749,6 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
if (Object::cast_to<Viewport>(p_node))
return NULL;
- //subwindows first!!
-
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
@@ -1770,9 +1765,6 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- if (p_node == gui.tooltip_popup)
- continue;
-
CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i));
if (!ci || ci->is_set_as_toplevel())
continue;
@@ -1858,39 +1850,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
bool is_handled = false;
- _gui_sort_modal_stack();
- while (!gui.modal_stack.empty()) {
-
- Control *top = gui.modal_stack.back()->get();
- Vector2 pos2 = top->get_global_transform_with_canvas().affine_inverse().xform(mpos);
- if (!top->has_point(pos2)) {
-
- 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)
- set_input_as_handled();
-
- return; // no one gets the event if exclusive NO ONE
- }
-
- if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN || mb->get_button_index() == BUTTON_WHEEL_LEFT || mb->get_button_index() == BUTTON_WHEEL_RIGHT) {
- //cancel scroll wheel events, only clicks should trigger focus changes.
- set_input_as_handled();
- return;
- }
-
- top->notification(Control::NOTIFICATION_MODAL_CLOSE);
- top->_modal_stack_remove();
- top->hide();
-
- if (!top->pass_on_modal_close_click()) {
- is_handled = true;
- }
- } else {
- break;
- }
- }
-
if (is_handled) {
set_input_as_handled();
return;
@@ -1992,11 +1951,8 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == BUTTON_LEFT) {
- if (gui.mouse_over) {
- Size2 pos = mpos;
- pos = gui.focus_inv_xform.xform(pos);
-
- _gui_drop(gui.mouse_over, pos, false);
+ if (gui.drag_mouse_over) {
+ _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, false);
}
if (gui.drag_preview && mb->get_button_index() == BUTTON_LEFT) {
@@ -2006,6 +1962,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_data = Variant();
gui.dragging = false;
+ gui.drag_mouse_over = nullptr;
_propagate_viewport_notification(this, NOTIFICATION_DRAG_END);
//change mouse accordingly
}
@@ -2029,6 +1986,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
//disable mouse focus if needed before calling input, this makes popups on mouse press event work better, as the release will never be received otherwise
if (gui.mouse_focus_mask == 0) {
gui.mouse_focus = NULL;
+ gui.forced_mouse_focus = false;
}
if (mouse_focus && mouse_focus->can_process()) {
@@ -2074,6 +2032,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (gui.drag_data.get_type() != Variant::NIL) {
gui.mouse_focus = NULL;
+ gui.forced_mouse_focus = false;
gui.mouse_focus_mask = 0;
break;
} else {
@@ -2113,45 +2072,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
over = _gui_find_control(mpos);
}
- if (gui.drag_data.get_type() == Variant::NIL && over && !gui.modal_stack.empty()) {
-
- Control *top = gui.modal_stack.back()->get();
-
- if (over != top && !top->is_a_parent_of(over)) {
-
- PopupMenu *popup_menu = Object::cast_to<PopupMenu>(top);
- MenuButton *popup_menu_parent = NULL;
- MenuButton *menu_button = Object::cast_to<MenuButton>(over);
-
- if (popup_menu) {
- popup_menu_parent = Object::cast_to<MenuButton>(popup_menu->get_parent());
- if (!popup_menu_parent) {
- // Go through the parents to see if there's a MenuButton at the end.
- while (Object::cast_to<PopupMenu>(popup_menu->get_parent())) {
- popup_menu = Object::cast_to<PopupMenu>(popup_menu->get_parent());
- }
- popup_menu_parent = Object::cast_to<MenuButton>(popup_menu->get_parent());
- }
- }
-
- // If the mouse is over a menu button, this menu will open automatically
- // if there is already a pop-up menu open at the same hierarchical level.
- if (popup_menu_parent && menu_button && popup_menu_parent->is_switch_on_hover() &&
- !menu_button->is_disabled() && menu_button->is_switch_on_hover() &&
- (popup_menu_parent->get_parent()->is_a_parent_of(menu_button) ||
- menu_button->get_parent()->is_a_parent_of(popup_menu))) {
-
- popup_menu->notification(Control::NOTIFICATION_MODAL_CLOSE);
- popup_menu->_modal_stack_remove();
- popup_menu->hide();
-
- menu_button->pressed();
- } else {
- over = NULL; //nothing can be found outside the modal stack
- }
- }
- }
-
if (over != gui.mouse_over) {
if (gui.mouse_over) {
@@ -2167,103 +2087,195 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.mouse_over = over;
- if (gui.drag_preview) {
- gui.drag_preview->set_position(mpos);
- }
+ DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)InputFilter::get_singleton()->get_default_cursor_shape();
- if (!over) {
- OS::get_singleton()->set_cursor_shape((OS::CursorShape)Input::get_singleton()->get_default_cursor_shape());
- return;
- }
+ if (over) {
- Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
- Size2 pos = localizer.xform(mpos);
- Vector2 speed = localizer.basis_xform(mm->get_speed());
- Vector2 rel = localizer.basis_xform(mm->get_relative());
+ Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
+ Size2 pos = localizer.xform(mpos);
+ Vector2 speed = localizer.basis_xform(mm->get_speed());
+ Vector2 rel = localizer.basis_xform(mm->get_relative());
- mm = mm->xformed_by(Transform2D()); //make a copy
+ mm = mm->xformed_by(Transform2D()); //make a copy
- mm->set_global_position(mpos);
- mm->set_speed(speed);
- mm->set_relative(rel);
+ mm->set_global_position(mpos);
+ mm->set_speed(speed);
+ mm->set_relative(rel);
- if (mm->get_button_mask() == 0) {
- //nothing pressed
+ if (mm->get_button_mask() == 0) {
+ //nothing pressed
- bool can_tooltip = true;
+ bool can_tooltip = true;
- if (!gui.modal_stack.empty()) {
- if (gui.modal_stack.back()->get() != over && !gui.modal_stack.back()->get()->is_a_parent_of(over))
- can_tooltip = false;
- }
+ bool is_tooltip_shown = false;
- bool is_tooltip_shown = false;
+ if (gui.tooltip_popup) {
+ if (can_tooltip && gui.tooltip) {
+ String tooltip = _gui_get_tooltip(over, gui.tooltip->get_global_transform().xform_inv(mpos));
- if (gui.tooltip_popup) {
- if (can_tooltip && gui.tooltip) {
- String tooltip = _gui_get_tooltip(over, gui.tooltip->get_global_transform().xform_inv(mpos));
+ if (tooltip.length() == 0)
+ _gui_cancel_tooltip();
+ else if (gui.tooltip_label) {
+ if (tooltip == gui.tooltip_label->get_text()) {
+ is_tooltip_shown = true;
+ }
+ } else {
- if (tooltip.length() == 0)
- _gui_cancel_tooltip();
- else if (gui.tooltip_label) {
- if (tooltip == gui.tooltip_label->get_text()) {
- is_tooltip_shown = true;
+ Variant t = gui.tooltip_popup->call("get_tooltip_text");
+
+ if (t.get_type() == Variant::STRING) {
+ if (tooltip == String(t)) {
+ is_tooltip_shown = true;
+ }
+ } else {
+ is_tooltip_shown = true; //well, nothing to compare against, likely using custom control, so if it changes there is nothing we can do
+ }
}
- } else if (tooltip == String(gui.tooltip_popup->call("get_tooltip_text"))) {
- is_tooltip_shown = true;
- }
- } else
- _gui_cancel_tooltip();
+ } else
+ _gui_cancel_tooltip();
+ }
+
+ if (can_tooltip && !is_tooltip_shown) {
+
+ gui.tooltip = over;
+ gui.tooltip_pos = over->get_screen_transform().xform(pos); //(parent_xform * get_transform()).affine_inverse().xform(pos);
+ gui.tooltip_timer = gui.tooltip_delay;
+ }
}
- if (can_tooltip && !is_tooltip_shown) {
+ //pos = gui.focus_inv_xform.xform(pos);
+
+ mm->set_position(pos);
- gui.tooltip = over;
- gui.tooltip_pos = mpos; //(parent_xform * get_transform()).affine_inverse().xform(pos);
- gui.tooltip_timer = gui.tooltip_delay;
+ Control::CursorShape cursor_shape = Control::CURSOR_ARROW;
+ {
+ Control *c = over;
+ Vector2 cpos = pos;
+ while (c) {
+ cursor_shape = c->get_cursor_shape(cpos);
+ cpos = c->get_transform().xform(cpos);
+ if (cursor_shape != Control::CURSOR_ARROW)
+ break;
+ if (c->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ break;
+ if (c->is_set_as_toplevel())
+ break;
+ c = c->get_parent_control();
+ }
}
+
+ ds_cursor_shape = (DisplayServer::CursorShape)cursor_shape;
+
+ if (over && over->can_process()) {
+ _gui_call_input(over, mm);
+ }
+
+ set_input_as_handled();
}
- //pos = gui.focus_inv_xform.xform(pos);
+ if (gui.drag_data.get_type() != Variant::NIL) {
+ //handle dragandrop
- mm->set_position(pos);
+ if (gui.drag_preview) {
+ gui.drag_preview->set_position(mpos);
+ }
- Control::CursorShape cursor_shape = Control::CURSOR_ARROW;
- {
- Control *c = over;
- Vector2 cpos = pos;
- while (c) {
- cursor_shape = c->get_cursor_shape(cpos);
- cpos = c->get_transform().xform(cpos);
- if (cursor_shape != Control::CURSOR_ARROW)
- break;
- if (c->data.mouse_filter == Control::MOUSE_FILTER_STOP)
- break;
- if (c->is_set_as_toplevel())
- break;
- c = c->get_parent_control();
+ gui.drag_mouse_over = over;
+ gui.drag_mouse_over_pos = Vector2();
+
+ //find the window this is above of
+
+ //see if there is an embedder
+ Viewport *embedder = nullptr;
+ Vector2 viewport_pos;
+
+ if (is_embedding_subwindows()) {
+ embedder = this;
+ viewport_pos = mpos;
+ } else {
+ //not an embeder, but may be a subwindow of an embedder
+ Window *w = Object::cast_to<Window>(this);
+ if (w) {
+ if (w->is_embedded()) {
+ embedder = w->_get_embedder();
+
+ Transform2D ai = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse();
+
+ viewport_pos = ai.xform(mpos) + w->get_position(); //to parent coords
+ }
+ }
}
- }
- OS::get_singleton()->set_cursor_shape((OS::CursorShape)cursor_shape);
+ Viewport *viewport_under = nullptr;
- if (over && over->can_process()) {
- _gui_call_input(over, mm);
- }
+ if (embedder) {
+ //use embedder logic
- set_input_as_handled();
+ for (int i = embedder->gui.sub_windows.size() - 1; i >= 0; i--) {
+ Window *sw = embedder->gui.sub_windows[i].window;
+ Rect2 swrect = Rect2i(sw->get_position(), sw->get_size());
+ if (!sw->get_flag(Window::FLAG_BORDERLESS)) {
+ int title_height = sw->get_theme_constant("title_height");
+ swrect.position.y -= title_height;
+ swrect.size.y += title_height;
+ }
+
+ if (swrect.has_point(viewport_pos)) {
+ viewport_under = sw;
+ viewport_pos -= sw->get_position();
+ }
+ }
+
+ if (!viewport_under) {
+ //not in a subwindow, likely in embedder
+ viewport_under = embedder;
+ }
+ } else {
+ //use displayserver logic
+ Vector2i screen_mouse_pos = DisplayServer::get_singleton()->mouse_get_position();
+
+ DisplayServer::WindowID window_id = DisplayServer::get_singleton()->get_window_at_screen_position(screen_mouse_pos);
+
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ ObjectID object_under = DisplayServer::get_singleton()->window_get_attached_instance_id(window_id);
+
+ if (object_under != ObjectID()) { //fetch window
+ Window *w = Object::cast_to<Window>(ObjectDB::get_instance(object_under));
+ if (w) {
+ viewport_under = w;
+ viewport_pos = screen_mouse_pos - w->get_position();
+ }
+ }
+ }
+ }
+
+ if (viewport_under) {
+ Transform2D ai = (viewport_under->get_final_transform().affine_inverse() * viewport_under->_get_input_pre_xform());
+ viewport_pos = ai.xform(viewport_pos);
+ //find control under at pos
+ gui.drag_mouse_over = viewport_under->_gui_find_control(viewport_pos);
+ if (gui.drag_mouse_over) {
+ Transform2D localizer = gui.drag_mouse_over->get_global_transform_with_canvas().affine_inverse();
+ gui.drag_mouse_over_pos = localizer.xform(viewport_pos);
- if (gui.drag_data.get_type() != Variant::NIL && mm->get_button_mask() & BUTTON_MASK_LEFT) {
+ if (mm->get_button_mask() & BUTTON_MASK_LEFT) {
- bool can_drop = _gui_drop(over, pos, true);
+ bool can_drop = _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, true);
+
+ if (!can_drop) {
+ ds_cursor_shape = DisplayServer::CURSOR_FORBIDDEN;
+ } else {
+ ds_cursor_shape = DisplayServer::CURSOR_CAN_DROP;
+ }
+ }
+ }
- if (!can_drop) {
- OS::get_singleton()->set_cursor_shape(OS::CURSOR_FORBIDDEN);
} else {
- OS::get_singleton()->set_cursor_shape(OS::CURSOR_CAN_DROP);
+ gui.drag_mouse_over = nullptr;
}
- //change mouse accordingly i guess
}
+
+ DisplayServer::get_singleton()->cursor_set_shape(ds_cursor_shape);
}
Ref<InputEventScreenTouch> touch_event = p_event;
@@ -2275,14 +2287,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Control *over = _gui_find_control(pos);
if (over) {
- if (!gui.modal_stack.empty()) {
-
- Control *top = gui.modal_stack.back()->get();
- if (over != top && !top->is_a_parent_of(over)) {
-
- return;
- }
- }
if (over->can_process()) {
touch_event = touch_event->xformed_by(Transform2D()); //make a copy
@@ -2348,14 +2352,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
if (over) {
- if (!gui.modal_stack.empty()) {
-
- Control *top = gui.modal_stack.back()->get();
- if (over != top && !top->is_a_parent_of(over)) {
-
- return;
- }
- }
if (over->can_process()) {
Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
@@ -2399,21 +2395,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
- if (p_event->is_pressed() && p_event->is_action("ui_cancel") && !gui.modal_stack.empty()) {
-
- _gui_sort_modal_stack();
- Control *top = gui.modal_stack.back()->get();
- if (!top->data.modal_exclusive) {
-
- top->notification(Control::NOTIFICATION_MODAL_CLOSE);
- top->_modal_stack_remove();
- top->hide();
- // Close modal, set input as handled
- set_input_as_handled();
- return;
- }
- }
-
Control *from = gui.key_focus ? gui.key_focus : NULL; //hmm
//keyboard focus
@@ -2426,7 +2407,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (from && p_event->is_pressed()) {
Control *next = NULL;
- Input *input = Input::get_singleton();
+ InputFilter *input = InputFilter::get_singleton();
if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) {
@@ -2472,61 +2453,10 @@ List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) {
return gui.roots.push_back(p_control);
}
-List<Control *>::Element *Viewport::_gui_add_subwindow_control(Control *p_control) {
-
- p_control->connect("visibility_changed", callable_mp(this, &Viewport::_subwindow_visibility_changed));
-
- if (p_control->is_visible_in_tree()) {
- gui.subwindow_order_dirty = true;
- gui.subwindows.push_back(p_control);
- }
-
- return gui.all_known_subwindows.push_back(p_control);
-}
-
-void Viewport::_gui_set_subwindow_order_dirty() {
- gui.subwindow_order_dirty = true;
-}
-
void Viewport::_gui_set_root_order_dirty() {
gui.roots_order_dirty = true;
}
-void Viewport::_gui_remove_modal_control(List<Control *>::Element *MI) {
-
- gui.modal_stack.erase(MI);
-}
-
-void Viewport::_gui_remove_from_modal_stack(List<Control *>::Element *MI, ObjectID p_prev_focus_owner) {
-
- //transfer the focus stack to the next
-
- List<Control *>::Element *next = MI->next();
-
- gui.modal_stack.erase(MI);
-
- if (p_prev_focus_owner.is_valid()) {
-
- // for previous window in stack, pass the focus so it feels more
- // natural
-
- if (!next) { //top of stack
-
- Object *pfo = ObjectDB::get_instance(p_prev_focus_owner);
- Control *pfoc = Object::cast_to<Control>(pfo);
- if (!pfoc)
- return;
-
- if (!pfoc->is_inside_tree() || !pfoc->is_visible_in_tree())
- return;
- pfoc->grab_focus();
- } else {
-
- next->get()->_modal_set_prev_focus_owner(p_prev_focus_owner);
- }
- }
-}
-
void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control) {
ERR_FAIL_COND_MSG(p_data.get_type() == Variant::NIL, "Drag data must be a value.");
@@ -2563,21 +2493,6 @@ void Viewport::_gui_remove_root_control(List<Control *>::Element *RI) {
gui.roots.erase(RI);
}
-void Viewport::_gui_remove_subwindow_control(List<Control *>::Element *SI) {
-
- ERR_FAIL_COND(!SI);
-
- Control *control = SI->get();
-
- control->disconnect("visibility_changed", callable_mp(this, &Viewport::_subwindow_visibility_changed));
-
- List<Control *>::Element *E = gui.subwindows.find(control);
- if (E)
- gui.subwindows.erase(E);
-
- gui.all_known_subwindows.erase(SI);
-}
-
void Viewport::_gui_unfocus_control(Control *p_control) {
if (gui.key_focus == p_control) {
@@ -2605,6 +2520,8 @@ void Viewport::_gui_hid_control(Control *p_control) {
_gui_remove_focus();
if (gui.mouse_over == p_control)
gui.mouse_over = NULL;
+ if (gui.drag_mouse_over == p_control)
+ gui.drag_mouse_over = NULL;
if (gui.tooltip == p_control)
_gui_cancel_tooltip();
}
@@ -2613,6 +2530,7 @@ void Viewport::_gui_remove_control(Control *p_control) {
if (gui.mouse_focus == p_control) {
gui.mouse_focus = NULL;
+ gui.forced_mouse_focus = false;
gui.mouse_focus_mask = 0;
}
if (gui.last_mouse_focus == p_control) {
@@ -2622,11 +2540,10 @@ void Viewport::_gui_remove_control(Control *p_control) {
gui.key_focus = NULL;
if (gui.mouse_over == p_control)
gui.mouse_over = NULL;
+ if (gui.drag_mouse_over == p_control)
+ gui.drag_mouse_over = NULL;
if (gui.tooltip == p_control)
gui.tooltip = NULL;
- if (gui.tooltip_popup == p_control) {
- _gui_cancel_tooltip();
- }
}
void Viewport::_gui_remove_focus() {
@@ -2638,11 +2555,6 @@ void Viewport::_gui_remove_focus() {
}
}
-bool Viewport::_gui_is_modal_on_top(const Control *p_control) {
-
- return (gui.modal_stack.size() && gui.modal_stack.back()->get() == p_control);
-}
-
bool Viewport::_gui_control_has_focus(const Control *p_control) {
return gui.key_focus == p_control;
@@ -2672,6 +2584,7 @@ void Viewport::_drop_mouse_focus() {
Control *c = gui.mouse_focus;
int mask = gui.mouse_focus_mask;
gui.mouse_focus = NULL;
+ gui.forced_mouse_focus = false;
gui.mouse_focus_mask = 0;
for (int i = 0; i < 3; i++) {
@@ -2703,7 +2616,7 @@ void Viewport::_drop_physics_mouseover() {
#ifndef _3D_DISABLED
if (physics_object_over.is_valid()) {
- CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_over));
+ CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over));
if (co) {
co->_mouse_exit();
}
@@ -2714,22 +2627,6 @@ void Viewport::_drop_physics_mouseover() {
#endif
}
-List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
-
- List<Control *>::Element *node = gui.modal_stack.push_back(p_control);
- if (gui.key_focus)
- p_control->_modal_set_prev_focus_owner(gui.key_focus->get_instance_id());
- else
- p_control->_modal_set_prev_focus_owner(ObjectID());
-
- if (gui.mouse_focus && !p_control->is_a_parent_of(gui.mouse_focus) && !gui.mouse_click_grabber) {
-
- _drop_mouse_focus();
- }
-
- return node;
-}
-
Control *Viewport::_gui_get_focus_owner() {
return gui.key_focus;
@@ -2798,44 +2695,390 @@ void Viewport::_post_gui_grab_click_focus() {
///////////////////////////////
-void Viewport::input(const Ref<InputEvent> &p_event) {
+void Viewport::input_text(const String &p_text) {
+
+ if (gui.subwindow_focused) {
+ gui.subwindow_focused->input_text(p_text);
+ return;
+ }
+
+ if (gui.key_focus) {
+ gui.key_focus->call("set_text", p_text);
+ }
+}
+Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point) {
+
+ if (p_subwindow->get_flag(Window::FLAG_BORDERLESS)) {
+ return SUB_WINDOW_RESIZE_DISABLED;
+ }
+
+ Rect2i r = Rect2i(p_subwindow->get_position(), p_subwindow->get_size());
+
+ int title_height = p_subwindow->get_theme_constant("title_height");
+
+ r.position.y -= title_height;
+ r.size.y += title_height;
+
+ if (r.has_point(p_point)) {
+ return SUB_WINDOW_RESIZE_DISABLED; //it's inside, so no resize
+ }
+
+ int dist_x = p_point.x < r.position.x ? (p_point.x - r.position.x) : (p_point.x > (r.position.x + r.size.x) ? (p_point.x - (r.position.x + r.size.x)) : 0);
+ int dist_y = p_point.y < r.position.y ? (p_point.y - r.position.y) : (p_point.y > (r.position.y + r.size.y) ? (p_point.y - (r.position.y + r.size.y)) : 0);
+
+ int limit = p_subwindow->get_theme_constant("resize_margin");
+
+ if (ABS(dist_x) > limit) {
+ return SUB_WINDOW_RESIZE_DISABLED;
+ }
+
+ if (ABS(dist_y) > limit) {
+ return SUB_WINDOW_RESIZE_DISABLED;
+ }
+
+ if (dist_x < 0 && dist_y < 0) {
+ return SUB_WINDOW_RESIZE_TOP_LEFT;
+ }
+
+ if (dist_x == 0 && dist_y < 0) {
+ return SUB_WINDOW_RESIZE_TOP;
+ }
+
+ if (dist_x > 0 && dist_y < 0) {
+ return SUB_WINDOW_RESIZE_TOP_RIGHT;
+ }
+
+ if (dist_x < 0 && dist_y == 0) {
+ return SUB_WINDOW_RESIZE_LEFT;
+ }
+
+ if (dist_x > 0 && dist_y == 0) {
+ return SUB_WINDOW_RESIZE_RIGHT;
+ }
+
+ if (dist_x < 0 && dist_y > 0) {
+ return SUB_WINDOW_RESIZE_BOTTOM_LEFT;
+ }
+
+ if (dist_x == 0 && dist_y > 0) {
+ return SUB_WINDOW_RESIZE_BOTTOM;
+ }
+
+ if (dist_x > 0 && dist_y > 0) {
+ return SUB_WINDOW_RESIZE_BOTTOM_RIGHT;
+ }
+
+ return SUB_WINDOW_RESIZE_DISABLED;
+}
+bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
+
+ if (gui.subwindow_drag != SUB_WINDOW_DRAG_DISABLED) {
+
+ ERR_FAIL_COND_V(gui.subwindow_focused == nullptr, false);
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+
+ if (gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE) {
+ if (gui.subwindow_drag_close_rect.has_point(mb->get_position())) {
+ //close window
+ gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_CLOSE_REQUEST);
+ }
+ }
+ gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
+ if (gui.subwindow_focused != nullptr) { //may have been erased
+ _sub_window_update(gui.subwindow_focused);
+ }
+ }
+
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+
+ if (gui.subwindow_drag == SUB_WINDOW_DRAG_MOVE) {
+ Vector2 diff = mm->get_position() - gui.subwindow_drag_from;
+ Rect2i new_rect(gui.subwindow_drag_pos + diff, gui.subwindow_focused->get_size());
+ gui.subwindow_focused->_rect_changed_callback(new_rect);
+ }
+ if (gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE) {
+ gui.subwindow_drag_close_inside = gui.subwindow_drag_close_rect.has_point(mm->get_position());
+ }
+ if (gui.subwindow_drag == SUB_WINDOW_DRAG_RESIZE) {
+ Vector2i diff = mm->get_position() - gui.subwindow_drag_from;
+ Size2i min_size = gui.subwindow_focused->get_min_size();
+ if (gui.subwindow_focused->is_wrapping_controls()) {
+ Size2i cms = gui.subwindow_focused->get_contents_minimum_size();
+ min_size.x = MAX(cms.x, min_size.x);
+ min_size.y = MAX(cms.y, min_size.y);
+ }
+ min_size.x = MAX(min_size.x, 1);
+ min_size.y = MAX(min_size.y, 1);
+
+ Rect2i r = gui.subwindow_resize_from_rect;
+
+ Size2i limit = r.size - min_size;
+
+ switch (gui.subwindow_resize_mode) {
+ case SUB_WINDOW_RESIZE_TOP_LEFT: {
+
+ diff.x = MIN(diff.x, limit.x);
+ diff.y = MIN(diff.y, limit.y);
+ r.position += diff;
+ r.size -= diff;
+ } break;
+ case SUB_WINDOW_RESIZE_TOP: {
+ diff.x = 0;
+ diff.y = MIN(diff.y, limit.y);
+ r.position += diff;
+ r.size -= diff;
+ } break;
+ case SUB_WINDOW_RESIZE_TOP_RIGHT: {
+ diff.x = MAX(diff.x, -limit.x);
+ diff.y = MIN(diff.y, limit.y);
+ r.position.y += diff.y;
+ r.size.y -= diff.y;
+ r.size.x += diff.x;
+ } break;
+ case SUB_WINDOW_RESIZE_LEFT: {
+ diff.x = MIN(diff.x, limit.x);
+ diff.y = 0;
+ r.position += diff;
+ r.size -= diff;
+
+ } break;
+ case SUB_WINDOW_RESIZE_RIGHT: {
+ diff.x = MAX(diff.x, -limit.x);
+ r.size.x += diff.x;
+ } break;
+ case SUB_WINDOW_RESIZE_BOTTOM_LEFT: {
+ diff.x = MIN(diff.x, limit.x);
+ diff.y = MAX(diff.y, -limit.y);
+ r.position.x += diff.x;
+ r.size.x -= diff.x;
+ r.size.y += diff.y;
+
+ } break;
+ case SUB_WINDOW_RESIZE_BOTTOM: {
+ diff.y = MAX(diff.y, -limit.y);
+ r.size.y += diff.y;
+ } break;
+ case SUB_WINDOW_RESIZE_BOTTOM_RIGHT: {
+ diff.x = MAX(diff.x, -limit.x);
+ diff.y = MAX(diff.y, -limit.y);
+ r.size += diff;
+
+ } break;
+ default: {
+ }
+ }
+
+ gui.subwindow_focused->_rect_changed_callback(r);
+ }
+
+ if (gui.subwindow_focused) { //may have been erased
+ _sub_window_update(gui.subwindow_focused);
+ }
+ }
+
+ return true; //handled
+ }
+ Ref<InputEventMouseButton> mb = p_event;
+ //if the event is a mouse button, we need to check whether another window was clicked
+
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+
+ bool click_on_window = false;
+ for (int i = gui.sub_windows.size() - 1; i >= 0; i--) {
+ SubWindow &sw = gui.sub_windows.write[i];
+
+ //clicked inside window?
+
+ Rect2i r = Rect2i(sw.window->get_position(), sw.window->get_size());
+
+ if (!sw.window->get_flag(Window::FLAG_BORDERLESS)) {
+ //check top bar
+ int title_height = sw.window->get_theme_constant("title_height");
+ Rect2i title_bar = r;
+ title_bar.position.y -= title_height;
+ title_bar.size.y = title_height;
+
+ if (title_bar.has_point(mb->get_position())) {
+
+ click_on_window = true;
+
+ int close_h_ofs = sw.window->get_theme_constant("close_h_ofs");
+ int close_v_ofs = sw.window->get_theme_constant("close_v_ofs");
+ Ref<Texture2D> close_icon = sw.window->get_theme_icon("close");
+
+ Rect2 close_rect;
+ close_rect.position = Vector2(r.position.x + r.size.x - close_v_ofs, r.position.y - close_h_ofs);
+ close_rect.size = close_icon->get_size();
+
+ if (gui.subwindow_focused != sw.window) {
+ //refocus
+ _sub_window_grab_focus(sw.window);
+ }
+
+ if (close_rect.has_point(mb->get_position())) {
+
+ gui.subwindow_drag = SUB_WINDOW_DRAG_CLOSE;
+ gui.subwindow_drag_close_inside = true; //starts inside
+ gui.subwindow_drag_close_rect = close_rect;
+ } else {
+
+ gui.subwindow_drag = SUB_WINDOW_DRAG_MOVE;
+ }
+
+ gui.subwindow_drag_from = mb->get_position();
+ gui.subwindow_drag_pos = sw.window->get_position();
+
+ _sub_window_update(sw.window);
+ } else {
+ gui.subwindow_resize_mode = _sub_window_get_resize_margin(sw.window, mb->get_position());
+ if (gui.subwindow_resize_mode != SUB_WINDOW_RESIZE_DISABLED) {
+ gui.subwindow_resize_from_rect = r;
+ gui.subwindow_drag_from = mb->get_position();
+ gui.subwindow_drag = SUB_WINDOW_DRAG_RESIZE;
+ click_on_window = true;
+ }
+ }
+ }
+ if (!click_on_window && r.has_point(mb->get_position())) {
+ //clicked, see if it needs to fetch focus
+ if (gui.subwindow_focused != sw.window) {
+ //refocus
+ _sub_window_grab_focus(sw.window);
+ }
+
+ click_on_window = true;
+ }
+
+ if (click_on_window) {
+ break;
+ }
+ }
+
+ if (!click_on_window && gui.subwindow_focused) {
+ //no window found and clicked, remove focus
+ _sub_window_grab_focus(nullptr);
+ }
+ }
+
+ if (gui.subwindow_focused) {
+
+ Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+
+ SubWindowResize resize = _sub_window_get_resize_margin(gui.subwindow_focused, mm->get_position());
+ if (resize != SUB_WINDOW_RESIZE_DISABLED) {
+
+ DisplayServer::CursorShape shapes[SUB_WINDOW_RESIZE_MAX] = {
+ DisplayServer::CURSOR_ARROW,
+ DisplayServer::CURSOR_FDIAGSIZE,
+ DisplayServer::CURSOR_VSIZE,
+ DisplayServer::CURSOR_BDIAGSIZE,
+ DisplayServer::CURSOR_HSIZE,
+ DisplayServer::CURSOR_HSIZE,
+ DisplayServer::CURSOR_BDIAGSIZE,
+ DisplayServer::CURSOR_VSIZE,
+ DisplayServer::CURSOR_FDIAGSIZE
+ };
+
+ DisplayServer::get_singleton()->cursor_set_shape(shapes[resize]);
+
+ return true; //reserved for showing the resize cursor
+ }
+ }
+ }
+
+ if (gui.subwindow_drag != SUB_WINDOW_DRAG_DISABLED) {
+ return true; // dragging, don't pass the event
+ }
+
+ if (!gui.subwindow_focused) {
+ return false;
+ }
+
+ Transform2D window_ofs;
+ window_ofs.set_origin(-gui.subwindow_focused->get_position());
+
+ Ref<InputEvent> ev = p_event->xformed_by(window_ofs);
+
+ gui.subwindow_focused->_window_input(ev);
+
+ return true;
+}
+
+void Viewport::input(const Ref<InputEvent> &p_event, bool p_local_coords) {
ERR_FAIL_COND(!is_inside_tree());
+ if (disable_input)
+ return;
+
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
+ return;
+ }
+
local_input_handled = false;
+ Ref<InputEvent> ev;
+ if (!p_local_coords) {
+ ev = _make_input_local(p_event);
+ } else {
+ ev = p_event;
+ }
+
+ if (is_embedding_subwindows() && _sub_windows_forward_input(p_event)) {
+ set_input_as_handled();
+ return;
+ }
+
if (!is_input_handled()) {
- get_tree()->_call_input_pause(input_group, "_input", p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
+ get_tree()->_call_input_pause(input_group, "_input", ev, this); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
}
if (!is_input_handled()) {
- _gui_input_event(p_event);
+ _gui_input_event(ev);
}
- //get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check
+ //get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",ev); //special one for GUI, as controls use their own process check
}
-void Viewport::unhandled_input(const Ref<InputEvent> &p_event) {
+void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
ERR_FAIL_COND(!is_inside_tree());
- get_tree()->_call_input_pause(unhandled_input_group, "_unhandled_input", p_event);
+ if (disable_input)
+ return;
+
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
+ return;
+ }
+
+ Ref<InputEvent> ev;
+ if (!p_local_coords) {
+ ev = _make_input_local(p_event);
+ } else {
+ ev = p_event;
+ }
+
+ get_tree()->_call_input_pause(unhandled_input_group, "_unhandled_input", ev, this);
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev);
- if (!get_tree()->input_handled && Object::cast_to<InputEventKey>(*p_event) != NULL) {
- get_tree()->_call_input_pause(unhandled_key_input_group, "_unhandled_key_input", p_event);
+ if (!is_input_handled() && Object::cast_to<InputEventKey>(*ev) != NULL) {
+ get_tree()->_call_input_pause(unhandled_key_input_group, "_unhandled_key_input", ev, this);
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev);
}
- if (physics_object_picking && !get_tree()->input_handled) {
+ if (physics_object_picking && !is_input_handled()) {
- if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED &&
- (Object::cast_to<InputEventMouseButton>(*p_event) ||
- Object::cast_to<InputEventMouseMotion>(*p_event) ||
- Object::cast_to<InputEventScreenDrag>(*p_event) ||
- Object::cast_to<InputEventScreenTouch>(*p_event) ||
- Object::cast_to<InputEventKey>(*p_event) //to remember state
+ if (InputFilter::get_singleton()->get_mouse_mode() != InputFilter::MOUSE_MODE_CAPTURED &&
+ (Object::cast_to<InputEventMouseButton>(*ev) ||
+ Object::cast_to<InputEventMouseMotion>(*ev) ||
+ Object::cast_to<InputEventScreenDrag>(*ev) ||
+ Object::cast_to<InputEventScreenTouch>(*ev) ||
+ Object::cast_to<InputEventKey>(*ev) //to remember state
)) {
- physics_picking_events.push_back(p_event);
+ physics_picking_events.push_back(ev);
}
}
}
@@ -2849,7 +3092,7 @@ void Viewport::set_use_own_world(bool p_world) {
_propagate_exit_world(this);
if (!p_world) {
- own_world = Ref<World>();
+ own_world = Ref<World3D>();
if (world.is_valid()) {
world->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
}
@@ -2858,7 +3101,7 @@ void Viewport::set_use_own_world(bool p_world) {
own_world = world->duplicate();
world->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
} else {
- own_world = Ref<World>(memnew(World));
+ own_world = Ref<World3D>(memnew(World3D));
}
}
@@ -2866,7 +3109,7 @@ void Viewport::set_use_own_world(bool p_world) {
_propagate_enter_world(this);
if (is_inside_tree()) {
- VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
+ RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
}
_update_listener();
@@ -2877,30 +3120,6 @@ bool Viewport::is_using_own_world() const {
return own_world.is_valid();
}
-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;
-}
-
-Rect2 Viewport::get_attach_to_screen_rect() const {
-
- return to_screen_rect;
-}
-
-void Viewport::set_use_render_direct_to_screen(bool p_render_direct_to_screen) {
-
- if (p_render_direct_to_screen == render_direct_to_screen)
- return;
-
- render_direct_to_screen = p_render_direct_to_screen;
- VS::get_singleton()->viewport_set_render_direct_to_screen(viewport, p_render_direct_to_screen);
-}
-
-bool Viewport::is_using_render_direct_to_screen() const {
- return render_direct_to_screen;
-}
-
void Viewport::set_physics_object_picking(bool p_enable) {
physics_object_picking = p_enable;
@@ -2925,11 +3144,6 @@ Vector2 Viewport::get_camera_rect_size() const {
return size;
}
-bool Viewport::gui_has_modal_stack() const {
-
- return gui.modal_stack.size();
-}
-
void Viewport::set_disable_input(bool p_disable) {
disable_input = p_disable;
}
@@ -2943,10 +3157,6 @@ Variant Viewport::gui_get_drag_data() const {
return gui.drag_data;
}
-Control *Viewport::get_modal_stack_top() const {
- return gui.modal_stack.size() ? gui.modal_stack.back()->get() : NULL;
-}
-
String Viewport::get_configuration_warning() const {
/*if (get_parent() && !Object::cast_to<Control>(get_parent()) && !render_target) {
@@ -2973,7 +3183,7 @@ void Viewport::set_msaa(MSAA p_msaa) {
if (msaa == p_msaa)
return;
msaa = p_msaa;
- VS::get_singleton()->viewport_set_msaa(viewport, VS::ViewportMSAA(p_msaa));
+ RS::get_singleton()->viewport_set_msaa(viewport, RS::ViewportMSAA(p_msaa));
}
Viewport::MSAA Viewport::get_msaa() const {
@@ -2984,7 +3194,7 @@ Viewport::MSAA Viewport::get_msaa() const {
void Viewport::set_debug_draw(DebugDraw p_debug_draw) {
debug_draw = p_debug_draw;
- VS::get_singleton()->viewport_set_debug_draw(viewport, VS::ViewportDebugDraw(p_debug_draw));
+ RS::get_singleton()->viewport_set_debug_draw(viewport, RS::ViewportDebugDraw(p_debug_draw));
}
Viewport::DebugDraw Viewport::get_debug_draw() const {
@@ -2994,7 +3204,7 @@ Viewport::DebugDraw Viewport::get_debug_draw() const {
int Viewport::get_render_info(RenderInfo p_info) {
- return VS::get_singleton()->viewport_get_render_info(viewport, VS::ViewportRenderInfo(p_info));
+ return RS::get_singleton()->viewport_get_render_info(viewport, RS::ViewportRenderInfo(p_info));
}
void Viewport::set_snap_controls_to_pixels(bool p_enable) {
@@ -3017,7 +3227,17 @@ void Viewport::set_input_as_handled() {
local_input_handled = true;
} else {
ERR_FAIL_COND(!is_inside_tree());
- get_tree()->set_input_as_handled();
+ Viewport *vp = this;
+ while (true) {
+ if (Object::cast_to<Window>(vp)) {
+ break;
+ }
+ if (!vp->get_parent()) {
+ break;
+ }
+ vp = vp->get_parent()->get_viewport();
+ }
+ vp->set_input_as_handled();
}
}
@@ -3025,8 +3245,17 @@ bool Viewport::is_input_handled() const {
if (handle_input_locally) {
return local_input_handled;
} else {
- ERR_FAIL_COND_V(!is_inside_tree(), false);
- return get_tree()->is_input_handled();
+ const Viewport *vp = this;
+ while (true) {
+ if (Object::cast_to<Window>(vp)) {
+ break;
+ }
+ if (!vp->get_parent()) {
+ break;
+ }
+ vp = vp->get_parent()->get_viewport();
+ }
+ return vp->is_input_handled();
}
}
@@ -3086,13 +3315,47 @@ void Viewport::_propagate_update_default_repeat(Node *p_node) {
}
}
-void Viewport::_bind_methods() {
+DisplayServer::WindowID Viewport::get_window_id() const {
+ return DisplayServer::MAIN_WINDOW_ID;
+}
- ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &Viewport::set_use_arvr);
- ClassDB::bind_method(D_METHOD("use_arvr"), &Viewport::use_arvr);
+Viewport *Viewport::get_parent_viewport() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
+ if (!get_parent()) {
+ return nullptr; //root viewport
+ }
+
+ return get_parent()->get_viewport();
+}
+
+void Viewport::set_embed_subwindows_hint(bool p_embed) {
+ gui.embed_subwindows_hint = p_embed;
+}
+bool Viewport::get_embed_subwindows_hint() const {
+ return gui.embed_subwindows_hint;
+}
+bool Viewport::is_embedding_subwindows() const {
+ return gui.embed_subwindows_hint;
+}
+
+void Viewport::pass_mouse_focus_to(Viewport *p_viewport, Control *p_control) {
+ ERR_FAIL_NULL(p_viewport);
+ ERR_FAIL_NULL(p_control);
+
+ if (gui.mouse_focus) {
+ p_viewport->gui.mouse_focus = p_control;
+ p_viewport->gui.mouse_focus_mask = gui.mouse_focus_mask;
+ p_viewport->gui.key_focus = p_control;
+ p_viewport->gui.forced_mouse_focus = true;
+
+ gui.mouse_focus = nullptr;
+ gui.forced_mouse_focus = false;
+ gui.mouse_focus_mask = 0;
+ }
+}
+
+void Viewport::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_size", "size"), &Viewport::set_size);
- ClassDB::bind_method(D_METHOD("get_size"), &Viewport::get_size);
ClassDB::bind_method(D_METHOD("set_world_2d", "world_2d"), &Viewport::set_world_2d);
ClassDB::bind_method(D_METHOD("get_world_2d"), &Viewport::get_world_2d);
ClassDB::bind_method(D_METHOD("find_world_2d"), &Viewport::find_world_2d);
@@ -3111,22 +3374,6 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_transparent_background", "enable"), &Viewport::set_transparent_background);
ClassDB::bind_method(D_METHOD("has_transparent_background"), &Viewport::has_transparent_background);
- ClassDB::bind_method(D_METHOD("_vp_input"), &Viewport::_vp_input);
- ClassDB::bind_method(D_METHOD("_vp_input_text", "text"), &Viewport::_vp_input_text);
- ClassDB::bind_method(D_METHOD("_vp_unhandled_input"), &Viewport::_vp_unhandled_input);
-
- ClassDB::bind_method(D_METHOD("set_size_override", "enable", "size", "margin"), &Viewport::set_size_override, DEFVAL(Size2(-1, -1)), DEFVAL(Size2(0, 0)));
- ClassDB::bind_method(D_METHOD("get_size_override"), &Viewport::get_size_override);
- ClassDB::bind_method(D_METHOD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
- ClassDB::bind_method(D_METHOD("set_size_override_stretch", "enabled"), &Viewport::set_size_override_stretch);
- ClassDB::bind_method(D_METHOD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
-
- ClassDB::bind_method(D_METHOD("set_clear_mode", "mode"), &Viewport::set_clear_mode);
- ClassDB::bind_method(D_METHOD("get_clear_mode"), &Viewport::get_clear_mode);
-
- ClassDB::bind_method(D_METHOD("set_update_mode", "mode"), &Viewport::set_update_mode);
- ClassDB::bind_method(D_METHOD("get_update_mode"), &Viewport::get_update_mode);
-
ClassDB::bind_method(D_METHOD("set_msaa", "msaa"), &Viewport::set_msaa);
ClassDB::bind_method(D_METHOD("get_msaa"), &Viewport::get_msaa);
@@ -3141,8 +3388,9 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
ClassDB::bind_method(D_METHOD("get_viewport_rid"), &Viewport::get_viewport_rid);
- ClassDB::bind_method(D_METHOD("input", "local_event"), &Viewport::input);
- ClassDB::bind_method(D_METHOD("unhandled_input", "local_event"), &Viewport::unhandled_input);
+ ClassDB::bind_method(D_METHOD("input_text", "text"), &Viewport::input_text);
+ ClassDB::bind_method(D_METHOD("input", "event", "in_local_coords"), &Viewport::input, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("unhandled_input", "event", "in_local_coords"), &Viewport::unhandled_input, DEFVAL(false));
ClassDB::bind_method(D_METHOD("update_worlds"), &Viewport::update_worlds);
@@ -3156,19 +3404,13 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_as_audio_listener_2d", "enable"), &Viewport::set_as_audio_listener_2d);
ClassDB::bind_method(D_METHOD("is_audio_listener_2d"), &Viewport::is_audio_listener_2d);
- ClassDB::bind_method(D_METHOD("set_attach_to_screen_rect", "rect"), &Viewport::set_attach_to_screen_rect);
- ClassDB::bind_method(D_METHOD("set_use_render_direct_to_screen", "enable"), &Viewport::set_use_render_direct_to_screen);
- ClassDB::bind_method(D_METHOD("is_using_render_direct_to_screen"), &Viewport::is_using_render_direct_to_screen);
ClassDB::bind_method(D_METHOD("get_mouse_position"), &Viewport::get_mouse_position);
ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Viewport::warp_mouse);
- ClassDB::bind_method(D_METHOD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
ClassDB::bind_method(D_METHOD("gui_get_drag_data"), &Viewport::gui_get_drag_data);
ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging);
- ClassDB::bind_method(D_METHOD("get_modal_stack_top"), &Viewport::get_modal_stack_top);
-
ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input);
ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
@@ -3194,13 +3436,13 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_default_canvas_item_texture_filter", "mode"), &Viewport::set_default_canvas_item_texture_filter);
ClassDB::bind_method(D_METHOD("get_default_canvas_item_texture_filter"), &Viewport::get_default_canvas_item_texture_filter);
+ ClassDB::bind_method(D_METHOD("set_embed_subwindows_hint", "enable"), &Viewport::set_embed_subwindows_hint);
+ ClassDB::bind_method(D_METHOD("get_embed_subwindows_hint"), &Viewport::get_embed_subwindows_hint);
+ ClassDB::bind_method(D_METHOD("is_embedding_subwindows"), &Viewport::is_embedding_subwindows);
+
ClassDB::bind_method(D_METHOD("set_default_canvas_item_texture_repeat", "mode"), &Viewport::set_default_canvas_item_texture_repeat);
ClassDB::bind_method(D_METHOD("get_default_canvas_item_texture_repeat"), &Viewport::get_default_canvas_item_texture_repeat);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "use_arvr");
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_override_stretch"), "set_size_override_stretch", "is_size_override_stretch_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world"), "set_use_own_world", "is_using_own_world");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world", PROPERTY_HINT_RESOURCE_TYPE, "World"), "set_world", "get_world");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d");
@@ -3208,11 +3450,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally");
ADD_GROUP("Rendering", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x"), "set_msaa", "get_msaa");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_direct_to_screen"), "set_use_render_direct_to_screen", "is_using_render_direct_to_screen");
ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw");
- ADD_GROUP("Render Target", "render_target_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode");
ADD_GROUP("Canvas Items", "canvas_item_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,MipmapLinear,MipmapNearest"), "set_default_canvas_item_texture_filter", "get_default_canvas_item_texture_filter");
ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirror"), "set_default_canvas_item_texture_repeat", "get_default_canvas_item_texture_repeat");
@@ -3224,6 +3462,7 @@ void Viewport::_bind_methods() {
ADD_GROUP("GUI", "gui_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_embed_subwindows"), "set_embed_subwindows_hint", "get_embed_subwindows_hint");
ADD_GROUP("Shadow Atlas", "shadow_atlas_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size");
ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_0", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 0);
@@ -3236,11 +3475,6 @@ void Viewport::_bind_methods() {
ADD_SIGNAL(MethodInfo("size_changed"));
ADD_SIGNAL(MethodInfo("gui_focus_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
- BIND_ENUM_CONSTANT(UPDATE_DISABLED);
- BIND_ENUM_CONSTANT(UPDATE_ONCE);
- BIND_ENUM_CONSTANT(UPDATE_WHEN_VISIBLE);
- BIND_ENUM_CONSTANT(UPDATE_ALWAYS);
-
BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED);
BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1);
BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_4);
@@ -3277,10 +3511,6 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(MSAA_8X);
BIND_ENUM_CONSTANT(MSAA_16X);
- BIND_ENUM_CONSTANT(CLEAR_MODE_ALWAYS);
- BIND_ENUM_CONSTANT(CLEAR_MODE_NEVER);
- BIND_ENUM_CONSTANT(CLEAR_MODE_ONLY_NEXT_FRAME);
-
BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR);
BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS);
@@ -3293,28 +3523,18 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX);
}
-void Viewport::_subwindow_visibility_changed() {
-
- // unfortunately, we don't know the sender, i.e. which subwindow changed;
- // so we have to check them all.
- gui.subwindow_visibility_dirty = true;
-}
-
Viewport::Viewport() {
world_2d = Ref<World2D>(memnew(World2D));
- viewport = VisualServer::get_singleton()->viewport_create();
- texture_rid = VisualServer::get_singleton()->viewport_get_texture(viewport);
-
- render_direct_to_screen = false;
+ viewport = RenderingServer::get_singleton()->viewport_create();
+ texture_rid = RenderingServer::get_singleton()->viewport_get_texture(viewport);
default_texture.instance();
default_texture->vp = const_cast<Viewport *>(this);
viewport_textures.insert(default_texture.ptr());
- default_texture->proxy = VS::get_singleton()->texture_proxy_create(texture_rid);
+ default_texture->proxy = RS::get_singleton()->texture_proxy_create(texture_rid);
- //internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener = false;
//internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create();
audio_listener_2d = false;
@@ -3324,14 +3544,10 @@ Viewport::Viewport() {
camera = NULL;
override_canvas_transform = false;
canvas_layers.insert(NULL); // This eases picking code (interpreted as the canvas of the Viewport)
- arvr = false;
- size_override = false;
- size_override_stretch = false;
- size_override_size = Size2(1, 1);
+
gen_mipmaps = false;
//clear=true;
- update_mode = UPDATE_WHEN_VISIBLE;
physics_object_picking = false;
physics_has_last_mousepos = false;
@@ -3368,12 +3584,14 @@ Viewport::Viewport() {
gui.canvas_sort_index = 0;
gui.roots_order_dirty = false;
gui.mouse_focus = NULL;
+ gui.forced_mouse_focus = false;
gui.last_mouse_focus = NULL;
+ gui.subwindow_focused = nullptr;
+ gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
msaa = MSAA_DISABLED;
debug_draw = DEBUG_DRAW_DISABLED;
- clear_mode = CLEAR_MODE_ALWAYS;
snap_controls_to_pixels = true;
physics_last_mouse_state.alt = false;
@@ -3384,6 +3602,8 @@ Viewport::Viewport() {
local_input_handled = false;
handle_input_locally = true;
+ size_allocated = false;
+
default_canvas_item_texture_filter = DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
default_canvas_item_texture_repeat = DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
}
@@ -3394,7 +3614,97 @@ Viewport::~Viewport() {
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);
+ RenderingServer::get_singleton()->free(viewport);
+}
+
+/////////////////////////////////
+
+void SubViewport::set_use_arvr(bool p_use_arvr) {
+ arvr = p_use_arvr;
+
+ RS::get_singleton()->viewport_set_use_arvr(get_viewport_rid(), arvr);
+}
+
+bool SubViewport::is_using_arvr() {
+ return arvr;
+}
+
+void SubViewport::set_size(const Size2i &p_size) {
+ _set_size(p_size, Size2i(), Rect2i(), Transform2D(), true);
+}
+Size2i SubViewport::get_size() const {
+ return _get_size();
+}
+
+void SubViewport::set_update_mode(UpdateMode p_mode) {
+
+ update_mode = p_mode;
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::ViewportUpdateMode(p_mode));
+}
+SubViewport::UpdateMode SubViewport::get_update_mode() const {
+
+ return update_mode;
+}
+
+void SubViewport::set_clear_mode(ClearMode p_mode) {
+
+ clear_mode = p_mode;
+ RS::get_singleton()->viewport_set_clear_mode(get_viewport_rid(), RS::ViewportClearMode(p_mode));
+}
+
+SubViewport::ClearMode SubViewport::get_clear_mode() const {
+
+ return clear_mode;
+}
+
+DisplayServer::WindowID SubViewport::get_window_id() const {
+ return DisplayServer::INVALID_WINDOW_ID;
+}
+
+void SubViewport::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
+ }
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), false);
+ }
+}
+
+void SubViewport::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &SubViewport::set_use_arvr);
+ ClassDB::bind_method(D_METHOD("is_using_arvr"), &SubViewport::is_using_arvr);
+
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &SubViewport::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &SubViewport::get_size);
+
+ ClassDB::bind_method(D_METHOD("set_update_mode", "mode"), &SubViewport::set_update_mode);
+ ClassDB::bind_method(D_METHOD("get_update_mode"), &SubViewport::get_update_mode);
+
+ ClassDB::bind_method(D_METHOD("set_clear_mode", "mode"), &SubViewport::set_clear_mode);
+ ClassDB::bind_method(D_METHOD("get_clear_mode"), &SubViewport::get_clear_mode);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "is_using_arvr");
+ ADD_GROUP("Render Target", "render_target_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode");
+
+ BIND_ENUM_CONSTANT(UPDATE_DISABLED);
+ BIND_ENUM_CONSTANT(UPDATE_ONCE);
+ BIND_ENUM_CONSTANT(UPDATE_WHEN_VISIBLE);
+ BIND_ENUM_CONSTANT(UPDATE_WHEN_PARENT_VISIBLE);
+ BIND_ENUM_CONSTANT(UPDATE_ALWAYS);
+
+ BIND_ENUM_CONSTANT(CLEAR_MODE_ALWAYS);
+ BIND_ENUM_CONSTANT(CLEAR_MODE_NEVER);
+ BIND_ENUM_CONSTANT(CLEAR_MODE_ONLY_NEXT_FRAME);
+}
+
+SubViewport::SubViewport() {
+ arvr = false;
+ update_mode = UPDATE_WHEN_VISIBLE;
+ clear_mode = CLEAR_MODE_ALWAYS;
+}
+
+SubViewport::~SubViewport() {
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index e511ce1b17..d0b22b5553 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -35,11 +35,12 @@
#include "scene/main/node.h"
#include "scene/resources/texture.h"
#include "scene/resources/world_2d.h"
-#include "servers/visual_server.h"
+#include "servers/display_server.h"
+#include "servers/rendering_server.h"
-class Camera;
+class Camera3D;
class Camera2D;
-class Listener;
+class Listener3D;
class Control;
class CanvasItem;
class CanvasLayer;
@@ -47,7 +48,7 @@ class Panel;
class Label;
class Timer;
class Viewport;
-class CollisionObject;
+class CollisionObject3D;
class ViewportTexture : public Texture2D {
@@ -88,13 +89,6 @@ class Viewport : public Node {
GDCLASS(Viewport, Node);
public:
- 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,
@@ -142,13 +136,6 @@ public:
DEBUG_DRAW_ROUGHNESS_LIMITER
};
- enum ClearMode {
-
- CLEAR_MODE_ALWAYS,
- CLEAR_MODE_NEVER,
- CLEAR_MODE_ONLY_NEXT_FRAME
- };
-
enum DefaultCanvasItemTextureFilter {
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST,
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR,
@@ -164,15 +151,17 @@ public:
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX,
};
+ enum {
+ SUBWINDOW_CANVAS_LAYER = 1024
+ };
+
private:
friend class ViewportTexture;
Viewport *parent;
- Listener *listener;
- Set<Listener *> listeners;
-
- bool arvr;
+ Listener3D *listener;
+ Set<Listener3D *> listeners;
struct CameraOverrideData {
Transform transform;
@@ -192,12 +181,13 @@ private:
}
} camera_override;
- Camera *camera;
- Set<Camera *> cameras;
+ Camera3D *camera;
+ Set<Camera3D *> cameras;
Set<CanvasLayer *> canvas_layers;
RID viewport;
RID current_canvas;
+ RID subwindow_canvas;
bool audio_listener;
RID internal_listener;
@@ -212,23 +202,17 @@ private:
Transform2D global_canvas_transform;
Transform2D stretch_transform;
- Size2 size;
- Rect2 to_screen_rect;
- bool render_direct_to_screen;
+ Size2i size;
+ Size2i size_override;
+ bool size_allocated;
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;
- Size2 size_override_margin;
-
Rect2 last_vp_rect;
bool transparent_bg;
- ClearMode clear_mode;
bool filter;
bool gen_mipmaps;
@@ -253,7 +237,7 @@ private:
} physics_last_mouse_state;
- void _collision_object_input_event(CollisionObject *p_object, Camera *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);
+ void _collision_object_input_event(CollisionObject3D *p_object, Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);
bool handle_input_locally;
bool local_input_handled;
@@ -261,9 +245,10 @@ private:
Map<ObjectID, uint64_t> physics_2d_mouseover;
Ref<World2D> world_2d;
- Ref<World> world;
- Ref<World> own_world;
+ Ref<World3D> world;
+ Ref<World3D> own_world;
+ Rect2i to_screen_rect;
StringName input_group;
StringName gui_input_group;
StringName unhandled_input_group;
@@ -276,10 +261,8 @@ private:
void _propagate_exit_world(Node *p_node);
void _propagate_viewport_notification(Node *p_node, int p_what);
- void _update_stretch_transform();
void _update_global_transform();
- UpdateMode update_mode;
RID texture_rid;
DebugDraw debug_draw;
@@ -291,9 +274,35 @@ private:
Ref<ViewportTexture> default_texture;
Set<ViewportTexture *> viewport_textures;
+ enum SubWindowDrag {
+ SUB_WINDOW_DRAG_DISABLED,
+ SUB_WINDOW_DRAG_MOVE,
+ SUB_WINDOW_DRAG_CLOSE,
+ SUB_WINDOW_DRAG_RESIZE,
+ };
+
+ enum SubWindowResize {
+ SUB_WINDOW_RESIZE_DISABLED,
+ SUB_WINDOW_RESIZE_TOP_LEFT,
+ SUB_WINDOW_RESIZE_TOP,
+ SUB_WINDOW_RESIZE_TOP_RIGHT,
+ SUB_WINDOW_RESIZE_LEFT,
+ SUB_WINDOW_RESIZE_RIGHT,
+ SUB_WINDOW_RESIZE_BOTTOM_LEFT,
+ SUB_WINDOW_RESIZE_BOTTOM,
+ SUB_WINDOW_RESIZE_BOTTOM_RIGHT,
+ SUB_WINDOW_RESIZE_MAX
+ };
+
+ struct SubWindow {
+ Window *window;
+ RID canvas_item;
+ };
+
struct GUI {
// info used when this is a window
+ bool forced_mouse_focus; //used for menu buttons
bool key_event_accepted;
Control *mouse_focus;
Control *last_mouse_focus;
@@ -301,8 +310,10 @@ private:
int mouse_focus_mask;
Control *key_focus;
Control *mouse_over;
+ Control *drag_mouse_over;
+ Vector2 drag_mouse_over_pos;
Control *tooltip;
- Control *tooltip_popup;
+ Window *tooltip_popup;
Label *tooltip_label;
Point2 tooltip_pos;
Point2 last_mouse_pos;
@@ -312,16 +323,24 @@ private:
Control *drag_preview;
float tooltip_timer;
float tooltip_delay;
- List<Control *> modal_stack;
Transform2D focus_inv_xform;
- bool subwindow_order_dirty;
- bool subwindow_visibility_dirty;
- List<Control *> subwindows; // visible subwindows
- List<Control *> all_known_subwindows;
bool roots_order_dirty;
List<Control *> roots;
int canvas_sort_index; //for sorting items with canvas as root
bool dragging;
+ bool embed_subwindows_hint;
+ bool embedding_subwindows;
+
+ Window *subwindow_focused;
+ SubWindowDrag subwindow_drag;
+ Vector2 subwindow_drag_from;
+ Vector2 subwindow_drag_pos;
+ Rect2i subwindow_drag_close_rect;
+ bool subwindow_drag_close_inside;
+ SubWindowResize subwindow_resize_mode;
+ Rect2i subwindow_resize_from_rect;
+
+ Vector<SubWindow> sub_windows;
GUI();
} gui;
@@ -337,10 +356,7 @@ private:
void _gui_call_input(Control *p_control, const Ref<InputEvent> &p_input);
void _gui_call_notification(Control *p_control, int p_what);
- void _gui_prepare_subwindows();
- void _gui_sort_subwindows();
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 Transform2D &p_xform, Transform2D &r_inv_xform);
@@ -350,23 +366,13 @@ private:
_FORCE_INLINE_ Transform2D _get_input_pre_xform() const;
- void _vp_input(const Ref<InputEvent> &p_ev);
- void _vp_input_text(const String &p_text);
- void _vp_unhandled_input(const Ref<InputEvent> &p_ev);
Ref<InputEvent> _make_input_local(const Ref<InputEvent> &ev);
friend class Control;
List<Control *>::Element *_gui_add_root_control(Control *p_control);
- List<Control *>::Element *_gui_add_subwindow_control(Control *p_control);
-
- void _gui_set_subwindow_order_dirty();
- void _gui_set_root_order_dirty();
- void _gui_remove_modal_control(List<Control *>::Element *MI);
- void _gui_remove_from_modal_stack(List<Control *>::Element *MI, ObjectID p_prev_focus_owner);
void _gui_remove_root_control(List<Control *>::Element *RI);
- void _gui_remove_subwindow_control(List<Control *>::Element *SI);
String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_which = NULL);
void _gui_cancel_tooltip();
@@ -378,9 +384,6 @@ private:
void _gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control);
void _gui_set_drag_preview(Control *p_base, Control *p_control);
- bool _gui_is_modal_on_top(const Control *p_control);
- List<Control *>::Element *_gui_show_modal(Control *p_control);
-
void _gui_remove_focus();
void _gui_unfocus_control(Control *p_control);
bool _gui_control_has_focus(const Control *p_control);
@@ -391,23 +394,21 @@ private:
Control *_gui_get_focus_owner();
- Vector2 _get_window_offset() const;
-
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
- friend class Listener;
+ friend class Listener3D;
void _listener_transform_changed_notify();
- void _listener_set(Listener *p_listener);
- bool _listener_add(Listener *p_listener); //true if first
- void _listener_remove(Listener *p_listener);
- void _listener_make_next_current(Listener *p_exclude);
+ void _listener_set(Listener3D *p_listener);
+ bool _listener_add(Listener3D *p_listener); //true if first
+ void _listener_remove(Listener3D *p_listener);
+ void _listener_make_next_current(Listener3D *p_exclude);
- friend class Camera;
+ friend class Camera3D;
void _camera_transform_changed_notify();
- void _camera_set(Camera *p_camera);
- bool _camera_add(Camera *p_camera); //true if first
- void _camera_remove(Camera *p_camera);
- void _camera_make_next_current(Camera *p_exclude);
+ void _camera_set(Camera3D *p_camera);
+ bool _camera_add(Camera3D *p_camera); //true if first
+ void _camera_remove(Camera3D *p_camera);
+ void _camera_make_next_current(Camera3D *p_exclude);
friend class CanvasLayer;
void _canvas_layer_add(CanvasLayer *p_canvas_layer);
@@ -418,16 +419,33 @@ private:
void _update_canvas_items(Node *p_node);
+ void _gui_set_root_order_dirty();
+
void _own_world_changed();
+ friend class Window;
+
+ void _sub_window_update_order();
+ void _sub_window_register(Window *p_window);
+ void _sub_window_update(Window *p_window);
+ void _sub_window_grab_focus(Window *p_window);
+ void _sub_window_remove(Window *p_window);
+ bool _sub_windows_forward_input(const Ref<InputEvent> &p_event);
+ SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point);
+
protected:
+ void _set_size(const Size2i &p_size, const Size2i &p_size_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated);
+
+ Size2i _get_size() const;
+ bool _is_size_allocated() const;
+
void _notification(int p_what);
static void _bind_methods();
virtual void _validate_property(PropertyInfo &property) const;
public:
- Listener *get_listener() const;
- Camera *get_camera() const;
+ Listener3D *get_listener() const;
+ Camera3D *get_camera() const;
void enable_camera_override(bool p_enable);
bool is_camera_override_enabled() const;
@@ -438,26 +456,21 @@ public:
void set_camera_override_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
void set_camera_override_orthogonal(float p_size, float p_z_near, float p_z_far);
- void set_use_arvr(bool p_use_arvr);
- bool use_arvr();
-
void set_as_audio_listener(bool p_enable);
bool is_audio_listener() const;
void set_as_audio_listener_2d(bool p_enable);
bool is_audio_listener_2d() const;
- void set_size(const Size2 &p_size);
void update_canvas_items();
- Size2 get_size() const;
Rect2 get_visible_rect() const;
RID get_viewport_rid() const;
- void set_world(const Ref<World> &p_world);
+ void set_world(const Ref<World3D> &p_world);
void set_world_2d(const Ref<World2D> &p_world_2d);
- Ref<World> get_world() const;
- Ref<World> find_world() const;
+ Ref<World3D> get_world() const;
+ Ref<World3D> find_world() const;
Ref<World2D> get_world_2d() const;
Ref<World2D> find_world_2d() const;
@@ -479,18 +492,6 @@ public:
void set_transparent_background(bool p_enable);
bool has_transparent_background() const;
- 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_clear_mode(ClearMode p_mode);
- ClearMode get_clear_mode() const;
-
- void set_update_mode(UpdateMode p_mode);
- UpdateMode get_update_mode() const;
Ref<ViewportTexture> get_texture() const;
void set_shadow_atlas_size(int p_size);
@@ -508,28 +509,20 @@ public:
void set_use_own_world(bool p_world);
bool is_using_own_world() const;
- void input(const Ref<InputEvent> &p_event);
- void unhandled_input(const Ref<InputEvent> &p_event);
+ void input_text(const String &p_text);
+ void input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
+ void unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
void set_disable_input(bool p_disable);
bool is_input_disabled() const;
- void set_attach_to_screen_rect(const Rect2 &p_rect);
- Rect2 get_attach_to_screen_rect() const;
-
- void set_use_render_direct_to_screen(bool p_render_direct_to_screen);
- bool is_using_render_direct_to_screen() const;
-
Vector2 get_mouse_position() const;
void warp_mouse(const Vector2 &p_pos);
void set_physics_object_picking(bool p_enable);
bool get_physics_object_picking();
- bool gui_has_modal_stack() const;
-
Variant gui_get_drag_data() const;
- Control *get_modal_stack_top() const;
void gui_reset_canvas_sort_index();
int gui_get_canvas_sort_index();
@@ -544,8 +537,6 @@ public:
void set_snap_controls_to_pixels(bool p_enable);
bool is_snap_controls_to_pixels_enabled() const;
- void _subwindow_visibility_changed();
-
void set_input_as_handled();
bool is_input_handled() const;
@@ -560,15 +551,71 @@ public:
void set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRepeat p_repeat);
DefaultCanvasItemTextureRepeat get_default_canvas_item_texture_repeat() const;
+ virtual DisplayServer::WindowID get_window_id() const = 0;
+
+ void set_embed_subwindows_hint(bool p_embed);
+ bool get_embed_subwindows_hint() const;
+ bool is_embedding_subwindows() const;
+
+ Viewport *get_parent_viewport() const;
+
+ void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
+
Viewport();
~Viewport();
};
-VARIANT_ENUM_CAST(Viewport::UpdateMode);
+class SubViewport : public Viewport {
+
+ GDCLASS(SubViewport, Viewport);
+
+public:
+ enum ClearMode {
+
+ CLEAR_MODE_ALWAYS,
+ CLEAR_MODE_NEVER,
+ CLEAR_MODE_ONLY_NEXT_FRAME
+ };
+
+ enum UpdateMode {
+ UPDATE_DISABLED,
+ UPDATE_ONCE, //then goes to disabled
+ UPDATE_WHEN_VISIBLE, // default
+ UPDATE_WHEN_PARENT_VISIBLE,
+ UPDATE_ALWAYS
+ };
+
+private:
+ UpdateMode update_mode;
+ ClearMode clear_mode;
+ bool arvr;
+
+protected:
+ static void _bind_methods();
+ virtual DisplayServer::WindowID get_window_id() const;
+ void _notification(int p_what);
+
+public:
+ void set_size(const Size2i &p_size);
+ Size2i get_size() const;
+
+ void set_use_arvr(bool p_use_arvr);
+ bool is_using_arvr();
+
+ void set_update_mode(UpdateMode p_mode);
+ UpdateMode get_update_mode() const;
+
+ void set_clear_mode(ClearMode p_mode);
+ ClearMode get_clear_mode() const;
+
+ SubViewport();
+ ~SubViewport();
+};
+VARIANT_ENUM_CAST(SubViewport::UpdateMode);
VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv);
VARIANT_ENUM_CAST(Viewport::MSAA);
VARIANT_ENUM_CAST(Viewport::DebugDraw);
-VARIANT_ENUM_CAST(Viewport::ClearMode);
+VARIANT_ENUM_CAST(SubViewport::ClearMode);
VARIANT_ENUM_CAST(Viewport::RenderInfo);
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureFilter);
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureRepeat);
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
new file mode 100644
index 0000000000..3a8f7ebb60
--- /dev/null
+++ b/scene/main/window.cpp
@@ -0,0 +1,1406 @@
+/*************************************************************************/
+/* window.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "window.h"
+
+#include "core/debugger/engine_debugger.h"
+#include "core/os/keyboard.h"
+#include "scene/gui/control.h"
+#include "scene/resources/dynamic_font.h"
+#include "scene/scene_string_names.h"
+
+void Window::set_title(const String &p_title) {
+ title = p_title;
+
+ if (embedder) {
+ embedder->_sub_window_update(this);
+
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+
+ DisplayServer::get_singleton()->window_set_title(p_title, window_id);
+ }
+}
+String Window::get_title() const {
+ return title;
+}
+
+void Window::set_current_screen(int p_screen) {
+ current_screen = p_screen;
+ if (window_id == DisplayServer::INVALID_WINDOW_ID)
+ return;
+ DisplayServer::get_singleton()->window_set_current_screen(p_screen, window_id);
+}
+int Window::get_current_screen() const {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ current_screen = DisplayServer::get_singleton()->window_get_current_screen(window_id);
+ }
+ return current_screen;
+}
+
+void Window::set_position(const Point2i &p_position) {
+
+ position = p_position;
+
+ if (embedder) {
+ embedder->_sub_window_update(this);
+
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+
+ DisplayServer::get_singleton()->window_set_position(p_position, window_id);
+ }
+}
+Point2i Window::get_position() const {
+ return position;
+}
+
+void Window::set_size(const Size2i &p_size) {
+ size = p_size;
+ _update_window_size();
+}
+Size2i Window::get_size() const {
+
+ return size;
+}
+
+Size2i Window::get_real_size() const {
+
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ return DisplayServer::get_singleton()->window_get_real_size(window_id);
+ }
+ return size;
+}
+
+void Window::set_max_size(const Size2i &p_max_size) {
+ max_size = p_max_size;
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_max_size(max_size, window_id);
+ }
+ _update_window_size();
+}
+
+Size2i Window::get_max_size() const {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ max_size = DisplayServer::get_singleton()->window_get_max_size(window_id);
+ }
+ return max_size;
+}
+
+void Window::set_min_size(const Size2i &p_min_size) {
+ min_size = p_min_size;
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_min_size(min_size, window_id);
+ }
+ _update_window_size();
+}
+
+Size2i Window::get_min_size() const {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ min_size = DisplayServer::get_singleton()->window_get_min_size(window_id);
+ }
+ return min_size;
+}
+
+void Window::set_mode(Mode p_mode) {
+
+ mode = p_mode;
+
+ if (embedder) {
+ embedder->_sub_window_update(this);
+
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+
+ DisplayServer::get_singleton()->window_set_mode(DisplayServer::WindowMode(p_mode), window_id);
+ }
+}
+
+Window::Mode Window::get_mode() const {
+
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ mode = (Mode)DisplayServer::get_singleton()->window_get_mode(window_id);
+ }
+ return mode;
+}
+
+void Window::set_flag(Flags p_flag, bool p_enabled) {
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags[p_flag] = p_enabled;
+
+ if (embedder) {
+ embedder->_sub_window_update(this);
+
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+
+ DisplayServer::get_singleton()->window_set_flag(DisplayServer::WindowFlags(p_flag), p_enabled, window_id);
+ }
+}
+
+bool Window::get_flag(Flags p_flag) const {
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ flags[p_flag] = DisplayServer::get_singleton()->window_get_flag(DisplayServer::WindowFlags(p_flag), window_id);
+ }
+ return flags[p_flag];
+}
+
+bool Window::is_maximize_allowed() const {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ return DisplayServer::get_singleton()->window_is_maximize_allowed(window_id);
+ }
+ return true;
+}
+
+void Window::request_attention() {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_request_attention(window_id);
+ }
+}
+void Window::move_to_foreground() {
+
+ if (embedder) {
+ embedder->_sub_window_grab_focus(this);
+
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_move_to_foreground(window_id);
+ }
+}
+
+bool Window::can_draw() const {
+ if (!is_inside_tree()) {
+ return false;
+ }
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ return DisplayServer::get_singleton()->window_can_draw(window_id);
+ }
+
+ return visible;
+}
+
+void Window::set_ime_active(bool p_active) {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_active(p_active, window_id);
+ }
+}
+void Window::set_ime_position(const Point2i &p_pos) {
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_ime_position(p_pos, window_id);
+ }
+}
+
+bool Window::is_embedded() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), false);
+
+ return _get_embedder() != nullptr;
+}
+
+void Window::_make_window() {
+ ERR_FAIL_COND(window_id != DisplayServer::INVALID_WINDOW_ID);
+
+ uint32_t f = 0;
+ for (int i = 0; i < FLAG_MAX; i++) {
+ if (flags[i]) {
+ f |= (1 << i);
+ }
+ }
+
+ window_id = DisplayServer::get_singleton()->create_sub_window(DisplayServer::WindowMode(mode), f, Rect2i(position, size));
+ ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID);
+ DisplayServer::get_singleton()->window_set_current_screen(current_screen, window_id);
+ DisplayServer::get_singleton()->window_set_max_size(max_size, window_id);
+ DisplayServer::get_singleton()->window_set_min_size(min_size, window_id);
+ DisplayServer::get_singleton()->window_set_title(title, window_id);
+ DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id);
+
+ _update_window_size();
+
+ if (transient_parent && transient_parent->window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(window_id, transient_parent->window_id);
+ }
+
+ for (Set<Window *>::Element *E = transient_children.front(); E; E = E->next()) {
+ if (E->get()->window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(E->get()->window_id, transient_parent->window_id);
+ }
+ }
+
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
+}
+void Window::_update_from_window() {
+
+ ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID);
+ mode = (Mode)DisplayServer::get_singleton()->window_get_mode(window_id);
+ for (int i = 0; i < FLAG_MAX; i++) {
+ flags[i] = DisplayServer::get_singleton()->window_get_flag(DisplayServer::WindowFlags(i), window_id);
+ }
+}
+
+void Window::_clear_window() {
+ ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID);
+
+ if (transient_parent && transient_parent->window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(window_id, DisplayServer::INVALID_WINDOW_ID);
+ }
+
+ for (Set<Window *>::Element *E = transient_children.front(); E; E = E->next()) {
+ if (E->get()->window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(E->get()->window_id, DisplayServer::INVALID_WINDOW_ID);
+ }
+ }
+
+ _update_from_window();
+
+ DisplayServer::get_singleton()->delete_sub_window(window_id);
+ window_id = DisplayServer::INVALID_WINDOW_ID;
+
+ _update_viewport_size();
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
+}
+
+void Window::_rect_changed_callback(const Rect2i &p_callback) {
+
+ //we must always accept this as the truth
+ if (size == p_callback.size && position == p_callback.position) {
+ return;
+ }
+ position = p_callback.position;
+
+ if (size != p_callback.size) {
+ size = p_callback.size;
+ _update_viewport_size();
+ }
+}
+
+void Window::_propagate_window_notification(Node *p_node, int p_notification) {
+ p_node->notification(p_notification);
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ Node *child = p_node->get_child(i);
+ Window *window = Object::cast_to<Window>(child);
+ if (window) {
+ break;
+ }
+ _propagate_window_notification(child, p_notification);
+ }
+}
+
+void Window::_event_callback(DisplayServer::WindowEvent p_event) {
+
+ switch (p_event) {
+ case DisplayServer::WINDOW_EVENT_MOUSE_ENTER: {
+ _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER);
+ emit_signal("mouse_entered");
+ } break;
+ case DisplayServer::WINDOW_EVENT_MOUSE_EXIT: {
+ _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_EXIT);
+ emit_signal("mouse_exited");
+ } break;
+ case DisplayServer::WINDOW_EVENT_FOCUS_IN: {
+ focused = true;
+ _propagate_window_notification(this, NOTIFICATION_WM_FOCUS_IN);
+ emit_signal("focus_entered");
+
+ } break;
+ case DisplayServer::WINDOW_EVENT_FOCUS_OUT: {
+ focused = false;
+ _propagate_window_notification(this, NOTIFICATION_WM_FOCUS_OUT);
+ emit_signal("focus_exited");
+ } break;
+ case DisplayServer::WINDOW_EVENT_CLOSE_REQUEST: {
+ if (exclusive_child != nullptr) {
+ break; //has an exclusive child, can't get events until child is closed
+ }
+ _propagate_window_notification(this, NOTIFICATION_WM_CLOSE_REQUEST);
+ emit_signal("close_requested");
+ } break;
+ case DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST: {
+ _propagate_window_notification(this, NOTIFICATION_WM_GO_BACK_REQUEST);
+ emit_signal("go_back_requested");
+ } break;
+ case DisplayServer::WINDOW_EVENT_DPI_CHANGE: {
+ _propagate_window_notification(this, NOTIFICATION_WM_DPI_CHANGE);
+ emit_signal("dpi_changed");
+ } break;
+ }
+}
+
+void Window::show() {
+ set_visible(true);
+}
+void Window::hide() {
+ set_visible(false);
+}
+
+void Window::set_visible(bool p_visible) {
+
+ if (visible == p_visible) {
+ return;
+ }
+
+ visible = p_visible;
+
+ if (!is_inside_tree()) {
+ return;
+ }
+
+ if (updating_child_controls) {
+ _update_child_controls();
+ }
+
+ ERR_FAIL_COND_MSG(get_parent() == nullptr, "Can't change visibility of main window.");
+
+ Viewport *embedder_vp = _get_embedder();
+
+ if (!embedder_vp) {
+ if (!p_visible && window_id != DisplayServer::INVALID_WINDOW_ID) {
+ _clear_window();
+ }
+ if (p_visible && window_id == DisplayServer::INVALID_WINDOW_ID) {
+ _make_window();
+ _update_window_callbacks();
+ }
+ } else {
+ if (visible) {
+ embedder = embedder_vp;
+ embedder->_sub_window_register(this);
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
+ } else {
+ embedder->_sub_window_remove(this);
+ embedder = nullptr;
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
+ }
+ _update_window_size();
+ }
+
+ if (!visible) {
+ focused = false;
+ }
+ notification(NOTIFICATION_VISIBILITY_CHANGED);
+ emit_signal(SceneStringNames::get_singleton()->visibility_changed);
+
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), visible);
+}
+
+void Window::_clear_transient() {
+ if (transient_parent) {
+ if (transient_parent->window_id != DisplayServer::INVALID_WINDOW_ID && window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(window_id, DisplayServer::INVALID_WINDOW_ID);
+ }
+ transient_parent->transient_children.erase(this);
+ if (transient_parent->exclusive_child == this) {
+ transient_parent->exclusive_child = nullptr;
+ }
+ transient_parent = nullptr;
+ }
+}
+
+void Window::_make_transient() {
+ if (!get_parent()) {
+ //main window, can't be transient
+ return;
+ }
+ //find transient parent
+ Viewport *vp = get_parent()->get_viewport();
+ Window *window = nullptr;
+ while (vp) {
+ window = Object::cast_to<Window>(vp);
+ if (window) {
+ break;
+ }
+ if (!vp->get_parent()) {
+ break;
+ }
+
+ vp = vp->get_parent()->get_viewport();
+ }
+
+ if (window) {
+ transient_parent = window;
+ window->transient_children.insert(this);
+ if (is_inside_tree() && is_visible() && exclusive) {
+ if (transient_parent->exclusive_child == nullptr) {
+ transient_parent->exclusive_child = this;
+ } else if (transient_parent->exclusive_child != this) {
+ ERR_PRINT("Making child transient exclusive, but parent has another exclusive child");
+ }
+ }
+ }
+
+ //see if we can make transient
+ if (transient_parent->window_id != DisplayServer::INVALID_WINDOW_ID && window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_transient(window_id, transient_parent->window_id);
+ }
+}
+
+void Window::set_transient(bool p_transient) {
+ if (transient == p_transient) {
+ return;
+ }
+
+ transient = p_transient;
+
+ if (!is_inside_tree()) {
+ return;
+ }
+
+ if (transient) {
+ _make_transient();
+ } else {
+ _clear_transient();
+ }
+}
+bool Window::is_transient() const {
+ return transient;
+}
+
+void Window::set_exclusive(bool p_exclusive) {
+
+ if (exclusive == p_exclusive) {
+ return;
+ }
+
+ exclusive = p_exclusive;
+
+ if (transient_parent) {
+ if (p_exclusive && is_inside_tree() && is_visible()) {
+ ERR_FAIL_COND_MSG(transient_parent->exclusive_child && transient_parent->exclusive_child != this, "Transient parent has another exclusive child.");
+ transient_parent->exclusive_child = this;
+ } else {
+ if (transient_parent->exclusive_child == this) {
+ transient_parent->exclusive_child = nullptr;
+ }
+ }
+ }
+}
+
+bool Window::is_exclusive() const {
+ return exclusive;
+}
+
+bool Window::is_visible() const {
+ return visible;
+}
+
+void Window::_update_window_size() {
+
+ Size2i size_limit;
+ if (wrap_controls) {
+ size_limit = get_contents_minimum_size();
+ }
+
+ size_limit.x = MAX(size_limit.x, min_size.x);
+ size_limit.y = MAX(size_limit.y, min_size.y);
+
+ size.x = MAX(size_limit.x, size.x);
+ size.y = MAX(size_limit.y, size.y);
+
+ if (max_size.x > 0 && max_size.x > min_size.x && max_size.x > size.x) {
+ size.x = max_size.x;
+ }
+
+ if (max_size.y > 0 && max_size.y > min_size.y && max_size.y > size.y) {
+ size.y = max_size.y;
+ }
+
+ if (embedder) {
+ embedder->_sub_window_update(this);
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_size(size, window_id);
+ }
+
+ //update the viewport
+ _update_viewport_size();
+}
+void Window::_update_viewport_size() {
+ //update the viewport part
+
+ Size2i final_size;
+ Size2i final_size_override;
+ Rect2i attach_to_screen_rect(Point2i(), size);
+ Transform2D stretch_transform;
+ float font_oversampling = 1.0;
+
+ if (content_scale_mode == CONTENT_SCALE_MODE_DISABLED || content_scale_size.x == 0 || content_scale_size.y == 0) {
+
+ stretch_transform = Transform2D();
+ final_size = size;
+
+ } else {
+
+ //actual screen video mode
+ Size2 video_mode = size;
+ Size2 desired_res = content_scale_size;
+
+ Size2 viewport_size;
+ Size2 screen_size;
+
+ float viewport_aspect = desired_res.aspect();
+ float video_mode_aspect = video_mode.aspect();
+
+ if (content_scale_aspect == CONTENT_SCALE_ASPECT_IGNORE || Math::is_equal_approx(viewport_aspect, video_mode_aspect)) {
+ //same aspect or ignore aspect
+ viewport_size = desired_res;
+ screen_size = video_mode;
+ } else if (viewport_aspect < video_mode_aspect) {
+ // screen ratio is smaller vertically
+
+ if (content_scale_aspect == CONTENT_SCALE_ASPECT_KEEP_HEIGHT || content_scale_aspect == CONTENT_SCALE_ASPECT_EXPAND) {
+
+ //will stretch horizontally
+ viewport_size.x = desired_res.y * video_mode_aspect;
+ viewport_size.y = desired_res.y;
+ screen_size = video_mode;
+
+ } else {
+ //will need black bars
+ viewport_size = desired_res;
+ screen_size.x = video_mode.y * viewport_aspect;
+ screen_size.y = video_mode.y;
+ }
+ } else {
+ //screen ratio is smaller horizontally
+ if (content_scale_aspect == CONTENT_SCALE_ASPECT_KEEP_WIDTH || content_scale_aspect == CONTENT_SCALE_ASPECT_EXPAND) {
+
+ //will stretch horizontally
+ viewport_size.x = desired_res.x;
+ viewport_size.y = desired_res.x / video_mode_aspect;
+ screen_size = video_mode;
+
+ } else {
+ //will need black bars
+ viewport_size = desired_res;
+ screen_size.x = video_mode.x;
+ screen_size.y = video_mode.x / viewport_aspect;
+ }
+ }
+
+ screen_size = screen_size.floor();
+ viewport_size = viewport_size.floor();
+
+ Size2 margin;
+ Size2 offset;
+ //black bars and margin
+ if (content_scale_aspect != CONTENT_SCALE_ASPECT_EXPAND && screen_size.x < video_mode.x) {
+ margin.x = Math::round((video_mode.x - screen_size.x) / 2.0);
+ //RenderingServer::get_singleton()->black_bars_set_margins(margin.x, 0, margin.x, 0);
+ offset.x = Math::round(margin.x * viewport_size.y / screen_size.y);
+ } else if (content_scale_aspect != CONTENT_SCALE_ASPECT_EXPAND && screen_size.y < video_mode.y) {
+ margin.y = Math::round((video_mode.y - screen_size.y) / 2.0);
+ //RenderingServer::get_singleton()->black_bars_set_margins(0, margin.y, 0, margin.y);
+ offset.y = Math::round(margin.y * viewport_size.x / screen_size.x);
+ } else {
+ //RenderingServer::get_singleton()->black_bars_set_margins(0, 0, 0, 0);
+ }
+
+ switch (content_scale_mode) {
+ case CONTENT_SCALE_MODE_DISABLED: {
+ // Already handled above
+ //_update_font_oversampling(1.0);
+ } break;
+ case CONTENT_SCALE_MODE_OBJECTS: {
+
+ final_size = screen_size;
+ final_size_override = viewport_size;
+ attach_to_screen_rect = Rect2(margin, screen_size);
+ font_oversampling = screen_size.x / viewport_size.x;
+ } break;
+ case CONTENT_SCALE_MODE_PIXELS: {
+
+ final_size = viewport_size;
+ attach_to_screen_rect = Rect2(margin, screen_size);
+
+ } break;
+ }
+
+ Size2 scale = size / (Vector2(final_size) + margin * 2);
+ stretch_transform.scale(scale);
+ stretch_transform.elements[2] = margin * scale;
+ }
+
+ bool allocate = is_inside_tree() && visible && (window_id != DisplayServer::INVALID_WINDOW_ID || embedder != nullptr);
+
+ _set_size(final_size, final_size_override, attach_to_screen_rect, stretch_transform, allocate);
+
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id);
+ } else {
+ RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), Rect2i(), DisplayServer::INVALID_WINDOW_ID);
+ }
+
+ if (window_id == DisplayServer::MAIN_WINDOW_ID) {
+
+ if (!use_font_oversampling) {
+ font_oversampling = 1.0;
+ }
+ if (DynamicFontAtSize::font_oversampling != font_oversampling) {
+
+ DynamicFontAtSize::font_oversampling = font_oversampling;
+ DynamicFont::update_oversampling();
+ }
+ }
+
+ notification(NOTIFICATION_WM_SIZE_CHANGED);
+
+ if (embedder) {
+ embedder->_sub_window_update(this);
+ }
+}
+
+void Window::_update_window_callbacks() {
+ DisplayServer::get_singleton()->window_set_rect_changed_callback(callable_mp(this, &Window::_rect_changed_callback), window_id);
+ DisplayServer::get_singleton()->window_set_window_event_callback(callable_mp(this, &Window::_event_callback), window_id);
+ DisplayServer::get_singleton()->window_set_input_event_callback(callable_mp(this, &Window::_window_input), window_id);
+ DisplayServer::get_singleton()->window_set_input_text_callback(callable_mp(this, &Window::_window_input_text), window_id);
+ DisplayServer::get_singleton()->window_set_drop_files_callback(callable_mp(this, &Window::_window_drop_files), window_id);
+}
+
+Viewport *Window::_get_embedder() const {
+
+ Viewport *vp = get_parent_viewport();
+
+ while (vp) {
+
+ if (vp->is_embedding_subwindows()) {
+ return vp;
+ }
+
+ if (vp->get_parent()) {
+ vp = vp->get_parent()->get_viewport();
+ } else {
+ vp = nullptr;
+ }
+ }
+ return nullptr;
+}
+
+void Window::_notification(int p_what) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+
+ bool embedded = false;
+ {
+
+ embedder = _get_embedder();
+
+ if (embedder) {
+ embedded = true;
+
+ if (!visible) {
+ embedder = nullptr; //not yet since not visible
+ }
+ }
+ }
+
+ if (embedded) {
+ //create as embedded
+ if (embedder) {
+ embedder->_sub_window_register(this);
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
+ _update_window_size();
+ }
+
+ } else {
+ if (get_parent() == nullptr) {
+ //it's the root window!
+ visible = true; //always visible
+ window_id = DisplayServer::MAIN_WINDOW_ID;
+ DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id);
+ _update_from_window();
+ //since this window already exists (created on start), we must update pos and size from it
+ {
+ position = DisplayServer::get_singleton()->window_get_position(window_id);
+ size = DisplayServer::get_singleton()->window_get_size(window_id);
+ }
+ _update_viewport_size(); //then feed back to the viewport
+ _update_window_callbacks();
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
+ } else {
+ //create
+ if (visible) {
+ _make_window();
+ _update_window_callbacks();
+ }
+ }
+ }
+
+ if (transient) {
+ _make_transient();
+ }
+ if (visible) {
+ notification(NOTIFICATION_VISIBILITY_CHANGED);
+ emit_signal(SceneStringNames::get_singleton()->visibility_changed);
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
+ }
+ }
+
+ if (p_what == NOTIFICATION_READY) {
+
+ if (wrap_controls) {
+ _update_child_controls();
+ }
+ }
+
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+
+ if (transient) {
+ _clear_transient();
+ }
+
+ if (!is_embedded() && window_id != DisplayServer::INVALID_WINDOW_ID) {
+
+ if (window_id == DisplayServer::MAIN_WINDOW_ID) {
+
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
+ _update_window_callbacks();
+ } else {
+ _clear_window();
+ }
+ } else {
+
+ if (embedder) {
+ embedder->_sub_window_remove(this);
+ embedder = nullptr;
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
+ }
+ _update_viewport_size(); //called by clear and make, which does not happen here
+ }
+
+ RS::get_singleton()->viewport_set_active(get_viewport_rid(), false);
+ }
+}
+
+void Window::set_content_scale_size(const Size2i &p_size) {
+ ERR_FAIL_COND(p_size.x < 0);
+ ERR_FAIL_COND(p_size.y < 0);
+ content_scale_size = p_size;
+ _update_viewport_size();
+}
+
+Size2i Window::get_content_scale_size() const {
+ return content_scale_size;
+}
+
+void Window::set_content_scale_mode(ContentScaleMode p_mode) {
+ content_scale_mode = p_mode;
+ _update_viewport_size();
+}
+Window::ContentScaleMode Window::get_content_scale_mode() const {
+ return content_scale_mode;
+}
+
+void Window::set_content_scale_aspect(ContentScaleAspect p_aspect) {
+ content_scale_aspect = p_aspect;
+ _update_viewport_size();
+}
+Window::ContentScaleAspect Window::get_content_scale_aspect() const {
+ return content_scale_aspect;
+}
+
+void Window::set_use_font_oversampling(bool p_oversampling) {
+ if (is_inside_tree() && window_id != DisplayServer::MAIN_WINDOW_ID) {
+ ERR_FAIL_MSG("Only the root window can set and use font oversampling.");
+ }
+ use_font_oversampling = p_oversampling;
+ _update_viewport_size();
+}
+bool Window::is_using_font_oversampling() const {
+ return use_font_oversampling;
+}
+
+DisplayServer::WindowID Window::get_window_id() const {
+ return window_id;
+}
+
+void Window::set_wrap_controls(bool p_enable) {
+ wrap_controls = p_enable;
+ if (wrap_controls) {
+ child_controls_changed();
+ }
+}
+
+bool Window::is_wrapping_controls() const {
+ return wrap_controls;
+}
+
+Size2 Window::_get_contents_minimum_size() const {
+ Size2 max;
+
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = Object::cast_to<Control>(get_child(i));
+ if (c) {
+ Point2i pos = c->get_position();
+ Size2i min = c->get_combined_minimum_size();
+
+ max.x = MAX(pos.x + min.x, max.x);
+ max.y = MAX(pos.y + min.y, max.y);
+ }
+ }
+
+ return max;
+}
+void Window::_update_child_controls() {
+
+ if (!updating_child_controls) {
+ return;
+ }
+
+ _update_window_size();
+
+ updating_child_controls = false;
+}
+void Window::child_controls_changed() {
+
+ if (!is_inside_tree() || !visible || updating_child_controls) {
+ return;
+ }
+
+ updating_child_controls = true;
+ call_deferred("_update_child_controls");
+}
+
+void Window::_window_input(const Ref<InputEvent> &p_ev) {
+ if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_ev.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_ev)))
+ return; //avoid joy input on editor
+
+ if (EngineDebugger::is_active()) {
+ //quit from game window using F8
+ Ref<InputEventKey> k = p_ev;
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_F8) {
+ EngineDebugger::get_singleton()->send_message("request_quit", Array());
+ }
+ }
+
+ if (exclusive_child != nullptr) {
+ exclusive_child->grab_focus();
+
+ return; //has an exclusive child, can't get events until child is closed
+ }
+
+ emit_signal(SceneStringNames::get_singleton()->window_input, p_ev);
+ input(p_ev);
+ if (!is_input_handled()) {
+ unhandled_input(p_ev);
+ }
+}
+void Window::_window_input_text(const String &p_text) {
+ input_text(p_text);
+}
+void Window::_window_drop_files(const Vector<String> &p_files) {
+ emit_signal("files_dropped", p_files);
+}
+
+Viewport *Window::get_parent_viewport() const {
+
+ if (get_parent()) {
+ return get_parent()->get_viewport();
+ } else {
+ return nullptr;
+ }
+}
+
+Window *Window::get_parent_visible_window() const {
+
+ Viewport *vp = get_parent_viewport();
+ Window *window = nullptr;
+ while (vp) {
+ window = Object::cast_to<Window>(vp);
+ if (window && window->visible) {
+ break;
+ }
+ if (!vp->get_parent()) {
+ break;
+ }
+
+ vp = vp->get_parent()->get_viewport();
+ }
+ return window;
+}
+
+void Window::popup_on_parent(const Rect2i &p_parent_rect) {
+
+ ERR_FAIL_COND(!is_inside_tree());
+ ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
+
+ if (!is_embedded()) {
+ Window *window = get_parent_visible_window();
+
+ if (!window) {
+ popup(p_parent_rect);
+ } else {
+ popup(Rect2i(window->get_position() + p_parent_rect.position, p_parent_rect.size));
+ }
+ } else {
+ popup(p_parent_rect);
+ }
+}
+
+void Window::popup_centered_clamped(const Size2i &p_size, float p_fallback_ratio) {
+
+ ERR_FAIL_COND(!is_inside_tree());
+ ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
+
+ Rect2 parent_rect;
+
+ if (is_embedded()) {
+ parent_rect = get_parent_viewport()->get_visible_rect();
+ } else {
+ DisplayServer::WindowID parent_id = get_parent_visible_window()->get_window_id();
+ int parent_screen = DisplayServer::get_singleton()->window_get_current_screen(parent_id);
+ parent_rect.position = DisplayServer::get_singleton()->screen_get_position(parent_screen);
+ parent_rect.size = DisplayServer::get_singleton()->screen_get_size(parent_screen);
+ }
+
+ Vector2i size_ratio = parent_rect.size * p_fallback_ratio;
+
+ Rect2i popup_rect;
+ popup_rect.size = Vector2i(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y));
+ popup_rect.position = (parent_rect.size - popup_rect.size) / 2;
+
+ popup(popup_rect);
+}
+
+void Window::popup_centered(const Size2i &p_minsize) {
+ ERR_FAIL_COND(!is_inside_tree());
+ ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
+
+ Rect2 parent_rect;
+
+ if (is_embedded()) {
+ parent_rect = get_parent_viewport()->get_visible_rect();
+ } else {
+ DisplayServer::WindowID parent_id = get_parent_visible_window()->get_window_id();
+ int parent_screen = DisplayServer::get_singleton()->window_get_current_screen(parent_id);
+ parent_rect.position = DisplayServer::get_singleton()->screen_get_position(parent_screen);
+ parent_rect.size = DisplayServer::get_singleton()->screen_get_size(parent_screen);
+ }
+
+ Rect2i popup_rect;
+ if (p_minsize == Size2i()) {
+ popup_rect.size = _get_contents_minimum_size();
+ } else {
+ popup_rect.size = p_minsize;
+ }
+ popup_rect.position = (parent_rect.size - popup_rect.size) / 2;
+
+ popup(popup_rect);
+}
+
+void Window::popup_centered_ratio(float p_ratio) {
+
+ ERR_FAIL_COND(!is_inside_tree());
+ ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
+
+ Rect2i parent_rect;
+
+ if (is_embedded()) {
+ parent_rect = get_parent_viewport()->get_visible_rect();
+ } else {
+ DisplayServer::WindowID parent_id = get_parent_visible_window()->get_window_id();
+ int parent_screen = DisplayServer::get_singleton()->window_get_current_screen(parent_id);
+ parent_rect.position = DisplayServer::get_singleton()->screen_get_position(parent_screen);
+ parent_rect.size = DisplayServer::get_singleton()->screen_get_size(parent_screen);
+ }
+
+ Rect2i popup_rect;
+ popup_rect.size = parent_rect.size * p_ratio;
+ popup_rect.position = (parent_rect.size - popup_rect.size) / 2;
+
+ popup(popup_rect);
+}
+
+void Window::popup(const Rect2i &p_screen_rect) {
+
+ emit_signal("about_to_popup");
+
+ if (p_screen_rect != Rect2i()) {
+ set_position(p_screen_rect.position);
+ set_size(p_screen_rect.size);
+ }
+
+ Rect2i adjust = _popup_adjust_rect();
+ if (adjust != Rect2i()) {
+ set_position(adjust.position);
+ set_size(adjust.size);
+ }
+
+ set_transient(true);
+ set_visible(true);
+ _post_popup();
+ notification(NOTIFICATION_POST_POPUP);
+}
+
+Size2 Window::get_contents_minimum_size() const {
+ return _get_contents_minimum_size();
+}
+
+void Window::grab_focus() {
+ if (embedder) {
+ embedder->_sub_window_grab_focus(this);
+ } else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_move_to_foreground(window_id);
+ }
+}
+
+bool Window::has_focus() const {
+ return focused;
+}
+
+Rect2i Window::get_usable_parent_rect() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
+ Rect2i parent;
+ if (is_embedded()) {
+ parent = _get_embedder()->get_visible_rect();
+ } else {
+
+ const Window *w = is_visible() ? this : get_parent_visible_window();
+ //find a parent that can contain us
+ ERR_FAIL_COND_V(!w, Rect2());
+
+ parent = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen(w->get_window_id()));
+ }
+ return parent;
+}
+
+void Window::add_child_notify(Node *p_child) {
+
+ Control *child_c = Object::cast_to<Control>(p_child);
+
+ if (child_c && child_c->data.theme.is_null() && (theme_owner || theme_owner_window)) {
+ Control::_propagate_theme_changed(child_c, theme_owner, theme_owner_window); //need to propagate here, since many controls may require setting up stuff
+ }
+
+ Window *child_w = Object::cast_to<Window>(p_child);
+
+ if (child_w && child_w->theme.is_null() && (theme_owner || theme_owner_window)) {
+ Control::_propagate_theme_changed(child_w, theme_owner, theme_owner_window); //need to propagate here, since many controls may require setting up stuff
+ }
+
+ if (is_inside_tree() && wrap_controls) {
+ child_controls_changed();
+ }
+}
+
+void Window::remove_child_notify(Node *p_child) {
+
+ Control *child_c = Object::cast_to<Control>(p_child);
+
+ if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) {
+ Control::_propagate_theme_changed(child_c, NULL, NULL);
+ }
+
+ Window *child_w = Object::cast_to<Window>(p_child);
+
+ if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) {
+ Control::_propagate_theme_changed(child_w, NULL, NULL);
+ }
+
+ if (is_inside_tree() && wrap_controls) {
+ child_controls_changed();
+ }
+}
+
+void Window::set_theme(const Ref<Theme> &p_theme) {
+
+ if (theme == p_theme)
+ return;
+
+ theme = p_theme;
+
+ if (!p_theme.is_null()) {
+
+ theme_owner = nullptr;
+ theme_owner_window = this;
+ Control::_propagate_theme_changed(this, nullptr, this);
+ } else {
+
+ Control *parent_c = cast_to<Control>(get_parent());
+ if (parent_c && (parent_c->data.theme_owner || parent_c->data.theme_owner_window)) {
+ Control::_propagate_theme_changed(this, parent_c->data.theme_owner, parent_c->data.theme_owner_window);
+ } else {
+ Window *parent_w = cast_to<Window>(get_parent());
+ if (parent_w && (parent_w->theme_owner || parent_w->theme_owner_window)) {
+ Control::_propagate_theme_changed(this, parent_w->theme_owner, parent_w->theme_owner_window);
+ } else {
+ Control::_propagate_theme_changed(this, nullptr, nullptr);
+ }
+ }
+ }
+}
+Ref<Theme> Window::get_theme() const {
+ return theme;
+}
+
+Ref<Texture2D> Window::get_theme_icon(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::get_icons(theme_owner, theme_owner_window, p_name, type);
+}
+Ref<Shader> Window::get_theme_shader(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::get_shaders(theme_owner, theme_owner_window, p_name, type);
+}
+Ref<StyleBox> Window::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::get_styleboxs(theme_owner, theme_owner_window, p_name, type);
+}
+Ref<Font> Window::get_theme_font(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::get_fonts(theme_owner, theme_owner_window, p_name, type);
+}
+Color Window::get_theme_color(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::get_colors(theme_owner, theme_owner_window, p_name, type);
+}
+int Window::get_theme_constant(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::get_constants(theme_owner, theme_owner_window, p_name, type);
+}
+
+bool Window::has_theme_icon(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::has_icons(theme_owner, theme_owner_window, p_name, type);
+}
+bool Window::has_theme_shader(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::has_shaders(theme_owner, theme_owner_window, p_name, type);
+}
+bool Window::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::has_styleboxs(theme_owner, theme_owner_window, p_name, type);
+}
+bool Window::has_theme_font(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::has_fonts(theme_owner, theme_owner_window, p_name, type);
+}
+bool Window::has_theme_color(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::has_colors(theme_owner, theme_owner_window, p_name, type);
+}
+bool Window::has_theme_constant(const StringName &p_name, const StringName &p_type) const {
+ StringName type = p_type ? p_type : get_class_name();
+ return Control::has_constants(theme_owner, theme_owner_window, p_name, type);
+}
+
+Rect2i Window::get_parent_rect() const {
+ ERR_FAIL_COND_V(!is_inside_tree(), Rect2i());
+ if (is_embedded()) {
+ //viewport
+ Node *n = get_parent();
+ ERR_FAIL_COND_V(!n, Rect2i());
+ Viewport *p = n->get_viewport();
+ ERR_FAIL_COND_V(!p, Rect2i());
+
+ return p->get_visible_rect();
+ } else {
+ int x = get_position().x;
+ int closest_dist = 0x7FFFFFFF;
+ Rect2i closest_rect;
+ for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
+ Rect2i s(DisplayServer::get_singleton()->screen_get_position(i), DisplayServer::get_singleton()->screen_get_size(i));
+ int d;
+ if (x >= s.position.x && x < s.size.x) {
+ //contained
+ closest_rect = s;
+ break;
+ } else if (x < s.position.x) {
+ d = s.position.x - x;
+ } else {
+ d = x - (s.position.x + s.size.x);
+ }
+
+ if (d < closest_dist) {
+ closest_dist = d;
+ closest_rect = s;
+ }
+ }
+ return closest_rect;
+ }
+}
+
+void Window::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_title", "title"), &Window::set_title);
+ ClassDB::bind_method(D_METHOD("get_title"), &Window::get_title);
+
+ ClassDB::bind_method(D_METHOD("set_current_screen", "index"), &Window::set_current_screen);
+ ClassDB::bind_method(D_METHOD("get_current_screen"), &Window::get_current_screen);
+
+ ClassDB::bind_method(D_METHOD("set_position", "position"), &Window::set_position);
+ ClassDB::bind_method(D_METHOD("get_position"), &Window::get_position);
+
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &Window::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &Window::get_size);
+
+ ClassDB::bind_method(D_METHOD("get_real_size"), &Window::get_real_size);
+
+ ClassDB::bind_method(D_METHOD("set_max_size", "max_size"), &Window::set_max_size);
+ ClassDB::bind_method(D_METHOD("get_max_size"), &Window::get_max_size);
+
+ ClassDB::bind_method(D_METHOD("set_min_size", "min_size"), &Window::set_min_size);
+ ClassDB::bind_method(D_METHOD("get_min_size"), &Window::get_min_size);
+
+ ClassDB::bind_method(D_METHOD("set_mode", "mode"), &Window::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"), &Window::get_mode);
+
+ ClassDB::bind_method(D_METHOD("set_flag", "flag", "enabled"), &Window::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag", "flag"), &Window::get_flag);
+
+ ClassDB::bind_method(D_METHOD("is_maximize_allowed"), &Window::is_maximize_allowed);
+
+ ClassDB::bind_method(D_METHOD("request_attention"), &Window::request_attention);
+
+ ClassDB::bind_method(D_METHOD("move_to_foreground"), &Window::move_to_foreground);
+
+ ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Window::set_visible);
+ ClassDB::bind_method(D_METHOD("is_visible"), &Window::is_visible);
+
+ ClassDB::bind_method(D_METHOD("hide"), &Window::hide);
+ ClassDB::bind_method(D_METHOD("show"), &Window::show);
+
+ ClassDB::bind_method(D_METHOD("set_transient", "transient"), &Window::set_transient);
+ ClassDB::bind_method(D_METHOD("is_transient"), &Window::is_transient);
+
+ ClassDB::bind_method(D_METHOD("set_exclusive", "exclusive"), &Window::set_exclusive);
+ ClassDB::bind_method(D_METHOD("is_exclusive"), &Window::is_exclusive);
+
+ ClassDB::bind_method(D_METHOD("can_draw"), &Window::is_transient);
+ ClassDB::bind_method(D_METHOD("has_focus"), &Window::has_focus);
+ ClassDB::bind_method(D_METHOD("grab_focus"), &Window::grab_focus);
+
+ ClassDB::bind_method(D_METHOD("set_ime_active"), &Window::set_ime_active);
+ ClassDB::bind_method(D_METHOD("set_ime_position"), &Window::set_ime_position);
+
+ ClassDB::bind_method(D_METHOD("is_embedded"), &Window::is_embedded);
+
+ ClassDB::bind_method(D_METHOD("set_content_scale_size", "size"), &Window::set_content_scale_size);
+ ClassDB::bind_method(D_METHOD("get_content_scale_size"), &Window::get_content_scale_size);
+
+ ClassDB::bind_method(D_METHOD("set_content_scale_mode", "mode"), &Window::set_content_scale_mode);
+ ClassDB::bind_method(D_METHOD("get_content_scale_mode"), &Window::get_content_scale_mode);
+
+ ClassDB::bind_method(D_METHOD("set_content_scale_aspect", "aspect"), &Window::set_content_scale_aspect);
+ ClassDB::bind_method(D_METHOD("get_content_scale_aspect"), &Window::get_content_scale_aspect);
+
+ ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &Window::set_use_font_oversampling);
+ ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &Window::is_using_font_oversampling);
+
+ ClassDB::bind_method(D_METHOD("set_wrap_controls", "enable"), &Window::set_wrap_controls);
+ ClassDB::bind_method(D_METHOD("is_wrapping_controls"), &Window::is_wrapping_controls);
+ ClassDB::bind_method(D_METHOD("child_controls_changed"), &Window::child_controls_changed);
+
+ ClassDB::bind_method(D_METHOD("_update_child_controls"), &Window::_update_child_controls);
+
+ ClassDB::bind_method(D_METHOD("set_theme", "theme"), &Window::set_theme);
+ ClassDB::bind_method(D_METHOD("get_theme"), &Window::get_theme);
+
+ ClassDB::bind_method(D_METHOD("get_theme_icon", "name", "type"), &Window::get_theme_icon, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_stylebox", "name", "type"), &Window::get_theme_stylebox, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_font", "name", "type"), &Window::get_theme_font, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_color", "name", "type"), &Window::get_theme_color, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_theme_constant", "name", "type"), &Window::get_theme_constant, DEFVAL(""));
+
+ ClassDB::bind_method(D_METHOD("has_theme_icon", "name", "type"), &Window::has_theme_icon, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_stylebox", "name", "type"), &Window::has_theme_stylebox, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_font", "name", "type"), &Window::has_theme_font, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_color", "name", "type"), &Window::has_theme_color, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_theme_constant", "name", "type"), &Window::has_theme_constant, DEFVAL(""));
+
+ ClassDB::bind_method(D_METHOD("popup", "rect"), &Window::popup, DEFVAL(Rect2i()));
+ ClassDB::bind_method(D_METHOD("popup_on_parent", "parent_rect"), &Window::popup_on_parent);
+ ClassDB::bind_method(D_METHOD("popup_centered_ratio", "ratio"), &Window::popup_centered_ratio, DEFVAL(0.8));
+ ClassDB::bind_method(D_METHOD("popup_centered", "minsize"), &Window::popup_centered, DEFVAL(Size2i()));
+ ClassDB::bind_method(D_METHOD("popup_centered_clamped", "minsize", "fallback_ratio"), &Window::popup_centered_clamped, DEFVAL(Size2i()), DEFVAL(0.75));
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "position"), "set_position", "get_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "size"), "set_size", "get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,FullScreen"), "set_mode", "get_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_screen"), "set_current_screen", "get_current_screen");
+ ADD_GROUP("Flags", "");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transient"), "set_transient", "is_transient");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclusive"), "set_exclusive", "is_exclusive");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unresizable"), "set_flag", "get_flag", FLAG_RESIZE_DISABLED);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "borderless"), "set_flag", "get_flag", FLAG_BORDERLESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "always_on_top"), "set_flag", "get_flag", FLAG_ALWAYS_ON_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transparent"), "set_flag", "get_flag", FLAG_TRANSPARENT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unfocusable"), "set_flag", "get_flag", FLAG_NO_FOCUS);
+ ADD_GROUP("Limits", "");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "min_size"), "set_min_size", "get_min_size");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "max_size"), "set_max_size", "get_max_size");
+ ADD_GROUP("Content Scale", "content_scale_");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "content_scale_size"), "set_content_scale_size", "get_content_scale_size");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_mode", PROPERTY_HINT_ENUM, "Disabled,Object,Pixels"), "set_content_scale_mode", "get_content_scale_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_aspect", PROPERTY_HINT_ENUM, "Ignore,Keep,KeepWidth,KeepHeight,Expand"), "set_content_scale_aspect", "get_content_scale_aspect");
+ ADD_GROUP("Theme", "");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
+
+ ADD_SIGNAL(MethodInfo("window_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
+ ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files")));
+ ADD_SIGNAL(MethodInfo("mouse_entered"));
+ ADD_SIGNAL(MethodInfo("mouse_exited"));
+ ADD_SIGNAL(MethodInfo("focus_entered"));
+ ADD_SIGNAL(MethodInfo("focus_exited"));
+ ADD_SIGNAL(MethodInfo("close_requested"));
+ ADD_SIGNAL(MethodInfo("go_back_requested"));
+ ADD_SIGNAL(MethodInfo("visibility_changed"));
+ ADD_SIGNAL(MethodInfo("about_to_popup"));
+
+ BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
+
+ BIND_ENUM_CONSTANT(MODE_WINDOWED);
+ BIND_ENUM_CONSTANT(MODE_MINIMIZED);
+ BIND_ENUM_CONSTANT(MODE_MAXIMIZED);
+ BIND_ENUM_CONSTANT(MODE_FULLSCREEN);
+
+ BIND_ENUM_CONSTANT(FLAG_RESIZE_DISABLED);
+ BIND_ENUM_CONSTANT(FLAG_BORDERLESS);
+ BIND_ENUM_CONSTANT(FLAG_ALWAYS_ON_TOP);
+ BIND_ENUM_CONSTANT(FLAG_TRANSPARENT);
+ BIND_ENUM_CONSTANT(FLAG_NO_FOCUS);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
+
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_OBJECTS);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_MODE_PIXELS);
+
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_IGNORE);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_KEEP);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_KEEP_WIDTH);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_KEEP_HEIGHT);
+ BIND_ENUM_CONSTANT(CONTENT_SCALE_ASPECT_EXPAND);
+}
+
+Window::Window() {
+ for (int i = 0; i < FLAG_MAX; i++) {
+ flags[i] = false;
+ }
+ content_scale_mode = CONTENT_SCALE_MODE_DISABLED;
+ content_scale_aspect = CONTENT_SCALE_ASPECT_IGNORE;
+ RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
+}
+Window::~Window() {
+}
diff --git a/scene/main/window.h b/scene/main/window.h
new file mode 100644
index 0000000000..be07762f20
--- /dev/null
+++ b/scene/main/window.h
@@ -0,0 +1,266 @@
+/*************************************************************************/
+/* window.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include "scene/main/viewport.h"
+#include "scene/resources/theme.h"
+#include "servers/display_server.h"
+
+class Control;
+class Window : public Viewport {
+ GDCLASS(Window, Viewport)
+public:
+ enum Mode {
+ MODE_WINDOWED = DisplayServer::WINDOW_MODE_WINDOWED,
+ MODE_MINIMIZED = DisplayServer::WINDOW_MODE_MINIMIZED,
+ MODE_MAXIMIZED = DisplayServer::WINDOW_MODE_MAXIMIZED,
+ MODE_FULLSCREEN = DisplayServer::WINDOW_MODE_FULLSCREEN
+ };
+
+ enum Flags {
+ FLAG_RESIZE_DISABLED = DisplayServer::WINDOW_FLAG_RESIZE_DISABLED,
+ FLAG_BORDERLESS = DisplayServer::WINDOW_FLAG_BORDERLESS,
+ FLAG_ALWAYS_ON_TOP = DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP,
+ FLAG_TRANSPARENT = DisplayServer::WINDOW_FLAG_TRANSPARENT,
+ FLAG_NO_FOCUS = DisplayServer::WINDOW_FLAG_NO_FOCUS,
+ FLAG_MAX = DisplayServer::WINDOW_FLAG_MAX,
+ };
+
+ enum ContentScaleMode {
+ CONTENT_SCALE_MODE_DISABLED,
+ CONTENT_SCALE_MODE_OBJECTS,
+ CONTENT_SCALE_MODE_PIXELS,
+
+ };
+
+ enum ContentScaleAspect {
+ CONTENT_SCALE_ASPECT_IGNORE,
+ CONTENT_SCALE_ASPECT_KEEP,
+ CONTENT_SCALE_ASPECT_KEEP_WIDTH,
+ CONTENT_SCALE_ASPECT_KEEP_HEIGHT,
+ CONTENT_SCALE_ASPECT_EXPAND,
+
+ };
+ enum {
+ DEFAULT_WINDOW_SIZE = 100
+ };
+
+private:
+ DisplayServer::WindowID window_id = DisplayServer::INVALID_WINDOW_ID;
+
+ String title;
+ mutable int current_screen = 0;
+ mutable Vector2i position;
+ mutable Size2i size = Size2i(DEFAULT_WINDOW_SIZE, DEFAULT_WINDOW_SIZE);
+ mutable Size2i min_size;
+ mutable Size2i max_size;
+ mutable Mode mode = MODE_WINDOWED;
+ mutable bool flags[FLAG_MAX];
+ bool visible = true;
+ bool focused = false;
+
+ bool use_font_oversampling = false;
+ bool transient = false;
+ bool exclusive = false;
+ bool wrap_controls = false;
+ bool updating_child_controls = false;
+
+ void _update_child_controls();
+
+ Size2i content_scale_size;
+ ContentScaleMode content_scale_mode;
+ ContentScaleAspect content_scale_aspect;
+
+ void _make_window();
+ void _clear_window();
+ void _update_from_window();
+
+ void _update_viewport_size();
+ void _update_window_size();
+
+ void _propagate_window_notification(Node *p_node, int p_notification);
+
+ void _update_window_callbacks();
+
+ void _clear_transient();
+ void _make_transient();
+ Window *transient_parent = nullptr;
+ Window *exclusive_child = nullptr;
+ Set<Window *> transient_children;
+
+ friend class Control;
+ Ref<Theme> theme;
+ Control *theme_owner = nullptr;
+ Window *theme_owner_window = nullptr;
+
+ Viewport *embedder = nullptr;
+
+ friend class Viewport; //friend back, can call the methods below
+
+ void _window_input(const Ref<InputEvent> &p_ev);
+ void _window_input_text(const String &p_text);
+ void _window_drop_files(const Vector<String> &p_files);
+ void _rect_changed_callback(const Rect2i &p_callback);
+ void _event_callback(DisplayServer::WindowEvent p_event);
+
+protected:
+ Viewport *_get_embedder() const;
+
+ virtual Rect2i _popup_adjust_rect() const { return Rect2i(); }
+
+ virtual void _post_popup() {}
+ virtual Size2 _get_contents_minimum_size() const;
+ static void _bind_methods();
+ void _notification(int p_what);
+
+ virtual void add_child_notify(Node *p_child);
+ virtual void remove_child_notify(Node *p_child);
+
+public:
+ enum {
+
+ NOTIFICATION_VISIBILITY_CHANGED = 30,
+ NOTIFICATION_POST_POPUP = 31,
+ NOTIFICATION_THEME_CHANGED = 32,
+ };
+
+ void set_title(const String &p_title);
+ String get_title() const;
+
+ void set_current_screen(int p_screen);
+ int get_current_screen() const;
+
+ void set_position(const Point2i &p_position);
+ Point2i get_position() const;
+
+ void set_size(const Size2i &p_size);
+ Size2i get_size() const;
+
+ Size2i get_real_size() const;
+
+ void set_max_size(const Size2i &p_max_size);
+ Size2i get_max_size() const;
+
+ void set_min_size(const Size2i &p_min_size);
+ Size2i get_min_size() const;
+
+ void set_mode(Mode p_mode);
+ Mode get_mode() const;
+
+ void set_flag(Flags p_flag, bool p_enabled);
+ bool get_flag(Flags p_flag) const;
+
+ bool is_maximize_allowed() const;
+
+ void request_attention();
+ void move_to_foreground();
+
+ void set_visible(bool p_visible);
+ bool is_visible() const;
+
+ void show();
+ void hide();
+
+ void set_transient(bool p_transient);
+ bool is_transient() const;
+
+ void set_exclusive(bool p_exclusive);
+ bool is_exclusive() const;
+
+ bool can_draw() const;
+
+ void set_ime_active(bool p_active);
+ void set_ime_position(const Point2i &p_pos);
+
+ bool is_embedded() const;
+
+ void set_content_scale_size(const Size2i &p_size);
+ Size2i get_content_scale_size() const;
+
+ void set_content_scale_mode(ContentScaleMode p_mode);
+ ContentScaleMode get_content_scale_mode() const;
+
+ void set_content_scale_aspect(ContentScaleAspect p_aspect);
+ ContentScaleAspect get_content_scale_aspect() const;
+
+ void set_use_font_oversampling(bool p_oversampling);
+ bool is_using_font_oversampling() const;
+
+ void set_wrap_controls(bool p_enable);
+ bool is_wrapping_controls() const;
+ void child_controls_changed();
+
+ Window *get_parent_visible_window() const;
+ Viewport *get_parent_viewport() const;
+ void popup(const Rect2i &p_rect = Rect2i());
+ void popup_on_parent(const Rect2i &p_parent_rect);
+ void popup_centered_ratio(float p_ratio = 0.8);
+ void popup_centered(const Size2i &p_minsize = Size2i());
+ void popup_centered_clamped(const Size2i &p_size = Size2i(), float p_fallback_ratio = 0.75);
+
+ void set_theme(const Ref<Theme> &p_theme);
+ Ref<Theme> get_theme() const;
+
+ Size2 get_contents_minimum_size() const;
+
+ void grab_focus();
+ bool has_focus() const;
+
+ Rect2i get_usable_parent_rect() const;
+
+ Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<Shader> get_theme_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<StyleBox> get_theme_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<Font> get_theme_font(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Color get_theme_color(const StringName &p_name, const StringName &p_type = StringName()) const;
+ int get_theme_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
+
+ bool has_theme_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_font(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_color(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_theme_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
+
+ Rect2i get_parent_rect() const;
+ virtual DisplayServer::WindowID get_window_id() const;
+
+ Window();
+ ~Window();
+};
+
+VARIANT_ENUM_CAST(Window::Window::Mode);
+VARIANT_ENUM_CAST(Window::Window::Flags);
+VARIANT_ENUM_CAST(Window::ContentScaleMode);
+VARIANT_ENUM_CAST(Window::ContentScaleAspect);
+
+#endif // WINDOW_H
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index f15911b0e2..774d943efe 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -33,16 +33,16 @@
#include "core/class_db.h"
#include "core/os/os.h"
#include "core/project_settings.h"
-#include "scene/2d/animated_sprite.h"
+#include "scene/2d/animated_sprite_2d.h"
#include "scene/2d/area_2d.h"
#include "scene/2d/audio_stream_player_2d.h"
#include "scene/2d/back_buffer_copy.h"
#include "scene/2d/camera_2d.h"
-#include "scene/2d/canvas_item.h"
#include "scene/2d/canvas_modulate.h"
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/collision_shape_2d.h"
#include "scene/2d/cpu_particles_2d.h"
+#include "scene/2d/gpu_particles_2d.h"
#include "scene/2d/joints_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/light_occluder_2d.h"
@@ -54,7 +54,6 @@
#include "scene/2d/navigation_obstacle_2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
-#include "scene/2d/particles_2d.h"
#include "scene/2d/path_2d.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/2d/polygon_2d.h"
@@ -62,7 +61,7 @@
#include "scene/2d/ray_cast_2d.h"
#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/skeleton_2d.h"
-#include "scene/2d/sprite.h"
+#include "scene/2d/sprite_2d.h"
#include "scene/2d/tile_map.h"
#include "scene/2d/touch_screen_button.h"
#include "scene/2d/visibility_notifier_2d.h"
@@ -121,6 +120,7 @@
#include "scene/gui/tree.h"
#include "scene/gui/video_player.h"
#include "scene/gui/viewport_container.h"
+#include "scene/main/canvas_item.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/http_request.h"
#include "scene/main/instance_placeholder.h"
@@ -128,21 +128,22 @@
#include "scene/main/scene_tree.h"
#include "scene/main/timer.h"
#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "scene/resources/audio_stream_sample.h"
#include "scene/resources/bit_map.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
+#include "scene/resources/box_shape_3d.h"
#include "scene/resources/capsule_shape_2d.h"
+#include "scene/resources/capsule_shape_3d.h"
#include "scene/resources/circle_shape_2d.h"
-#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/concave_polygon_shape_2d.h"
-#include "scene/resources/convex_polygon_shape.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
-#include "scene/resources/cylinder_shape.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/cylinder_shape_3d.h"
#include "scene/resources/default_theme/default_theme.h"
#include "scene/resources/dynamic_font.h"
#include "scene/resources/gradient.h"
-#include "scene/resources/height_map_shape.h"
+#include "scene/resources/height_map_shape_3d.h"
#include "scene/resources/line_shape_2d.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
@@ -153,13 +154,13 @@
#include "scene/resources/physics_material.h"
#include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h"
-#include "scene/resources/ray_shape.h"
+#include "scene/resources/ray_shape_3d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/resource_format_text.h"
#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/sky.h"
#include "scene/resources/sky_material.h"
-#include "scene/resources/sphere_shape.h"
+#include "scene/resources/sphere_shape_3d.h"
#include "scene/resources/surface_tool.h"
#include "scene/resources/text_file.h"
#include "scene/resources/texture.h"
@@ -167,50 +168,51 @@
#include "scene/resources/video_stream.h"
#include "scene/resources/visual_shader.h"
#include "scene/resources/visual_shader_nodes.h"
-#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-#include "scene/resources/world_margin_shape.h"
+#include "scene/resources/world_3d.h"
+#include "scene/resources/world_margin_shape_3d.h"
#include "scene/scene_string_names.h"
+// Needed by animation code, so keep when 3D disabled.
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
+
#ifndef _3D_DISABLED
-#include "scene/3d/area.h"
+#include "scene/3d/area_3d.h"
#include "scene/3d/arvr_nodes.h"
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/baked_lightmap.h"
-#include "scene/3d/bone_attachment.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/collision_polygon.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/cpu_particles.h"
+#include "scene/3d/bone_attachment_3d.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/collision_polygon_3d.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/cpu_particles_3d.h"
#include "scene/3d/gi_probe.h"
-#include "scene/3d/immediate_geometry.h"
-#include "scene/3d/interpolated_camera.h"
-#include "scene/3d/light.h"
-#include "scene/3d/listener.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/multimesh_instance.h"
-#include "scene/3d/navigation.h"
-#include "scene/3d/navigation_agent.h"
-#include "scene/3d/navigation_obstacle.h"
-#include "scene/3d/navigation_region.h"
-#include "scene/3d/particles.h"
-#include "scene/3d/path.h"
-#include "scene/3d/physics_body.h"
-#include "scene/3d/physics_joint.h"
+#include "scene/3d/gpu_particles_3d.h"
+#include "scene/3d/immediate_geometry_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/listener_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/multimesh_instance_3d.h"
+#include "scene/3d/navigation_3d.h"
+#include "scene/3d/navigation_agent_3d.h"
+#include "scene/3d/navigation_obstacle_3d.h"
+#include "scene/3d/navigation_region_3d.h"
+#include "scene/3d/path_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/3d/physics_joint_3d.h"
#include "scene/3d/position_3d.h"
-#include "scene/3d/proximity_group.h"
-#include "scene/3d/ray_cast.h"
+#include "scene/3d/proximity_group_3d.h"
+#include "scene/3d/ray_cast_3d.h"
#include "scene/3d/reflection_probe.h"
-#include "scene/3d/remote_transform.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/soft_body.h"
-#include "scene/3d/spatial.h"
-#include "scene/3d/spring_arm.h"
+#include "scene/3d/remote_transform_3d.h"
+#include "scene/3d/skeleton_ik_3d.h"
+#include "scene/3d/soft_body_3d.h"
+#include "scene/3d/spring_arm_3d.h"
#include "scene/3d/sprite_3d.h"
-#include "scene/3d/vehicle_body.h"
-#include "scene/3d/visibility_notifier.h"
+#include "scene/3d/vehicle_body_3d.h"
+#include "scene/3d/visibility_notifier_3d.h"
#include "scene/3d/world_environment.h"
-#include "scene/animation/skeleton_ik.h"
#include "scene/resources/environment.h"
#include "scene/resources/mesh_library.h"
#endif
@@ -267,15 +269,17 @@ void register_scene_types() {
ClassDB::register_class<Node>();
ClassDB::register_virtual_class<InstancePlaceholder>();
- ClassDB::register_class<Viewport>();
+ ClassDB::register_virtual_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>();
+ ClassDB::register_class<Window>();
/* REGISTER GUI */
+
ClassDB::register_class<ButtonGroup>();
ClassDB::register_virtual_class<BaseButton>();
@@ -332,7 +336,6 @@ void register_scene_types() {
ClassDB::register_class<VideoPlayer>();
#ifndef ADVANCED_GUI_DISABLED
-
ClassDB::register_class<FileDialog>();
ClassDB::register_class<PopupMenu>();
@@ -348,10 +351,10 @@ void register_scene_types() {
ClassDB::register_class<RichTextLabel>();
ClassDB::register_class<RichTextEffect>();
ClassDB::register_class<CharFXTransform>();
- ClassDB::register_class<PopupDialog>();
- ClassDB::register_class<WindowDialog>();
+
ClassDB::register_class<AcceptDialog>();
ClassDB::register_class<ConfirmationDialog>();
+
ClassDB::register_class<MarginContainer>();
ClassDB::register_class<ViewportContainer>();
ClassDB::register_virtual_class<SplitContainer>();
@@ -362,16 +365,18 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
+ AcceptDialog::set_swap_ok_cancel(GLOBAL_DEF("gui/common/swap_ok_cancel", bool(DisplayServer::get_singleton()->get_swap_ok_cancel())));
#endif
/* REGISTER 3D */
+ // Needed even with _3D_DISABLED as used in animation code.
+ ClassDB::register_class<Node3D>();
+ ClassDB::register_virtual_class<Node3DGizmo>();
ClassDB::register_class<Skin>();
ClassDB::register_virtual_class<SkinReference>();
+ ClassDB::register_class<Skeleton3D>();
- ClassDB::register_class<Spatial>();
- ClassDB::register_virtual_class<SpatialGizmo>();
- ClassDB::register_class<Skeleton>();
ClassDB::register_class<AnimationPlayer>();
ClassDB::register_class<Tween>();
@@ -399,32 +404,31 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
#ifndef _3D_DISABLED
- ClassDB::register_virtual_class<VisualInstance>();
- ClassDB::register_virtual_class<GeometryInstance>();
- ClassDB::register_class<Camera>();
- ClassDB::register_class<ClippedCamera>();
- ClassDB::register_class<Listener>();
+ ClassDB::register_virtual_class<VisualInstance3D>();
+ ClassDB::register_virtual_class<GeometryInstance3D>();
+ ClassDB::register_class<Camera3D>();
+ ClassDB::register_class<ClippedCamera3D>();
+ ClassDB::register_class<Listener3D>();
ClassDB::register_class<ARVRCamera>();
ClassDB::register_class<ARVRController>();
ClassDB::register_class<ARVRAnchor>();
ClassDB::register_class<ARVROrigin>();
- ClassDB::register_class<InterpolatedCamera>();
- ClassDB::register_class<MeshInstance>();
- ClassDB::register_class<ImmediateGeometry>();
+ ClassDB::register_class<MeshInstance3D>();
+ ClassDB::register_class<ImmediateGeometry3D>();
ClassDB::register_virtual_class<SpriteBase3D>();
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_virtual_class<Light3D>();
+ ClassDB::register_class<DirectionalLight3D>();
+ ClassDB::register_class<OmniLight3D>();
+ ClassDB::register_class<SpotLight3D>();
ClassDB::register_class<ReflectionProbe>();
ClassDB::register_class<GIProbe>();
ClassDB::register_class<GIProbeData>();
//ClassDB::register_class<BakedLightmap>();
//ClassDB::register_class<BakedLightmapData>();
- ClassDB::register_class<Particles>();
- ClassDB::register_class<CPUParticles>();
+ ClassDB::register_class<GPUParticles3D>();
+ ClassDB::register_class<CPUParticles3D>();
ClassDB::register_class<Position3D>();
ClassDB::register_class<RootMotionView>();
@@ -432,55 +436,53 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- ClassDB::register_virtual_class<CollisionObject>();
- ClassDB::register_virtual_class<PhysicsBody>();
- ClassDB::register_class<StaticBody>();
- ClassDB::register_class<RigidBody>();
- ClassDB::register_class<KinematicCollision>();
- ClassDB::register_class<KinematicBody>();
- ClassDB::register_class<SpringArm>();
-
- ClassDB::register_class<PhysicalBone>();
- ClassDB::register_class<SoftBody>();
-
- ClassDB::register_class<SkeletonIK>();
- ClassDB::register_class<BoneAttachment>();
-
- 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_virtual_class<CollisionObject3D>();
+ ClassDB::register_virtual_class<PhysicsBody3D>();
+ ClassDB::register_class<StaticBody3D>();
+ ClassDB::register_class<RigidBody3D>();
+ ClassDB::register_class<KinematicCollision3D>();
+ ClassDB::register_class<KinematicBody3D>();
+ ClassDB::register_class<SpringArm3D>();
+
+ ClassDB::register_class<PhysicalBone3D>();
+ ClassDB::register_class<SoftBody3D>();
+
+ ClassDB::register_class<SkeletonIK3D>();
+ ClassDB::register_class<BoneAttachment3D>();
+
+ ClassDB::register_class<VehicleBody3D>();
+ ClassDB::register_class<VehicleWheel3D>();
+ ClassDB::register_class<Area3D>();
+ ClassDB::register_class<ProximityGroup3D>();
+ ClassDB::register_class<CollisionShape3D>();
+ ClassDB::register_class<CollisionPolygon3D>();
+ ClassDB::register_class<RayCast3D>();
+ ClassDB::register_class<MultiMeshInstance3D>();
ClassDB::register_class<Curve3D>();
- ClassDB::register_class<Path>();
- ClassDB::register_class<PathFollow>();
- ClassDB::register_class<VisibilityNotifier>();
- ClassDB::register_class<VisibilityEnabler>();
+ ClassDB::register_class<Path3D>();
+ ClassDB::register_class<PathFollow3D>();
+ ClassDB::register_class<VisibilityNotifier3D>();
+ ClassDB::register_class<VisibilityEnabler3D>();
ClassDB::register_class<WorldEnvironment>();
- ClassDB::register_class<RemoteTransform>();
+ ClassDB::register_class<RemoteTransform3D>();
- 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>();
+ ClassDB::register_virtual_class<Joint3D>();
+ ClassDB::register_class<PinJoint3D>();
+ ClassDB::register_class<HingeJoint3D>();
+ ClassDB::register_class<SliderJoint3D>();
+ ClassDB::register_class<ConeTwistJoint3D>();
+ ClassDB::register_class<Generic6DOFJoint3D>();
- ClassDB::register_class<Navigation>();
- ClassDB::register_class<NavigationRegion>();
- ClassDB::register_class<NavigationAgent>();
- ClassDB::register_class<NavigationObstacle>();
+ ClassDB::register_class<Navigation3D>();
+ ClassDB::register_class<NavigationRegion3D>();
+ ClassDB::register_class<NavigationAgent3D>();
+ ClassDB::register_class<NavigationObstacle3D>();
OS::get_singleton()->yield(); //may take time to init
-
#endif
- ClassDB::register_class<NavigationMesh>();
- AcceptDialog::set_swap_ok_cancel(GLOBAL_DEF("gui/common/swap_ok_cancel", bool(OS::get_singleton()->get_swap_ok_cancel())));
+ /* REGISTER SHADER */
ClassDB::register_class<Shader>();
ClassDB::register_class<VisualShader>();
@@ -554,14 +556,15 @@ void register_scene_types() {
ClassDB::register_class<CanvasItemMaterial>();
SceneTree::add_idle_callback(CanvasItemMaterial::flush_changes);
CanvasItemMaterial::init_shaders();
+
+ /* REGISTER 2D */
+
ClassDB::register_class<Node2D>();
ClassDB::register_class<CPUParticles2D>();
- ClassDB::register_class<Particles2D>();
- //ClassDB::register_class<ParticleAttractor2D>();
- ClassDB::register_class<Sprite>();
- //ClassDB::register_type<ViewportSprite>();
+ ClassDB::register_class<GPUParticles2D>();
+ ClassDB::register_class<Sprite2D>();
ClassDB::register_class<SpriteFrames>();
- ClassDB::register_class<AnimatedSprite>();
+ ClassDB::register_class<AnimatedSprite2D>();
ClassDB::register_class<Position2D>();
ClassDB::register_class<Line2D>();
ClassDB::register_class<MeshInstance2D>();
@@ -641,24 +644,24 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- ClassDB::register_virtual_class<Shape>();
- ClassDB::register_class<RayShape>();
- ClassDB::register_class<SphereShape>();
- ClassDB::register_class<BoxShape>();
- ClassDB::register_class<CapsuleShape>();
- ClassDB::register_class<CylinderShape>();
- ClassDB::register_class<HeightMapShape>();
- ClassDB::register_class<WorldMarginShape>();
- ClassDB::register_class<ConvexPolygonShape>();
- ClassDB::register_class<ConcavePolygonShape>();
+ ClassDB::register_virtual_class<Shape3D>();
+ ClassDB::register_class<RayShape3D>();
+ ClassDB::register_class<SphereShape3D>();
+ ClassDB::register_class<BoxShape3D>();
+ ClassDB::register_class<CapsuleShape3D>();
+ ClassDB::register_class<CylinderShape3D>();
+ ClassDB::register_class<HeightMapShape3D>();
+ ClassDB::register_class<WorldMarginShape3D>();
+ ClassDB::register_class<ConvexPolygonShape3D>();
+ ClassDB::register_class<ConcavePolygonShape3D>();
OS::get_singleton()->yield(); //may take time to init
- ClassDB::register_class<SpatialVelocityTracker>();
-
+ ClassDB::register_class<VelocityTracker3D>();
#endif
+
ClassDB::register_class<PhysicsMaterial>();
- ClassDB::register_class<World>();
+ ClassDB::register_class<World3D>();
ClassDB::register_class<Environment>();
ClassDB::register_class<CameraEffects>();
ClassDB::register_class<World2D>();
@@ -727,6 +730,7 @@ void register_scene_types() {
ClassDB::register_class<Path2D>();
ClassDB::register_class<PathFollow2D>();
+ ClassDB::register_class<NavigationMesh>();
ClassDB::register_class<Navigation2D>();
ClassDB::register_class<NavigationPolygon>();
ClassDB::register_class<NavigationRegion2D>();
@@ -742,16 +746,93 @@ void register_scene_types() {
ClassDB::register_virtual_class<SceneTreeTimer>(); //sorry, you can't create it
#ifndef DISABLE_DEPRECATED
- ClassDB::add_compatibility_class("SpatialMaterial", "StandardMaterial3D");
- ClassDB::add_compatibility_class("Mesh", "ArrayMesh");
+ // Dropped in 4.0, near approximation.
ClassDB::add_compatibility_class("AnimationTreePlayer", "AnimationTree");
+
+ // Renamed in 4.0.
+ ClassDB::add_compatibility_class("AnimatedSprite", "AnimatedSprite2D");
+ ClassDB::add_compatibility_class("Area", "Area3D");
+ ClassDB::add_compatibility_class("BoneAttachment", "BoneAttachment3D");
+ ClassDB::add_compatibility_class("BoxShape", "BoxShape3D");
+ ClassDB::add_compatibility_class("Camera", "Camera3D");
+ ClassDB::add_compatibility_class("CapsuleShape", "CapsuleShape3D");
+ ClassDB::add_compatibility_class("ClippedCamera", "ClippedCamera3D");
+ ClassDB::add_compatibility_class("CollisionObject", "CollisionObject3D");
+ ClassDB::add_compatibility_class("CollisionPolygon", "CollisionPolygon3D");
+ ClassDB::add_compatibility_class("CollisionShape", "CollisionShape3D");
+ ClassDB::add_compatibility_class("ConcavePolygonShape", "ConcavePolygonShape3D");
+ ClassDB::add_compatibility_class("ConeTwistJoint", "ConeTwistJoint3D");
+ ClassDB::add_compatibility_class("ConvexPolygonShape", "ConvexPolygonShape3D");
+ ClassDB::add_compatibility_class("CPUParticles", "CPUParticles3D");
+ ClassDB::add_compatibility_class("CylinderShape", "CylinderShape3D");
+ ClassDB::add_compatibility_class("DirectionalLight", "DirectionalLight3D");
+ ClassDB::add_compatibility_class("Generic6DOFJoint", "Generic6DOFJoint3D");
+ ClassDB::add_compatibility_class("HeightMapShape", "HeightMapShape3D");
+ ClassDB::add_compatibility_class("HingeJoint", "HingeJoint3D");
+ ClassDB::add_compatibility_class("ImmediateGeometry", "ImmediateGeometry3D");
+ ClassDB::add_compatibility_class("Joint", "Joint3D");
+ ClassDB::add_compatibility_class("KinematicBody", "KinematicBody3D");
+ ClassDB::add_compatibility_class("KinematicCollision", "KinematicCollision3D");
+ ClassDB::add_compatibility_class("Light", "Light3D");
+ ClassDB::add_compatibility_class("Listener", "Listener3D");
+ ClassDB::add_compatibility_class("MeshInstance", "MeshInstance3D");
+ ClassDB::add_compatibility_class("MultiMeshInstance", "MultiMeshInstance3D");
+ ClassDB::add_compatibility_class("Navigation", "Navigation3D");
+ ClassDB::add_compatibility_class("NavigationAgent", "NavigationAgent3D");
+ ClassDB::add_compatibility_class("NavigationMeshInstance", "NavigationRegion3D");
+ ClassDB::add_compatibility_class("NavigationObstacle", "NavigationObstacle3D");
+ ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D");
+ ClassDB::add_compatibility_class("NavigationRegion", "NavigationRegion3D");
+ ClassDB::add_compatibility_class("OmniLight", "OmniLight3D");
+ ClassDB::add_compatibility_class("Particles", "GPUParticles3D");
+ ClassDB::add_compatibility_class("Particles2D", "GPUParticles2D");
+ ClassDB::add_compatibility_class("Path", "Path3D");
+ ClassDB::add_compatibility_class("PathFollow", "PathFollow3D");
+ ClassDB::add_compatibility_class("PhysicalBone", "PhysicalBone3D");
+ ClassDB::add_compatibility_class("Physics2DDirectBodyStateSW", "PhysicsDirectBodyState2DSW");
+ ClassDB::add_compatibility_class("Physics2DDirectBodyState", "PhysicsDirectBodyState2D");
+ ClassDB::add_compatibility_class("Physics2DDirectSpaceState", "PhysicsDirectSpaceState2D");
+ ClassDB::add_compatibility_class("Physics2DServerSW", "PhysicsServer2DSW");
+ ClassDB::add_compatibility_class("Physics2DServer", "PhysicsServer2D");
+ ClassDB::add_compatibility_class("Physics2DShapeQueryParameters", "PhysicsShapeQueryParameters2D");
+ ClassDB::add_compatibility_class("Physics2DShapeQueryResult", "PhysicsShapeQueryResult2D");
+ ClassDB::add_compatibility_class("Physics2DTestMotionResult", "PhysicsTestMotionResult2D");
+ ClassDB::add_compatibility_class("PhysicsBody", "PhysicsBody3D");
+ ClassDB::add_compatibility_class("PhysicsDirectBodyState", "PhysicsDirectBodyState3D");
+ ClassDB::add_compatibility_class("PhysicsDirectSpaceState", "PhysicsDirectSpaceState3D");
+ ClassDB::add_compatibility_class("PhysicsServer", "PhysicsServer3D");
+ ClassDB::add_compatibility_class("PhysicsShapeQueryParameters", "PhysicsShapeQueryParameters3D");
+ ClassDB::add_compatibility_class("PhysicsShapeQueryResult", "PhysicsShapeQueryResult3D");
+ ClassDB::add_compatibility_class("PinJoint", "PinJoint3D");
+ ClassDB::add_compatibility_class("PlaneShape", "WorldMarginShape3D");
+ ClassDB::add_compatibility_class("ProximityGroup", "ProximityGroup3D");
+ ClassDB::add_compatibility_class("RayCast", "RayCast3D");
+ ClassDB::add_compatibility_class("RayShape", "RayShape3D");
+ ClassDB::add_compatibility_class("RemoteTransform", "RemoteTransform3D");
+ ClassDB::add_compatibility_class("RigidBody", "RigidBody3D");
+ ClassDB::add_compatibility_class("Shape", "Shape3D");
+ ClassDB::add_compatibility_class("Skeleton", "Skeleton3D");
+ ClassDB::add_compatibility_class("SkeletonIK", "SkeletonIK3D");
+ ClassDB::add_compatibility_class("SliderJoint", "SliderJoint3D");
+ ClassDB::add_compatibility_class("SoftBody", "SoftBody3D");
+ ClassDB::add_compatibility_class("Spatial", "Node3D");
+ ClassDB::add_compatibility_class("SpatialMaterial", "StandardMaterial3D");
+ ClassDB::add_compatibility_class("SpatialVelocityTracker", "VelocityTracker3D");
+ ClassDB::add_compatibility_class("SphereShape", "SphereShape3D");
+ ClassDB::add_compatibility_class("SpotLight", "SpotLight3D");
+ ClassDB::add_compatibility_class("SpringArm", "SpringArm3D");
+ ClassDB::add_compatibility_class("Sprite", "Sprite2D");
+ ClassDB::add_compatibility_class("StaticBody", "StaticBody3D");
+ ClassDB::add_compatibility_class("VehicleBody", "VehicleBody3D");
+ ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D");
+ ClassDB::add_compatibility_class("VisibilityEnabler", "VisibilityEnabler3D");
+ ClassDB::add_compatibility_class("VisibilityNotifier", "VisibilityNotifier3D");
+ ClassDB::add_compatibility_class("VisualServer", "RenderingServer");
ClassDB::add_compatibility_class("VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant");
- ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform");
- ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp");
ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc");
- ClassDB::add_compatibility_class("NavigationMeshInstance", "NavigationRegion");
- ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D");
- ClassDB::add_compatibility_class("PlaneShape", "WorldMarginShape");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp");
+ ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform");
+ ClassDB::add_compatibility_class("World", "World3D");
#endif
OS::get_singleton()->yield(); //may take time to init
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index a68b750b31..06b65e4b4a 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -481,7 +481,7 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) {
AudioServer::get_singleton()->lock();
if (data) {
- AudioServer::get_singleton()->audio_data_free(data);
+ memfree(data);
data = NULL;
data_bytes = 0;
}
@@ -491,7 +491,7 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) {
const uint8_t *r = p_data.ptr();
int alloc_len = datalen + DATA_PAD * 2;
- data = AudioServer::get_singleton()->audio_data_alloc(alloc_len); //alloc with some padding for interpolation
+ data = memalloc(alloc_len); //alloc with some padding for interpolation
zeromem(data, alloc_len);
uint8_t *dataptr = (uint8_t *)data;
copymem(dataptr + DATA_PAD, r, datalen);
@@ -660,7 +660,7 @@ AudioStreamSample::AudioStreamSample() {
AudioStreamSample::~AudioStreamSample() {
if (data) {
- AudioServer::get_singleton()->audio_data_free(data);
+ memfree(data);
data = NULL;
data_bytes = 0;
}
diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape_3d.cpp
index e1f485bae6..64c821a011 100644
--- a/scene/resources/box_shape.cpp
+++ b/scene/resources/box_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* box_shape.cpp */
+/* box_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "box_shape.h"
-#include "servers/physics_server.h"
+#include "box_shape_3d.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> BoxShape::get_debug_mesh_lines() {
+Vector<Vector3> BoxShape3D::get_debug_mesh_lines() {
Vector<Vector3> lines;
AABB aabb;
@@ -48,17 +48,17 @@ Vector<Vector3> BoxShape::get_debug_mesh_lines() {
return lines;
}
-real_t BoxShape::get_enclosing_radius() const {
+real_t BoxShape3D::get_enclosing_radius() const {
return extents.length();
}
-void BoxShape::_update_shape() {
+void BoxShape3D::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), extents);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), extents);
+ Shape3D::_update_shape();
}
-void BoxShape::set_extents(const Vector3 &p_extents) {
+void BoxShape3D::set_extents(const Vector3 &p_extents) {
extents = p_extents;
_update_shape();
@@ -66,21 +66,21 @@ void BoxShape::set_extents(const Vector3 &p_extents) {
_change_notify("extents");
}
-Vector3 BoxShape::get_extents() const {
+Vector3 BoxShape3D::get_extents() const {
return extents;
}
-void BoxShape::_bind_methods() {
+void BoxShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_extents", "extents"), &BoxShape::set_extents);
- ClassDB::bind_method(D_METHOD("get_extents"), &BoxShape::get_extents);
+ ClassDB::bind_method(D_METHOD("set_extents", "extents"), &BoxShape3D::set_extents);
+ ClassDB::bind_method(D_METHOD("get_extents"), &BoxShape3D::get_extents);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents");
}
-BoxShape::BoxShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX)) {
+BoxShape3D::BoxShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_BOX)) {
set_extents(Vector3(1, 1, 1));
}
diff --git a/scene/resources/box_shape.h b/scene/resources/box_shape_3d.h
index fb164cc300..a93fd8d33a 100644
--- a/scene/resources/box_shape.h
+++ b/scene/resources/box_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* box_shape.h */
+/* box_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,11 +31,11 @@
#ifndef BOX_SHAPE_H
#define BOX_SHAPE_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class BoxShape : public Shape {
+class BoxShape3D : public Shape3D {
- GDCLASS(BoxShape, Shape);
+ GDCLASS(BoxShape3D, Shape3D);
Vector3 extents;
protected:
@@ -50,7 +50,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- BoxShape();
+ BoxShape3D();
};
#endif // BOX_SHAPE_H
diff --git a/scene/resources/canvas.cpp b/scene/resources/canvas.cpp
deleted file mode 100644
index 1dbd02ea28..0000000000
--- a/scene/resources/canvas.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*************************************************************************/
-/* canvas.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "canvas.h"
-#include "servers/visual_server.h"
-
-RID Canvas::get_rid() const {
-
- return canvas;
-}
-
-Canvas::Canvas() {
-
- canvas = VisualServer::get_singleton()->canvas_create();
-}
-
-Canvas::~Canvas() {
- VisualServer::get_singleton()->free(canvas);
-}
diff --git a/scene/resources/canvas.h b/scene/resources/canvas.h
deleted file mode 100644
index 621911fe0a..0000000000
--- a/scene/resources/canvas.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*************************************************************************/
-/* canvas.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef CANVAS_H
-#define CANVAS_H
-
-#include "core/resource.h"
-
-class Canvas : public Resource {
-
- GDCLASS(Canvas, Resource);
-
- RID canvas;
-
-public:
- virtual RID get_rid() const;
- Canvas();
- ~Canvas();
-};
-
-#endif // CANVAS_H
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 9b8083de97..ab2657c892 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -30,8 +30,8 @@
#include "capsule_shape_2d.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
Vector<Vector2> CapsuleShape2D::_get_points() const {
@@ -54,7 +54,7 @@ bool CapsuleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_
void CapsuleShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), Vector2(radius, height));
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), Vector2(radius, height));
emit_changed();
}
@@ -85,7 +85,7 @@ void CapsuleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Vector2> points = _get_points();
Vector<Color> col;
col.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
+ RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
Rect2 CapsuleShape2D::get_rect() const {
@@ -114,7 +114,7 @@ void CapsuleShape2D::_bind_methods() {
}
CapsuleShape2D::CapsuleShape2D() :
- Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->capsule_shape_create()) {
radius = 10;
height = 20;
diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape_3d.cpp
index dddbd7fef3..da3ffcb306 100644
--- a/scene/resources/capsule_shape.cpp
+++ b/scene/resources/capsule_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* capsule_shape.cpp */
+/* capsule_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "capsule_shape.h"
-#include "servers/physics_server.h"
+#include "capsule_shape_3d.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> CapsuleShape::get_debug_mesh_lines() {
+Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() {
float radius = get_radius();
float height = get_height();
@@ -69,20 +69,20 @@ Vector<Vector3> CapsuleShape::get_debug_mesh_lines() {
return points;
}
-real_t CapsuleShape::get_enclosing_radius() const {
+real_t CapsuleShape3D::get_enclosing_radius() const {
return radius + height * 0.5;
}
-void CapsuleShape::_update_shape() {
+void CapsuleShape3D::_update_shape() {
Dictionary d;
d["radius"] = radius;
d["height"] = height;
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), d);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d);
+ Shape3D::_update_shape();
}
-void CapsuleShape::set_radius(float p_radius) {
+void CapsuleShape3D::set_radius(float p_radius) {
radius = p_radius;
_update_shape();
@@ -90,12 +90,12 @@ void CapsuleShape::set_radius(float p_radius) {
_change_notify("radius");
}
-float CapsuleShape::get_radius() const {
+float CapsuleShape3D::get_radius() const {
return radius;
}
-void CapsuleShape::set_height(float p_height) {
+void CapsuleShape3D::set_height(float p_height) {
height = p_height;
_update_shape();
@@ -103,24 +103,24 @@ void CapsuleShape::set_height(float p_height) {
_change_notify("height");
}
-float CapsuleShape::get_height() const {
+float CapsuleShape3D::get_height() const {
return height;
}
-void CapsuleShape::_bind_methods() {
+void CapsuleShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CapsuleShape::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &CapsuleShape::get_radius);
- ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape::set_height);
- ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape::get_height);
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CapsuleShape3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &CapsuleShape3D::get_radius);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape3D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"), &CapsuleShape3D::get_height);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_height", "get_height");
}
-CapsuleShape::CapsuleShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CAPSULE)) {
+CapsuleShape3D::CapsuleShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CAPSULE)) {
radius = 1.0;
height = 1.0;
diff --git a/scene/resources/capsule_shape.h b/scene/resources/capsule_shape_3d.h
index f097e51175..dca7a6c983 100644
--- a/scene/resources/capsule_shape.h
+++ b/scene/resources/capsule_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* capsule_shape.h */
+/* capsule_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,11 +31,11 @@
#ifndef CAPSULE_SHAPE_H
#define CAPSULE_SHAPE_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class CapsuleShape : public Shape {
+class CapsuleShape3D : public Shape3D {
- GDCLASS(CapsuleShape, Shape);
+ GDCLASS(CapsuleShape3D, Shape3D);
float radius;
float height;
@@ -53,7 +53,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- CapsuleShape();
+ CapsuleShape3D();
};
#endif // CAPSULE_SHAPE_H
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index 37874e17ef..afb7597280 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -30,8 +30,8 @@
#include "circle_shape_2d.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
bool CircleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
@@ -40,7 +40,7 @@ bool CircleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_t
void CircleShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), radius);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), radius);
emit_changed();
}
@@ -84,11 +84,11 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Color> col;
col.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
+ RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
CircleShape2D::CircleShape2D() :
- Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->circle_shape_create()) {
radius = 10;
_update_shape();
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index c3e9e19721..c8fec3b72d 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -30,8 +30,8 @@
#include "concave_polygon_shape_2d.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
@@ -52,13 +52,13 @@ bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, do
void ConcavePolygonShape2D::set_segments(const Vector<Vector2> &p_segments) {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), p_segments);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), p_segments);
emit_changed();
}
Vector<Vector2> ConcavePolygonShape2D::get_segments() const {
- return Physics2DServer::get_singleton()->shape_get_data(get_rid());
+ return PhysicsServer2D::get_singleton()->shape_get_data(get_rid());
}
void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
@@ -70,7 +70,7 @@ void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
const Vector2 *r = s.ptr();
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);
+ RenderingServer::get_singleton()->canvas_item_add_line(p_to_rid, r[i], r[i + 1], p_color, 2);
}
}
@@ -113,7 +113,7 @@ void ConcavePolygonShape2D::_bind_methods() {
}
ConcavePolygonShape2D::ConcavePolygonShape2D() :
- Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->concave_polygon_shape_create()) {
Vector<Vector2> empty;
set_segments(empty);
}
diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape_3d.cpp
index fe123a2df7..42e06a49b6 100644
--- a/scene/resources/concave_polygon_shape.cpp
+++ b/scene/resources/concave_polygon_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* concave_polygon_shape.cpp */
+/* concave_polygon_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "concave_polygon_shape.h"
+#include "concave_polygon_shape_3d.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> ConcavePolygonShape::get_debug_mesh_lines() {
+Vector<Vector3> ConcavePolygonShape3D::get_debug_mesh_lines() {
Set<DrawEdge> edges;
@@ -64,7 +64,7 @@ Vector<Vector3> ConcavePolygonShape::get_debug_mesh_lines() {
return points;
}
-real_t ConcavePolygonShape::get_enclosing_radius() const {
+real_t ConcavePolygonShape3D::get_enclosing_radius() const {
Vector<Vector3> data = get_faces();
const Vector3 *read = data.ptr();
real_t r = 0;
@@ -74,30 +74,30 @@ real_t ConcavePolygonShape::get_enclosing_radius() const {
return Math::sqrt(r);
}
-void ConcavePolygonShape::_update_shape() {
- Shape::_update_shape();
+void ConcavePolygonShape3D::_update_shape() {
+ Shape3D::_update_shape();
}
-void ConcavePolygonShape::set_faces(const Vector<Vector3> &p_faces) {
+void ConcavePolygonShape3D::set_faces(const Vector<Vector3> &p_faces) {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces);
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), p_faces);
notify_change_to_owners();
}
-Vector<Vector3> ConcavePolygonShape::get_faces() const {
+Vector<Vector3> ConcavePolygonShape3D::get_faces() const {
- return PhysicsServer::get_singleton()->shape_get_data(get_shape());
+ return PhysicsServer3D::get_singleton()->shape_get_data(get_shape());
}
-void ConcavePolygonShape::_bind_methods() {
+void ConcavePolygonShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_faces", "faces"), &ConcavePolygonShape::set_faces);
- ClassDB::bind_method(D_METHOD("get_faces"), &ConcavePolygonShape::get_faces);
+ ClassDB::bind_method(D_METHOD("set_faces", "faces"), &ConcavePolygonShape3D::set_faces);
+ ClassDB::bind_method(D_METHOD("get_faces"), &ConcavePolygonShape3D::get_faces);
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_faces", "get_faces");
}
-ConcavePolygonShape::ConcavePolygonShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) {
+ConcavePolygonShape3D::ConcavePolygonShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON)) {
//set_planes(Vector3(1,1,1));
}
diff --git a/scene/resources/concave_polygon_shape.h b/scene/resources/concave_polygon_shape_3d.h
index 63aabb27d7..b4e96c662f 100644
--- a/scene/resources/concave_polygon_shape.h
+++ b/scene/resources/concave_polygon_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* concave_polygon_shape.h */
+/* concave_polygon_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CONCAVE_POLYGON_SHAPE_H
-#define CONCAVE_POLYGON_SHAPE_H
+#ifndef CONCAVE_POLYGON_SHAPE_3D_H
+#define CONCAVE_POLYGON_SHAPE_3D_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class ConcavePolygonShape : public Shape {
+class ConcavePolygonShape3D : public Shape3D {
- GDCLASS(ConcavePolygonShape, Shape);
+ GDCLASS(ConcavePolygonShape3D, Shape3D);
struct DrawEdge {
@@ -69,7 +69,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- ConcavePolygonShape();
+ ConcavePolygonShape3D();
};
#endif // CONCAVE_POLYGON_SHAPE_H
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 95967429c9..6b1ddec507 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -31,8 +31,8 @@
#include "convex_polygon_shape_2d.h"
#include "core/math/geometry.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
bool ConvexPolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
@@ -45,7 +45,7 @@ void ConvexPolygonShape2D::_update_shape() {
if (Geometry::is_polygon_clockwise(final_points)) { //needs to be counter clockwise
final_points.invert();
}
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), final_points);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), final_points);
emit_changed();
}
@@ -81,7 +81,7 @@ void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Color> col;
col.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
+ RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
Rect2 ConvexPolygonShape2D::get_rect() const {
@@ -106,5 +106,5 @@ real_t ConvexPolygonShape2D::get_enclosing_radius() const {
}
ConvexPolygonShape2D::ConvexPolygonShape2D() :
- Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->convex_polygon_shape_create()) {
}
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape_3d.cpp
index b7463605b4..ec9ab68015 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* convex_polygon_shape.cpp */
+/* convex_polygon_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "convex_polygon_shape.h"
+#include "convex_polygon_shape_3d.h"
#include "core/math/quick_hull.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> ConvexPolygonShape::get_debug_mesh_lines() {
+Vector<Vector3> ConvexPolygonShape3D::get_debug_mesh_lines() {
Vector<Vector3> points = get_points();
@@ -55,7 +55,7 @@ Vector<Vector3> ConvexPolygonShape::get_debug_mesh_lines() {
return Vector<Vector3>();
}
-real_t ConvexPolygonShape::get_enclosing_radius() const {
+real_t ConvexPolygonShape3D::get_enclosing_radius() const {
Vector<Vector3> data = get_points();
const Vector3 *read = data.ptr();
real_t r = 0;
@@ -65,32 +65,32 @@ real_t ConvexPolygonShape::get_enclosing_radius() const {
return Math::sqrt(r);
}
-void ConvexPolygonShape::_update_shape() {
+void ConvexPolygonShape3D::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), points);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), points);
+ Shape3D::_update_shape();
}
-void ConvexPolygonShape::set_points(const Vector<Vector3> &p_points) {
+void ConvexPolygonShape3D::set_points(const Vector<Vector3> &p_points) {
points = p_points;
_update_shape();
notify_change_to_owners();
}
-Vector<Vector3> ConvexPolygonShape::get_points() const {
+Vector<Vector3> ConvexPolygonShape3D::get_points() const {
return points;
}
-void ConvexPolygonShape::_bind_methods() {
+void ConvexPolygonShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_points", "points"), &ConvexPolygonShape::set_points);
- ClassDB::bind_method(D_METHOD("get_points"), &ConvexPolygonShape::get_points);
+ ClassDB::bind_method(D_METHOD("set_points", "points"), &ConvexPolygonShape3D::set_points);
+ ClassDB::bind_method(D_METHOD("get_points"), &ConvexPolygonShape3D::get_points);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "points"), "set_points", "get_points");
}
-ConvexPolygonShape::ConvexPolygonShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) {
+ConvexPolygonShape3D::ConvexPolygonShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON)) {
}
diff --git a/scene/resources/convex_polygon_shape.h b/scene/resources/convex_polygon_shape_3d.h
index fcd733887e..51e4c8eb0b 100644
--- a/scene/resources/convex_polygon_shape.h
+++ b/scene/resources/convex_polygon_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* convex_polygon_shape.h */
+/* convex_polygon_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,11 +31,11 @@
#ifndef CONVEX_POLYGON_SHAPE_H
#define CONVEX_POLYGON_SHAPE_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class ConvexPolygonShape : public Shape {
+class ConvexPolygonShape3D : public Shape3D {
- GDCLASS(ConvexPolygonShape, Shape);
+ GDCLASS(ConvexPolygonShape3D, Shape3D);
Vector<Vector3> points;
protected:
@@ -50,7 +50,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- ConvexPolygonShape();
+ ConvexPolygonShape3D();
};
#endif // CONVEX_POLYGON_SHAPE_H
diff --git a/scene/resources/cylinder_shape.cpp b/scene/resources/cylinder_shape_3d.cpp
index 53d368d32a..19f0542818 100644
--- a/scene/resources/cylinder_shape.cpp
+++ b/scene/resources/cylinder_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cylinder_shape.cpp */
+/* cylinder_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "cylinder_shape.h"
-#include "servers/physics_server.h"
+#include "cylinder_shape_3d.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> CylinderShape::get_debug_mesh_lines() {
+Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() {
float radius = get_radius();
float height = get_height();
@@ -62,20 +62,20 @@ Vector<Vector3> CylinderShape::get_debug_mesh_lines() {
return points;
}
-real_t CylinderShape::get_enclosing_radius() const {
+real_t CylinderShape3D::get_enclosing_radius() const {
return Vector2(radius, height * 0.5).length();
}
-void CylinderShape::_update_shape() {
+void CylinderShape3D::_update_shape() {
Dictionary d;
d["radius"] = radius;
d["height"] = height;
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), d);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d);
+ Shape3D::_update_shape();
}
-void CylinderShape::set_radius(float p_radius) {
+void CylinderShape3D::set_radius(float p_radius) {
radius = p_radius;
_update_shape();
@@ -83,12 +83,12 @@ void CylinderShape::set_radius(float p_radius) {
_change_notify("radius");
}
-float CylinderShape::get_radius() const {
+float CylinderShape3D::get_radius() const {
return radius;
}
-void CylinderShape::set_height(float p_height) {
+void CylinderShape3D::set_height(float p_height) {
height = p_height;
_update_shape();
@@ -96,24 +96,24 @@ void CylinderShape::set_height(float p_height) {
_change_notify("height");
}
-float CylinderShape::get_height() const {
+float CylinderShape3D::get_height() const {
return height;
}
-void CylinderShape::_bind_methods() {
+void CylinderShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CylinderShape::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &CylinderShape::get_radius);
- ClassDB::bind_method(D_METHOD("set_height", "height"), &CylinderShape::set_height);
- ClassDB::bind_method(D_METHOD("get_height"), &CylinderShape::get_height);
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CylinderShape3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &CylinderShape3D::get_radius);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &CylinderShape3D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"), &CylinderShape3D::get_height);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_height", "get_height");
}
-CylinderShape::CylinderShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CYLINDER)) {
+CylinderShape3D::CylinderShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CYLINDER)) {
radius = 1.0;
height = 2.0;
diff --git a/scene/resources/cylinder_shape.h b/scene/resources/cylinder_shape_3d.h
index a26fda10cd..7b37f733e0 100644
--- a/scene/resources/cylinder_shape.h
+++ b/scene/resources/cylinder_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cylinder_shape.h */
+/* cylinder_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CYLINDER_SHAPE_H
-#define CYLINDER_SHAPE_H
+#ifndef CYLINDER_SHAPE_3D_H
+#define CYLINDER_SHAPE_3D_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class CylinderShape : public Shape {
+class CylinderShape3D : public Shape3D {
- GDCLASS(CylinderShape, Shape);
+ GDCLASS(CylinderShape3D, Shape3D);
float radius;
float height;
@@ -52,7 +52,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- CylinderShape();
+ CylinderShape3D();
};
#endif // CYLINDER_SHAPE_H
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 9f5b49c4c3..0c45779307 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -188,6 +188,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// Panel
theme->set_stylebox("panel", "Panel", make_stylebox(panel_bg_png, 0, 0, 0, 0));
+ theme->set_stylebox("panel_fg", "Panel", make_stylebox(panel_bg_png, 0, 0, 0, 0));
// Focus
@@ -523,17 +524,19 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// WindowDialog
- theme->set_stylebox("panel", "WindowDialog", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
- theme->set_constant("scaleborder_size", "WindowDialog", 4 * scale);
+ theme->set_stylebox("panel", "Window", default_style);
+ theme->set_stylebox("window_panel", "Window", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
+ theme->set_constant("scaleborder_size", "Window", 4 * scale);
- theme->set_font("title_font", "WindowDialog", large_font);
- theme->set_color("title_color", "WindowDialog", Color(0, 0, 0));
- theme->set_constant("title_height", "WindowDialog", 20 * scale);
+ theme->set_font("title_font", "Window", large_font);
+ theme->set_color("title_color", "Window", Color(0, 0, 0));
+ theme->set_constant("title_height", "Window", 20 * scale);
+ theme->set_constant("resize_margin", "Window", 4 * scale);
- theme->set_icon("close", "WindowDialog", make_icon(close_png));
- theme->set_icon("close_highlight", "WindowDialog", make_icon(close_hl_png));
- theme->set_constant("close_h_ofs", "WindowDialog", 18 * scale);
- theme->set_constant("close_v_ofs", "WindowDialog", 18 * scale);
+ theme->set_icon("close", "Window", make_icon(close_png));
+ theme->set_icon("close_highlight", "Window", make_icon(close_hl_png));
+ theme->set_constant("close_h_ofs", "Window", 18 * scale);
+ theme->set_constant("close_v_ofs", "Window", 18 * scale);
// File Dialog
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 410c4990a2..107f07ec7d 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -336,7 +336,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
modulate.r = modulate.g = modulate.b = 1.0;
}
RID texture = font->textures[ch->texture_idx].texture->get_rid();
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
}
advance = ch->advance;
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index d407dd3722..89937238c1 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -30,7 +30,7 @@
#include "environment.h"
#include "core/project_settings.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#include "texture.h"
RID Environment::get_rid() const {
@@ -41,7 +41,7 @@ RID Environment::get_rid() const {
void Environment::set_background(BGMode p_bg) {
bg_mode = p_bg;
- VS::get_singleton()->environment_set_background(environment, VS::EnvironmentBG(p_bg));
+ RS::get_singleton()->environment_set_background(environment, RS::EnvironmentBG(p_bg));
_change_notify();
}
@@ -53,56 +53,56 @@ void Environment::set_sky(const Ref<Sky> &p_sky) {
if (bg_sky.is_valid())
sb_rid = bg_sky->get_rid();
- VS::get_singleton()->environment_set_sky(environment, sb_rid);
+ RS::get_singleton()->environment_set_sky(environment, sb_rid);
}
void Environment::set_sky_custom_fov(float p_scale) {
bg_sky_custom_fov = p_scale;
- VS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale);
+ RS::get_singleton()->environment_set_sky_custom_fov(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);
+ RS::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);
+ RS::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);
+ RS::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, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color);
+ RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
void Environment::set_ambient_light_energy(float p_energy) {
ambient_energy = p_energy;
- VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color);
+ RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
void Environment::set_ambient_light_sky_contribution(float p_energy) {
ambient_sky_contribution = p_energy;
- VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color);
+ RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
void Environment::set_camera_feed_id(int p_camera_feed_id) {
camera_feed_id = p_camera_feed_id;
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
- VS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id);
+ RS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id);
#endif
};
void Environment::set_ambient_source(AmbientSource p_source) {
ambient_source = p_source;
- VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color);
+ RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
Environment::AmbientSource Environment::get_ambient_source() const {
@@ -110,7 +110,7 @@ Environment::AmbientSource Environment::get_ambient_source() const {
}
void Environment::set_reflection_source(ReflectionSource p_source) {
reflection_source = p_source;
- VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color);
+ RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
Environment::ReflectionSource Environment::get_reflection_source() const {
return reflection_source;
@@ -132,7 +132,7 @@ float Environment::get_sky_custom_fov() const {
void Environment::set_sky_rotation(const Vector3 &p_rotation) {
sky_rotation = p_rotation;
- VS::get_singleton()->environment_set_sky_orientation(environment, Basis(p_rotation));
+ RS::get_singleton()->environment_set_sky_orientation(environment, Basis(p_rotation));
}
Vector3 Environment::get_sky_rotation() const {
@@ -172,7 +172,7 @@ int Environment::get_camera_feed_id(void) const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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);
}
Environment::ToneMapper Environment::get_tonemapper() const {
@@ -183,7 +183,7 @@ Environment::ToneMapper Environment::get_tonemapper() const {
void Environment::set_tonemap_exposure(float p_exposure) {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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 {
@@ -194,7 +194,7 @@ float Environment::get_tonemap_exposure() const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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 {
@@ -204,7 +204,7 @@ float Environment::get_tonemap_white() const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
_change_notify();
}
bool Environment::get_tonemap_auto_exposure() const {
@@ -215,7 +215,7 @@ bool Environment::get_tonemap_auto_exposure() const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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 {
@@ -225,7 +225,7 @@ float Environment::get_tonemap_auto_exposure_max() const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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 {
@@ -235,7 +235,7 @@ float Environment::get_tonemap_auto_exposure_min() const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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 {
@@ -245,7 +245,7 @@ float Environment::get_tonemap_auto_exposure_speed() const {
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);
+ RS::get_singleton()->environment_set_tonemap(environment, RS::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 {
@@ -255,7 +255,7 @@ float Environment::get_tonemap_auto_exposure_grey() const {
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());
+ RS::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());
_change_notify();
}
@@ -267,7 +267,7 @@ bool Environment::is_adjustment_enabled() const {
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());
+ RS::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 {
@@ -277,7 +277,7 @@ float Environment::get_adjustment_brightness() const {
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());
+ RS::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 {
@@ -287,7 +287,7 @@ float Environment::get_adjustment_contrast() const {
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());
+ RS::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 {
@@ -297,7 +297,7 @@ float Environment::get_adjustment_saturation() const {
void Environment::set_adjustment_color_correction(const Ref<Texture2D> &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());
+ RS::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<Texture2D> Environment::get_adjustment_color_correction() const {
@@ -371,7 +371,7 @@ void Environment::_validate_property(PropertyInfo &property) const {
prefixes++;
}
- if (VisualServer::get_singleton()->is_low_end()) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
prefixes = high_end_prefixes;
while (*prefixes) {
String prefix = String(*prefixes);
@@ -389,7 +389,7 @@ void Environment::_validate_property(PropertyInfo &property) const {
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_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
+ RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
_change_notify();
}
@@ -401,7 +401,7 @@ bool Environment::is_ssr_enabled() const {
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_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
+ RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
}
int Environment::get_ssr_max_steps() const {
@@ -411,7 +411,7 @@ int Environment::get_ssr_max_steps() const {
void Environment::set_ssr_fade_in(float p_fade_in) {
ssr_fade_in = p_fade_in;
- VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
+ RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
}
float Environment::get_ssr_fade_in() const {
@@ -421,7 +421,7 @@ float Environment::get_ssr_fade_in() const {
void Environment::set_ssr_fade_out(float p_fade_out) {
ssr_fade_out = p_fade_out;
- VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
+ RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
}
float Environment::get_ssr_fade_out() const {
@@ -431,7 +431,7 @@ float Environment::get_ssr_fade_out() const {
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_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
+ RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
}
float Environment::get_ssr_depth_tolerance() const {
@@ -441,7 +441,7 @@ float Environment::get_ssr_depth_tolerance() const {
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_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
+ RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
}
bool Environment::is_ssr_rough() const {
@@ -451,7 +451,7 @@ bool Environment::is_ssr_rough() const {
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_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
_change_notify();
}
@@ -463,7 +463,7 @@ bool Environment::is_ssao_enabled() const {
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_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_radius() const {
@@ -473,7 +473,7 @@ float Environment::get_ssao_radius() const {
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_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_intensity() const {
@@ -484,7 +484,7 @@ float Environment::get_ssao_intensity() const {
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_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_bias() const {
@@ -494,7 +494,7 @@ float Environment::get_ssao_bias() const {
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_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_direct_light_affect() const {
@@ -504,7 +504,7 @@ float Environment::get_ssao_direct_light_affect() const {
void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) {
ssao_ao_channel_affect = p_ao_channel_affect;
- VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_ao_channel_affect() const {
@@ -514,7 +514,7 @@ float Environment::get_ssao_ao_channel_affect() const {
void Environment::set_ao_color(const Color &p_color) {
ao_color = p_color;
- VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color);
+ RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
Color Environment::get_ao_color() const {
@@ -525,7 +525,7 @@ Color Environment::get_ao_color() const {
void Environment::set_ssao_blur(SSAOBlur p_blur) {
ssao_blur = p_blur;
- VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
Environment::SSAOBlur Environment::get_ssao_blur() const {
@@ -535,7 +535,7 @@ Environment::SSAOBlur Environment::get_ssao_blur() const {
void Environment::set_ssao_edge_sharpness(float p_edge_sharpness) {
ssao_edge_sharpness = p_edge_sharpness;
- VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
+ RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_edge_sharpness() const {
@@ -546,7 +546,7 @@ float Environment::get_ssao_edge_sharpness() const {
void Environment::set_glow_enabled(bool p_enabled) {
glow_enabled = p_enabled;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
_change_notify();
}
@@ -557,18 +557,18 @@ bool Environment::is_glow_enabled() const {
void Environment::set_glow_level(int p_level, bool p_enabled) {
- ERR_FAIL_INDEX(p_level, VS::MAX_GLOW_LEVELS);
+ ERR_FAIL_INDEX(p_level, RS::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_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
bool Environment::is_glow_level_enabled(int p_level) const {
- ERR_FAIL_INDEX_V(p_level, VS::MAX_GLOW_LEVELS, false);
+ ERR_FAIL_INDEX_V(p_level, RS::MAX_GLOW_LEVELS, false);
return glow_levels & (1 << p_level);
}
@@ -577,7 +577,7 @@ void Environment::set_glow_intensity(float p_intensity) {
glow_intensity = p_intensity;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_intensity() const {
@@ -587,7 +587,7 @@ float Environment::get_glow_intensity() const {
void Environment::set_glow_strength(float p_strength) {
glow_strength = p_strength;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_strength() const {
@@ -597,7 +597,7 @@ float Environment::get_glow_strength() const {
void Environment::set_glow_mix(float p_mix) {
glow_mix = p_mix;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_mix() const {
@@ -608,7 +608,7 @@ void Environment::set_glow_bloom(float p_threshold) {
glow_bloom = p_threshold;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_bloom() const {
@@ -619,7 +619,7 @@ 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_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
_change_notify();
}
Environment::GlowBlendMode Environment::get_glow_blend_mode() const {
@@ -631,7 +631,7 @@ void Environment::set_glow_hdr_bleed_threshold(float p_threshold) {
glow_hdr_bleed_threshold = p_threshold;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_hdr_bleed_threshold() const {
@@ -642,7 +642,7 @@ void Environment::set_glow_hdr_luminance_cap(float p_amount) {
glow_hdr_luminance_cap = p_amount;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_hdr_luminance_cap() const {
@@ -653,7 +653,7 @@ 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_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
float Environment::get_glow_hdr_bleed_scale() const {
@@ -663,7 +663,7 @@ float Environment::get_glow_hdr_bleed_scale() const {
void Environment::set_glow_bicubic_upscale(bool p_enable) {
glow_bicubic_upscale = p_enable;
- VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
+ RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale);
}
bool Environment::is_glow_bicubic_upscale_enabled() const {
@@ -674,7 +674,7 @@ bool Environment::is_glow_bicubic_upscale_enabled() const {
void Environment::set_fog_enabled(bool p_enabled) {
fog_enabled = p_enabled;
- VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
+ RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
_change_notify();
}
@@ -686,7 +686,7 @@ bool Environment::is_fog_enabled() const {
void Environment::set_fog_color(const Color &p_color) {
fog_color = p_color;
- VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
+ RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
}
Color Environment::get_fog_color() const {
@@ -696,7 +696,7 @@ Color Environment::get_fog_color() const {
void Environment::set_fog_sun_color(const Color &p_color) {
fog_sun_color = p_color;
- VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
+ RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
}
Color Environment::get_fog_sun_color() const {
@@ -706,7 +706,7 @@ Color Environment::get_fog_sun_color() const {
void Environment::set_fog_sun_amount(float p_amount) {
fog_sun_amount = p_amount;
- VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
+ RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
}
float Environment::get_fog_sun_amount() const {
@@ -716,7 +716,7 @@ float Environment::get_fog_sun_amount() const {
void Environment::set_fog_depth_enabled(bool p_enabled) {
fog_depth_enabled = p_enabled;
- VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
+ RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
bool Environment::is_fog_depth_enabled() const {
@@ -726,7 +726,7 @@ bool Environment::is_fog_depth_enabled() const {
void Environment::set_fog_depth_begin(float p_distance) {
fog_depth_begin = p_distance;
- VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
+ RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
float Environment::get_fog_depth_begin() const {
@@ -736,7 +736,7 @@ float Environment::get_fog_depth_begin() const {
void Environment::set_fog_depth_end(float p_distance) {
fog_depth_end = p_distance;
- VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
+ RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
float Environment::get_fog_depth_end() const {
@@ -747,7 +747,7 @@ float Environment::get_fog_depth_end() const {
void Environment::set_fog_depth_curve(float p_curve) {
fog_depth_curve = p_curve;
- VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
+ RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
float Environment::get_fog_depth_curve() const {
@@ -757,7 +757,7 @@ float Environment::get_fog_depth_curve() const {
void Environment::set_fog_transmit_enabled(bool p_enabled) {
fog_transmit_enabled = p_enabled;
- VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
+ RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
bool Environment::is_fog_transmit_enabled() const {
@@ -767,7 +767,7 @@ bool Environment::is_fog_transmit_enabled() const {
void Environment::set_fog_transmit_curve(float p_curve) {
fog_transmit_curve = p_curve;
- VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
+ RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
float Environment::get_fog_transmit_curve() const {
@@ -777,7 +777,7 @@ float Environment::get_fog_transmit_curve() const {
void Environment::set_fog_height_enabled(bool p_enabled) {
fog_height_enabled = p_enabled;
- VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
+ RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
bool Environment::is_fog_height_enabled() const {
@@ -787,7 +787,7 @@ bool Environment::is_fog_height_enabled() const {
void Environment::set_fog_height_min(float p_distance) {
fog_height_min = p_distance;
- VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
+ RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
float Environment::get_fog_height_min() const {
@@ -797,7 +797,7 @@ float Environment::get_fog_height_min() const {
void Environment::set_fog_height_max(float p_distance) {
fog_height_max = p_distance;
- VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
+ RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
float Environment::get_fog_height_max() const {
@@ -807,7 +807,7 @@ float Environment::get_fog_height_max() const {
void Environment::set_fog_height_curve(float p_distance) {
fog_height_curve = p_distance;
- VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
+ RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
float Environment::get_fog_height_curve() const {
@@ -1152,7 +1152,7 @@ Environment::Environment() :
ssao_blur(SSAO_BLUR_3x3),
glow_blend_mode(GLOW_BLEND_MODE_ADDITIVE) {
- environment = VS::get_singleton()->environment_create();
+ environment = RS::get_singleton()->environment_create();
bg_mode = BG_CLEAR_COLOR;
bg_sky_custom_fov = 0;
@@ -1236,7 +1236,7 @@ Environment::Environment() :
Environment::~Environment() {
- VS::get_singleton()->free(environment);
+ RS::get_singleton()->free(environment);
}
//////////////////////
@@ -1244,7 +1244,7 @@ Environment::~Environment() {
void CameraEffects::set_dof_blur_far_enabled(bool p_enable) {
dof_blur_far_enabled = p_enable;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
bool CameraEffects::is_dof_blur_far_enabled() const {
@@ -1255,7 +1255,7 @@ bool CameraEffects::is_dof_blur_far_enabled() const {
void CameraEffects::set_dof_blur_far_distance(float p_distance) {
dof_blur_far_distance = p_distance;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_far_distance() const {
@@ -1265,7 +1265,7 @@ float CameraEffects::get_dof_blur_far_distance() const {
void CameraEffects::set_dof_blur_far_transition(float p_distance) {
dof_blur_far_transition = p_distance;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_far_transition() const {
@@ -1275,7 +1275,7 @@ float CameraEffects::get_dof_blur_far_transition() const {
void CameraEffects::set_dof_blur_near_enabled(bool p_enable) {
dof_blur_near_enabled = p_enable;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
_change_notify();
}
@@ -1287,7 +1287,7 @@ bool CameraEffects::is_dof_blur_near_enabled() const {
void CameraEffects::set_dof_blur_near_distance(float p_distance) {
dof_blur_near_distance = p_distance;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_near_distance() const {
@@ -1298,7 +1298,7 @@ float CameraEffects::get_dof_blur_near_distance() const {
void CameraEffects::set_dof_blur_near_transition(float p_distance) {
dof_blur_near_transition = p_distance;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_near_transition() const {
@@ -1309,7 +1309,7 @@ float CameraEffects::get_dof_blur_near_transition() const {
void CameraEffects::set_dof_blur_amount(float p_amount) {
dof_blur_amount = p_amount;
- VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
+ RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_amount() const {
@@ -1318,7 +1318,7 @@ float CameraEffects::get_dof_blur_amount() const {
void CameraEffects::set_override_exposure_enabled(bool p_enabled) {
override_exposure_enabled = p_enabled;
- VS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure);
+ RS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure);
}
bool CameraEffects::is_override_exposure_enabled() const {
@@ -1327,7 +1327,7 @@ bool CameraEffects::is_override_exposure_enabled() const {
void CameraEffects::set_override_exposure(float p_exposure) {
override_exposure = p_exposure;
- VS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure);
+ RS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure);
}
float CameraEffects::get_override_exposure() const {
@@ -1382,7 +1382,7 @@ void CameraEffects::_bind_methods() {
CameraEffects::CameraEffects() {
- camera_effects = VS::get_singleton()->camera_effects_create();
+ camera_effects = RS::get_singleton()->camera_effects_create();
dof_blur_far_enabled = false;
dof_blur_far_distance = 10;
@@ -1400,5 +1400,5 @@ CameraEffects::CameraEffects() {
CameraEffects::~CameraEffects() {
- VS::get_singleton()->free(camera_effects);
+ RS::get_singleton()->free(camera_effects);
}
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index f9fe26f792..657c7190e5 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -34,7 +34,7 @@
#include "core/resource.h"
#include "scene/resources/sky.h"
#include "scene/resources/texture.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
class Environment : public Resource {
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 1f5e4b647a..8914cf8097 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -556,7 +556,7 @@ float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_c
cpos.x += c->h_align;
cpos.y -= ascent;
cpos.y += c->v_align;
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
}
return get_char_size(p_char, p_next).width;
diff --git a/scene/resources/height_map_shape.cpp b/scene/resources/height_map_shape_3d.cpp
index fa45ddcabb..33b6063299 100644
--- a/scene/resources/height_map_shape.cpp
+++ b/scene/resources/height_map_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* height_map_shape.cpp */
+/* height_map_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "height_map_shape.h"
-#include "servers/physics_server.h"
+#include "height_map_shape_3d.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> HeightMapShape::get_debug_mesh_lines() {
+Vector<Vector3> HeightMapShape3D::get_debug_mesh_lines() {
Vector<Vector3> points;
if ((map_width != 0) && (map_depth != 0)) {
@@ -76,11 +76,11 @@ Vector<Vector3> HeightMapShape::get_debug_mesh_lines() {
return points;
}
-real_t HeightMapShape::get_enclosing_radius() const {
+real_t HeightMapShape3D::get_enclosing_radius() const {
return Vector3(real_t(map_width), max_height - min_height, real_t(map_depth)).length();
}
-void HeightMapShape::_update_shape() {
+void HeightMapShape3D::_update_shape() {
Dictionary d;
d["width"] = map_width;
@@ -88,11 +88,11 @@ void HeightMapShape::_update_shape() {
d["heights"] = map_data;
d["min_height"] = min_height;
d["max_height"] = max_height;
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), d);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d);
+ Shape3D::_update_shape();
}
-void HeightMapShape::set_map_width(int p_new) {
+void HeightMapShape3D::set_map_width(int p_new) {
if (p_new < 1) {
// ignore
} else if (map_width != p_new) {
@@ -114,11 +114,11 @@ void HeightMapShape::set_map_width(int p_new) {
}
}
-int HeightMapShape::get_map_width() const {
+int HeightMapShape3D::get_map_width() const {
return map_width;
}
-void HeightMapShape::set_map_depth(int p_new) {
+void HeightMapShape3D::set_map_depth(int p_new) {
if (p_new < 1) {
// ignore
} else if (map_depth != p_new) {
@@ -140,11 +140,11 @@ void HeightMapShape::set_map_depth(int p_new) {
}
}
-int HeightMapShape::get_map_depth() const {
+int HeightMapShape3D::get_map_depth() const {
return map_depth;
}
-void HeightMapShape::set_map_data(PackedFloat32Array p_new) {
+void HeightMapShape3D::set_map_data(PackedFloat32Array p_new) {
int size = (map_width * map_depth);
if (p_new.size() != size) {
// fail
@@ -174,25 +174,25 @@ void HeightMapShape::set_map_data(PackedFloat32Array p_new) {
_change_notify("map_data");
}
-PackedFloat32Array HeightMapShape::get_map_data() const {
+PackedFloat32Array HeightMapShape3D::get_map_data() const {
return map_data;
}
-void HeightMapShape::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_map_width", "width"), &HeightMapShape::set_map_width);
- ClassDB::bind_method(D_METHOD("get_map_width"), &HeightMapShape::get_map_width);
- ClassDB::bind_method(D_METHOD("set_map_depth", "height"), &HeightMapShape::set_map_depth);
- ClassDB::bind_method(D_METHOD("get_map_depth"), &HeightMapShape::get_map_depth);
- ClassDB::bind_method(D_METHOD("set_map_data", "data"), &HeightMapShape::set_map_data);
- ClassDB::bind_method(D_METHOD("get_map_data"), &HeightMapShape::get_map_data);
+void HeightMapShape3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_map_width", "width"), &HeightMapShape3D::set_map_width);
+ ClassDB::bind_method(D_METHOD("get_map_width"), &HeightMapShape3D::get_map_width);
+ ClassDB::bind_method(D_METHOD("set_map_depth", "height"), &HeightMapShape3D::set_map_depth);
+ ClassDB::bind_method(D_METHOD("get_map_depth"), &HeightMapShape3D::get_map_depth);
+ ClassDB::bind_method(D_METHOD("set_map_data", "data"), &HeightMapShape3D::set_map_data);
+ ClassDB::bind_method(D_METHOD("get_map_data"), &HeightMapShape3D::get_map_data);
ADD_PROPERTY(PropertyInfo(Variant::INT, "map_width", PROPERTY_HINT_RANGE, "1,4096,1"), "set_map_width", "get_map_width");
ADD_PROPERTY(PropertyInfo(Variant::INT, "map_depth", PROPERTY_HINT_RANGE, "1,4096,1"), "set_map_depth", "get_map_depth");
ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "map_data"), "set_map_data", "get_map_data");
}
-HeightMapShape::HeightMapShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_HEIGHTMAP)) {
+HeightMapShape3D::HeightMapShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_HEIGHTMAP)) {
map_width = 2;
map_depth = 2;
diff --git a/scene/resources/height_map_shape.h b/scene/resources/height_map_shape_3d.h
index b8204f6c98..291d41a34e 100644
--- a/scene/resources/height_map_shape.h
+++ b/scene/resources/height_map_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* height_map_shape.h */
+/* height_map_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,10 +31,10 @@
#ifndef HEIGHT_MAP_SHAPE_H
#define HEIGHT_MAP_SHAPE_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class HeightMapShape : public Shape {
- GDCLASS(HeightMapShape, Shape);
+class HeightMapShape3D : public Shape3D {
+ GDCLASS(HeightMapShape3D, Shape3D);
int map_width;
int map_depth;
@@ -57,7 +57,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- HeightMapShape();
+ HeightMapShape3D();
};
#endif /* !HEIGHT_MAP_SHAPE_H */
diff --git a/scene/resources/line_shape_2d.cpp b/scene/resources/line_shape_2d.cpp
index 3b30b4528a..a1c1b2f9f4 100644
--- a/scene/resources/line_shape_2d.cpp
+++ b/scene/resources/line_shape_2d.cpp
@@ -30,8 +30,8 @@
#include "line_shape_2d.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
@@ -52,7 +52,7 @@ void LineShape2D::_update_shape() {
Array arr;
arr.push_back(normal);
arr.push_back(d);
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), arr);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), arr);
emit_changed();
}
@@ -82,9 +82,9 @@ void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector2 point = get_d() * get_normal();
Vector2 l1[2] = { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 };
- VS::get_singleton()->canvas_item_add_line(p_to_rid, l1[0], l1[1], p_color, 3);
+ RS::get_singleton()->canvas_item_add_line(p_to_rid, l1[0], l1[1], p_color, 3);
Vector2 l2[2] = { point, point + get_normal() * 30 };
- VS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3);
+ RS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3);
}
Rect2 LineShape2D::get_rect() const {
@@ -117,7 +117,7 @@ void LineShape2D::_bind_methods() {
}
LineShape2D::LineShape2D() :
- Shape2D(Physics2DServer::get_singleton()->line_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->line_shape_create()) {
normal = Vector2(0, 1);
d = 0;
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index d387a39dbe..f52b755ed3 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -51,7 +51,7 @@ void Material::set_next_pass(const Ref<Material> &p_pass) {
RID next_pass_rid;
if (next_pass.is_valid())
next_pass_rid = next_pass->get_rid();
- VS::get_singleton()->material_set_next_pass(material, next_pass_rid);
+ RS::get_singleton()->material_set_next_pass(material, next_pass_rid);
}
Ref<Material> Material::get_next_pass() const {
@@ -64,7 +64,7 @@ void Material::set_render_priority(int p_priority) {
ERR_FAIL_COND(p_priority < RENDER_PRIORITY_MIN);
ERR_FAIL_COND(p_priority > RENDER_PRIORITY_MAX);
render_priority = p_priority;
- VS::get_singleton()->material_set_render_priority(material, p_priority);
+ RS::get_singleton()->material_set_render_priority(material, p_priority);
}
int Material::get_render_priority() const {
@@ -100,13 +100,13 @@ void Material::_bind_methods() {
Material::Material() {
- material = VisualServer::get_singleton()->material_create();
+ material = RenderingServer::get_singleton()->material_create();
render_priority = 0;
}
Material::~Material() {
- VisualServer::get_singleton()->free(material);
+ RenderingServer::get_singleton()->free(material);
}
///////////////////////////////////
@@ -126,7 +126,7 @@ bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
}
}
if (pr) {
- VisualServer::get_singleton()->material_set_param(_get_material(), pr, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), pr, p_value);
return true;
}
}
@@ -150,7 +150,7 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
}
if (pr) {
- r_ret = VisualServer::get_singleton()->material_get_param(_get_material(), pr);
+ r_ret = RenderingServer::get_singleton()->material_get_param(_get_material(), pr);
return true;
}
}
@@ -171,7 +171,7 @@ bool ShaderMaterial::property_can_revert(const String &p_name) {
StringName pr = shader->remap_param(p_name);
if (pr) {
- Variant default_value = VisualServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
+ Variant default_value = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
Variant current_value;
_get(p_name, current_value);
return default_value.get_type() != Variant::NIL && default_value != current_value;
@@ -185,7 +185,7 @@ Variant ShaderMaterial::property_get_revert(const String &p_name) {
if (shader.is_valid()) {
StringName pr = shader->remap_param(p_name);
if (pr) {
- r_ret = VisualServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
+ r_ret = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
}
}
return r_ret;
@@ -211,7 +211,7 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
}
}
- VS::get_singleton()->material_set_shader(_get_material(), rid);
+ RS::get_singleton()->material_set_shader(_get_material(), rid);
_change_notify(); //properties for shader exposed
emit_changed();
}
@@ -223,12 +223,12 @@ Ref<Shader> ShaderMaterial::get_shader() const {
void ShaderMaterial::set_shader_param(const StringName &p_param, const Variant &p_value) {
- VS::get_singleton()->material_set_param(_get_material(), p_param, p_value);
+ RS::get_singleton()->material_set_param(_get_material(), p_param, p_value);
}
Variant ShaderMaterial::get_shader_param(const StringName &p_param) const {
- return VS::get_singleton()->material_get_param(_get_material(), p_param);
+ return RS::get_singleton()->material_get_param(_get_material(), p_param);
}
void ShaderMaterial::_shader_changed() {
@@ -392,7 +392,7 @@ void BaseMaterial3D::_update_shader() {
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);
+ RS::get_singleton()->free(shader_map[current_key].shader);
shader_map.erase(current_key);
}
}
@@ -401,7 +401,7 @@ void BaseMaterial3D::_update_shader() {
if (shader_map.has(mk)) {
- VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
shader_map[mk].users++;
return;
}
@@ -773,7 +773,7 @@ void BaseMaterial3D::_update_shader() {
code += "\tvec2 base_uv2 = UV2;\n";
}
- if (!VisualServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar
+ if (!RenderingServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar
code += "\t{\n";
code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-)
@@ -953,7 +953,7 @@ void BaseMaterial3D::_update_shader() {
if (distance_fade != DISTANCE_FADE_DISABLED) {
if ((distance_fade == DISTANCE_FADE_OBJECT_DITHER || distance_fade == DISTANCE_FADE_PIXEL_DITHER)) {
- if (!VisualServer::get_singleton()->is_low_end()) {
+ if (!RenderingServer::get_singleton()->is_low_end()) {
code += "\t{\n";
if (distance_fade == DISTANCE_FADE_OBJECT_DITHER) {
code += "\t\tfloat fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);\n";
@@ -1112,14 +1112,14 @@ void BaseMaterial3D::_update_shader() {
code += "}\n";
ShaderData shader_data;
- shader_data.shader = VS::get_singleton()->shader_create();
+ shader_data.shader = RS::get_singleton()->shader_create();
shader_data.users = 1;
- VS::get_singleton()->shader_set_code(shader_data.shader, code);
+ RS::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);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
}
void BaseMaterial3D::flush_changes() {
@@ -1151,7 +1151,7 @@ void BaseMaterial3D::set_albedo(const Color &p_albedo) {
albedo = p_albedo;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo);
}
Color BaseMaterial3D::get_albedo() const {
@@ -1162,7 +1162,7 @@ Color BaseMaterial3D::get_albedo() const {
void BaseMaterial3D::set_specular(float p_specular) {
specular = p_specular;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular);
}
float BaseMaterial3D::get_specular() const {
@@ -1173,7 +1173,7 @@ float BaseMaterial3D::get_specular() const {
void BaseMaterial3D::set_roughness(float p_roughness) {
roughness = p_roughness;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness);
}
float BaseMaterial3D::get_roughness() const {
@@ -1184,7 +1184,7 @@ float BaseMaterial3D::get_roughness() const {
void BaseMaterial3D::set_metallic(float p_metallic) {
metallic = p_metallic;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic);
}
float BaseMaterial3D::get_metallic() const {
@@ -1195,7 +1195,7 @@ float BaseMaterial3D::get_metallic() const {
void BaseMaterial3D::set_emission(const Color &p_emission) {
emission = p_emission;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission);
}
Color BaseMaterial3D::get_emission() const {
@@ -1205,7 +1205,7 @@ Color BaseMaterial3D::get_emission() const {
void BaseMaterial3D::set_emission_energy(float p_emission_energy) {
emission_energy = p_emission_energy;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy);
}
float BaseMaterial3D::get_emission_energy() const {
@@ -1215,7 +1215,7 @@ float BaseMaterial3D::get_emission_energy() const {
void BaseMaterial3D::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);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->normal_scale, p_normal_scale);
}
float BaseMaterial3D::get_normal_scale() const {
@@ -1225,7 +1225,7 @@ float BaseMaterial3D::get_normal_scale() const {
void BaseMaterial3D::set_rim(float p_rim) {
rim = p_rim;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim);
}
float BaseMaterial3D::get_rim() const {
@@ -1235,7 +1235,7 @@ float BaseMaterial3D::get_rim() const {
void BaseMaterial3D::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);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->rim_tint, p_rim_tint);
}
float BaseMaterial3D::get_rim_tint() const {
@@ -1245,7 +1245,7 @@ float BaseMaterial3D::get_rim_tint() const {
void BaseMaterial3D::set_ao_light_affect(float p_ao_light_affect) {
ao_light_affect = p_ao_light_affect;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect);
}
float BaseMaterial3D::get_ao_light_affect() const {
@@ -1255,7 +1255,7 @@ float BaseMaterial3D::get_ao_light_affect() const {
void BaseMaterial3D::set_clearcoat(float p_clearcoat) {
clearcoat = p_clearcoat;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat);
}
float BaseMaterial3D::get_clearcoat() const {
@@ -1266,7 +1266,7 @@ float BaseMaterial3D::get_clearcoat() const {
void BaseMaterial3D::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);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat_gloss, p_clearcoat_gloss);
}
float BaseMaterial3D::get_clearcoat_gloss() const {
@@ -1277,7 +1277,7 @@ float BaseMaterial3D::get_clearcoat_gloss() const {
void BaseMaterial3D::set_anisotropy(float p_anisotropy) {
anisotropy = p_anisotropy;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy);
}
float BaseMaterial3D::get_anisotropy() const {
@@ -1287,7 +1287,7 @@ float BaseMaterial3D::get_anisotropy() const {
void BaseMaterial3D::set_heightmap_scale(float p_heightmap_scale) {
heightmap_scale = p_heightmap_scale;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_scale, p_heightmap_scale);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_scale, p_heightmap_scale);
}
float BaseMaterial3D::get_heightmap_scale() const {
@@ -1298,7 +1298,7 @@ float BaseMaterial3D::get_heightmap_scale() const {
void BaseMaterial3D::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);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->subsurface_scattering_strength, subsurface_scattering_strength);
}
float BaseMaterial3D::get_subsurface_scattering_strength() const {
@@ -1309,7 +1309,7 @@ float BaseMaterial3D::get_subsurface_scattering_strength() const {
void BaseMaterial3D::set_transmission(const Color &p_transmission) {
transmission = p_transmission;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission);
}
Color BaseMaterial3D::get_transmission() const {
@@ -1320,7 +1320,7 @@ Color BaseMaterial3D::get_transmission() const {
void BaseMaterial3D::set_refraction(float p_refraction) {
refraction = p_refraction;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction);
}
float BaseMaterial3D::get_refraction() const {
@@ -1488,7 +1488,7 @@ void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_t
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);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->texture_names[p_param], rid);
_change_notify();
_queue_shader_change();
}
@@ -1637,7 +1637,7 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
void BaseMaterial3D::set_point_size(float p_point_size) {
point_size = p_point_size;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size);
}
float BaseMaterial3D::get_point_size() const {
@@ -1648,7 +1648,7 @@ float BaseMaterial3D::get_point_size() const {
void BaseMaterial3D::set_uv1_scale(const Vector3 &p_scale) {
uv1_scale = p_scale;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale);
}
Vector3 BaseMaterial3D::get_uv1_scale() const {
@@ -1659,7 +1659,7 @@ Vector3 BaseMaterial3D::get_uv1_scale() const {
void BaseMaterial3D::set_uv1_offset(const Vector3 &p_offset) {
uv1_offset = p_offset;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset);
}
Vector3 BaseMaterial3D::get_uv1_offset() const {
@@ -1669,7 +1669,7 @@ Vector3 BaseMaterial3D::get_uv1_offset() const {
void BaseMaterial3D::set_uv1_triplanar_blend_sharpness(float p_sharpness) {
uv1_triplanar_sharpness = p_sharpness;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness);
}
float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const {
@@ -1680,7 +1680,7 @@ float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const {
void BaseMaterial3D::set_uv2_scale(const Vector3 &p_scale) {
uv2_scale = p_scale;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale);
}
Vector3 BaseMaterial3D::get_uv2_scale() const {
@@ -1691,7 +1691,7 @@ Vector3 BaseMaterial3D::get_uv2_scale() const {
void BaseMaterial3D::set_uv2_offset(const Vector3 &p_offset) {
uv2_offset = p_offset;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset);
}
Vector3 BaseMaterial3D::get_uv2_offset() const {
@@ -1702,7 +1702,7 @@ Vector3 BaseMaterial3D::get_uv2_offset() const {
void BaseMaterial3D::set_uv2_triplanar_blend_sharpness(float p_sharpness) {
uv2_triplanar_sharpness = p_sharpness;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness);
}
float BaseMaterial3D::get_uv2_triplanar_blend_sharpness() const {
@@ -1725,7 +1725,7 @@ BaseMaterial3D::BillboardMode BaseMaterial3D::get_billboard_mode() const {
void BaseMaterial3D::set_particles_anim_h_frames(int p_frames) {
particles_anim_h_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
}
int BaseMaterial3D::get_particles_anim_h_frames() const {
@@ -1735,7 +1735,7 @@ int BaseMaterial3D::get_particles_anim_h_frames() const {
void BaseMaterial3D::set_particles_anim_v_frames(int p_frames) {
particles_anim_v_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
}
int BaseMaterial3D::get_particles_anim_v_frames() const {
@@ -1746,7 +1746,7 @@ int BaseMaterial3D::get_particles_anim_v_frames() const {
void BaseMaterial3D::set_particles_anim_loop(bool p_loop) {
particles_anim_loop = p_loop;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
}
bool BaseMaterial3D::get_particles_anim_loop() const {
@@ -1769,7 +1769,7 @@ bool BaseMaterial3D::is_heightmap_deep_parallax_enabled() const {
void BaseMaterial3D::set_heightmap_deep_parallax_min_layers(int p_layer) {
deep_parallax_min_layers = p_layer;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_min_layers, p_layer);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_min_layers, p_layer);
}
int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const {
@@ -1779,7 +1779,7 @@ int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const {
void BaseMaterial3D::set_heightmap_deep_parallax_max_layers(int p_layer) {
deep_parallax_max_layers = p_layer;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_max_layers, p_layer);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_max_layers, p_layer);
}
int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const {
@@ -1789,7 +1789,7 @@ int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const {
void BaseMaterial3D::set_heightmap_deep_parallax_flip_tangent(bool p_flip) {
heightmap_parallax_flip_tangent = p_flip;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1));
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1));
}
bool BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent() const {
@@ -1800,7 +1800,7 @@ bool BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent() const {
void BaseMaterial3D::set_heightmap_deep_parallax_flip_binormal(bool p_flip) {
heightmap_parallax_flip_binormal = p_flip;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1));
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1));
}
bool BaseMaterial3D::get_heightmap_deep_parallax_flip_binormal() const {
@@ -1820,7 +1820,7 @@ bool BaseMaterial3D::is_grow_enabled() const {
void BaseMaterial3D::set_alpha_scissor_threshold(float p_threshold) {
alpha_scissor_threshold = p_threshold;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_threshold);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_threshold);
}
float BaseMaterial3D::get_alpha_scissor_threshold() const {
@@ -1830,7 +1830,7 @@ float BaseMaterial3D::get_alpha_scissor_threshold() const {
void BaseMaterial3D::set_grow(float p_grow) {
grow = p_grow;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow);
}
float BaseMaterial3D::get_grow() const {
@@ -1853,7 +1853,7 @@ static Plane _get_texture_mask(BaseMaterial3D::TextureChannel p_channel) {
void BaseMaterial3D::set_metallic_texture_channel(TextureChannel p_channel) {
ERR_FAIL_INDEX(p_channel, 5);
metallic_texture_channel = p_channel;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel));
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel));
}
BaseMaterial3D::TextureChannel BaseMaterial3D::get_metallic_texture_channel() const {
@@ -1875,7 +1875,7 @@ void BaseMaterial3D::set_ao_texture_channel(TextureChannel p_channel) {
ERR_FAIL_INDEX(p_channel, 5);
ao_texture_channel = p_channel;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel));
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel));
}
BaseMaterial3D::TextureChannel BaseMaterial3D::get_ao_texture_channel() const {
@@ -1886,7 +1886,7 @@ void BaseMaterial3D::set_refraction_texture_channel(TextureChannel p_channel) {
ERR_FAIL_INDEX(p_channel, 5);
refraction_texture_channel = p_channel;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel));
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel));
}
BaseMaterial3D::TextureChannel BaseMaterial3D::get_refraction_texture_channel() const {
@@ -1954,7 +1954,7 @@ bool BaseMaterial3D::is_proximity_fade_enabled() const {
void BaseMaterial3D::set_proximity_fade_distance(float p_distance) {
proximity_fade_distance = p_distance;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance);
}
float BaseMaterial3D::get_proximity_fade_distance() const {
@@ -1975,7 +1975,7 @@ BaseMaterial3D::DistanceFadeMode BaseMaterial3D::get_distance_fade() const {
void BaseMaterial3D::set_distance_fade_max_distance(float p_distance) {
distance_fade_max_distance = p_distance;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance);
}
float BaseMaterial3D::get_distance_fade_max_distance() const {
@@ -1985,7 +1985,7 @@ float BaseMaterial3D::get_distance_fade_max_distance() const {
void BaseMaterial3D::set_distance_fade_min_distance(float p_distance) {
distance_fade_min_distance = p_distance;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance);
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance);
}
float BaseMaterial3D::get_distance_fade_min_distance() const {
@@ -2561,11 +2561,11 @@ BaseMaterial3D::~BaseMaterial3D() {
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);
+ RS::get_singleton()->free(shader_map[current_key].shader);
shader_map.erase(current_key);
}
- VS::get_singleton()->material_set_shader(_get_material(), RID());
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
}
}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index fc77226fb9..0c9352baf4 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -35,8 +35,8 @@
#include "core/self_list.h"
#include "scene/resources/shader.h"
#include "scene/resources/texture.h"
-#include "servers/visual/shader_language.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/shader_language.h"
+#include "servers/rendering_server.h"
class Material : public Resource {
@@ -57,8 +57,8 @@ protected:
public:
enum {
- RENDER_PRIORITY_MAX = VS::MATERIAL_RENDER_PRIORITY_MAX,
- RENDER_PRIORITY_MIN = VS::MATERIAL_RENDER_PRIORITY_MIN,
+ RENDER_PRIORITY_MAX = RS::MATERIAL_RENDER_PRIORITY_MAX,
+ RENDER_PRIORITY_MIN = RS::MATERIAL_RENDER_PRIORITY_MIN,
};
void set_next_pass(const Ref<Material> &p_pass);
Ref<Material> get_next_pass() const;
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index f93b7ced98..b37b7f9751 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -31,8 +31,8 @@
#include "mesh.h"
#include "core/pair.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
#include "surface_tool.h"
#include <stdlib.h>
@@ -169,20 +169,20 @@ Vector<Face3> Mesh::get_faces() const {
/*
for (int i=0;i<surfaces.size();i++) {
- if (VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != VisualServer::PRIMITIVE_TRIANGLES )
+ if (RenderingServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != RenderingServer::PRIMITIVE_TRIANGLES )
continue;
Vector<int> indices;
Vector<Vector3> vertices;
- vertices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_VERTEX);
+ vertices=RenderingServer::get_singleton()->mesh_surface_get_array(mesh, i,RenderingServer::ARRAY_VERTEX);
- int len=VisualServer::get_singleton()->mesh_surface_get_array_index_len(mesh, i);
+ int len=RenderingServer::get_singleton()->mesh_surface_get_array_index_len(mesh, i);
bool has_indices;
if (len>0) {
- indices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_INDEX);
+ indices=RenderingServer::get_singleton()->mesh_surface_get_array(mesh, i,RenderingServer::ARRAY_INDEX);
has_indices=true;
} else {
@@ -226,28 +226,28 @@ Vector<Face3> Mesh::get_faces() const {
*/
}
-Ref<Shape> Mesh::create_convex_shape() const {
+Ref<Shape3D> Mesh::create_convex_shape() const {
Vector<Vector3> vertices;
for (int i = 0; i < get_surface_count(); i++) {
Array a = surface_get_arrays(i);
- ERR_FAIL_COND_V(a.empty(), Ref<ConvexPolygonShape>());
+ ERR_FAIL_COND_V(a.empty(), Ref<ConvexPolygonShape3D>());
Vector<Vector3> v = a[ARRAY_VERTEX];
vertices.append_array(v);
}
- Ref<ConvexPolygonShape> shape = memnew(ConvexPolygonShape);
+ Ref<ConvexPolygonShape3D> shape = memnew(ConvexPolygonShape3D);
shape->set_points(vertices);
return shape;
}
-Ref<Shape> Mesh::create_trimesh_shape() const {
+Ref<Shape3D> Mesh::create_trimesh_shape() const {
Vector<Face3> faces = get_faces();
if (faces.size() == 0)
- return Ref<Shape>();
+ return Ref<Shape3D>();
Vector<Vector3> face_points;
face_points.resize(faces.size() * 3);
@@ -260,7 +260,7 @@ Ref<Shape> Mesh::create_trimesh_shape() const {
face_points.set(i + 2, f.vertex[2]);
}
- Ref<ConcavePolygonShape> shape = memnew(ConcavePolygonShape);
+ Ref<ConcavePolygonShape3D> shape = memnew(ConcavePolygonShape3D);
shape->set_faces(face_points);
return shape;
}
@@ -372,7 +372,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
ERR_FAIL_COND_V(arrays.size() != ARRAY_MAX, Ref<ArrayMesh>());
{
- int *ir;
+ int *ir = NULL;
Vector<int> indices = arrays[ARRAY_INDEX];
bool has_indices = false;
Vector<Vector3> vertices = arrays[ARRAY_VERTEX];
@@ -541,15 +541,15 @@ void Mesh::clear_cache() const {
debug_lines.clear();
}
-Vector<Ref<Shape>> Mesh::convex_decompose() const {
+Vector<Ref<Shape3D>> Mesh::convex_decompose() const {
- ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape>>());
+ ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape3D>>());
const Vector<Face3> faces = get_faces();
Vector<Vector<Face3>> decomposed = convex_composition_function(faces);
- Vector<Ref<Shape>> ret;
+ Vector<Ref<Shape3D>> ret;
for (int i = 0; i < decomposed.size(); i++) {
Set<Vector3> points;
@@ -569,7 +569,7 @@ Vector<Ref<Shape>> Mesh::convex_decompose() const {
}
}
- Ref<ConvexPolygonShape> shape;
+ Ref<ConvexPolygonShape3D> shape;
shape.instance();
shape->set_points(convex_points);
ret.push_back(shape);
@@ -846,7 +846,7 @@ Array ArrayMesh::_get_surfaces() const {
Array ret;
for (int i = 0; i < surfaces.size(); i++) {
- VisualServer::SurfaceData surface = VS::get_singleton()->mesh_get_surface(mesh, i);
+ RenderingServer::SurfaceData surface = RS::get_singleton()->mesh_get_surface(mesh, i);
Dictionary data;
data["format"] = surface.format;
data["primitive"] = surface.primitive;
@@ -902,20 +902,20 @@ Array ArrayMesh::_get_surfaces() const {
void ArrayMesh::_create_if_empty() const {
if (!mesh.is_valid()) {
- mesh = VS::get_singleton()->mesh_create();
- VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)blend_shape_mode);
+ mesh = RS::get_singleton()->mesh_create();
+ RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)blend_shape_mode);
}
}
void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
- Vector<VS::SurfaceData> surface_data;
+ Vector<RS::SurfaceData> surface_data;
Vector<Ref<Material>> surface_materials;
Vector<String> surface_names;
Vector<bool> surface_2d;
for (int i = 0; i < p_surfaces.size(); i++) {
- VS::SurfaceData surface;
+ RS::SurfaceData surface;
Dictionary d = p_surfaces[i];
ERR_FAIL_COND(!d.has("format"));
ERR_FAIL_COND(!d.has("primitive"));
@@ -923,7 +923,7 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
ERR_FAIL_COND(!d.has("vertex_count"));
ERR_FAIL_COND(!d.has("aabb"));
surface.format = d["format"];
- surface.primitive = VS::PrimitiveType(int(d["primitive"]));
+ surface.primitive = RS::PrimitiveType(int(d["primitive"]));
surface.vertex_data = d["vertex_data"];
surface.vertex_count = d["vertex_count"];
surface.aabb = d["aabb"];
@@ -938,7 +938,7 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
Array lods = d["lods"];
ERR_FAIL_COND(lods.size() & 1); //must be even
for (int j = 0; j < lods.size(); j += 2) {
- VS::SurfaceData::LOD lod;
+ RS::SurfaceData::LOD lod;
lod.edge_length = lods[j + 0];
lod.index_data = lods[j + 1];
surface.lods.push_back(lod);
@@ -993,15 +993,15 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
if (mesh.is_valid()) {
//if mesh exists, it needs to be updated
- VS::get_singleton()->mesh_clear(mesh);
+ RS::get_singleton()->mesh_clear(mesh);
for (int i = 0; i < surface_data.size(); i++) {
- VS::get_singleton()->mesh_add_surface(mesh, surface_data[i]);
+ RS::get_singleton()->mesh_add_surface(mesh, surface_data[i]);
}
} else {
// if mesh does not exist (first time this is loaded, most likely),
// we can create it with a single call, which is a lot more efficient and thread friendly
- mesh = VS::get_singleton()->mesh_create_from_surfaces(surface_data);
- VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)blend_shape_mode);
+ mesh = RS::get_singleton()->mesh_create_from_surfaces(surface_data);
+ RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)blend_shape_mode);
}
surfaces.clear();
@@ -1102,7 +1102,7 @@ void ArrayMesh::_recompute_aabb() {
#ifndef _MSC_VER
#warning need to add binding to add_surface using future MeshSurfaceData object
#endif
-void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<VS::SurfaceData::LOD> &p_lods) {
+void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<RS::SurfaceData::LOD> &p_lods) {
_create_if_empty();
@@ -1117,9 +1117,9 @@ void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const
surfaces.push_back(s);
_recompute_aabb();
- VS::SurfaceData sd;
+ RS::SurfaceData sd;
sd.format = p_format;
- sd.primitive = VS::PrimitiveType(p_primitive);
+ sd.primitive = RS::PrimitiveType(p_primitive);
sd.aabb = p_aabb;
sd.vertex_count = p_vertex_count;
sd.vertex_data = p_array;
@@ -1129,7 +1129,7 @@ void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const
sd.bone_aabbs = p_bone_aabb;
sd.lods = p_lods;
- VisualServer::get_singleton()->mesh_add_surface(mesh, sd);
+ RenderingServer::get_singleton()->mesh_add_surface(mesh, sd);
clear_cache();
_change_notify();
@@ -1140,9 +1140,9 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array &
ERR_FAIL_COND(p_arrays.size() != ARRAY_MAX);
- VS::SurfaceData surface;
+ RS::SurfaceData surface;
- Error err = VS::get_singleton()->mesh_create_surface_data_from_arrays(&surface, (VisualServer::PrimitiveType)p_primitive, p_arrays, p_blend_shapes, p_lods, p_flags);
+ Error err = RS::get_singleton()->mesh_create_surface_data_from_arrays(&surface, (RenderingServer::PrimitiveType)p_primitive, p_arrays, p_blend_shapes, p_lods, p_flags);
ERR_FAIL_COND(err != OK);
/* print_line("format: " + itos(surface.format));
@@ -1159,16 +1159,16 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array &
Array ArrayMesh::surface_get_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
- return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface);
+ return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface);
}
Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
- return VisualServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface);
+ return RenderingServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface);
}
Dictionary ArrayMesh::surface_get_lods(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Dictionary());
- return VisualServer::get_singleton()->mesh_surface_get_lods(mesh, p_surface);
+ return RenderingServer::get_singleton()->mesh_surface_get_lods(mesh, p_surface);
}
int ArrayMesh::get_surface_count() const {
@@ -1193,7 +1193,7 @@ void ArrayMesh::add_blend_shape(const StringName &p_name) {
}
blend_shapes.push_back(name);
- //VS::get_singleton()->mesh_set_blend_shape_count(mesh, blend_shapes.size());
+ //RS::get_singleton()->mesh_set_blend_shape_count(mesh, blend_shapes.size());
}
int ArrayMesh::get_blend_shape_count() const {
@@ -1215,7 +1215,7 @@ void ArrayMesh::set_blend_shape_mode(BlendShapeMode p_mode) {
blend_shape_mode = p_mode;
if (mesh.is_valid()) {
- VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)p_mode);
+ RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)p_mode);
}
}
@@ -1254,7 +1254,7 @@ void ArrayMesh::surface_set_material(int p_idx, const Ref<Material> &p_material)
if (surfaces[p_idx].material == p_material)
return;
surfaces.write[p_idx].material = p_material;
- VisualServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null() ? RID() : p_material->get_rid());
+ RenderingServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null() ? RID() : p_material->get_rid());
_change_notify("material");
emit_changed();
@@ -1286,7 +1286,7 @@ String ArrayMesh::surface_get_name(int p_idx) const {
void ArrayMesh::surface_update_region(int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
ERR_FAIL_INDEX(p_surface, surfaces.size());
- VS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data);
+ RS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data);
emit_changed();
}
@@ -1318,7 +1318,7 @@ void ArrayMesh::clear_surfaces() {
if (!mesh.is_valid()) {
return;
}
- VS::get_singleton()->mesh_clear(mesh);
+ RS::get_singleton()->mesh_clear(mesh);
surfaces.clear();
aabb = AABB();
}
@@ -1327,7 +1327,7 @@ void ArrayMesh::set_custom_aabb(const AABB &p_custom) {
_create_if_empty();
custom_aabb = p_custom;
- VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
+ RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
emit_changed();
}
@@ -1609,7 +1609,7 @@ void ArrayMesh::_bind_methods() {
}
void ArrayMesh::reload_from_file() {
- VisualServer::get_singleton()->mesh_clear(mesh);
+ RenderingServer::get_singleton()->mesh_clear(mesh);
surfaces.clear();
clear_blend_shapes();
clear_cache();
@@ -1622,13 +1622,13 @@ void ArrayMesh::reload_from_file() {
ArrayMesh::ArrayMesh() {
//mesh is now created on demand
- //mesh = VisualServer::get_singleton()->mesh_create();
+ //mesh = RenderingServer::get_singleton()->mesh_create();
blend_shape_mode = BLEND_SHAPE_MODE_RELATIVE;
}
ArrayMesh::~ArrayMesh() {
if (mesh.is_valid()) {
- VisualServer::get_singleton()->free(mesh);
+ RenderingServer::get_singleton()->free(mesh);
}
}
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index e0cc214301..25a9722046 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -35,8 +35,8 @@
#include "core/math/triangle_mesh.h"
#include "core/resource.h"
#include "scene/resources/material.h"
-#include "scene/resources/shape.h"
-#include "servers/visual_server.h"
+#include "scene/resources/shape_3d.h"
+#include "servers/rendering_server.h"
class Mesh : public Resource {
GDCLASS(Mesh, Resource);
@@ -51,22 +51,22 @@ protected:
public:
enum {
- NO_INDEX_ARRAY = VisualServer::NO_INDEX_ARRAY,
- ARRAY_WEIGHTS_SIZE = VisualServer::ARRAY_WEIGHTS_SIZE
+ NO_INDEX_ARRAY = RenderingServer::NO_INDEX_ARRAY,
+ ARRAY_WEIGHTS_SIZE = RenderingServer::ARRAY_WEIGHTS_SIZE
};
enum ArrayType {
- ARRAY_VERTEX = VisualServer::ARRAY_VERTEX,
- ARRAY_NORMAL = VisualServer::ARRAY_NORMAL,
- ARRAY_TANGENT = VisualServer::ARRAY_TANGENT,
- ARRAY_COLOR = VisualServer::ARRAY_COLOR,
- ARRAY_TEX_UV = VisualServer::ARRAY_TEX_UV,
- ARRAY_TEX_UV2 = VisualServer::ARRAY_TEX_UV2,
- ARRAY_BONES = VisualServer::ARRAY_BONES,
- ARRAY_WEIGHTS = VisualServer::ARRAY_WEIGHTS,
- ARRAY_INDEX = VisualServer::ARRAY_INDEX,
- ARRAY_MAX = VisualServer::ARRAY_MAX
+ ARRAY_VERTEX = RenderingServer::ARRAY_VERTEX,
+ ARRAY_NORMAL = RenderingServer::ARRAY_NORMAL,
+ ARRAY_TANGENT = RenderingServer::ARRAY_TANGENT,
+ ARRAY_COLOR = RenderingServer::ARRAY_COLOR,
+ ARRAY_TEX_UV = RenderingServer::ARRAY_TEX_UV,
+ ARRAY_TEX_UV2 = RenderingServer::ARRAY_TEX_UV2,
+ ARRAY_BONES = RenderingServer::ARRAY_BONES,
+ ARRAY_WEIGHTS = RenderingServer::ARRAY_WEIGHTS,
+ ARRAY_INDEX = RenderingServer::ARRAY_INDEX,
+ ARRAY_MAX = RenderingServer::ARRAY_MAX
};
@@ -98,18 +98,18 @@ public:
};
enum PrimitiveType {
- PRIMITIVE_POINTS = VisualServer::PRIMITIVE_POINTS,
- PRIMITIVE_LINES = VisualServer::PRIMITIVE_LINES,
- PRIMITIVE_LINE_STRIP = VisualServer::PRIMITIVE_LINE_STRIP,
- PRIMITIVE_TRIANGLES = VisualServer::PRIMITIVE_TRIANGLES,
- PRIMITIVE_TRIANGLE_STRIP = VisualServer::PRIMITIVE_TRIANGLE_STRIP,
- PRIMITIVE_MAX = VisualServer::PRIMITIVE_MAX,
+ PRIMITIVE_POINTS = RenderingServer::PRIMITIVE_POINTS,
+ PRIMITIVE_LINES = RenderingServer::PRIMITIVE_LINES,
+ PRIMITIVE_LINE_STRIP = RenderingServer::PRIMITIVE_LINE_STRIP,
+ PRIMITIVE_TRIANGLES = RenderingServer::PRIMITIVE_TRIANGLES,
+ PRIMITIVE_TRIANGLE_STRIP = RenderingServer::PRIMITIVE_TRIANGLE_STRIP,
+ PRIMITIVE_MAX = RenderingServer::PRIMITIVE_MAX,
};
enum BlendShapeMode {
- BLEND_SHAPE_MODE_NORMALIZED = VS::BLEND_SHAPE_MODE_NORMALIZED,
- BLEND_SHAPE_MODE_RELATIVE = VS::BLEND_SHAPE_MODE_RELATIVE,
+ BLEND_SHAPE_MODE_NORMALIZED = RS::BLEND_SHAPE_MODE_NORMALIZED,
+ BLEND_SHAPE_MODE_RELATIVE = RS::BLEND_SHAPE_MODE_RELATIVE,
};
virtual int get_surface_count() const = 0;
@@ -131,8 +131,8 @@ public:
void generate_debug_mesh_lines(Vector<Vector3> &r_lines);
void generate_debug_mesh_indices(Vector<Vector3> &r_points);
- Ref<Shape> create_trimesh_shape() const;
- Ref<Shape> create_convex_shape() const;
+ Ref<Shape3D> create_trimesh_shape() const;
+ Ref<Shape3D> create_convex_shape() const;
Ref<Mesh> create_outline(float p_margin) const;
@@ -146,7 +146,7 @@ public:
static ConvexDecompositionFunc convex_composition_function;
- Vector<Ref<Shape>> convex_decompose() const;
+ Vector<Ref<Shape3D>> convex_decompose() const;
Mesh();
};
@@ -193,7 +193,7 @@ protected:
public:
void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_flags = ARRAY_COMPRESS_DEFAULT);
- void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<VS::SurfaceData::LOD> &p_lods = Vector<VS::SurfaceData::LOD>());
+ void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<RS::SurfaceData::LOD> &p_lods = Vector<RS::SurfaceData::LOD>());
Array surface_get_arrays(int p_surface) const;
Array surface_get_blend_shape_arrays(int p_surface) const;
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index 675cfc6d64..8b7f8288b8 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -58,30 +58,30 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
const Vector3 *vr = varray.ptr();
- const Vector3 *nr;
+ const Vector3 *nr = NULL;
if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL)
nr = arrays[Mesh::ARRAY_NORMAL].operator Vector<Vector3>().ptr();
- const real_t *ta;
+ const real_t *ta = NULL;
if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL)
ta = arrays[Mesh::ARRAY_TANGENT].operator Vector<real_t>().ptr();
- const Vector2 *uv;
+ const Vector2 *uv = NULL;
if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL)
uv = arrays[Mesh::ARRAY_TEX_UV].operator Vector<Vector2>().ptr();
- const Vector2 *uv2;
+ const Vector2 *uv2 = NULL;
if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL)
uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator Vector<Vector2>().ptr();
- const Color *col;
+ const Color *col = NULL;
if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL)
col = arrays[Mesh::ARRAY_COLOR].operator Vector<Color>().ptr();
- const int *bo;
+ const int *bo = NULL;
if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL)
bo = arrays[Mesh::ARRAY_BONES].operator Vector<int>().ptr();
- const real_t *we;
+ const real_t *we = NULL;
if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL)
we = arrays[Mesh::ARRAY_WEIGHTS].operator Vector<real_t>().ptr();
@@ -202,43 +202,43 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
v.resize(vcount);
Vector3 *vr = v.ptrw();
- Vector3 *nr;
+ Vector3 *nr = NULL;
if (format & Mesh::ARRAY_FORMAT_NORMAL) {
n.resize(vcount);
nr = n.ptrw();
}
- real_t *ta;
+ real_t *ta = NULL;
if (format & Mesh::ARRAY_FORMAT_TANGENT) {
t.resize(vcount * 4);
ta = t.ptrw();
}
- Vector2 *uv;
+ Vector2 *uv = NULL;
if (format & Mesh::ARRAY_FORMAT_TEX_UV) {
u.resize(vcount);
uv = u.ptrw();
}
- Vector2 *uv2;
+ Vector2 *uv2 = NULL;
if (format & Mesh::ARRAY_FORMAT_TEX_UV2) {
u2.resize(vcount);
uv2 = u2.ptrw();
}
- Color *col;
+ Color *col = NULL;
if (format & Mesh::ARRAY_FORMAT_COLOR) {
c.resize(vcount);
col = c.ptrw();
}
- int *bo;
+ int *bo = NULL;
if (format & Mesh::ARRAY_FORMAT_BONES) {
b.resize(vcount * 4);
bo = b.ptrw();
}
- real_t *we;
+ real_t *we = NULL;
if (format & Mesh::ARRAY_FORMAT_WEIGHTS) {
w.resize(vcount * 4);
we = w.ptrw();
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index b256e86b96..55001f2545 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -34,8 +34,8 @@
#include "core/map.h"
#include "core/resource.h"
#include "mesh.h"
-#include "scene/3d/navigation_region.h"
-#include "shape.h"
+#include "scene/3d/navigation_region_3d.h"
+#include "shape_3d.h"
class MeshLibrary : public Resource {
@@ -44,7 +44,7 @@ class MeshLibrary : public Resource {
public:
struct ShapeData {
- Ref<Shape> shape;
+ Ref<Shape3D> shape;
Transform local_transform;
};
struct Item {
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index aa8be326f5..ce561bfaaf 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -30,7 +30,7 @@
#include "multimesh.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#ifndef DISABLE_DEPRECATED
// Kept for compatibility from 3.x to 4.0.
@@ -198,20 +198,20 @@ Vector<Color> MultiMesh::_get_custom_data_array() const {
#endif // DISABLE_DEPRECATED
void MultiMesh::set_buffer(const Vector<float> &p_buffer) {
- VS::get_singleton()->multimesh_set_buffer(multimesh, p_buffer);
+ RS::get_singleton()->multimesh_set_buffer(multimesh, p_buffer);
}
Vector<float> MultiMesh::get_buffer() const {
- return VS::get_singleton()->multimesh_get_buffer(multimesh);
+ return RS::get_singleton()->multimesh_get_buffer(multimesh);
}
void MultiMesh::set_mesh(const Ref<Mesh> &p_mesh) {
mesh = p_mesh;
if (!mesh.is_null())
- VisualServer::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
+ RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
else
- VisualServer::get_singleton()->multimesh_set_mesh(multimesh, RID());
+ RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, RID());
}
Ref<Mesh> MultiMesh::get_mesh() const {
@@ -221,7 +221,7 @@ Ref<Mesh> MultiMesh::get_mesh() const {
void MultiMesh::set_instance_count(int p_count) {
ERR_FAIL_COND(p_count < 0);
- VisualServer::get_singleton()->multimesh_allocate(multimesh, p_count, VS::MultimeshTransformFormat(transform_format), use_colors, use_custom_data);
+ RenderingServer::get_singleton()->multimesh_allocate(multimesh, p_count, RS::MultimeshTransformFormat(transform_format), use_colors, use_custom_data);
instance_count = p_count;
}
int MultiMesh::get_instance_count() const {
@@ -232,7 +232,7 @@ int MultiMesh::get_instance_count() const {
void MultiMesh::set_visible_instance_count(int p_count) {
ERR_FAIL_COND(p_count < -1);
ERR_FAIL_COND(p_count > instance_count);
- VisualServer::get_singleton()->multimesh_set_visible_instances(multimesh, p_count);
+ RenderingServer::get_singleton()->multimesh_set_visible_instances(multimesh, p_count);
visible_instance_count = p_count;
}
int MultiMesh::get_visible_instance_count() const {
@@ -242,45 +242,45 @@ int MultiMesh::get_visible_instance_count() const {
void MultiMesh::set_instance_transform(int p_instance, const Transform &p_transform) {
- VisualServer::get_singleton()->multimesh_instance_set_transform(multimesh, p_instance, p_transform);
+ RenderingServer::get_singleton()->multimesh_instance_set_transform(multimesh, p_instance, p_transform);
}
void MultiMesh::set_instance_transform_2d(int p_instance, const Transform2D &p_transform) {
- VisualServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform);
+ RenderingServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform);
}
Transform MultiMesh::get_instance_transform(int p_instance) const {
- return VisualServer::get_singleton()->multimesh_instance_get_transform(multimesh, p_instance);
+ return RenderingServer::get_singleton()->multimesh_instance_get_transform(multimesh, p_instance);
}
Transform2D MultiMesh::get_instance_transform_2d(int p_instance) const {
- return VisualServer::get_singleton()->multimesh_instance_get_transform_2d(multimesh, p_instance);
+ return RenderingServer::get_singleton()->multimesh_instance_get_transform_2d(multimesh, p_instance);
}
void MultiMesh::set_instance_color(int p_instance, const Color &p_color) {
- VisualServer::get_singleton()->multimesh_instance_set_color(multimesh, p_instance, p_color);
+ RenderingServer::get_singleton()->multimesh_instance_set_color(multimesh, p_instance, p_color);
}
Color MultiMesh::get_instance_color(int p_instance) const {
- return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance);
+ return RenderingServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance);
}
void MultiMesh::set_instance_custom_data(int p_instance, const Color &p_custom_data) {
- VisualServer::get_singleton()->multimesh_instance_set_custom_data(multimesh, p_instance, p_custom_data);
+ RenderingServer::get_singleton()->multimesh_instance_set_custom_data(multimesh, p_instance, p_custom_data);
}
Color MultiMesh::get_instance_custom_data(int p_instance) const {
- return VisualServer::get_singleton()->multimesh_instance_get_custom_data(multimesh, p_instance);
+ return RenderingServer::get_singleton()->multimesh_instance_get_custom_data(multimesh, p_instance);
}
AABB MultiMesh::get_aabb() const {
- return VisualServer::get_singleton()->multimesh_get_aabb(multimesh);
+ return RenderingServer::get_singleton()->multimesh_get_aabb(multimesh);
}
RID MultiMesh::get_rid() const {
@@ -375,7 +375,7 @@ void MultiMesh::_bind_methods() {
MultiMesh::MultiMesh() {
- multimesh = VisualServer::get_singleton()->multimesh_create();
+ multimesh = RenderingServer::get_singleton()->multimesh_create();
use_colors = false;
use_custom_data = false;
transform_format = TRANSFORM_2D;
@@ -385,5 +385,5 @@ MultiMesh::MultiMesh() {
MultiMesh::~MultiMesh() {
- VisualServer::get_singleton()->free(multimesh);
+ RenderingServer::get_singleton()->free(multimesh);
}
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 8ca30a5b88..c1e52bc981 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -32,7 +32,7 @@
#define MULTIMESH_H
#include "scene/resources/mesh.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
class MultiMesh : public Resource {
@@ -41,8 +41,8 @@ class MultiMesh : public Resource {
public:
enum TransformFormat {
- TRANSFORM_2D = VS::MULTIMESH_TRANSFORM_2D,
- TRANSFORM_3D = VS::MULTIMESH_TRANSFORM_3D
+ TRANSFORM_2D = RS::MULTIMESH_TRANSFORM_2D,
+ TRANSFORM_3D = RS::MULTIMESH_TRANSFORM_3D
};
private:
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 7059682904..549c29a7f3 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -35,7 +35,7 @@
#include "core/io/resource_loader.h"
#include "core/project_settings.h"
#include "scene/2d/node_2d.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/node_3d.h"
#include "scene/gui/control.h"
#include "scene/main/instance_placeholder.h"
@@ -159,8 +159,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
WARN_PRINT(String("Warning node of type " + snames[n.type].operator String() + " does not exist.").ascii().get_data());
if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) {
- if (Object::cast_to<Spatial>(ret_nodes[n.parent])) {
- obj = memnew(Spatial);
+ if (Object::cast_to<Node3D>(ret_nodes[n.parent])) {
+ obj = memnew(Node3D);
} else if (Object::cast_to<Control>(ret_nodes[n.parent])) {
obj = memnew(Control);
} else if (Object::cast_to<Node2D>(ret_nodes[n.parent])) {
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index f18e8956f1..63766c1756 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -121,7 +121,7 @@ void ParticlesMaterial::_update_shader() {
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);
+ RS::get_singleton()->free(shader_map[current_key].shader);
shader_map.erase(current_key);
}
}
@@ -130,7 +130,7 @@ void ParticlesMaterial::_update_shader() {
if (shader_map.has(mk)) {
- VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
shader_map[mk].users++;
return;
}
@@ -592,14 +592,14 @@ void ParticlesMaterial::_update_shader() {
code += "\n";
ShaderData shader_data;
- shader_data.shader = VS::get_singleton()->shader_create();
+ shader_data.shader = RS::get_singleton()->shader_create();
shader_data.users = 1;
- VS::get_singleton()->shader_set_code(shader_data.shader, code);
+ RS::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);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader);
}
void ParticlesMaterial::flush_changes() {
@@ -631,7 +631,7 @@ bool ParticlesMaterial::_is_shader_dirty() const {
void ParticlesMaterial::set_direction(Vector3 p_direction) {
direction = p_direction;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->direction, direction);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->direction, direction);
}
Vector3 ParticlesMaterial::get_direction() const {
@@ -642,7 +642,7 @@ Vector3 ParticlesMaterial::get_direction() const {
void ParticlesMaterial::set_spread(float p_spread) {
spread = p_spread;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread);
}
float ParticlesMaterial::get_spread() const {
@@ -653,7 +653,7 @@ float ParticlesMaterial::get_spread() const {
void ParticlesMaterial::set_flatness(float p_flatness) {
flatness = p_flatness;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness);
}
float ParticlesMaterial::get_flatness() const {
@@ -668,40 +668,40 @@ void ParticlesMaterial::set_param(Parameter p_param, float p_value) {
switch (p_param) {
case PARAM_INITIAL_LINEAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity, p_value);
} break;
case PARAM_ANGULAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity, p_value);
} break;
case PARAM_ORBIT_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity, p_value);
} break;
case PARAM_LINEAR_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel, p_value);
} break;
case PARAM_RADIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel, p_value);
} break;
case PARAM_TANGENTIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel, p_value);
} break;
case PARAM_DAMPING: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->damping, p_value);
} break;
case PARAM_ANGLE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle, p_value);
} break;
case PARAM_SCALE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->scale, p_value);
} break;
case PARAM_HUE_VARIATION: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation, p_value);
} break;
case PARAM_ANIM_SPEED: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed, p_value);
} break;
case PARAM_ANIM_OFFSET: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value);
} break;
case PARAM_MAX: break; // Can't happen, but silences warning
}
@@ -721,40 +721,40 @@ void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) {
switch (p_param) {
case PARAM_INITIAL_LINEAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity_random, p_value);
} break;
case PARAM_ANGULAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_random, p_value);
} break;
case PARAM_ORBIT_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_random, p_value);
} break;
case PARAM_LINEAR_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_random, p_value);
} break;
case PARAM_RADIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_random, p_value);
} break;
case PARAM_TANGENTIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_random, p_value);
} break;
case PARAM_DAMPING: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_random, p_value);
} break;
case PARAM_ANGLE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle_random, p_value);
} break;
case PARAM_SCALE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_random, p_value);
} break;
case PARAM_HUE_VARIATION: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_random, p_value);
} break;
case PARAM_ANIM_SPEED: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_random, p_value);
} break;
case PARAM_ANIM_OFFSET: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value);
} break;
case PARAM_MAX: break; // Can't happen, but silences warning
}
@@ -786,47 +786,47 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D
//do none for this one
} break;
case PARAM_ANGULAR_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_texture, p_texture);
_adjust_curve_range(p_texture, -360, 360);
} break;
case PARAM_ORBIT_VELOCITY: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, p_texture);
_adjust_curve_range(p_texture, -500, 500);
} break;
case PARAM_LINEAR_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_texture, p_texture);
_adjust_curve_range(p_texture, -200, 200);
} break;
case PARAM_RADIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_texture, p_texture);
_adjust_curve_range(p_texture, -200, 200);
} break;
case PARAM_TANGENTIAL_ACCEL: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_texture, p_texture);
_adjust_curve_range(p_texture, -200, 200);
} break;
case PARAM_DAMPING: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_texture, p_texture);
_adjust_curve_range(p_texture, 0, 100);
} break;
case PARAM_ANGLE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angle_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angle_texture, p_texture);
_adjust_curve_range(p_texture, -360, 360);
} break;
case PARAM_SCALE: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_texture, p_texture);
_adjust_curve_range(p_texture, 0, 1);
} break;
case PARAM_HUE_VARIATION: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_texture, p_texture);
_adjust_curve_range(p_texture, -1, 1);
} break;
case PARAM_ANIM_SPEED: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_texture, p_texture);
_adjust_curve_range(p_texture, 0, 200);
} break;
case PARAM_ANIM_OFFSET: {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture);
} break;
case PARAM_MAX: break; // Can't happen, but silences warning
}
@@ -842,7 +842,7 @@ Ref<Texture2D> ParticlesMaterial::get_param_texture(Parameter p_param) const {
void ParticlesMaterial::set_color(const Color &p_color) {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color);
color = p_color;
}
@@ -854,7 +854,7 @@ Color ParticlesMaterial::get_color() const {
void ParticlesMaterial::set_color_ramp(const Ref<Texture2D> &p_texture) {
color_ramp = p_texture;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture);
_queue_shader_change();
_change_notify();
}
@@ -888,38 +888,38 @@ void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) {
void ParticlesMaterial::set_emission_sphere_radius(float p_radius) {
emission_sphere_radius = p_radius;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius);
}
void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) {
emission_box_extents = p_extents;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents);
}
void ParticlesMaterial::set_emission_point_texture(const Ref<Texture2D> &p_points) {
emission_point_texture = p_points;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points);
}
void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture2D> &p_normals) {
emission_normal_texture = p_normals;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals);
}
void ParticlesMaterial::set_emission_color_texture(const Ref<Texture2D> &p_colors) {
emission_color_texture = p_colors;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors);
_queue_shader_change();
}
void ParticlesMaterial::set_emission_point_count(int p_count) {
emission_point_count = p_count;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count);
}
ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const {
@@ -957,7 +957,7 @@ int ParticlesMaterial::get_emission_point_count() const {
void ParticlesMaterial::set_trail_divisor(int p_divisor) {
trail_divisor = p_divisor;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
}
int ParticlesMaterial::get_trail_divisor() const {
@@ -974,7 +974,7 @@ void ParticlesMaterial::set_trail_size_modifier(const Ref<CurveTexture> &p_trail
curve->ensure_default_setup();
}
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_size_modifier, curve);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_size_modifier, curve);
_queue_shader_change();
}
@@ -986,7 +986,7 @@ Ref<CurveTexture> ParticlesMaterial::get_trail_size_modifier() const {
void ParticlesMaterial::set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier) {
trail_color_modifier = p_trail_color_modifier;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier);
_queue_shader_change();
}
@@ -1002,7 +1002,7 @@ void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) {
if (gset == Vector3()) {
gset = Vector3(0, -0.000001, 0); //as gravity is used as upvector in some calculations
}
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->gravity, gset);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->gravity, gset);
}
Vector3 ParticlesMaterial::get_gravity() const {
@@ -1013,7 +1013,7 @@ Vector3 ParticlesMaterial::get_gravity() const {
void ParticlesMaterial::set_lifetime_randomness(float p_lifetime) {
lifetime_randomness = p_lifetime;
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->lifetime_randomness, lifetime_randomness);
+ RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->lifetime_randomness, lifetime_randomness);
}
float ParticlesMaterial::get_lifetime_randomness() const {
@@ -1280,10 +1280,10 @@ ParticlesMaterial::~ParticlesMaterial() {
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);
+ RS::get_singleton()->free(shader_map[current_key].shader);
shader_map.erase(current_key);
}
- VS::get_singleton()->material_set_shader(_get_material(), RID());
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
}
}
diff --git a/scene/resources/physics_material.h b/scene/resources/physics_material.h
index 2f7f4424b2..f4a77d9854 100644
--- a/scene/resources/physics_material.h
+++ b/scene/resources/physics_material.h
@@ -32,7 +32,7 @@
#define physics_material_override_H
#include "core/resource.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
class PhysicsMaterial : public Resource {
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 959ee214a2..0792af2143 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "primitive_meshes.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
/**
PrimitiveMesh
@@ -37,10 +37,10 @@
void PrimitiveMesh::_update() const {
Array arr;
- arr.resize(VS::ARRAY_MAX);
+ arr.resize(RS::ARRAY_MAX);
_create_mesh_array(arr);
- Vector<Vector3> points = arr[VS::ARRAY_VERTEX];
+ Vector<Vector3> points = arr[RS::ARRAY_VERTEX];
aabb = AABB();
@@ -57,10 +57,10 @@ void PrimitiveMesh::_update() const {
}
}
- Vector<int> indices = arr[VS::ARRAY_INDEX];
+ Vector<int> indices = arr[RS::ARRAY_INDEX];
if (flip_faces) {
- Vector<Vector3> normals = arr[VS::ARRAY_NORMAL];
+ Vector<Vector3> normals = arr[RS::ARRAY_NORMAL];
if (normals.size() && indices.size()) {
@@ -79,17 +79,17 @@ void PrimitiveMesh::_update() const {
SWAP(w[i + 0], w[i + 1]);
}
}
- arr[VS::ARRAY_NORMAL] = normals;
- arr[VS::ARRAY_INDEX] = indices;
+ arr[RS::ARRAY_NORMAL] = normals;
+ arr[RS::ARRAY_INDEX] = indices;
}
}
array_len = pc;
index_array_len = indices.size();
// in with the new
- VisualServer::get_singleton()->mesh_clear(mesh);
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh, (VisualServer::PrimitiveType)primitive_type, arr);
- VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());
+ RenderingServer::get_singleton()->mesh_clear(mesh);
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh, (RenderingServer::PrimitiveType)primitive_type, arr);
+ RenderingServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());
pending_request = false;
@@ -136,7 +136,7 @@ Array PrimitiveMesh::surface_get_arrays(int p_surface) const {
_update();
}
- return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, 0);
+ return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, 0);
}
Dictionary PrimitiveMesh::surface_get_lods(int p_surface) const {
@@ -150,7 +150,7 @@ Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const {
uint32_t PrimitiveMesh::surface_get_format(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, 0);
- return VS::ARRAY_FORMAT_VERTEX | VS::ARRAY_FORMAT_NORMAL | VS::ARRAY_FORMAT_TANGENT | VS::ARRAY_FORMAT_TEX_UV | VS::ARRAY_FORMAT_INDEX | VS::ARRAY_COMPRESS_DEFAULT;
+ return RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_TANGENT | RS::ARRAY_FORMAT_TEX_UV | RS::ARRAY_FORMAT_INDEX | RS::ARRAY_COMPRESS_DEFAULT;
}
Mesh::PrimitiveType PrimitiveMesh::surface_get_primitive_type(int p_idx) const {
@@ -215,7 +215,7 @@ void PrimitiveMesh::set_material(const Ref<Material> &p_material) {
material = p_material;
if (!pending_request) {
// just apply it, else it'll happen when _update is called.
- VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());
+ RenderingServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid());
_change_notify();
emit_changed();
};
@@ -232,7 +232,7 @@ Array PrimitiveMesh::get_mesh_arrays() const {
void PrimitiveMesh::set_custom_aabb(const AABB &p_custom) {
custom_aabb = p_custom;
- VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
+ RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
emit_changed();
}
@@ -254,7 +254,7 @@ PrimitiveMesh::PrimitiveMesh() {
flip_faces = false;
// defaults
- mesh = VisualServer::get_singleton()->mesh_create();
+ mesh = RenderingServer::get_singleton()->mesh_create();
// assume primitive triangles as the type, correct for all but one and it will change this :)
primitive_type = Mesh::PRIMITIVE_TRIANGLES;
@@ -267,7 +267,7 @@ PrimitiveMesh::PrimitiveMesh() {
}
PrimitiveMesh::~PrimitiveMesh() {
- VisualServer::get_singleton()->free(mesh);
+ RenderingServer::get_singleton()->free(mesh);
}
/**
@@ -413,11 +413,11 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
};
- p_arr[VS::ARRAY_VERTEX] = points;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
- p_arr[VS::ARRAY_INDEX] = indices;
+ p_arr[RS::ARRAY_VERTEX] = points;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_INDEX] = indices;
}
void CapsuleMesh::_bind_methods() {
@@ -670,11 +670,11 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
};
- p_arr[VS::ARRAY_VERTEX] = points;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
- p_arr[VS::ARRAY_INDEX] = indices;
+ p_arr[RS::ARRAY_VERTEX] = points;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_INDEX] = indices;
}
void CubeMesh::_bind_methods() {
@@ -871,11 +871,11 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
};
};
- p_arr[VS::ARRAY_VERTEX] = points;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
- p_arr[VS::ARRAY_INDEX] = indices;
+ p_arr[RS::ARRAY_VERTEX] = points;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_INDEX] = indices;
}
void CylinderMesh::_bind_methods() {
@@ -1010,11 +1010,11 @@ void PlaneMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
};
- p_arr[VS::ARRAY_VERTEX] = points;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
- p_arr[VS::ARRAY_INDEX] = indices;
+ p_arr[RS::ARRAY_VERTEX] = points;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_INDEX] = indices;
}
void PlaneMesh::_bind_methods() {
@@ -1270,11 +1270,11 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
};
- p_arr[VS::ARRAY_VERTEX] = points;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
- p_arr[VS::ARRAY_INDEX] = indices;
+ p_arr[RS::ARRAY_VERTEX] = points;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_INDEX] = indices;
}
void PrismMesh::_bind_methods() {
@@ -1401,10 +1401,10 @@ void QuadMesh::_create_mesh_array(Array &p_arr) const {
uvs.set(i, quad_uv[j]);
}
- p_arr[VS::ARRAY_VERTEX] = faces;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_VERTEX] = faces;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
}
void QuadMesh::_bind_methods() {
@@ -1494,11 +1494,11 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
thisrow = point;
};
- p_arr[VS::ARRAY_VERTEX] = points;
- p_arr[VS::ARRAY_NORMAL] = normals;
- p_arr[VS::ARRAY_TANGENT] = tangents;
- p_arr[VS::ARRAY_TEX_UV] = uvs;
- p_arr[VS::ARRAY_INDEX] = indices;
+ p_arr[RS::ARRAY_VERTEX] = points;
+ p_arr[RS::ARRAY_NORMAL] = normals;
+ p_arr[RS::ARRAY_TANGENT] = tangents;
+ p_arr[RS::ARRAY_TEX_UV] = uvs;
+ p_arr[RS::ARRAY_INDEX] = indices;
}
void SphereMesh::_bind_methods() {
@@ -1585,7 +1585,7 @@ void PointMesh::_create_mesh_array(Array &p_arr) const {
faces.resize(1);
faces.set(0, Vector3(0.0, 0.0, 0.0));
- p_arr[VS::ARRAY_VERTEX] = faces;
+ p_arr[RS::ARRAY_VERTEX] = faces;
}
PointMesh::PointMesh() {
diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape_3d.cpp
index 906abaf60c..0211c55f46 100644
--- a/scene/resources/ray_shape.cpp
+++ b/scene/resources/ray_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* ray_shape.cpp */
+/* ray_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "ray_shape.h"
+#include "ray_shape_3d.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> RayShape::get_debug_mesh_lines() {
+Vector<Vector3> RayShape3D::get_debug_mesh_lines() {
Vector<Vector3> points;
points.push_back(Vector3());
@@ -41,20 +41,20 @@ Vector<Vector3> RayShape::get_debug_mesh_lines() {
return points;
}
-real_t RayShape::get_enclosing_radius() const {
+real_t RayShape3D::get_enclosing_radius() const {
return length;
}
-void RayShape::_update_shape() {
+void RayShape3D::_update_shape() {
Dictionary d;
d["length"] = length;
d["slips_on_slope"] = slips_on_slope;
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), d);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d);
+ Shape3D::_update_shape();
}
-void RayShape::set_length(float p_length) {
+void RayShape3D::set_length(float p_length) {
length = p_length;
_update_shape();
@@ -62,12 +62,12 @@ void RayShape::set_length(float p_length) {
_change_notify("length");
}
-float RayShape::get_length() const {
+float RayShape3D::get_length() const {
return length;
}
-void RayShape::set_slips_on_slope(bool p_active) {
+void RayShape3D::set_slips_on_slope(bool p_active) {
slips_on_slope = p_active;
_update_shape();
@@ -75,24 +75,24 @@ void RayShape::set_slips_on_slope(bool p_active) {
_change_notify("slips_on_slope");
}
-bool RayShape::get_slips_on_slope() const {
+bool RayShape3D::get_slips_on_slope() const {
return slips_on_slope;
}
-void RayShape::_bind_methods() {
+void RayShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape::set_length);
- ClassDB::bind_method(D_METHOD("get_length"), &RayShape::get_length);
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape3D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &RayShape3D::get_length);
- ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape::set_slips_on_slope);
- ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape::get_slips_on_slope);
+ ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape3D::set_slips_on_slope);
+ ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape3D::get_slips_on_slope);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_length", "get_length");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
}
-RayShape::RayShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_RAY)) {
+RayShape3D::RayShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_RAY)) {
length = 1.0;
slips_on_slope = false;
diff --git a/scene/resources/ray_shape.h b/scene/resources/ray_shape_3d.h
index c89705ad7d..83bb71cca3 100644
--- a/scene/resources/ray_shape.h
+++ b/scene/resources/ray_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* ray_shape.h */
+/* ray_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -30,11 +30,11 @@
#ifndef RAY_SHAPE_H
#define RAY_SHAPE_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class RayShape : public Shape {
+class RayShape3D : public Shape3D {
- GDCLASS(RayShape, Shape);
+ GDCLASS(RayShape3D, Shape3D);
float length;
bool slips_on_slope;
@@ -52,6 +52,6 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- RayShape();
+ RayShape3D();
};
#endif // RAY_SHAPE_H
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp
index f8c8ffb289..19e72a65b0 100644
--- a/scene/resources/rectangle_shape_2d.cpp
+++ b/scene/resources/rectangle_shape_2d.cpp
@@ -30,11 +30,11 @@
#include "rectangle_shape_2d.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
void RectangleShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), extents);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), extents);
emit_changed();
}
@@ -51,7 +51,7 @@ Vector2 RectangleShape2D::get_extents() const {
void RectangleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
- VisualServer::get_singleton()->canvas_item_add_rect(p_to_rid, Rect2(-extents, extents * 2.0), p_color);
+ RenderingServer::get_singleton()->canvas_item_add_rect(p_to_rid, Rect2(-extents, extents * 2.0), p_color);
}
Rect2 RectangleShape2D::get_rect() const {
@@ -72,7 +72,7 @@ void RectangleShape2D::_bind_methods() {
}
RectangleShape2D::RectangleShape2D() :
- Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->rectangle_shape_create()) {
extents = Vector2(10, 10);
_update_shape();
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index 2e78a4fccf..814c349784 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -30,8 +30,8 @@
#include "segment_shape_2d.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
bool SegmentShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
@@ -45,7 +45,7 @@ void SegmentShape2D::_update_shape() {
Rect2 r;
r.position = a;
r.size = b;
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), r);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), r);
emit_changed();
}
@@ -71,7 +71,7 @@ Vector2 SegmentShape2D::get_b() const {
void SegmentShape2D::draw(const RID &p_to_rid, const Color &p_color) {
- VisualServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3);
+ RenderingServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3);
}
Rect2 SegmentShape2D::get_rect() const {
@@ -99,7 +99,7 @@ void SegmentShape2D::_bind_methods() {
}
SegmentShape2D::SegmentShape2D() :
- Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->segment_shape_create()) {
a = Vector2();
b = Vector2(0, 10);
@@ -113,14 +113,14 @@ void RayShape2D::_update_shape() {
Dictionary d;
d["length"] = length;
d["slips_on_slope"] = slips_on_slope;
- Physics2DServer::get_singleton()->shape_set_data(get_rid(), d);
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d);
emit_changed();
}
void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector2 tip = Vector2(0, get_length());
- VS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
+ RS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
Vector<Vector2> pts;
float tsize = 4;
pts.push_back(tip + Vector2(0, tsize));
@@ -130,7 +130,7 @@ void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
for (int i = 0; i < 3; i++)
cols.push_back(p_color);
- VS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
+ RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
}
Rect2 RayShape2D::get_rect() const {
@@ -179,7 +179,7 @@ bool RayShape2D::get_slips_on_slope() const {
}
RayShape2D::RayShape2D() :
- Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) {
+ Shape2D(PhysicsServer2D::get_singleton()->ray_shape_create()) {
length = 20;
slips_on_slope = false;
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 47f6d673ae..a62e7ded16 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -31,8 +31,8 @@
#include "shader.h"
#include "core/os/file_access.h"
#include "scene/scene_string_names.h"
-#include "servers/visual/shader_language.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/shader_language.h"
+#include "servers/rendering_server.h"
#include "texture.h"
Shader::Mode Shader::get_mode() const {
@@ -54,7 +54,7 @@ void Shader::set_code(const String &p_code) {
mode = MODE_SPATIAL;
}
- VisualServer::get_singleton()->shader_set_code(shader, p_code);
+ RenderingServer::get_singleton()->shader_set_code(shader, p_code);
params_cache_dirty = true;
emit_changed();
@@ -63,7 +63,7 @@ void Shader::set_code(const String &p_code) {
String Shader::get_code() const {
_update_shader();
- return VisualServer::get_singleton()->shader_get_code(shader);
+ return RenderingServer::get_singleton()->shader_get_code(shader);
}
void Shader::get_param_list(List<PropertyInfo> *p_params) const {
@@ -71,7 +71,7 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const {
_update_shader();
List<PropertyInfo> local;
- VisualServer::get_singleton()->shader_get_param_list(shader, &local);
+ RenderingServer::get_singleton()->shader_get_param_list(shader, &local);
params_cache.clear();
params_cache_dirty = false;
@@ -104,10 +104,10 @@ void Shader::set_default_texture_param(const StringName &p_param, const Ref<Text
if (p_texture.is_valid()) {
default_textures[p_param] = p_texture;
- VS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid());
+ RS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid());
} else {
default_textures.erase(p_param);
- VS::get_singleton()->shader_set_default_texture_param(shader, p_param, RID());
+ RS::get_singleton()->shader_set_default_texture_param(shader, p_param, RID());
}
emit_changed();
@@ -166,13 +166,13 @@ void Shader::_bind_methods() {
Shader::Shader() {
mode = MODE_SPATIAL;
- shader = VisualServer::get_singleton()->shader_create();
+ shader = RenderingServer::get_singleton()->shader_create();
params_cache_dirty = true;
}
Shader::~Shader() {
- VisualServer::get_singleton()->free(shader);
+ RenderingServer::get_singleton()->free(shader);
}
////////////
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 5804fe8fef..e65457ed76 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -56,7 +56,7 @@ private:
Mode mode;
// hack the name of performance
- // shaders keep a list of ShaderMaterial -> VisualServer name translations, to make
+ // shaders keep a list of ShaderMaterial -> RenderingServer name translations, to make
// conversion fast and save memory.
mutable bool params_cache_dirty;
mutable Map<StringName, StringName> params_cache; //map a shader param to a material param..
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index 64930c3117..7984dadbc5 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "shape_2d.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
RID Shape2D::get_rid() const {
return shape;
@@ -38,7 +38,7 @@ RID Shape2D::get_rid() const {
void Shape2D::set_custom_solver_bias(real_t p_bias) {
custom_bias = p_bias;
- Physics2DServer::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias);
+ PhysicsServer2D::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias);
}
real_t Shape2D::get_custom_solver_bias() const {
@@ -50,13 +50,13 @@ bool Shape2D::collide_with_motion(const Transform2D &p_local_xform, const Vector
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);
+ return PhysicsServer2D::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 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);
+ return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), NULL, 0, r);
}
Array 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) {
@@ -66,7 +66,7 @@ Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_x
Vector2 result[max_contacts * 2];
int contacts = 0;
- if (!Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts))
+ if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts))
return Array();
Array results;
@@ -84,7 +84,7 @@ Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const
Vector2 result[max_contacts * 2];
int contacts = 0;
- if (!Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts))
+ if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts))
return Array();
Array results;
@@ -115,5 +115,5 @@ Shape2D::Shape2D(const RID &p_rid) {
Shape2D::~Shape2D() {
- Physics2DServer::get_singleton()->free(shape);
+ PhysicsServer2D::get_singleton()->free(shape);
}
diff --git a/scene/resources/shape.cpp b/scene/resources/shape_3d.cpp
index 4a6da18f2b..f4a5d91e52 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* shape.cpp */
+/* shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "shape.h"
+#include "shape_3d.h"
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
#include "scene/resources/mesh.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-void Shape::add_vertices_to_array(Vector<Vector3> &array, const Transform &p_xform) {
+void Shape3D::add_vertices_to_array(Vector<Vector3> &array, const Transform &p_xform) {
Vector<Vector3> toadd = get_debug_mesh_lines();
@@ -50,16 +50,16 @@ void Shape::add_vertices_to_array(Vector<Vector3> &array, const Transform &p_xfo
}
}
-real_t Shape::get_margin() const {
+real_t Shape3D::get_margin() const {
return margin;
}
-void Shape::set_margin(real_t p_margin) {
+void Shape3D::set_margin(real_t p_margin) {
margin = p_margin;
- PhysicsServer::get_singleton()->shape_set_margin(shape, margin);
+ PhysicsServer3D::get_singleton()->shape_set_margin(shape, margin);
}
-Ref<ArrayMesh> Shape::get_debug_mesh() {
+Ref<ArrayMesh> Shape3D::get_debug_mesh() {
if (debug_mesh_cache.is_valid())
return debug_mesh_cache;
@@ -96,32 +96,32 @@ Ref<ArrayMesh> Shape::get_debug_mesh() {
return debug_mesh_cache;
}
-void Shape::_update_shape() {
+void Shape3D::_update_shape() {
emit_changed();
debug_mesh_cache.unref();
}
-void Shape::_bind_methods() {
+void Shape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Shape::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &Shape::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Shape3D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &Shape3D::get_margin);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0.001,10,0.001"), "set_margin", "get_margin");
}
-Shape::Shape() :
+Shape3D::Shape3D() :
margin(0.04) {
ERR_PRINT("Constructor must not be called!");
}
-Shape::Shape(RID p_shape) :
+Shape3D::Shape3D(RID p_shape) :
margin(0.04) {
shape = p_shape;
}
-Shape::~Shape() {
+Shape3D::~Shape3D() {
- PhysicsServer::get_singleton()->free(shape);
+ PhysicsServer3D::get_singleton()->free(shape);
}
diff --git a/scene/resources/shape.h b/scene/resources/shape_3d.h
index e5ccbf7e28..e7a516412d 100644
--- a/scene/resources/shape.h
+++ b/scene/resources/shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* shape.h */
+/* shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SHAPE_H
-#define SHAPE_H
+#ifndef SHAPE_3D_H
+#define SHAPE_3D_H
#include "core/resource.h"
class ArrayMesh;
-class Shape : public Resource {
+class Shape3D : public Resource {
- GDCLASS(Shape, Resource);
- OBJ_SAVE_TYPE(Shape);
+ GDCLASS(Shape3D, Resource);
+ OBJ_SAVE_TYPE(Shape3D);
RES_BASE_EXTENSION("shape");
RID shape;
real_t margin;
@@ -49,7 +49,7 @@ protected:
static void _bind_methods();
_FORCE_INLINE_ RID get_shape() const { return shape; }
- Shape(RID p_shape);
+ Shape3D(RID p_shape);
virtual void _update_shape();
@@ -66,8 +66,8 @@ public:
real_t get_margin() const;
void set_margin(real_t p_margin);
- Shape();
- ~Shape();
+ Shape3D();
+ ~Shape3D();
};
#endif // SHAPE_H
diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp
index 1185b693b7..cbe86b16b2 100644
--- a/scene/resources/sky.cpp
+++ b/scene/resources/sky.cpp
@@ -39,7 +39,7 @@ void Sky::set_radiance_size(RadianceSize p_size) {
static const int size[RADIANCE_SIZE_MAX] = {
32, 64, 128, 256, 512, 1024, 2048
};
- VS::get_singleton()->sky_set_radiance_size(sky, size[radiance_size]);
+ RS::get_singleton()->sky_set_radiance_size(sky, size[radiance_size]);
}
Sky::RadianceSize Sky::get_radiance_size() const {
@@ -49,7 +49,7 @@ Sky::RadianceSize Sky::get_radiance_size() const {
void Sky::set_process_mode(ProcessMode p_mode) {
mode = p_mode;
- VS::get_singleton()->sky_set_mode(sky, VS::SkyMode(mode));
+ RS::get_singleton()->sky_set_mode(sky, RS::SkyMode(mode));
}
Sky::ProcessMode Sky::get_process_mode() const {
@@ -61,7 +61,7 @@ void Sky::set_material(const Ref<Material> &p_material) {
RID material_rid;
if (sky_material.is_valid())
material_rid = sky_material->get_rid();
- VS::get_singleton()->sky_set_material(sky, material_rid);
+ RS::get_singleton()->sky_set_material(sky, material_rid);
}
Ref<Material> Sky::get_material() const {
@@ -104,10 +104,10 @@ void Sky::_bind_methods() {
Sky::Sky() {
mode = PROCESS_MODE_QUALITY;
radiance_size = RADIANCE_SIZE_256;
- sky = VS::get_singleton()->sky_create();
+ sky = RS::get_singleton()->sky_create();
}
Sky::~Sky() {
- VS::get_singleton()->free(sky);
+ RS::get_singleton()->free(sky);
} \ No newline at end of file
diff --git a/scene/resources/sky_material.cpp b/scene/resources/sky_material.cpp
index 5d8ceacbf2..37b88cccea 100644
--- a/scene/resources/sky_material.cpp
+++ b/scene/resources/sky_material.cpp
@@ -6,7 +6,7 @@
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
void ProceduralSkyMaterial::set_sky_top_color(const Color &p_sky_top) {
sky_top_color = p_sky_top;
- VS::get_singleton()->material_set_param(_get_material(), "sky_top_color", sky_top_color.to_linear());
+ RS::get_singleton()->material_set_param(_get_material(), "sky_top_color", sky_top_color.to_linear());
}
Color ProceduralSkyMaterial::get_sky_top_color() const {
@@ -44,7 +44,7 @@ Color ProceduralSkyMaterial::get_sky_top_color() const {
void ProceduralSkyMaterial::set_sky_horizon_color(const Color &p_sky_horizon) {
sky_horizon_color = p_sky_horizon;
- VS::get_singleton()->material_set_param(_get_material(), "sky_horizon_color", sky_horizon_color.to_linear());
+ RS::get_singleton()->material_set_param(_get_material(), "sky_horizon_color", sky_horizon_color.to_linear());
}
Color ProceduralSkyMaterial::get_sky_horizon_color() const {
@@ -54,7 +54,7 @@ Color ProceduralSkyMaterial::get_sky_horizon_color() const {
void ProceduralSkyMaterial::set_sky_curve(float p_curve) {
sky_curve = p_curve;
- VS::get_singleton()->material_set_param(_get_material(), "sky_curve", sky_curve);
+ RS::get_singleton()->material_set_param(_get_material(), "sky_curve", sky_curve);
}
float ProceduralSkyMaterial::get_sky_curve() const {
@@ -64,7 +64,7 @@ float ProceduralSkyMaterial::get_sky_curve() const {
void ProceduralSkyMaterial::set_sky_energy(float p_energy) {
sky_energy = p_energy;
- VS::get_singleton()->material_set_param(_get_material(), "sky_energy", sky_energy);
+ RS::get_singleton()->material_set_param(_get_material(), "sky_energy", sky_energy);
}
float ProceduralSkyMaterial::get_sky_energy() const {
@@ -74,7 +74,7 @@ float ProceduralSkyMaterial::get_sky_energy() const {
void ProceduralSkyMaterial::set_ground_bottom_color(const Color &p_ground_bottom) {
ground_bottom_color = p_ground_bottom;
- VS::get_singleton()->material_set_param(_get_material(), "ground_bottom_color", ground_bottom_color.to_linear());
+ RS::get_singleton()->material_set_param(_get_material(), "ground_bottom_color", ground_bottom_color.to_linear());
}
Color ProceduralSkyMaterial::get_ground_bottom_color() const {
@@ -84,7 +84,7 @@ Color ProceduralSkyMaterial::get_ground_bottom_color() const {
void ProceduralSkyMaterial::set_ground_horizon_color(const Color &p_ground_horizon) {
ground_horizon_color = p_ground_horizon;
- VS::get_singleton()->material_set_param(_get_material(), "ground_horizon_color", ground_horizon_color.to_linear());
+ RS::get_singleton()->material_set_param(_get_material(), "ground_horizon_color", ground_horizon_color.to_linear());
}
Color ProceduralSkyMaterial::get_ground_horizon_color() const {
@@ -94,7 +94,7 @@ Color ProceduralSkyMaterial::get_ground_horizon_color() const {
void ProceduralSkyMaterial::set_ground_curve(float p_curve) {
ground_curve = p_curve;
- VS::get_singleton()->material_set_param(_get_material(), "ground_curve", ground_curve);
+ RS::get_singleton()->material_set_param(_get_material(), "ground_curve", ground_curve);
}
float ProceduralSkyMaterial::get_ground_curve() const {
@@ -104,7 +104,7 @@ float ProceduralSkyMaterial::get_ground_curve() const {
void ProceduralSkyMaterial::set_ground_energy(float p_energy) {
ground_energy = p_energy;
- VS::get_singleton()->material_set_param(_get_material(), "ground_energy", ground_energy);
+ RS::get_singleton()->material_set_param(_get_material(), "ground_energy", ground_energy);
}
float ProceduralSkyMaterial::get_ground_energy() const {
@@ -114,7 +114,7 @@ float ProceduralSkyMaterial::get_ground_energy() const {
void ProceduralSkyMaterial::set_sun_angle_min(float p_angle) {
sun_angle_min = p_angle;
- VS::get_singleton()->material_set_param(_get_material(), "sun_angle_min", Math::deg2rad(sun_angle_min));
+ RS::get_singleton()->material_set_param(_get_material(), "sun_angle_min", Math::deg2rad(sun_angle_min));
}
float ProceduralSkyMaterial::get_sun_angle_min() const {
@@ -124,7 +124,7 @@ float ProceduralSkyMaterial::get_sun_angle_min() const {
void ProceduralSkyMaterial::set_sun_angle_max(float p_angle) {
sun_angle_max = p_angle;
- VS::get_singleton()->material_set_param(_get_material(), "sun_angle_max", Math::deg2rad(sun_angle_max));
+ RS::get_singleton()->material_set_param(_get_material(), "sun_angle_max", Math::deg2rad(sun_angle_max));
}
float ProceduralSkyMaterial::get_sun_angle_max() const {
@@ -134,7 +134,7 @@ float ProceduralSkyMaterial::get_sun_angle_max() const {
void ProceduralSkyMaterial::set_sun_curve(float p_curve) {
sun_curve = p_curve;
- VS::get_singleton()->material_set_param(_get_material(), "sun_curve", sun_curve);
+ RS::get_singleton()->material_set_param(_get_material(), "sun_curve", sun_curve);
}
float ProceduralSkyMaterial::get_sun_curve() const {
@@ -271,11 +271,11 @@ ProceduralSkyMaterial::ProceduralSkyMaterial() {
code += "\tCOLOR = mix(ground, sky, step(0.0, EYEDIR.y));\n";
code += "}\n";
- shader = VS::get_singleton()->shader_create();
+ shader = RS::get_singleton()->shader_create();
- VS::get_singleton()->shader_set_code(shader, code);
+ RS::get_singleton()->shader_set_code(shader, code);
- VS::get_singleton()->material_set_shader(_get_material(), shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader);
set_sky_top_color(Color(0.35, 0.46, 0.71));
set_sky_horizon_color(Color(0.55, 0.69, 0.81));
@@ -293,6 +293,8 @@ ProceduralSkyMaterial::ProceduralSkyMaterial() {
}
ProceduralSkyMaterial::~ProceduralSkyMaterial() {
+ RS::get_singleton()->free(shader);
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
}
/////////////////////////////////////////
@@ -301,7 +303,7 @@ ProceduralSkyMaterial::~ProceduralSkyMaterial() {
void PanoramaSkyMaterial::set_panorama(const Ref<Texture2D> &p_panorama) {
panorama = p_panorama;
- VS::get_singleton()->material_set_param(_get_material(), "source_panorama", panorama);
+ RS::get_singleton()->material_set_param(_get_material(), "source_panorama", panorama);
}
Ref<Texture2D> PanoramaSkyMaterial::get_panorama() const {
@@ -339,16 +341,16 @@ PanoramaSkyMaterial::PanoramaSkyMaterial() {
code += "\tCOLOR = texture(source_panorama, SKY_COORDS).rgb;\n";
code += "}";
- shader = VS::get_singleton()->shader_create();
+ shader = RS::get_singleton()->shader_create();
- VS::get_singleton()->shader_set_code(shader, code);
+ RS::get_singleton()->shader_set_code(shader, code);
- VS::get_singleton()->material_set_shader(_get_material(), shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader);
}
PanoramaSkyMaterial::~PanoramaSkyMaterial() {
- VS::get_singleton()->free(shader);
- VS::get_singleton()->material_set_shader(_get_material(), RID());
+ RS::get_singleton()->free(shader);
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
}
//////////////////////////////////
/* PhysicalSkyMaterial */
@@ -356,7 +358,7 @@ PanoramaSkyMaterial::~PanoramaSkyMaterial() {
void PhysicalSkyMaterial::set_rayleigh_coefficient(float p_rayleigh) {
rayleigh = p_rayleigh;
- VS::get_singleton()->material_set_param(_get_material(), "rayleigh", rayleigh);
+ RS::get_singleton()->material_set_param(_get_material(), "rayleigh", rayleigh);
}
float PhysicalSkyMaterial::get_rayleigh_coefficient() const {
@@ -366,7 +368,7 @@ float PhysicalSkyMaterial::get_rayleigh_coefficient() const {
void PhysicalSkyMaterial::set_rayleigh_color(Color p_rayleigh_color) {
rayleigh_color = p_rayleigh_color;
- VS::get_singleton()->material_set_param(_get_material(), "rayleigh_color", rayleigh_color);
+ RS::get_singleton()->material_set_param(_get_material(), "rayleigh_color", rayleigh_color);
}
Color PhysicalSkyMaterial::get_rayleigh_color() const {
@@ -376,7 +378,7 @@ Color PhysicalSkyMaterial::get_rayleigh_color() const {
void PhysicalSkyMaterial::set_mie_coefficient(float p_mie) {
mie = p_mie;
- VS::get_singleton()->material_set_param(_get_material(), "mie", mie);
+ RS::get_singleton()->material_set_param(_get_material(), "mie", mie);
}
float PhysicalSkyMaterial::get_mie_coefficient() const {
@@ -386,7 +388,7 @@ float PhysicalSkyMaterial::get_mie_coefficient() const {
void PhysicalSkyMaterial::set_mie_eccentricity(float p_eccentricity) {
mie_eccentricity = p_eccentricity;
- VS::get_singleton()->material_set_param(_get_material(), "mie_eccentricity", mie_eccentricity);
+ RS::get_singleton()->material_set_param(_get_material(), "mie_eccentricity", mie_eccentricity);
}
float PhysicalSkyMaterial::get_mie_eccentricity() const {
@@ -396,7 +398,7 @@ float PhysicalSkyMaterial::get_mie_eccentricity() const {
void PhysicalSkyMaterial::set_mie_color(Color p_mie_color) {
mie_color = p_mie_color;
- VS::get_singleton()->material_set_param(_get_material(), "mie_color", mie_color);
+ RS::get_singleton()->material_set_param(_get_material(), "mie_color", mie_color);
}
Color PhysicalSkyMaterial::get_mie_color() const {
return mie_color;
@@ -405,7 +407,7 @@ Color PhysicalSkyMaterial::get_mie_color() const {
void PhysicalSkyMaterial::set_turbidity(float p_turbidity) {
turbidity = p_turbidity;
- VS::get_singleton()->material_set_param(_get_material(), "turbidity", turbidity);
+ RS::get_singleton()->material_set_param(_get_material(), "turbidity", turbidity);
}
float PhysicalSkyMaterial::get_turbidity() const {
@@ -415,7 +417,7 @@ float PhysicalSkyMaterial::get_turbidity() const {
void PhysicalSkyMaterial::set_sun_disk_scale(float p_sun_disk_scale) {
sun_disk_scale = p_sun_disk_scale;
- VS::get_singleton()->material_set_param(_get_material(), "sun_disk_scale", sun_disk_scale);
+ RS::get_singleton()->material_set_param(_get_material(), "sun_disk_scale", sun_disk_scale);
}
float PhysicalSkyMaterial::get_sun_disk_scale() const {
@@ -425,7 +427,7 @@ float PhysicalSkyMaterial::get_sun_disk_scale() const {
void PhysicalSkyMaterial::set_ground_color(Color p_ground_color) {
ground_color = p_ground_color;
- VS::get_singleton()->material_set_param(_get_material(), "ground_color", ground_color);
+ RS::get_singleton()->material_set_param(_get_material(), "ground_color", ground_color);
}
Color PhysicalSkyMaterial::get_ground_color() const {
@@ -435,7 +437,7 @@ Color PhysicalSkyMaterial::get_ground_color() const {
void PhysicalSkyMaterial::set_exposure(float p_exposure) {
exposure = p_exposure;
- VS::get_singleton()->material_set_param(_get_material(), "exposure", exposure);
+ RS::get_singleton()->material_set_param(_get_material(), "exposure", exposure);
}
float PhysicalSkyMaterial::get_exposure() const {
@@ -445,7 +447,7 @@ float PhysicalSkyMaterial::get_exposure() const {
void PhysicalSkyMaterial::set_dither_strength(float p_dither_strength) {
dither_strength = p_dither_strength;
- VS::get_singleton()->material_set_param(_get_material(), "dither_strength", dither_strength);
+ RS::get_singleton()->material_set_param(_get_material(), "dither_strength", dither_strength);
}
float PhysicalSkyMaterial::get_dither_strength() const {
@@ -602,11 +604,11 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() {
code += "\tCOLOR += (hash(EYEDIR * 1741.9782) * 0.08 - 0.04) * 0.008 * dither_strength;\n";
code += "}\n";
- shader = VS::get_singleton()->shader_create();
+ shader = RS::get_singleton()->shader_create();
- VS::get_singleton()->shader_set_code(shader, code);
+ RS::get_singleton()->shader_set_code(shader, code);
- VS::get_singleton()->material_set_shader(_get_material(), shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader);
set_rayleigh_coefficient(2.0);
set_rayleigh_color(Color(0.056, 0.14, 0.3));
@@ -621,6 +623,6 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() {
}
PhysicalSkyMaterial::~PhysicalSkyMaterial() {
- VS::get_singleton()->free(shader);
- VS::get_singleton()->material_set_shader(_get_material(), RID());
+ RS::get_singleton()->free(shader);
+ RS::get_singleton()->material_set_shader(_get_material(), RID());
}
diff --git a/scene/resources/sky_material.h b/scene/resources/sky_material.h
index 2d0a62e0f6..515706b0c5 100644
--- a/scene/resources/sky_material.h
+++ b/scene/resources/sky_material.h
@@ -6,7 +6,7 @@
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp
deleted file mode 100644
index 376e926548..0000000000
--- a/scene/resources/space_2d.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*************************************************************************/
-/* space_2d.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "space_2d.h"
-
-RID Space2D::get_rid() const {
-
- return space;
-}
-
-void Space2D::set_active(bool p_active) {
-
- active = p_active;
- Physics2DServer::get_singleton()->space_set_active(space, active);
-}
-
-bool Space2D::is_active() const {
-
- return active;
-}
-
-void Space2D::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_active", "active"), &Space2D::set_active);
- ClassDB::bind_method(D_METHOD("is_active"), &Space2D::is_active);
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active");
-}
-
-Space2D::Space2D() {
-
- active = false;
- space = Physics2DServer::get_singleton()->space_create();
-}
-
-Space2D::~Space2D() {
-
- Physics2DServer::get_singleton()->free(space);
-}
diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h
deleted file mode 100644
index ff88c40348..0000000000
--- a/scene/resources/space_2d.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*************************************************************************/
-/* space_2d.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef SPACE_2D_H
-#define SPACE_2D_H
-
-#include "core/resource.h"
-#include "servers/physics_2d_server.h"
-
-class Space2D : public Resource {
-
- GDCLASS(Space2D, Resource);
- bool active;
- RID space;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_active(bool p_active);
- bool is_active() const;
-
- virtual RID get_rid() const;
-
- Space2D();
- ~Space2D();
-};
-
-#endif // SPACE_2D_H
diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape_3d.cpp
index 825708d1e2..153db4c291 100644
--- a/scene/resources/sphere_shape.cpp
+++ b/scene/resources/sphere_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sphere_shape.cpp */
+/* sphere_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "sphere_shape.h"
-#include "servers/physics_server.h"
+#include "sphere_shape_3d.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> SphereShape::get_debug_mesh_lines() {
+Vector<Vector3> SphereShape3D::get_debug_mesh_lines() {
float r = get_radius();
@@ -55,17 +55,17 @@ Vector<Vector3> SphereShape::get_debug_mesh_lines() {
return points;
}
-real_t SphereShape::get_enclosing_radius() const {
+real_t SphereShape3D::get_enclosing_radius() const {
return radius;
}
-void SphereShape::_update_shape() {
+void SphereShape3D::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), radius);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), radius);
+ Shape3D::_update_shape();
}
-void SphereShape::set_radius(float p_radius) {
+void SphereShape3D::set_radius(float p_radius) {
radius = p_radius;
_update_shape();
@@ -73,21 +73,21 @@ void SphereShape::set_radius(float p_radius) {
_change_notify("radius");
}
-float SphereShape::get_radius() const {
+float SphereShape3D::get_radius() const {
return radius;
}
-void SphereShape::_bind_methods() {
+void SphereShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape3D::get_radius);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_radius", "get_radius");
}
-SphereShape::SphereShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) {
+SphereShape3D::SphereShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_SPHERE)) {
set_radius(1.0);
}
diff --git a/scene/resources/sphere_shape.h b/scene/resources/sphere_shape_3d.h
index 07e8f1e233..3ed50cfe83 100644
--- a/scene/resources/sphere_shape.h
+++ b/scene/resources/sphere_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sphere_shape.h */
+/* sphere_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SPHERE_SHAPE_H
-#define SPHERE_SHAPE_H
+#ifndef SPHERE_SHAPE_3D_H
+#define SPHERE_SHAPE_3D_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class SphereShape : public Shape {
+class SphereShape3D : public Shape3D {
- GDCLASS(SphereShape, Shape);
+ GDCLASS(SphereShape3D, Shape3D);
float radius;
protected:
@@ -50,7 +50,7 @@ public:
virtual Vector<Vector3> get_debug_mesh_lines();
virtual real_t get_enclosing_radius() const;
- SphereShape();
+ SphereShape3D();
};
#endif // SPHERE_SHAPE_H
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 119cbcd098..56fb5d441f 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "style_box.h"
-#include "scene/2d/canvas_item.h"
+
+#include "scene/main/canvas_item.h"
#include <limits.h>
@@ -201,7 +202,7 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
if (normal_map.is_valid())
normal_rid = normal_map->get_rid();
- VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NinePatchAxisMode(axis_h), VS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid);
+ RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid);
}
void StyleBoxTexture::set_draw_center(bool p_enabled) {
@@ -852,7 +853,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
//DRAWING
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors, uvs);
}
@@ -1049,7 +1050,7 @@ Size2 StyleBoxLine::get_center_size() const {
}
void StyleBoxLine::draw(RID p_canvas_item, const Rect2 &p_rect) const {
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
Rect2i r = p_rect;
if (vertical) {
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 1aa1a00c55..f19b93d00d 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -33,7 +33,7 @@
#include "core/resource.h"
#include "scene/resources/texture.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
class CanvasItem;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index fa177d03fb..fee6bd1b54 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -519,7 +519,7 @@ void SurfaceTool::deindex() {
void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
Array arr = p_existing->surface_get_arrays(p_surface);
- ERR_FAIL_COND(arr.size() != VS::ARRAY_MAX);
+ ERR_FAIL_COND(arr.size() != RS::ARRAY_MAX);
_create_list_from_arrays(arr, r_vertex, r_index, lformat);
}
@@ -527,14 +527,14 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
Vector<SurfaceTool::Vertex> ret;
- Vector<Vector3> varr = p_arrays[VS::ARRAY_VERTEX];
- Vector<Vector3> narr = p_arrays[VS::ARRAY_NORMAL];
- Vector<float> tarr = p_arrays[VS::ARRAY_TANGENT];
- Vector<Color> carr = p_arrays[VS::ARRAY_COLOR];
- Vector<Vector2> uvarr = p_arrays[VS::ARRAY_TEX_UV];
- Vector<Vector2> uv2arr = p_arrays[VS::ARRAY_TEX_UV2];
- Vector<int> barr = p_arrays[VS::ARRAY_BONES];
- Vector<float> warr = p_arrays[VS::ARRAY_WEIGHTS];
+ Vector<Vector3> varr = p_arrays[RS::ARRAY_VERTEX];
+ Vector<Vector3> narr = p_arrays[RS::ARRAY_NORMAL];
+ Vector<float> tarr = p_arrays[RS::ARRAY_TANGENT];
+ Vector<Color> carr = p_arrays[RS::ARRAY_COLOR];
+ Vector<Vector2> uvarr = p_arrays[RS::ARRAY_TEX_UV];
+ Vector<Vector2> uv2arr = p_arrays[RS::ARRAY_TEX_UV2];
+ Vector<int> barr = p_arrays[RS::ARRAY_BONES];
+ Vector<float> warr = p_arrays[RS::ARRAY_WEIGHTS];
int vc = varr.size();
if (vc == 0)
@@ -542,48 +542,48 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
int lformat = 0;
if (varr.size()) {
- lformat |= VS::ARRAY_FORMAT_VERTEX;
+ lformat |= RS::ARRAY_FORMAT_VERTEX;
}
if (narr.size()) {
- lformat |= VS::ARRAY_FORMAT_NORMAL;
+ lformat |= RS::ARRAY_FORMAT_NORMAL;
}
if (tarr.size()) {
- lformat |= VS::ARRAY_FORMAT_TANGENT;
+ lformat |= RS::ARRAY_FORMAT_TANGENT;
}
if (carr.size()) {
- lformat |= VS::ARRAY_FORMAT_COLOR;
+ lformat |= RS::ARRAY_FORMAT_COLOR;
}
if (uvarr.size()) {
- lformat |= VS::ARRAY_FORMAT_TEX_UV;
+ lformat |= RS::ARRAY_FORMAT_TEX_UV;
}
if (uv2arr.size()) {
- lformat |= VS::ARRAY_FORMAT_TEX_UV2;
+ lformat |= RS::ARRAY_FORMAT_TEX_UV2;
}
if (barr.size()) {
- lformat |= VS::ARRAY_FORMAT_BONES;
+ lformat |= RS::ARRAY_FORMAT_BONES;
}
if (warr.size()) {
- lformat |= VS::ARRAY_FORMAT_WEIGHTS;
+ lformat |= RS::ARRAY_FORMAT_WEIGHTS;
}
for (int i = 0; i < vc; i++) {
Vertex v;
- if (lformat & VS::ARRAY_FORMAT_VERTEX)
+ if (lformat & RS::ARRAY_FORMAT_VERTEX)
v.vertex = varr[i];
- if (lformat & VS::ARRAY_FORMAT_NORMAL)
+ if (lformat & RS::ARRAY_FORMAT_NORMAL)
v.normal = narr[i];
- if (lformat & VS::ARRAY_FORMAT_TANGENT) {
+ if (lformat & RS::ARRAY_FORMAT_TANGENT) {
Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
v.tangent = p.normal;
v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
}
- if (lformat & VS::ARRAY_FORMAT_COLOR)
+ if (lformat & RS::ARRAY_FORMAT_COLOR)
v.color = carr[i];
- if (lformat & VS::ARRAY_FORMAT_TEX_UV)
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV)
v.uv = uvarr[i];
- if (lformat & VS::ARRAY_FORMAT_TEX_UV2)
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV2)
v.uv2 = uv2arr[i];
- if (lformat & VS::ARRAY_FORMAT_BONES) {
+ if (lformat & RS::ARRAY_FORMAT_BONES) {
Vector<int> b;
b.resize(4);
b.write[0] = barr[i * 4 + 0];
@@ -592,7 +592,7 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
b.write[3] = barr[i * 4 + 3];
v.bones = b;
}
- if (lformat & VS::ARRAY_FORMAT_WEIGHTS) {
+ if (lformat & RS::ARRAY_FORMAT_WEIGHTS) {
Vector<float> w;
w.resize(4);
w.write[0] = warr[i * 4 + 0];
@@ -610,14 +610,14 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
- Vector<Vector3> varr = arr[VS::ARRAY_VERTEX];
- Vector<Vector3> narr = arr[VS::ARRAY_NORMAL];
- Vector<float> tarr = arr[VS::ARRAY_TANGENT];
- Vector<Color> carr = arr[VS::ARRAY_COLOR];
- Vector<Vector2> uvarr = arr[VS::ARRAY_TEX_UV];
- Vector<Vector2> uv2arr = arr[VS::ARRAY_TEX_UV2];
- Vector<int> barr = arr[VS::ARRAY_BONES];
- Vector<float> warr = arr[VS::ARRAY_WEIGHTS];
+ Vector<Vector3> varr = arr[RS::ARRAY_VERTEX];
+ Vector<Vector3> narr = arr[RS::ARRAY_NORMAL];
+ Vector<float> tarr = arr[RS::ARRAY_TANGENT];
+ Vector<Color> carr = arr[RS::ARRAY_COLOR];
+ Vector<Vector2> uvarr = arr[RS::ARRAY_TEX_UV];
+ Vector<Vector2> uv2arr = arr[RS::ARRAY_TEX_UV2];
+ Vector<int> barr = arr[RS::ARRAY_BONES];
+ Vector<float> warr = arr[RS::ARRAY_WEIGHTS];
int vc = varr.size();
if (vc == 0)
@@ -625,48 +625,48 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
lformat = 0;
if (varr.size()) {
- lformat |= VS::ARRAY_FORMAT_VERTEX;
+ lformat |= RS::ARRAY_FORMAT_VERTEX;
}
if (narr.size()) {
- lformat |= VS::ARRAY_FORMAT_NORMAL;
+ lformat |= RS::ARRAY_FORMAT_NORMAL;
}
if (tarr.size()) {
- lformat |= VS::ARRAY_FORMAT_TANGENT;
+ lformat |= RS::ARRAY_FORMAT_TANGENT;
}
if (carr.size()) {
- lformat |= VS::ARRAY_FORMAT_COLOR;
+ lformat |= RS::ARRAY_FORMAT_COLOR;
}
if (uvarr.size()) {
- lformat |= VS::ARRAY_FORMAT_TEX_UV;
+ lformat |= RS::ARRAY_FORMAT_TEX_UV;
}
if (uv2arr.size()) {
- lformat |= VS::ARRAY_FORMAT_TEX_UV2;
+ lformat |= RS::ARRAY_FORMAT_TEX_UV2;
}
if (barr.size()) {
- lformat |= VS::ARRAY_FORMAT_BONES;
+ lformat |= RS::ARRAY_FORMAT_BONES;
}
if (warr.size()) {
- lformat |= VS::ARRAY_FORMAT_WEIGHTS;
+ lformat |= RS::ARRAY_FORMAT_WEIGHTS;
}
for (int i = 0; i < vc; i++) {
Vertex v;
- if (lformat & VS::ARRAY_FORMAT_VERTEX)
+ if (lformat & RS::ARRAY_FORMAT_VERTEX)
v.vertex = varr[i];
- if (lformat & VS::ARRAY_FORMAT_NORMAL)
+ if (lformat & RS::ARRAY_FORMAT_NORMAL)
v.normal = narr[i];
- if (lformat & VS::ARRAY_FORMAT_TANGENT) {
+ if (lformat & RS::ARRAY_FORMAT_TANGENT) {
Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
v.tangent = p.normal;
v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
}
- if (lformat & VS::ARRAY_FORMAT_COLOR)
+ if (lformat & RS::ARRAY_FORMAT_COLOR)
v.color = carr[i];
- if (lformat & VS::ARRAY_FORMAT_TEX_UV)
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV)
v.uv = uvarr[i];
- if (lformat & VS::ARRAY_FORMAT_TEX_UV2)
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV2)
v.uv2 = uv2arr[i];
- if (lformat & VS::ARRAY_FORMAT_BONES) {
+ if (lformat & RS::ARRAY_FORMAT_BONES) {
Vector<int> b;
b.resize(4);
b.write[0] = barr[i * 4 + 0];
@@ -675,7 +675,7 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
b.write[3] = barr[i * 4 + 3];
v.bones = b;
}
- if (lformat & VS::ARRAY_FORMAT_WEIGHTS) {
+ if (lformat & RS::ARRAY_FORMAT_WEIGHTS) {
Vector<float> w;
w.resize(4);
w.write[0] = warr[i * 4 + 0];
@@ -690,11 +690,11 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
//indices
- Vector<int> idx = arr[VS::ARRAY_INDEX];
+ Vector<int> idx = arr[RS::ARRAY_INDEX];
int is = idx.size();
if (is) {
- lformat |= VS::ARRAY_FORMAT_INDEX;
+ lformat |= RS::ARRAY_FORMAT_INDEX;
const int *iarr = idx.ptr();
for (int i = 0; i < is; i++) {
r_index->push_back(iarr[i]);
@@ -733,7 +733,7 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur
ERR_FAIL_COND(shape_idx == -1);
ERR_FAIL_COND(shape_idx >= arr.size());
Array mesh = arr[shape_idx];
- ERR_FAIL_COND(mesh.size() != VS::ARRAY_MAX);
+ ERR_FAIL_COND(mesh.size() != RS::ARRAY_MAX);
_create_list_from_arrays(arr[shape_idx], &vertex_array, &index_array, format);
}
@@ -755,10 +755,10 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const
Vertex v = E->get();
v.vertex = p_xform.xform(v.vertex);
- if (nformat & VS::ARRAY_FORMAT_NORMAL) {
+ if (nformat & RS::ARRAY_FORMAT_NORMAL) {
v.normal = p_xform.basis.xform(v.normal);
}
- if (nformat & VS::ARRAY_FORMAT_TANGENT) {
+ if (nformat & RS::ARRAY_FORMAT_TANGENT) {
v.tangent = p_xform.basis.xform(v.tangent);
v.binormal = p_xform.basis.xform(v.binormal);
}
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 1c5b2abad2..74b6a16d41 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -47,25 +47,25 @@ bool Texture2D::is_pixel_opaque(int p_x, int p_y) const {
return true;
}
-void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
}
bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
@@ -82,9 +82,9 @@ void Texture2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_height"), &Texture2D::get_height);
ClassDB::bind_method(D_METHOD("get_size"), &Texture2D::get_size);
ClassDB::bind_method(D_METHOD("has_alpha"), &Texture2D::has_alpha);
- ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT));
- ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT));
- ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT));
+ ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT));
+ ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT), DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data);
ADD_GROUP("", "");
@@ -121,7 +121,7 @@ bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {
Size2 s = p_value;
w = s.width;
h = s.height;
- VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
+ RenderingServer::get_singleton()->texture_set_size_override(texture, w, h);
} else
return false;
@@ -158,8 +158,8 @@ void ImageTexture::_reload_hook(const RID &p_hook) {
ERR_FAIL_COND_MSG(err != OK, "Cannot load image from path '" + path + "'.");
- RID new_texture = VisualServer::get_singleton()->texture_2d_create(img);
- VisualServer::get_singleton()->texture_replace(texture, new_texture);
+ RID new_texture = RenderingServer::get_singleton()->texture_2d_create(img);
+ RenderingServer::get_singleton()->texture_replace(texture, new_texture);
_change_notify();
emit_changed();
@@ -174,10 +174,10 @@ void ImageTexture::create_from_image(const Ref<Image> &p_image) {
mipmaps = p_image->has_mipmaps();
if (texture.is_null()) {
- texture = VisualServer::get_singleton()->texture_2d_create(p_image);
+ texture = RenderingServer::get_singleton()->texture_2d_create(p_image);
} else {
- RID new_texture = VisualServer::get_singleton()->texture_2d_create(p_image);
- VisualServer::get_singleton()->texture_replace(texture, new_texture);
+ RID new_texture = RenderingServer::get_singleton()->texture_2d_create(p_image);
+ RenderingServer::get_singleton()->texture_replace(texture, new_texture);
}
_change_notify();
emit_changed();
@@ -199,9 +199,9 @@ void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) {
ERR_FAIL_COND(mipmaps != p_image->has_mipmaps());
if (p_immediate) {
- VisualServer::get_singleton()->texture_2d_update_immediate(texture, p_image);
+ RenderingServer::get_singleton()->texture_2d_update_immediate(texture, p_image);
} else {
- VisualServer::get_singleton()->texture_2d_update(texture, p_image);
+ RenderingServer::get_singleton()->texture_2d_update(texture, p_image);
}
_change_notify();
@@ -219,7 +219,7 @@ void ImageTexture::_resource_path_changed() {
Ref<Image> ImageTexture::get_data() const {
if (image_stored) {
- return VisualServer::get_singleton()->texture_2d_get(texture);
+ return RenderingServer::get_singleton()->texture_2d_get(texture);
} else {
return Ref<Image>();
}
@@ -239,7 +239,7 @@ RID ImageTexture::get_rid() const {
if (texture.is_null()) {
//we are in trouble, create something temporary
- texture = VisualServer::get_singleton()->texture_2d_placeholder_create();
+ texture = RenderingServer::get_singleton()->texture_2d_placeholder_create();
}
return texture;
}
@@ -249,29 +249,29 @@ bool ImageTexture::has_alpha() const {
return (format == Image::FORMAT_LA8 || format == Image::FORMAT_RGBA8);
}
-void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
}
bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
@@ -316,13 +316,13 @@ void ImageTexture::set_size_override(const Size2 &p_size) {
w = s.x;
if (s.y != 0)
h = s.y;
- VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
+ RenderingServer::get_singleton()->texture_set_size_override(texture, w, h);
}
void ImageTexture::set_path(const String &p_path, bool p_take_over) {
if (texture.is_valid()) {
- VisualServer::get_singleton()->texture_set_path(texture, p_path);
+ RenderingServer::get_singleton()->texture_set_path(texture, p_path);
}
Resource::set_path(p_path, p_take_over);
@@ -349,7 +349,7 @@ ImageTexture::ImageTexture() {
ImageTexture::~ImageTexture() {
if (texture.is_valid()) {
- VisualServer::get_singleton()->free(texture);
+ RenderingServer::get_singleton()->free(texture);
}
}
@@ -495,7 +495,7 @@ Ref<Image> StreamTexture::load_image_from_file(FileAccess *f, int p_size_limit)
void StreamTexture::set_path(const String &p_path, bool p_take_over) {
if (texture.is_valid()) {
- VisualServer::get_singleton()->texture_set_path(texture, p_path);
+ RenderingServer::get_singleton()->texture_set_path(texture, p_path);
}
Resource::set_path(p_path, p_take_over);
@@ -509,7 +509,7 @@ void StreamTexture::_requested_3d(void *p_ud) {
request_3d_callback(stex);
}
-void StreamTexture::_requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel) {
+void StreamTexture::_requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel) {
StreamTexture *st = (StreamTexture *)p_ud;
Ref<StreamTexture> stex(st);
@@ -611,13 +611,13 @@ Error StreamTexture::load(const String &p_path) {
return err;
if (texture.is_valid()) {
- RID new_texture = VS::get_singleton()->texture_2d_create(image);
- VS::get_singleton()->texture_replace(texture, new_texture);
+ RID new_texture = RS::get_singleton()->texture_2d_create(image);
+ RS::get_singleton()->texture_replace(texture, new_texture);
} else {
- texture = VS::get_singleton()->texture_2d_create(image);
+ texture = RS::get_singleton()->texture_2d_create(image);
}
if (lwc || lhc) {
- VS::get_singleton()->texture_set_size_override(texture, lwc, lhc);
+ RS::get_singleton()->texture_set_size_override(texture, lwc, lhc);
}
w = lwc ? lwc : lw;
@@ -627,33 +627,33 @@ Error StreamTexture::load(const String &p_path) {
if (get_path() == String()) {
//temporarily set path if no path set for resource, helps find errors
- VisualServer::get_singleton()->texture_set_path(texture, p_path);
+ RenderingServer::get_singleton()->texture_set_path(texture, p_path);
}
#ifdef TOOLS_ENABLED
if (request_3d) {
//print_line("request detect 3D at " + p_path);
- VS::get_singleton()->texture_set_detect_3d_callback(texture, _requested_3d, this);
+ RS::get_singleton()->texture_set_detect_3d_callback(texture, _requested_3d, this);
} else {
//print_line("not requesting detect 3D at " + p_path);
- VS::get_singleton()->texture_set_detect_3d_callback(texture, NULL, NULL);
+ RS::get_singleton()->texture_set_detect_3d_callback(texture, NULL, NULL);
}
if (request_roughness) {
//print_line("request detect srgb at " + p_path);
- VS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this);
+ RS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this);
} else {
//print_line("not requesting detect srgb at " + p_path);
- VS::get_singleton()->texture_set_detect_roughness_callback(texture, NULL, NULL);
+ RS::get_singleton()->texture_set_detect_roughness_callback(texture, NULL, NULL);
}
if (request_normal) {
//print_line("request detect srgb at " + p_path);
- VS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this);
+ RS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this);
} else {
//print_line("not requesting detect normal at " + p_path);
- VS::get_singleton()->texture_set_detect_normal_callback(texture, NULL, NULL);
+ RS::get_singleton()->texture_set_detect_normal_callback(texture, NULL, NULL);
}
#endif
@@ -677,34 +677,34 @@ int StreamTexture::get_height() const {
RID StreamTexture::get_rid() const {
if (!texture.is_valid()) {
- texture = VS::get_singleton()->texture_2d_placeholder_create();
+ texture = RS::get_singleton()->texture_2d_placeholder_create();
}
return texture;
}
-void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
}
bool StreamTexture::has_alpha() const {
@@ -715,7 +715,7 @@ bool StreamTexture::has_alpha() const {
Ref<Image> StreamTexture::get_data() const {
if (texture.is_valid()) {
- return VS::get_singleton()->texture_2d_get(texture);
+ return RS::get_singleton()->texture_2d_get(texture);
} else {
return Ref<Image>();
}
@@ -792,7 +792,7 @@ StreamTexture::StreamTexture() {
StreamTexture::~StreamTexture() {
if (texture.is_valid()) {
- VS::get_singleton()->free(texture);
+ RS::get_singleton()->free(texture);
}
}
@@ -935,7 +935,7 @@ void AtlasTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_clip"), "set_filter_clip", "has_filter_clip");
}
-void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if (!atlas.is_valid())
return;
@@ -952,10 +952,10 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
+ RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
}
-void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if (!atlas.is_valid())
return;
@@ -975,9 +975,9 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
+ RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
}
-void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
//this might not necessarily work well if using a rect, needs to be fixed properly
if (!atlas.is_valid())
@@ -989,7 +989,7 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
+ RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
}
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
@@ -1087,7 +1087,7 @@ Ref<Texture2D> MeshTexture::get_base_texture() const {
return base_texture;
}
-void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
@@ -1100,9 +1100,9 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo
}
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1123,9 +1123,9 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile,
}
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
@@ -1147,7 +1147,7 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const
}
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
bool MeshTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
r_rect = p_rect;
@@ -1300,7 +1300,7 @@ void LargeTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
}
-void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
for (int i = 0; i < pieces.size(); i++) {
@@ -1309,7 +1309,7 @@ void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
}
}
-void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const {
+void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
//tiling not supported for this
if (size.x == 0 || size.y == 0)
@@ -1323,7 +1323,7 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
}
-void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
//tiling not supported for this
if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0)
@@ -1445,10 +1445,10 @@ void CurveTexture::_update() {
Ref<Image> image = memnew(Image(_width, 1, false, Image::FORMAT_RF, data));
if (_texture.is_valid()) {
- RID new_texture = VS::get_singleton()->texture_2d_create(image);
- VS::get_singleton()->texture_replace(_texture, new_texture);
+ RID new_texture = RS::get_singleton()->texture_2d_create(image);
+ RS::get_singleton()->texture_replace(_texture, new_texture);
} else {
- _texture = VS::get_singleton()->texture_2d_create(image);
+ _texture = RS::get_singleton()->texture_2d_create(image);
}
emit_changed();
@@ -1462,7 +1462,7 @@ Ref<Curve> CurveTexture::get_curve() const {
RID CurveTexture::get_rid() const {
if (!_texture.is_valid()) {
- _texture = VS::get_singleton()->texture_2d_placeholder_create();
+ _texture = RS::get_singleton()->texture_2d_placeholder_create();
}
return _texture;
}
@@ -1472,7 +1472,7 @@ CurveTexture::CurveTexture() {
}
CurveTexture::~CurveTexture() {
if (_texture.is_valid()) {
- VS::get_singleton()->free(_texture);
+ RS::get_singleton()->free(_texture);
}
}
//////////////////
@@ -1492,7 +1492,7 @@ GradientTexture::GradientTexture() {
GradientTexture::~GradientTexture() {
if (texture.is_valid()) {
- VS::get_singleton()->free(texture);
+ RS::get_singleton()->free(texture);
}
}
@@ -1564,10 +1564,10 @@ void GradientTexture::_update() {
Ref<Image> image = memnew(Image(width, 1, false, Image::FORMAT_RGBA8, data));
if (texture.is_valid()) {
- RID new_texture = VS::get_singleton()->texture_2d_create(image);
- VS::get_singleton()->texture_replace(texture, new_texture);
+ RID new_texture = RS::get_singleton()->texture_2d_create(image);
+ RS::get_singleton()->texture_replace(texture, new_texture);
} else {
- texture = VS::get_singleton()->texture_2d_create(image);
+ texture = RS::get_singleton()->texture_2d_create(image);
}
emit_changed();
@@ -1587,7 +1587,7 @@ Ref<Image> GradientTexture::get_data() const {
if (!texture.is_valid()) {
return Ref<Image>();
}
- return VisualServer::get_singleton()->texture_2d_get(texture);
+ return RenderingServer::get_singleton()->texture_2d_get(texture);
}
//////////////////////////////////////
@@ -1607,13 +1607,13 @@ void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) {
base = p_texture;
if (base.is_valid()) {
if (proxy_ph.is_valid()) {
- VS::get_singleton()->texture_proxy_update(proxy, base->get_rid());
- VS::get_singleton()->free(proxy_ph);
+ RS::get_singleton()->texture_proxy_update(proxy, base->get_rid());
+ RS::get_singleton()->free(proxy_ph);
proxy_ph = RID();
} else if (proxy.is_valid()) {
- VS::get_singleton()->texture_proxy_update(proxy, base->get_rid());
+ RS::get_singleton()->texture_proxy_update(proxy, base->get_rid());
} else {
- proxy = VS::get_singleton()->texture_proxy_create(base->get_rid());
+ proxy = RS::get_singleton()->texture_proxy_create(base->get_rid());
}
}
}
@@ -1638,8 +1638,8 @@ int ProxyTexture::get_height() const {
RID ProxyTexture::get_rid() const {
if (proxy.is_null()) {
- proxy_ph = VS::get_singleton()->texture_2d_placeholder_create();
- proxy = VS::get_singleton()->texture_proxy_create(proxy_ph);
+ proxy_ph = RS::get_singleton()->texture_2d_placeholder_create();
+ proxy = RS::get_singleton()->texture_proxy_create(proxy_ph);
}
return proxy;
}
@@ -1653,16 +1653,16 @@ bool ProxyTexture::has_alpha() const {
ProxyTexture::ProxyTexture() {
- //proxy = VS::get_singleton()->texture_create();
+ //proxy = RS::get_singleton()->texture_create();
}
ProxyTexture::~ProxyTexture() {
if (proxy_ph.is_valid()) {
- VS::get_singleton()->free(proxy_ph);
+ RS::get_singleton()->free(proxy_ph);
}
if (proxy.is_valid()) {
- VS::get_singleton()->free(proxy);
+ RS::get_singleton()->free(proxy);
}
}
//////////////////////////////////////////////
@@ -1708,7 +1708,7 @@ void AnimatedTexture::_update_proxy() {
}
if (frames[current_frame].texture.is_valid()) {
- VisualServer::get_singleton()->texture_proxy_update(proxy, frames[current_frame].texture->get_rid());
+ RenderingServer::get_singleton()->texture_proxy_update(proxy, frames[current_frame].texture->get_rid());
}
}
@@ -1854,17 +1854,17 @@ void AnimatedTexture::_bind_methods() {
}
AnimatedTexture::AnimatedTexture() {
- //proxy = VS::get_singleton()->texture_create();
- proxy_ph = VS::get_singleton()->texture_2d_placeholder_create();
- proxy = VS::get_singleton()->texture_proxy_create(proxy_ph);
+ //proxy = RS::get_singleton()->texture_create();
+ proxy_ph = RS::get_singleton()->texture_2d_placeholder_create();
+ proxy = RS::get_singleton()->texture_proxy_create(proxy_ph);
- VisualServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true);
+ RenderingServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true);
time = 0;
frame_count = 1;
fps = 4;
prev_ticks = 0;
current_frame = 0;
- VisualServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy));
+ RenderingServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy));
#ifndef NO_THREADS
rw_lock = RWLock::create();
@@ -1874,8 +1874,8 @@ AnimatedTexture::AnimatedTexture() {
}
AnimatedTexture::~AnimatedTexture() {
- VS::get_singleton()->free(proxy);
- VS::get_singleton()->free(proxy_ph);
+ RS::get_singleton()->free(proxy);
+ RS::get_singleton()->free(proxy_ph);
if (rw_lock) {
memdelete(rw_lock);
}
@@ -1921,10 +1921,10 @@ Error TextureLayered::create_from_images(Vector<Ref<Image>> p_images) {
int new_layers = p_images.size();
ERR_FAIL_COND_V(new_layers == 0, ERR_INVALID_PARAMETER);
- if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP) {
+ if (layered_type == RS::TEXTURE_LAYERED_CUBEMAP) {
ERR_FAIL_COND_V_MSG(new_layers != 6, ERR_INVALID_PARAMETER,
"Cubemaps require exactly 6 layers");
- } else if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {
+ } else if (layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {
ERR_FAIL_COND_V_MSG((new_layers % 6) != 0, ERR_INVALID_PARAMETER,
"Cubemap array layers must be a multiple of 6");
}
@@ -1946,11 +1946,11 @@ Error TextureLayered::create_from_images(Vector<Ref<Image>> p_images) {
}
if (texture.is_valid()) {
- RID new_texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type);
+ RID new_texture = RS::get_singleton()->texture_2d_layered_create(p_images, layered_type);
ERR_FAIL_COND_V(!new_texture.is_valid(), ERR_CANT_CREATE);
- VS::get_singleton()->texture_replace(texture, new_texture);
+ RS::get_singleton()->texture_replace(texture, new_texture);
} else {
- texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type);
+ texture = RS::get_singleton()->texture_2d_layered_create(p_images, layered_type);
ERR_FAIL_COND_V(!texture.is_valid(), ERR_CANT_CREATE);
}
@@ -1969,24 +1969,24 @@ void TextureLayered::update_layer(const Ref<Image> &p_image, int p_layer) {
ERR_FAIL_COND(p_image->get_width() != width || p_image->get_height() != height);
ERR_FAIL_INDEX(p_layer, layers);
ERR_FAIL_COND(p_image->has_mipmaps() != mipmaps);
- VS::get_singleton()->texture_2d_update(texture, p_image, p_layer);
+ RS::get_singleton()->texture_2d_update(texture, p_image, p_layer);
}
Ref<Image> TextureLayered::get_layer_data(int p_layer) const {
ERR_FAIL_INDEX_V(p_layer, layers, Ref<Image>());
- return VS::get_singleton()->texture_2d_layer_get(texture, p_layer);
+ return RS::get_singleton()->texture_2d_layer_get(texture, p_layer);
}
RID TextureLayered::get_rid() const {
if (texture.is_null()) {
- texture = VS::get_singleton()->texture_2d_layered_placeholder_create();
+ texture = RS::get_singleton()->texture_2d_layered_placeholder_create();
}
return texture;
}
void TextureLayered::set_path(const String &p_path, bool p_take_over) {
if (texture.is_valid()) {
- VS::get_singleton()->texture_set_path(texture, p_path);
+ RS::get_singleton()->texture_set_path(texture, p_path);
}
Resource::set_path(p_path, p_take_over);
@@ -2009,7 +2009,7 @@ void TextureLayered::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_INTERNAL), "create_from_images", "_get_images");
}
-TextureLayered::TextureLayered(VisualServer::TextureLayeredType p_layered_type) {
+TextureLayered::TextureLayered(RenderingServer::TextureLayeredType p_layered_type) {
layered_type = p_layered_type;
format = Image::FORMAT_MAX;
@@ -2020,7 +2020,7 @@ TextureLayered::TextureLayered(VisualServer::TextureLayeredType p_layered_type)
TextureLayered::~TextureLayered() {
if (texture.is_valid()) {
- VS::get_singleton()->free(texture);
+ RS::get_singleton()->free(texture);
}
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 1fb8742cec..c3bbbd5ee6 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -41,7 +41,7 @@
#include "scene/resources/curve.h"
#include "scene/resources/gradient.h"
#include "servers/camera_server.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
class Texture : public Resource {
GDCLASS(Texture, Resource);
@@ -68,9 +68,9 @@ public:
virtual bool has_alpha() const = 0;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
virtual Ref<Image> get_data() const { return Ref<Image>(); }
@@ -118,9 +118,9 @@ public:
virtual RID get_rid() const;
bool has_alpha() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -171,7 +171,7 @@ private:
virtual void reload_from_file();
static void _requested_3d(void *p_ud);
- static void _requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel);
+ static void _requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel);
static void _requested_normal(void *p_ud);
protected:
@@ -182,7 +182,7 @@ public:
static Ref<Image> load_image_from_file(FileAccess *p_file, int p_size_limit);
typedef void (*TextureFormatRequestCallback)(const Ref<StreamTexture> &);
- typedef void (*TextureFormatRoughnessRequestCallback)(const Ref<StreamTexture> &, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel);
+ typedef void (*TextureFormatRoughnessRequestCallback)(const Ref<StreamTexture> &, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel);
static TextureFormatRequestCallback request_3d_callback;
static TextureFormatRoughnessRequestCallback request_roughness_callback;
@@ -198,9 +198,9 @@ public:
virtual void set_path(const String &p_path, bool p_take_over);
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
virtual bool has_alpha() const;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -251,9 +251,9 @@ public:
void set_filter_clip(const bool p_enable);
bool has_filter_clip() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -291,9 +291,9 @@ public:
void set_base_texture(const Ref<Texture2D> &p_texture);
Ref<Texture2D> get_base_texture() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -339,9 +339,9 @@ public:
Ref<Texture2D> get_piece_texture(int p_idx) const;
Ref<Image> to_image() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -352,7 +352,7 @@ class TextureLayered : public Texture {
GDCLASS(TextureLayered, Texture);
- VS::TextureLayeredType layered_type;
+ RS::TextureLayeredType layered_type;
mutable RID texture;
Image::Format format;
@@ -383,7 +383,7 @@ public:
virtual RID get_rid() const;
virtual void set_path(const String &p_path, bool p_take_over = false);
- TextureLayered(VS::TextureLayeredType p_layered_type);
+ TextureLayered(RS::TextureLayeredType p_layered_type);
~TextureLayered();
};
@@ -392,7 +392,7 @@ class Texture2DArray : public TextureLayered {
GDCLASS(Texture2DArray, TextureLayered)
public:
Texture2DArray() :
- TextureLayered(VS::TEXTURE_LAYERED_2D_ARRAY) {}
+ TextureLayered(RS::TEXTURE_LAYERED_2D_ARRAY) {}
};
class Cubemap : public TextureLayered {
@@ -401,7 +401,7 @@ class Cubemap : public TextureLayered {
public:
Cubemap() :
- TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP) {}
+ TextureLayered(RS::TEXTURE_LAYERED_CUBEMAP) {}
};
class CubemapArray : public TextureLayered {
@@ -410,7 +410,7 @@ class CubemapArray : public TextureLayered {
public:
CubemapArray() :
- TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {}
+ TextureLayered(RS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {}
};
class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader {
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index b312aa054c..27305cfff1 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -362,7 +362,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::BOOL, pre + "shape_one_way", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
p_list->push_back(PropertyInfo(Variant::FLOAT, pre + "shape_one_way_margin", PROPERTY_HINT_RANGE, "0,128,0.01", PROPERTY_USAGE_NOEDITOR));
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "shapes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
- p_list->push_back(PropertyInfo(Variant::INT, pre + "z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, pre + "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1", PROPERTY_USAGE_NOEDITOR));
}
}
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 3c964ec667..5252c560a4 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -34,7 +34,7 @@
#include "core/array.h"
#include "core/resource.h"
#include "scene/2d/light_occluder_2d.h"
-#include "scene/2d/navigation_polygon.h"
+#include "scene/2d/navigation_region_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/shape_2d.h"
#include "scene/resources/texture.h"
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 407325c199..c47e80c807 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -31,7 +31,7 @@
#include "visual_shader.h"
#include "core/vmap.h"
-#include "servers/visual/shader_types.h"
+#include "servers/rendering/shader_types.h"
#include "visual_shader_nodes.h"
bool VisualShaderNode::is_simple_decl() const {
@@ -1034,14 +1034,14 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const {
void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
//mode
- p_list->push_back(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Spatial,CanvasItem,Particles"));
+ p_list->push_back(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Node3D,CanvasItem,Particles,Sky"));
//render modes
Map<String, String> blend_mode_enums;
Set<String> toggles;
- for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode)).size(); i++) {
- String mode = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode))[i];
+ for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) {
+ String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i];
int idx = 0;
bool in_enum = false;
while (render_mode_enums[idx].string) {
@@ -1299,8 +1299,8 @@ void VisualShader::_update_shader() const {
StringBuilder code;
Vector<VisualShader::DefaultTextureParam> default_tex_params;
Set<StringName> classes;
- List<int> insertion_pos;
- static const char *shader_mode_str[Shader::MODE_MAX] = { "spatial", "canvas_item", "particles" };
+ Map<int, int> insertion_pos;
+ static const char *shader_mode_str[Shader::MODE_MAX] = { "spatial", "canvas_item", "particles", "sky" };
global_code += String() + "shader_type " + shader_mode_str[shader_mode] + ";\n";
@@ -1317,8 +1317,8 @@ void VisualShader::_update_shader() const {
int which = modes[render_mode_enums[idx].string];
int count = 0;
- for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode)).size(); i++) {
- String mode = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode))[i];
+ for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) {
+ String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i];
if (mode.begins_with(render_mode_enums[idx].string)) {
if (count == which) {
if (render_mode != String()) {
@@ -1336,9 +1336,9 @@ void VisualShader::_update_shader() const {
}
//fill render mode flags
- for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode)).size(); i++) {
+ for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) {
- String mode = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode))[i];
+ String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i];
if (flags.has(mode)) {
if (render_mode != String()) {
render_mode += ", ";
@@ -1357,6 +1357,11 @@ void VisualShader::_update_shader() const {
String global_expressions;
for (int i = 0, index = 0; i < TYPE_MAX; i++) {
+
+ if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) {
+ continue;
+ }
+
for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) {
Ref<VisualShaderNodeGlobalExpression> global_expression = Object::cast_to<VisualShaderNodeGlobalExpression>(E->get().node.ptr());
if (global_expression.is_valid()) {
@@ -1373,6 +1378,10 @@ void VisualShader::_update_shader() const {
for (int i = 0; i < TYPE_MAX; i++) {
+ if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) {
+ continue;
+ }
+
//make it faster to go around through shader
VMap<ConnectionKey, const List<Connection>::Element *> input_connections;
VMap<ConnectionKey, const List<Connection>::Element *> output_connections;
@@ -1396,7 +1405,7 @@ void VisualShader::_update_shader() const {
Set<int> processed;
Error err = _write_node(Type(i), global_code, global_code_per_node, global_code_per_func, code, default_tex_params, input_connections, output_connections, NODE_ID_OUTPUT, processed, false, classes);
ERR_FAIL_COND(err != OK);
- insertion_pos.push_back(code.get_string_length());
+ insertion_pos.insert(i, code.get_string_length());
code += "}\n";
}
@@ -1408,6 +1417,9 @@ void VisualShader::_update_shader() const {
final_code += global_expressions;
String tcode = code;
for (int i = 0; i < TYPE_MAX; i++) {
+ if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) {
+ continue;
+ }
tcode = tcode.insert(insertion_pos[i], global_code_per_func[Type(i)]);
}
final_code += tcode;
@@ -1643,6 +1655,38 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = {
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_TRANSFORM, "emission_transform", "EMISSION_TRANSFORM" },
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
+
+ // Sky, Fragment
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "at_cubemap_pass", "AT_CUBEMAP_PASS" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "at_half_res_pass", "AT_HALF_RES_PASS" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "at_quarter_res_pass", "AT_QUARTER_RES_PASS" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "eyedir", "EYEDIR" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "half_res_color", "HALF_RES_COLOR.rgb" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "half_res_alpha", "HALF_RES_COLOR.a" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light0_color", "LIGHT0_COLOR" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light0_direction", "LIGHT0_DIRECTION" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light0_enabled", "LIGHT0_ENABLED" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light0_energy", "LIGHT0_ENERGY" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light1_color", "LIGHT1_COLOR" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light1_direction", "LIGHT1_DIRECTION" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light1_enabled", "LIGHT1_ENABLED" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light1_energy", "LIGHT1_ENERGY" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light2_color", "LIGHT2_COLOR" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light2_direction", "LIGHT2_DIRECTION" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light2_enabled", "LIGHT2_ENABLED" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light2_energy", "LIGHT2_ENERGY" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light3_color", "LIGHT3_COLOR" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light3_direction", "LIGHT3_DIRECTION" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light3_enabled", "LIGHT3_ENABLED" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light3_energy", "LIGHT3_ENERGY" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "position", "POSITION" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "quarter_res_color", "QUARTER_RES_COLOR.rgb" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "quarter_res_alpha", "QUARTER_RES_COLOR.a" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SAMPLER, "radiance", "RADIANCE" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "sky_coords", "vec3(SKY_COORDS, 0.0)" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" },
+
{ Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL },
};
@@ -1986,6 +2030,10 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = {
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "custom", "CUSTOM.rgb" },
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "custom_alpha", "CUSTOM.a" },
{ Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_TRANSFORM, "transform", "TRANSFORM" },
+ // Sky, Fragment
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR" },
+ { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "ALPHA" },
+
{ Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL },
};
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 6bdc4cf6f0..742ef106d9 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -33,9 +33,9 @@
#include "core/project_settings.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/visibility_notifier_2d.h"
-#include "scene/main/viewport.h"
-#include "servers/physics_2d_server.h"
-#include "servers/visual_server.h"
+#include "scene/main/window.h"
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
struct SpatialIndexer2D {
@@ -376,33 +376,33 @@ void World2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::_RID, "canvas", PROPERTY_HINT_NONE, "", 0), "", "get_canvas");
ADD_PROPERTY(PropertyInfo(Variant::_RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "Physics2DDirectSpaceState", 0), "", "get_direct_space_state");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", 0), "", "get_direct_space_state");
}
-Physics2DDirectSpaceState *World2D::get_direct_space_state() {
+PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
- return Physics2DServer::get_singleton()->space_get_direct_state(space);
+ return PhysicsServer2D::get_singleton()->space_get_direct_state(space);
}
World2D::World2D() {
- canvas = VisualServer::get_singleton()->canvas_create();
- space = Physics2DServer::get_singleton()->space_create();
+ canvas = RenderingServer::get_singleton()->canvas_create();
+ space = PhysicsServer2D::get_singleton()->space_create();
//set space2D to be more friendly with pixels than meters, by adjusting some constants
- Physics2DServer::get_singleton()->space_set_active(space, true);
- Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/2d/default_gravity", 98));
- Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/2d/default_gravity_vector", Vector2(0, 1)));
- Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/2d/default_linear_damp", 0.1));
+ PhysicsServer2D::get_singleton()->space_set_active(space, true);
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/2d/default_gravity", 98));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/2d/default_gravity_vector", Vector2(0, 1)));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/2d/default_linear_damp", 0.1));
ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/default_linear_damp", PropertyInfo(Variant::FLOAT, "physics/2d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"));
- Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/2d/default_angular_damp", 1.0));
+ PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/2d/default_angular_damp", 1.0));
ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/2d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"));
indexer = memnew(SpatialIndexer2D);
}
World2D::~World2D() {
- VisualServer::get_singleton()->free(canvas);
- Physics2DServer::get_singleton()->free(space);
+ RenderingServer::get_singleton()->free(canvas);
+ PhysicsServer2D::get_singleton()->free(space);
memdelete(indexer);
}
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index d837ef58c2..88b4c2594c 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -33,7 +33,7 @@
#include "core/project_settings.h"
#include "core/resource.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
class VisibilityNotifier2D;
class Viewport;
@@ -67,7 +67,7 @@ public:
RID get_canvas();
RID get_space();
- Physics2DDirectSpaceState *get_direct_space_state();
+ PhysicsDirectSpaceState2D *get_direct_space_state();
void get_viewport_list(List<Viewport *> *r_viewports);
diff --git a/scene/resources/world.cpp b/scene/resources/world_3d.cpp
index a7e519479f..8e45b22cbf 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* world.cpp */
+/* world_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "world.h"
+#include "world_3d.h"
#include "core/math/camera_matrix.h"
#include "core/math/octree.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/visibility_notifier.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/visibility_notifier_3d.h"
#include "scene/scene_string_names.h"
struct SpatialIndexer {
- Octree<VisibilityNotifier> octree;
+ Octree<VisibilityNotifier3D> octree;
struct NotifierData {
@@ -46,25 +46,25 @@ struct SpatialIndexer {
OctreeElementID id;
};
- Map<VisibilityNotifier *, NotifierData> notifiers;
+ Map<VisibilityNotifier3D *, NotifierData> notifiers;
struct CameraData {
- Map<VisibilityNotifier *, uint64_t> notifiers;
+ Map<VisibilityNotifier3D *, uint64_t> notifiers;
};
- Map<Camera *, CameraData> cameras;
+ Map<Camera3D *, CameraData> cameras;
enum {
VISIBILITY_CULL_MAX = 32768
};
- Vector<VisibilityNotifier *> cull;
+ Vector<VisibilityNotifier3D *> cull;
bool changed;
uint64_t pass;
uint64_t last_frame;
- void _notifier_add(VisibilityNotifier *p_notifier, const AABB &p_rect) {
+ void _notifier_add(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
ERR_FAIL_COND(notifiers.has(p_notifier));
notifiers[p_notifier].aabb = p_rect;
@@ -72,9 +72,9 @@ struct SpatialIndexer {
changed = true;
}
- void _notifier_update(VisibilityNotifier *p_notifier, const AABB &p_rect) {
+ void _notifier_update(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
- Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier);
+ Map<VisibilityNotifier3D *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
if (E->get().aabb == p_rect)
return;
@@ -84,18 +84,18 @@ struct SpatialIndexer {
changed = true;
}
- void _notifier_remove(VisibilityNotifier *p_notifier) {
+ void _notifier_remove(VisibilityNotifier3D *p_notifier) {
- Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier);
+ Map<VisibilityNotifier3D *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
octree.erase(E->get().id);
notifiers.erase(p_notifier);
- List<Camera *> removed;
- for (Map<Camera *, CameraData>::Element *F = cameras.front(); F; F = F->next()) {
+ List<Camera3D *> removed;
+ for (Map<Camera3D *, CameraData>::Element *F = cameras.front(); F; F = F->next()) {
- Map<VisibilityNotifier *, uint64_t>::Element *G = F->get().notifiers.find(p_notifier);
+ Map<VisibilityNotifier3D *, uint64_t>::Element *G = F->get().notifiers.find(p_notifier);
if (G) {
F->get().notifiers.erase(G);
@@ -112,7 +112,7 @@ struct SpatialIndexer {
changed = true;
}
- void _add_camera(Camera *p_camera) {
+ void _add_camera(Camera3D *p_camera) {
ERR_FAIL_COND(cameras.has(p_camera));
CameraData vd;
@@ -120,17 +120,17 @@ struct SpatialIndexer {
changed = true;
}
- void _update_camera(Camera *p_camera) {
+ void _update_camera(Camera3D *p_camera) {
- Map<Camera *, CameraData>::Element *E = cameras.find(p_camera);
+ Map<Camera3D *, CameraData>::Element *E = cameras.find(p_camera);
ERR_FAIL_COND(!E);
changed = true;
}
- void _remove_camera(Camera *p_camera) {
+ void _remove_camera(Camera3D *p_camera) {
ERR_FAIL_COND(!cameras.has(p_camera));
- List<VisibilityNotifier *> removed;
- for (Map<VisibilityNotifier *, uint64_t>::Element *E = cameras[p_camera].notifiers.front(); E; E = E->next()) {
+ List<VisibilityNotifier3D *> removed;
+ for (Map<VisibilityNotifier3D *, uint64_t>::Element *E = cameras[p_camera].notifiers.front(); E; E = E->next()) {
removed.push_back(E->key());
}
@@ -152,26 +152,26 @@ struct SpatialIndexer {
if (!changed)
return;
- for (Map<Camera *, CameraData>::Element *E = cameras.front(); E; E = E->next()) {
+ for (Map<Camera3D *, CameraData>::Element *E = cameras.front(); E; E = E->next()) {
pass++;
- Camera *c = E->key();
+ Camera3D *c = E->key();
Vector<Plane> planes = c->get_frustum();
int culled = octree.cull_convex(planes, cull.ptrw(), cull.size());
- VisibilityNotifier **ptr = cull.ptrw();
+ VisibilityNotifier3D **ptr = cull.ptrw();
- List<VisibilityNotifier *> added;
- List<VisibilityNotifier *> removed;
+ List<VisibilityNotifier3D *> added;
+ List<VisibilityNotifier3D *> removed;
for (int i = 0; i < culled; i++) {
//notifiers in frustum
- Map<VisibilityNotifier *, uint64_t>::Element *H = E->get().notifiers.find(ptr[i]);
+ Map<VisibilityNotifier3D *, uint64_t>::Element *H = E->get().notifiers.find(ptr[i]);
if (!H) {
E->get().notifiers.insert(ptr[i], pass);
@@ -181,7 +181,7 @@ struct SpatialIndexer {
}
}
- for (Map<VisibilityNotifier *, uint64_t>::Element *F = E->get().notifiers.front(); F; F = F->next()) {
+ for (Map<VisibilityNotifier3D *, uint64_t>::Element *F = E->get().notifiers.front(); F; F = F->next()) {
if (F->get() != pass)
removed.push_back(F->key());
@@ -210,139 +210,139 @@ struct SpatialIndexer {
}
};
-void World::_register_camera(Camera *p_camera) {
+void World3D::_register_camera(Camera3D *p_camera) {
#ifndef _3D_DISABLED
indexer->_add_camera(p_camera);
#endif
}
-void World::_update_camera(Camera *p_camera) {
+void World3D::_update_camera(Camera3D *p_camera) {
#ifndef _3D_DISABLED
indexer->_update_camera(p_camera);
#endif
}
-void World::_remove_camera(Camera *p_camera) {
+void World3D::_remove_camera(Camera3D *p_camera) {
#ifndef _3D_DISABLED
indexer->_remove_camera(p_camera);
#endif
}
-void World::_register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) {
+void World3D::_register_notifier(VisibilityNotifier3D *p_notifier, const AABB &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 World3D::_update_notifier(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
#ifndef _3D_DISABLED
indexer->_notifier_update(p_notifier, p_rect);
#endif
}
-void World::_remove_notifier(VisibilityNotifier *p_notifier) {
+void World3D::_remove_notifier(VisibilityNotifier3D *p_notifier) {
#ifndef _3D_DISABLED
indexer->_notifier_remove(p_notifier);
#endif
}
-void World::_update(uint64_t p_frame) {
+void World3D::_update(uint64_t p_frame) {
#ifndef _3D_DISABLED
indexer->_update(p_frame);
#endif
}
-RID World::get_space() const {
+RID World3D::get_space() const {
return space;
}
-RID World::get_scenario() const {
+RID World3D::get_scenario() const {
return scenario;
}
-void World::set_environment(const Ref<Environment> &p_environment) {
+void World3D::set_environment(const Ref<Environment> &p_environment) {
if (environment == p_environment) {
return;
}
environment = p_environment;
if (environment.is_valid())
- VS::get_singleton()->scenario_set_environment(scenario, environment->get_rid());
+ RS::get_singleton()->scenario_set_environment(scenario, environment->get_rid());
else
- VS::get_singleton()->scenario_set_environment(scenario, RID());
+ RS::get_singleton()->scenario_set_environment(scenario, RID());
emit_changed();
}
-Ref<Environment> World::get_environment() const {
+Ref<Environment> World3D::get_environment() const {
return environment;
}
-void World::set_fallback_environment(const Ref<Environment> &p_environment) {
+void World3D::set_fallback_environment(const Ref<Environment> &p_environment) {
if (fallback_environment == p_environment) {
return;
}
fallback_environment = p_environment;
if (fallback_environment.is_valid())
- VS::get_singleton()->scenario_set_fallback_environment(scenario, p_environment->get_rid());
+ RS::get_singleton()->scenario_set_fallback_environment(scenario, p_environment->get_rid());
else
- VS::get_singleton()->scenario_set_fallback_environment(scenario, RID());
+ RS::get_singleton()->scenario_set_fallback_environment(scenario, RID());
emit_changed();
}
-Ref<Environment> World::get_fallback_environment() const {
+Ref<Environment> World3D::get_fallback_environment() const {
return fallback_environment;
}
-void World::set_camera_effects(const Ref<CameraEffects> &p_camera_effects) {
+void World3D::set_camera_effects(const Ref<CameraEffects> &p_camera_effects) {
camera_effects = p_camera_effects;
if (camera_effects.is_valid())
- VS::get_singleton()->scenario_set_camera_effects(scenario, camera_effects->get_rid());
+ RS::get_singleton()->scenario_set_camera_effects(scenario, camera_effects->get_rid());
else
- VS::get_singleton()->scenario_set_camera_effects(scenario, RID());
+ RS::get_singleton()->scenario_set_camera_effects(scenario, RID());
}
-Ref<CameraEffects> World::get_camera_effects() const {
+Ref<CameraEffects> World3D::get_camera_effects() const {
return camera_effects;
}
-PhysicsDirectSpaceState *World::get_direct_space_state() {
+PhysicsDirectSpaceState3D *World3D::get_direct_space_state() {
- return PhysicsServer::get_singleton()->space_get_direct_state(space);
+ return PhysicsServer3D::get_singleton()->space_get_direct_state(space);
}
-void World::get_camera_list(List<Camera *> *r_cameras) {
+void World3D::get_camera_list(List<Camera3D *> *r_cameras) {
- for (Map<Camera *, SpatialIndexer::CameraData>::Element *E = indexer->cameras.front(); E; E = E->next()) {
+ for (Map<Camera3D *, SpatialIndexer::CameraData>::Element *E = indexer->cameras.front(); E; E = E->next()) {
r_cameras->push_back(E->key());
}
}
-void World::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_space"), &World::get_space);
- ClassDB::bind_method(D_METHOD("get_scenario"), &World::get_scenario);
- ClassDB::bind_method(D_METHOD("set_environment", "env"), &World::set_environment);
- ClassDB::bind_method(D_METHOD("get_environment"), &World::get_environment);
- ClassDB::bind_method(D_METHOD("set_fallback_environment", "env"), &World::set_fallback_environment);
- ClassDB::bind_method(D_METHOD("get_fallback_environment"), &World::get_fallback_environment);
- ClassDB::bind_method(D_METHOD("set_camera_effects", "env"), &World::set_camera_effects);
- ClassDB::bind_method(D_METHOD("get_camera_effects"), &World::get_camera_effects);
- ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World::get_direct_space_state);
+void World3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("get_space"), &World3D::get_space);
+ ClassDB::bind_method(D_METHOD("get_scenario"), &World3D::get_scenario);
+ ClassDB::bind_method(D_METHOD("set_environment", "env"), &World3D::set_environment);
+ ClassDB::bind_method(D_METHOD("get_environment"), &World3D::get_environment);
+ ClassDB::bind_method(D_METHOD("set_fallback_environment", "env"), &World3D::set_fallback_environment);
+ ClassDB::bind_method(D_METHOD("get_fallback_environment"), &World3D::get_fallback_environment);
+ ClassDB::bind_method(D_METHOD("set_camera_effects", "env"), &World3D::set_camera_effects);
+ ClassDB::bind_method(D_METHOD("get_camera_effects"), &World3D::get_camera_effects);
+ ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World3D::get_direct_space_state);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback_environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_fallback_environment", "get_fallback_environment");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_effects", PROPERTY_HINT_RESOURCE_TYPE, "CameraEffects"), "set_camera_effects", "get_camera_effects");
@@ -351,17 +351,17 @@ void World::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState", 0), "", "get_direct_space_state");
}
-World::World() {
+World3D::World3D() {
- space = PhysicsServer::get_singleton()->space_create();
- scenario = VisualServer::get_singleton()->scenario_create();
+ space = PhysicsServer3D::get_singleton()->space_create();
+ scenario = RenderingServer::get_singleton()->scenario_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));
+ PhysicsServer3D::get_singleton()->space_set_active(space, true);
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/3d/default_gravity", 9.8));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/3d/default_gravity_vector", Vector3(0, -1, 0)));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/3d/default_linear_damp", 0.1));
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/default_linear_damp", PropertyInfo(Variant::FLOAT, "physics/3d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"));
- PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/3d/default_angular_damp", 0.1));
+ PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/3d/default_angular_damp", 0.1));
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/3d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"));
#ifdef _3D_DISABLED
@@ -371,10 +371,10 @@ World::World() {
#endif
}
-World::~World() {
+World3D::~World3D() {
- PhysicsServer::get_singleton()->free(space);
- VisualServer::get_singleton()->free(scenario);
+ PhysicsServer3D::get_singleton()->free(space);
+ RenderingServer::get_singleton()->free(scenario);
#ifndef _3D_DISABLED
memdelete(indexer);
diff --git a/scene/resources/world.h b/scene/resources/world_3d.h
index 6fd79abaaf..81a27a7349 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* world.h */
+/* world_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,21 +28,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef WORLD_H
-#define WORLD_H
+#ifndef WORLD_3D_H
+#define WORLD_3D_H
#include "core/resource.h"
#include "scene/resources/environment.h"
-#include "servers/physics_server.h"
-#include "servers/visual_server.h"
+#include "servers/physics_server_3d.h"
+#include "servers/rendering_server.h"
-class Camera;
-class VisibilityNotifier;
+class Camera3D;
+class VisibilityNotifier3D;
struct SpatialIndexer;
-class World : public Resource {
- GDCLASS(World, Resource);
- RES_BASE_EXTENSION("world");
+class World3D : public Resource {
+ GDCLASS(World3D, Resource);
private:
RID space;
@@ -55,16 +54,16 @@ private:
protected:
static void _bind_methods();
- friend class Camera;
- friend class VisibilityNotifier;
+ friend class Camera3D;
+ friend class VisibilityNotifier3D;
- void _register_camera(Camera *p_camera);
- void _update_camera(Camera *p_camera);
- void _remove_camera(Camera *p_camera);
+ void _register_camera(Camera3D *p_camera);
+ void _update_camera(Camera3D *p_camera);
+ void _remove_camera(Camera3D *p_camera);
- void _register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect);
- void _update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect);
- void _remove_notifier(VisibilityNotifier *p_notifier);
+ void _register_notifier(VisibilityNotifier3D *p_notifier, const AABB &p_rect);
+ void _update_notifier(VisibilityNotifier3D *p_notifier, const AABB &p_rect);
+ void _remove_notifier(VisibilityNotifier3D *p_notifier);
friend class Viewport;
void _update(uint64_t p_frame);
@@ -81,12 +80,12 @@ public:
void set_camera_effects(const Ref<CameraEffects> &p_camera_effects);
Ref<CameraEffects> get_camera_effects() const;
- void get_camera_list(List<Camera *> *r_cameras);
+ void get_camera_list(List<Camera3D *> *r_cameras);
- PhysicsDirectSpaceState *get_direct_space_state();
+ PhysicsDirectSpaceState3D *get_direct_space_state();
- World();
- ~World();
+ World3D();
+ ~World3D();
};
-#endif // WORLD_H
+#endif // WORLD_3D_H
diff --git a/scene/resources/world_margin_shape.cpp b/scene/resources/world_margin_shape_3d.cpp
index b5b701327c..aa96f8aa68 100644
--- a/scene/resources/world_margin_shape.cpp
+++ b/scene/resources/world_margin_shape_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* world_margin_shape.cpp */
+/* world_margin_shape_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "world_margin_shape.h"
+#include "world_margin_shape_3d.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
-Vector<Vector3> WorldMarginShape::get_debug_mesh_lines() {
+Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() {
Plane p = get_plane();
Vector<Vector3> points;
@@ -61,13 +61,13 @@ Vector<Vector3> WorldMarginShape::get_debug_mesh_lines() {
return points;
}
-void WorldMarginShape::_update_shape() {
+void WorldMarginShape3D::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane);
- Shape::_update_shape();
+ PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), plane);
+ Shape3D::_update_shape();
}
-void WorldMarginShape::set_plane(Plane p_plane) {
+void WorldMarginShape3D::set_plane(Plane p_plane) {
plane = p_plane;
_update_shape();
@@ -75,21 +75,21 @@ void WorldMarginShape::set_plane(Plane p_plane) {
_change_notify("plane");
}
-Plane WorldMarginShape::get_plane() const {
+Plane WorldMarginShape3D::get_plane() const {
return plane;
}
-void WorldMarginShape::_bind_methods() {
+void WorldMarginShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape::set_plane);
- ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape::get_plane);
+ ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape3D::set_plane);
+ ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape3D::get_plane);
ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane");
}
-WorldMarginShape::WorldMarginShape() :
- Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) {
+WorldMarginShape3D::WorldMarginShape3D() :
+ Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_PLANE)) {
set_plane(Plane(0, 1, 0, 0));
}
diff --git a/scene/resources/world_margin_shape.h b/scene/resources/world_margin_shape_3d.h
index 78ea570212..5e0f046628 100644
--- a/scene/resources/world_margin_shape.h
+++ b/scene/resources/world_margin_shape_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* world_margin_shape.h */
+/* world_margin_shape_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef WORLD_MARGIN_SHAPE_H
-#define WORLD_MARGIN_SHAPE_H
+#ifndef WORLD_MARGIN_SHAPE_3D_H
+#define WORLD_MARGIN_SHAPE_3D_H
-#include "scene/resources/shape.h"
+#include "scene/resources/shape_3d.h"
-class WorldMarginShape : public Shape {
+class WorldMarginShape3D : public Shape3D {
- GDCLASS(WorldMarginShape, Shape);
+ GDCLASS(WorldMarginShape3D, Shape3D);
Plane plane;
protected:
@@ -52,6 +52,6 @@ public:
return 0;
}
- WorldMarginShape();
+ WorldMarginShape3D();
};
#endif // WORLD_MARGIN_SHAPE_H
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index d3c5a87cae..1f0365dab9 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -193,6 +193,12 @@ SceneStringNames::SceneStringNames() {
mesh_materials[i] = "material/" + itos(i);
}
+ _window_group = StaticCString::create("_window_group");
+ _window_input = StaticCString::create("_window_input");
+ window_input = StaticCString::create("window_input");
+ _window_unhandled_input = StaticCString::create("_window_unhandled_input");
+
+ theme_changed = StaticCString::create("theme_changed");
parameters_base_path = "parameters/";
tracks_changed = "tracks_changed";
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 7976a2072c..e255ebb3cb 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -201,6 +201,13 @@ public:
StringName tracks_changed;
+ StringName _window_group;
+ StringName _window_input;
+ StringName _window_unhandled_input;
+ StringName window_input;
+
+ StringName theme_changed;
+
enum {
MAX_MATERIALS = 32
};
diff --git a/servers/SCsub b/servers/SCsub
index 34ba70b8cb..7706b99d87 100644
--- a/servers/SCsub
+++ b/servers/SCsub
@@ -7,9 +7,9 @@ env.add_source_files(env.servers_sources, "*.cpp")
SConscript('arvr/SCsub')
SConscript('camera/SCsub')
-SConscript('physics/SCsub')
+SConscript('physics_3d/SCsub')
SConscript('physics_2d/SCsub')
-SConscript('visual/SCsub')
+SConscript('rendering/SCsub')
SConscript('audio/SCsub')
lib = env.add_library("servers", env.servers_sources)
diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h
index f33ddb2411..861061cbf5 100644
--- a/servers/arvr/arvr_interface.h
+++ b/servers/arvr/arvr_interface.h
@@ -33,7 +33,7 @@
#include "core/math/camera_matrix.h"
#include "core/os/thread_safe.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "servers/arvr_server.h"
/**
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index a64e36b6a2..dabeb7b86f 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "arvr_positional_tracker.h"
-#include "core/os/input.h"
+#include "core/input/input_filter.h"
void ARVRPositionalTracker::_bind_methods() {
BIND_ENUM_CONSTANT(TRACKER_HAND_UNKNOWN);
diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp
index 4b3417db6c..724414ae96 100644
--- a/servers/arvr_server.cpp
+++ b/servers/arvr_server.cpp
@@ -343,7 +343,7 @@ uint64_t ARVRServer::get_last_frame_usec() {
};
void ARVRServer::_process() {
- /* called from visual_server_viewport.draw_viewports right before we start drawing our viewports */
+ /* called from rendering_server_viewport.draw_viewports right before we start drawing our viewports */
/* mark for our frame timing */
last_process_usec = OS::get_singleton()->get_ticks_usec();
diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp
deleted file mode 100644
index 3bf0b0ea96..0000000000
--- a/servers/audio/reverb_sw.cpp
+++ /dev/null
@@ -1,538 +0,0 @@
-/*************************************************************************/
-/* reverb_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "reverb_sw.h"
-
-#include "core/print_string.h"
-
-#include <stdlib.h>
-
-#define SETMIN(x, y) (x) = MIN((x), (y))
-
-#define rangeloop(c, min, max) \
- for ((c) = (min); (c) < (max); (c)++)
-
-#define MULSHIFT_S32(Factor1, Factor2, Bits) \
- ((int)(((int64_t)(Factor1) * (Factor2)) >> (Bits)))
-
-struct ReverbParamsSW {
- unsigned int BufferSize; // Required buffer size
- int gLPF; // Coefficient
- int gEcho0; // Coefficient
- int gEcho1; // Coefficient
- int gEcho2; // Coefficient
- int gEcho3; // Coefficient
- int gWall; // Coefficient
- int gReva; // Coefficient
- int gRevb; // Coefficient
- int gInputL; // Coefficient
- int gInputR; // Coefficient
- unsigned int nRevaOldL; // Offset
- unsigned int nRevaOldR; // Offset
- unsigned int nRevbOldL; // Offset
- unsigned int nRevbOldR; // Offset
- unsigned int nLwlNew; // Offset
- unsigned int nRwrNew; // Offset
- unsigned int nEcho0L; // Offset
- unsigned int nEcho0R; // Offset
- unsigned int nEcho1L; // Offset
- unsigned int nEcho1R; // Offset
- unsigned int nLwlOld; // Offset
- unsigned int nRwrOld; // Offset
- unsigned int nLwrNew; // Offset
- unsigned int nRwlNew; // Offset
- unsigned int nEcho2L; // Offset
- unsigned int nEcho2R; // Offset
- unsigned int nEcho3L; // Offset
- unsigned int nEcho3R; // Offset
- unsigned int nLwrOld; // Offset
- unsigned int nRwlOld; // Offset
- unsigned int nRevaNewL; // Offset
- unsigned int nRevaNewR; // Offset
- unsigned int nRevbNewL; // Offset
- unsigned int nRevbNewR; // Offset
-};
-
-static ReverbParamsSW reverb_params_Room = {
- 0x26C0 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x6D80, 0x54B8, -0x4130, 0x0000, 0x0000, -0x4580,
- //gReva gRevb gInputL gInputR
- 0x5800, 0x5300, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x01B4 - 0x007D, 0x0136 - 0x007D, 0x00B8 - 0x005B, 0x005C - 0x005B,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x04D6, 0x0333, 0x03F0, 0x0227, 0x0374, 0x01EF,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x0334, 0x01B5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x0000, 0x0000, 0x01B4, 0x0136, 0x00B8, 0x005C
-};
-
-static ReverbParamsSW reverb_params_StudioSmall = {
- 0x1F40 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x70F0, 0x4FA8, -0x4320, 0x4410, -0x3F10, -0x6400,
- //gReva gRevb gInputL gInputR
- 0x5280, 0x4EC0, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x00B4 - 0x0033, 0x0080 - 0x0033, 0x004C - 0x0025, 0x0026 - 0x0025,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x03E4, 0x031B, 0x03A4, 0x02AF, 0x0372, 0x0266,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x031C, 0x025D, 0x025C, 0x018E, 0x022F, 0x0135, 0x01D2, 0x00B7,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x018F, 0x00B5, 0x00B4, 0x0080, 0x004C, 0x0026
-};
-
-static ReverbParamsSW reverb_params_StudioMedium = {
- 0x4840 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x70F0, 0x4FA8, -0x4320, 0x4510, -0x4110, -0x4B40,
- //gReva gRevb gInputL gInputR
- 0x5280, 0x4EC0, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x0264 - 0x00B1, 0x01B2 - 0x00B1, 0x0100 - 0x007F, 0x0080 - 0x007F,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x0904, 0x076B, 0x0824, 0x065F, 0x07A2, 0x0616,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x076C, 0x05ED, 0x05EC, 0x042E, 0x050F, 0x0305, 0x0462, 0x02B7,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x042F, 0x0265, 0x0264, 0x01B2, 0x0100, 0x0080
-};
-
-static ReverbParamsSW reverb_params_StudioLarge = {
- 0x6FE0 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x6F60, 0x4FA8, -0x4320, 0x4510, -0x4110, -0x5980,
- //gReva gRevb gInputL gInputR
- 0x5680, 0x52C0, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x031C - 0x00E3, 0x0238 - 0x00E3, 0x0154 - 0x00A9, 0x00AA - 0x00A9,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x0DFB, 0x0B58, 0x0D09, 0x0A3C, 0x0BD9, 0x0973,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x0B59, 0x08DA, 0x08D9, 0x05E9, 0x07EC, 0x04B0, 0x06EF, 0x03D2,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x05EA, 0x031D, 0x031C, 0x0238, 0x0154, 0x00AA
-};
-
-static ReverbParamsSW reverb_params_Hall = {
- 0xADE0 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x6000, 0x5000, 0x4C00, -0x4800, -0x4400, -0x4000,
- //gReva gRevb gInputL gInputR
- 0x6000, 0x5C00, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x05C0 - 0x01A5, 0x041A - 0x01A5, 0x0274 - 0x0139, 0x013A - 0x0139,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x15BA, 0x11BB, 0x14C2, 0x10BD, 0x11BC, 0x0DC1,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x11C0, 0x0DC3, 0x0DC0, 0x09C1, 0x0BC4, 0x07C1, 0x0A00, 0x06CD,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x09C2, 0x05C1, 0x05C0, 0x041A, 0x0274, 0x013A
-};
-
-static ReverbParamsSW reverb_params_SpaceEcho = {
- 0xF6C0 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x7E00, 0x5000, -0x4C00, -0x5000, 0x4C00, -0x5000,
- //gReva gRevb gInputL gInputR
- 0x6000, 0x5400, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x0AE0 - 0x033D, 0x07A2 - 0x033D, 0x0464 - 0x0231, 0x0232 - 0x0231,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x1ED6, 0x1A31, 0x1D14, 0x183B, 0x1BC2, 0x16B2,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x1A32, 0x15EF, 0x15EE, 0x1055, 0x1334, 0x0F2D, 0x11F6, 0x0C5D,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x1056, 0x0AE1, 0x0AE0, 0x07A2, 0x0464, 0x0232
-};
-
-static ReverbParamsSW reverb_params_Echo = {
- 0x18040 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x7FFF, 0x7FFF, 0x0000, 0x0000, 0x0000, -0x7F00,
- //gReva gRevb gInputL gInputR
- 0x0000, 0x0000, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x1004 - 0x0001, 0x1002 - 0x0001, 0x0004 - 0x0001, 0x0002 - 0x0001,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x1FFF, 0x0FFF, 0x1005, 0x0005, 0x0000, 0x0000,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x1005, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x0000, 0x0000, 0x1004, 0x1002, 0x0004, 0x0002
-};
-
-static ReverbParamsSW reverb_params_Delay = {
- 0x18040 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x7FFF, 0x7FFF, 0x0000, 0x0000, 0x0000, 0x0000,
- //gReva gRevb gInputL gInputR
- 0x0000, 0x0000, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x1004 - 0x0001, 0x1002 - 0x0001, 0x0004 - 0x0001, 0x0002 - 0x0001,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x1FFF, 0x0FFF, 0x1005, 0x0005, 0x0000, 0x0000,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x1005, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x0000, 0x0000, 0x1004, 0x1002, 0x0004, 0x0002
-};
-
-static ReverbParamsSW reverb_params_HalfEcho = {
- 0x3C00 / 2,
- //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
- 0x70F0, 0x4FA8, -0x4320, 0x4510, -0x4110, -0x7B00,
- //gReva gRevb gInputL gInputR
- 0x5F80, 0x54C0, -0x8000, -0x8000,
- //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
- 0x0058 - 0x0017, 0x0040 - 0x0017, 0x0028 - 0x0013, 0x0014 - 0x0013,
- //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
- 0x0371, 0x02AF, 0x02E5, 0x01DF, 0x02B0, 0x01D7,
- //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
- 0x0358, 0x026A, 0x01D6, 0x011E, 0x012D, 0x00B1, 0x011F, 0x0059,
- //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
- 0x01A0, 0x00E3, 0x0058, 0x0040, 0x0028, 0x0014
-};
-
-static ReverbParamsSW *reverb_param_modes[] = {
- &reverb_params_Room,
- &reverb_params_StudioSmall,
- &reverb_params_StudioMedium,
- &reverb_params_StudioLarge,
- &reverb_params_Hall,
- &reverb_params_SpaceEcho,
- &reverb_params_Echo,
- &reverb_params_Delay,
- &reverb_params_HalfEcho,
-};
-
-bool ReverbSW::process(int *p_input, int *p_output, int p_frames, int p_stereo_stride) {
-
- // p_input must point to a non-looping buffer.
- // BOTH p_input and p_output must be touched (use ClearModuleBuffer).
-
- if (!reverb_buffer)
- return false;
-
-// LOCAL MACROS
-#undef LM_SETSRCOFFSET
-#define LM_SETSRCOFFSET(x) \
- (x) = current_params->x + Offset; \
- if ((x) >= reverb_buffer_size) { \
- (x) -= reverb_buffer_size; \
- } \
- SETMIN(aSample, reverb_buffer_size - (x));
-
-/*
-#undef LM_SETSRCOFFSET2
-#define LM_SETSRCOFFSET2(x,y) \
- (x) = ((y) << 3) >> HZShift; \
- (x) += Offset; \
- if ( (x) >= reverb_buffer_size ) { \
- (x) -= reverb_buffer_size; \
- } \
- SETMIN ( aSample, reverb_buffer_size - (x) );
-*/
-#undef LM_SRCADVANCE
-#define LM_SRCADVANCE(x) \
- (x) += aSample;
-
-#undef LM_MUL
-#define LM_MUL(x, y) \
- MULSHIFT_S32(x, current_params->y, 15)
-
-#undef LM_REVERB
-#define LM_REVERB(x) reverb_buffer[(x) + cSample]
-
- // LOCAL VARIABLES
-
- unsigned int Offset;
-
- int lwl, lwr, rwl, rwr;
- //unsigned char HZShift;
-
- // CODE
-
- lwl = state.lwl;
- lwr = state.lwr;
- rwl = state.rwl;
- rwr = state.rwr;
- Offset = state.Offset;
-
- int max = 0;
-
- while (p_frames) {
-
- // Offsets
-
- unsigned int nLwlOld;
- unsigned int nRwrOld;
- unsigned int nLwlNew;
- unsigned int nRwrNew;
-
- unsigned int nLwrOld;
- unsigned int nRwlOld;
- unsigned int nLwrNew;
- unsigned int nRwlNew;
-
- unsigned int nEcho0L;
- unsigned int nEcho1L;
- unsigned int nEcho2L;
- unsigned int nEcho3L;
-
- unsigned int nEcho0R;
- unsigned int nEcho1R;
- unsigned int nEcho2R;
- unsigned int nEcho3R;
-
- unsigned int nRevaOldL;
- unsigned int nRevaOldR;
- unsigned int nRevbOldL;
- unsigned int nRevbOldR;
-
- unsigned int nRevaNewL;
- unsigned int nRevaNewR;
- unsigned int nRevbNewL;
- unsigned int nRevbNewR;
-
- // Other variables
-
- unsigned int aSample = p_frames;
-
- // Set initial offsets
-
- LM_SETSRCOFFSET(nLwlOld);
- LM_SETSRCOFFSET(nRwrOld);
- LM_SETSRCOFFSET(nLwlNew);
- LM_SETSRCOFFSET(nRwrNew);
- LM_SETSRCOFFSET(nLwrOld);
- LM_SETSRCOFFSET(nRwlOld);
- LM_SETSRCOFFSET(nLwrNew);
- LM_SETSRCOFFSET(nRwlNew);
- LM_SETSRCOFFSET(nEcho0L);
- LM_SETSRCOFFSET(nEcho1L);
- LM_SETSRCOFFSET(nEcho2L);
- LM_SETSRCOFFSET(nEcho3L);
- LM_SETSRCOFFSET(nEcho0R);
- LM_SETSRCOFFSET(nEcho1R);
- LM_SETSRCOFFSET(nEcho2R);
- LM_SETSRCOFFSET(nEcho3R);
- LM_SETSRCOFFSET(nRevaOldL);
- LM_SETSRCOFFSET(nRevaOldR);
- LM_SETSRCOFFSET(nRevbOldL);
- LM_SETSRCOFFSET(nRevbOldR);
- LM_SETSRCOFFSET(nRevaNewL);
- LM_SETSRCOFFSET(nRevaNewR);
- LM_SETSRCOFFSET(nRevbNewL);
- LM_SETSRCOFFSET(nRevbNewR);
-
- //SETMIN ( aSample, p_output.Size - p_output.Offset );
-
- for (unsigned int cSample = 0; cSample < aSample; cSample++) {
-
- int tempL0, tempL1, tempR0, tempR1;
-
- tempL1 = p_input[(cSample << p_stereo_stride)] >> 8;
- tempR1 = p_input[(cSample << p_stereo_stride) + 1] >> 8;
-
- tempL0 = LM_MUL(tempL1, gInputL);
- tempR0 = LM_MUL(tempR1, gInputR);
-
- /*
- Left -> Wall -> Left Reflection
- */
- tempL1 = tempL0 + LM_MUL(LM_REVERB(nLwlOld), gWall);
- tempR1 = tempR0 + LM_MUL(LM_REVERB(nRwrOld), gWall);
- lwl += LM_MUL(tempL1 - lwl, gLPF);
- rwr += LM_MUL(tempR1 - rwr, gLPF);
- LM_REVERB(nLwlNew) = lwl;
- LM_REVERB(nRwrNew) = rwr;
- /*
- Left -> Wall -> Right Reflection
- */
- tempL1 = tempL0 + LM_MUL(LM_REVERB(nRwlOld), gWall);
- tempR1 = tempR0 + LM_MUL(LM_REVERB(nLwrOld), gWall);
- lwr += LM_MUL(tempL1 - lwr, gLPF);
- rwl += LM_MUL(tempR1 - rwl, gLPF);
- LM_REVERB(nLwrNew) = lwr;
- LM_REVERB(nRwlNew) = rwl;
- /*
- Early Echo(Early Reflection)
- */
- tempL0 =
- LM_MUL(LM_REVERB(nEcho0L), gEcho0) +
- LM_MUL(LM_REVERB(nEcho1L), gEcho1) +
- LM_MUL(LM_REVERB(nEcho2L), gEcho2) +
- LM_MUL(LM_REVERB(nEcho3L), gEcho3);
- tempR0 =
- LM_MUL(LM_REVERB(nEcho0R), gEcho0) +
- LM_MUL(LM_REVERB(nEcho1R), gEcho1) +
- LM_MUL(LM_REVERB(nEcho2R), gEcho2) +
- LM_MUL(LM_REVERB(nEcho3R), gEcho3);
- /*
- Late Reverb
- */
- tempL1 = LM_REVERB(nRevaOldL);
- tempR1 = LM_REVERB(nRevaOldR);
- tempL0 -= LM_MUL(tempL1, gReva);
- tempR0 -= LM_MUL(tempR1, gReva);
- LM_REVERB(nRevaNewL) = tempL0;
- LM_REVERB(nRevaNewR) = tempR0;
- tempL0 = LM_MUL(tempL0, gReva) + tempL1;
- tempR0 = LM_MUL(tempR0, gReva) + tempR1;
- tempL1 = LM_REVERB(nRevbOldL);
- tempR1 = LM_REVERB(nRevbOldR);
- tempL0 -= LM_MUL(tempL1, gRevb);
- tempR0 -= LM_MUL(tempR1, gRevb);
- LM_REVERB(nRevbNewL) = tempL0;
- LM_REVERB(nRevbNewR) = tempR0;
- tempL0 = LM_MUL(tempL0, gRevb) + tempL1;
- tempR0 = LM_MUL(tempR0, gRevb) + tempR1;
- /*
- Output
- */
-
- max |= abs(tempL0);
- max |= abs(tempR0);
-
- p_output[(cSample << p_stereo_stride)] += tempL0 << 8;
- p_output[(cSample << p_stereo_stride) + 1] += tempR0 << 8;
- }
-
- // Advance offsets
-
- Offset += aSample;
- if (Offset >= reverb_buffer_size) {
- Offset -= reverb_buffer_size;
- }
-
- p_input += aSample << p_stereo_stride;
- p_output += aSample << p_stereo_stride;
-
- p_frames -= aSample;
- }
-
- state.lwl = lwl;
- state.lwr = lwr;
- state.rwl = rwl;
- state.rwr = rwr;
- state.Offset = Offset;
-
- return (max & 0x7FFFFF00) != 0; // audio was mixed?
-}
-
-void ReverbSW::adjust_current_params() {
-
- *current_params = *reverb_param_modes[mode];
-
- uint32_t maxofs = 0;
-
-#define LM_CONFIG_PARAM(x) \
- current_params->x = (int)(((int64_t)current_params->x * (int64_t)mix_rate * 8L) / (int64_t)44100); \
- if (current_params->x > maxofs) \
- maxofs = current_params->x;
-
- LM_CONFIG_PARAM(nLwlOld);
- LM_CONFIG_PARAM(nRwrOld);
- LM_CONFIG_PARAM(nLwlNew);
- LM_CONFIG_PARAM(nRwrNew);
- LM_CONFIG_PARAM(nLwrOld);
- LM_CONFIG_PARAM(nRwlOld);
- LM_CONFIG_PARAM(nLwrNew);
- LM_CONFIG_PARAM(nRwlNew);
- LM_CONFIG_PARAM(nEcho0L);
- LM_CONFIG_PARAM(nEcho1L);
- LM_CONFIG_PARAM(nEcho2L);
- LM_CONFIG_PARAM(nEcho3L);
- LM_CONFIG_PARAM(nEcho0R);
- LM_CONFIG_PARAM(nEcho1R);
- LM_CONFIG_PARAM(nEcho2R);
- LM_CONFIG_PARAM(nEcho3R);
- LM_CONFIG_PARAM(nRevaOldL);
- LM_CONFIG_PARAM(nRevaOldR);
- LM_CONFIG_PARAM(nRevbOldL);
- LM_CONFIG_PARAM(nRevbOldR);
- LM_CONFIG_PARAM(nRevaNewL);
- LM_CONFIG_PARAM(nRevaNewR);
- LM_CONFIG_PARAM(nRevbNewL);
- LM_CONFIG_PARAM(nRevbNewR);
-
- int needed_buffer_size = maxofs + 1;
- if (reverb_buffer)
- memdelete_arr(reverb_buffer);
-
- reverb_buffer = memnew_arr(int, needed_buffer_size);
- reverb_buffer_size = needed_buffer_size;
-
- for (uint32_t i = 0; i < reverb_buffer_size; i++)
- reverb_buffer[i] = 0;
-
- state.reset();
-}
-
-void ReverbSW::set_mode(ReverbMode p_mode) {
-
- if (mode == p_mode)
- return;
-
- mode = p_mode;
-
- adjust_current_params();
-}
-
-void ReverbSW::set_mix_rate(int p_mix_rate) {
-
- if (p_mix_rate == mix_rate)
- return;
-
- mix_rate = p_mix_rate;
-
- adjust_current_params();
-}
-
-ReverbSW::ReverbSW() {
-
- reverb_buffer = 0;
- reverb_buffer_size = 0;
- mode = REVERB_MODE_ROOM;
- mix_rate = 1;
- current_params = memnew(ReverbParamsSW);
-}
-
-ReverbSW::~ReverbSW() {
-
- if (reverb_buffer)
- memdelete_arr(reverb_buffer);
-
- memdelete(current_params);
-}
diff --git a/servers/audio/reverb_sw.h b/servers/audio/reverb_sw.h
deleted file mode 100644
index 13c63e602a..0000000000
--- a/servers/audio/reverb_sw.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*************************************************************************/
-/* reverb_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef REVERB_SW_H
-#define REVERB_SW_H
-
-#include "core/os/memory.h"
-#include "core/typedefs.h"
-
-struct ReverbParamsSW;
-
-class ReverbSW {
-public:
- enum ReverbMode {
- REVERB_MODE_ROOM,
- REVERB_MODE_STUDIO_SMALL,
- REVERB_MODE_STUDIO_MEDIUM,
- REVERB_MODE_STUDIO_LARGE,
- REVERB_MODE_HALL,
- REVERB_MODE_SPACE_ECHO,
- REVERB_MODE_ECHO,
- REVERB_MODE_DELAY,
- REVERB_MODE_HALF_ECHO
- };
-
-private:
- struct State {
- int lwl;
- int lwr;
- int rwl;
- int rwr;
- unsigned int Offset;
- void reset() {
- lwl = 0;
- lwr = 0;
- rwl = 0;
- rwr = 0;
- Offset = 0;
- }
- State() { reset(); }
- } state;
-
- ReverbParamsSW *current_params;
-
- int *reverb_buffer;
- unsigned int reverb_buffer_size;
- ReverbMode mode;
- int mix_rate;
-
- void adjust_current_params();
-
-public:
- void set_mode(ReverbMode p_mode);
- bool process(int *p_input, int *p_output, int p_frames, int p_stereo_stride = 1); // return tru if audio was created
- void set_mix_rate(int p_mix_rate);
-
- ReverbSW();
- ~ReverbSW();
-};
-
-#endif
diff --git a/servers/audio/voice_rb_sw.h b/servers/audio/voice_rb_sw.h
deleted file mode 100644
index c51076035c..0000000000
--- a/servers/audio/voice_rb_sw.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*************************************************************************/
-/* voice_rb_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef VOICE_RB_SW_H
-#define VOICE_RB_SW_H
-
-#include "core/os/os.h"
-#include "servers/audio_server.h"
-class VoiceRBSW {
-public:
- enum {
- VOICE_RB_SIZE = 1024
- };
-
- struct Command {
-
- enum Type {
- CMD_NONE,
- CMD_PLAY,
- CMD_STOP,
- CMD_SET_VOLUME,
- CMD_SET_PAN,
- CMD_SET_FILTER,
- CMD_SET_CHORUS,
- CMD_SET_REVERB,
- CMD_SET_MIX_RATE,
- CMD_SET_POSITIONAL,
- CMD_CHANGE_ALL_FX_VOLUMES
- };
-
- Type type;
- RID voice;
-
- struct {
-
- RID sample;
-
- } play;
-
- union {
-
- struct {
-
- float volume;
- } volume;
-
- struct {
-
- float pan, depth, height;
- } pan;
-
- struct {
-
- AS::FilterType type;
- float cutoff;
- float resonance;
- float gain;
- } filter;
-
- struct {
- float send;
- } chorus;
- struct {
- float send;
- AS::ReverbRoomType room;
- } reverb;
-
- struct {
-
- int mix_rate;
- } mix_rate;
-
- struct {
-
- bool positional;
- } positional;
- };
-
- Command() { type = CMD_NONE; }
- };
-
-private:
- Command voice_cmd_rb[VOICE_RB_SIZE];
- volatile int read_pos;
- volatile int write_pos;
-
-public:
- _FORCE_INLINE_ bool commands_left() const { return read_pos != write_pos; }
- _FORCE_INLINE_ Command pop_command() {
- ERR_FAIL_COND_V(read_pos == write_pos, Command());
- Command cmd = voice_cmd_rb[read_pos];
- read_pos = (read_pos + 1) % VOICE_RB_SIZE;
- return cmd;
- }
- _FORCE_INLINE_ void push_command(const Command &p_command) {
-
- bool full = ((write_pos + 1) % VOICE_RB_SIZE) == read_pos;
- if (full) {
-#ifdef DEBUG_ENABLED
- if (OS::get_singleton()->is_stdout_verbose()) {
- ERR_FAIL_COND_MSG(((write_pos + 1) % VOICE_RB_SIZE) == read_pos, "Audio ring buffer full (too many commands).");
- }
-#endif
- return;
- }
-
- voice_cmd_rb[write_pos] = p_command;
- write_pos = (write_pos + 1) % VOICE_RB_SIZE;
- }
-
- VoiceRBSW() { read_pos = write_pos = 0; }
-};
-
-#endif // VOICE_RB_SW_H
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 0e68c8a543..02e6d0f2d4 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -1131,47 +1131,6 @@ double AudioServer::get_time_since_last_mix() const {
AudioServer *AudioServer::singleton = NULL;
-void *AudioServer::audio_data_alloc(uint32_t p_data_len, const uint8_t *p_from_data) {
-
- void *ad = memalloc(p_data_len);
- ERR_FAIL_COND_V(!ad, NULL);
- if (p_from_data) {
- copymem(ad, p_from_data, p_data_len);
- }
-
- {
- MutexLock lock(audio_data_lock);
-
- audio_data[ad] = p_data_len;
- audio_data_total_mem += p_data_len;
- audio_data_max_mem = MAX(audio_data_total_mem, audio_data_max_mem);
- }
-
- return ad;
-}
-
-void AudioServer::audio_data_free(void *p_data) {
-
- MutexLock lock(audio_data_lock);
-
- if (!audio_data.has(p_data)) {
- ERR_FAIL();
- }
-
- audio_data_total_mem -= audio_data[p_data];
- audio_data.erase(p_data);
- memfree(p_data);
-}
-
-size_t AudioServer::audio_data_get_total_memory_usage() const {
-
- return audio_data_total_mem;
-}
-size_t AudioServer::audio_data_get_max_memory_usage() const {
-
- return audio_data_max_mem;
-}
-
void AudioServer::add_callback(AudioCallback p_callback, void *p_userdata) {
lock();
CallbackItem ci;
@@ -1400,8 +1359,6 @@ void AudioServer::_bind_methods() {
AudioServer::AudioServer() {
singleton = this;
- audio_data_total_mem = 0;
- audio_data_max_mem = 0;
mix_frames = 0;
channel_count = 0;
to_mix = 0;
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 8df0172750..a1a3dde719 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -232,14 +232,6 @@ private:
static AudioServer *singleton;
- // TODO create an audiodata pool to optimize memory
-
- Map<void *, uint32_t> audio_data;
- size_t audio_data_total_mem;
- size_t audio_data_max_mem;
-
- Mutex audio_data_lock;
-
void init_channels_and_buffers();
void _mix_step();
@@ -350,12 +342,6 @@ public:
virtual double get_time_to_next_mix() const;
virtual double get_time_since_last_mix() const;
- void *audio_data_alloc(uint32_t p_data_len, const uint8_t *p_from_data = NULL);
- void audio_data_free(void *p_data);
-
- size_t audio_data_get_total_memory_usage() const;
- size_t audio_data_get_max_memory_usage() const;
-
void add_callback(AudioCallback p_callback, void *p_userdata);
void remove_callback(AudioCallback p_callback, void *p_userdata);
diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp
index e8537950ec..41f44abae8 100644
--- a/servers/camera/camera_feed.cpp
+++ b/servers/camera/camera_feed.cpp
@@ -30,7 +30,7 @@
#include "camera_feed.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
void CameraFeed::_bind_methods() {
// FIXME: Disabled during Vulkan refactoring, should be ported.
@@ -148,7 +148,7 @@ CameraFeed::CameraFeed() {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
// create a texture object
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA
texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create();
#endif
@@ -168,7 +168,7 @@ CameraFeed::CameraFeed(String p_name, FeedPosition p_position) {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
// create a texture object
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA
texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create();
#endif
@@ -178,7 +178,7 @@ CameraFeed::~CameraFeed() {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
// Free our textures
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
vs->free(texture[CameraServer::FEED_Y_IMAGE]);
vs->free(texture[CameraServer::FEED_CBCR_IMAGE]);
#endif
@@ -188,7 +188,7 @@ void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
if (active) {
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
int new_width = p_rgb_img->get_width();
int new_height = p_rgb_img->get_height();
@@ -198,7 +198,7 @@ void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) {
base_width = new_width;
base_height = new_height;
- vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAGS_DEFAULT);
+ vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAGS_DEFAULT);
}
vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_rgb_img);
@@ -211,7 +211,7 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
if (active) {
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
int new_width = p_ycbcr_img->get_width();
int new_height = p_ycbcr_img->get_height();
@@ -221,7 +221,7 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) {
base_width = new_width;
base_height = new_height;
- vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAGS_DEFAULT);
+ vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAGS_DEFAULT);
}
vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_ycbcr_img);
@@ -234,7 +234,7 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
if (active) {
- VisualServer *vs = VisualServer::get_singleton();
+ RenderingServer *vs = RenderingServer::get_singleton();
///@TODO investigate whether we can use thirdparty/misc/yuv2rgb.h here to convert our YUV data to RGB, our shader approach is potentially faster though..
// Wondering about including that into multiple projects, may cause issues.
@@ -250,10 +250,10 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) {
base_width = new_y_width;
base_height = new_y_height;
- vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING);
+ vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAG_USED_FOR_STREAMING);
///@TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
- vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING);
+ vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAG_USED_FOR_STREAMING);
}
vs->texture_set_data(texture[CameraServer::FEED_Y_IMAGE], p_y_img);
@@ -265,15 +265,15 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) {
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
-void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type) {
- VisualServer *vs = VisualServer::get_singleton();
+void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_format, RenderingServer::TextureType p_texture_type, FeedDataType p_data_type) {
+ RenderingServer *vs = RenderingServer::get_singleton();
if ((base_width != p_width) || (base_height != p_height)) {
// We're assuming here that our camera image doesn't change around formats etc, allocate the whole lot...
base_width = p_width;
base_height = p_height;
- vs->texture_allocate(texture[0], p_width, p_height, 0, p_format, p_texture_type, VS::TEXTURE_FLAGS_DEFAULT);
+ vs->texture_allocate(texture[0], p_width, p_height, 0, p_format, p_texture_type, RS::TEXTURE_FLAGS_DEFAULT);
}
datatype = p_data_type;
diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h
index b99ded68e4..52a737cd8d 100644
--- a/servers/camera/camera_feed.h
+++ b/servers/camera/camera_feed.h
@@ -34,7 +34,7 @@
#include "core/image.h"
#include "core/math/transform_2d.h"
#include "servers/camera_server.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
/**
@author Bastiaan Olij <mux213@gmail.com>
@@ -105,7 +105,7 @@ public:
void set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img);
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
- void allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type);
+ void allocate_texture(int p_width, int p_height, Image::Format p_format, RenderingServer::TextureType p_texture_type, FeedDataType p_data_type);
#endif
virtual bool activate_feed();
diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp
index fd88d15e58..1a86ff1af4 100644
--- a/servers/camera_server.cpp
+++ b/servers/camera_server.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "camera_server.h"
+#include "rendering_server.h"
#include "servers/camera/camera_feed.h"
-#include "visual_server.h"
////////////////////////////////////////////////////////
// CameraServer
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
new file mode 100644
index 0000000000..9798c57707
--- /dev/null
+++ b/servers/display_server.cpp
@@ -0,0 +1,597 @@
+/*************************************************************************/
+/* display_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "display_server.h"
+#include "core/input/input_filter.h"
+#include "scene/resources/texture.h"
+
+DisplayServer *DisplayServer::singleton = nullptr;
+DisplayServer::SwitchVSyncCallbackInThread DisplayServer::switch_vsync_function = nullptr;
+
+bool DisplayServer::hidpi_allowed = false;
+
+DisplayServer::DisplayServerCreate DisplayServer::server_create_functions[DisplayServer::MAX_SERVERS];
+int DisplayServer::server_create_count = 0;
+
+void DisplayServer::global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_add_separator(const String &p_menu_root) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+bool DisplayServer::global_menu_is_item_checked(const String &p_menu_root, int p_idx) const {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return false;
+}
+
+bool DisplayServer::global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return false;
+}
+
+Callable DisplayServer::global_menu_get_item_callback(const String &p_menu_root, int p_idx) {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return Callable();
+}
+
+Variant DisplayServer::global_menu_get_item_tag(const String &p_menu_root, int p_idx) {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return Variant();
+}
+
+String DisplayServer::global_menu_get_item_text(const String &p_menu_root, int p_idx) {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return String();
+}
+
+String DisplayServer::global_menu_get_item_submenu(const String &p_menu_root, int p_idx) {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return String();
+}
+
+void DisplayServer::global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+int DisplayServer::global_menu_get_item_count(const String &p_menu_root) const {
+ WARN_PRINT("Global menus not supported by this display server.");
+ return 0;
+}
+
+void DisplayServer::global_menu_remove_item(const String &p_menu_root, int p_idx) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::global_menu_clear(const String &p_menu_root) {
+ WARN_PRINT("Global menus not supported by this display server.");
+}
+
+void DisplayServer::mouse_set_mode(MouseMode p_mode) {
+ WARN_PRINT("Mouse is not supported by this display server.");
+}
+DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
+ return MOUSE_MODE_VISIBLE;
+}
+
+void DisplayServer::mouse_warp_to_position(const Point2i &p_to) {
+ WARN_PRINT("Mouse warping is not supported by this display server.");
+}
+Point2i DisplayServer::mouse_get_absolute_position() const {
+ ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
+}
+Point2i DisplayServer::mouse_get_position() const {
+ ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
+}
+int DisplayServer::mouse_get_button_state() const {
+ ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server.");
+}
+
+void DisplayServer::clipboard_set(const String &p_text) {
+ WARN_PRINT("Clipboard is not supported by this display server.");
+}
+String DisplayServer::clipboard_get() const {
+ ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server.");
+}
+
+void DisplayServer::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
+ WARN_PRINT("Orientation not supported by this display server.");
+}
+DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_screen) const {
+ return SCREEN_LANDSCAPE;
+}
+
+float DisplayServer::screen_get_scale(int p_screen) const {
+ return 1.0f;
+};
+
+bool DisplayServer::screen_is_touchscreen(int p_screen) const {
+ //return false;
+ return InputFilter::get_singleton() && InputFilter::get_singleton()->is_emulating_touch_from_mouse();
+}
+
+void DisplayServer::screen_set_keep_on(bool p_enable) {
+ WARN_PRINT("Keeping screen on not supported by this display server.");
+}
+bool DisplayServer::screen_is_kept_on() const {
+ return false;
+}
+
+DisplayServer::WindowID DisplayServer::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &) {
+ ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Sub-windows not supported by this display server.");
+}
+void DisplayServer::delete_sub_window(WindowID p_id) {
+ ERR_FAIL_MSG("Sub-windows not supported by this display server.");
+}
+
+void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) {
+ WARN_PRINT("IME not supported by this display server.");
+}
+void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
+ WARN_PRINT("IME not supported by this display server.");
+}
+
+Point2i DisplayServer::ime_get_selection() const {
+ ERR_FAIL_V_MSG(Point2i(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server.");
+}
+String DisplayServer::ime_get_text() const {
+ ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATEnot supported by this display server.");
+}
+
+void DisplayServer::console_set_visible(bool p_enabled) {
+ WARN_PRINT("Console window not supported by this display server.");
+}
+bool DisplayServer::is_console_visible() const {
+ return false;
+}
+
+void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_legth) {
+ WARN_PRINT("Virtual keyboard not supported by this display server.");
+}
+void DisplayServer::virtual_keyboard_hide() {
+ WARN_PRINT("Virtual keyboard not supported by this display server.");
+}
+
+// returns height of the currently shown keyboard (0 if keyboard is hidden)
+int DisplayServer::virtual_keyboard_get_height() const {
+ ERR_FAIL_V_MSG(0, "Virtual keyboad not supported by this display server.");
+}
+
+void DisplayServer::cursor_set_shape(CursorShape p_shape) {
+ WARN_PRINT("Cursor shape not supported by this display server.");
+}
+DisplayServer::CursorShape DisplayServer::cursor_get_shape() const {
+ return CURSOR_ARROW;
+}
+void DisplayServer::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+ WARN_PRINT("Custom cursor shape not supported by this display server.");
+}
+
+bool DisplayServer::get_swap_ok_cancel() {
+ return false;
+}
+
+void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) {
+}
+
+//plays video natively, in fullscreen, only implemented in mobile for now, likely not possible to implement on linux also.
+Error DisplayServer::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen) {
+ ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Native video not supported by this display server.");
+}
+bool DisplayServer::native_video_is_playing() const {
+ return false;
+}
+void DisplayServer::native_video_pause() {
+ WARN_PRINT("Native video not supported by this display server.");
+}
+void DisplayServer::native_video_unpause() {
+ WARN_PRINT("Native video not supported by this display server.");
+}
+void DisplayServer::native_video_stop() {
+ WARN_PRINT("Native video not supported by this display server.");
+}
+
+Error DisplayServer::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
+ WARN_PRINT("Native dialogs not supported by this display server.");
+ return OK;
+}
+Error DisplayServer::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
+ WARN_PRINT("Native dialogs not supported by this display server.");
+ return OK;
+}
+
+DisplayServer::LatinKeyboardVariant DisplayServer::get_latin_keyboard_variant() const {
+ return LATIN_KEYBOARD_QWERTY;
+}
+
+void DisplayServer::force_process_and_drop_events() {
+}
+
+void DisplayServer::release_rendering_thread() {
+ WARN_PRINT("Rendering thread not supported by this display server.");
+}
+void DisplayServer::make_rendering_thread() {
+ WARN_PRINT("Rendering thread not supported by this display server.");
+}
+void DisplayServer::swap_buffers() {
+ WARN_PRINT("Swap buffers not supported by this display server.");
+}
+
+void DisplayServer::set_native_icon(const String &p_filename) {
+ WARN_PRINT("Native icon not supported by this display server.");
+}
+void DisplayServer::set_icon(const Ref<Image> &p_icon) {
+ WARN_PRINT("Icon not supported by this display server.");
+}
+
+void DisplayServer::_set_use_vsync(bool p_enable) {
+ WARN_PRINT("VSync not supported by this display server.");
+}
+void DisplayServer::vsync_set_enabled(bool p_enable) {
+ vsync_enabled = p_enable;
+ if (switch_vsync_function) { //if a function was set, use function
+ switch_vsync_function(p_enable);
+ } else { //otherwise just call here
+ _set_use_vsync(p_enable);
+ }
+}
+bool DisplayServer::vsync_is_enabled() const {
+ return vsync_enabled;
+}
+
+void DisplayServer::vsync_set_use_via_compositor(bool p_enable) {
+ WARN_PRINT("VSync via compositor not supported by this display server.");
+}
+bool DisplayServer::vsync_is_using_via_compositor() const {
+ return false;
+}
+
+void DisplayServer::set_context(Context p_context) {
+}
+
+void DisplayServer::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("has_feature", "feature"), &DisplayServer::has_feature);
+ ClassDB::bind_method(D_METHOD("get_name"), &DisplayServer::get_name);
+
+ ClassDB::bind_method(D_METHOD("global_menu_add_item", "menu_root", "label", "callback", "tag"), &DisplayServer::global_menu_add_item, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("global_menu_add_check_item", "menu_root", "label", "callback", "tag"), &DisplayServer::global_menu_add_check_item, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("global_menu_add_submenu_item", "menu_root", "label", "submenu"), &DisplayServer::global_menu_add_submenu_item);
+ ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu_root"), &DisplayServer::global_menu_add_separator);
+
+ ClassDB::bind_method(D_METHOD("global_menu_is_item_checked", "menu_root", "idx"), &DisplayServer::global_menu_is_item_checked);
+ ClassDB::bind_method(D_METHOD("global_menu_is_item_checkable", "menu_root", "idx"), &DisplayServer::global_menu_is_item_checkable);
+ ClassDB::bind_method(D_METHOD("global_menu_get_item_callback", "menu_root", "idx"), &DisplayServer::global_menu_get_item_callback);
+ ClassDB::bind_method(D_METHOD("global_menu_get_item_tag", "menu_root", "idx"), &DisplayServer::global_menu_get_item_tag);
+ ClassDB::bind_method(D_METHOD("global_menu_get_item_text", "menu_root", "idx"), &DisplayServer::global_menu_get_item_text);
+ ClassDB::bind_method(D_METHOD("global_menu_get_item_submenu", "menu_root", "idx"), &DisplayServer::global_menu_get_item_submenu);
+
+ ClassDB::bind_method(D_METHOD("global_menu_set_item_checked", "menu_root", "idx", "checked"), &DisplayServer::global_menu_set_item_checked);
+ ClassDB::bind_method(D_METHOD("global_menu_set_item_checkable", "menu_root", "idx", "checkable"), &DisplayServer::global_menu_set_item_checkable);
+ ClassDB::bind_method(D_METHOD("global_menu_set_item_callback", "menu_root", "idx", "callback"), &DisplayServer::global_menu_set_item_callback);
+ ClassDB::bind_method(D_METHOD("global_menu_set_item_tag", "menu_root", "idx", "tag"), &DisplayServer::global_menu_set_item_tag);
+ ClassDB::bind_method(D_METHOD("global_menu_set_item_text", "menu_root", "idx", "text"), &DisplayServer::global_menu_set_item_text);
+ ClassDB::bind_method(D_METHOD("global_menu_set_item_submenu", "menu_root", "idx", "submenu"), &DisplayServer::global_menu_set_item_submenu);
+
+ ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu_root", "idx"), &DisplayServer::global_menu_remove_item);
+ ClassDB::bind_method(D_METHOD("global_menu_clear", "menu_root"), &DisplayServer::global_menu_clear);
+
+ ClassDB::bind_method(D_METHOD("alert", "text", "title"), &DisplayServer::alert, DEFVAL("Alert!"));
+
+ ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode);
+ ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode);
+
+ ClassDB::bind_method(D_METHOD("mouse_warp_to_position", "position"), &DisplayServer::mouse_warp_to_position);
+ ClassDB::bind_method(D_METHOD("mouse_get_position"), &DisplayServer::mouse_get_position);
+ ClassDB::bind_method(D_METHOD("mouse_get_absolute_position"), &DisplayServer::mouse_get_absolute_position);
+ ClassDB::bind_method(D_METHOD("mouse_get_button_state"), &DisplayServer::mouse_get_button_state);
+
+ ClassDB::bind_method(D_METHOD("clipboard_set", "clipboard"), &DisplayServer::clipboard_set);
+ ClassDB::bind_method(D_METHOD("clipboard_get"), &DisplayServer::clipboard_get);
+
+ ClassDB::bind_method(D_METHOD("get_screen_count"), &DisplayServer::get_screen_count);
+ ClassDB::bind_method(D_METHOD("screen_get_position", "screen"), &DisplayServer::screen_get_position, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_size", "screen"), &DisplayServer::screen_get_size, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_usable_rect", "screen"), &DisplayServer::screen_get_usable_rect, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_dpi", "screen"), &DisplayServer::screen_get_dpi, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_scale", "screen"), &DisplayServer::screen_get_scale, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_is_touchscreen", "screen"), &DisplayServer::screen_is_touchscreen, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+
+ ClassDB::bind_method(D_METHOD("screen_set_orientation", "orientation", "screen"), &DisplayServer::screen_set_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+ ClassDB::bind_method(D_METHOD("screen_get_orientation", "screen"), &DisplayServer::screen_get_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
+
+ ClassDB::bind_method(D_METHOD("screen_set_keep_on", "enable"), &DisplayServer::screen_set_keep_on);
+ ClassDB::bind_method(D_METHOD("screen_is_kept_on"), &DisplayServer::screen_is_kept_on);
+
+ ClassDB::bind_method(D_METHOD("get_window_list"), &DisplayServer::get_window_list);
+ ClassDB::bind_method(D_METHOD("get_window_at_screen_position", "position"), &DisplayServer::get_window_at_screen_position);
+
+ ClassDB::bind_method(D_METHOD("create_sub_window", "mode", "rect"), &DisplayServer::create_sub_window, DEFVAL(Rect2i()));
+ ClassDB::bind_method(D_METHOD("delete_sub_window", "window_id"), &DisplayServer::delete_sub_window);
+
+ ClassDB::bind_method(D_METHOD("window_set_title", "title", "window_id"), &DisplayServer::window_set_title, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_current_screen", "window_id"), &DisplayServer::window_get_current_screen, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_current_screen", "screen", "window_id"), &DisplayServer::window_set_current_screen, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_position", "window_id"), &DisplayServer::window_get_position, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_position", "position", "window_id"), &DisplayServer::window_set_position, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_size", "window_id"), &DisplayServer::window_get_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_size", "size", "window_id"), &DisplayServer::window_set_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_rect_changed_callback", "callback", "window_id"), &DisplayServer::window_set_rect_changed_callback, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_window_event_callback", "callback", "window_id"), &DisplayServer::window_set_window_event_callback, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_input_event_callback", "callback", "window_id"), &DisplayServer::window_set_input_event_callback, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_input_text_callback", "callback", "window_id"), &DisplayServer::window_set_input_text_callback, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_drop_files_callback", "callback", "window_id"), &DisplayServer::window_set_drop_files_callback, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_attach_instance_id", "instance_id", "window_id"), &DisplayServer::window_attach_instance_id, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_get_attached_instance_id", "window_id"), &DisplayServer::window_get_attached_instance_id, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_max_size", "window_id"), &DisplayServer::window_get_max_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_max_size", "max_size", "window_id"), &DisplayServer::window_set_max_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_min_size", "window_id"), &DisplayServer::window_get_min_size, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_min_size", "min_size", "window_id"), &DisplayServer::window_set_min_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_real_size", "window_id"), &DisplayServer::window_get_real_size, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_get_mode", "window_id"), &DisplayServer::window_get_mode, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_mode", "mode", "window_id"), &DisplayServer::window_set_mode, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_set_flag", "flag", "enabled", "window_id"), &DisplayServer::window_set_flag, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_get_flag", "flag", "window_id"), &DisplayServer::window_get_flag, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_request_attention", "window_id"), &DisplayServer::window_request_attention, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_move_to_foreground", "window_id"), &DisplayServer::window_move_to_foreground, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_can_draw", "window_id"), &DisplayServer::window_can_draw, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("window_set_transient", "window_id", "parent_window_id"), &DisplayServer::window_set_transient);
+
+ ClassDB::bind_method(D_METHOD("window_set_ime_active", "active", "window_id"), &DisplayServer::window_set_ime_active, DEFVAL(MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("window_set_ime_position", "position", "window_id"), &DisplayServer::window_set_ime_position, DEFVAL(MAIN_WINDOW_ID));
+
+ ClassDB::bind_method(D_METHOD("ime_get_selection"), &DisplayServer::ime_get_selection);
+ ClassDB::bind_method(D_METHOD("ime_get_text"), &DisplayServer::ime_get_text);
+
+ ClassDB::bind_method(D_METHOD("console_set_visible", "console_visible"), &DisplayServer::console_set_visible);
+ ClassDB::bind_method(D_METHOD("is_console_visible"), &DisplayServer::is_console_visible);
+
+ ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position", "max_length"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("virtual_keyboard_hide"), &DisplayServer::virtual_keyboard_hide);
+
+ ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height);
+
+ ClassDB::bind_method(D_METHOD("cursor_set_shape", "shape"), &DisplayServer::cursor_set_shape);
+ ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);
+ ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
+
+ ClassDB::bind_method(D_METHOD("get_swap_ok_cancel"), &DisplayServer::get_swap_ok_cancel);
+
+ ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus);
+
+ ClassDB::bind_method(D_METHOD("native_video_play", "path", "volume", "audio_track", "subtitle_track"), &DisplayServer::native_video_play);
+ ClassDB::bind_method(D_METHOD("native_video_is_playing"), &DisplayServer::native_video_is_playing);
+ ClassDB::bind_method(D_METHOD("native_video_stop"), &DisplayServer::native_video_stop);
+ ClassDB::bind_method(D_METHOD("native_video_pause"), &DisplayServer::native_video_pause);
+ ClassDB::bind_method(D_METHOD("native_video_unpause"), &DisplayServer::native_video_unpause);
+
+ ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show);
+ ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_show);
+
+ ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &DisplayServer::get_latin_keyboard_variant);
+
+ ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
+ ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
+
+ ClassDB::bind_method(D_METHOD("vsync_set_enabled", "enabled"), &DisplayServer::vsync_set_enabled);
+ ClassDB::bind_method(D_METHOD("vsync_is_enabled"), &DisplayServer::vsync_is_enabled);
+
+ ClassDB::bind_method(D_METHOD("vsync_set_use_via_compositor", "enabled"), &DisplayServer::vsync_set_use_via_compositor);
+ ClassDB::bind_method(D_METHOD("vsync_is_using_via_compositor"), &DisplayServer::vsync_is_using_via_compositor);
+
+ ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &DisplayServer::set_native_icon);
+ ClassDB::bind_method(D_METHOD("set_icon", "image"), &DisplayServer::set_icon);
+
+ BIND_ENUM_CONSTANT(FEATURE_GLOBAL_MENU);
+ BIND_ENUM_CONSTANT(FEATURE_SUBWINDOWS);
+ BIND_ENUM_CONSTANT(FEATURE_TOUCHSCREEN);
+ BIND_ENUM_CONSTANT(FEATURE_MOUSE);
+ BIND_ENUM_CONSTANT(FEATURE_MOUSE_WARP);
+ BIND_ENUM_CONSTANT(FEATURE_CLIPBOARD);
+ BIND_ENUM_CONSTANT(FEATURE_VIRTUAL_KEYBOARD);
+ BIND_ENUM_CONSTANT(FEATURE_CURSOR_SHAPE);
+ BIND_ENUM_CONSTANT(FEATURE_CUSTOM_CURSOR_SHAPE);
+ BIND_ENUM_CONSTANT(FEATURE_NATIVE_VIDEO);
+ BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG);
+ BIND_ENUM_CONSTANT(FEATURE_CONSOLE_WINDOW);
+ BIND_ENUM_CONSTANT(FEATURE_IME);
+ BIND_ENUM_CONSTANT(FEATURE_WINDOW_TRANSPARENCY);
+ BIND_ENUM_CONSTANT(FEATURE_HIDPI);
+ BIND_ENUM_CONSTANT(FEATURE_ICON);
+ BIND_ENUM_CONSTANT(FEATURE_NATIVE_ICON);
+ BIND_ENUM_CONSTANT(FEATURE_ORIENTATION);
+ BIND_ENUM_CONSTANT(FEATURE_SWAP_BUFFERS);
+
+ BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
+ BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
+
+ BIND_CONSTANT(SCREEN_OF_MAIN_WINDOW);
+ BIND_CONSTANT(MAIN_WINDOW_ID);
+ BIND_CONSTANT(INVALID_WINDOW_ID);
+
+ BIND_ENUM_CONSTANT(SCREEN_LANDSCAPE);
+ BIND_ENUM_CONSTANT(SCREEN_PORTRAIT);
+ BIND_ENUM_CONSTANT(SCREEN_REVERSE_LANDSCAPE);
+ BIND_ENUM_CONSTANT(SCREEN_REVERSE_PORTRAIT);
+ BIND_ENUM_CONSTANT(SCREEN_SENSOR_LANDSCAPE);
+ BIND_ENUM_CONSTANT(SCREEN_SENSOR_PORTRAIT);
+ BIND_ENUM_CONSTANT(SCREEN_SENSOR);
+
+ BIND_ENUM_CONSTANT(CURSOR_ARROW);
+ BIND_ENUM_CONSTANT(CURSOR_IBEAM);
+ BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
+ BIND_ENUM_CONSTANT(CURSOR_CROSS);
+ BIND_ENUM_CONSTANT(CURSOR_WAIT);
+ BIND_ENUM_CONSTANT(CURSOR_BUSY);
+ BIND_ENUM_CONSTANT(CURSOR_DRAG);
+ BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
+ BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
+ BIND_ENUM_CONSTANT(CURSOR_VSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_HSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_MOVE);
+ BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HELP);
+ BIND_ENUM_CONSTANT(CURSOR_MAX);
+
+ BIND_ENUM_CONSTANT(WINDOW_MODE_WINDOWED);
+ BIND_ENUM_CONSTANT(WINDOW_MODE_MINIMIZED);
+ BIND_ENUM_CONSTANT(WINDOW_MODE_MAXIMIZED);
+ BIND_ENUM_CONSTANT(WINDOW_MODE_FULLSCREEN);
+
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT_BIT);
+ BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS_BIT);
+
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTY);
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTZ);
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_AZERTY);
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QZERTY);
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_DVORAK);
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_NEO);
+ BIND_ENUM_CONSTANT(LATIN_KEYBOARD_COLEMAK);
+
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER);
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_EXIT);
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_IN);
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_OUT);
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_CLOSE_REQUEST);
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_GO_BACK_REQUEST);
+ BIND_ENUM_CONSTANT(WINDOW_EVENT_DPI_CHANGE);
+}
+
+void DisplayServer::register_create_function(const char *p_name, CreateFunction p_function, GetRenderingDriversFunction p_get_drivers) {
+ ERR_FAIL_COND(server_create_count == MAX_SERVERS);
+ server_create_functions[server_create_count].name = p_name;
+ server_create_functions[server_create_count].create_function = p_function;
+ server_create_functions[server_create_count].get_rendering_drivers_function = p_get_drivers;
+ server_create_count++;
+}
+
+int DisplayServer::get_create_function_count() {
+ return server_create_count;
+}
+
+const char *DisplayServer::get_create_function_name(int p_index) {
+ ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
+ return server_create_functions[p_index].name;
+}
+
+Vector<String> DisplayServer::get_create_function_rendering_drivers(int p_index) {
+ ERR_FAIL_INDEX_V(p_index, server_create_count, Vector<String>());
+ return server_create_functions[p_index].get_rendering_drivers_function();
+}
+
+DisplayServer *DisplayServer::create(int p_index, const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
+ ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
+ return server_create_functions[p_index].create_function(p_rendering_driver, p_mode, p_flags, p_resolution, r_error);
+}
+
+void DisplayServer::_input_set_mouse_mode(InputFilter::MouseMode p_mode) {
+ singleton->mouse_set_mode(MouseMode(p_mode));
+}
+InputFilter::MouseMode DisplayServer::_input_get_mouse_mode() {
+ return InputFilter::MouseMode(singleton->mouse_get_mode());
+}
+
+void DisplayServer::_input_warp(const Vector2 &p_to_pos) {
+ singleton->mouse_warp_to_position(p_to_pos);
+}
+
+InputFilter::CursorShape DisplayServer::_input_get_current_cursor_shape() {
+ return (InputFilter::CursorShape)singleton->cursor_get_shape();
+}
+void DisplayServer::_input_set_custom_mouse_cursor_func(const RES &p_image, InputFilter::CursorShape p_shape, const Vector2 &p_hostspot) {
+ singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hostspot);
+}
+
+DisplayServer::DisplayServer() {
+ singleton = this;
+ InputFilter::set_mouse_mode_func = _input_set_mouse_mode;
+ InputFilter::get_mouse_mode_func = _input_get_mouse_mode;
+ InputFilter::warp_mouse_func = _input_warp;
+ InputFilter::get_current_cursor_shape_func = _input_get_current_cursor_shape;
+ InputFilter::set_custom_mouse_cursor_func = _input_set_custom_mouse_cursor_func;
+}
+DisplayServer::~DisplayServer() {
+}
diff --git a/servers/display_server.h b/servers/display_server.h
new file mode 100644
index 0000000000..c0e92891a3
--- /dev/null
+++ b/servers/display_server.h
@@ -0,0 +1,385 @@
+/*************************************************************************/
+/* display_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef DISPLAY_SERVER_H
+#define DISPLAY_SERVER_H
+
+#include "core/callable.h"
+#include "core/input/input_filter.h"
+#include "core/os/os.h"
+#include "core/resource.h"
+
+class Texture2D;
+
+class DisplayServer : public Object {
+ GDCLASS(DisplayServer, Object)
+
+ static DisplayServer *singleton;
+ bool vsync_enabled = true;
+ static bool hidpi_allowed;
+
+public:
+ _FORCE_INLINE_ static DisplayServer *get_singleton() {
+ return singleton;
+ }
+
+ enum WindowMode {
+ WINDOW_MODE_WINDOWED,
+ WINDOW_MODE_MINIMIZED,
+ WINDOW_MODE_MAXIMIZED,
+ WINDOW_MODE_FULLSCREEN
+ };
+
+ typedef DisplayServer *(*CreateFunction)(const String &, WindowMode, uint32_t, const Size2i &, Error &r_error);
+ typedef Vector<String> (*GetRenderingDriversFunction)();
+
+private:
+ static void _input_set_mouse_mode(InputFilter::MouseMode p_mode);
+ static InputFilter::MouseMode _input_get_mouse_mode();
+ static void _input_warp(const Vector2 &p_to_pos);
+ static InputFilter::CursorShape _input_get_current_cursor_shape();
+ static void _input_set_custom_mouse_cursor_func(const RES &, InputFilter::CursorShape, const Vector2 &p_hostspot);
+
+protected:
+ static void _bind_methods();
+
+ enum {
+ MAX_SERVERS = 64
+ };
+
+ struct DisplayServerCreate {
+ const char *name;
+ CreateFunction create_function;
+ GetRenderingDriversFunction get_rendering_drivers_function;
+ };
+
+ static DisplayServerCreate server_create_functions[MAX_SERVERS];
+ static int server_create_count;
+
+ friend class RenderingServerRaster;
+ virtual void _set_use_vsync(bool p_enable);
+
+public:
+ enum Feature {
+ FEATURE_GLOBAL_MENU,
+ FEATURE_SUBWINDOWS,
+ FEATURE_TOUCHSCREEN,
+ FEATURE_MOUSE,
+ FEATURE_MOUSE_WARP,
+ FEATURE_CLIPBOARD,
+ FEATURE_VIRTUAL_KEYBOARD,
+ FEATURE_CURSOR_SHAPE,
+ FEATURE_CUSTOM_CURSOR_SHAPE,
+ FEATURE_NATIVE_VIDEO,
+ FEATURE_NATIVE_DIALOG,
+ FEATURE_CONSOLE_WINDOW,
+ FEATURE_IME,
+ FEATURE_WINDOW_TRANSPARENCY,
+ FEATURE_HIDPI,
+ FEATURE_ICON,
+ FEATURE_NATIVE_ICON,
+ FEATURE_ORIENTATION,
+ FEATURE_SWAP_BUFFERS,
+ FEATURE_KEEP_SCREEN_ON,
+ };
+
+ virtual bool has_feature(Feature p_feature) const = 0;
+ virtual String get_name() const = 0;
+
+ virtual void global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
+ virtual void global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback, const Variant &p_tag = Variant());
+ virtual void global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu);
+ virtual void global_menu_add_separator(const String &p_menu_root);
+
+ virtual bool global_menu_is_item_checked(const String &p_menu_root, int p_idx) const;
+ virtual bool global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const;
+ virtual Callable global_menu_get_item_callback(const String &p_menu_root, int p_idx);
+ virtual Variant global_menu_get_item_tag(const String &p_menu_root, int p_idx);
+ virtual String global_menu_get_item_text(const String &p_menu_root, int p_idx);
+ virtual String global_menu_get_item_submenu(const String &p_menu_root, int p_idx);
+
+ virtual void global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked);
+ virtual void global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable);
+ virtual void global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback);
+ virtual void global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag);
+ virtual void global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text);
+ virtual void global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu);
+
+ virtual int global_menu_get_item_count(const String &p_menu_root) const;
+
+ virtual void global_menu_remove_item(const String &p_menu_root, int p_idx);
+ virtual void global_menu_clear(const String &p_menu_root);
+
+ virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0;
+
+ enum MouseMode {
+ MOUSE_MODE_VISIBLE,
+ MOUSE_MODE_HIDDEN,
+ MOUSE_MODE_CAPTURED,
+ MOUSE_MODE_CONFINED
+ };
+
+ virtual void mouse_set_mode(MouseMode p_mode);
+ virtual MouseMode mouse_get_mode() const;
+
+ virtual void mouse_warp_to_position(const Point2i &p_to);
+ virtual Point2i mouse_get_position() const;
+ virtual Point2i mouse_get_absolute_position() const;
+ virtual int mouse_get_button_state() const;
+
+ virtual void clipboard_set(const String &p_text);
+ virtual String clipboard_get() const;
+
+ enum {
+ SCREEN_OF_MAIN_WINDOW = -1
+ };
+
+ virtual int get_screen_count() const = 0;
+ virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0;
+ virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ enum ScreenOrientation {
+
+ SCREEN_LANDSCAPE,
+ SCREEN_PORTRAIT,
+ SCREEN_REVERSE_LANDSCAPE,
+ SCREEN_REVERSE_PORTRAIT,
+ SCREEN_SENSOR_LANDSCAPE,
+ SCREEN_SENSOR_PORTRAIT,
+ SCREEN_SENSOR,
+ };
+
+ virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW);
+ ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+
+ virtual void screen_set_keep_on(bool p_enable); //disable screensaver
+ virtual bool screen_is_kept_on() const;
+ enum {
+ MAIN_WINDOW_ID = 0,
+ INVALID_WINDOW_ID = -1
+ };
+
+ typedef int WindowID;
+
+ virtual Vector<DisplayServer::WindowID> get_window_list() const = 0;
+
+ enum WindowFlags {
+ WINDOW_FLAG_RESIZE_DISABLED,
+ WINDOW_FLAG_BORDERLESS,
+ WINDOW_FLAG_ALWAYS_ON_TOP,
+ WINDOW_FLAG_TRANSPARENT,
+ WINDOW_FLAG_NO_FOCUS,
+ WINDOW_FLAG_MAX,
+ WINDOW_FLAG_RESIZE_DISABLED_BIT = (1 << WINDOW_FLAG_RESIZE_DISABLED),
+ WINDOW_FLAG_BORDERLESS_BIT = (1 << WINDOW_FLAG_BORDERLESS),
+ WINDOW_FLAG_ALWAYS_ON_TOP_BIT = (1 << WINDOW_FLAG_ALWAYS_ON_TOP),
+ WINDOW_FLAG_TRANSPARENT_BIT = (1 << WINDOW_FLAG_TRANSPARENT),
+ WINDOW_FLAG_NO_FOCUS_BIT = (1 << WINDOW_FLAG_NO_FOCUS)
+ };
+
+ virtual WindowID create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i & = Rect2i());
+ virtual void delete_sub_window(WindowID p_id);
+
+ virtual WindowID get_window_at_screen_position(const Point2i &p_position) const = 0;
+
+ virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ enum WindowEvent {
+ WINDOW_EVENT_MOUSE_ENTER,
+ WINDOW_EVENT_MOUSE_EXIT,
+ WINDOW_EVENT_FOCUS_IN,
+ WINDOW_EVENT_FOCUS_OUT,
+ WINDOW_EVENT_CLOSE_REQUEST,
+ WINDOW_EVENT_GO_BACK_REQUEST,
+ WINDOW_EVENT_DPI_CHANGE,
+ };
+ virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+ virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+ virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual void window_set_transient(WindowID p_window, WindowID p_parent) = 0;
+
+ virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+ virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const = 0; // FIXME: Find clearer name for this.
+
+ virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) = 0;
+ virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) = 0;
+
+ virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const = 0;
+
+ virtual bool can_any_window_draw() const = 0;
+
+ virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID);
+ virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID);
+
+ virtual Point2i ime_get_selection() const;
+ virtual String ime_get_text() const;
+
+ virtual void console_set_visible(bool p_enabled);
+ virtual bool is_console_visible() const;
+
+ virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_legth = -1);
+ virtual void virtual_keyboard_hide();
+
+ // returns height of the currently shown virtual keyboard (0 if keyboard is hidden)
+ virtual int virtual_keyboard_get_height() const;
+
+ enum CursorShape {
+ CURSOR_ARROW,
+ CURSOR_IBEAM,
+ CURSOR_POINTING_HAND,
+ CURSOR_CROSS,
+ CURSOR_WAIT,
+ CURSOR_BUSY,
+ CURSOR_DRAG,
+ CURSOR_CAN_DROP,
+ CURSOR_FORBIDDEN,
+ CURSOR_VSIZE,
+ CURSOR_HSIZE,
+ CURSOR_BDIAGSIZE,
+ CURSOR_FDIAGSIZE,
+ CURSOR_MOVE,
+ CURSOR_VSPLIT,
+ CURSOR_HSPLIT,
+ CURSOR_HELP,
+ CURSOR_MAX
+ };
+ virtual void cursor_set_shape(CursorShape p_shape);
+ virtual CursorShape cursor_get_shape() const;
+ virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
+
+ virtual bool get_swap_ok_cancel();
+
+ virtual void enable_for_stealing_focus(OS::ProcessID pid);
+
+ //plays video natively, in fullscreen, only implemented in mobile for now, likely not possible to implement on linux also.
+ virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen = SCREEN_OF_MAIN_WINDOW);
+ virtual bool native_video_is_playing() const;
+ virtual void native_video_pause();
+ virtual void native_video_unpause();
+ virtual void native_video_stop();
+
+ virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback);
+ virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback);
+
+ enum LatinKeyboardVariant {
+ LATIN_KEYBOARD_QWERTY,
+ LATIN_KEYBOARD_QWERTZ,
+ LATIN_KEYBOARD_AZERTY,
+ LATIN_KEYBOARD_QZERTY,
+ LATIN_KEYBOARD_DVORAK,
+ LATIN_KEYBOARD_NEO,
+ LATIN_KEYBOARD_COLEMAK,
+ };
+
+ virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+
+ virtual void process_events() = 0;
+
+ virtual void force_process_and_drop_events();
+
+ virtual void release_rendering_thread();
+ virtual void make_rendering_thread();
+ virtual void swap_buffers();
+
+ virtual void set_native_icon(const String &p_filename);
+ virtual void set_icon(const Ref<Image> &p_icon);
+
+ typedef void (*SwitchVSyncCallbackInThread)(bool);
+
+ static SwitchVSyncCallbackInThread switch_vsync_function;
+
+ void vsync_set_enabled(bool p_enable);
+ bool vsync_is_enabled() const;
+
+ virtual void vsync_set_use_via_compositor(bool p_enable);
+ virtual bool vsync_is_using_via_compositor() const;
+
+ //real, actual overridable function to switch vsync, which needs to be called from graphics thread if needed
+
+ enum Context {
+ CONTEXT_EDITOR,
+ CONTEXT_PROJECTMAN,
+ CONTEXT_ENGINE,
+ };
+
+ virtual void set_context(Context p_context);
+
+ static void register_create_function(const char *p_name, CreateFunction p_function, GetRenderingDriversFunction p_get_drivers);
+ static int get_create_function_count();
+ static const char *get_create_function_name(int p_index);
+ static Vector<String> get_create_function_rendering_drivers(int p_index);
+ static DisplayServer *create(int p_index, const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
+
+ DisplayServer();
+ ~DisplayServer();
+};
+
+VARIANT_ENUM_CAST(DisplayServer::WindowEvent)
+VARIANT_ENUM_CAST(DisplayServer::Feature)
+VARIANT_ENUM_CAST(DisplayServer::MouseMode)
+VARIANT_ENUM_CAST(DisplayServer::ScreenOrientation)
+VARIANT_ENUM_CAST(DisplayServer::WindowMode)
+VARIANT_ENUM_CAST(DisplayServer::WindowFlags)
+VARIANT_ENUM_CAST(DisplayServer::CursorShape)
+VARIANT_ENUM_CAST(DisplayServer::LatinKeyboardVariant)
+
+#endif // DISPLAY_SERVER_H
diff --git a/servers/navigation_2d_server.cpp b/servers/navigation_server_2d.cpp
index d9b53122e2..fe9eaa5736 100644
--- a/servers/navigation_2d_server.cpp
+++ b/servers/navigation_server_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_2d_server.cpp */
+/* navigation_server_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,77 +28,77 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server_2d.h"
#include "core/math/transform.h"
#include "core/math/transform_2d.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
/**
@author AndreaCatania
*/
-Navigation2DServer *Navigation2DServer::singleton = NULL;
+NavigationServer2D *NavigationServer2D::singleton = NULL;
-#define FORWARD_0_C(FUNC_NAME) \
- Navigation2DServer::FUNC_NAME() \
- const { \
- return NavigationServer::get_singleton()->FUNC_NAME(); \
+#define FORWARD_0_C(FUNC_NAME) \
+ NavigationServer2D::FUNC_NAME() \
+ const { \
+ return NavigationServer3D::get_singleton()->FUNC_NAME(); \
}
-#define FORWARD_1(FUNC_NAME, T_0, D_0, CONV_0) \
- Navigation2DServer::FUNC_NAME(T_0 D_0) { \
- return NavigationServer::get_singleton_mut()->FUNC_NAME(CONV_0(D_0)); \
+#define FORWARD_1(FUNC_NAME, T_0, D_0, CONV_0) \
+ NavigationServer2D::FUNC_NAME(T_0 D_0) { \
+ return NavigationServer3D::get_singleton_mut()->FUNC_NAME(CONV_0(D_0)); \
}
-#define FORWARD_1_C(FUNC_NAME, T_0, D_0, CONV_0) \
- Navigation2DServer::FUNC_NAME(T_0 D_0) \
- const { \
- return NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0)); \
+#define FORWARD_1_C(FUNC_NAME, T_0, D_0, CONV_0) \
+ NavigationServer2D::FUNC_NAME(T_0 D_0) \
+ const { \
+ return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0)); \
}
-#define FORWARD_2_C(FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \
- Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1) \
- const { \
- return NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1)); \
+#define FORWARD_2_C(FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \
+ NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1) \
+ const { \
+ return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1)); \
}
-#define FORWARD_2_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \
- Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1) \
- const { \
- return CONV_R(NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1))); \
+#define FORWARD_2_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \
+ NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1) \
+ const { \
+ return CONV_R(NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1))); \
}
-#define FORWARD_4_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \
- Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \
- const { \
- return CONV_R(NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3))); \
+#define FORWARD_4_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \
+ NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \
+ const { \
+ return CONV_R(NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3))); \
}
-#define FORWARD_4_C(FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \
- Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \
- const { \
- return NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3)); \
+#define FORWARD_4_C(FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \
+ NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \
+ const { \
+ return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3)); \
}
-RID rid_to_rid(const RID d) {
+static RID rid_to_rid(const RID d) {
return d;
}
-bool bool_to_bool(const bool d) {
+static bool bool_to_bool(const bool d) {
return d;
}
-int int_to_int(const int d) {
+static int int_to_int(const int d) {
return d;
}
-real_t real_to_real(const real_t d) {
+static real_t real_to_real(const real_t d) {
return d;
}
-Vector3 v2_to_v3(const Vector2 d) {
+static Vector3 v2_to_v3(const Vector2 d) {
return Vector3(d.x, 0.0, d.y);
}
-Vector2 v3_to_v2(const Vector3 &d) {
+static Vector2 v3_to_v2(const Vector3 &d) {
return Vector2(d.x, d.z);
}
-Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) {
+static Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) {
Vector<Vector2> nd;
nd.resize(d.size());
for (int i(0); i < nd.size(); i++) {
@@ -106,22 +106,22 @@ Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) {
}
return nd;
}
-Transform trf2_to_trf3(const Transform2D &d) {
+static Transform trf2_to_trf3(const Transform2D &d) {
Vector3 o(v2_to_v3(d.get_origin()));
Basis b;
b.rotate(Vector3(0, 1, 0), d.get_rotation());
return Transform(b, o);
}
-Object *obj_to_obj(Object *d) {
+static Object *obj_to_obj(Object *d) {
return d;
}
-StringName sn_to_sn(StringName &d) {
+static StringName sn_to_sn(StringName &d) {
return d;
}
-Variant var_to_var(Variant &d) {
+static Variant var_to_var(Variant &d) {
return d;
}
-Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) {
+static Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) {
if (d.is_valid()) {
return d->get_mesh();
} else {
@@ -129,44 +129,44 @@ Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) {
}
}
-void Navigation2DServer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("map_create"), &Navigation2DServer::map_create);
- ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &Navigation2DServer::map_set_active);
- ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &Navigation2DServer::map_is_active);
- ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &Navigation2DServer::map_set_cell_size);
- ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &Navigation2DServer::map_get_cell_size);
- ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &Navigation2DServer::map_set_edge_connection_margin);
- ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &Navigation2DServer::map_get_edge_connection_margin);
- ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &Navigation2DServer::map_get_path);
- ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &Navigation2DServer::map_get_closest_point);
- ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &Navigation2DServer::map_get_closest_point_owner);
-
- ClassDB::bind_method(D_METHOD("region_create"), &Navigation2DServer::region_create);
- ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &Navigation2DServer::region_set_map);
- ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &Navigation2DServer::region_set_transform);
- ClassDB::bind_method(D_METHOD("region_set_navpoly", "region", "nav_poly"), &Navigation2DServer::region_set_navpoly);
-
- ClassDB::bind_method(D_METHOD("agent_create"), &Navigation2DServer::agent_create);
- ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &Navigation2DServer::agent_set_map);
- ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &Navigation2DServer::agent_set_neighbor_dist);
- ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &Navigation2DServer::agent_set_max_neighbors);
- ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &Navigation2DServer::agent_set_time_horizon);
- ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &Navigation2DServer::agent_set_radius);
- ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &Navigation2DServer::agent_set_max_speed);
- ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &Navigation2DServer::agent_set_velocity);
- ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &Navigation2DServer::agent_set_target_velocity);
- ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &Navigation2DServer::agent_set_position);
- ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &Navigation2DServer::agent_is_map_changed);
- ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &Navigation2DServer::agent_set_callback, DEFVAL(Variant()));
-
- ClassDB::bind_method(D_METHOD("free", "object"), &Navigation2DServer::free);
-}
-
-Navigation2DServer::Navigation2DServer() {
+void NavigationServer2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer2D::map_create);
+ ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer2D::map_set_active);
+ ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer2D::map_is_active);
+ ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer2D::map_set_cell_size);
+ ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer2D::map_get_cell_size);
+ ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer2D::map_set_edge_connection_margin);
+ ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer2D::map_get_edge_connection_margin);
+ ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer2D::map_get_path);
+ ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer2D::map_get_closest_point);
+ ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer2D::map_get_closest_point_owner);
+
+ ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer2D::region_create);
+ ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer2D::region_set_map);
+ ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer2D::region_set_transform);
+ ClassDB::bind_method(D_METHOD("region_set_navpoly", "region", "nav_poly"), &NavigationServer2D::region_set_navpoly);
+
+ ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer2D::agent_create);
+ ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer2D::agent_set_map);
+ ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &NavigationServer2D::agent_set_neighbor_dist);
+ ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer2D::agent_set_max_neighbors);
+ ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &NavigationServer2D::agent_set_time_horizon);
+ ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer2D::agent_set_radius);
+ ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer2D::agent_set_max_speed);
+ ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer2D::agent_set_velocity);
+ ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer2D::agent_set_target_velocity);
+ ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer2D::agent_set_position);
+ ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer2D::agent_is_map_changed);
+ ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer2D::agent_set_callback, DEFVAL(Variant()));
+
+ ClassDB::bind_method(D_METHOD("free", "object"), &NavigationServer2D::free);
+}
+
+NavigationServer2D::NavigationServer2D() {
singleton = this;
}
-Navigation2DServer::~Navigation2DServer() {
+NavigationServer2D::~NavigationServer2D() {
singleton = NULL;
}
@@ -192,13 +192,13 @@ void FORWARD_2_C(region_set_map, RID, p_region, RID, p_map, rid_to_rid, rid_to_r
void FORWARD_2_C(region_set_transform, RID, p_region, Transform2D, p_transform, rid_to_rid, trf2_to_trf3);
-void Navigation2DServer::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) const {
- NavigationServer::get_singleton()->region_set_navmesh(p_region, poly_to_mesh(p_nav_mesh));
+void NavigationServer2D::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) const {
+ NavigationServer3D::get_singleton()->region_set_navmesh(p_region, poly_to_mesh(p_nav_mesh));
}
-RID Navigation2DServer::agent_create() const {
- RID agent = NavigationServer::get_singleton()->agent_create();
- NavigationServer::get_singleton()->agent_set_ignore_y(agent, true);
+RID NavigationServer2D::agent_create() const {
+ RID agent = NavigationServer3D::get_singleton()->agent_create();
+ NavigationServer3D::get_singleton()->agent_set_ignore_y(agent, true);
return agent;
}
diff --git a/servers/navigation_2d_server.h b/servers/navigation_server_2d.h
index 7b0b9fbb01..af914e5ba9 100644
--- a/servers/navigation_2d_server.h
+++ b/servers/navigation_server_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_2d_server.h */
+/* navigation_server_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -37,23 +37,23 @@
#include "core/object.h"
#include "core/rid.h"
-#include "scene/2d/navigation_polygon.h"
+#include "scene/2d/navigation_region_2d.h"
// This server exposes the 3D `NavigationServer` features in the 2D world.
-class Navigation2DServer : public Object {
- GDCLASS(Navigation2DServer, Object);
+class NavigationServer2D : public Object {
+ GDCLASS(NavigationServer2D, Object);
- static Navigation2DServer *singleton;
+ static NavigationServer2D *singleton;
protected:
static void _bind_methods();
public:
/// Thread safe, can be used across many threads.
- static const Navigation2DServer *get_singleton() { return singleton; }
+ static const NavigationServer2D *get_singleton() { return singleton; }
/// MUST be used in single thread!
- static Navigation2DServer *get_singleton_mut() { return singleton; }
+ static NavigationServer2D *get_singleton_mut() { return singleton; }
/// Create a new map.
virtual RID map_create() const;
@@ -156,8 +156,8 @@ public:
/// Destroy the `RID`
virtual void free(RID p_object) const;
- Navigation2DServer();
- virtual ~Navigation2DServer();
+ NavigationServer2D();
+ virtual ~NavigationServer2D();
};
#endif
diff --git a/servers/navigation_server.cpp b/servers/navigation_server_3d.cpp
index f2b727ac47..3e7a8e816e 100644
--- a/servers/navigation_server.cpp
+++ b/servers/navigation_server_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_server.cpp */
+/* navigation_server_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,76 +32,76 @@
@author AndreaCatania
*/
-#include "navigation_server.h"
-
-NavigationServer *NavigationServer::singleton = NULL;
-
-void NavigationServer::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer::map_create);
- ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer::map_set_active);
- ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer::map_is_active);
- ClassDB::bind_method(D_METHOD("map_set_up", "map", "up"), &NavigationServer::map_set_up);
- ClassDB::bind_method(D_METHOD("map_get_up", "map"), &NavigationServer::map_get_up);
- ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer::map_set_cell_size);
- ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer::map_get_cell_size);
- ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer::map_set_edge_connection_margin);
- ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer::map_get_edge_connection_margin);
- ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer::map_get_path);
- ClassDB::bind_method(D_METHOD("map_get_closest_point_to_segment", "map", "start", "end", "use_collision"), &NavigationServer::map_get_closest_point_to_segment, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer::map_get_closest_point);
- ClassDB::bind_method(D_METHOD("map_get_closest_point_normal", "map", "to_point"), &NavigationServer::map_get_closest_point_normal);
- ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer::map_get_closest_point_owner);
-
- ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer::region_create);
- ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer::region_set_map);
- ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer::region_set_transform);
- ClassDB::bind_method(D_METHOD("region_set_navmesh", "region", "nav_mesh"), &NavigationServer::region_set_navmesh);
- ClassDB::bind_method(D_METHOD("region_bake_navmesh", "mesh", "node"), &NavigationServer::region_bake_navmesh);
-
- ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer::agent_create);
- ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer::agent_set_map);
- ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &NavigationServer::agent_set_neighbor_dist);
- ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer::agent_set_max_neighbors);
- ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &NavigationServer::agent_set_time_horizon);
- ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer::agent_set_radius);
- ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer::agent_set_max_speed);
- ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer::agent_set_velocity);
- ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer::agent_set_target_velocity);
- ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer::agent_set_position);
- ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer::agent_is_map_changed);
- ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer::agent_set_callback, DEFVAL(Variant()));
-
- ClassDB::bind_method(D_METHOD("free", "object"), &NavigationServer::free);
-
- ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer::set_active);
- ClassDB::bind_method(D_METHOD("process", "delta_time"), &NavigationServer::process);
+#include "navigation_server_3d.h"
+
+NavigationServer3D *NavigationServer3D::singleton = NULL;
+
+void NavigationServer3D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer3D::map_create);
+ ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer3D::map_set_active);
+ ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer3D::map_is_active);
+ ClassDB::bind_method(D_METHOD("map_set_up", "map", "up"), &NavigationServer3D::map_set_up);
+ ClassDB::bind_method(D_METHOD("map_get_up", "map"), &NavigationServer3D::map_get_up);
+ ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer3D::map_set_cell_size);
+ ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer3D::map_get_cell_size);
+ ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer3D::map_set_edge_connection_margin);
+ ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer3D::map_get_edge_connection_margin);
+ ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer3D::map_get_path);
+ ClassDB::bind_method(D_METHOD("map_get_closest_point_to_segment", "map", "start", "end", "use_collision"), &NavigationServer3D::map_get_closest_point_to_segment, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer3D::map_get_closest_point);
+ ClassDB::bind_method(D_METHOD("map_get_closest_point_normal", "map", "to_point"), &NavigationServer3D::map_get_closest_point_normal);
+ ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer3D::map_get_closest_point_owner);
+
+ ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer3D::region_create);
+ ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer3D::region_set_map);
+ ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer3D::region_set_transform);
+ ClassDB::bind_method(D_METHOD("region_set_navmesh", "region", "nav_mesh"), &NavigationServer3D::region_set_navmesh);
+ ClassDB::bind_method(D_METHOD("region_bake_navmesh", "mesh", "node"), &NavigationServer3D::region_bake_navmesh);
+
+ ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer3D::agent_create);
+ ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer3D::agent_set_map);
+ ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &NavigationServer3D::agent_set_neighbor_dist);
+ ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer3D::agent_set_max_neighbors);
+ ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &NavigationServer3D::agent_set_time_horizon);
+ ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer3D::agent_set_radius);
+ ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer3D::agent_set_max_speed);
+ ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer3D::agent_set_velocity);
+ ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer3D::agent_set_target_velocity);
+ ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer3D::agent_set_position);
+ ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer3D::agent_is_map_changed);
+ ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer3D::agent_set_callback, DEFVAL(Variant()));
+
+ ClassDB::bind_method(D_METHOD("free", "object"), &NavigationServer3D::free);
+
+ ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer3D::set_active);
+ ClassDB::bind_method(D_METHOD("process", "delta_time"), &NavigationServer3D::process);
}
-const NavigationServer *NavigationServer::get_singleton() {
+const NavigationServer3D *NavigationServer3D::get_singleton() {
return singleton;
}
-NavigationServer *NavigationServer::get_singleton_mut() {
+NavigationServer3D *NavigationServer3D::get_singleton_mut() {
return singleton;
}
-NavigationServer::NavigationServer() {
+NavigationServer3D::NavigationServer3D() {
ERR_FAIL_COND(singleton != NULL);
singleton = this;
}
-NavigationServer::~NavigationServer() {
+NavigationServer3D::~NavigationServer3D() {
singleton = NULL;
}
-NavigationServerCallback NavigationServerManager::create_callback = NULL;
+NavigationServer3DCallback NavigationServer3DManager::create_callback = NULL;
-void NavigationServerManager::set_default_server(NavigationServerCallback p_callback) {
+void NavigationServer3DManager::set_default_server(NavigationServer3DCallback p_callback) {
create_callback = p_callback;
}
-NavigationServer *NavigationServerManager::new_default_server() {
+NavigationServer3D *NavigationServer3DManager::new_default_server() {
ERR_FAIL_COND_V(create_callback == NULL, NULL);
return create_callback();
}
diff --git a/servers/navigation_server.h b/servers/navigation_server_3d.h
index 546e543db3..c34bd2391b 100644
--- a/servers/navigation_server.h
+++ b/servers/navigation_server_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* navigation_server.h */
+/* navigation_server_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -37,7 +37,7 @@
#include "core/object.h"
#include "core/rid.h"
-#include "scene/3d/navigation_region.h"
+#include "scene/3d/navigation_region_3d.h"
/// This server uses the concept of internal mutability.
/// All the constant functions can be called in multithread because internally
@@ -45,20 +45,20 @@
///
/// Note: All the `set` functions are commands executed during the `sync` phase,
/// don't expect that a change is immediately propagated.
-class NavigationServer : public Object {
- GDCLASS(NavigationServer, Object);
+class NavigationServer3D : public Object {
+ GDCLASS(NavigationServer3D, Object);
- static NavigationServer *singleton;
+ static NavigationServer3D *singleton;
protected:
static void _bind_methods();
public:
/// Thread safe, can be used across many threads.
- static const NavigationServer *get_singleton();
+ static const NavigationServer3D *get_singleton();
/// MUST be used in single thread!
- static NavigationServer *get_singleton_mut();
+ static NavigationServer3D *get_singleton_mut();
/// Create a new map.
virtual RID map_create() const = 0;
@@ -181,19 +181,19 @@ public:
/// Note: This function is not thread safe.
virtual void process(real_t delta_time) = 0;
- NavigationServer();
- virtual ~NavigationServer();
+ NavigationServer3D();
+ virtual ~NavigationServer3D();
};
-typedef NavigationServer *(*NavigationServerCallback)();
+typedef NavigationServer3D *(*NavigationServer3DCallback)();
/// Manager used for the server singleton registration
-class NavigationServerManager {
- static NavigationServerCallback create_callback;
+class NavigationServer3DManager {
+ static NavigationServer3DCallback create_callback;
public:
- static void set_default_server(NavigationServerCallback p_callback);
- static NavigationServer *new_default_server();
+ static void set_default_server(NavigationServer3DCallback p_callback);
+ static NavigationServer3D *new_default_server();
};
#endif
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
deleted file mode 100644
index 25b21a5394..0000000000
--- a/servers/physics/physics_server_sw.cpp
+++ /dev/null
@@ -1,1589 +0,0 @@
-/*************************************************************************/
-/* physics_server_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "physics_server_sw.h"
-
-#include "broad_phase_basic.h"
-#include "broad_phase_octree.h"
-#include "core/debugger/engine_debugger.h"
-#include "core/os/os.h"
-#include "joints/cone_twist_joint_sw.h"
-#include "joints/generic_6dof_joint_sw.h"
-#include "joints/hinge_joint_sw.h"
-#include "joints/pin_joint_sw.h"
-#include "joints/slider_joint_sw.h"
-
-#define FLUSH_QUERY_CHECK(m_object) \
- ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
-
-RID PhysicsServerSW::shape_create(ShapeType p_shape) {
-
- ShapeSW *shape = NULL;
- switch (p_shape) {
-
- case SHAPE_PLANE: {
-
- shape = memnew(PlaneShapeSW);
- } break;
- case SHAPE_RAY: {
-
- shape = memnew(RayShapeSW);
- } break;
- case SHAPE_SPHERE: {
-
- shape = memnew(SphereShapeSW);
- } break;
- case SHAPE_BOX: {
-
- shape = memnew(BoxShapeSW);
- } break;
- case SHAPE_CAPSULE: {
-
- shape = memnew(CapsuleShapeSW);
- } break;
- case SHAPE_CYLINDER: {
-
- ERR_FAIL_V_MSG(RID(), "CylinderShape is not supported in GodotPhysics. Please switch to Bullet in the Project Settings.");
- } break;
- case SHAPE_CONVEX_POLYGON: {
-
- shape = memnew(ConvexPolygonShapeSW);
- } break;
- case SHAPE_CONCAVE_POLYGON: {
-
- shape = memnew(ConcavePolygonShapeSW);
- } break;
- case SHAPE_HEIGHTMAP: {
-
- shape = memnew(HeightMapShapeSW);
- } break;
- case SHAPE_CUSTOM: {
-
- ERR_FAIL_V(RID());
-
- } break;
- }
-
- RID id = shape_owner.make_rid(shape);
- shape->set_self(id);
-
- return id;
-};
-
-void PhysicsServerSW::shape_set_data(RID p_shape, const Variant &p_data) {
-
- ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND(!shape);
- shape->set_data(p_data);
-};
-
-void PhysicsServerSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
-
- ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND(!shape);
- shape->set_custom_bias(p_bias);
-}
-
-PhysicsServer::ShapeType PhysicsServerSW::shape_get_type(RID p_shape) const {
-
- const ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
- return shape->get_type();
-};
-
-Variant PhysicsServerSW::shape_get_data(RID p_shape) const {
-
- const ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND_V(!shape, Variant());
- ERR_FAIL_COND_V(!shape->is_configured(), Variant());
- return shape->get_data();
-};
-
-void PhysicsServerSW::shape_set_margin(RID p_shape, real_t p_margin) {
-}
-
-real_t PhysicsServerSW::shape_get_margin(RID p_shape) const {
- return 0.0;
-}
-
-real_t PhysicsServerSW::shape_get_custom_solver_bias(RID p_shape) const {
-
- const ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND_V(!shape, 0);
- return shape->get_custom_bias();
-}
-
-RID PhysicsServerSW::space_create() {
-
- SpaceSW *space = memnew(SpaceSW);
- RID id = space_owner.make_rid(space);
- space->set_self(id);
- RID area_id = area_create();
- AreaSW *area = area_owner.getornull(area_id);
- ERR_FAIL_COND_V(!area, RID());
- space->set_default_area(area);
- area->set_space(space);
- area->set_priority(-1);
- RID sgb = body_create();
- body_set_space(sgb, id);
- body_set_mode(sgb, BODY_MODE_STATIC);
- space->set_static_global_body(sgb);
-
- return id;
-};
-
-void PhysicsServerSW::space_set_active(RID p_space, bool p_active) {
-
- SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND(!space);
- if (p_active)
- active_spaces.insert(space);
- else
- active_spaces.erase(space);
-}
-
-bool PhysicsServerSW::space_is_active(RID p_space) const {
-
- const SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND_V(!space, false);
-
- return active_spaces.has(space);
-}
-
-void PhysicsServerSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
-
- SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND(!space);
-
- space->set_param(p_param, p_value);
-}
-
-real_t PhysicsServerSW::space_get_param(RID p_space, SpaceParameter p_param) const {
-
- const SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND_V(!space, 0);
- return space->get_param(p_param);
-}
-
-PhysicsDirectSpaceState *PhysicsServerSW::space_get_direct_state(RID p_space) {
-
- SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND_V(!space, NULL);
- ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification.");
-
- return space->get_direct_state();
-}
-
-void PhysicsServerSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
-
- SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND(!space);
- space->set_debug_contacts(p_max_contacts);
-}
-
-Vector<Vector3> PhysicsServerSW::space_get_contacts(RID p_space) const {
-
- SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND_V(!space, Vector<Vector3>());
- return space->get_debug_contacts();
-}
-
-int PhysicsServerSW::space_get_contact_count(RID p_space) const {
-
- SpaceSW *space = space_owner.getornull(p_space);
- ERR_FAIL_COND_V(!space, 0);
- return space->get_debug_contact_count();
-}
-
-RID PhysicsServerSW::area_create() {
-
- AreaSW *area = memnew(AreaSW);
- RID rid = area_owner.make_rid(area);
- area->set_self(rid);
- return rid;
-};
-
-void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- SpaceSW *space = NULL;
- if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
- ERR_FAIL_COND(!space);
- }
-
- if (area->get_space() == space)
- return; //pointless
-
- area->clear_constraints();
- area->set_space(space);
-};
-
-RID PhysicsServerSW::area_get_space(RID p_area) const {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, RID());
-
- SpaceSW *space = area->get_space();
- if (!space)
- return RID();
- return space->get_self();
-};
-
-void PhysicsServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_space_override_mode(p_mode);
-}
-
-PhysicsServer::AreaSpaceOverrideMode PhysicsServerSW::area_get_space_override_mode(RID p_area) const {
-
- const AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
-
- return area->get_space_override_mode();
-}
-
-void PhysicsServerSW::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND(!shape);
-
- area->add_shape(shape, p_transform, p_disabled);
-}
-
-void PhysicsServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND(!shape);
- ERR_FAIL_COND(!shape->is_configured());
-
- area->set_shape(p_shape_idx, shape);
-}
-
-void PhysicsServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_shape_transform(p_shape_idx, p_transform);
-}
-
-int PhysicsServerSW::area_get_shape_count(RID p_area) const {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, -1);
-
- return area->get_shape_count();
-}
-RID PhysicsServerSW::area_get_shape(RID p_area, int p_shape_idx) const {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, RID());
-
- ShapeSW *shape = area->get_shape(p_shape_idx);
- ERR_FAIL_COND_V(!shape, RID());
-
- return shape->get_self();
-}
-Transform PhysicsServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, Transform());
-
- return area->get_shape_transform(p_shape_idx);
-}
-
-void PhysicsServerSW::area_remove_shape(RID p_area, int p_shape_idx) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->remove_shape(p_shape_idx);
-}
-
-void PhysicsServerSW::area_clear_shapes(RID p_area) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- while (area->get_shape_count())
- area->remove_shape(0);
-}
-
-void PhysicsServerSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
- ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count());
- FLUSH_QUERY_CHECK(area);
- area->set_shape_as_disabled(p_shape_idx, p_disabled);
-}
-
-void PhysicsServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
-
- if (space_owner.owns(p_area)) {
- SpaceSW *space = space_owner.getornull(p_area);
- p_area = space->get_default_area()->get_self();
- }
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
- area->set_instance_id(p_id);
-}
-ObjectID PhysicsServerSW::area_get_object_instance_id(RID p_area) const {
-
- if (space_owner.owns(p_area)) {
- SpaceSW *space = space_owner.getornull(p_area);
- p_area = space->get_default_area()->get_self();
- }
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, ObjectID());
- return area->get_instance_id();
-}
-
-void PhysicsServerSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
-
- if (space_owner.owns(p_area)) {
- SpaceSW *space = space_owner.getornull(p_area);
- p_area = space->get_default_area()->get_self();
- }
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
- area->set_param(p_param, p_value);
-};
-
-void PhysicsServerSW::area_set_transform(RID p_area, const Transform &p_transform) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
- area->set_transform(p_transform);
-};
-
-Variant PhysicsServerSW::area_get_param(RID p_area, AreaParameter p_param) const {
-
- if (space_owner.owns(p_area)) {
- SpaceSW *space = space_owner.getornull(p_area);
- p_area = space->get_default_area()->get_self();
- }
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, Variant());
-
- return area->get_param(p_param);
-};
-
-Transform PhysicsServerSW::area_get_transform(RID p_area) const {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, Transform());
-
- return area->get_transform();
-};
-
-void PhysicsServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_collision_layer(p_layer);
-}
-
-void PhysicsServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_collision_mask(p_mask);
-}
-
-void PhysicsServerSW::area_set_monitorable(RID p_area, bool p_monitorable) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
- FLUSH_QUERY_CHECK(area);
-
- area->set_monitorable(p_monitorable);
-}
-
-void PhysicsServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
-}
-
-void PhysicsServerSW::area_set_ray_pickable(RID p_area, bool p_enable) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_ray_pickable(p_enable);
-}
-
-bool PhysicsServerSW::area_is_ray_pickable(RID p_area) const {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, false);
-
- return area->is_ray_pickable();
-}
-
-void PhysicsServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
-
- AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND(!area);
-
- area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
-}
-
-/* BODY API */
-
-RID PhysicsServerSW::body_create(BodyMode p_mode, bool p_init_sleeping) {
-
- BodySW *body = memnew(BodySW);
- if (p_mode != BODY_MODE_RIGID)
- body->set_mode(p_mode);
- if (p_init_sleeping)
- body->set_state(BODY_STATE_SLEEPING, p_init_sleeping);
- RID rid = body_owner.make_rid(body);
- body->set_self(rid);
- return rid;
-};
-
-void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- SpaceSW *space = NULL;
- if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
- ERR_FAIL_COND(!space);
- }
-
- if (body->get_space() == space)
- return; //pointless
-
- body->clear_constraint_map();
- body->set_space(space);
-};
-
-RID PhysicsServerSW::body_get_space(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, RID());
-
- SpaceSW *space = body->get_space();
- if (!space)
- return RID();
- return space->get_self();
-};
-
-void PhysicsServerSW::body_set_mode(RID p_body, BodyMode p_mode) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_mode(p_mode);
-};
-
-PhysicsServer::BodyMode PhysicsServerSW::body_get_mode(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
-
- return body->get_mode();
-};
-
-void PhysicsServerSW::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND(!shape);
-
- body->add_shape(shape, p_transform, p_disabled);
-}
-
-void PhysicsServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- ShapeSW *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND(!shape);
- ERR_FAIL_COND(!shape->is_configured());
-
- body->set_shape(p_shape_idx, shape);
-}
-void PhysicsServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_shape_transform(p_shape_idx, p_transform);
-}
-
-int PhysicsServerSW::body_get_shape_count(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, -1);
-
- return body->get_shape_count();
-}
-RID PhysicsServerSW::body_get_shape(RID p_body, int p_shape_idx) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, RID());
-
- ShapeSW *shape = body->get_shape(p_shape_idx);
- ERR_FAIL_COND_V(!shape, RID());
-
- return shape->get_self();
-}
-
-void PhysicsServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
- ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
- FLUSH_QUERY_CHECK(body);
-
- body->set_shape_as_disabled(p_shape_idx, p_disabled);
-}
-
-Transform PhysicsServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, Transform());
-
- return body->get_shape_transform(p_shape_idx);
-}
-
-void PhysicsServerSW::body_remove_shape(RID p_body, int p_shape_idx) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->remove_shape(p_shape_idx);
-}
-
-void PhysicsServerSW::body_clear_shapes(RID p_body) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- while (body->get_shape_count())
- body->remove_shape(0);
-}
-
-void PhysicsServerSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_continuous_collision_detection(p_enable);
-}
-
-bool PhysicsServerSW::body_is_continuous_collision_detection_enabled(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, false);
-
- return body->is_continuous_collision_detection_enabled();
-}
-
-void PhysicsServerSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_collision_layer(p_layer);
- body->wakeup();
-}
-
-uint32_t PhysicsServerSW::body_get_collision_layer(RID p_body) const {
-
- const BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
-
- return body->get_collision_layer();
-}
-
-void PhysicsServerSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_collision_mask(p_mask);
- body->wakeup();
-}
-
-uint32_t PhysicsServerSW::body_get_collision_mask(RID p_body) const {
-
- const BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
-
- return body->get_collision_mask();
-}
-
-void PhysicsServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_instance_id(p_id);
-};
-
-ObjectID PhysicsServerSW::body_get_object_instance_id(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, ObjectID());
-
- return body->get_instance_id();
-};
-
-void PhysicsServerSW::body_set_user_flags(RID p_body, uint32_t p_flags) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-};
-
-uint32_t PhysicsServerSW::body_get_user_flags(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
-
- return 0;
-};
-
-void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_param(p_param, p_value);
-};
-
-real_t PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
-
- return body->get_param(p_param);
-};
-
-void PhysicsServerSW::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
- body->set_kinematic_margin(p_margin);
-}
-
-real_t PhysicsServerSW::body_get_kinematic_safe_margin(RID p_body) const {
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
-
- return body->get_kinematic_margin();
-}
-
-void PhysicsServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_state(p_state, p_variant);
-};
-
-Variant PhysicsServerSW::body_get_state(RID p_body, BodyState p_state) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, Variant());
-
- return body->get_state(p_state);
-};
-
-void PhysicsServerSW::body_set_applied_force(RID p_body, const Vector3 &p_force) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_applied_force(p_force);
- body->wakeup();
-};
-
-Vector3 PhysicsServerSW::body_get_applied_force(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, Vector3());
- return body->get_applied_force();
-};
-
-void PhysicsServerSW::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_applied_torque(p_torque);
- body->wakeup();
-};
-
-Vector3 PhysicsServerSW::body_get_applied_torque(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, Vector3());
-
- return body->get_applied_torque();
-};
-
-void PhysicsServerSW::body_add_central_force(RID p_body, const Vector3 &p_force) {
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->add_central_force(p_force);
- body->wakeup();
-}
-
-void PhysicsServerSW::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->add_force(p_force, p_pos);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_add_torque(RID p_body, const Vector3 &p_torque) {
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->add_torque(p_torque);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- _update_shapes();
-
- body->apply_central_impulse(p_impulse);
- body->wakeup();
-}
-
-void PhysicsServerSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- _update_shapes();
-
- body->apply_impulse(p_pos, p_impulse);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- _update_shapes();
-
- body->apply_torque_impulse(p_impulse);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- _update_shapes();
-
- Vector3 v = body->get_linear_velocity();
- Vector3 axis = p_axis_velocity.normalized();
- v -= axis * axis.dot(v);
- v += p_axis_velocity;
- body->set_linear_velocity(v);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_axis_lock(p_axis, p_lock);
- body->wakeup();
-}
-
-bool PhysicsServerSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
-
- const BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
- return body->is_axis_locked(p_axis);
-}
-
-void PhysicsServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->add_exception(p_body_b);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->remove_exception(p_body_b);
- body->wakeup();
-};
-
-void PhysicsServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- for (int i = 0; i < body->get_exceptions().size(); i++) {
- p_exceptions->push_back(body->get_exceptions()[i]);
- }
-};
-
-void PhysicsServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-};
-
-real_t PhysicsServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
- return 0;
-};
-
-void PhysicsServerSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
-
- body->set_omit_force_integration(p_omit);
-};
-
-bool PhysicsServerSW::body_is_omitting_force_integration(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, false);
- return body->get_omit_force_integration();
-};
-
-void PhysicsServerSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
- body->set_max_contacts_reported(p_contacts);
-}
-
-int PhysicsServerSW::body_get_max_contacts_reported(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, -1);
- return body->get_max_contacts_reported();
-}
-
-void PhysicsServerSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
- body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
-}
-
-void PhysicsServerSW::body_set_ray_pickable(RID p_body, bool p_enable) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND(!body);
- body->set_ray_pickable(p_enable);
-}
-
-bool PhysicsServerSW::body_is_ray_pickable(RID p_body) const {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, false);
- return body->is_ray_pickable();
-}
-
-bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, false);
- ERR_FAIL_COND_V(!body->get_space(), false);
- ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
-
- _update_shapes();
-
- return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, body->get_kinematic_margin(), r_result, p_exclude_raycast_shapes);
-}
-
-int PhysicsServerSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, false);
- ERR_FAIL_COND_V(!body->get_space(), false);
- ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
-
- _update_shapes();
-
- return body->get_space()->test_body_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
-}
-
-PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) {
-
- BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, NULL);
- ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification.");
-
- direct_state->body = body;
- return direct_state;
-}
-
-/* JOINT API */
-
-RID PhysicsServerSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
-
- BodySW *body_A = body_owner.getornull(p_body_A);
- ERR_FAIL_COND_V(!body_A, RID());
-
- if (!p_body_B.is_valid()) {
- ERR_FAIL_COND_V(!body_A->get_space(), RID());
- p_body_B = body_A->get_space()->get_static_global_body();
- }
-
- BodySW *body_B = body_owner.getornull(p_body_B);
- ERR_FAIL_COND_V(!body_B, RID());
-
- ERR_FAIL_COND_V(body_A == body_B, RID());
-
- JointSW *joint = memnew(PinJointSW(body_A, p_local_A, body_B, p_local_B));
- RID rid = joint_owner.make_rid(joint);
- joint->set_self(rid);
- return rid;
-}
-
-void PhysicsServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
- PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- pin_joint->set_param(p_param, p_value);
-}
-real_t PhysicsServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
- PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- return pin_joint->get_param(p_param);
-}
-
-void PhysicsServerSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
- PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- pin_joint->set_pos_a(p_A);
-}
-Vector3 PhysicsServerSW::pin_joint_get_local_a(RID p_joint) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, Vector3());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
- PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- return pin_joint->get_position_a();
-}
-
-void PhysicsServerSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
- PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- pin_joint->set_pos_b(p_B);
-}
-Vector3 PhysicsServerSW::pin_joint_get_local_b(RID p_joint) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, Vector3());
- ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
- PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- return pin_joint->get_position_b();
-}
-
-RID PhysicsServerSW::joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B) {
-
- BodySW *body_A = body_owner.getornull(p_body_A);
- ERR_FAIL_COND_V(!body_A, RID());
-
- if (!p_body_B.is_valid()) {
- ERR_FAIL_COND_V(!body_A->get_space(), RID());
- p_body_B = body_A->get_space()->get_static_global_body();
- }
-
- BodySW *body_B = body_owner.getornull(p_body_B);
- ERR_FAIL_COND_V(!body_B, RID());
-
- ERR_FAIL_COND_V(body_A == body_B, RID());
-
- JointSW *joint = memnew(HingeJointSW(body_A, body_B, p_frame_A, p_frame_B));
- RID rid = joint_owner.make_rid(joint);
- joint->set_self(rid);
- return rid;
-}
-
-RID PhysicsServerSW::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
-
- BodySW *body_A = body_owner.getornull(p_body_A);
- ERR_FAIL_COND_V(!body_A, RID());
-
- if (!p_body_B.is_valid()) {
- ERR_FAIL_COND_V(!body_A->get_space(), RID());
- p_body_B = body_A->get_space()->get_static_global_body();
- }
-
- BodySW *body_B = body_owner.getornull(p_body_B);
- ERR_FAIL_COND_V(!body_B, RID());
-
- ERR_FAIL_COND_V(body_A == body_B, RID());
-
- JointSW *joint = memnew(HingeJointSW(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B));
- RID rid = joint_owner.make_rid(joint);
- joint->set_self(rid);
- return rid;
-}
-
-void PhysicsServerSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
- HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint);
- hinge_joint->set_param(p_param, p_value);
-}
-real_t PhysicsServerSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
- HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint);
- return hinge_joint->get_param(p_param);
-}
-
-void PhysicsServerSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
- HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint);
- hinge_joint->set_flag(p_flag, p_value);
-}
-bool PhysicsServerSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
- HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint);
- return hinge_joint->get_flag(p_flag);
-}
-
-void PhysicsServerSW::joint_set_solver_priority(RID p_joint, int p_priority) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- joint->set_priority(p_priority);
-}
-
-int PhysicsServerSW::joint_get_solver_priority(RID p_joint) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, 0);
- return joint->get_priority();
-}
-
-void PhysicsServerSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
-
- joint->disable_collisions_between_bodies(p_disable);
-
- if (2 == joint->get_body_count()) {
- BodySW *body_a = *joint->get_body_ptr();
- BodySW *body_b = *(joint->get_body_ptr() + 1);
-
- if (p_disable) {
- body_add_collision_exception(body_a->get_self(), body_b->get_self());
- body_add_collision_exception(body_b->get_self(), body_a->get_self());
- } else {
- body_remove_collision_exception(body_a->get_self(), body_b->get_self());
- body_remove_collision_exception(body_b->get_self(), body_a->get_self());
- }
- }
-}
-
-bool PhysicsServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, true);
-
- return joint->is_disabled_collisions_between_bodies();
-}
-
-PhysicsServerSW::JointType PhysicsServerSW::joint_get_type(RID p_joint) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, JOINT_PIN);
- return joint->get_type();
-}
-
-RID PhysicsServerSW::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
-
- BodySW *body_A = body_owner.getornull(p_body_A);
- ERR_FAIL_COND_V(!body_A, RID());
-
- if (!p_body_B.is_valid()) {
- ERR_FAIL_COND_V(!body_A->get_space(), RID());
- p_body_B = body_A->get_space()->get_static_global_body();
- }
-
- BodySW *body_B = body_owner.getornull(p_body_B);
- ERR_FAIL_COND_V(!body_B, RID());
-
- ERR_FAIL_COND_V(body_A == body_B, RID());
-
- JointSW *joint = memnew(SliderJointSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
- RID rid = joint_owner.make_rid(joint);
- joint->set_self(rid);
- return rid;
-}
-
-void PhysicsServerSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
- SliderJointSW *slider_joint = static_cast<SliderJointSW *>(joint);
- slider_joint->set_param(p_param, p_value);
-}
-real_t PhysicsServerSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0);
- SliderJointSW *slider_joint = static_cast<SliderJointSW *>(joint);
- return slider_joint->get_param(p_param);
-}
-
-RID PhysicsServerSW::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
-
- BodySW *body_A = body_owner.getornull(p_body_A);
- ERR_FAIL_COND_V(!body_A, RID());
-
- if (!p_body_B.is_valid()) {
- ERR_FAIL_COND_V(!body_A->get_space(), RID());
- p_body_B = body_A->get_space()->get_static_global_body();
- }
-
- BodySW *body_B = body_owner.getornull(p_body_B);
- ERR_FAIL_COND_V(!body_B, RID());
-
- ERR_FAIL_COND_V(body_A == body_B, RID());
-
- JointSW *joint = memnew(ConeTwistJointSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
- RID rid = joint_owner.make_rid(joint);
- joint->set_self(rid);
- return rid;
-}
-
-void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
- ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW *>(joint);
- cone_twist_joint->set_param(p_param, p_value);
-}
-real_t PhysicsServerSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0);
- ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW *>(joint);
- return cone_twist_joint->get_param(p_param);
-}
-
-RID PhysicsServerSW::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
-
- BodySW *body_A = body_owner.getornull(p_body_A);
- ERR_FAIL_COND_V(!body_A, RID());
-
- if (!p_body_B.is_valid()) {
- ERR_FAIL_COND_V(!body_A->get_space(), RID());
- p_body_B = body_A->get_space()->get_static_global_body();
- }
-
- BodySW *body_B = body_owner.getornull(p_body_B);
- ERR_FAIL_COND_V(!body_B, RID());
-
- ERR_FAIL_COND_V(body_A == body_B, RID());
-
- JointSW *joint = memnew(Generic6DOFJointSW(body_A, body_B, p_local_frame_A, p_local_frame_B, true));
- RID rid = joint_owner.make_rid(joint);
- joint->set_self(rid);
- return rid;
-}
-
-void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
- Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint);
- generic_6dof_joint->set_param(p_axis, p_param, p_value);
-}
-real_t PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, 0);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
- Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint);
- return generic_6dof_joint->get_param(p_axis, p_param);
-}
-
-void PhysicsServerSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND(!joint);
- ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
- Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint);
- generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
-}
-bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
-
- JointSW *joint = joint_owner.getornull(p_joint);
- ERR_FAIL_COND_V(!joint, false);
- ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
- Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint);
- return generic_6dof_joint->get_flag(p_axis, p_flag);
-}
-
-void PhysicsServerSW::free(RID p_rid) {
-
- _update_shapes(); //just in case
-
- if (shape_owner.owns(p_rid)) {
-
- ShapeSW *shape = shape_owner.getornull(p_rid);
-
- while (shape->get_owners().size()) {
- ShapeOwnerSW *so = shape->get_owners().front()->key();
- so->remove_shape(shape);
- }
-
- shape_owner.free(p_rid);
- memdelete(shape);
- } else if (body_owner.owns(p_rid)) {
-
- BodySW *body = body_owner.getornull(p_rid);
-
- /*
- if (body->get_state_query())
- _clear_query(body->get_state_query());
-
- if (body->get_direct_state_query())
- _clear_query(body->get_direct_state_query());
- */
-
- body->set_space(NULL);
-
- while (body->get_shape_count()) {
-
- body->remove_shape(0);
- }
-
- body_owner.free(p_rid);
- memdelete(body);
-
- } else if (area_owner.owns(p_rid)) {
-
- AreaSW *area = area_owner.getornull(p_rid);
-
- /*
- if (area->get_monitor_query())
- _clear_query(area->get_monitor_query());
- */
-
- area->set_space(NULL);
-
- while (area->get_shape_count()) {
-
- area->remove_shape(0);
- }
-
- area_owner.free(p_rid);
- memdelete(area);
- } else if (space_owner.owns(p_rid)) {
-
- SpaceSW *space = space_owner.getornull(p_rid);
-
- while (space->get_objects().size()) {
- CollisionObjectSW *co = (CollisionObjectSW *)space->get_objects().front()->get();
- co->set_space(NULL);
- }
-
- active_spaces.erase(space);
- free(space->get_default_area()->get_self());
- free(space->get_static_global_body());
-
- space_owner.free(p_rid);
- memdelete(space);
- } else if (joint_owner.owns(p_rid)) {
-
- JointSW *joint = joint_owner.getornull(p_rid);
-
- for (int i = 0; i < joint->get_body_count(); i++) {
-
- joint->get_body_ptr()[i]->remove_constraint(joint);
- }
- joint_owner.free(p_rid);
- memdelete(joint);
-
- } else {
-
- ERR_FAIL_MSG("Invalid ID.");
- }
-};
-
-void PhysicsServerSW::set_active(bool p_active) {
-
- active = p_active;
-};
-
-void PhysicsServerSW::init() {
-
- doing_sync = true;
- last_step = 0.001;
- iterations = 8; // 8?
- stepper = memnew(StepSW);
- direct_state = memnew(PhysicsDirectBodyStateSW);
-};
-
-void PhysicsServerSW::step(real_t p_step) {
-
-#ifndef _3D_DISABLED
-
- if (!active)
- return;
-
- _update_shapes();
-
- doing_sync = false;
-
- last_step = p_step;
- PhysicsDirectBodyStateSW::singleton->step = p_step;
-
- island_count = 0;
- active_objects = 0;
- collision_pairs = 0;
- for (Set<const SpaceSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
- stepper->step((SpaceSW *)E->get(), p_step, iterations);
- island_count += E->get()->get_island_count();
- active_objects += E->get()->get_active_objects();
- collision_pairs += E->get()->get_collision_pairs();
- }
-#endif
-}
-
-void PhysicsServerSW::sync(){
-
-};
-
-void PhysicsServerSW::flush_queries() {
-
-#ifndef _3D_DISABLED
-
- if (!active)
- return;
-
- doing_sync = true;
-
- flushing_queries = true;
-
- uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
-
- for (Set<const SpaceSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
- SpaceSW *space = (SpaceSW *)E->get();
- space->call_queries();
- }
-
- flushing_queries = false;
-
- if (EngineDebugger::is_profiling("servers")) {
-
- uint64_t total_time[SpaceSW::ELAPSED_TIME_MAX];
- static const char *time_name[SpaceSW::ELAPSED_TIME_MAX] = {
- "integrate_forces",
- "generate_islands",
- "setup_constraints",
- "solve_constraints",
- "integrate_velocities"
- };
-
- for (int i = 0; i < SpaceSW::ELAPSED_TIME_MAX; i++) {
- total_time[i] = 0;
- }
-
- for (Set<const SpaceSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
- for (int i = 0; i < SpaceSW::ELAPSED_TIME_MAX; i++) {
- total_time[i] += E->get()->get_elapsed_time(SpaceSW::ElapsedTime(i));
- }
- }
-
- Array values;
- values.resize(SpaceSW::ELAPSED_TIME_MAX * 2);
- for (int i = 0; i < SpaceSW::ELAPSED_TIME_MAX; i++) {
- values[i * 2 + 0] = time_name[i];
- values[i * 2 + 1] = USEC_TO_SEC(total_time[i]);
- }
- values.push_back("flush_queries");
- values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec() - time_beg));
-
- values.push_front("physics");
- EngineDebugger::profiler_add_frame_data("server", values);
- }
-#endif
-};
-
-void PhysicsServerSW::finish() {
-
- memdelete(stepper);
- memdelete(direct_state);
-};
-
-int PhysicsServerSW::get_process_info(ProcessInfo p_info) {
-
- switch (p_info) {
-
- case INFO_ACTIVE_OBJECTS: {
-
- return active_objects;
- } break;
- case INFO_COLLISION_PAIRS: {
- return collision_pairs;
- } break;
- case INFO_ISLAND_COUNT: {
-
- return island_count;
- } break;
- }
-
- return 0;
-}
-
-void PhysicsServerSW::_update_shapes() {
-
- while (pending_shape_update_list.first()) {
- pending_shape_update_list.first()->self()->_shape_changed();
- pending_shape_update_list.remove(pending_shape_update_list.first());
- }
-}
-
-void PhysicsServerSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
-
- CollCbkData *cbk = (CollCbkData *)p_userdata;
-
- if (cbk->max == 0)
- return;
-
- if (cbk->amount == cbk->max) {
- //find least deep
- real_t min_depth = 1e20;
- int min_depth_idx = 0;
- for (int i = 0; i < cbk->amount; i++) {
-
- real_t d = cbk->ptr[i * 2 + 0].distance_squared_to(cbk->ptr[i * 2 + 1]);
- if (d < min_depth) {
- min_depth = d;
- min_depth_idx = i;
- }
- }
-
- real_t d = p_point_A.distance_squared_to(p_point_B);
- if (d < min_depth)
- return;
- cbk->ptr[min_depth_idx * 2 + 0] = p_point_A;
- cbk->ptr[min_depth_idx * 2 + 1] = p_point_B;
-
- } else {
-
- cbk->ptr[cbk->amount * 2 + 0] = p_point_A;
- cbk->ptr[cbk->amount * 2 + 1] = p_point_B;
- cbk->amount++;
- }
-}
-
-PhysicsServerSW *PhysicsServerSW::singleton = NULL;
-PhysicsServerSW::PhysicsServerSW() {
- singleton = this;
- BroadPhaseSW::create_func = BroadPhaseOctree::_create;
- island_count = 0;
- active_objects = 0;
- collision_pairs = 0;
-
- active = true;
- flushing_queries = false;
-};
-
-PhysicsServerSW::~PhysicsServerSW(){
-
-};
diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp
index 45666d9d09..85ec2aae47 100644
--- a/servers/physics_2d/area_2d_sw.cpp
+++ b/servers/physics_2d/area_2d_sw.cpp
@@ -117,40 +117,40 @@ void Area2DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_meth
get_space()->area_add_to_moved_list(&moved_list);
}
-void Area2DSW::set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_mode) {
- bool do_override = p_mode != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED;
- if (do_override == (space_override_mode != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED))
+void Area2DSW::set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode) {
+ bool do_override = p_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
+ if (do_override == (space_override_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED))
return;
_unregister_shapes();
space_override_mode = p_mode;
_shape_changed();
}
-void Area2DSW::set_param(Physics2DServer::AreaParameter p_param, const Variant &p_value) {
+void Area2DSW::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case Physics2DServer::AREA_PARAM_GRAVITY: gravity = p_value; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break;
- case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break;
- case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break;
- case Physics2DServer::AREA_PARAM_PRIORITY: priority = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY: gravity = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break;
+ case PhysicsServer2D::AREA_PARAM_PRIORITY: priority = p_value; break;
}
}
-Variant Area2DSW::get_param(Physics2DServer::AreaParameter p_param) const {
+Variant Area2DSW::get_param(PhysicsServer2D::AreaParameter p_param) const {
switch (p_param) {
- case Physics2DServer::AREA_PARAM_GRAVITY: return gravity;
- case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector;
- case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point;
- case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale;
- case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation;
- case Physics2DServer::AREA_PARAM_LINEAR_DAMP: return linear_damp;
- case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: return angular_damp;
- case Physics2DServer::AREA_PARAM_PRIORITY: return priority;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY: return gravity;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale;
+ case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation;
+ case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP: return linear_damp;
+ case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP: return angular_damp;
+ case PhysicsServer2D::AREA_PARAM_PRIORITY: return priority;
}
return Variant();
@@ -194,7 +194,7 @@ void Area2DSW::call_queries() {
if (E->get().state == 0)
continue; //nothing happened
- res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED;
+ res[0] = E->get().state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
res[2] = E->key().instance_id;
res[3] = E->key().body_shape;
@@ -226,7 +226,7 @@ void Area2DSW::call_queries() {
if (E->get().state == 0)
continue; //nothing happened
- res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED;
+ res[0] = E->get().state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
res[2] = E->key().instance_id;
res[3] = E->key().body_shape;
@@ -248,7 +248,7 @@ Area2DSW::Area2DSW() :
moved_list(this) {
_set_static(true); //areas are not active by default
- space_override_mode = Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED;
+ space_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
gravity = 9.80665;
gravity_vector = Vector2(0, -1);
gravity_is_point = false;
diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h
index 54ffd9763d..ae2a8ff995 100644
--- a/servers/physics_2d/area_2d_sw.h
+++ b/servers/physics_2d/area_2d_sw.h
@@ -33,8 +33,8 @@
#include "collision_object_2d_sw.h"
#include "core/self_list.h"
-#include "servers/physics_2d_server.h"
-//#include "servers/physics/query_sw.h"
+#include "servers/physics_server_2d.h"
+//#include "servers/physics_3d/query_sw.h"
class Space2DSW;
class Body2DSW;
@@ -42,7 +42,7 @@ class Constraint2DSW;
class Area2DSW : public CollisionObject2DSW {
- Physics2DServer::AreaSpaceOverrideMode space_override_mode;
+ PhysicsServer2D::AreaSpaceOverrideMode space_override_mode;
real_t gravity;
Vector2 gravity_vector;
bool gravity_is_point;
@@ -121,11 +121,11 @@ public:
_FORCE_INLINE_ void add_area_to_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
_FORCE_INLINE_ void remove_area_from_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
- void set_param(Physics2DServer::AreaParameter p_param, const Variant &p_value);
- Variant get_param(Physics2DServer::AreaParameter p_param) const;
+ void set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PhysicsServer2D::AreaParameter p_param) const;
- void set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_mode);
- Physics2DServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
+ void set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode);
+ PhysicsServer2D::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
_FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; }
_FORCE_INLINE_ real_t get_gravity() const { return gravity; }
diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp
index 05d71cfabe..669f27bcc8 100644
--- a/servers/physics_2d/area_pair_2d_sw.cpp
+++ b/servers/physics_2d/area_pair_2d_sw.cpp
@@ -45,14 +45,14 @@ bool AreaPair2DSW::setup(real_t p_step) {
if (result) {
- if (area->get_space_override_mode() != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)
body->add_area(area);
if (area->has_monitor_callback())
area->add_body_to_query(body, body_shape, area_shape);
} else {
- if (area->get_space_override_mode() != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)
body->remove_area(area);
if (area->has_monitor_callback())
area->remove_body_from_query(body, body_shape, area_shape);
@@ -76,7 +76,7 @@ AreaPair2DSW::AreaPair2DSW(Body2DSW *p_body, int p_body_shape, Area2DSW *p_area,
colliding = false;
body->add_constraint(this, 0);
area->add_constraint(this);
- if (p_body->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) //need to be active to process pair
+ if (p_body->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) //need to be active to process pair
p_body->set_active(true);
}
@@ -84,7 +84,7 @@ AreaPair2DSW::~AreaPair2DSW() {
if (colliding) {
- if (area->get_space_override_mode() != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)
body->remove_area(area);
if (area->has_monitor_callback())
area->remove_body_from_query(body, body_shape, area_shape);
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 863b422996..11cf1339bc 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -30,7 +30,7 @@
#include "body_2d_sw.h"
#include "area_2d_sw.h"
-#include "physics_2d_server_sw.h"
+#include "physics_server_2d_sw.h"
#include "space_2d_sw.h"
void Body2DSW::_update_inertia() {
@@ -45,7 +45,7 @@ void Body2DSW::update_inertias() {
switch (mode) {
- case Physics2DServer::BODY_MODE_RIGID: {
+ case PhysicsServer2D::BODY_MODE_RIGID: {
if (user_inertia) {
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
@@ -86,13 +86,13 @@ void Body2DSW::update_inertias() {
_inv_mass = 0;
} break;
- case Physics2DServer::BODY_MODE_KINEMATIC:
- case Physics2DServer::BODY_MODE_STATIC: {
+ case PhysicsServer2D::BODY_MODE_KINEMATIC:
+ case PhysicsServer2D::BODY_MODE_STATIC: {
_inv_inertia = 0;
_inv_mass = 0;
} break;
- case Physics2DServer::BODY_MODE_CHARACTER: {
+ case PhysicsServer2D::BODY_MODE_CHARACTER: {
_inv_inertia = 0;
_inv_mass = 1.0 / mass;
@@ -114,7 +114,7 @@ void Body2DSW::set_active(bool p_active) {
if (get_space())
get_space()->body_remove_from_active_list(&active_list);
} else {
- if (mode == Physics2DServer::BODY_MODE_STATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC)
return; //static bodies can't become active
if (get_space())
get_space()->body_add_to_active_list(&active_list);
@@ -134,24 +134,24 @@ void Body2DSW::set_active(bool p_active) {
*/
}
-void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value) {
+void Body2DSW::set_param(PhysicsServer2D::BodyParameter p_param, real_t p_value) {
switch (p_param) {
- case Physics2DServer::BODY_PARAM_BOUNCE: {
+ case PhysicsServer2D::BODY_PARAM_BOUNCE: {
bounce = p_value;
} break;
- case Physics2DServer::BODY_PARAM_FRICTION: {
+ case PhysicsServer2D::BODY_PARAM_FRICTION: {
friction = p_value;
} break;
- case Physics2DServer::BODY_PARAM_MASS: {
+ case PhysicsServer2D::BODY_PARAM_MASS: {
ERR_FAIL_COND(p_value <= 0);
mass = p_value;
_update_inertia();
} break;
- case Physics2DServer::BODY_PARAM_INERTIA: {
+ case PhysicsServer2D::BODY_PARAM_INERTIA: {
if (p_value <= 0) {
user_inertia = false;
_update_inertia();
@@ -161,14 +161,14 @@ void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value)
_inv_inertia = 1.0 / p_value;
}
} break;
- case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: {
+ case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: {
gravity_scale = p_value;
} break;
- case Physics2DServer::BODY_PARAM_LINEAR_DAMP: {
+ case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: {
linear_damp = p_value;
} break;
- case Physics2DServer::BODY_PARAM_ANGULAR_DAMP: {
+ case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: {
angular_damp = p_value;
} break;
@@ -177,31 +177,31 @@ void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value)
}
}
-real_t Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
+real_t Body2DSW::get_param(PhysicsServer2D::BodyParameter p_param) const {
switch (p_param) {
- case Physics2DServer::BODY_PARAM_BOUNCE: {
+ case PhysicsServer2D::BODY_PARAM_BOUNCE: {
return bounce;
}
- case Physics2DServer::BODY_PARAM_FRICTION: {
+ case PhysicsServer2D::BODY_PARAM_FRICTION: {
return friction;
}
- case Physics2DServer::BODY_PARAM_MASS: {
+ case PhysicsServer2D::BODY_PARAM_MASS: {
return mass;
}
- case Physics2DServer::BODY_PARAM_INERTIA: {
+ case PhysicsServer2D::BODY_PARAM_INERTIA: {
return inertia;
}
- case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: {
+ case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
}
- case Physics2DServer::BODY_PARAM_LINEAR_DAMP: {
+ case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: {
return linear_damp;
}
- case Physics2DServer::BODY_PARAM_ANGULAR_DAMP: {
+ case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: {
return angular_damp;
}
@@ -212,28 +212,28 @@ real_t Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
return 0;
}
-void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
+void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
- Physics2DServer::BodyMode prev = mode;
+ PhysicsServer2D::BodyMode prev = mode;
mode = p_mode;
switch (p_mode) {
//CLEAR UP EVERYTHING IN CASE IT NOT WORKS!
- case Physics2DServer::BODY_MODE_STATIC:
- case Physics2DServer::BODY_MODE_KINEMATIC: {
+ case PhysicsServer2D::BODY_MODE_STATIC:
+ case PhysicsServer2D::BODY_MODE_KINEMATIC: {
_set_inv_transform(get_transform().affine_inverse());
_inv_mass = 0;
_inv_inertia = 0;
- _set_static(p_mode == Physics2DServer::BODY_MODE_STATIC);
- set_active(p_mode == Physics2DServer::BODY_MODE_KINEMATIC && contacts.size());
+ _set_static(p_mode == PhysicsServer2D::BODY_MODE_STATIC);
+ set_active(p_mode == PhysicsServer2D::BODY_MODE_KINEMATIC && contacts.size());
linear_velocity = Vector2();
angular_velocity = 0;
- if (mode == Physics2DServer::BODY_MODE_KINEMATIC && prev != mode) {
+ if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && prev != mode) {
first_time_kinematic = true;
}
} break;
- case Physics2DServer::BODY_MODE_RIGID: {
+ case PhysicsServer2D::BODY_MODE_RIGID: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
@@ -241,7 +241,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
set_active(true);
} break;
- case Physics2DServer::BODY_MODE_CHARACTER: {
+ case PhysicsServer2D::BODY_MODE_CHARACTER: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = 0;
@@ -250,7 +250,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
angular_velocity = 0;
} break;
}
- if (p_mode == Physics2DServer::BODY_MODE_RIGID && _inv_inertia == 0) {
+ if (p_mode == PhysicsServer2D::BODY_MODE_RIGID && _inv_inertia == 0) {
_update_inertia();
}
/*
@@ -258,7 +258,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
_update_queries();
*/
}
-Physics2DServer::BodyMode Body2DSW::get_mode() const {
+PhysicsServer2D::BodyMode Body2DSW::get_mode() const {
return mode;
}
@@ -269,12 +269,12 @@ void Body2DSW::_shapes_changed() {
wakeup_neighbours();
}
-void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_variant) {
+void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case Physics2DServer::BODY_STATE_TRANSFORM: {
+ case PhysicsServer2D::BODY_STATE_TRANSFORM: {
- if (mode == Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
new_transform = p_variant;
//wakeup_neighbours();
@@ -284,7 +284,7 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_va
_set_inv_transform(get_transform().affine_inverse());
first_time_kinematic = false;
}
- } else if (mode == Physics2DServer::BODY_MODE_STATIC) {
+ } else if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
_set_transform(p_variant);
_set_inv_transform(get_transform().affine_inverse());
wakeup_neighbours();
@@ -300,28 +300,28 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_va
wakeup();
} break;
- case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: {
+ case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: {
/*
- if (mode==Physics2DServer::BODY_MODE_STATIC)
+ if (mode==PhysicsServer2D::BODY_MODE_STATIC)
break;
*/
linear_velocity = p_variant;
wakeup();
} break;
- case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: {
+ case PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY: {
/*
- if (mode!=Physics2DServer::BODY_MODE_RIGID)
+ if (mode!=PhysicsServer2D::BODY_MODE_RIGID)
break;
*/
angular_velocity = p_variant;
wakeup();
} break;
- case Physics2DServer::BODY_STATE_SLEEPING: {
+ case PhysicsServer2D::BODY_STATE_SLEEPING: {
//?
- if (mode == Physics2DServer::BODY_MODE_STATIC || mode == Physics2DServer::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC)
break;
bool do_sleep = p_variant;
if (do_sleep) {
@@ -331,34 +331,34 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_va
//biased_angular_velocity=Vector3();
set_active(false);
} else {
- if (mode != Physics2DServer::BODY_MODE_STATIC)
+ if (mode != PhysicsServer2D::BODY_MODE_STATIC)
set_active(true);
}
} break;
- case Physics2DServer::BODY_STATE_CAN_SLEEP: {
+ case PhysicsServer2D::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant;
- if (mode == Physics2DServer::BODY_MODE_RIGID && !active && !can_sleep)
+ if (mode == PhysicsServer2D::BODY_MODE_RIGID && !active && !can_sleep)
set_active(true);
} break;
}
}
-Variant Body2DSW::get_state(Physics2DServer::BodyState p_state) const {
+Variant Body2DSW::get_state(PhysicsServer2D::BodyState p_state) const {
switch (p_state) {
- case Physics2DServer::BODY_STATE_TRANSFORM: {
+ case PhysicsServer2D::BODY_STATE_TRANSFORM: {
return get_transform();
}
- case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: {
+ case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: {
return linear_velocity;
}
- case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: {
+ case PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY: {
return angular_velocity;
}
- case Physics2DServer::BODY_STATE_SLEEPING: {
+ case PhysicsServer2D::BODY_STATE_SLEEPING: {
return !is_active();
}
- case Physics2DServer::BODY_STATE_CAN_SLEEP: {
+ case PhysicsServer2D::BODY_STATE_CAN_SLEEP: {
return can_sleep;
}
}
@@ -418,7 +418,7 @@ void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
void Body2DSW::integrate_forces(real_t p_step) {
- if (mode == Physics2DServer::BODY_MODE_STATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC)
return;
Area2DSW *def_area = get_space()->get_default_area();
@@ -435,20 +435,20 @@ void Body2DSW::integrate_forces(real_t p_step) {
const AreaCMP *aa = &areas[0];
// damp_area = aa[ac-1].area;
for (int i = ac - 1; i >= 0 && !stopped; i--) {
- Physics2DServer::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode();
+ PhysicsServer2D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode();
switch (mode) {
- case Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE:
- case Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
+ case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
_compute_area_gravity_and_dampenings(aa[i].area);
- stopped = mode == Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ stopped = mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE:
- case Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
+ case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
gravity = Vector2(0, 0);
area_angular_damp = 0;
area_linear_damp = 0;
_compute_area_gravity_and_dampenings(aa[i].area);
- stopped = mode == Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE;
+ stopped = mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -478,7 +478,7 @@ void Body2DSW::integrate_forces(real_t p_step) {
Vector2 motion;
bool do_motion = false;
- if (mode == Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
//compute motion, angular and etc. velocities from prev transform
motion = new_transform.get_origin() - get_transform().get_origin();
@@ -521,7 +521,7 @@ void Body2DSW::integrate_forces(real_t p_step) {
angular_velocity += _inv_inertia * torque * p_step;
}
- if (continuous_cd_mode != Physics2DServer::CCD_MODE_DISABLED) {
+ if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) {
motion = linear_velocity * p_step;
do_motion = true;
@@ -545,13 +545,13 @@ void Body2DSW::integrate_forces(real_t p_step) {
void Body2DSW::integrate_velocities(real_t p_step) {
- if (mode == Physics2DServer::BODY_MODE_STATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC)
return;
if (fi_callback)
get_space()->body_add_to_state_query_list(&direct_state_query_list);
- if (mode == Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
@@ -566,10 +566,10 @@ void Body2DSW::integrate_velocities(real_t p_step) {
real_t angle = get_transform().get_rotation() + total_angular_velocity * p_step;
Vector2 pos = get_transform().get_origin() + total_linear_velocity * p_step;
- _set_transform(Transform2D(angle, pos), continuous_cd_mode == Physics2DServer::CCD_MODE_DISABLED);
+ _set_transform(Transform2D(angle, pos), continuous_cd_mode == PhysicsServer2D::CCD_MODE_DISABLED);
_set_inv_transform(get_transform().inverse());
- if (continuous_cd_mode != Physics2DServer::CCD_MODE_DISABLED)
+ if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED)
new_transform = get_transform();
//_update_inertia_tensor();
@@ -588,7 +588,7 @@ void Body2DSW::wakeup_neighbours() {
if (i == E->get())
continue;
Body2DSW *b = n[i];
- if (b->mode != Physics2DServer::BODY_MODE_RIGID)
+ if (b->mode != PhysicsServer2D::BODY_MODE_RIGID)
continue;
if (!b->is_active())
@@ -601,7 +601,7 @@ void Body2DSW::call_queries() {
if (fi_callback) {
- Physics2DDirectBodyStateSW *dbs = Physics2DDirectBodyStateSW::singleton;
+ PhysicsDirectBodyState2DSW *dbs = PhysicsDirectBodyState2DSW::singleton;
dbs->body = this;
Variant v = dbs;
@@ -626,9 +626,9 @@ void Body2DSW::call_queries() {
bool Body2DSW::sleep_test(real_t p_step) {
- if (mode == Physics2DServer::BODY_MODE_STATIC || mode == Physics2DServer::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC)
return true; //
- else if (mode == Physics2DServer::BODY_MODE_CHARACTER)
+ else if (mode == PhysicsServer2D::BODY_MODE_CHARACTER)
return !active; // characters and kinematic bodies don't sleep unless asked to sleep
else if (!can_sleep)
return false;
@@ -668,7 +668,7 @@ Body2DSW::Body2DSW() :
inertia_update_list(this),
direct_state_query_list(this) {
- mode = Physics2DServer::BODY_MODE_RIGID;
+ mode = PhysicsServer2D::BODY_MODE_RIGID;
active = true;
angular_velocity = 0;
biased_angular_velocity = 0;
@@ -695,7 +695,7 @@ Body2DSW::Body2DSW() :
first_integration = false;
still_time = 0;
- continuous_cd_mode = Physics2DServer::CCD_MODE_DISABLED;
+ continuous_cd_mode = PhysicsServer2D::CCD_MODE_DISABLED;
can_sleep = true;
fi_callback = NULL;
}
@@ -706,22 +706,22 @@ Body2DSW::~Body2DSW() {
memdelete(fi_callback);
}
-Physics2DDirectBodyStateSW *Physics2DDirectBodyStateSW::singleton = NULL;
+PhysicsDirectBodyState2DSW *PhysicsDirectBodyState2DSW::singleton = NULL;
-Physics2DDirectSpaceState *Physics2DDirectBodyStateSW::get_space_state() {
+PhysicsDirectSpaceState2D *PhysicsDirectBodyState2DSW::get_space_state() {
return body->get_space()->get_direct_state();
}
-Variant Physics2DDirectBodyStateSW::get_contact_collider_shape_metadata(int p_contact_idx) const {
+Variant PhysicsDirectBodyState2DSW::get_contact_collider_shape_metadata(int p_contact_idx) const {
ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Variant());
- if (!Physics2DServerSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) {
+ if (!PhysicsServer2DSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) {
return Variant();
}
- Body2DSW *other = Physics2DServerSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider);
+ Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider);
int sidx = body->contacts[p_contact_idx].collider_shape;
if (sidx < 0 || sidx >= other->get_shape_count()) {
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index ea07b8260c..e463377c7b 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -39,7 +39,7 @@ class Constraint2DSW;
class Body2DSW : public CollisionObject2DSW {
- Physics2DServer::BodyMode mode;
+ PhysicsServer2D::BodyMode mode;
Vector2 biased_linear_velocity;
real_t biased_angular_velocity;
@@ -74,7 +74,7 @@ class Body2DSW : public CollisionObject2DSW {
SelfList<Body2DSW> direct_state_query_list;
VSet<RID> exceptions;
- Physics2DServer::CCDMode continuous_cd_mode;
+ PhysicsServer2D::CCDMode continuous_cd_mode;
bool omit_force_integration;
bool active;
bool can_sleep;
@@ -132,7 +132,7 @@ class Body2DSW : public CollisionObject2DSW {
_FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const Area2DSW *p_area);
- friend class Physics2DDirectBodyStateSW; // i give up, too many functions to expose
+ friend class PhysicsDirectBodyState2DSW; // i give up, too many functions to expose
public:
void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant());
@@ -158,7 +158,7 @@ public:
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
contacts.resize(p_size);
contact_count = 0;
- if (mode == Physics2DServer::BODY_MODE_KINEMATIC && p_size) set_active(true);
+ if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size) set_active(true);
}
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
@@ -224,19 +224,19 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode == Physics2DServer::BODY_MODE_STATIC || mode == Physics2DServer::BODY_MODE_KINEMATIC)
+ if ((!get_space()) || mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC)
return;
set_active(true);
}
- void set_param(Physics2DServer::BodyParameter p_param, real_t);
- real_t get_param(Physics2DServer::BodyParameter p_param) const;
+ void set_param(PhysicsServer2D::BodyParameter p_param, real_t);
+ real_t get_param(PhysicsServer2D::BodyParameter p_param) const;
- void set_mode(Physics2DServer::BodyMode p_mode);
- Physics2DServer::BodyMode get_mode() const;
+ void set_mode(PhysicsServer2D::BodyMode p_mode);
+ PhysicsServer2D::BodyMode get_mode() const;
- void set_state(Physics2DServer::BodyState p_state, const Variant &p_variant);
- Variant get_state(Physics2DServer::BodyState p_state) const;
+ void set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PhysicsServer2D::BodyState p_state) const;
void set_applied_force(const Vector2 &p_force) { applied_force = p_force; }
Vector2 get_applied_force() const { return applied_force; }
@@ -258,8 +258,8 @@ public:
applied_torque += p_torque;
}
- _FORCE_INLINE_ void set_continuous_collision_detection_mode(Physics2DServer::CCDMode p_mode) { continuous_cd_mode = p_mode; }
- _FORCE_INLINE_ Physics2DServer::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; }
+ _FORCE_INLINE_ void set_continuous_collision_detection_mode(PhysicsServer2D::CCDMode p_mode) { continuous_cd_mode = p_mode; }
+ _FORCE_INLINE_ PhysicsServer2D::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; }
void set_space(Space2DSW *p_space);
@@ -278,9 +278,9 @@ public:
_FORCE_INLINE_ Vector2 get_motion() const {
- if (mode > Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (mode > PhysicsServer2D::BODY_MODE_KINEMATIC) {
return new_transform.get_origin() - get_transform().get_origin();
- } else if (mode == Physics2DServer::BODY_MODE_KINEMATIC) {
+ } else if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
return get_transform().get_origin() - new_transform.get_origin(); //kinematic simulates forward
}
return Vector2();
@@ -341,12 +341,12 @@ void Body2DSW::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local_no
c[idx].collider_velocity_at_pos = p_collider_velocity_at_pos;
}
-class Physics2DDirectBodyStateSW : public Physics2DDirectBodyState {
+class PhysicsDirectBodyState2DSW : public PhysicsDirectBodyState2D {
- GDCLASS(Physics2DDirectBodyStateSW, Physics2DDirectBodyState);
+ GDCLASS(PhysicsDirectBodyState2DSW, PhysicsDirectBodyState2D);
public:
- static Physics2DDirectBodyStateSW *singleton;
+ static PhysicsDirectBodyState2DSW *singleton;
Body2DSW *body;
real_t step;
@@ -363,7 +363,7 @@ public:
virtual void set_angular_velocity(real_t p_velocity) { body->set_angular_velocity(p_velocity); }
virtual real_t get_angular_velocity() const { return body->get_angular_velocity(); }
- virtual void set_transform(const Transform2D &p_transform) { body->set_state(Physics2DServer::BODY_STATE_TRANSFORM, p_transform); }
+ virtual void set_transform(const Transform2D &p_transform) { body->set_state(PhysicsServer2D::BODY_STATE_TRANSFORM, p_transform); }
virtual Transform2D get_transform() const { return body->get_transform(); }
virtual void add_central_force(const Vector2 &p_force) { body->add_central_force(p_force); }
@@ -414,10 +414,10 @@ public:
return body->contacts[p_contact_idx].collider_velocity_at_pos;
}
- virtual Physics2DDirectSpaceState *get_space_state();
+ virtual PhysicsDirectSpaceState2D *get_space_state();
virtual real_t get_step() const { return step; }
- Physics2DDirectBodyStateSW() {
+ PhysicsDirectBodyState2DSW() {
singleton = this;
body = NULL;
}
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index 38f33134a5..f38a76cff6 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -230,7 +230,7 @@ real_t combine_friction(Body2DSW *A, Body2DSW *B) {
bool BodyPair2DSW::setup(real_t p_step) {
//cannot collide
- if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) {
+ if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) {
collided = false;
return false;
}
@@ -258,10 +258,10 @@ bool BodyPair2DSW::setup(real_t p_step) {
Vector2 motion_A, motion_B;
- if (A->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_SHAPE) {
+ if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_SHAPE) {
motion_A = A->get_motion();
}
- if (B->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_SHAPE) {
+ if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_SHAPE) {
motion_B = B->get_motion();
}
//faster to set than to check..
@@ -273,12 +273,12 @@ bool BodyPair2DSW::setup(real_t p_step) {
//test ccd (currently just a raycast)
- if (A->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_RAY && A->get_mode() > Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) {
if (_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B))
collided = true;
}
- if (B->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_RAY && B->get_mode() > Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) {
if (_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A, true))
collided = true;
}
@@ -405,7 +405,7 @@ bool BodyPair2DSW::setup(real_t p_step) {
}
}
- if ((A->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC)) {
+ if ((A->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC)) {
c.active = false;
collided = false;
continue;
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp
index 8fb3296be6..a6891372c2 100644
--- a/servers/physics_2d/collision_object_2d_sw.cpp
+++ b/servers/physics_2d/collision_object_2d_sw.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "collision_object_2d_sw.h"
-#include "servers/physics_2d/physics_2d_server_sw.h"
+#include "servers/physics_2d/physics_server_2d_sw.h"
#include "space_2d_sw.h"
void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform, bool p_disabled) {
@@ -46,7 +46,7 @@ void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_tra
p_shape->add_owner(this);
if (!pending_shape_update_list.in_list()) {
- Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
}
// _update_shapes();
// _shapes_changed();
@@ -61,7 +61,7 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
p_shape->add_owner(this);
if (!pending_shape_update_list.in_list()) {
- Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
}
// _update_shapes();
// _shapes_changed();
@@ -81,7 +81,7 @@ void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_
shapes.write[p_index].xform_inv = p_transform.affine_inverse();
if (!pending_shape_update_list.in_list()) {
- Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
}
// _update_shapes();
// _shapes_changed();
@@ -103,12 +103,12 @@ void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
space->get_broadphase()->remove(shape.bpid);
shape.bpid = 0;
if (!pending_shape_update_list.in_list()) {
- Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
}
//_update_shapes();
} else if (!p_disabled && shape.bpid == 0) {
if (!pending_shape_update_list.in_list()) {
- Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
}
//_update_shapes(); // automatically adds shape with bpid == 0
}
@@ -142,7 +142,7 @@ void CollisionObject2DSW::remove_shape(int p_index) {
shapes.remove(p_index);
if (!pending_shape_update_list.in_list()) {
- Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list);
}
// _update_shapes();
// _shapes_changed();
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index 3f9d19bbab..98105a7c0e 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -33,7 +33,7 @@
#include "broad_phase_2d_sw.h"
#include "core/self_list.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
#include "shape_2d_sw.h"
class Space2DSW;
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index da67fcc770..217c93c6da 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -1042,16 +1042,16 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW *p_a, const
bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
- Physics2DServer::ShapeType type_A = p_shape_A->get_type();
+ PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
- ERR_FAIL_COND_V(type_A == Physics2DServer::SHAPE_LINE, false);
- //ERR_FAIL_COND_V(type_A==Physics2DServer::SHAPE_RAY,false);
+ ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_LINE, false);
+ //ERR_FAIL_COND_V(type_A==PhysicsServer2D::SHAPE_RAY,false);
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
- Physics2DServer::ShapeType type_B = p_shape_B->get_type();
+ PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
- ERR_FAIL_COND_V(type_B == Physics2DServer::SHAPE_LINE, false);
- //ERR_FAIL_COND_V(type_B==Physics2DServer::SHAPE_RAY,false);
+ ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_LINE, false);
+ //ERR_FAIL_COND_V(type_B==PhysicsServer2D::SHAPE_RAY,false);
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
static const CollisionFunc collision_table[5][5] = {
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index 60cca6f825..f117dcbfe5 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -37,7 +37,7 @@
bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
const LineShape2DSW *line = static_cast<const LineShape2DSW *>(p_shape_A);
- if (p_shape_B->get_type() == Physics2DServer::SHAPE_LINE)
+ if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_LINE)
return false;
Vector2 n = p_transform_A.basis_xform(line->get_normal()).normalized();
@@ -75,7 +75,7 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Tr
bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis) {
const RayShape2DSW *ray = static_cast<const RayShape2DSW *>(p_shape_A);
- if (p_shape_B->get_type() == Physics2DServer::SHAPE_RAY)
+ if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_RAY)
return false;
Vector2 from = p_transform_A.get_origin();
@@ -195,8 +195,8 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A, const Transf
bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
- Physics2DServer::ShapeType type_A = p_shape_A->get_type();
- Physics2DServer::ShapeType type_B = p_shape_B->get_type();
+ PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
+ PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
bool concave_A = p_shape_A->is_concave();
bool concave_B = p_shape_B->is_concave();
real_t margin_A = p_margin_A, margin_B = p_margin_B;
@@ -210,9 +210,9 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
swap = true;
}
- if (type_A == Physics2DServer::SHAPE_LINE) {
+ if (type_A == PhysicsServer2D::SHAPE_LINE) {
- if (type_B == Physics2DServer::SHAPE_LINE || type_B == Physics2DServer::SHAPE_RAY) {
+ if (type_B == PhysicsServer2D::SHAPE_LINE || type_B == PhysicsServer2D::SHAPE_RAY) {
return false;
}
@@ -222,9 +222,9 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
return solve_static_line(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
}
- } else if (type_A == Physics2DServer::SHAPE_RAY) {
+ } else if (type_A == PhysicsServer2D::SHAPE_RAY) {
- if (type_B == Physics2DServer::SHAPE_RAY) {
+ if (type_B == PhysicsServer2D::SHAPE_RAY) {
return false; //no ray-ray
}
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 02b3502242..4524629d50 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -171,15 +171,15 @@ void PinJoint2DSW::solve(real_t p_step) {
P += impulse;
}
-void PinJoint2DSW::set_param(Physics2DServer::PinJointParam p_param, real_t p_value) {
+void PinJoint2DSW::set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value) {
- if (p_param == Physics2DServer::PIN_JOINT_SOFTNESS)
+ if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS)
softness = p_value;
}
-real_t PinJoint2DSW::get_param(Physics2DServer::PinJointParam p_param) const {
+real_t PinJoint2DSW::get_param(PhysicsServer2D::PinJointParam p_param) const {
- if (p_param == Physics2DServer::PIN_JOINT_SOFTNESS)
+ if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS)
return softness;
ERR_FAIL_V(0);
}
@@ -396,38 +396,38 @@ void DampedSpringJoint2DSW::solve(real_t p_step) {
B->apply_impulse(rB, j);
}
-void DampedSpringJoint2DSW::set_param(Physics2DServer::DampedStringParam p_param, real_t p_value) {
+void DampedSpringJoint2DSW::set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value) {
switch (p_param) {
- case Physics2DServer::DAMPED_STRING_REST_LENGTH: {
+ case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: {
rest_length = p_value;
} break;
- case Physics2DServer::DAMPED_STRING_DAMPING: {
+ case PhysicsServer2D::DAMPED_STRING_DAMPING: {
damping = p_value;
} break;
- case Physics2DServer::DAMPED_STRING_STIFFNESS: {
+ case PhysicsServer2D::DAMPED_STRING_STIFFNESS: {
stiffness = p_value;
} break;
}
}
-real_t DampedSpringJoint2DSW::get_param(Physics2DServer::DampedStringParam p_param) const {
+real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedStringParam p_param) const {
switch (p_param) {
- case Physics2DServer::DAMPED_STRING_REST_LENGTH: {
+ case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: {
return rest_length;
} break;
- case Physics2DServer::DAMPED_STRING_DAMPING: {
+ case PhysicsServer2D::DAMPED_STRING_DAMPING: {
return damping;
} break;
- case Physics2DServer::DAMPED_STRING_STIFFNESS: {
+ case PhysicsServer2D::DAMPED_STRING_STIFFNESS: {
return stiffness;
} break;
diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h
index 3e8fc1a29f..f4aeb6e3c8 100644
--- a/servers/physics_2d/joints_2d_sw.h
+++ b/servers/physics_2d/joints_2d_sw.h
@@ -50,7 +50,7 @@ public:
_FORCE_INLINE_ void set_max_bias(real_t p_bias) { max_bias = p_bias; }
_FORCE_INLINE_ real_t get_max_bias() const { return max_bias; }
- virtual Physics2DServer::JointType get_type() const = 0;
+ virtual PhysicsServer2D::JointType get_type() const = 0;
Joint2DSW(Body2DSW **p_body_ptr = NULL, int p_body_count = 0) :
Constraint2DSW(p_body_ptr, p_body_count) {
bias = 0;
@@ -78,13 +78,13 @@ class PinJoint2DSW : public Joint2DSW {
real_t softness;
public:
- virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_PIN; }
+ virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_PIN; }
virtual bool setup(real_t p_step);
virtual void solve(real_t p_step);
- void set_param(Physics2DServer::PinJointParam p_param, real_t p_value);
- real_t get_param(Physics2DServer::PinJointParam p_param) const;
+ void set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer2D::PinJointParam p_param) const;
PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b = NULL);
~PinJoint2DSW();
@@ -116,7 +116,7 @@ class GrooveJoint2DSW : public Joint2DSW {
bool correct;
public:
- virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_GROOVE; }
+ virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_GROOVE; }
virtual bool setup(real_t p_step);
virtual void solve(real_t p_step);
@@ -150,13 +150,13 @@ class DampedSpringJoint2DSW : public Joint2DSW {
real_t v_coef;
public:
- virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_DAMPED_SPRING; }
+ virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_DAMPED_SPRING; }
virtual bool setup(real_t p_step);
virtual void solve(real_t p_step);
- void set_param(Physics2DServer::DampedStringParam p_param, real_t p_value);
- real_t get_param(Physics2DServer::DampedStringParam p_param) const;
+ void set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer2D::DampedStringParam p_param) const;
DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b);
~DampedSpringJoint2DSW();
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index baeb3f76b0..e2a482e960 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_2d_server_sw.cpp */
+/* physics_server_2d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physics_2d_server_sw.h"
+#include "physics_server_2d_sw.h"
+
#include "broad_phase_2d_basic.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
@@ -39,7 +40,7 @@
#define FLUSH_QUERY_CHECK(m_object) \
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
-RID Physics2DServerSW::_shape_create(ShapeType p_shape) {
+RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
Shape2DSW *shape = NULL;
switch (p_shape) {
@@ -89,63 +90,63 @@ RID Physics2DServerSW::_shape_create(ShapeType p_shape) {
return id;
}
-RID Physics2DServerSW::line_shape_create() {
+RID PhysicsServer2DSW::line_shape_create() {
return _shape_create(SHAPE_LINE);
}
-RID Physics2DServerSW::ray_shape_create() {
+RID PhysicsServer2DSW::ray_shape_create() {
return _shape_create(SHAPE_RAY);
}
-RID Physics2DServerSW::segment_shape_create() {
+RID PhysicsServer2DSW::segment_shape_create() {
return _shape_create(SHAPE_SEGMENT);
}
-RID Physics2DServerSW::circle_shape_create() {
+RID PhysicsServer2DSW::circle_shape_create() {
return _shape_create(SHAPE_CIRCLE);
}
-RID Physics2DServerSW::rectangle_shape_create() {
+RID PhysicsServer2DSW::rectangle_shape_create() {
return _shape_create(SHAPE_RECTANGLE);
}
-RID Physics2DServerSW::capsule_shape_create() {
+RID PhysicsServer2DSW::capsule_shape_create() {
return _shape_create(SHAPE_CAPSULE);
}
-RID Physics2DServerSW::convex_polygon_shape_create() {
+RID PhysicsServer2DSW::convex_polygon_shape_create() {
return _shape_create(SHAPE_CONVEX_POLYGON);
}
-RID Physics2DServerSW::concave_polygon_shape_create() {
+RID PhysicsServer2DSW::concave_polygon_shape_create() {
return _shape_create(SHAPE_CONCAVE_POLYGON);
}
-void Physics2DServerSW::shape_set_data(RID p_shape, const Variant &p_data) {
+void PhysicsServer2DSW::shape_set_data(RID p_shape, const Variant &p_data) {
Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
-void Physics2DServerSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
+void PhysicsServer2DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
-Physics2DServer::ShapeType Physics2DServerSW::shape_get_type(RID p_shape) const {
+PhysicsServer2D::ShapeType PhysicsServer2DSW::shape_get_type(RID p_shape) const {
const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
-Variant Physics2DServerSW::shape_get_data(RID p_shape) const {
+Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const {
const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
@@ -153,14 +154,14 @@ Variant Physics2DServerSW::shape_get_data(RID p_shape) const {
return shape->get_data();
};
-real_t Physics2DServerSW::shape_get_custom_solver_bias(RID p_shape) const {
+real_t PhysicsServer2DSW::shape_get_custom_solver_bias(RID p_shape) const {
const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
-void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) {
+void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) {
CollCbkData *cbk = (CollCbkData *)p_userdata;
@@ -217,7 +218,7 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
}
}
-bool Physics2DServerSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
+bool PhysicsServer2DSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
Shape2DSW *shape_A = shape_owner.getornull(p_shape_A);
ERR_FAIL_COND_V(!shape_A, false);
@@ -240,7 +241,7 @@ bool Physics2DServerSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_
return res;
}
-RID Physics2DServerSW::space_create() {
+RID PhysicsServer2DSW::space_create() {
Space2DSW *space = memnew(Space2DSW);
RID id = space_owner.make_rid(space);
@@ -255,7 +256,7 @@ RID Physics2DServerSW::space_create() {
return id;
};
-void Physics2DServerSW::space_set_active(RID p_space, bool p_active) {
+void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) {
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -265,7 +266,7 @@ void Physics2DServerSW::space_set_active(RID p_space, bool p_active) {
active_spaces.erase(space);
}
-bool Physics2DServerSW::space_is_active(RID p_space) const {
+bool PhysicsServer2DSW::space_is_active(RID p_space) const {
const Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
@@ -273,7 +274,7 @@ bool Physics2DServerSW::space_is_active(RID p_space) const {
return active_spaces.has(space);
}
-void Physics2DServerSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -281,35 +282,35 @@ void Physics2DServerSW::space_set_param(RID p_space, SpaceParameter p_param, rea
space->set_param(p_param, p_value);
}
-real_t Physics2DServerSW::space_get_param(RID p_space, SpaceParameter p_param) const {
+real_t PhysicsServer2DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
const Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
-void Physics2DServerSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
+void PhysicsServer2DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
-Vector<Vector2> Physics2DServerSW::space_get_contacts(RID p_space) const {
+Vector<Vector2> PhysicsServer2DSW::space_get_contacts(RID p_space) const {
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector2>());
return space->get_debug_contacts();
}
-int Physics2DServerSW::space_get_contact_count(RID p_space) const {
+int PhysicsServer2DSW::space_get_contact_count(RID p_space) const {
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
-Physics2DDirectSpaceState *Physics2DServerSW::space_get_direct_state(RID p_space) {
+PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space) {
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, NULL);
@@ -318,7 +319,7 @@ Physics2DDirectSpaceState *Physics2DServerSW::space_get_direct_state(RID p_space
return space->get_direct_state();
}
-RID Physics2DServerSW::area_create() {
+RID PhysicsServer2DSW::area_create() {
Area2DSW *area = memnew(Area2DSW);
RID rid = area_owner.make_rid(area);
@@ -326,7 +327,7 @@ RID Physics2DServerSW::area_create() {
return rid;
};
-void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
+void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -344,7 +345,7 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
area->set_space(space);
};
-RID Physics2DServerSW::area_get_space(RID p_area) const {
+RID PhysicsServer2DSW::area_get_space(RID p_area) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
@@ -355,7 +356,7 @@ RID Physics2DServerSW::area_get_space(RID p_area) const {
return space->get_self();
};
-void Physics2DServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
+void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -363,7 +364,7 @@ void Physics2DServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverri
area->set_space_override_mode(p_mode);
}
-Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_override_mode(RID p_area) const {
+PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_override_mode(RID p_area) const {
const Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
@@ -371,7 +372,7 @@ Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_overrid
return area->get_space_override_mode();
}
-void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
+void PhysicsServer2DSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -382,7 +383,7 @@ void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2
area->add_shape(shape, p_transform, p_disabled);
}
-void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
+void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -393,7 +394,7 @@ void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
area->set_shape(p_shape_idx, shape);
}
-void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
+void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -401,7 +402,7 @@ void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, co
area->set_shape_transform(p_shape_idx, p_transform);
}
-void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
+void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -411,14 +412,14 @@ void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_
area->set_shape_as_disabled(p_shape, p_disabled);
}
-int Physics2DServerSW::area_get_shape_count(RID p_area) const {
+int PhysicsServer2DSW::area_get_shape_count(RID p_area) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
-RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const {
+RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
@@ -428,7 +429,7 @@ RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const {
return shape->get_self();
}
-Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
+Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
@@ -436,7 +437,7 @@ Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_
return area->get_shape_transform(p_shape_idx);
}
-void Physics2DServerSW::area_remove_shape(RID p_area, int p_shape_idx) {
+void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -444,7 +445,7 @@ void Physics2DServerSW::area_remove_shape(RID p_area, int p_shape_idx) {
area->remove_shape(p_shape_idx);
}
-void Physics2DServerSW::area_clear_shapes(RID p_area) {
+void PhysicsServer2DSW::area_clear_shapes(RID p_area) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -453,7 +454,7 @@ void Physics2DServerSW::area_clear_shapes(RID p_area) {
area->remove_shape(0);
}
-void Physics2DServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
+void PhysicsServer2DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
@@ -463,7 +464,7 @@ void Physics2DServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
-ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const {
+ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
@@ -474,7 +475,7 @@ ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const {
return area->get_instance_id();
}
-void Physics2DServerSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) {
+void PhysicsServer2DSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
@@ -484,7 +485,7 @@ void Physics2DServerSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id
ERR_FAIL_COND(!area);
area->set_canvas_instance_id(p_id);
}
-ObjectID Physics2DServerSW::area_get_canvas_instance_id(RID p_area) const {
+ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
@@ -495,7 +496,7 @@ ObjectID Physics2DServerSW::area_get_canvas_instance_id(RID p_area) const {
return area->get_canvas_instance_id();
}
-void Physics2DServerSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+void PhysicsServer2DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
@@ -506,14 +507,14 @@ void Physics2DServerSW::area_set_param(RID p_area, AreaParameter p_param, const
area->set_param(p_param, p_value);
};
-void Physics2DServerSW::area_set_transform(RID p_area, const Transform2D &p_transform) {
+void PhysicsServer2DSW::area_set_transform(RID p_area, const Transform2D &p_transform) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
-Variant Physics2DServerSW::area_get_param(RID p_area, AreaParameter p_param) const {
+Variant PhysicsServer2DSW::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
@@ -525,7 +526,7 @@ Variant Physics2DServerSW::area_get_param(RID p_area, AreaParameter p_param) con
return area->get_param(p_param);
};
-Transform2D Physics2DServerSW::area_get_transform(RID p_area) const {
+Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
@@ -533,14 +534,14 @@ Transform2D Physics2DServerSW::area_get_transform(RID p_area) const {
return area->get_transform();
};
-void Physics2DServerSW::area_set_pickable(RID p_area, bool p_pickable) {
+void PhysicsServer2DSW::area_set_pickable(RID p_area, bool p_pickable) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_pickable(p_pickable);
}
-void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) {
+void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -549,7 +550,7 @@ void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) {
area->set_monitorable(p_monitorable);
}
-void Physics2DServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
+void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -557,7 +558,7 @@ void Physics2DServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
area->set_collision_mask(p_mask);
}
-void Physics2DServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
+void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -565,7 +566,7 @@ void Physics2DServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
area->set_collision_layer(p_layer);
}
-void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -573,7 +574,7 @@ void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver
area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
-void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+void PhysicsServer2DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -583,7 +584,7 @@ void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_rec
/* BODY API */
-RID Physics2DServerSW::body_create() {
+RID PhysicsServer2DSW::body_create() {
Body2DSW *body = memnew(Body2DSW);
RID rid = body_owner.make_rid(body);
@@ -591,7 +592,7 @@ RID Physics2DServerSW::body_create() {
return rid;
}
-void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
+void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -608,7 +609,7 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
body->set_space(space);
};
-RID Physics2DServerSW::body_get_space(RID p_body) const {
+RID PhysicsServer2DSW::body_get_space(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -619,7 +620,7 @@ RID Physics2DServerSW::body_get_space(RID p_body) const {
return space->get_self();
};
-void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) {
+void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -628,7 +629,7 @@ void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) {
body->set_mode(p_mode);
};
-Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const {
+PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
@@ -636,7 +637,7 @@ Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const {
return body->get_mode();
};
-void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
+void PhysicsServer2DSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -647,7 +648,7 @@ void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2
body->add_shape(shape, p_transform, p_disabled);
}
-void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
+void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -658,7 +659,7 @@ void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
body->set_shape(p_shape_idx, shape);
}
-void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
+void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -666,28 +667,28 @@ void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, co
body->set_shape_transform(p_shape_idx, p_transform);
}
-void Physics2DServerSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) {
+void PhysicsServer2DSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_metadata(p_shape_idx, p_metadata);
}
-Variant Physics2DServerSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const {
+Variant PhysicsServer2DSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_shape_metadata(p_shape_idx);
}
-int Physics2DServerSW::body_get_shape_count(RID p_body) const {
+int PhysicsServer2DSW::body_get_shape_count(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
-RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const {
+RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -697,7 +698,7 @@ RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const {
return shape->get_self();
}
-Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
+Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform2D());
@@ -705,7 +706,7 @@ Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_
return body->get_shape_transform(p_shape_idx);
}
-void Physics2DServerSW::body_remove_shape(RID p_body, int p_shape_idx) {
+void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -713,7 +714,7 @@ void Physics2DServerSW::body_remove_shape(RID p_body, int p_shape_idx) {
body->remove_shape(p_shape_idx);
}
-void Physics2DServerSW::body_clear_shapes(RID p_body) {
+void PhysicsServer2DSW::body_clear_shapes(RID p_body) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -722,7 +723,7 @@ void Physics2DServerSW::body_clear_shapes(RID p_body) {
body->remove_shape(0);
}
-void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
+void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -731,7 +732,7 @@ void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
body->set_shape_as_disabled(p_shape_idx, p_disabled);
}
-void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {
+void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -741,14 +742,14 @@ void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh
body->set_shape_as_one_way_collision(p_shape_idx, p_enable, p_margin);
}
-void Physics2DServerSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
+void PhysicsServer2DSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection_mode(p_mode);
}
-Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_detection_mode(RID p_body) const {
+PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_detection_mode(RID p_body) const {
const Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED);
@@ -756,7 +757,7 @@ Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_dete
return body->get_continuous_collision_detection_mode();
}
-void Physics2DServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
+void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -764,7 +765,7 @@ void Physics2DServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id
body->set_instance_id(p_id);
};
-ObjectID Physics2DServerSW::body_get_object_instance_id(RID p_body) const {
+ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
@@ -772,7 +773,7 @@ ObjectID Physics2DServerSW::body_get_object_instance_id(RID p_body) const {
return body->get_instance_id();
};
-void Physics2DServerSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
+void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -780,7 +781,7 @@ void Physics2DServerSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id
body->set_canvas_instance_id(p_id);
};
-ObjectID Physics2DServerSW::body_get_canvas_instance_id(RID p_body) const {
+ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
@@ -788,14 +789,14 @@ ObjectID Physics2DServerSW::body_get_canvas_instance_id(RID p_body) const {
return body->get_canvas_instance_id();
};
-void Physics2DServerSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
+void PhysicsServer2DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
};
-uint32_t Physics2DServerSW::body_get_collision_layer(RID p_body) const {
+uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -803,14 +804,14 @@ uint32_t Physics2DServerSW::body_get_collision_layer(RID p_body) const {
return body->get_collision_layer();
};
-void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
+void PhysicsServer2DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
};
-uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
+uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -818,7 +819,7 @@ uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
return body->get_collision_mask();
};
-void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
+void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -826,7 +827,7 @@ void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t
body->set_param(p_param, p_value);
};
-real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
+real_t PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -834,7 +835,7 @@ real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) cons
return body->get_param(p_param);
};
-void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -842,7 +843,7 @@ void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Vari
body->set_state(p_state, p_variant);
};
-Variant Physics2DServerSW::body_get_state(RID p_body, BodyState p_state) const {
+Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
@@ -850,7 +851,7 @@ Variant Physics2DServerSW::body_get_state(RID p_body, BodyState p_state) const {
return body->get_state(p_state);
};
-void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2 &p_force) {
+void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_force) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -859,14 +860,14 @@ void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2 &p_forc
body->wakeup();
};
-Vector2 Physics2DServerSW::body_get_applied_force(RID p_body) const {
+Vector2 PhysicsServer2DSW::body_get_applied_force(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector2());
return body->get_applied_force();
};
-void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) {
+void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -875,7 +876,7 @@ void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) {
body->wakeup();
};
-real_t Physics2DServerSW::body_get_applied_torque(RID p_body) const {
+real_t PhysicsServer2DSW::body_get_applied_torque(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -883,7 +884,7 @@ real_t Physics2DServerSW::body_get_applied_torque(RID p_body) const {
return body->get_applied_torque();
};
-void Physics2DServerSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
+void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -891,7 +892,7 @@ void Physics2DServerSW::body_apply_central_impulse(RID p_body, const Vector2 &p_
body->wakeup();
}
-void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
+void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -900,7 +901,7 @@ void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
body->apply_torque_impulse(p_torque);
}
-void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, const Vector2 &p_impulse) {
+void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, const Vector2 &p_impulse) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -911,7 +912,7 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, con
body->wakeup();
};
-void Physics2DServerSW::body_add_central_force(RID p_body, const Vector2 &p_force) {
+void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_force) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -919,7 +920,7 @@ void Physics2DServerSW::body_add_central_force(RID p_body, const Vector2 &p_forc
body->wakeup();
};
-void Physics2DServerSW::body_add_force(RID p_body, const Vector2 &p_offset, const Vector2 &p_force) {
+void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_offset, const Vector2 &p_force) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -928,7 +929,7 @@ void Physics2DServerSW::body_add_force(RID p_body, const Vector2 &p_offset, cons
body->wakeup();
};
-void Physics2DServerSW::body_add_torque(RID p_body, real_t p_torque) {
+void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -936,7 +937,7 @@ void Physics2DServerSW::body_add_torque(RID p_body, real_t p_torque) {
body->wakeup();
};
-void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
+void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -951,7 +952,7 @@ void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
body->wakeup();
};
-void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
+void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -960,7 +961,7 @@ void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
body->wakeup();
};
-void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
+void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -969,7 +970,7 @@ void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b
body->wakeup();
};
-void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
+void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -979,20 +980,20 @@ void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
}
};
-void Physics2DServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
+void PhysicsServer2DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
};
-real_t Physics2DServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
+real_t PhysicsServer2DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
-void Physics2DServerSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
+void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -1000,35 +1001,35 @@ void Physics2DServerSW::body_set_omit_force_integration(RID p_body, bool p_omit)
body->set_omit_force_integration(p_omit);
};
-bool Physics2DServerSW::body_is_omitting_force_integration(RID p_body) const {
+bool PhysicsServer2DSW::body_is_omitting_force_integration(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
-void Physics2DServerSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
+void PhysicsServer2DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
-int Physics2DServerSW::body_get_max_contacts_reported(RID p_body) const {
+int PhysicsServer2DSW::body_get_max_contacts_reported(RID p_body) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
-void Physics2DServerSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
+void PhysicsServer2DSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
-bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) {
+bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
@@ -1037,14 +1038,14 @@ bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s
return shape_collide(body->get_shape(p_body_shape)->get_self(), body->get_transform() * body->get_shape_transform(p_body_shape), Vector2(), p_shape, p_shape_xform, p_motion, r_results, p_result_max, r_result_count);
}
-void Physics2DServerSW::body_set_pickable(RID p_body, bool p_pickable) {
+void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_pickable(p_pickable);
}
-bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
@@ -1056,7 +1057,7 @@ bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from,
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes);
}
-int Physics2DServerSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
+int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
@@ -1066,7 +1067,7 @@ int Physics2DServerSW::body_test_ray_separation(RID p_body, const Transform2D &p
return body->get_space()->test_body_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
}
-Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) {
+PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification.");
@@ -1084,7 +1085,7 @@ Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) {
/* JOINT API */
-void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
+void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
@@ -1096,7 +1097,7 @@ void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t
}
}
-real_t Physics2DServerSW::joint_get_param(RID p_joint, JointParam p_param) const {
+real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const {
const Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, -1);
@@ -1110,7 +1111,7 @@ real_t Physics2DServerSW::joint_get_param(RID p_joint, JointParam p_param) const
return 0;
}
-void Physics2DServerSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
+void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
@@ -1130,14 +1131,14 @@ void Physics2DServerSW::joint_disable_collisions_between_bodies(RID p_joint, con
}
}
-bool Physics2DServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
+bool PhysicsServer2DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
const Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, true);
return joint->is_disabled_collisions_between_bodies();
}
-RID Physics2DServerSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
+RID PhysicsServer2DSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
@@ -1154,7 +1155,7 @@ RID Physics2DServerSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID
return self;
}
-RID Physics2DServerSW::groove_joint_create(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) {
+RID PhysicsServer2DSW::groove_joint_create(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) {
Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
@@ -1168,7 +1169,7 @@ RID Physics2DServerSW::groove_joint_create(const Vector2 &p_a_groove1, const Vec
return self;
}
-RID Physics2DServerSW::damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) {
+RID PhysicsServer2DSW::damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) {
Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
@@ -1182,7 +1183,7 @@ RID Physics2DServerSW::damped_spring_joint_create(const Vector2 &p_anchor_a, con
return self;
}
-void Physics2DServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
+void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!j);
@@ -1192,7 +1193,7 @@ void Physics2DServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
pin_joint->set_param(p_param, p_value);
}
-real_t Physics2DServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_PIN, 0);
@@ -1201,7 +1202,7 @@ real_t Physics2DServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
return pin_joint->get_param(p_param);
}
-void Physics2DServerSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) {
+void PhysicsServer2DSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) {
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!j);
@@ -1211,7 +1212,7 @@ void Physics2DServerSW::damped_string_joint_set_param(RID p_joint, DampedStringP
dsj->set_param(p_param, p_value);
}
-real_t Physics2DServerSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const {
+real_t PhysicsServer2DSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const {
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!j, 0);
@@ -1221,7 +1222,7 @@ real_t Physics2DServerSW::damped_string_joint_get_param(RID p_joint, DampedStrin
return dsj->get_param(p_param);
}
-Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const {
+PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const {
Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
@@ -1229,7 +1230,7 @@ Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const
return joint->get_type();
}
-void Physics2DServerSW::free(RID p_rid) {
+void PhysicsServer2DSW::free(RID p_rid) {
_update_shapes(); // just in case
@@ -1310,21 +1311,21 @@ void Physics2DServerSW::free(RID p_rid) {
}
};
-void Physics2DServerSW::set_active(bool p_active) {
+void PhysicsServer2DSW::set_active(bool p_active) {
active = p_active;
};
-void Physics2DServerSW::init() {
+void PhysicsServer2DSW::init() {
doing_sync = false;
last_step = 0.001;
iterations = 8; // 8?
stepper = memnew(Step2DSW);
- direct_state = memnew(Physics2DDirectBodyStateSW);
+ direct_state = memnew(PhysicsDirectBodyState2DSW);
};
-void Physics2DServerSW::step(real_t p_step) {
+void PhysicsServer2DSW::step(real_t p_step) {
if (!active)
return;
@@ -1334,7 +1335,7 @@ void Physics2DServerSW::step(real_t p_step) {
doing_sync = false;
last_step = p_step;
- Physics2DDirectBodyStateSW::singleton->step = p_step;
+ PhysicsDirectBodyState2DSW::singleton->step = p_step;
island_count = 0;
active_objects = 0;
collision_pairs = 0;
@@ -1347,12 +1348,12 @@ void Physics2DServerSW::step(real_t p_step) {
}
};
-void Physics2DServerSW::sync() {
+void PhysicsServer2DSW::sync() {
doing_sync = true;
};
-void Physics2DServerSW::flush_queries() {
+void PhysicsServer2DSW::flush_queries() {
if (!active)
return;
@@ -1405,17 +1406,17 @@ void Physics2DServerSW::flush_queries() {
}
}
-void Physics2DServerSW::end_sync() {
+void PhysicsServer2DSW::end_sync() {
doing_sync = false;
}
-void Physics2DServerSW::finish() {
+void PhysicsServer2DSW::finish() {
memdelete(stepper);
memdelete(direct_state);
};
-void Physics2DServerSW::_update_shapes() {
+void PhysicsServer2DSW::_update_shapes() {
while (pending_shape_update_list.first()) {
pending_shape_update_list.first()->self()->_shape_changed();
@@ -1423,7 +1424,7 @@ void Physics2DServerSW::_update_shapes() {
}
}
-int Physics2DServerSW::get_process_info(ProcessInfo p_info) {
+int PhysicsServer2DSW::get_process_info(ProcessInfo p_info) {
switch (p_info) {
@@ -1443,9 +1444,9 @@ int Physics2DServerSW::get_process_info(ProcessInfo p_info) {
return 0;
}
-Physics2DServerSW *Physics2DServerSW::singletonsw = NULL;
+PhysicsServer2DSW *PhysicsServer2DSW::singletonsw = NULL;
-Physics2DServerSW::Physics2DServerSW() {
+PhysicsServer2DSW::PhysicsServer2DSW() {
singletonsw = this;
BroadPhase2DSW::create_func = BroadPhase2DHashGrid::_create;
@@ -1459,6 +1460,6 @@ Physics2DServerSW::Physics2DServerSW() {
flushing_queries = false;
};
-Physics2DServerSW::~Physics2DServerSW(){
+PhysicsServer2DSW::~PhysicsServer2DSW(){
};
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_server_2d_sw.h
index a95a2ea0dd..9dfa8bf474 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_server_2d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_2d_server_sw.h */
+/* physics_server_2d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,17 +33,17 @@
#include "core/rid_owner.h"
#include "joints_2d_sw.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
#include "shape_2d_sw.h"
#include "space_2d_sw.h"
#include "step_2d_sw.h"
-class Physics2DServerSW : public Physics2DServer {
+class PhysicsServer2DSW : public PhysicsServer2D {
- GDCLASS(Physics2DServerSW, Physics2DServer);
+ GDCLASS(PhysicsServer2DSW, PhysicsServer2D);
- friend class Physics2DDirectSpaceStateSW;
- friend class Physics2DDirectBodyStateSW;
+ friend class PhysicsDirectSpaceState2DSW;
+ friend class PhysicsDirectBodyState2DSW;
bool active;
int iterations;
bool doing_sync;
@@ -60,7 +60,7 @@ class Physics2DServerSW : public Physics2DServer {
Step2DSW *stepper;
Set<const Space2DSW *> active_spaces;
- Physics2DDirectBodyStateSW *direct_state;
+ PhysicsDirectBodyState2DSW *direct_state;
mutable RID_PtrOwner<Shape2DSW> shape_owner;
mutable RID_PtrOwner<Space2DSW> space_owner;
@@ -68,7 +68,7 @@ class Physics2DServerSW : public Physics2DServer {
mutable RID_PtrOwner<Body2DSW> body_owner;
mutable RID_PtrOwner<Joint2DSW> joint_owner;
- static Physics2DServerSW *singletonsw;
+ static PhysicsServer2DSW *singletonsw;
//void _clear_query(Query2DSW *p_query);
friend class CollisionObject2DSW;
@@ -123,7 +123,7 @@ public:
virtual int space_get_contact_count(RID p_space) const;
// this function only works on physics process, errors and returns null otherwise
- virtual Physics2DDirectSpaceState *space_get_direct_state(RID p_space);
+ virtual PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space);
/* AREA API */
@@ -253,7 +253,7 @@ public:
virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001);
// this function only works on physics process, errors and returns null otherwise
- virtual Physics2DDirectBodyState *body_get_direct_state(RID p_body);
+ virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body);
/* JOINT API */
@@ -289,8 +289,8 @@ public:
int get_process_info(ProcessInfo p_info);
- Physics2DServerSW();
- ~Physics2DServerSW();
+ PhysicsServer2DSW();
+ ~PhysicsServer2DSW();
};
#endif
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_server_2d_wrap_mt.cpp
index 76036930c6..5f65e296fd 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_2d_server_wrap_mt.cpp */
+/* physics_server_2d_wrap_mt.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,29 +28,29 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physics_2d_server_wrap_mt.h"
+#include "physics_server_2d_wrap_mt.h"
#include "core/os/os.h"
-void Physics2DServerWrapMT::thread_exit() {
+void PhysicsServer2DWrapMT::thread_exit() {
exit = true;
}
-void Physics2DServerWrapMT::thread_step(real_t p_delta) {
+void PhysicsServer2DWrapMT::thread_step(real_t p_delta) {
physics_2d_server->step(p_delta);
step_sem.post();
}
-void Physics2DServerWrapMT::_thread_callback(void *_instance) {
+void PhysicsServer2DWrapMT::_thread_callback(void *_instance) {
- Physics2DServerWrapMT *vsmt = reinterpret_cast<Physics2DServerWrapMT *>(_instance);
+ PhysicsServer2DWrapMT *vsmt = reinterpret_cast<PhysicsServer2DWrapMT *>(_instance);
vsmt->thread_loop();
}
-void Physics2DServerWrapMT::thread_loop() {
+void PhysicsServer2DWrapMT::thread_loop() {
server_thread = Thread::get_caller_id();
@@ -70,11 +70,11 @@ void Physics2DServerWrapMT::thread_loop() {
/* EVENT QUEUING */
-void Physics2DServerWrapMT::step(real_t p_step) {
+void PhysicsServer2DWrapMT::step(real_t p_step) {
if (create_thread) {
- command_queue.push(this, &Physics2DServerWrapMT::thread_step, p_step);
+ command_queue.push(this, &PhysicsServer2DWrapMT::thread_step, p_step);
} else {
command_queue.flush_all(); //flush all pending from other threads
@@ -82,7 +82,7 @@ void Physics2DServerWrapMT::step(real_t p_step) {
}
}
-void Physics2DServerWrapMT::sync() {
+void PhysicsServer2DWrapMT::sync() {
if (thread) {
if (first_frame)
@@ -93,17 +93,17 @@ void Physics2DServerWrapMT::sync() {
physics_2d_server->sync();
}
-void Physics2DServerWrapMT::flush_queries() {
+void PhysicsServer2DWrapMT::flush_queries() {
physics_2d_server->flush_queries();
}
-void Physics2DServerWrapMT::end_sync() {
+void PhysicsServer2DWrapMT::end_sync() {
physics_2d_server->end_sync();
}
-void Physics2DServerWrapMT::init() {
+void PhysicsServer2DWrapMT::init() {
if (create_thread) {
@@ -118,11 +118,11 @@ void Physics2DServerWrapMT::init() {
}
}
-void Physics2DServerWrapMT::finish() {
+void PhysicsServer2DWrapMT::finish() {
if (thread) {
- command_queue.push(this, &Physics2DServerWrapMT::thread_exit);
+ command_queue.push(this, &PhysicsServer2DWrapMT::thread_exit);
Thread::wait_to_finish(thread);
memdelete(thread);
@@ -145,7 +145,7 @@ void Physics2DServerWrapMT::finish() {
body_free_cached_ids();
}
-Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread) :
+PhysicsServer2DWrapMT::PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
physics_2d_server = p_contained;
@@ -166,7 +166,7 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool
first_frame = true;
}
-Physics2DServerWrapMT::~Physics2DServerWrapMT() {
+PhysicsServer2DWrapMT::~PhysicsServer2DWrapMT() {
memdelete(physics_2d_server);
//finish();
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index 4d5e317c8c..ffd46feebd 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_2d_server_wrap_mt.h */
+/* physics_server_2d_wrap_mt.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,7 +34,7 @@
#include "core/command_queue_mt.h"
#include "core/os/thread.h"
#include "core/project_settings.h"
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__));
@@ -42,9 +42,9 @@
#define SYNC_DEBUG
#endif
-class Physics2DServerWrapMT : public Physics2DServer {
+class PhysicsServer2DWrapMT : public PhysicsServer2D {
- mutable Physics2DServer *physics_2d_server;
+ mutable PhysicsServer2D *physics_2d_server;
mutable CommandQueueMT command_queue;
@@ -71,8 +71,8 @@ class Physics2DServerWrapMT : public Physics2DServer {
int pool_max_size;
public:
-#define ServerName Physics2DServer
-#define ServerNameWrapMT Physics2DServerWrapMT
+#define ServerName PhysicsServer2D
+#define ServerNameWrapMT PhysicsServer2DWrapMT
#define server_name physics_2d_server
#include "servers/server_wrap_mt_common.h"
@@ -110,7 +110,7 @@ public:
FUNC2RC(real_t, space_get_param, RID, SpaceParameter);
// this function only works on physics process, errors and returns null otherwise
- Physics2DDirectSpaceState *space_get_direct_state(RID p_space) {
+ PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), NULL);
return physics_2d_server->space_get_direct_state(p_space);
@@ -268,7 +268,7 @@ public:
}
// this function only works on physics process, errors and returns null otherwise
- Physics2DDirectBodyState *body_get_direct_state(RID p_body) {
+ PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), NULL);
return physics_2d_server->body_get_direct_state(p_body);
@@ -320,19 +320,19 @@ public:
return physics_2d_server->get_process_info(p_info);
}
- Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread);
- ~Physics2DServerWrapMT();
+ PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread);
+ ~PhysicsServer2DWrapMT();
template <class T>
- static Physics2DServer *init_server() {
+ static PhysicsServer2D *init_server() {
int tm = GLOBAL_DEF("physics/2d/thread_model", 1);
if (tm == 0) // single unsafe
return memnew(T);
else if (tm == 1) // single safe
- return memnew(Physics2DServerWrapMT(memnew(T), false));
+ return memnew(PhysicsServer2DWrapMT(memnew(T), false));
else // multi threaded
- return memnew(Physics2DServerWrapMT(memnew(T), true));
+ return memnew(PhysicsServer2DWrapMT(memnew(T), true));
}
#undef ServerNameWrapMT
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index fa56f2a250..48f3bea1e1 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_2D_2DSW_H
#define SHAPE_2D_2DSW_H
-#include "servers/physics_2d_server.h"
+#include "servers/physics_server_2d.h"
#define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998
/*
@@ -72,7 +72,7 @@ public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- virtual Physics2DServer::ShapeType get_type() const = 0;
+ virtual PhysicsServer2D::ShapeType get_type() const = 0;
_FORCE_INLINE_ Rect2 get_aabb() const { return aabb; }
_FORCE_INLINE_ bool is_configured() const { return configured; }
@@ -165,7 +165,7 @@ public:
_FORCE_INLINE_ Vector2 get_normal() const { return normal; }
_FORCE_INLINE_ real_t get_d() const { return d; }
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_LINE; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_LINE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -203,7 +203,7 @@ public:
_FORCE_INLINE_ real_t get_length() const { return length; }
_FORCE_INLINE_ bool get_slips_on_slope() const { return slips_on_slope; }
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_RAY; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_RAY; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -242,7 +242,7 @@ public:
_FORCE_INLINE_ const Vector2 &get_b() const { return b; }
_FORCE_INLINE_ const Vector2 &get_normal() const { return n; }
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_SEGMENT; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_SEGMENT; }
_FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const {
@@ -285,7 +285,7 @@ class CircleShape2DSW : public Shape2DSW {
public:
_FORCE_INLINE_ const real_t &get_radius() const { return radius; }
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CIRCLE; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CIRCLE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -319,7 +319,7 @@ class RectangleShape2DSW : public Shape2DSW {
public:
_FORCE_INLINE_ const Vector2 &get_half_extents() const { return half_extents; }
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_RECTANGLE; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_RECTANGLE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -395,7 +395,7 @@ public:
_FORCE_INLINE_ const real_t &get_radius() const { return radius; }
_FORCE_INLINE_ const real_t &get_height() const { return height; }
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CAPSULE; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CAPSULE; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -452,7 +452,7 @@ public:
return (p_xform.xform(b) - p_xform.xform(a)).normalized().tangent();
}
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CONVEX_POLYGON; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONVEX_POLYGON; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -531,7 +531,7 @@ class ConcavePolygonShape2DSW : public ConcaveShape2DSW {
int _generate_bvh(BVH *p_bvh, int p_len, int p_depth);
public:
- virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CONCAVE_POLYGON; }
+ virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONCAVE_POLYGON; }
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/
}
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 2009cb823d..cba190995f 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -33,7 +33,7 @@
#include "collision_solver_2d_sw.h"
#include "core/os/os.h"
#include "core/pair.h"
-#include "physics_2d_server_sw.h"
+#include "physics_server_2d_sw.h"
_FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (!(p_object->get_collision_layer() & p_collision_mask)) {
@@ -49,7 +49,7 @@ _FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint
return true;
}
-int Physics2DDirectSpaceStateSW::_intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
+int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
if (p_result_max <= 0)
return 0;
@@ -103,17 +103,17 @@ int Physics2DDirectSpaceStateSW::_intersect_point_impl(const Vector2 &p_point, S
return cc;
}
-int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) {
+int PhysicsDirectSpaceState2DSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) {
return _intersect_point_impl(p_point, r_results, p_result_max, p_exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_point);
}
-int Physics2DDirectSpaceStateSW::intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_instance_id, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) {
+int PhysicsDirectSpaceState2DSW::intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_instance_id, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) {
return _intersect_point_impl(p_point, r_results, p_result_max, p_exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_point, true, p_canvas_instance_id);
}
-bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
ERR_FAIL_COND_V(space->locked, false);
@@ -193,12 +193,12 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec
return true;
}
-int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (p_result_max <= 0)
return 0;
- Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -238,9 +238,9 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
return cc;
}
-bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, false);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -308,12 +308,12 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor
return true;
}
-bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (p_result_max <= 0)
return 0;
- Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
@@ -325,14 +325,14 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
bool collided = false;
r_result_count = 0;
- Physics2DServerSW::CollCbkData cbk;
+ PhysicsServer2DSW::CollCbkData cbk;
cbk.max = p_result_max;
cbk.amount = 0;
cbk.passed = 0;
cbk.ptr = r_results;
- CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk;
+ CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk;
- Physics2DServerSW::CollCbkData *cbkptr = &cbk;
+ PhysicsServer2DSW::CollCbkData *cbkptr = &cbk;
for (int i = 0; i < amount; i++) {
@@ -402,9 +402,9 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
rd->best_local_shape = rd->local_shape;
}
-bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
@@ -462,7 +462,7 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh
return true;
}
-Physics2DDirectSpaceStateSW::Physics2DDirectSpaceStateSW() {
+PhysicsDirectSpaceState2DSW::PhysicsDirectSpaceState2DSW() {
space = NULL;
}
@@ -503,7 +503,7 @@ int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body, const Rect2 &p_aabb) {
return amount;
}
-int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, Physics2DServer::SeparationResult *r_results, int p_result_max, real_t p_margin) {
+int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, PhysicsServer2D::SeparationResult *r_results, int p_result_max, real_t p_margin) {
Rect2 body_aabb;
@@ -514,7 +514,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
if (p_body->is_shape_set_as_disabled(i))
continue;
- if (p_body->get_shape(i)->get_type() != Physics2DServer::SHAPE_RAY)
+ if (p_body->get_shape(i)->get_type() != PhysicsServer2D::SHAPE_RAY)
continue;
if (!shapes_found) {
@@ -548,10 +548,10 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
const int max_results = 32;
int recover_attempts = 4;
Vector2 sr[max_results * 2];
- Physics2DServerSW::CollCbkData cbk;
+ PhysicsServer2DSW::CollCbkData cbk;
cbk.max = max_results;
- Physics2DServerSW::CollCbkData *cbkptr = &cbk;
- CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk;
+ PhysicsServer2DSW::CollCbkData *cbkptr = &cbk;
+ CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk;
do {
@@ -567,7 +567,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
Shape2DSW *body_shape = p_body->get_shape(j);
- if (body_shape->get_type() != Physics2DServer::SHAPE_RAY)
+ if (body_shape->get_type() != PhysicsServer2D::SHAPE_RAY)
continue;
Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j);
@@ -584,7 +584,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) {
const Body2DSW *b = static_cast<const Body2DSW *>(col_obj);
- if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) {
+ if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
@@ -632,7 +632,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
if (ray_index != -1) {
- Physics2DServer::SeparationResult &result = r_results[ray_index];
+ PhysicsServer2D::SeparationResult &result = r_results[ray_index];
for (int k = 0; k < cbk.amount; k++) {
Vector2 a = sr[k * 2 + 0];
@@ -687,7 +687,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
return rays_found;
}
-bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, Physics2DServer::MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
//give me back regular physics engine logic
//this is madness
@@ -709,7 +709,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (p_body->is_shape_set_as_disabled(i))
continue;
- if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == Physics2DServer::SHAPE_RAY)
+ if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == PhysicsServer2D::SHAPE_RAY)
continue;
if (!shapes_found) {
@@ -722,7 +722,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (!shapes_found) {
if (r_result) {
- *r_result = Physics2DServer::MotionResult();
+ *r_result = PhysicsServer2D::MotionResult();
r_result->motion = p_motion;
}
return false;
@@ -749,7 +749,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
do {
- Physics2DServerSW::CollCbkData cbk;
+ PhysicsServer2DSW::CollCbkData cbk;
cbk.max = max_results;
cbk.amount = 0;
cbk.passed = 0;
@@ -757,8 +757,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
cbk.invalid_by_dir = 0;
excluded_shape_pair_count = 0; //last step is the one valid
- Physics2DServerSW::CollCbkData *cbkptr = &cbk;
- CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk;
+ PhysicsServer2DSW::CollCbkData *cbkptr = &cbk;
+ CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk;
bool collided = false;
@@ -769,7 +769,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
continue;
Shape2DSW *body_shape = p_body->get_shape(j);
- if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) {
+ if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) {
continue;
}
@@ -781,7 +781,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) {
const Body2DSW *b = static_cast<const Body2DSW *>(col_obj);
- if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) {
+ if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
@@ -798,11 +798,11 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (col_obj->get_type() == CollisionObject2DSW::TYPE_BODY) {
const Body2DSW *b = static_cast<const Body2DSW *>(col_obj);
- if (b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC || b->get_mode() == Physics2DServer::BODY_MODE_RIGID) {
+ if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_RIGID) {
//fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction
Vector2 lv = b->get_linear_velocity();
//compute displacement from linear velocity
- Vector2 motion = lv * Physics2DDirectBodyStateSW::singleton->step;
+ Vector2 motion = lv * PhysicsDirectBodyState2DSW::singleton->step;
float motion_len = motion.length();
motion.normalize();
cbk.valid_depth += motion_len * MAX(motion.dot(-cbk.valid_dir), 0.0);
@@ -884,7 +884,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
continue;
Shape2DSW *body_shape = p_body->get_shape(body_shape_idx);
- if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) {
+ if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) {
continue;
}
@@ -903,7 +903,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) {
const Body2DSW *b = static_cast<const Body2DSW *>(col_obj);
- if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) {
+ if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
@@ -964,7 +964,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) {
Vector2 cd[2];
- Physics2DServerSW::CollCbkData cbk;
+ PhysicsServer2DSW::CollCbkData cbk;
cbk.max = 1;
cbk.amount = 0;
cbk.passed = 0;
@@ -974,7 +974,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
cbk.valid_depth = 10e20;
Vector2 sep = mnormal; //important optimization for this to work fast enough
- bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_shape_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0);
+ bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_shape_xform, Vector2(), PhysicsServer2DSW::_shape_col_cbk, &cbk, &sep, 0);
if (!collided || cbk.amount == 0) {
continue;
}
@@ -1034,7 +1034,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Transform2D body_shape_xform = ugt * p_body->get_shape_transform(j);
Shape2DSW *body_shape = p_body->get_shape(j);
- if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) {
+ if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) {
continue;
}
@@ -1049,7 +1049,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) {
const Body2DSW *b = static_cast<const Body2DSW *>(col_obj);
- if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) {
+ if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
@@ -1277,33 +1277,33 @@ void Space2DSW::update() {
broadphase->update();
}
-void Space2DSW::set_param(Physics2DServer::SpaceParameter p_param, real_t p_value) {
+void Space2DSW::set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value) {
switch (p_param) {
- case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break;
- case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break;
- case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break;
- case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
- case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
- case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break;
- case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break;
- case Physics2DServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break;
+ case PhysicsServer2D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break;
}
}
-real_t Space2DSW::get_param(Physics2DServer::SpaceParameter p_param) const {
+real_t Space2DSW::get_param(PhysicsServer2D::SpaceParameter p_param) const {
switch (p_param) {
- case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius;
- case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation;
- case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration;
- case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold;
- case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold;
- case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep;
- case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias;
- case Physics2DServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth;
+ case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius;
+ case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation;
+ case PhysicsServer2D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration;
+ case PhysicsServer2D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold;
+ case PhysicsServer2D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold;
+ case PhysicsServer2D::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep;
+ case PhysicsServer2D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias;
+ case PhysicsServer2D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth;
}
return 0;
}
@@ -1323,7 +1323,7 @@ bool Space2DSW::is_locked() const {
return locked;
}
-Physics2DDirectSpaceStateSW *Space2DSW::get_direct_state() {
+PhysicsDirectSpaceState2DSW *Space2DSW::get_direct_state() {
return direct_access;
}
@@ -1353,7 +1353,7 @@ Space2DSW::Space2DSW() {
broadphase->set_unpair_callback(_broadphase_unpair, this);
area = NULL;
- direct_access = memnew(Physics2DDirectSpaceStateSW);
+ direct_access = memnew(PhysicsDirectSpaceState2DSW);
direct_access->space = this;
for (int i = 0; i < ELAPSED_TIME_MAX; i++)
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index 919c65d849..c6b324c928 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -41,9 +41,9 @@
#include "core/project_settings.h"
#include "core/typedefs.h"
-class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState {
+class PhysicsDirectSpaceState2DSW : public PhysicsDirectSpaceState2D {
- GDCLASS(Physics2DDirectSpaceStateSW, Physics2DDirectSpaceState);
+ GDCLASS(PhysicsDirectSpaceState2DSW, PhysicsDirectSpaceState2D);
int _intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas = false, ObjectID p_canvas_instance_id = ObjectID());
@@ -58,7 +58,7 @@ public:
virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
- Physics2DDirectSpaceStateSW();
+ PhysicsDirectSpaceState2DSW();
};
class Space2DSW {
@@ -83,7 +83,7 @@ private:
uint64_t elapsed_time[ELAPSED_TIME_MAX];
- Physics2DDirectSpaceStateSW *direct_access;
+ PhysicsDirectSpaceState2DSW *direct_access;
RID self;
BroadPhase2DSW *broadphase;
@@ -129,7 +129,7 @@ private:
Vector<Vector2> contact_debug;
int contact_debug_count;
- friend class Physics2DDirectSpaceStateSW;
+ friend class PhysicsDirectSpaceState2DSW;
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
@@ -175,8 +175,8 @@ public:
void lock();
void unlock();
- void set_param(Physics2DServer::SpaceParameter p_param, real_t p_value);
- real_t get_param(Physics2DServer::SpaceParameter p_param) const;
+ void set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value);
+ real_t get_param(PhysicsServer2D::SpaceParameter p_param) const;
void set_island_count(int p_island_count) { island_count = p_island_count; }
int get_island_count() const { return island_count; }
@@ -186,8 +186,8 @@ public:
int get_collision_pairs() const { return collision_pairs; }
- bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, Physics2DServer::MotionResult *r_result, bool p_exclude_raycast_shapes = true);
- int test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, Physics2DServer::SeparationResult *r_results, int p_result_max, real_t p_margin);
+ bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes = true);
+ int test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, PhysicsServer2D::SeparationResult *r_results, int p_result_max, real_t p_margin);
void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); }
_FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.empty(); }
@@ -197,7 +197,7 @@ public:
_FORCE_INLINE_ Vector<Vector2> get_debug_contacts() { return contact_debug; }
_FORCE_INLINE_ int get_debug_contact_count() { return contact_debug_count; }
- Physics2DDirectSpaceStateSW *get_direct_state();
+ PhysicsDirectSpaceState2DSW *get_direct_state();
void set_elapsed_time(ElapsedTime p_time, uint64_t p_msec) { elapsed_time[p_time] = p_msec; }
uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; }
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp
index 21f18229e7..198fccdb80 100644
--- a/servers/physics_2d/step_2d_sw.cpp
+++ b/servers/physics_2d/step_2d_sw.cpp
@@ -50,7 +50,7 @@ void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constrain
if (i == E->get())
continue;
Body2DSW *b = c->get_body_ptr()[i];
- if (b->get_island_step() == _step || b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC)
+ if (b->get_island_step() == _step || b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC)
continue; //no go
_populate_island(c->get_body_ptr()[i], p_island, p_constraint_island);
}
@@ -101,7 +101,7 @@ void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) {
Body2DSW *b = p_island;
while (b) {
- if (b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
}
@@ -117,7 +117,7 @@ void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) {
b = p_island;
while (b) {
- if (b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) {
+ if (b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
}
diff --git a/servers/physics/SCsub b/servers/physics_3d/SCsub
index c5cc889112..c5cc889112 100644
--- a/servers/physics/SCsub
+++ b/servers/physics_3d/SCsub
diff --git a/servers/physics/area_sw.cpp b/servers/physics_3d/area_3d_sw.cpp
index 4b54a56253..911a664a10 100644
--- a/servers/physics/area_sw.cpp
+++ b/servers/physics_3d/area_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* area_sw.cpp */
+/* area_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,30 +28,30 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "area_sw.h"
-#include "body_sw.h"
-#include "space_sw.h"
+#include "area_3d_sw.h"
+#include "body_3d_sw.h"
+#include "space_3d_sw.h"
-AreaSW::BodyKey::BodyKey(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
+Area3DSW::BodyKey::BodyKey(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
rid = p_body->get_self();
instance_id = p_body->get_instance_id();
body_shape = p_body_shape;
area_shape = p_area_shape;
}
-AreaSW::BodyKey::BodyKey(AreaSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
+Area3DSW::BodyKey::BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
rid = p_body->get_self();
instance_id = p_body->get_instance_id();
body_shape = p_body_shape;
area_shape = p_area_shape;
}
-void AreaSW::_shapes_changed() {
+void Area3DSW::_shapes_changed() {
if (!moved_list.in_list() && get_space())
get_space()->area_add_to_moved_list(&moved_list);
}
-void AreaSW::set_transform(const Transform &p_transform) {
+void Area3DSW::set_transform(const Transform &p_transform) {
if (!moved_list.in_list() && get_space())
get_space()->area_add_to_moved_list(&moved_list);
@@ -60,7 +60,7 @@ void AreaSW::set_transform(const Transform &p_transform) {
_set_inv_transform(p_transform.affine_inverse());
}
-void AreaSW::set_space(SpaceSW *p_space) {
+void Area3DSW::set_space(Space3DSW *p_space) {
if (get_space()) {
if (monitor_query_list.in_list())
@@ -75,7 +75,7 @@ void AreaSW::set_space(SpaceSW *p_space) {
_set_space(p_space);
}
-void AreaSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
+void Area3DSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
if (p_id == monitor_callback_id) {
monitor_callback_method = p_method;
@@ -96,7 +96,7 @@ void AreaSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
get_space()->area_add_to_moved_list(&moved_list);
}
-void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method) {
+void Area3DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method) {
if (p_id == area_monitor_callback_id) {
area_monitor_callback_method = p_method;
@@ -117,46 +117,46 @@ void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method
get_space()->area_add_to_moved_list(&moved_list);
}
-void AreaSW::set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode) {
- bool do_override = p_mode != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED;
- if (do_override == (space_override_mode != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED))
+void Area3DSW::set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) {
+ bool do_override = p_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
+ if (do_override == (space_override_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED))
return;
_unregister_shapes();
space_override_mode = p_mode;
_shape_changed();
}
-void AreaSW::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) {
+void Area3DSW::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY: gravity = p_value; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break;
- case PhysicsServer::AREA_PARAM_PRIORITY: priority = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY: gravity = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break;
+ case PhysicsServer3D::AREA_PARAM_PRIORITY: priority = p_value; break;
}
}
-Variant AreaSW::get_param(PhysicsServer::AreaParameter p_param) const {
+Variant Area3DSW::get_param(PhysicsServer3D::AreaParameter p_param) const {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY: return gravity;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP: return linear_damp;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: return angular_damp;
- case PhysicsServer::AREA_PARAM_PRIORITY: return priority;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY: return gravity;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale;
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation;
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: return linear_damp;
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: return angular_damp;
+ case PhysicsServer3D::AREA_PARAM_PRIORITY: return priority;
}
return Variant();
}
-void AreaSW::_queue_monitor_update() {
+void Area3DSW::_queue_monitor_update() {
ERR_FAIL_COND(!get_space());
@@ -164,7 +164,7 @@ void AreaSW::_queue_monitor_update() {
get_space()->area_add_to_monitor_query_list(&monitor_query_list);
}
-void AreaSW::set_monitorable(bool p_monitorable) {
+void Area3DSW::set_monitorable(bool p_monitorable) {
if (monitorable == p_monitorable)
return;
@@ -173,7 +173,7 @@ void AreaSW::set_monitorable(bool p_monitorable) {
_set_static(!monitorable);
}
-void AreaSW::call_queries() {
+void Area3DSW::call_queries() {
if (monitor_callback_id.is_valid() && !monitored_bodies.empty()) {
@@ -194,7 +194,7 @@ void AreaSW::call_queries() {
if (E->get().state == 0)
continue; //nothing happened
- res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
+ res[0] = E->get().state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
res[2] = E->key().instance_id;
res[3] = E->key().body_shape;
@@ -226,7 +226,7 @@ void AreaSW::call_queries() {
if (E->get().state == 0)
continue; //nothing happened
- res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
+ res[0] = E->get().state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
res[2] = E->key().instance_id;
res[3] = E->key().body_shape;
@@ -241,13 +241,13 @@ void AreaSW::call_queries() {
//get_space()->area_remove_from_monitor_query_list(&monitor_query_list);
}
-AreaSW::AreaSW() :
- CollisionObjectSW(TYPE_AREA),
+Area3DSW::Area3DSW() :
+ CollisionObject3DSW(TYPE_AREA),
monitor_query_list(this),
moved_list(this) {
_set_static(true); //areas are never active
- space_override_mode = PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED;
+ space_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
gravity = 9.80665;
gravity_vector = Vector3(0, -1, 0);
gravity_is_point = false;
@@ -260,5 +260,5 @@ AreaSW::AreaSW() :
monitorable = false;
}
-AreaSW::~AreaSW() {
+Area3DSW::~Area3DSW() {
}
diff --git a/servers/physics/area_sw.h b/servers/physics_3d/area_3d_sw.h
index 4da2b00d20..05e74e63dc 100644
--- a/servers/physics/area_sw.h
+++ b/servers/physics_3d/area_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* area_sw.h */
+/* area_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,18 +31,18 @@
#ifndef AREA_SW_H
#define AREA_SW_H
-#include "collision_object_sw.h"
+#include "collision_object_3d_sw.h"
#include "core/self_list.h"
-#include "servers/physics_server.h"
-//#include "servers/physics/query_sw.h"
+#include "servers/physics_server_3d.h"
+//#include "servers/physics_3d/query_sw.h"
-class SpaceSW;
-class BodySW;
-class ConstraintSW;
+class Space3DSW;
+class Body3DSW;
+class Constraint3DSW;
-class AreaSW : public CollisionObjectSW {
+class Area3DSW : public CollisionObject3DSW {
- PhysicsServer::AreaSpaceOverrideMode space_override_mode;
+ PhysicsServer3D::AreaSpaceOverrideMode space_override_mode;
real_t gravity;
Vector3 gravity_vector;
bool gravity_is_point;
@@ -59,8 +59,8 @@ class AreaSW : public CollisionObjectSW {
ObjectID area_monitor_callback_id;
StringName area_monitor_callback_method;
- SelfList<AreaSW> monitor_query_list;
- SelfList<AreaSW> moved_list;
+ SelfList<Area3DSW> monitor_query_list;
+ SelfList<Area3DSW> moved_list;
struct BodyKey {
@@ -83,8 +83,8 @@ class AreaSW : public CollisionObjectSW {
}
_FORCE_INLINE_ BodyKey() {}
- BodyKey(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
- BodyKey(AreaSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
+ BodyKey(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
+ BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
};
struct BodyState {
@@ -101,7 +101,7 @@ class AreaSW : public CollisionObjectSW {
//virtual void shape_changed_notify(ShapeSW *p_shape);
//virtual void shape_deleted_notify(ShapeSW *p_shape);
- Set<ConstraintSW *> constraints;
+ Set<Constraint3DSW *> constraints;
virtual void _shapes_changed();
void _queue_monitor_update();
@@ -116,17 +116,17 @@ public:
void set_area_monitor_callback(ObjectID p_id, const StringName &p_method);
_FORCE_INLINE_ bool has_area_monitor_callback() const { return area_monitor_callback_id.is_valid(); }
- _FORCE_INLINE_ void add_body_to_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
- _FORCE_INLINE_ void remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
+ _FORCE_INLINE_ void add_body_to_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
+ _FORCE_INLINE_ void remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
- _FORCE_INLINE_ void add_area_to_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
- _FORCE_INLINE_ void remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
+ _FORCE_INLINE_ void add_area_to_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
+ _FORCE_INLINE_ void remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape);
- void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer::AreaParameter p_param) const;
+ void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PhysicsServer3D::AreaParameter p_param) const;
- void set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode);
- PhysicsServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
+ void set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode);
+ PhysicsServer3D::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
_FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; }
_FORCE_INLINE_ real_t get_gravity() const { return gravity; }
@@ -152,9 +152,9 @@ public:
_FORCE_INLINE_ void set_priority(int p_priority) { priority = p_priority; }
_FORCE_INLINE_ int get_priority() const { return priority; }
- _FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint) { constraints.insert(p_constraint); }
- _FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraints.erase(p_constraint); }
- _FORCE_INLINE_ const Set<ConstraintSW *> &get_constraints() const { return constraints; }
+ _FORCE_INLINE_ void add_constraint(Constraint3DSW *p_constraint) { constraints.insert(p_constraint); }
+ _FORCE_INLINE_ void remove_constraint(Constraint3DSW *p_constraint) { constraints.erase(p_constraint); }
+ _FORCE_INLINE_ const Set<Constraint3DSW *> &get_constraints() const { return constraints; }
_FORCE_INLINE_ void clear_constraints() { constraints.clear(); }
void set_monitorable(bool p_monitorable);
@@ -162,22 +162,22 @@ public:
void set_transform(const Transform &p_transform);
- void set_space(SpaceSW *p_space);
+ void set_space(Space3DSW *p_space);
void call_queries();
- AreaSW();
- ~AreaSW();
+ Area3DSW();
+ ~Area3DSW();
};
-void AreaSW::add_body_to_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
+void Area3DSW::add_body_to_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].inc();
if (!monitor_query_list.in_list())
_queue_monitor_update();
}
-void AreaSW::remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
+void Area3DSW::remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].dec();
@@ -185,14 +185,14 @@ void AreaSW::remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint3
_queue_monitor_update();
}
-void AreaSW::add_area_to_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
+void Area3DSW::add_area_to_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].inc();
if (!monitor_query_list.in_list())
_queue_monitor_update();
}
-void AreaSW::remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
+void Area3DSW::remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].dec();
diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics_3d/area_pair_3d_sw.cpp
index 966a440930..e92a3a0dd1 100644
--- a/servers/physics/area_pair_sw.cpp
+++ b/servers/physics_3d/area_pair_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* area_pair_sw.cpp */
+/* area_pair_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "area_pair_sw.h"
-#include "collision_solver_sw.h"
+#include "area_pair_3d_sw.h"
+#include "collision_solver_3d_sw.h"
-bool AreaPairSW::setup(real_t p_step) {
+bool AreaPair3DSW::setup(real_t p_step) {
bool result = false;
if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) {
result = false;
- } else if (area->test_collision_mask(body) && CollisionSolverSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), NULL, this)) {
+ } else if (area->test_collision_mask(body) && CollisionSolver3DSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), NULL, this)) {
result = true;
}
@@ -45,14 +45,14 @@ bool AreaPairSW::setup(real_t p_step) {
if (result) {
- if (area->get_space_override_mode() != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)
body->add_area(area);
if (area->has_monitor_callback())
area->add_body_to_query(body, body_shape, area_shape);
} else {
- if (area->get_space_override_mode() != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)
body->remove_area(area);
if (area->has_monitor_callback())
area->remove_body_from_query(body, body_shape, area_shape);
@@ -64,10 +64,10 @@ bool AreaPairSW::setup(real_t p_step) {
return false; //never do any post solving
}
-void AreaPairSW::solve(real_t p_step) {
+void AreaPair3DSW::solve(real_t p_step) {
}
-AreaPairSW::AreaPairSW(BodySW *p_body, int p_body_shape, AreaSW *p_area, int p_area_shape) {
+AreaPair3DSW::AreaPair3DSW(Body3DSW *p_body, int p_body_shape, Area3DSW *p_area, int p_area_shape) {
body = p_body;
area = p_area;
@@ -76,15 +76,15 @@ AreaPairSW::AreaPairSW(BodySW *p_body, int p_body_shape, AreaSW *p_area, int p_a
colliding = false;
body->add_constraint(this, 0);
area->add_constraint(this);
- if (p_body->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC)
+ if (p_body->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC)
p_body->set_active(true);
}
-AreaPairSW::~AreaPairSW() {
+AreaPair3DSW::~AreaPair3DSW() {
if (colliding) {
- if (area->get_space_override_mode() != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)
body->remove_area(area);
if (area->has_monitor_callback())
area->remove_body_from_query(body, body_shape, area_shape);
@@ -95,12 +95,12 @@ AreaPairSW::~AreaPairSW() {
////////////////////////////////////////////////////
-bool Area2PairSW::setup(real_t p_step) {
+bool Area2Pair3DSW::setup(real_t p_step) {
bool result = false;
if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) {
result = false;
- } else if (area_a->test_collision_mask(area_b) && CollisionSolverSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), NULL, this)) {
+ } else if (area_a->test_collision_mask(area_b) && CollisionSolver3DSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), NULL, this)) {
result = true;
}
@@ -129,10 +129,10 @@ bool Area2PairSW::setup(real_t p_step) {
return false; //never do any post solving
}
-void Area2PairSW::solve(real_t p_step) {
+void Area2Pair3DSW::solve(real_t p_step) {
}
-Area2PairSW::Area2PairSW(AreaSW *p_area_a, int p_shape_a, AreaSW *p_area_b, int p_shape_b) {
+Area2Pair3DSW::Area2Pair3DSW(Area3DSW *p_area_a, int p_shape_a, Area3DSW *p_area_b, int p_shape_b) {
area_a = p_area_a;
area_b = p_area_b;
@@ -143,7 +143,7 @@ Area2PairSW::Area2PairSW(AreaSW *p_area_a, int p_shape_a, AreaSW *p_area_b, int
area_b->add_constraint(this);
}
-Area2PairSW::~Area2PairSW() {
+Area2Pair3DSW::~Area2Pair3DSW() {
if (colliding) {
diff --git a/servers/physics/area_pair_sw.h b/servers/physics_3d/area_pair_3d_sw.h
index 97a37ebf90..3490f41c26 100644
--- a/servers/physics/area_pair_sw.h
+++ b/servers/physics_3d/area_pair_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* area_pair_sw.h */
+/* area_pair_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,14 +31,14 @@
#ifndef AREA_PAIR_SW_H
#define AREA_PAIR_SW_H
-#include "area_sw.h"
-#include "body_sw.h"
-#include "constraint_sw.h"
+#include "area_3d_sw.h"
+#include "body_3d_sw.h"
+#include "constraint_3d_sw.h"
-class AreaPairSW : public ConstraintSW {
+class AreaPair3DSW : public Constraint3DSW {
- BodySW *body;
- AreaSW *area;
+ Body3DSW *body;
+ Area3DSW *area;
int body_shape;
int area_shape;
bool colliding;
@@ -47,14 +47,14 @@ public:
bool setup(real_t p_step);
void solve(real_t p_step);
- AreaPairSW(BodySW *p_body, int p_body_shape, AreaSW *p_area, int p_area_shape);
- ~AreaPairSW();
+ AreaPair3DSW(Body3DSW *p_body, int p_body_shape, Area3DSW *p_area, int p_area_shape);
+ ~AreaPair3DSW();
};
-class Area2PairSW : public ConstraintSW {
+class Area2Pair3DSW : public Constraint3DSW {
- AreaSW *area_a;
- AreaSW *area_b;
+ Area3DSW *area_a;
+ Area3DSW *area_b;
int shape_a;
int shape_b;
bool colliding;
@@ -63,8 +63,8 @@ public:
bool setup(real_t p_step);
void solve(real_t p_step);
- Area2PairSW(AreaSW *p_area_a, int p_shape_a, AreaSW *p_area_b, int p_shape_b);
- ~Area2PairSW();
+ Area2Pair3DSW(Area3DSW *p_area_a, int p_shape_a, Area3DSW *p_area_b, int p_shape_b);
+ ~Area2Pair3DSW();
};
#endif // AREA_PAIR__SW_H
diff --git a/servers/physics/body_sw.cpp b/servers/physics_3d/body_3d_sw.cpp
index 8819941f04..6a00e4f471 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics_3d/body_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* body_sw.cpp */
+/* body_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "body_sw.h"
-#include "area_sw.h"
-#include "space_sw.h"
+#include "body_3d_sw.h"
+#include "area_3d_sw.h"
+#include "space_3d_sw.h"
-void BodySW::_update_inertia() {
+void Body3DSW::_update_inertia() {
if (get_space() && !inertia_update_list.in_list())
get_space()->body_add_to_inertia_update_list(&inertia_update_list);
}
-void BodySW::_update_transform_dependant() {
+void Body3DSW::_update_transform_dependant() {
center_of_mass = get_transform().basis.xform(center_of_mass_local);
principal_inertia_axes = get_transform().basis * principal_inertia_axes_local;
@@ -51,13 +51,13 @@ void BodySW::_update_transform_dependant() {
_inv_inertia_tensor = tb * diag * tbt;
}
-void BodySW::update_inertias() {
+void Body3DSW::update_inertias() {
//update shapes and motions
switch (mode) {
- case PhysicsServer::BODY_MODE_RIGID: {
+ case PhysicsServer3D::BODY_MODE_RIGID: {
//update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet)
real_t total_area = 0;
@@ -91,7 +91,7 @@ void BodySW::update_inertias() {
continue;
}
- const ShapeSW *shape = get_shape(i);
+ const Shape3DSW *shape = get_shape(i);
real_t area = get_shape_area(i);
@@ -119,13 +119,13 @@ void BodySW::update_inertias() {
} break;
- case PhysicsServer::BODY_MODE_KINEMATIC:
- case PhysicsServer::BODY_MODE_STATIC: {
+ case PhysicsServer3D::BODY_MODE_KINEMATIC:
+ case PhysicsServer3D::BODY_MODE_STATIC: {
_inv_inertia_tensor.set_zero();
_inv_mass = 0;
} break;
- case PhysicsServer::BODY_MODE_CHARACTER: {
+ case PhysicsServer3D::BODY_MODE_CHARACTER: {
_inv_inertia_tensor.set_zero();
_inv_mass = 1.0 / mass;
@@ -138,7 +138,7 @@ void BodySW::update_inertias() {
_update_transform_dependant();
}
-void BodySW::set_active(bool p_active) {
+void Body3DSW::set_active(bool p_active) {
if (active == p_active)
return;
@@ -148,7 +148,7 @@ void BodySW::set_active(bool p_active) {
if (get_space())
get_space()->body_remove_from_active_list(&active_list);
} else {
- if (mode == PhysicsServer::BODY_MODE_STATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC)
return; //static bodies can't become active
if (get_space())
get_space()->body_add_to_active_list(&active_list);
@@ -168,31 +168,31 @@ void BodySW::set_active(bool p_active) {
*/
}
-void BodySW::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) {
+void Body3DSW::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::BODY_PARAM_BOUNCE: {
+ case PhysicsServer3D::BODY_PARAM_BOUNCE: {
bounce = p_value;
} break;
- case PhysicsServer::BODY_PARAM_FRICTION: {
+ case PhysicsServer3D::BODY_PARAM_FRICTION: {
friction = p_value;
} break;
- case PhysicsServer::BODY_PARAM_MASS: {
+ case PhysicsServer3D::BODY_PARAM_MASS: {
ERR_FAIL_COND(p_value <= 0);
mass = p_value;
_update_inertia();
} break;
- case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: {
+ case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
gravity_scale = p_value;
} break;
- case PhysicsServer::BODY_PARAM_LINEAR_DAMP: {
+ case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
linear_damp = p_value;
} break;
- case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: {
+ case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
angular_damp = p_value;
} break;
@@ -201,28 +201,28 @@ void BodySW::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) {
}
}
-real_t BodySW::get_param(PhysicsServer::BodyParameter p_param) const {
+real_t Body3DSW::get_param(PhysicsServer3D::BodyParameter p_param) const {
switch (p_param) {
- case PhysicsServer::BODY_PARAM_BOUNCE: {
+ case PhysicsServer3D::BODY_PARAM_BOUNCE: {
return bounce;
} break;
- case PhysicsServer::BODY_PARAM_FRICTION: {
+ case PhysicsServer3D::BODY_PARAM_FRICTION: {
return friction;
} break;
- case PhysicsServer::BODY_PARAM_MASS: {
+ case PhysicsServer3D::BODY_PARAM_MASS: {
return mass;
} break;
- case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: {
+ case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
} break;
- case PhysicsServer::BODY_PARAM_LINEAR_DAMP: {
+ case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
return linear_damp;
} break;
- case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: {
+ case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
return angular_damp;
} break;
@@ -234,36 +234,36 @@ real_t BodySW::get_param(PhysicsServer::BodyParameter p_param) const {
return 0;
}
-void BodySW::set_mode(PhysicsServer::BodyMode p_mode) {
+void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
- PhysicsServer::BodyMode prev = mode;
+ PhysicsServer3D::BodyMode prev = mode;
mode = p_mode;
switch (p_mode) {
//CLEAR UP EVERYTHING IN CASE IT NOT WORKS!
- case PhysicsServer::BODY_MODE_STATIC:
- case PhysicsServer::BODY_MODE_KINEMATIC: {
+ case PhysicsServer3D::BODY_MODE_STATIC:
+ case PhysicsServer3D::BODY_MODE_KINEMATIC: {
_set_inv_transform(get_transform().affine_inverse());
_inv_mass = 0;
- _set_static(p_mode == PhysicsServer::BODY_MODE_STATIC);
- //set_active(p_mode==PhysicsServer::BODY_MODE_KINEMATIC);
- set_active(p_mode == PhysicsServer::BODY_MODE_KINEMATIC && contacts.size());
+ _set_static(p_mode == PhysicsServer3D::BODY_MODE_STATIC);
+ //set_active(p_mode==PhysicsServer3D::BODY_MODE_KINEMATIC);
+ set_active(p_mode == PhysicsServer3D::BODY_MODE_KINEMATIC && contacts.size());
linear_velocity = Vector3();
angular_velocity = Vector3();
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC && prev != mode) {
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && prev != mode) {
first_time_kinematic = true;
}
} break;
- case PhysicsServer::BODY_MODE_RIGID: {
+ case PhysicsServer3D::BODY_MODE_RIGID: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_set_static(false);
set_active(true);
} break;
- case PhysicsServer::BODY_MODE_CHARACTER: {
+ case PhysicsServer3D::BODY_MODE_CHARACTER: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_set_static(false);
@@ -278,22 +278,22 @@ void BodySW::set_mode(PhysicsServer::BodyMode p_mode) {
_update_queries();
*/
}
-PhysicsServer::BodyMode BodySW::get_mode() const {
+PhysicsServer3D::BodyMode Body3DSW::get_mode() const {
return mode;
}
-void BodySW::_shapes_changed() {
+void Body3DSW::_shapes_changed() {
_update_inertia();
}
-void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) {
+void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case PhysicsServer::BODY_STATE_TRANSFORM: {
+ case PhysicsServer3D::BODY_STATE_TRANSFORM: {
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
new_transform = p_variant;
//wakeup_neighbours();
set_active(true);
@@ -303,7 +303,7 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian
first_time_kinematic = false;
}
- } else if (mode == PhysicsServer::BODY_MODE_STATIC) {
+ } else if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
_set_transform(p_variant);
_set_inv_transform(get_transform().affine_inverse());
wakeup_neighbours();
@@ -319,27 +319,27 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian
wakeup();
} break;
- case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: {
+ case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
/*
- if (mode==PhysicsServer::BODY_MODE_STATIC)
+ if (mode==PhysicsServer3D::BODY_MODE_STATIC)
break;
*/
linear_velocity = p_variant;
wakeup();
} break;
- case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: {
+ case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
/*
- if (mode!=PhysicsServer::BODY_MODE_RIGID)
+ if (mode!=PhysicsServer3D::BODY_MODE_RIGID)
break;
*/
angular_velocity = p_variant;
wakeup();
} break;
- case PhysicsServer::BODY_STATE_SLEEPING: {
+ case PhysicsServer3D::BODY_STATE_SLEEPING: {
//?
- if (mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC)
break;
bool do_sleep = p_variant;
if (do_sleep) {
@@ -352,30 +352,30 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian
set_active(true);
}
} break;
- case PhysicsServer::BODY_STATE_CAN_SLEEP: {
+ case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant;
- if (mode == PhysicsServer::BODY_MODE_RIGID && !active && !can_sleep)
+ if (mode == PhysicsServer3D::BODY_MODE_RIGID && !active && !can_sleep)
set_active(true);
} break;
}
}
-Variant BodySW::get_state(PhysicsServer::BodyState p_state) const {
+Variant Body3DSW::get_state(PhysicsServer3D::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer::BODY_STATE_TRANSFORM: {
+ case PhysicsServer3D::BODY_STATE_TRANSFORM: {
return get_transform();
} break;
- case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: {
+ case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
return linear_velocity;
} break;
- case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: {
+ case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: {
return angular_velocity;
} break;
- case PhysicsServer::BODY_STATE_SLEEPING: {
+ case PhysicsServer3D::BODY_STATE_SLEEPING: {
return !is_active();
} break;
- case PhysicsServer::BODY_STATE_CAN_SLEEP: {
+ case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
return can_sleep;
} break;
}
@@ -383,7 +383,7 @@ Variant BodySW::get_state(PhysicsServer::BodyState p_state) const {
return Variant();
}
-void BodySW::set_space(SpaceSW *p_space) {
+void Body3DSW::set_space(Space3DSW *p_space) {
if (get_space()) {
@@ -414,7 +414,7 @@ void BodySW::set_space(SpaceSW *p_space) {
first_integration = true;
}
-void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) {
+void Body3DSW::_compute_area_gravity_and_dampenings(const Area3DSW *p_area) {
if (p_area->is_gravity_point()) {
if (p_area->get_gravity_distance_scale() > 0) {
@@ -431,7 +431,7 @@ void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) {
area_angular_damp += p_area->get_angular_damp();
}
-void BodySW::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
+void Body3DSW::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) {
if (lock) {
locked_axis |= p_axis;
} else {
@@ -439,16 +439,16 @@ void BodySW::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
}
}
-bool BodySW::is_axis_locked(PhysicsServer::BodyAxis p_axis) const {
+bool Body3DSW::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
return locked_axis & p_axis;
}
-void BodySW::integrate_forces(real_t p_step) {
+void Body3DSW::integrate_forces(real_t p_step) {
- if (mode == PhysicsServer::BODY_MODE_STATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC)
return;
- AreaSW *def_area = get_space()->get_default_area();
+ Area3DSW *def_area = get_space()->get_default_area();
// AreaSW *damp_area = def_area;
ERR_FAIL_COND(!def_area);
@@ -463,20 +463,20 @@ void BodySW::integrate_forces(real_t p_step) {
const AreaCMP *aa = &areas[0];
// damp_area = aa[ac-1].area;
for (int i = ac - 1; i >= 0 && !stopped; i--) {
- PhysicsServer::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode();
+ PhysicsServer3D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode();
switch (mode) {
- case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE:
- case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
_compute_area_gravity_and_dampenings(aa[i].area);
- stopped = mode == PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
+ stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
- case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE:
- case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
gravity = Vector3(0, 0, 0);
area_angular_damp = 0;
area_linear_damp = 0;
_compute_area_gravity_and_dampenings(aa[i].area);
- stopped = mode == PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE;
+ stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
@@ -508,7 +508,7 @@ void BodySW::integrate_forces(real_t p_step) {
Vector3 motion;
bool do_motion = false;
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
//compute motion, angular and etc. velocities from prev transform
linear_velocity = (new_transform.origin - get_transform().origin) / p_step;
@@ -573,9 +573,9 @@ void BodySW::integrate_forces(real_t p_step) {
contact_count = 0;
}
-void BodySW::integrate_velocities(real_t p_step) {
+void Body3DSW::integrate_velocities(real_t p_step) {
- if (mode == PhysicsServer::BODY_MODE_STATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC)
return;
if (fi_callback)
@@ -583,7 +583,7 @@ void BodySW::integrate_velocities(real_t p_step) {
//apply axis lock linear
for (int i = 0; i < 3; i++) {
- if (is_axis_locked((PhysicsServer::BodyAxis)(1 << i))) {
+ if (is_axis_locked((PhysicsServer3D::BodyAxis)(1 << i))) {
linear_velocity[i] = 0;
biased_linear_velocity[i] = 0;
new_transform.origin[i] = get_transform().origin[i];
@@ -591,13 +591,13 @@ void BodySW::integrate_velocities(real_t p_step) {
}
//apply axis lock angular
for (int i = 0; i < 3; i++) {
- if (is_axis_locked((PhysicsServer::BodyAxis)(1 << (i + 3)))) {
+ if (is_axis_locked((PhysicsServer3D::BodyAxis)(1 << (i + 3)))) {
angular_velocity[i] = 0;
biased_angular_velocity[i] = 0;
}
}
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
@@ -675,20 +675,20 @@ void BodySW::simulate_motion(const Transform& p_xform,real_t p_step) {
}
*/
-void BodySW::wakeup_neighbours() {
+void Body3DSW::wakeup_neighbours() {
- for (Map<ConstraintSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) {
+ for (Map<Constraint3DSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) {
- const ConstraintSW *c = E->key();
- BodySW **n = c->get_body_ptr();
+ const Constraint3DSW *c = E->key();
+ Body3DSW **n = c->get_body_ptr();
int bc = c->get_body_count();
for (int i = 0; i < bc; i++) {
if (i == E->get())
continue;
- BodySW *b = n[i];
- if (b->mode != PhysicsServer::BODY_MODE_RIGID)
+ Body3DSW *b = n[i];
+ if (b->mode != PhysicsServer3D::BODY_MODE_RIGID)
continue;
if (!b->is_active())
@@ -697,11 +697,11 @@ void BodySW::wakeup_neighbours() {
}
}
-void BodySW::call_queries() {
+void Body3DSW::call_queries() {
if (fi_callback) {
- PhysicsDirectBodyStateSW *dbs = PhysicsDirectBodyStateSW::singleton;
+ PhysicsDirectBodyState3DSW *dbs = PhysicsDirectBodyState3DSW::singleton;
dbs->body = this;
Variant v = dbs;
@@ -720,11 +720,11 @@ void BodySW::call_queries() {
}
}
-bool BodySW::sleep_test(real_t p_step) {
+bool Body3DSW::sleep_test(real_t p_step) {
- if (mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC)
return true; //
- else if (mode == PhysicsServer::BODY_MODE_CHARACTER)
+ else if (mode == PhysicsServer3D::BODY_MODE_CHARACTER)
return !active; // characters don't sleep unless asked to sleep
else if (!can_sleep)
return false;
@@ -741,7 +741,7 @@ bool BodySW::sleep_test(real_t p_step) {
}
}
-void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
+void Body3DSW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
if (fi_callback) {
@@ -758,18 +758,18 @@ void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_m
}
}
-void BodySW::set_kinematic_margin(real_t p_margin) {
+void Body3DSW::set_kinematic_margin(real_t p_margin) {
kinematic_safe_margin = p_margin;
}
-BodySW::BodySW() :
- CollisionObjectSW(TYPE_BODY),
+Body3DSW::Body3DSW() :
+ CollisionObject3DSW(TYPE_BODY),
locked_axis(0),
active_list(this),
inertia_update_list(this),
direct_state_query_list(this) {
- mode = PhysicsServer::BODY_MODE_RIGID;
+ mode = PhysicsServer3D::BODY_MODE_RIGID;
active = true;
mass = 1;
@@ -800,15 +800,15 @@ BodySW::BodySW() :
fi_callback = NULL;
}
-BodySW::~BodySW() {
+Body3DSW::~Body3DSW() {
if (fi_callback)
memdelete(fi_callback);
}
-PhysicsDirectBodyStateSW *PhysicsDirectBodyStateSW::singleton = NULL;
+PhysicsDirectBodyState3DSW *PhysicsDirectBodyState3DSW::singleton = NULL;
-PhysicsDirectSpaceState *PhysicsDirectBodyStateSW::get_space_state() {
+PhysicsDirectSpaceState3D *PhysicsDirectBodyState3DSW::get_space_state() {
return body->get_space()->get_direct_state();
}
diff --git a/servers/physics/body_sw.h b/servers/physics_3d/body_3d_sw.h
index d712b09878..368dd59b06 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics_3d/body_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* body_sw.h */
+/* body_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,15 +31,15 @@
#ifndef BODY_SW_H
#define BODY_SW_H
-#include "area_sw.h"
-#include "collision_object_sw.h"
+#include "area_3d_sw.h"
+#include "collision_object_3d_sw.h"
#include "core/vset.h"
-class ConstraintSW;
+class Constraint3DSW;
-class BodySW : public CollisionObjectSW {
+class Body3DSW : public CollisionObject3DSW {
- PhysicsServer::BodyMode mode;
+ PhysicsServer3D::BodyMode mode;
Vector3 linear_velocity;
Vector3 angular_velocity;
@@ -79,9 +79,9 @@ class BodySW : public CollisionObjectSW {
real_t area_angular_damp;
real_t area_linear_damp;
- SelfList<BodySW> active_list;
- SelfList<BodySW> inertia_update_list;
- SelfList<BodySW> direct_state_query_list;
+ SelfList<Body3DSW> active_list;
+ SelfList<Body3DSW> inertia_update_list;
+ SelfList<Body3DSW> direct_state_query_list;
VSet<RID> exceptions;
bool omit_force_integration;
@@ -96,16 +96,16 @@ class BodySW : public CollisionObjectSW {
virtual void _shapes_changed();
Transform new_transform;
- Map<ConstraintSW *, int> constraint_map;
+ Map<Constraint3DSW *, int> constraint_map;
struct AreaCMP {
- AreaSW *area;
+ Area3DSW *area;
int refCount;
_FORCE_INLINE_ bool operator==(const AreaCMP &p_cmp) const { return area->get_self() == p_cmp.area->get_self(); }
_FORCE_INLINE_ bool operator<(const AreaCMP &p_cmp) const { return area->get_priority() < p_cmp.area->get_priority(); }
_FORCE_INLINE_ AreaCMP() {}
- _FORCE_INLINE_ AreaCMP(AreaSW *p_area) {
+ _FORCE_INLINE_ AreaCMP(Area3DSW *p_area) {
area = p_area;
refCount = 1;
}
@@ -139,14 +139,14 @@ class BodySW : public CollisionObjectSW {
ForceIntegrationCallback *fi_callback;
uint64_t island_step;
- BodySW *island_next;
- BodySW *island_list_next;
+ Body3DSW *island_next;
+ Body3DSW *island_list_next;
- _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const AreaSW *p_area);
+ _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const Area3DSW *p_area);
_FORCE_INLINE_ void _update_transform_dependant();
- friend class PhysicsDirectBodyStateSW; // i give up, too many functions to expose
+ friend class PhysicsDirectBodyState3DSW; // i give up, too many functions to expose
public:
void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant());
@@ -154,7 +154,7 @@ public:
void set_kinematic_margin(real_t p_margin);
_FORCE_INLINE_ real_t get_kinematic_margin() { return kinematic_safe_margin; }
- _FORCE_INLINE_ void add_area(AreaSW *p_area) {
+ _FORCE_INLINE_ void add_area(Area3DSW *p_area) {
int index = areas.find(AreaCMP(p_area));
if (index > -1) {
areas.write[index].refCount += 1;
@@ -163,7 +163,7 @@ public:
}
}
- _FORCE_INLINE_ void remove_area(AreaSW *p_area) {
+ _FORCE_INLINE_ void remove_area(Area3DSW *p_area) {
int index = areas.find(AreaCMP(p_area));
if (index > -1) {
areas.write[index].refCount -= 1;
@@ -175,7 +175,7 @@ public:
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
contacts.resize(p_size);
contact_count = 0;
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true);
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && p_size) set_active(true);
}
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
@@ -190,15 +190,15 @@ public:
_FORCE_INLINE_ uint64_t get_island_step() const { return island_step; }
_FORCE_INLINE_ void set_island_step(uint64_t p_step) { island_step = p_step; }
- _FORCE_INLINE_ BodySW *get_island_next() const { return island_next; }
- _FORCE_INLINE_ void set_island_next(BodySW *p_next) { island_next = p_next; }
+ _FORCE_INLINE_ Body3DSW *get_island_next() const { return island_next; }
+ _FORCE_INLINE_ void set_island_next(Body3DSW *p_next) { island_next = p_next; }
- _FORCE_INLINE_ BodySW *get_island_list_next() const { return island_list_next; }
- _FORCE_INLINE_ void set_island_list_next(BodySW *p_next) { island_list_next = p_next; }
+ _FORCE_INLINE_ Body3DSW *get_island_list_next() const { return island_list_next; }
+ _FORCE_INLINE_ void set_island_list_next(Body3DSW *p_next) { island_list_next = p_next; }
- _FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; }
- _FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraint_map.erase(p_constraint); }
- const Map<ConstraintSW *, int> &get_constraint_map() const { return constraint_map; }
+ _FORCE_INLINE_ void add_constraint(Constraint3DSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; }
+ _FORCE_INLINE_ void remove_constraint(Constraint3DSW *p_constraint) { constraint_map.erase(p_constraint); }
+ const Map<Constraint3DSW *, int> &get_constraint_map() const { return constraint_map; }
_FORCE_INLINE_ void clear_constraint_map() { constraint_map.clear(); }
_FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration = p_omit_force_integration; }
@@ -268,19 +268,19 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC)
+ if ((!get_space()) || mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC)
return;
set_active(true);
}
- void set_param(PhysicsServer::BodyParameter p_param, real_t);
- real_t get_param(PhysicsServer::BodyParameter p_param) const;
+ void set_param(PhysicsServer3D::BodyParameter p_param, real_t);
+ real_t get_param(PhysicsServer3D::BodyParameter p_param) const;
- void set_mode(PhysicsServer::BodyMode p_mode);
- PhysicsServer::BodyMode get_mode() const;
+ void set_mode(PhysicsServer3D::BodyMode p_mode);
+ PhysicsServer3D::BodyMode get_mode() const;
- void set_state(PhysicsServer::BodyState p_state, const Variant &p_variant);
- Variant get_state(PhysicsServer::BodyState p_state) const;
+ void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PhysicsServer3D::BodyState p_state) const;
void set_applied_force(const Vector3 &p_force) { applied_force = p_force; }
Vector3 get_applied_force() const { return applied_force; }
@@ -291,7 +291,7 @@ public:
_FORCE_INLINE_ void set_continuous_collision_detection(bool p_enable) { continuous_cd = p_enable; }
_FORCE_INLINE_ bool is_continuous_collision_detection_enabled() const { return continuous_cd; }
- void set_space(SpaceSW *p_space);
+ void set_space(Space3DSW *p_space);
void update_inertias();
@@ -302,8 +302,8 @@ public:
_FORCE_INLINE_ Vector3 get_gravity() const { return gravity; }
_FORCE_INLINE_ real_t get_bounce() const { return bounce; }
- void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock);
- bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const;
+ void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock);
+ bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const;
void integrate_forces(real_t p_step);
void integrate_velocities(real_t p_step);
@@ -335,13 +335,13 @@ public:
bool sleep_test(real_t p_step);
- BodySW();
- ~BodySW();
+ Body3DSW();
+ ~Body3DSW();
};
//add contact inline
-void BodySW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos) {
+void Body3DSW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos) {
int c_max = contacts.size();
@@ -385,13 +385,13 @@ void BodySW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_norm
c[idx].collider_velocity_at_pos = p_collider_velocity_at_pos;
}
-class PhysicsDirectBodyStateSW : public PhysicsDirectBodyState {
+class PhysicsDirectBodyState3DSW : public PhysicsDirectBodyState3D {
- GDCLASS(PhysicsDirectBodyStateSW, PhysicsDirectBodyState);
+ GDCLASS(PhysicsDirectBodyState3DSW, PhysicsDirectBodyState3D);
public:
- static PhysicsDirectBodyStateSW *singleton;
- BodySW *body;
+ static PhysicsDirectBodyState3DSW *singleton;
+ Body3DSW *body;
real_t step;
virtual Vector3 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area
@@ -411,7 +411,7 @@ public:
virtual void set_angular_velocity(const Vector3 &p_velocity) { body->set_angular_velocity(p_velocity); }
virtual Vector3 get_angular_velocity() const { return body->get_angular_velocity(); }
- virtual void set_transform(const Transform &p_transform) { body->set_state(PhysicsServer::BODY_STATE_TRANSFORM, p_transform); }
+ virtual void set_transform(const Transform &p_transform) { body->set_state(PhysicsServer3D::BODY_STATE_TRANSFORM, p_transform); }
virtual Transform get_transform() const { return body->get_transform(); }
virtual void add_central_force(const Vector3 &p_force) { body->add_central_force(p_force); }
@@ -463,10 +463,10 @@ public:
return body->contacts[p_contact_idx].collider_velocity_at_pos;
}
- virtual PhysicsDirectSpaceState *get_space_state();
+ virtual PhysicsDirectSpaceState3D *get_space_state();
virtual real_t get_step() const { return step; }
- PhysicsDirectBodyStateSW() {
+ PhysicsDirectBodyState3DSW() {
singleton = this;
body = NULL;
}
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics_3d/body_pair_3d_sw.cpp
index 31fc1b07d9..245fb3449c 100644
--- a/servers/physics/body_pair_sw.cpp
+++ b/servers/physics_3d/body_pair_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* body_pair_sw.cpp */
+/* body_pair_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "body_pair_sw.h"
+#include "body_pair_3d_sw.h"
-#include "collision_solver_sw.h"
+#include "collision_solver_3d_sw.h"
#include "core/os/os.h"
-#include "space_sw.h"
+#include "space_3d_sw.h"
/*
#define NO_ACCUMULATE_IMPULSES
@@ -49,13 +49,13 @@
#define MIN_VELOCITY 0.0001
#define MAX_BIAS_ROTATION (Math_PI / 8)
-void BodyPairSW::_contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
+void BodyPair3DSW::_contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
- BodyPairSW *pair = (BodyPairSW *)p_userdata;
+ BodyPair3DSW *pair = (BodyPair3DSW *)p_userdata;
pair->contact_added_callback(p_point_A, p_point_B);
}
-void BodyPairSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B) {
+void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B) {
// check if we already have the contact
@@ -141,7 +141,7 @@ void BodyPairSW::contact_added_callback(const Vector3 &p_point_A, const Vector3
}
}
-void BodyPairSW::validate_contacts() {
+void BodyPair3DSW::validate_contacts() {
//make sure to erase contacts that are no longer valid
@@ -169,7 +169,7 @@ void BodyPairSW::validate_contacts() {
}
}
-bool BodyPairSW::_test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Transform &p_xform_A, BodySW *p_B, int p_shape_B, const Transform &p_xform_B) {
+bool BodyPair3DSW::_test_ccd(real_t p_step, Body3DSW *p_A, int p_shape_A, const Transform &p_xform_A, Body3DSW *p_B, int p_shape_B, const Transform &p_xform_B) {
Vector3 motion = p_A->get_linear_velocity() * p_step;
real_t mlen = motion.length();
@@ -211,18 +211,18 @@ bool BodyPairSW::_test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Tran
return true;
}
-real_t combine_bounce(BodySW *A, BodySW *B) {
+real_t combine_bounce(Body3DSW *A, Body3DSW *B) {
return CLAMP(A->get_bounce() + B->get_bounce(), 0, 1);
}
-real_t combine_friction(BodySW *A, BodySW *B) {
+real_t combine_friction(Body3DSW *A, Body3DSW *B) {
return ABS(MIN(A->get_friction(), B->get_friction()));
}
-bool BodyPairSW::setup(real_t p_step) {
+bool BodyPair3DSW::setup(real_t p_step) {
//cannot collide
- if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) {
+ if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) {
collided = false;
return false;
}
@@ -244,21 +244,21 @@ bool BodyPairSW::setup(real_t p_step) {
xform_Bu.origin -= offset_A;
Transform xform_B = xform_Bu * B->get_shape_transform(shape_B);
- ShapeSW *shape_A_ptr = A->get_shape(shape_A);
- ShapeSW *shape_B_ptr = B->get_shape(shape_B);
+ Shape3DSW *shape_A_ptr = A->get_shape(shape_A);
+ Shape3DSW *shape_B_ptr = B->get_shape(shape_B);
- bool collided = CollisionSolverSW::solve_static(shape_A_ptr, xform_A, shape_B_ptr, xform_B, _contact_added_callback, this, &sep_axis);
+ bool collided = CollisionSolver3DSW::solve_static(shape_A_ptr, xform_A, shape_B_ptr, xform_B, _contact_added_callback, this, &sep_axis);
this->collided = collided;
if (!collided) {
//test ccd (currently just a raycast)
- if (A->is_continuous_collision_detection_enabled() && A->get_mode() > PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (A->is_continuous_collision_detection_enabled() && A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC) {
_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B);
}
- if (B->is_continuous_collision_detection_enabled() && B->get_mode() > PhysicsServer::BODY_MODE_KINEMATIC && A->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (B->is_continuous_collision_detection_enabled() && B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC && A->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC) {
_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A);
}
@@ -353,7 +353,7 @@ bool BodyPairSW::setup(real_t p_step) {
return true;
}
-void BodyPairSW::solve(real_t p_step) {
+void BodyPair3DSW::solve(real_t p_step) {
if (!collided)
return;
@@ -474,8 +474,8 @@ void BodyPairSW::solve(real_t p_step) {
}
}
-BodyPairSW::BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B) :
- ConstraintSW(_arr, 2) {
+BodyPair3DSW::BodyPair3DSW(Body3DSW *p_A, int p_shape_A, Body3DSW *p_B, int p_shape_B) :
+ Constraint3DSW(_arr, 2) {
A = p_A;
B = p_B;
@@ -488,7 +488,7 @@ BodyPairSW::BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B) :
collided = false;
}
-BodyPairSW::~BodyPairSW() {
+BodyPair3DSW::~BodyPair3DSW() {
A->remove_constraint(this);
B->remove_constraint(this);
diff --git a/servers/physics/body_pair_sw.h b/servers/physics_3d/body_pair_3d_sw.h
index 235aab23b5..7f4afb9dca 100644
--- a/servers/physics/body_pair_sw.h
+++ b/servers/physics_3d/body_pair_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* body_pair_sw.h */
+/* body_pair_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,10 +31,10 @@
#ifndef BODY_PAIR_SW_H
#define BODY_PAIR_SW_H
-#include "body_sw.h"
-#include "constraint_sw.h"
+#include "body_3d_sw.h"
+#include "constraint_3d_sw.h"
-class BodyPairSW : public ConstraintSW {
+class BodyPair3DSW : public Constraint3DSW {
enum {
MAX_CONTACTS = 4
@@ -42,11 +42,11 @@ class BodyPairSW : public ConstraintSW {
union {
struct {
- BodySW *A;
- BodySW *B;
+ Body3DSW *A;
+ Body3DSW *B;
};
- BodySW *_arr[2];
+ Body3DSW *_arr[2];
};
int shape_A;
@@ -82,16 +82,16 @@ class BodyPairSW : public ConstraintSW {
void contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B);
void validate_contacts();
- bool _test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Transform &p_xform_A, BodySW *p_B, int p_shape_B, const Transform &p_xform_B);
+ bool _test_ccd(real_t p_step, Body3DSW *p_A, int p_shape_A, const Transform &p_xform_A, Body3DSW *p_B, int p_shape_B, const Transform &p_xform_B);
- SpaceSW *space;
+ Space3DSW *space;
public:
bool setup(real_t p_step);
void solve(real_t p_step);
- BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B);
- ~BodyPairSW();
+ BodyPair3DSW(Body3DSW *p_A, int p_shape_A, Body3DSW *p_B, int p_shape_B);
+ ~BodyPair3DSW();
};
#endif // BODY_PAIR__SW_H
diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics_3d/broad_phase_3d_basic.cpp
index f49bf9d4cc..bea87a45ca 100644
--- a/servers/physics/broad_phase_basic.cpp
+++ b/servers/physics_3d/broad_phase_3d_basic.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* broad_phase_basic.cpp */
+/* broad_phase_3d_basic.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "broad_phase_basic.h"
+#include "broad_phase_3d_basic.h"
#include "core/list.h"
#include "core/print_string.h"
-BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) {
+BroadPhase3DSW::ID BroadPhase3DBasic::create(CollisionObject3DSW *p_object, int p_subindex) {
ERR_FAIL_COND_V(p_object == NULL, 0);
@@ -47,19 +47,19 @@ BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subi
return current;
}
-void BroadPhaseBasic::move(ID p_id, const AABB &p_aabb) {
+void BroadPhase3DBasic::move(ID p_id, const AABB &p_aabb) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get().aabb = p_aabb;
}
-void BroadPhaseBasic::set_static(ID p_id, bool p_static) {
+void BroadPhase3DBasic::set_static(ID p_id, bool p_static) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get()._static = p_static;
}
-void BroadPhaseBasic::remove(ID p_id) {
+void BroadPhase3DBasic::remove(ID p_id) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -85,26 +85,26 @@ void BroadPhaseBasic::remove(ID p_id) {
element_map.erase(E);
}
-CollisionObjectSW *BroadPhaseBasic::get_object(ID p_id) const {
+CollisionObject3DSW *BroadPhase3DBasic::get_object(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, NULL);
return E->get().owner;
}
-bool BroadPhaseBasic::is_static(ID p_id) const {
+bool BroadPhase3DBasic::is_static(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, false);
return E->get()._static;
}
-int BroadPhaseBasic::get_subindex(ID p_id) const {
+int BroadPhase3DBasic::get_subindex(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, -1);
return E->get().subindex;
}
-int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhase3DBasic::cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
@@ -124,7 +124,7 @@ int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_re
return rc;
}
-int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhase3DBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
@@ -143,7 +143,7 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co
return rc;
}
-int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhase3DBasic::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
@@ -163,18 +163,18 @@ int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results
return rc;
}
-void BroadPhaseBasic::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) {
+void BroadPhase3DBasic::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) {
pair_userdata = p_userdata;
pair_callback = p_pair_callback;
}
-void BroadPhaseBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
+void BroadPhase3DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_userdata = p_userdata;
unpair_callback = p_unpair_callback;
}
-void BroadPhaseBasic::update() {
+void BroadPhase3DBasic::update() {
// recompute pairs
for (Map<ID, Element>::Element *I = element_map.front(); I; I = I->next()) {
@@ -210,12 +210,12 @@ void BroadPhaseBasic::update() {
}
}
-BroadPhaseSW *BroadPhaseBasic::_create() {
+BroadPhase3DSW *BroadPhase3DBasic::_create() {
- return memnew(BroadPhaseBasic);
+ return memnew(BroadPhase3DBasic);
}
-BroadPhaseBasic::BroadPhaseBasic() {
+BroadPhase3DBasic::BroadPhase3DBasic() {
current = 1;
unpair_callback = NULL;
diff --git a/servers/physics/broad_phase_basic.h b/servers/physics_3d/broad_phase_3d_basic.h
index 424889d8aa..9b20b7619a 100644
--- a/servers/physics/broad_phase_basic.h
+++ b/servers/physics_3d/broad_phase_3d_basic.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* broad_phase_basic.h */
+/* broad_phase_3d_basic.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,14 +31,14 @@
#ifndef BROAD_PHASE_BASIC_H
#define BROAD_PHASE_BASIC_H
-#include "broad_phase_sw.h"
+#include "broad_phase_3d_sw.h"
#include "core/map.h"
-class BroadPhaseBasic : public BroadPhaseSW {
+class BroadPhase3DBasic : public BroadPhase3DSW {
struct Element {
- CollisionObjectSW *owner;
+ CollisionObject3DSW *owner;
bool _static;
AABB aabb;
int subindex;
@@ -83,26 +83,26 @@ class BroadPhaseBasic : public BroadPhaseSW {
public:
// 0 is an invalid ID
- virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0);
+ virtual ID create(CollisionObject3DSW *p_object, int p_subindex = 0);
virtual void move(ID p_id, const AABB &p_aabb);
virtual void set_static(ID p_id, bool p_static);
virtual void remove(ID p_id);
- virtual CollisionObjectSW *get_object(ID p_id) const;
+ virtual CollisionObject3DSW *get_object(ID p_id) const;
virtual bool is_static(ID p_id) const;
virtual int get_subindex(ID p_id) const;
- virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
- virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
- virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
virtual void update();
- static BroadPhaseSW *_create();
- BroadPhaseBasic();
+ static BroadPhase3DSW *_create();
+ BroadPhase3DBasic();
};
#endif // BROAD_PHASE_BASIC_H
diff --git a/servers/physics/broad_phase_sw.cpp b/servers/physics_3d/broad_phase_3d_sw.cpp
index a6fc253b1b..5e367a7736 100644
--- a/servers/physics/broad_phase_sw.cpp
+++ b/servers/physics_3d/broad_phase_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* broad_phase_sw.cpp */
+/* broad_phase_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,9 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "broad_phase_sw.h"
+#include "broad_phase_3d_sw.h"
-BroadPhaseSW::CreateFunction BroadPhaseSW::create_func = NULL;
+BroadPhase3DSW::CreateFunction BroadPhase3DSW::create_func = NULL;
-BroadPhaseSW::~BroadPhaseSW() {
+BroadPhase3DSW::~BroadPhase3DSW() {
}
diff --git a/servers/physics/broad_phase_sw.h b/servers/physics_3d/broad_phase_3d_sw.h
index e69a2d24ed..47d09a8b1d 100644
--- a/servers/physics/broad_phase_sw.h
+++ b/servers/physics_3d/broad_phase_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* broad_phase_sw.h */
+/* broad_phase_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,40 +34,40 @@
#include "core/math/aabb.h"
#include "core/math/math_funcs.h"
-class CollisionObjectSW;
+class CollisionObject3DSW;
-class BroadPhaseSW {
+class BroadPhase3DSW {
public:
- typedef BroadPhaseSW *(*CreateFunction)();
+ typedef BroadPhase3DSW *(*CreateFunction)();
static CreateFunction create_func;
typedef uint32_t ID;
- typedef void *(*PairCallback)(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_userdata);
- typedef void (*UnpairCallback)(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_userdata);
+ typedef void *(*PairCallback)(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_userdata);
+ typedef void (*UnpairCallback)(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_userdata);
// 0 is an invalid ID
- virtual ID create(CollisionObjectSW *p_object_, int p_subindex = 0) = 0;
+ virtual ID create(CollisionObject3DSW *p_object_, int p_subindex = 0) = 0;
virtual void move(ID p_id, const AABB &p_aabb) = 0;
virtual void set_static(ID p_id, bool p_static) = 0;
virtual void remove(ID p_id) = 0;
- virtual CollisionObjectSW *get_object(ID p_id) const = 0;
+ virtual CollisionObject3DSW *get_object(ID p_id) const = 0;
virtual bool is_static(ID p_id) const = 0;
virtual int get_subindex(ID p_id) const = 0;
- virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
- virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
- virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
+ virtual int cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
+ virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
+ virtual int cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0;
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0;
virtual void update() = 0;
- virtual ~BroadPhaseSW();
+ virtual ~BroadPhase3DSW();
};
#endif // BROAD_PHASE__SW_H
diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics_3d/broad_phase_octree.cpp
index a9aa662abf..50ac17e027 100644
--- a/servers/physics/broad_phase_octree.cpp
+++ b/servers/physics_3d/broad_phase_octree.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "broad_phase_octree.h"
-#include "collision_object_sw.h"
+#include "collision_object_3d_sw.h"
-BroadPhaseSW::ID BroadPhaseOctree::create(CollisionObjectSW *p_object, int p_subindex) {
+BroadPhase3DSW::ID BroadPhaseOctree::create(CollisionObject3DSW *p_object, int p_subindex) {
ID oid = octree.create(p_object, AABB(), p_subindex, false, 1 << p_object->get_type(), 0);
return oid;
@@ -44,7 +44,7 @@ void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) {
void BroadPhaseOctree::set_static(ID p_id, bool p_static) {
- CollisionObjectSW *it = octree.get(p_id);
+ CollisionObject3DSW *it = octree.get(p_id);
octree.set_pairable(p_id, !p_static, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
}
void BroadPhaseOctree::remove(ID p_id) {
@@ -52,9 +52,9 @@ void BroadPhaseOctree::remove(ID p_id) {
octree.erase(p_id);
}
-CollisionObjectSW *BroadPhaseOctree::get_object(ID p_id) const {
+CollisionObject3DSW *BroadPhaseOctree::get_object(ID p_id) const {
- CollisionObjectSW *it = octree.get(p_id);
+ CollisionObject3DSW *it = octree.get(p_id);
ERR_FAIL_COND_V(!it, NULL);
return it;
}
@@ -67,22 +67,22 @@ int BroadPhaseOctree::get_subindex(ID p_id) const {
return octree.get_subindex(p_id);
}
-int BroadPhaseOctree::cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhaseOctree::cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
return octree.cull_point(p_point, p_results, p_max_results, p_result_indices);
}
-int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices);
}
-int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
return octree.cull_aabb(p_aabb, p_results, p_max_results, p_result_indices);
}
-void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, CollisionObjectSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObjectSW *p_object_B, int subindex_B) {
+void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, CollisionObject3DSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObject3DSW *p_object_B, int subindex_B) {
BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self);
if (!bpo->pair_callback)
@@ -91,7 +91,7 @@ void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, Collisio
return bpo->pair_callback(p_object_A, subindex_A, p_object_B, subindex_B, bpo->pair_userdata);
}
-void BroadPhaseOctree::_unpair_callback(void *self, OctreeElementID p_A, CollisionObjectSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObjectSW *p_object_B, int subindex_B, void *pairdata) {
+void BroadPhaseOctree::_unpair_callback(void *self, OctreeElementID p_A, CollisionObject3DSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObject3DSW *p_object_B, int subindex_B, void *pairdata) {
BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self);
if (!bpo->unpair_callback)
@@ -115,7 +115,7 @@ void BroadPhaseOctree::update() {
// does.. not?
}
-BroadPhaseSW *BroadPhaseOctree::_create() {
+BroadPhase3DSW *BroadPhaseOctree::_create() {
return memnew(BroadPhaseOctree);
}
diff --git a/servers/physics/broad_phase_octree.h b/servers/physics_3d/broad_phase_octree.h
index e2a1d82b69..25cf5b32da 100644
--- a/servers/physics/broad_phase_octree.h
+++ b/servers/physics_3d/broad_phase_octree.h
@@ -31,15 +31,15 @@
#ifndef BROAD_PHASE_OCTREE_H
#define BROAD_PHASE_OCTREE_H
-#include "broad_phase_sw.h"
+#include "broad_phase_3d_sw.h"
#include "core/math/octree.h"
-class BroadPhaseOctree : public BroadPhaseSW {
+class BroadPhaseOctree : public BroadPhase3DSW {
- Octree<CollisionObjectSW, true> octree;
+ Octree<CollisionObject3DSW, true> octree;
- static void *_pair_callback(void *, OctreeElementID, CollisionObjectSW *, int, OctreeElementID, CollisionObjectSW *, int);
- static void _unpair_callback(void *, OctreeElementID, CollisionObjectSW *, int, OctreeElementID, CollisionObjectSW *, int, void *);
+ static void *_pair_callback(void *, OctreeElementID, CollisionObject3DSW *, int, OctreeElementID, CollisionObject3DSW *, int);
+ static void _unpair_callback(void *, OctreeElementID, CollisionObject3DSW *, int, OctreeElementID, CollisionObject3DSW *, int, void *);
PairCallback pair_callback;
void *pair_userdata;
@@ -48,25 +48,25 @@ class BroadPhaseOctree : public BroadPhaseSW {
public:
// 0 is an invalid ID
- virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0);
+ virtual ID create(CollisionObject3DSW *p_object, int p_subindex = 0);
virtual void move(ID p_id, const AABB &p_aabb);
virtual void set_static(ID p_id, bool p_static);
virtual void remove(ID p_id);
- virtual CollisionObjectSW *get_object(ID p_id) const;
+ virtual CollisionObject3DSW *get_object(ID p_id) const;
virtual bool is_static(ID p_id) const;
virtual int get_subindex(ID p_id) const;
- virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
- virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
- virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
virtual void update();
- static BroadPhaseSW *_create();
+ static BroadPhase3DSW *_create();
BroadPhaseOctree();
};
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics_3d/collision_object_3d_sw.cpp
index 3cabf75ab6..ba13d70e4f 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics_3d/collision_object_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_object_sw.cpp */
+/* collision_object_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_object_sw.h"
-#include "servers/physics/physics_server_sw.h"
-#include "space_sw.h"
+#include "collision_object_3d_sw.h"
+#include "servers/physics_3d/physics_server_3d_sw.h"
+#include "space_3d_sw.h"
-void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform, bool p_disabled) {
+void CollisionObject3DSW::add_shape(Shape3DSW *p_shape, const Transform &p_transform, bool p_disabled) {
Shape s;
s.shape = p_shape;
@@ -44,13 +44,13 @@ void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform
p_shape->add_owner(this);
if (!pending_shape_update_list.in_list()) {
- PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
}
//_update_shapes();
//_shapes_changed();
}
-void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) {
+void CollisionObject3DSW::set_shape(int p_index, Shape3DSW *p_shape) {
ERR_FAIL_INDEX(p_index, shapes.size());
shapes[p_index].shape->remove_owner(this);
@@ -58,32 +58,32 @@ void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) {
p_shape->add_owner(this);
if (!pending_shape_update_list.in_list()) {
- PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
}
//_update_shapes();
//_shapes_changed();
}
-void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_transform) {
+void CollisionObject3DSW::set_shape_transform(int p_index, const Transform &p_transform) {
ERR_FAIL_INDEX(p_index, shapes.size());
shapes.write[p_index].xform = p_transform;
shapes.write[p_index].xform_inv = p_transform.affine_inverse();
if (!pending_shape_update_list.in_list()) {
- PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
}
//_update_shapes();
//_shapes_changed();
}
-void CollisionObjectSW::set_shape_as_disabled(int p_idx, bool p_enable) {
+void CollisionObject3DSW::set_shape_as_disabled(int p_idx, bool p_enable) {
shapes.write[p_idx].disabled = p_enable;
if (!pending_shape_update_list.in_list()) {
- PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
}
}
-void CollisionObjectSW::remove_shape(ShapeSW *p_shape) {
+void CollisionObject3DSW::remove_shape(Shape3DSW *p_shape) {
//remove a shape, all the times it appears
for (int i = 0; i < shapes.size(); i++) {
@@ -95,7 +95,7 @@ void CollisionObjectSW::remove_shape(ShapeSW *p_shape) {
}
}
-void CollisionObjectSW::remove_shape(int p_index) {
+void CollisionObject3DSW::remove_shape(int p_index) {
//remove anything from shape to be erased to end, so subindices don't change
ERR_FAIL_INDEX(p_index, shapes.size());
@@ -111,13 +111,13 @@ void CollisionObjectSW::remove_shape(int p_index) {
shapes.remove(p_index);
if (!pending_shape_update_list.in_list()) {
- PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
}
//_update_shapes();
//_shapes_changed();
}
-void CollisionObjectSW::_set_static(bool p_static) {
+void CollisionObject3DSW::_set_static(bool p_static) {
if (_static == p_static)
return;
_static = p_static;
@@ -132,7 +132,7 @@ void CollisionObjectSW::_set_static(bool p_static) {
}
}
-void CollisionObjectSW::_unregister_shapes() {
+void CollisionObject3DSW::_unregister_shapes() {
for (int i = 0; i < shapes.size(); i++) {
@@ -144,7 +144,7 @@ void CollisionObjectSW::_unregister_shapes() {
}
}
-void CollisionObjectSW::_update_shapes() {
+void CollisionObject3DSW::_update_shapes() {
if (!space)
return;
@@ -171,7 +171,7 @@ void CollisionObjectSW::_update_shapes() {
}
}
-void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) {
+void CollisionObject3DSW::_update_shapes_with_motion(const Vector3 &p_motion) {
if (!space)
return;
@@ -195,7 +195,7 @@ void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) {
}
}
-void CollisionObjectSW::_set_space(SpaceSW *p_space) {
+void CollisionObject3DSW::_set_space(Space3DSW *p_space) {
if (space) {
@@ -220,13 +220,13 @@ void CollisionObjectSW::_set_space(SpaceSW *p_space) {
}
}
-void CollisionObjectSW::_shape_changed() {
+void CollisionObject3DSW::_shape_changed() {
_update_shapes();
_shapes_changed();
}
-CollisionObjectSW::CollisionObjectSW(Type p_type) :
+CollisionObject3DSW::CollisionObject3DSW(Type p_type) :
pending_shape_update_list(this) {
_static = true;
diff --git a/servers/physics/collision_object_sw.h b/servers/physics_3d/collision_object_3d_sw.h
index 7c0e66ff90..c5773d0c61 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics_3d/collision_object_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_object_sw.h */
+/* collision_object_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,10 +31,10 @@
#ifndef COLLISION_OBJECT_SW_H
#define COLLISION_OBJECT_SW_H
-#include "broad_phase_sw.h"
+#include "broad_phase_3d_sw.h"
#include "core/self_list.h"
-#include "servers/physics_server.h"
-#include "shape_sw.h"
+#include "servers/physics_server_3d.h"
+#include "shape_3d_sw.h"
#ifdef DEBUG_ENABLED
#define MAX_OBJECT_DISTANCE 3.1622776601683791e+18
@@ -42,9 +42,9 @@
#define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE * MAX_OBJECT_DISTANCE)
#endif
-class SpaceSW;
+class Space3DSW;
-class CollisionObjectSW : public ShapeOwnerSW {
+class CollisionObject3DSW : public ShapeOwner3DSW {
public:
enum Type {
TYPE_AREA,
@@ -62,22 +62,22 @@ private:
Transform xform;
Transform xform_inv;
- BroadPhaseSW::ID bpid;
+ BroadPhase3DSW::ID bpid;
AABB aabb_cache; //for rayqueries
real_t area_cache;
- ShapeSW *shape;
+ Shape3DSW *shape;
bool disabled;
Shape() { disabled = false; }
};
Vector<Shape> shapes;
- SpaceSW *space;
+ Space3DSW *space;
Transform transform;
Transform inv_transform;
bool _static;
- SelfList<CollisionObjectSW> pending_shape_update_list;
+ SelfList<CollisionObject3DSW> pending_shape_update_list;
void _update_shapes();
@@ -98,11 +98,11 @@ protected:
void _set_static(bool p_static);
virtual void _shapes_changed() = 0;
- void _set_space(SpaceSW *p_space);
+ void _set_space(Space3DSW *p_space);
bool ray_pickable;
- CollisionObjectSW(Type p_type);
+ CollisionObject3DSW(Type p_type);
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
@@ -114,15 +114,15 @@ public:
void _shape_changed();
_FORCE_INLINE_ Type get_type() const { return type; }
- void add_shape(ShapeSW *p_shape, const Transform &p_transform = Transform(), bool p_disabled = false);
- void set_shape(int p_index, ShapeSW *p_shape);
+ void add_shape(Shape3DSW *p_shape, const Transform &p_transform = Transform(), bool p_disabled = false);
+ void set_shape(int p_index, Shape3DSW *p_shape);
void set_shape_transform(int p_index, const Transform &p_transform);
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
_FORCE_INLINE_ bool is_shape_disabled(int p_index) const {
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].disabled;
}
- _FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; }
+ _FORCE_INLINE_ Shape3DSW *get_shape(int p_index) const { return shapes[p_index].shape; }
_FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; }
_FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
_FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
@@ -130,7 +130,7 @@ public:
_FORCE_INLINE_ Transform get_transform() const { return transform; }
_FORCE_INLINE_ Transform get_inv_transform() const { return inv_transform; }
- _FORCE_INLINE_ SpaceSW *get_space() const { return space; }
+ _FORCE_INLINE_ Space3DSW *get_space() const { return space; }
_FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable = p_enable; }
_FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; }
@@ -147,18 +147,18 @@ public:
_FORCE_INLINE_ void set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; }
_FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; }
- _FORCE_INLINE_ bool test_collision_mask(CollisionObjectSW *p_other) const {
+ _FORCE_INLINE_ bool test_collision_mask(CollisionObject3DSW *p_other) const {
return collision_layer & p_other->collision_mask || p_other->collision_layer & collision_mask;
}
- void remove_shape(ShapeSW *p_shape);
+ void remove_shape(Shape3DSW *p_shape);
void remove_shape(int p_index);
- virtual void set_space(SpaceSW *p_space) = 0;
+ virtual void set_space(Space3DSW *p_space) = 0;
_FORCE_INLINE_ bool is_static() const { return _static; }
- virtual ~CollisionObjectSW() {}
+ virtual ~CollisionObject3DSW() {}
};
#endif // COLLISION_OBJECT_SW_H
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp
index 0e0dfd3cf2..0a7a9caf91 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics_3d/collision_solver_3d_sat.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_solver_sat.cpp */
+/* collision_solver_3d_sat.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_solver_sat.h"
+#include "collision_solver_3d_sat.h"
#include "core/math/geometry.h"
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02
struct _CollectorCallback {
- CollisionSolverSW::CallbackResult callback;
+ CollisionSolver3DSW::CallbackResult callback;
void *userdata;
bool swap;
bool collided;
@@ -426,15 +426,15 @@ public:
/****** SAT TESTS *******/
-typedef void (*CollisionFunc)(const ShapeSW *, const Transform &, const ShapeSW *, const Transform &, _CollectorCallback *p_callback, real_t, real_t);
+typedef void (*CollisionFunc)(const Shape3DSW *, const Transform &, const Shape3DSW *, const Transform &, _CollectorCallback *p_callback, real_t, real_t);
template <bool withMargin>
-static void _collision_sphere_sphere(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_sphere_sphere(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
- const SphereShapeSW *sphere_B = static_cast<const SphereShapeSW *>(p_b);
+ const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
+ const SphereShape3DSW *sphere_B = static_cast<const SphereShape3DSW *>(p_b);
- SeparatorAxisTest<SphereShapeSW, SphereShapeSW, withMargin> separator(sphere_A, p_transform_a, sphere_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<SphereShape3DSW, SphereShape3DSW, withMargin> separator(sphere_A, p_transform_a, sphere_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
// previous axis
@@ -448,12 +448,12 @@ static void _collision_sphere_sphere(const ShapeSW *p_a, const Transform &p_tran
}
template <bool withMargin>
-static void _collision_sphere_box(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_sphere_box(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
- const BoxShapeSW *box_B = static_cast<const BoxShapeSW *>(p_b);
+ const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
+ const BoxShape3DSW *box_B = static_cast<const BoxShape3DSW *>(p_b);
- SeparatorAxisTest<SphereShapeSW, BoxShapeSW, withMargin> separator(sphere_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<SphereShape3DSW, BoxShape3DSW, withMargin> separator(sphere_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -498,12 +498,12 @@ static void _collision_sphere_box(const ShapeSW *p_a, const Transform &p_transfo
}
template <bool withMargin>
-static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_sphere_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
- const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b);
+ const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
+ const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b);
- SeparatorAxisTest<SphereShapeSW, CapsuleShapeSW, withMargin> separator(sphere_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<SphereShape3DSW, CapsuleShape3DSW, withMargin> separator(sphere_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -537,16 +537,16 @@ static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_tra
}
template <bool withMargin>
-static void _collision_sphere_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_sphere_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
}
template <bool withMargin>
-static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_sphere_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
- const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b);
+ const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
+ const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
- SeparatorAxisTest<SphereShapeSW, ConvexPolygonShapeSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<SphereShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -601,12 +601,12 @@ static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform
}
template <bool withMargin>
-static void _collision_sphere_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_sphere_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
- const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b);
+ const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
+ const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
- SeparatorAxisTest<SphereShapeSW, FaceShapeSW, withMargin> separator(sphere_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<SphereShape3DSW, FaceShape3DSW, withMargin> separator(sphere_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
Vector3 vertex[3] = {
p_transform_b.xform(face_B->vertex[0]),
@@ -639,12 +639,12 @@ static void _collision_sphere_face(const ShapeSW *p_a, const Transform &p_transf
}
template <bool withMargin>
-static void _collision_box_box(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_box_box(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a);
- const BoxShapeSW *box_B = static_cast<const BoxShapeSW *>(p_b);
+ const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
+ const BoxShape3DSW *box_B = static_cast<const BoxShape3DSW *>(p_b);
- SeparatorAxisTest<BoxShapeSW, BoxShapeSW, withMargin> separator(box_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<BoxShape3DSW, BoxShape3DSW, withMargin> separator(box_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -737,12 +737,12 @@ static void _collision_box_box(const ShapeSW *p_a, const Transform &p_transform_
}
template <bool withMargin>
-static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a);
- const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b);
+ const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
+ const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b);
- SeparatorAxisTest<BoxShapeSW, CapsuleShapeSW, withMargin> separator(box_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<BoxShape3DSW, CapsuleShape3DSW, withMargin> separator(box_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -832,16 +832,16 @@ static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transf
}
template <bool withMargin>
-static void _collision_box_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_box_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
}
template <bool withMargin>
-static void _collision_box_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a);
- const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b);
+ const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
+ const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
- SeparatorAxisTest<BoxShapeSW, ConvexPolygonShapeSW, withMargin> separator(box_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<BoxShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(box_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -953,12 +953,12 @@ static void _collision_box_convex_polygon(const ShapeSW *p_a, const Transform &p
}
template <bool withMargin>
-static void _collision_box_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a);
- const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b);
+ const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
+ const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
- SeparatorAxisTest<BoxShapeSW, FaceShapeSW, withMargin> separator(box_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<BoxShape3DSW, FaceShape3DSW, withMargin> separator(box_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
Vector3 vertex[3] = {
p_transform_b.xform(face_B->vertex[0]),
@@ -1057,12 +1057,12 @@ static void _collision_box_face(const ShapeSW *p_a, const Transform &p_transform
}
template <bool withMargin>
-static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_capsule_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a);
- const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b);
+ const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a);
+ const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b);
- SeparatorAxisTest<CapsuleShapeSW, CapsuleShapeSW, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<CapsuleShape3DSW, CapsuleShape3DSW, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -1112,16 +1112,16 @@ static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_tr
}
template <bool withMargin>
-static void _collision_capsule_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_capsule_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
}
template <bool withMargin>
-static void _collision_capsule_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a);
- const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b);
+ const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a);
+ const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
- SeparatorAxisTest<CapsuleShapeSW, ConvexPolygonShapeSW, withMargin> separator(capsule_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<CapsuleShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(capsule_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -1181,12 +1181,12 @@ static void _collision_capsule_convex_polygon(const ShapeSW *p_a, const Transfor
}
template <bool withMargin>
-static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_capsule_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a);
- const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b);
+ const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a);
+ const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
- SeparatorAxisTest<CapsuleShapeSW, FaceShapeSW, withMargin> separator(capsule_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<CapsuleShape3DSW, FaceShape3DSW, withMargin> separator(capsule_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
Vector3 vertex[3] = {
p_transform_b.xform(face_B->vertex[0]),
@@ -1236,24 +1236,24 @@ static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_trans
}
template <bool withMargin>
-static void _collision_cylinder_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_cylinder_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
}
template <bool withMargin>
-static void _collision_cylinder_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_cylinder_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
}
template <bool withMargin>
-static void _collision_cylinder_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
}
template <bool withMargin>
-static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_convex_polygon_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW *>(p_a);
- const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b);
+ const ConvexPolygonShape3DSW *convex_polygon_A = static_cast<const ConvexPolygonShape3DSW *>(p_a);
+ const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
- SeparatorAxisTest<ConvexPolygonShapeSW, ConvexPolygonShapeSW, withMargin> separator(convex_polygon_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<ConvexPolygonShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
@@ -1362,12 +1362,12 @@ static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a, const T
}
template <bool withMargin>
-static void _collision_convex_polygon_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
+static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
- const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW *>(p_a);
- const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b);
+ const ConvexPolygonShape3DSW *convex_polygon_A = static_cast<const ConvexPolygonShape3DSW *>(p_a);
+ const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
- SeparatorAxisTest<ConvexPolygonShapeSW, FaceShapeSW, withMargin> separator(convex_polygon_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
+ SeparatorAxisTest<ConvexPolygonShape3DSW, FaceShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
const Geometry::MeshData &mesh = convex_polygon_A->get_mesh();
@@ -1462,18 +1462,18 @@ static void _collision_convex_polygon_face(const ShapeSW *p_a, const Transform &
separator.generate_contacts();
}
-bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) {
+bool sat_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) {
- PhysicsServer::ShapeType type_A = p_shape_A->get_type();
+ PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
- ERR_FAIL_COND_V(type_A == PhysicsServer::SHAPE_PLANE, false);
- ERR_FAIL_COND_V(type_A == PhysicsServer::SHAPE_RAY, false);
+ ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_PLANE, false);
+ ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_RAY, false);
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
- PhysicsServer::ShapeType type_B = p_shape_B->get_type();
+ PhysicsServer3D::ShapeType type_B = p_shape_B->get_type();
- ERR_FAIL_COND_V(type_B == PhysicsServer::SHAPE_PLANE, false);
- ERR_FAIL_COND_V(type_B == PhysicsServer::SHAPE_RAY, false);
+ ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_PLANE, false);
+ ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_RAY, false);
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
static const CollisionFunc collision_table[6][6] = {
@@ -1561,8 +1561,8 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran
callback.collided = false;
callback.prev_axis = r_prev_axis;
- const ShapeSW *A = p_shape_A;
- const ShapeSW *B = p_shape_B;
+ const Shape3DSW *A = p_shape_A;
+ const Shape3DSW *B = p_shape_B;
const Transform *transform_A = &p_transform_A;
const Transform *transform_B = &p_transform_B;
real_t margin_A = p_margin_a;
diff --git a/servers/physics/collision_solver_sat.h b/servers/physics_3d/collision_solver_3d_sat.h
index 31895231f0..c8ffd8e660 100644
--- a/servers/physics/collision_solver_sat.h
+++ b/servers/physics_3d/collision_solver_3d_sat.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_solver_sat.h */
+/* collision_solver_3d_sat.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,8 +31,8 @@
#ifndef COLLISION_SOLVER_SAT_H
#define COLLISION_SOLVER_SAT_H
-#include "collision_solver_sw.h"
+#include "collision_solver_3d_sw.h"
-bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector3 *r_prev_axis = NULL, real_t p_margin_a = 0, real_t p_margin_b = 0);
+bool sat_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector3 *r_prev_axis = NULL, real_t p_margin_a = 0, real_t p_margin_b = 0);
#endif // COLLISION_SOLVER_SAT_H
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics_3d/collision_solver_3d_sw.cpp
index ce24ba6bca..26de49c96f 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics_3d/collision_solver_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_solver_sw.cpp */
+/* collision_solver_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,18 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_solver_sw.h"
-#include "collision_solver_sat.h"
+#include "collision_solver_3d_sw.h"
+#include "collision_solver_3d_sat.h"
#include "gjk_epa.h"
#define collision_solver sat_calculate_penetration
//#define collision_solver gjk_epa_calculate_penetration
-bool CollisionSolverSW::solve_static_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
+bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
- const PlaneShapeSW *plane = static_cast<const PlaneShapeSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer::SHAPE_PLANE)
+ const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
+ if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE)
return false;
Plane p = p_transform_A.xform(plane->get_plane());
@@ -71,9 +71,9 @@ bool CollisionSolverSW::solve_static_plane(const ShapeSW *p_shape_A, const Trans
return found;
}
-bool CollisionSolverSW::solve_ray(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
+bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
- const RayShapeSW *ray = static_cast<const RayShapeSW *>(p_shape_A);
+ const RayShape3DSW *ray = static_cast<const RayShape3DSW *>(p_shape_A);
Vector3 from = p_transform_A.origin;
Vector3 to = from + p_transform_A.basis.get_axis(2) * ray->get_length();
@@ -106,9 +106,9 @@ bool CollisionSolverSW::solve_ray(const ShapeSW *p_shape_A, const Transform &p_t
struct _ConcaveCollisionInfo {
const Transform *transform_A;
- const ShapeSW *shape_A;
+ const Shape3DSW *shape_A;
const Transform *transform_B;
- CollisionSolverSW::CallbackResult result_callback;
+ CollisionSolver3DSW::CallbackResult result_callback;
void *userdata;
bool swap_result;
bool collided;
@@ -120,7 +120,7 @@ struct _ConcaveCollisionInfo {
Vector3 close_A, close_B;
};
-void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) {
+void CollisionSolver3DSW::concave_callback(void *p_userdata, Shape3DSW *p_convex) {
_ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata);
cinfo.aabb_tests++;
@@ -133,9 +133,9 @@ void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) {
cinfo.collisions++;
}
-bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A, real_t p_margin_B) {
+bool CollisionSolver3DSW::solve_concave(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A, real_t p_margin_B) {
- const ConcaveShapeSW *concave_B = static_cast<const ConcaveShapeSW *>(p_shape_B);
+ const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B);
_ConcaveCollisionInfo cinfo;
cinfo.transform_A = &p_transform_A;
@@ -179,10 +179,10 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform
return cinfo.collided;
}
-bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) {
+bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) {
- PhysicsServer::ShapeType type_A = p_shape_A->get_type();
- PhysicsServer::ShapeType type_B = p_shape_B->get_type();
+ PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
+ PhysicsServer3D::ShapeType type_B = p_shape_B->get_type();
bool concave_A = p_shape_A->is_concave();
bool concave_B = p_shape_B->is_concave();
@@ -194,11 +194,11 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &
swap = true;
}
- if (type_A == PhysicsServer::SHAPE_PLANE) {
+ if (type_A == PhysicsServer3D::SHAPE_PLANE) {
- if (type_B == PhysicsServer::SHAPE_PLANE)
+ if (type_B == PhysicsServer3D::SHAPE_PLANE)
return false;
- if (type_B == PhysicsServer::SHAPE_RAY) {
+ if (type_B == PhysicsServer3D::SHAPE_RAY) {
return false;
}
@@ -208,9 +208,9 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &
return solve_static_plane(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
}
- } else if (type_A == PhysicsServer::SHAPE_RAY) {
+ } else if (type_A == PhysicsServer3D::SHAPE_RAY) {
- if (type_B == PhysicsServer::SHAPE_RAY)
+ if (type_B == PhysicsServer3D::SHAPE_RAY)
return false;
if (swap) {
@@ -235,7 +235,7 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &
}
}
-void CollisionSolverSW::concave_distance_callback(void *p_userdata, ShapeSW *p_convex) {
+void CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW *p_convex) {
_ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata);
cinfo.aabb_tests++;
@@ -257,10 +257,10 @@ void CollisionSolverSW::concave_distance_callback(void *p_userdata, ShapeSW *p_c
cinfo.collisions++;
}
-bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
+bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
- const PlaneShapeSW *plane = static_cast<const PlaneShapeSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer::SHAPE_PLANE)
+ const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
+ if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE)
return false;
Plane p = p_transform_A.xform(plane->get_plane());
@@ -292,12 +292,12 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Tra
return collided;
}
-bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) {
+bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) {
if (p_shape_A->is_concave())
return false;
- if (p_shape_B->get_type() == PhysicsServer::SHAPE_PLANE) {
+ if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
Vector3 a, b;
bool col = solve_distance_plane(p_shape_B, p_transform_B, p_shape_A, p_transform_A, a, b);
@@ -310,7 +310,7 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform
if (p_shape_A->is_concave())
return false;
- const ConcaveShapeSW *concave_B = static_cast<const ConcaveShapeSW *>(p_shape_B);
+ const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B);
_ConcaveCollisionInfo cinfo;
cinfo.transform_A = &p_transform_A;
diff --git a/servers/physics/collision_solver_sw.h b/servers/physics_3d/collision_solver_3d_sw.h
index d4dc1ac2a2..ec76a4217e 100644
--- a/servers/physics/collision_solver_sw.h
+++ b/servers/physics_3d/collision_solver_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_solver_sw.h */
+/* collision_solver_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,23 +31,23 @@
#ifndef COLLISION_SOLVER_SW_H
#define COLLISION_SOLVER_SW_H
-#include "shape_sw.h"
+#include "shape_3d_sw.h"
-class CollisionSolverSW {
+class CollisionSolver3DSW {
public:
typedef void (*CallbackResult)(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata);
private:
- static void concave_callback(void *p_userdata, ShapeSW *p_convex);
- static bool solve_static_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
- static bool solve_ray(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
- static bool solve_concave(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A = 0, real_t p_margin_B = 0);
- static void concave_distance_callback(void *p_userdata, ShapeSW *p_convex);
- static bool solve_distance_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B);
+ static void concave_callback(void *p_userdata, Shape3DSW *p_convex);
+ static bool solve_static_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
+ static bool solve_ray(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
+ static bool solve_concave(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A = 0, real_t p_margin_B = 0);
+ static void concave_distance_callback(void *p_userdata, Shape3DSW *p_convex);
+ static bool solve_distance_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B);
public:
- static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0);
- static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL);
+ static bool solve_static(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0);
+ static bool solve_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL);
};
#endif // COLLISION_SOLVER__SW_H
diff --git a/servers/physics/constraint_sw.h b/servers/physics_3d/constraint_3d_sw.h
index 22f31b411b..b9d3ac4f12 100644
--- a/servers/physics/constraint_sw.h
+++ b/servers/physics_3d/constraint_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* constraint_sw.h */
+/* constraint_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,22 +31,22 @@
#ifndef CONSTRAINT_SW_H
#define CONSTRAINT_SW_H
-#include "body_sw.h"
+#include "body_3d_sw.h"
-class ConstraintSW {
+class Constraint3DSW {
- BodySW **_body_ptr;
+ Body3DSW **_body_ptr;
int _body_count;
uint64_t island_step;
- ConstraintSW *island_next;
- ConstraintSW *island_list_next;
+ Constraint3DSW *island_next;
+ Constraint3DSW *island_list_next;
int priority;
bool disabled_collisions_between_bodies;
RID self;
protected:
- ConstraintSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) {
+ Constraint3DSW(Body3DSW **p_body_ptr = NULL, int p_body_count = 0) {
_body_ptr = p_body_ptr;
_body_count = p_body_count;
island_step = 0;
@@ -61,13 +61,13 @@ public:
_FORCE_INLINE_ uint64_t get_island_step() const { return island_step; }
_FORCE_INLINE_ void set_island_step(uint64_t p_step) { island_step = p_step; }
- _FORCE_INLINE_ ConstraintSW *get_island_next() const { return island_next; }
- _FORCE_INLINE_ void set_island_next(ConstraintSW *p_next) { island_next = p_next; }
+ _FORCE_INLINE_ Constraint3DSW *get_island_next() const { return island_next; }
+ _FORCE_INLINE_ void set_island_next(Constraint3DSW *p_next) { island_next = p_next; }
- _FORCE_INLINE_ ConstraintSW *get_island_list_next() const { return island_list_next; }
- _FORCE_INLINE_ void set_island_list_next(ConstraintSW *p_next) { island_list_next = p_next; }
+ _FORCE_INLINE_ Constraint3DSW *get_island_list_next() const { return island_list_next; }
+ _FORCE_INLINE_ void set_island_list_next(Constraint3DSW *p_next) { island_list_next = p_next; }
- _FORCE_INLINE_ BodySW **get_body_ptr() const { return _body_ptr; }
+ _FORCE_INLINE_ Body3DSW **get_body_ptr() const { return _body_ptr; }
_FORCE_INLINE_ int get_body_count() const { return _body_count; }
_FORCE_INLINE_ void set_priority(int p_priority) { priority = p_priority; }
@@ -79,7 +79,7 @@ public:
virtual bool setup(real_t p_step) = 0;
virtual void solve(real_t p_step) = 0;
- virtual ~ConstraintSW() {}
+ virtual ~Constraint3DSW() {}
};
#endif // CONSTRAINT__SW_H
diff --git a/servers/physics/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp
index abf0c0dc15..bd0d429e7b 100644
--- a/servers/physics/gjk_epa.cpp
+++ b/servers/physics_3d/gjk_epa.cpp
@@ -103,7 +103,7 @@ typedef unsigned char U1;
// MinkowskiDiff
struct MinkowskiDiff {
- const ShapeSW* m_shapes[2];
+ const Shape3DSW* m_shapes[2];
Transform transform_A;
Transform transform_B;
@@ -783,8 +783,8 @@ struct GJK
};
//
- static void Initialize( const ShapeSW* shape0,const Transform& wtrs0,
- const ShapeSW* shape1,const Transform& wtrs1,
+ static void Initialize( const Shape3DSW* shape0,const Transform& wtrs0,
+ const Shape3DSW* shape1,const Transform& wtrs1,
sResults& results,
tShape& shape,
bool withmargins)
@@ -810,9 +810,9 @@ struct GJK
//
//
-bool Distance( const ShapeSW* shape0,
+bool Distance( const Shape3DSW* shape0,
const Transform& wtrs0,
- const ShapeSW* shape1,
+ const Shape3DSW* shape1,
const Transform& wtrs1,
const Vector3& guess,
sResults& results)
@@ -848,9 +848,9 @@ bool Distance( const ShapeSW* shape0,
}
//
-bool Penetration( const ShapeSW* shape0,
+bool Penetration( const Shape3DSW* shape0,
const Transform& wtrs0,
- const ShapeSW* shape1,
+ const Shape3DSW* shape1,
const Transform& wtrs1,
const Vector3& guess,
sResults& results
@@ -914,7 +914,7 @@ bool Penetration( const ShapeSW* shape0,
/* clang-format on */
-bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B) {
+bool gjk_epa_calculate_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B) {
GjkEpa2::sResults res;
@@ -928,7 +928,7 @@ bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_tra
return false;
}
-bool gjk_epa_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap) {
+bool gjk_epa_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap) {
GjkEpa2::sResults res;
diff --git a/servers/physics/gjk_epa.h b/servers/physics_3d/gjk_epa.h
index 38c616cde0..dec0f269e1 100644
--- a/servers/physics/gjk_epa.h
+++ b/servers/physics_3d/gjk_epa.h
@@ -31,10 +31,10 @@
#ifndef GJK_EPA_H
#define GJK_EPA_H
-#include "collision_solver_sw.h"
-#include "shape_sw.h"
+#include "collision_solver_3d_sw.h"
+#include "shape_3d_sw.h"
-bool gjk_epa_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false);
-bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B);
+bool gjk_epa_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false);
+bool gjk_epa_calculate_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B);
#endif
diff --git a/servers/physics/joints/SCsub b/servers/physics_3d/joints/SCsub
index d730144861..d730144861 100644
--- a/servers/physics/joints/SCsub
+++ b/servers/physics_3d/joints/SCsub
diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp
index 58f66f7ea2..a072c1f3a0 100644
--- a/servers/physics/joints/cone_twist_joint_sw.cpp
+++ b/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cone_twist_joint_sw.cpp */
+/* cone_twist_joint_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -49,7 +49,7 @@ subject to the following restrictions:
Written by: Marcus Hennix
*/
-#include "cone_twist_joint_sw.h"
+#include "cone_twist_joint_3d_sw.h"
static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
@@ -85,8 +85,8 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
return (y < 0.0f) ? -angle : angle;
}
-ConeTwistJointSW::ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) :
- JointSW(_arr, 2) {
+ConeTwistJoint3DSW::ConeTwistJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) :
+ Joint3DSW(_arr, 2) {
A = rbA;
B = rbB;
@@ -110,7 +110,7 @@ ConeTwistJointSW::ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rb
m_appliedImpulse = 0;
}
-bool ConeTwistJointSW::setup(real_t p_timestep) {
+bool ConeTwistJoint3DSW::setup(real_t p_timestep) {
m_appliedImpulse = real_t(0.);
//set bias, sign, clear accumulator
@@ -136,7 +136,7 @@ bool ConeTwistJointSW::setup(real_t p_timestep) {
plane_space(normal[0], normal[1], normal[2]);
for (int i = 0; i < 3; i++) {
- memnew_placement(&m_jac[i], JacobianEntrySW(
+ memnew_placement(&m_jac[i], JacobianEntry3DSW(
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
pivotAInW - A->get_transform().origin - A->get_center_of_mass(),
@@ -237,7 +237,7 @@ bool ConeTwistJointSW::setup(real_t p_timestep) {
return true;
}
-void ConeTwistJointSW::solve(real_t p_timestep) {
+void ConeTwistJoint3DSW::solve(real_t p_timestep) {
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
@@ -308,58 +308,58 @@ void ConeTwistJointSW::solve(real_t p_timestep) {
}
}
-void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) {
+void ConeTwistJoint3DSW::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
m_swingSpan1 = p_value;
m_swingSpan2 = p_value;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
m_twistSpan = p_value;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_BIAS: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
m_biasFactor = p_value;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
m_limitSoftness = p_value;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_RELAXATION: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
m_relaxationFactor = p_value;
} break;
- case PhysicsServer::CONE_TWIST_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::CONE_TWIST_MAX: break; // Can't happen, but silences warning
}
}
-real_t ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) const {
+real_t ConeTwistJoint3DSW::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
return m_swingSpan1;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
return m_twistSpan;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_BIAS: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
return m_biasFactor;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
return m_limitSoftness;
} break;
- case PhysicsServer::CONE_TWIST_JOINT_RELAXATION: {
+ case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
return m_relaxationFactor;
} break;
- case PhysicsServer::CONE_TWIST_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::CONE_TWIST_MAX: break; // Can't happen, but silences warning
}
return 0;
diff --git a/servers/physics/joints/cone_twist_joint_sw.h b/servers/physics_3d/joints/cone_twist_joint_3d_sw.h
index 857aaa0d86..c713d8cf17 100644
--- a/servers/physics/joints/cone_twist_joint_sw.h
+++ b/servers/physics_3d/joints/cone_twist_joint_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cone_twist_joint_sw.h */
+/* cone_twist_joint_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -52,25 +52,25 @@ Written by: Marcus Hennix
#ifndef CONE_TWIST_JOINT_SW_H
#define CONE_TWIST_JOINT_SW_H
-#include "servers/physics/joints/jacobian_entry_sw.h"
-#include "servers/physics/joints_sw.h"
+#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h"
+#include "servers/physics_3d/joints_3d_sw.h"
///ConeTwistJointSW can be used to simulate ragdoll joints (upper arm, leg etc)
-class ConeTwistJointSW : public JointSW {
+class ConeTwistJoint3DSW : public Joint3DSW {
#ifdef IN_PARALLELL_SOLVER
public:
#endif
union {
struct {
- BodySW *A;
- BodySW *B;
+ Body3DSW *A;
+ Body3DSW *B;
};
- BodySW *_arr[2];
+ Body3DSW *_arr[2];
};
- JacobianEntrySW m_jac[3]; //3 orthogonal linear constraints
+ JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints
real_t m_appliedImpulse;
Transform m_rbAFrame;
@@ -102,12 +102,12 @@ public:
bool m_solveSwingLimit;
public:
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; }
virtual bool setup(real_t p_timestep);
virtual void solve(real_t p_timestep);
- ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rbAFrame, const Transform &rbBFrame);
+ ConeTwistJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &rbAFrame, const Transform &rbBFrame);
void setAngularOnly(bool angularOnly) {
m_angularOnly = angularOnly;
@@ -135,8 +135,8 @@ public:
return m_twistLimitSign;
}
- void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const;
+ void set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::ConeTwistJointParam p_param) const;
};
#endif // CONE_TWIST_JOINT_SW_H
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
index 8f0ccab7f7..1f433ec6a5 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* generic_6dof_joint_sw.cpp */
+/* generic_6dof_joint_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -54,13 +54,13 @@ email: projectileman@yahoo.com
http://gimpact.sf.net
*/
-#include "generic_6dof_joint_sw.h"
+#include "generic_6dof_joint_3d_sw.h"
#define GENERIC_D6_DISABLE_WARMSTARTING 1
//////////////////////////// G6DOFRotationalLimitMotorSW ////////////////////////////////////
-int G6DOFRotationalLimitMotorSW::testLimitValue(real_t test_value) {
+int G6DOFRotationalLimitMotor3DSW::testLimitValue(real_t test_value) {
if (m_loLimit > m_hiLimit) {
m_currentLimit = 0; //Free from violation
return 0;
@@ -80,9 +80,9 @@ int G6DOFRotationalLimitMotorSW::testLimitValue(real_t test_value) {
return 0;
}
-real_t G6DOFRotationalLimitMotorSW::solveAngularLimits(
+real_t G6DOFRotationalLimitMotor3DSW::solveAngularLimits(
real_t timeStep, Vector3 &axis, real_t jacDiagABInv,
- BodySW *body0, BodySW *body1) {
+ Body3DSW *body0, Body3DSW *body1) {
if (!needApplyTorques()) return 0.0f;
real_t target_velocity = m_targetVelocity;
@@ -145,11 +145,11 @@ real_t G6DOFRotationalLimitMotorSW::solveAngularLimits(
//////////////////////////// End G6DOFRotationalLimitMotorSW ////////////////////////////////////
//////////////////////////// G6DOFTranslationalLimitMotorSW ////////////////////////////////////
-real_t G6DOFTranslationalLimitMotorSW::solveLinearAxis(
+real_t G6DOFTranslationalLimitMotor3DSW::solveLinearAxis(
real_t timeStep,
real_t jacDiagABInv,
- BodySW *body1, const Vector3 &pointInA,
- BodySW *body2, const Vector3 &pointInB,
+ Body3DSW *body1, const Vector3 &pointInA,
+ Body3DSW *body2, const Vector3 &pointInB,
int limit_index,
const Vector3 &axis_normal_on_a,
const Vector3 &anchorPos) {
@@ -209,8 +209,8 @@ real_t G6DOFTranslationalLimitMotorSW::solveLinearAxis(
//////////////////////////// G6DOFTranslationalLimitMotorSW ////////////////////////////////////
-Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) :
- JointSW(_arr, 2),
+Generic6DOFJoint3DSW::Generic6DOFJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) :
+ Joint3DSW(_arr, 2),
m_frameInA(frameInA),
m_frameInB(frameInB),
m_useLinearReferenceFrameA(useLinearReferenceFrameA) {
@@ -220,7 +220,7 @@ Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform
B->add_constraint(this, 1);
}
-void Generic6DOFJointSW::calculateAngleInfo() {
+void Generic6DOFJoint3DSW::calculateAngleInfo() {
Basis relative_frame = m_calculatedTransformB.basis.inverse() * m_calculatedTransformA.basis;
m_calculatedAxisAngleDiff = relative_frame.get_euler_xyz();
@@ -261,17 +261,17 @@ void Generic6DOFJointSW::calculateAngleInfo() {
*/
}
-void Generic6DOFJointSW::calculateTransforms() {
+void Generic6DOFJoint3DSW::calculateTransforms() {
m_calculatedTransformA = A->get_transform() * m_frameInA;
m_calculatedTransformB = B->get_transform() * m_frameInB;
calculateAngleInfo();
}
-void Generic6DOFJointSW::buildLinearJacobian(
- JacobianEntrySW &jacLinear, const Vector3 &normalWorld,
+void Generic6DOFJoint3DSW::buildLinearJacobian(
+ JacobianEntry3DSW &jacLinear, const Vector3 &normalWorld,
const Vector3 &pivotAInW, const Vector3 &pivotBInW) {
- memnew_placement(&jacLinear, JacobianEntrySW(
+ memnew_placement(&jacLinear, JacobianEntry3DSW(
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
pivotAInW - A->get_transform().origin - A->get_center_of_mass(),
@@ -283,16 +283,16 @@ void Generic6DOFJointSW::buildLinearJacobian(
B->get_inv_mass()));
}
-void Generic6DOFJointSW::buildAngularJacobian(
- JacobianEntrySW &jacAngular, const Vector3 &jointAxisW) {
- memnew_placement(&jacAngular, JacobianEntrySW(jointAxisW,
+void Generic6DOFJoint3DSW::buildAngularJacobian(
+ JacobianEntry3DSW &jacAngular, const Vector3 &jointAxisW) {
+ memnew_placement(&jacAngular, JacobianEntry3DSW(jointAxisW,
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
A->get_inv_inertia(),
B->get_inv_inertia()));
}
-bool Generic6DOFJointSW::testAngularLimitMotor(int axis_index) {
+bool Generic6DOFJoint3DSW::testAngularLimitMotor(int axis_index) {
real_t angle = m_calculatedAxisAngleDiff[axis_index];
//test limits
@@ -300,7 +300,7 @@ bool Generic6DOFJointSW::testAngularLimitMotor(int axis_index) {
return m_angularLimits[axis_index].needApplyTorques();
}
-bool Generic6DOFJointSW::setup(real_t p_timestep) {
+bool Generic6DOFJoint3DSW::setup(real_t p_timestep) {
// Clear accumulated impulses for the next simulation step
m_linearLimits.m_accumulatedImpulse = Vector3(real_t(0.), real_t(0.), real_t(0.));
@@ -349,7 +349,7 @@ bool Generic6DOFJointSW::setup(real_t p_timestep) {
return true;
}
-void Generic6DOFJointSW::solve(real_t p_timestep) {
+void Generic6DOFJoint3DSW::solve(real_t p_timestep) {
m_timeStep = p_timestep;
//calculateTransforms();
@@ -397,19 +397,19 @@ void Generic6DOFJointSW::solve(real_t p_timestep) {
}
}
-void Generic6DOFJointSW::updateRHS(real_t timeStep) {
+void Generic6DOFJoint3DSW::updateRHS(real_t timeStep) {
(void)timeStep;
}
-Vector3 Generic6DOFJointSW::getAxis(int axis_index) const {
+Vector3 Generic6DOFJoint3DSW::getAxis(int axis_index) const {
return m_calculatedAxis[axis_index];
}
-real_t Generic6DOFJointSW::getAngle(int axis_index) const {
+real_t Generic6DOFJoint3DSW::getAngle(int axis_index) const {
return m_calculatedAxisAngleDiff[axis_index];
}
-void Generic6DOFJointSW::calcAnchorPos(void) {
+void Generic6DOFJoint3DSW::calcAnchorPos(void) {
real_t imA = A->get_inv_mass();
real_t imB = B->get_inv_mass();
real_t weight;
@@ -423,263 +423,263 @@ void Generic6DOFJointSW::calcAnchorPos(void) {
m_AnchorPos = pA * weight + pB * (real_t(1.0) - weight);
} // Generic6DOFJointSW::calcAnchorPos()
-void Generic6DOFJointSW::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
+void Generic6DOFJoint3DSW::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
ERR_FAIL_INDEX(p_axis, 3);
switch (p_param) {
- case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
m_linearLimits.m_lowerLimit[p_axis] = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
m_linearLimits.m_upperLimit[p_axis] = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
m_linearLimits.m_limitSoftness[p_axis] = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
m_linearLimits.m_restitution[p_axis] = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
m_linearLimits.m_damping[p_axis] = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
m_angularLimits[p_axis].m_loLimit = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
m_angularLimits[p_axis].m_hiLimit = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
m_angularLimits[p_axis].m_limitSoftness = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
m_angularLimits[p_axis].m_damping = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
m_angularLimits[p_axis].m_bounce = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
m_angularLimits[p_axis].m_maxLimitForce = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
m_angularLimits[p_axis].m_ERP = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
m_angularLimits[p_axis].m_targetVelocity = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
m_angularLimits[p_axis].m_maxLimitForce = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning
}
}
-real_t Generic6DOFJointSW::get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const {
+real_t Generic6DOFJoint3DSW::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
switch (p_param) {
- case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
return m_linearLimits.m_lowerLimit[p_axis];
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
return m_linearLimits.m_upperLimit[p_axis];
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
return m_linearLimits.m_limitSoftness[p_axis];
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
return m_linearLimits.m_restitution[p_axis];
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
return m_linearLimits.m_damping[p_axis];
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
return m_angularLimits[p_axis].m_loLimit;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
return m_angularLimits[p_axis].m_hiLimit;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
return m_angularLimits[p_axis].m_limitSoftness;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
return m_angularLimits[p_axis].m_damping;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
return m_angularLimits[p_axis].m_bounce;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
return m_angularLimits[p_axis].m_maxLimitForce;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
return m_angularLimits[p_axis].m_ERP;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
return m_angularLimits[p_axis].m_targetVelocity;
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
return m_angularLimits[p_axis].m_maxMotorForce;
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning
}
return 0;
}
-void Generic6DOFJointSW::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value) {
+void Generic6DOFJoint3DSW::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_axis, 3);
switch (p_flag) {
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
m_linearLimits.enable_limit[p_axis] = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
m_angularLimits[p_axis].m_enableLimit = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
m_angularLimits[p_axis].m_enableMotor = p_value;
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
}
}
-bool Generic6DOFJointSW::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const {
+bool Generic6DOFJoint3DSW::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
switch (p_flag) {
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
return m_linearLimits.enable_limit[p_axis];
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
return m_angularLimits[p_axis].m_enableLimit;
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
return m_angularLimits[p_axis].m_enableMotor;
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: {
// Not implemented in GodotPhysics backend
} break;
- case PhysicsServer::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
}
return 0;
diff --git a/servers/physics/joints/generic_6dof_joint_sw.h b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h
index 07626ffa97..f7aa607901 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.h
+++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* generic_6dof_joint_sw.h */
+/* generic_6dof_joint_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library.
#ifndef GENERIC_6DOF_JOINT_SW_H
#define GENERIC_6DOF_JOINT_SW_H
-#include "servers/physics/joints/jacobian_entry_sw.h"
-#include "servers/physics/joints_sw.h"
+#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h"
+#include "servers/physics_3d/joints_3d_sw.h"
/*
Bullet Continuous Collision Detection and Physics Library
@@ -61,7 +61,7 @@ http://gimpact.sf.net
*/
//! Rotation Limit structure for generic joints
-class G6DOFRotationalLimitMotorSW {
+class G6DOFRotationalLimitMotor3DSW {
public:
//! limit_parameters
//!@{
@@ -86,7 +86,7 @@ public:
real_t m_accumulatedImpulse;
//!@}
- G6DOFRotationalLimitMotorSW() {
+ G6DOFRotationalLimitMotor3DSW() {
m_accumulatedImpulse = 0.f;
m_targetVelocity = 0;
m_maxMotorForce = 0.1f;
@@ -103,7 +103,7 @@ public:
m_enableLimit = false;
}
- G6DOFRotationalLimitMotorSW(const G6DOFRotationalLimitMotorSW &limot) {
+ G6DOFRotationalLimitMotor3DSW(const G6DOFRotationalLimitMotor3DSW &limot) {
m_targetVelocity = limot.m_targetVelocity;
m_maxMotorForce = limot.m_maxMotorForce;
m_limitSoftness = limot.m_limitSoftness;
@@ -133,10 +133,10 @@ public:
int testLimitValue(real_t test_value);
//! apply the correction impulses for two bodies
- real_t solveAngularLimits(real_t timeStep, Vector3 &axis, real_t jacDiagABInv, BodySW *body0, BodySW *body1);
+ real_t solveAngularLimits(real_t timeStep, Vector3 &axis, real_t jacDiagABInv, Body3DSW *body0, Body3DSW *body1);
};
-class G6DOFTranslationalLimitMotorSW {
+class G6DOFTranslationalLimitMotor3DSW {
public:
Vector3 m_lowerLimit; //!< the constraint lower limits
Vector3 m_upperLimit; //!< the constraint upper limits
@@ -149,7 +149,7 @@ public:
//!@}
bool enable_limit[3];
- G6DOFTranslationalLimitMotorSW() {
+ G6DOFTranslationalLimitMotor3DSW() {
m_lowerLimit = Vector3(0.f, 0.f, 0.f);
m_upperLimit = Vector3(0.f, 0.f, 0.f);
m_accumulatedImpulse = Vector3(0.f, 0.f, 0.f);
@@ -163,7 +163,7 @@ public:
enable_limit[2] = true;
}
- G6DOFTranslationalLimitMotorSW(const G6DOFTranslationalLimitMotorSW &other) {
+ G6DOFTranslationalLimitMotor3DSW(const G6DOFTranslationalLimitMotor3DSW &other) {
m_lowerLimit = other.m_lowerLimit;
m_upperLimit = other.m_upperLimit;
m_accumulatedImpulse = other.m_accumulatedImpulse;
@@ -187,22 +187,22 @@ public:
real_t solveLinearAxis(
real_t timeStep,
real_t jacDiagABInv,
- BodySW *body1, const Vector3 &pointInA,
- BodySW *body2, const Vector3 &pointInB,
+ Body3DSW *body1, const Vector3 &pointInA,
+ Body3DSW *body2, const Vector3 &pointInB,
int limit_index,
const Vector3 &axis_normal_on_a,
const Vector3 &anchorPos);
};
-class Generic6DOFJointSW : public JointSW {
+class Generic6DOFJoint3DSW : public Joint3DSW {
protected:
union {
struct {
- BodySW *A;
- BodySW *B;
+ Body3DSW *A;
+ Body3DSW *B;
};
- BodySW *_arr[2];
+ Body3DSW *_arr[2];
};
//! relative_frames
@@ -213,18 +213,18 @@ protected:
//! Jacobians
//!@{
- JacobianEntrySW m_jacLinear[3]; //!< 3 orthogonal linear constraints
- JacobianEntrySW m_jacAng[3]; //!< 3 orthogonal angular constraints
+ JacobianEntry3DSW m_jacLinear[3]; //!< 3 orthogonal linear constraints
+ JacobianEntry3DSW m_jacAng[3]; //!< 3 orthogonal angular constraints
//!@}
//! Linear_Limit_parameters
//!@{
- G6DOFTranslationalLimitMotorSW m_linearLimits;
+ G6DOFTranslationalLimitMotor3DSW m_linearLimits;
//!@}
//! hinge_parameters
//!@{
- G6DOFRotationalLimitMotorSW m_angularLimits[3];
+ G6DOFRotationalLimitMotor3DSW m_angularLimits[3];
//!@}
protected:
@@ -242,25 +242,25 @@ protected:
//!@}
- Generic6DOFJointSW &operator=(Generic6DOFJointSW &other) {
+ Generic6DOFJoint3DSW &operator=(Generic6DOFJoint3DSW &other) {
ERR_PRINT("pito");
(void)other;
return *this;
}
void buildLinearJacobian(
- JacobianEntrySW &jacLinear, const Vector3 &normalWorld,
+ JacobianEntry3DSW &jacLinear, const Vector3 &normalWorld,
const Vector3 &pivotAInW, const Vector3 &pivotBInW);
- void buildAngularJacobian(JacobianEntrySW &jacAngular, const Vector3 &jointAxisW);
+ void buildAngularJacobian(JacobianEntry3DSW &jacAngular, const Vector3 &jointAxisW);
//! calcs the euler angles between the two bodies.
void calculateAngleInfo();
public:
- Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA);
+ Generic6DOFJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; }
virtual bool setup(real_t p_timestep);
virtual void solve(real_t p_timestep);
@@ -348,12 +348,12 @@ public:
}
//! Retrieves the angular limit informacion
- G6DOFRotationalLimitMotorSW *getRotationalLimitMotor(int index) {
+ G6DOFRotationalLimitMotor3DSW *getRotationalLimitMotor(int index) {
return &m_angularLimits[index];
}
//! Retrieves the limit informacion
- G6DOFTranslationalLimitMotorSW *getTranslationalLimitMotor() {
+ G6DOFTranslationalLimitMotor3DSW *getTranslationalLimitMotor() {
return &m_linearLimits;
}
@@ -382,20 +382,20 @@ public:
return m_angularLimits[limitIndex - 3].isLimited();
}
- const BodySW *getRigidBodyA() const {
+ const Body3DSW *getRigidBodyA() const {
return A;
}
- const BodySW *getRigidBodyB() const {
+ const Body3DSW *getRigidBodyB() const {
return B;
}
virtual void calcAnchorPos(void); // overridable
- void set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value);
- real_t get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const;
+ void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value);
+ real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const;
- void set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value);
- bool get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const;
+ void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value);
+ bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const;
};
#endif // GENERIC_6DOF_JOINT_SW_H
diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
index 1ad3e738ba..e76d366422 100644
--- a/servers/physics/joints/hinge_joint_sw.cpp
+++ b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* hinge_joint_sw.cpp */
+/* hinge_joint_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -47,7 +47,7 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-#include "hinge_joint_sw.h"
+#include "hinge_joint_3d_sw.h"
static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
@@ -68,8 +68,8 @@ static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
}
}
-HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, const Transform &frameB) :
- JointSW(_arr, 2) {
+HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameA, const Transform &frameB) :
+ Joint3DSW(_arr, 2) {
A = rbA;
B = rbB;
@@ -100,9 +100,9 @@ HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, co
B->add_constraint(this, 1);
}
-HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB,
+HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB,
const Vector3 &axisInA, const Vector3 &axisInB) :
- JointSW(_arr, 2) {
+ Joint3DSW(_arr, 2) {
A = rbA;
B = rbB;
@@ -157,7 +157,7 @@ HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, co
B->add_constraint(this, 1);
}
-bool HingeJointSW::setup(real_t p_step) {
+bool HingeJoint3DSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
@@ -176,7 +176,7 @@ bool HingeJointSW::setup(real_t p_step) {
plane_space(normal[0], normal[1], normal[2]);
for (int i = 0; i < 3; i++) {
- memnew_placement(&m_jac[i], JacobianEntrySW(
+ memnew_placement(&m_jac[i], JacobianEntry3DSW(
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
pivotAInW - A->get_transform().origin - A->get_center_of_mass(),
@@ -202,19 +202,19 @@ bool HingeJointSW::setup(real_t p_step) {
Vector3 jointAxis1 = A->get_transform().basis.xform(jointAxis1local);
Vector3 hingeAxisWorld = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(2));
- memnew_placement(&m_jacAng[0], JacobianEntrySW(jointAxis0,
+ memnew_placement(&m_jacAng[0], JacobianEntry3DSW(jointAxis0,
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
A->get_inv_inertia(),
B->get_inv_inertia()));
- memnew_placement(&m_jacAng[1], JacobianEntrySW(jointAxis1,
+ memnew_placement(&m_jacAng[1], JacobianEntry3DSW(jointAxis1,
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
A->get_inv_inertia(),
B->get_inv_inertia()));
- memnew_placement(&m_jacAng[2], JacobianEntrySW(hingeAxisWorld,
+ memnew_placement(&m_jacAng[2], JacobianEntry3DSW(hingeAxisWorld,
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
A->get_inv_inertia(),
@@ -253,7 +253,7 @@ bool HingeJointSW::setup(real_t p_step) {
return true;
}
-void HingeJointSW::solve(real_t p_step) {
+void HingeJoint3DSW::solve(real_t p_step) {
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
@@ -388,7 +388,7 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
return (y < 0.0f) ? -angle : angle;
}
-real_t HingeJointSW::get_hinge_angle() {
+real_t HingeJoint3DSW::get_hinge_angle() {
const Vector3 refAxis0 = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(0));
const Vector3 refAxis1 = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(1));
const Vector3 swingAxis = B->get_transform().basis.xform(m_rbBFrame.basis.get_axis(1));
@@ -396,54 +396,54 @@ real_t HingeJointSW::get_hinge_angle() {
return atan2fast(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1));
}
-void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
+void HingeJoint3DSW::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS: tau = p_value; break;
- case PhysicsServer::HINGE_JOINT_LIMIT_UPPER: m_upperLimit = p_value; break;
- case PhysicsServer::HINGE_JOINT_LIMIT_LOWER: m_lowerLimit = p_value; break;
- case PhysicsServer::HINGE_JOINT_LIMIT_BIAS: m_biasFactor = p_value; break;
- case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS: m_limitSoftness = p_value; break;
- case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: m_relaxationFactor = p_value; break;
- case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: m_motorTargetVelocity = p_value; break;
- case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: m_maxMotorImpulse = p_value; break;
- case PhysicsServer::HINGE_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::HINGE_JOINT_BIAS: tau = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: m_upperLimit = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: m_lowerLimit = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: m_biasFactor = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: m_limitSoftness = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: m_relaxationFactor = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: m_motorTargetVelocity = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: m_maxMotorImpulse = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_MAX: break; // Can't happen, but silences warning
}
}
-real_t HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const {
+real_t HingeJoint3DSW::get_param(PhysicsServer3D::HingeJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS: return tau;
- case PhysicsServer::HINGE_JOINT_LIMIT_UPPER: return m_upperLimit;
- case PhysicsServer::HINGE_JOINT_LIMIT_LOWER: return m_lowerLimit;
- case PhysicsServer::HINGE_JOINT_LIMIT_BIAS: return m_biasFactor;
- case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS: return m_limitSoftness;
- case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: return m_relaxationFactor;
- case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: return m_motorTargetVelocity;
- case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: return m_maxMotorImpulse;
- case PhysicsServer::HINGE_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::HINGE_JOINT_BIAS: return tau;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: return m_upperLimit;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: return m_lowerLimit;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: return m_biasFactor;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: return m_limitSoftness;
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: return m_relaxationFactor;
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: return m_motorTargetVelocity;
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: return m_maxMotorImpulse;
+ case PhysicsServer3D::HINGE_JOINT_MAX: break; // Can't happen, but silences warning
}
return 0;
}
-void HingeJointSW::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) {
+void HingeJoint3DSW::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) {
switch (p_flag) {
- case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: m_useLimit = p_value; break;
- case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: m_enableAngularMotor = p_value; break;
- case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: m_useLimit = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: m_enableAngularMotor = p_value; break;
+ case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
}
}
-bool HingeJointSW::get_flag(PhysicsServer::HingeJointFlag p_flag) const {
+bool HingeJoint3DSW::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
switch (p_flag) {
- case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: return m_useLimit;
- case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: return m_enableAngularMotor;
- case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: return m_useLimit;
+ case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: return m_enableAngularMotor;
+ case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
}
return false;
diff --git a/servers/physics/joints/hinge_joint_sw.h b/servers/physics_3d/joints/hinge_joint_3d_sw.h
index 1c160cfc09..eebead20b8 100644
--- a/servers/physics/joints/hinge_joint_sw.h
+++ b/servers/physics_3d/joints/hinge_joint_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* hinge_joint_sw.h */
+/* hinge_joint_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library.
#ifndef HINGE_JOINT_SW_H
#define HINGE_JOINT_SW_H
-#include "servers/physics/joints/jacobian_entry_sw.h"
-#include "servers/physics/joints_sw.h"
+#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h"
+#include "servers/physics_3d/joints_3d_sw.h"
/*
Bullet Continuous Collision Detection and Physics Library
@@ -53,19 +53,19 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-class HingeJointSW : public JointSW {
+class HingeJoint3DSW : public Joint3DSW {
union {
struct {
- BodySW *A;
- BodySW *B;
+ Body3DSW *A;
+ Body3DSW *B;
};
- BodySW *_arr[2];
+ Body3DSW *_arr[2];
};
- JacobianEntrySW m_jac[3]; //3 orthogonal linear constraints
- JacobianEntrySW m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor
+ JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints
+ JacobianEntry3DSW m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor
Transform m_rbAFrame; // constraint axii. Assumes z is hinge axis.
Transform m_rbBFrame;
@@ -97,21 +97,21 @@ class HingeJointSW : public JointSW {
real_t m_appliedImpulse;
public:
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; }
virtual bool setup(real_t p_step);
virtual void solve(real_t p_step);
real_t get_hinge_angle();
- void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::HingeJointParam p_param) const;
+ void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::HingeJointParam p_param) const;
- void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value);
- bool get_flag(PhysicsServer::HingeJointFlag p_flag) const;
+ void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value);
+ bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const;
- HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, const Transform &frameB);
- HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);
+ HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameA, const Transform &frameB);
+ HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);
};
#endif // HINGE_JOINT_SW_H
diff --git a/servers/physics/joints/jacobian_entry_sw.h b/servers/physics_3d/joints/jacobian_entry_3d_sw.h
index a17175e6de..7e605ab173 100644
--- a/servers/physics/joints/jacobian_entry_sw.h
+++ b/servers/physics_3d/joints/jacobian_entry_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* jacobian_entry_sw.h */
+/* jacobian_entry_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -52,11 +52,11 @@ subject to the following restrictions:
#include "core/math/transform.h"
-class JacobianEntrySW {
+class JacobianEntry3DSW {
public:
- JacobianEntrySW(){};
+ JacobianEntry3DSW(){};
//constraint between two different rigidbodies
- JacobianEntrySW(
+ JacobianEntry3DSW(
const Basis &world2A,
const Basis &world2B,
const Vector3 &rel_pos1, const Vector3 &rel_pos2,
@@ -76,7 +76,7 @@ public:
}
//angular constraint between two different rigidbodies
- JacobianEntrySW(const Vector3 &jointAxis,
+ JacobianEntry3DSW(const Vector3 &jointAxis,
const Basis &world2A,
const Basis &world2B,
const Vector3 &inertiaInvA,
@@ -92,7 +92,7 @@ public:
}
//angular constraint between two different rigidbodies
- JacobianEntrySW(const Vector3 &axisInA,
+ JacobianEntry3DSW(const Vector3 &axisInA,
const Vector3 &axisInB,
const Vector3 &inertiaInvA,
const Vector3 &inertiaInvB) :
@@ -107,7 +107,7 @@ public:
}
//constraint on one rigidbody
- JacobianEntrySW(
+ JacobianEntry3DSW(
const Basis &world2A,
const Vector3 &rel_pos1, const Vector3 &rel_pos2,
const Vector3 &jointAxis,
@@ -126,16 +126,16 @@ public:
real_t getDiagonal() const { return m_Adiag; }
// for two constraints on the same rigidbody (for example vehicle friction)
- real_t getNonDiagonal(const JacobianEntrySW &jacB, const real_t massInvA) const {
- const JacobianEntrySW &jacA = *this;
+ real_t getNonDiagonal(const JacobianEntry3DSW &jacB, const real_t massInvA) const {
+ const JacobianEntry3DSW &jacA = *this;
real_t lin = massInvA * jacA.m_linearJointAxis.dot(jacB.m_linearJointAxis);
real_t ang = jacA.m_0MinvJt.dot(jacB.m_aJ);
return lin + ang;
}
// for two constraints on sharing two same rigidbodies (for example two contact points between two rigidbodies)
- real_t getNonDiagonal(const JacobianEntrySW &jacB, const real_t massInvA, const real_t massInvB) const {
- const JacobianEntrySW &jacA = *this;
+ real_t getNonDiagonal(const JacobianEntry3DSW &jacB, const real_t massInvA, const real_t massInvB) const {
+ const JacobianEntry3DSW &jacA = *this;
Vector3 lin = jacA.m_linearJointAxis * jacB.m_linearJointAxis;
Vector3 ang0 = jacA.m_0MinvJt * jacB.m_aJ;
Vector3 ang1 = jacA.m_1MinvJt * jacB.m_bJ;
diff --git a/servers/physics/joints/pin_joint_sw.cpp b/servers/physics_3d/joints/pin_joint_3d_sw.cpp
index fe994aa172..95c01bc463 100644
--- a/servers/physics/joints/pin_joint_sw.cpp
+++ b/servers/physics_3d/joints/pin_joint_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* pin_joint_sw.cpp */
+/* pin_joint_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -47,9 +47,9 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-#include "pin_joint_sw.h"
+#include "pin_joint_3d_sw.h"
-bool PinJointSW::setup(real_t p_step) {
+bool PinJoint3DSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
@@ -57,7 +57,7 @@ bool PinJointSW::setup(real_t p_step) {
for (int i = 0; i < 3; i++) {
normal[i] = 1;
- memnew_placement(&m_jac[i], JacobianEntrySW(
+ memnew_placement(&m_jac[i], JacobianEntry3DSW(
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
A->get_transform().xform(m_pivotInA) - A->get_transform().origin - A->get_center_of_mass(),
@@ -73,7 +73,7 @@ bool PinJointSW::setup(real_t p_step) {
return true;
}
-void PinJointSW::solve(real_t p_step) {
+void PinJoint3DSW::solve(real_t p_step) {
Vector3 pivotAInW = A->get_transform().xform(m_pivotInA);
Vector3 pivotBInW = B->get_transform().xform(m_pivotInB);
@@ -126,28 +126,28 @@ void PinJointSW::solve(real_t p_step) {
}
}
-void PinJointSW::set_param(PhysicsServer::PinJointParam p_param, real_t p_value) {
+void PinJoint3DSW::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::PIN_JOINT_BIAS: m_tau = p_value; break;
- case PhysicsServer::PIN_JOINT_DAMPING: m_damping = p_value; break;
- case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP: m_impulseClamp = p_value; break;
+ case PhysicsServer3D::PIN_JOINT_BIAS: m_tau = p_value; break;
+ case PhysicsServer3D::PIN_JOINT_DAMPING: m_damping = p_value; break;
+ case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: m_impulseClamp = p_value; break;
}
}
-real_t PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const {
+real_t PinJoint3DSW::get_param(PhysicsServer3D::PinJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::PIN_JOINT_BIAS: return m_tau;
- case PhysicsServer::PIN_JOINT_DAMPING: return m_damping;
- case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP: return m_impulseClamp;
+ case PhysicsServer3D::PIN_JOINT_BIAS: return m_tau;
+ case PhysicsServer3D::PIN_JOINT_DAMPING: return m_damping;
+ case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: return m_impulseClamp;
}
return 0;
}
-PinJointSW::PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b) :
- JointSW(_arr, 2) {
+PinJoint3DSW::PinJoint3DSW(Body3DSW *p_body_a, const Vector3 &p_pos_a, Body3DSW *p_body_b, const Vector3 &p_pos_b) :
+ Joint3DSW(_arr, 2) {
A = p_body_a;
B = p_body_b;
@@ -163,5 +163,5 @@ PinJointSW::PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_
B->add_constraint(this, 1);
}
-PinJointSW::~PinJointSW() {
+PinJoint3DSW::~PinJoint3DSW() {
}
diff --git a/servers/physics/joints/pin_joint_sw.h b/servers/physics_3d/joints/pin_joint_3d_sw.h
index 42884e4940..8e81ccf5e0 100644
--- a/servers/physics/joints/pin_joint_sw.h
+++ b/servers/physics_3d/joints/pin_joint_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* pin_joint_sw.h */
+/* pin_joint_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library.
#ifndef PIN_JOINT_SW_H
#define PIN_JOINT_SW_H
-#include "servers/physics/joints/jacobian_entry_sw.h"
-#include "servers/physics/joints_sw.h"
+#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h"
+#include "servers/physics_3d/joints_3d_sw.h"
/*
Bullet Continuous Collision Detection and Physics Library
@@ -53,15 +53,15 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-class PinJointSW : public JointSW {
+class PinJoint3DSW : public Joint3DSW {
union {
struct {
- BodySW *A;
- BodySW *B;
+ Body3DSW *A;
+ Body3DSW *B;
};
- BodySW *_arr[2];
+ Body3DSW *_arr[2];
};
real_t m_tau; //bias
@@ -69,19 +69,19 @@ class PinJointSW : public JointSW {
real_t m_impulseClamp;
real_t m_appliedImpulse;
- JacobianEntrySW m_jac[3]; //3 orthogonal linear constraints
+ JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints
Vector3 m_pivotInA;
Vector3 m_pivotInB;
public:
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_PIN; }
virtual bool setup(real_t p_step);
virtual void solve(real_t p_step);
- void set_param(PhysicsServer::PinJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::PinJointParam p_param) const;
+ void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::PinJointParam p_param) const;
void set_pos_a(const Vector3 &p_pos) { m_pivotInA = p_pos; }
void set_pos_b(const Vector3 &p_pos) { m_pivotInB = p_pos; }
@@ -89,8 +89,8 @@ public:
Vector3 get_position_a() { return m_pivotInA; }
Vector3 get_position_b() { return m_pivotInB; }
- PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b);
- ~PinJointSW();
+ PinJoint3DSW(Body3DSW *p_body_a, const Vector3 &p_pos_a, Body3DSW *p_body_b, const Vector3 &p_pos_b);
+ ~PinJoint3DSW();
};
#endif // PIN_JOINT_SW_H
diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics_3d/joints/slider_joint_3d_sw.cpp
index 9963c7ae89..066c30e0f3 100644
--- a/servers/physics/joints/slider_joint_sw.cpp
+++ b/servers/physics_3d/joints/slider_joint_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* slider_joint_sw.cpp */
+/* slider_joint_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -53,7 +53,7 @@ April 04, 2008
*/
-#include "slider_joint_sw.h"
+#include "slider_joint_3d_sw.h"
//-----------------------------------------------------------------------------
@@ -72,7 +72,7 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
return (y < 0.0f) ? -angle : angle;
}
-void SliderJointSW::initParams() {
+void SliderJoint3DSW::initParams() {
m_lowerLinLimit = real_t(1.0);
m_upperLinLimit = real_t(-1.0);
m_lowerAngLimit = real_t(0.);
@@ -112,8 +112,8 @@ void SliderJointSW::initParams() {
//-----------------------------------------------------------------------------
-SliderJointSW::SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB) :
- JointSW(_arr, 2),
+SliderJoint3DSW::SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB) :
+ Joint3DSW(_arr, 2),
m_frameInA(frameInA),
m_frameInB(frameInB) {
@@ -128,7 +128,7 @@ SliderJointSW::SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA
//-----------------------------------------------------------------------------
-bool SliderJointSW::setup(real_t p_step) {
+bool SliderJoint3DSW::setup(real_t p_step) {
//calculate transforms
m_calculatedTransformA = A->get_transform() * m_frameInA;
@@ -145,7 +145,7 @@ bool SliderJointSW::setup(real_t p_step) {
//linear part
for (i = 0; i < 3; i++) {
normalWorld = m_calculatedTransformA.basis.get_axis(i);
- memnew_placement(&m_jacLin[i], JacobianEntrySW(
+ memnew_placement(&m_jacLin[i], JacobianEntry3DSW(
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
m_relPosA - A->get_center_of_mass(),
@@ -162,7 +162,7 @@ bool SliderJointSW::setup(real_t p_step) {
// angular part
for (i = 0; i < 3; i++) {
normalWorld = m_calculatedTransformA.basis.get_axis(i);
- memnew_placement(&m_jacAng[i], JacobianEntrySW(
+ memnew_placement(&m_jacAng[i], JacobianEntry3DSW(
normalWorld,
A->get_principal_inertia_axes().transposed(),
B->get_principal_inertia_axes().transposed(),
@@ -181,7 +181,7 @@ bool SliderJointSW::setup(real_t p_step) {
//-----------------------------------------------------------------------------
-void SliderJointSW::solve(real_t p_step) {
+void SliderJoint3DSW::solve(real_t p_step) {
int i;
// linear
@@ -304,7 +304,7 @@ void SliderJointSW::solve(real_t p_step) {
//-----------------------------------------------------------------------------
-void SliderJointSW::calculateTransforms(void) {
+void SliderJoint3DSW::calculateTransforms(void) {
m_calculatedTransformA = A->get_transform() * m_frameInA;
m_calculatedTransformB = B->get_transform() * m_frameInB;
m_realPivotAInW = m_calculatedTransformA.origin;
@@ -323,7 +323,7 @@ void SliderJointSW::calculateTransforms(void) {
//-----------------------------------------------------------------------------
-void SliderJointSW::testLinLimits(void) {
+void SliderJoint3DSW::testLinLimits(void) {
m_solveLinLim = false;
m_linPos = m_depth[0];
if (m_lowerLinLimit <= m_upperLinLimit) {
@@ -343,7 +343,7 @@ void SliderJointSW::testLinLimits(void) {
//-----------------------------------------------------------------------------
-void SliderJointSW::testAngLimits(void) {
+void SliderJoint3DSW::testAngLimits(void) {
m_angDepth = real_t(0.);
m_solveAngLim = false;
if (m_lowerAngLimit <= m_upperAngLimit) {
@@ -363,7 +363,7 @@ void SliderJointSW::testAngLimits(void) {
//-----------------------------------------------------------------------------
-Vector3 SliderJointSW::getAncorInA(void) {
+Vector3 SliderJoint3DSW::getAncorInA(void) {
Vector3 ancorInA;
ancorInA = m_realPivotAInW + (m_lowerLinLimit + m_upperLinLimit) * real_t(0.5) * m_sliderAxis;
ancorInA = A->get_transform().inverse().xform(ancorInA);
@@ -372,71 +372,71 @@ Vector3 SliderJointSW::getAncorInA(void) {
//-----------------------------------------------------------------------------
-Vector3 SliderJointSW::getAncorInB(void) {
+Vector3 SliderJoint3DSW::getAncorInB(void) {
Vector3 ancorInB;
ancorInB = m_frameInB.origin;
return ancorInB;
} // SliderJointSW::getAncorInB();
-void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) {
+void SliderJoint3DSW::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: m_upperLinLimit = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: m_lowerLinLimit = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: m_softnessLimLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: m_restitutionLimLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: m_dampingLimLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: m_softnessDirLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: m_restitutionDirLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: m_dampingDirLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoLin = p_value; break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: m_dampingOrthoLin = p_value; break;
-
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: m_upperAngLimit = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: m_lowerAngLimit = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: m_softnessLimAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: m_restitutionLimAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: m_dampingLimAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: m_softnessDirAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: m_restitutionDirAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: m_dampingDirAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoAng = p_value; break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: m_dampingOrthoAng = p_value; break;
-
- case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: m_upperLinLimit = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: m_lowerLinLimit = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: m_softnessLimLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: m_restitutionLimLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: m_dampingLimLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: m_softnessDirLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: m_restitutionDirLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: m_dampingDirLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoLin = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: m_dampingOrthoLin = p_value; break;
+
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: m_upperAngLimit = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: m_lowerAngLimit = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: m_softnessLimAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: m_restitutionLimAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: m_dampingLimAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: m_softnessDirAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: m_restitutionDirAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: m_dampingDirAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoAng = p_value; break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: m_dampingOrthoAng = p_value; break;
+
+ case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
}
}
-real_t SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const {
+real_t SliderJoint3DSW::get_param(PhysicsServer3D::SliderJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return m_upperLinLimit;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return m_lowerLinLimit;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return m_softnessLimLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return m_restitutionLimLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return m_dampingLimLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return m_softnessDirLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return m_restitutionDirLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return m_dampingDirLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoLin;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return m_dampingOrthoLin;
-
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return m_upperAngLimit;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return m_lowerAngLimit;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return m_softnessLimAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return m_restitutionLimAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return m_dampingLimAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return m_softnessDirAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return m_restitutionDirAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return m_dampingDirAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoAng;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return m_dampingOrthoAng;
-
- case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return m_upperLinLimit;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return m_lowerLinLimit;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return m_softnessLimLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return m_restitutionLimLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return m_dampingLimLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return m_softnessDirLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return m_restitutionDirLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return m_dampingDirLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoLin;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return m_dampingOrthoLin;
+
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return m_upperAngLimit;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return m_lowerAngLimit;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return m_softnessLimAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return m_restitutionLimAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return m_dampingLimAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return m_softnessDirAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return m_restitutionDirAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return m_dampingDirAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoAng;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return m_dampingOrthoAng;
+
+ case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
}
return 0;
diff --git a/servers/physics/joints/slider_joint_sw.h b/servers/physics_3d/joints/slider_joint_3d_sw.h
index 8b416eafc9..18287db9c2 100644
--- a/servers/physics/joints/slider_joint_sw.h
+++ b/servers/physics_3d/joints/slider_joint_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* slider_joint_sw.h */
+/* slider_joint_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library.
#ifndef SLIDER_JOINT_SW_H
#define SLIDER_JOINT_SW_H
-#include "servers/physics/joints/jacobian_entry_sw.h"
-#include "servers/physics/joints_sw.h"
+#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h"
+#include "servers/physics_3d/joints_3d_sw.h"
/*
Bullet Continuous Collision Detection and Physics Library
@@ -65,15 +65,15 @@ April 04, 2008
//-----------------------------------------------------------------------------
-class SliderJointSW : public JointSW {
+class SliderJoint3DSW : public Joint3DSW {
protected:
union {
struct {
- BodySW *A;
- BodySW *B;
+ Body3DSW *A;
+ Body3DSW *B;
};
- BodySW *_arr[2];
+ Body3DSW *_arr[2];
};
Transform m_frameInA;
@@ -114,10 +114,10 @@ protected:
bool m_solveLinLim;
bool m_solveAngLim;
- JacobianEntrySW m_jacLin[3];
+ JacobianEntry3DSW m_jacLin[3];
real_t m_jacLinDiagABInv[3];
- JacobianEntrySW m_jacAng[3];
+ JacobianEntry3DSW m_jacAng[3];
real_t m_timeStep;
Transform m_calculatedTransformA;
@@ -152,13 +152,13 @@ protected:
public:
// constructors
- SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB);
+ SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB);
//SliderJointSW();
// overrides
// access
- const BodySW *getRigidBodyA() const { return A; }
- const BodySW *getRigidBodyB() const { return B; }
+ const Body3DSW *getRigidBodyA() const { return A; }
+ const Body3DSW *getRigidBodyB() const { return B; }
const Transform &getCalculatedTransformA() const { return m_calculatedTransformA; }
const Transform &getCalculatedTransformB() const { return m_calculatedTransformB; }
const Transform &getFrameOffsetA() const { return m_frameInA; }
@@ -237,13 +237,13 @@ public:
Vector3 getAncorInA(void);
Vector3 getAncorInB(void);
- void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::SliderJointParam p_param) const;
+ void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::SliderJointParam p_param) const;
bool setup(real_t p_step);
void solve(real_t p_step);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; }
};
#endif // SLIDER_JOINT_SW_H
diff --git a/servers/physics/joints_sw.h b/servers/physics_3d/joints_3d_sw.h
index c284d541e3..435ee2301d 100644
--- a/servers/physics/joints_sw.h
+++ b/servers/physics_3d/joints_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* joints_sw.h */
+/* joints_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,15 +31,15 @@
#ifndef JOINTS_SW_H
#define JOINTS_SW_H
-#include "body_sw.h"
-#include "constraint_sw.h"
+#include "body_3d_sw.h"
+#include "constraint_3d_sw.h"
-class JointSW : public ConstraintSW {
+class Joint3DSW : public Constraint3DSW {
public:
- virtual PhysicsServer::JointType get_type() const = 0;
- _FORCE_INLINE_ JointSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) :
- ConstraintSW(p_body_ptr, p_body_count) {
+ virtual PhysicsServer3D::JointType get_type() const = 0;
+ _FORCE_INLINE_ Joint3DSW(Body3DSW **p_body_ptr = NULL, int p_body_count = 0) :
+ Constraint3DSW(p_body_ptr, p_body_count) {
}
};
diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp
new file mode 100644
index 0000000000..da84630088
--- /dev/null
+++ b/servers/physics_3d/physics_server_3d_sw.cpp
@@ -0,0 +1,1589 @@
+/*************************************************************************/
+/* physics_server_3d_sw.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "physics_server_3d_sw.h"
+
+#include "broad_phase_3d_basic.h"
+#include "broad_phase_octree.h"
+#include "core/debugger/engine_debugger.h"
+#include "core/os/os.h"
+#include "joints/cone_twist_joint_3d_sw.h"
+#include "joints/generic_6dof_joint_3d_sw.h"
+#include "joints/hinge_joint_3d_sw.h"
+#include "joints/pin_joint_3d_sw.h"
+#include "joints/slider_joint_3d_sw.h"
+
+#define FLUSH_QUERY_CHECK(m_object) \
+ ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
+
+RID PhysicsServer3DSW::shape_create(ShapeType p_shape) {
+
+ Shape3DSW *shape = NULL;
+ switch (p_shape) {
+
+ case SHAPE_PLANE: {
+
+ shape = memnew(PlaneShape3DSW);
+ } break;
+ case SHAPE_RAY: {
+
+ shape = memnew(RayShape3DSW);
+ } break;
+ case SHAPE_SPHERE: {
+
+ shape = memnew(SphereShape3DSW);
+ } break;
+ case SHAPE_BOX: {
+
+ shape = memnew(BoxShape3DSW);
+ } break;
+ case SHAPE_CAPSULE: {
+
+ shape = memnew(CapsuleShape3DSW);
+ } break;
+ case SHAPE_CYLINDER: {
+
+ ERR_FAIL_V_MSG(RID(), "CylinderShape is not supported in GodotPhysics. Please switch to Bullet in the Project Settings.");
+ } break;
+ case SHAPE_CONVEX_POLYGON: {
+
+ shape = memnew(ConvexPolygonShape3DSW);
+ } break;
+ case SHAPE_CONCAVE_POLYGON: {
+
+ shape = memnew(ConcavePolygonShape3DSW);
+ } break;
+ case SHAPE_HEIGHTMAP: {
+
+ shape = memnew(HeightMapShape3DSW);
+ } break;
+ case SHAPE_CUSTOM: {
+
+ ERR_FAIL_V(RID());
+
+ } break;
+ }
+
+ RID id = shape_owner.make_rid(shape);
+ shape->set_self(id);
+
+ return id;
+};
+
+void PhysicsServer3DSW::shape_set_data(RID p_shape, const Variant &p_data) {
+
+ Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND(!shape);
+ shape->set_data(p_data);
+};
+
+void PhysicsServer3DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
+
+ Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND(!shape);
+ shape->set_custom_bias(p_bias);
+}
+
+PhysicsServer3D::ShapeType PhysicsServer3DSW::shape_get_type(RID p_shape) const {
+
+ const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
+ return shape->get_type();
+};
+
+Variant PhysicsServer3DSW::shape_get_data(RID p_shape) const {
+
+ const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND_V(!shape, Variant());
+ ERR_FAIL_COND_V(!shape->is_configured(), Variant());
+ return shape->get_data();
+};
+
+void PhysicsServer3DSW::shape_set_margin(RID p_shape, real_t p_margin) {
+}
+
+real_t PhysicsServer3DSW::shape_get_margin(RID p_shape) const {
+ return 0.0;
+}
+
+real_t PhysicsServer3DSW::shape_get_custom_solver_bias(RID p_shape) const {
+
+ const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND_V(!shape, 0);
+ return shape->get_custom_bias();
+}
+
+RID PhysicsServer3DSW::space_create() {
+
+ Space3DSW *space = memnew(Space3DSW);
+ RID id = space_owner.make_rid(space);
+ space->set_self(id);
+ RID area_id = area_create();
+ Area3DSW *area = area_owner.getornull(area_id);
+ ERR_FAIL_COND_V(!area, RID());
+ space->set_default_area(area);
+ area->set_space(space);
+ area->set_priority(-1);
+ RID sgb = body_create();
+ body_set_space(sgb, id);
+ body_set_mode(sgb, BODY_MODE_STATIC);
+ space->set_static_global_body(sgb);
+
+ return id;
+};
+
+void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) {
+
+ Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND(!space);
+ if (p_active)
+ active_spaces.insert(space);
+ else
+ active_spaces.erase(space);
+}
+
+bool PhysicsServer3DSW::space_is_active(RID p_space) const {
+
+ const Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND_V(!space, false);
+
+ return active_spaces.has(space);
+}
+
+void PhysicsServer3DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+
+ Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND(!space);
+
+ space->set_param(p_param, p_value);
+}
+
+real_t PhysicsServer3DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
+
+ const Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND_V(!space, 0);
+ return space->get_param(p_param);
+}
+
+PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space) {
+
+ Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND_V(!space, NULL);
+ ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification.");
+
+ return space->get_direct_state();
+}
+
+void PhysicsServer3DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
+
+ Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND(!space);
+ space->set_debug_contacts(p_max_contacts);
+}
+
+Vector<Vector3> PhysicsServer3DSW::space_get_contacts(RID p_space) const {
+
+ Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND_V(!space, Vector<Vector3>());
+ return space->get_debug_contacts();
+}
+
+int PhysicsServer3DSW::space_get_contact_count(RID p_space) const {
+
+ Space3DSW *space = space_owner.getornull(p_space);
+ ERR_FAIL_COND_V(!space, 0);
+ return space->get_debug_contact_count();
+}
+
+RID PhysicsServer3DSW::area_create() {
+
+ Area3DSW *area = memnew(Area3DSW);
+ RID rid = area_owner.make_rid(area);
+ area->set_self(rid);
+ return rid;
+};
+
+void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ Space3DSW *space = NULL;
+ if (p_space.is_valid()) {
+ space = space_owner.getornull(p_space);
+ ERR_FAIL_COND(!space);
+ }
+
+ if (area->get_space() == space)
+ return; //pointless
+
+ area->clear_constraints();
+ area->set_space(space);
+};
+
+RID PhysicsServer3DSW::area_get_space(RID p_area) const {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, RID());
+
+ Space3DSW *space = area->get_space();
+ if (!space)
+ return RID();
+ return space->get_self();
+};
+
+void PhysicsServer3DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_space_override_mode(p_mode);
+}
+
+PhysicsServer3D::AreaSpaceOverrideMode PhysicsServer3DSW::area_get_space_override_mode(RID p_area) const {
+
+ const Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
+
+ return area->get_space_override_mode();
+}
+
+void PhysicsServer3DSW::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND(!shape);
+
+ area->add_shape(shape, p_transform, p_disabled);
+}
+
+void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND(!shape);
+ ERR_FAIL_COND(!shape->is_configured());
+
+ area->set_shape(p_shape_idx, shape);
+}
+
+void PhysicsServer3DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_shape_transform(p_shape_idx, p_transform);
+}
+
+int PhysicsServer3DSW::area_get_shape_count(RID p_area) const {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, -1);
+
+ return area->get_shape_count();
+}
+RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, RID());
+
+ Shape3DSW *shape = area->get_shape(p_shape_idx);
+ ERR_FAIL_COND_V(!shape, RID());
+
+ return shape->get_self();
+}
+Transform PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, Transform());
+
+ return area->get_shape_transform(p_shape_idx);
+}
+
+void PhysicsServer3DSW::area_remove_shape(RID p_area, int p_shape_idx) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->remove_shape(p_shape_idx);
+}
+
+void PhysicsServer3DSW::area_clear_shapes(RID p_area) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ while (area->get_shape_count())
+ area->remove_shape(0);
+}
+
+void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+ ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count());
+ FLUSH_QUERY_CHECK(area);
+ area->set_shape_as_disabled(p_shape_idx, p_disabled);
+}
+
+void PhysicsServer3DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
+
+ if (space_owner.owns(p_area)) {
+ Space3DSW *space = space_owner.getornull(p_area);
+ p_area = space->get_default_area()->get_self();
+ }
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+ area->set_instance_id(p_id);
+}
+ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const {
+
+ if (space_owner.owns(p_area)) {
+ Space3DSW *space = space_owner.getornull(p_area);
+ p_area = space->get_default_area()->get_self();
+ }
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, ObjectID());
+ return area->get_instance_id();
+}
+
+void PhysicsServer3DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+
+ if (space_owner.owns(p_area)) {
+ Space3DSW *space = space_owner.getornull(p_area);
+ p_area = space->get_default_area()->get_self();
+ }
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+ area->set_param(p_param, p_value);
+};
+
+void PhysicsServer3DSW::area_set_transform(RID p_area, const Transform &p_transform) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+ area->set_transform(p_transform);
+};
+
+Variant PhysicsServer3DSW::area_get_param(RID p_area, AreaParameter p_param) const {
+
+ if (space_owner.owns(p_area)) {
+ Space3DSW *space = space_owner.getornull(p_area);
+ p_area = space->get_default_area()->get_self();
+ }
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, Variant());
+
+ return area->get_param(p_param);
+};
+
+Transform PhysicsServer3DSW::area_get_transform(RID p_area) const {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, Transform());
+
+ return area->get_transform();
+};
+
+void PhysicsServer3DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_collision_layer(p_layer);
+}
+
+void PhysicsServer3DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_collision_mask(p_mask);
+}
+
+void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+ FLUSH_QUERY_CHECK(area);
+
+ area->set_monitorable(p_monitorable);
+}
+
+void PhysicsServer3DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
+}
+
+void PhysicsServer3DSW::area_set_ray_pickable(RID p_area, bool p_enable) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_ray_pickable(p_enable);
+}
+
+bool PhysicsServer3DSW::area_is_ray_pickable(RID p_area) const {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND_V(!area, false);
+
+ return area->is_ray_pickable();
+}
+
+void PhysicsServer3DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+
+ Area3DSW *area = area_owner.getornull(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
+}
+
+/* BODY API */
+
+RID PhysicsServer3DSW::body_create(BodyMode p_mode, bool p_init_sleeping) {
+
+ Body3DSW *body = memnew(Body3DSW);
+ if (p_mode != BODY_MODE_RIGID)
+ body->set_mode(p_mode);
+ if (p_init_sleeping)
+ body->set_state(BODY_STATE_SLEEPING, p_init_sleeping);
+ RID rid = body_owner.make_rid(body);
+ body->set_self(rid);
+ return rid;
+};
+
+void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ Space3DSW *space = NULL;
+ if (p_space.is_valid()) {
+ space = space_owner.getornull(p_space);
+ ERR_FAIL_COND(!space);
+ }
+
+ if (body->get_space() == space)
+ return; //pointless
+
+ body->clear_constraint_map();
+ body->set_space(space);
+};
+
+RID PhysicsServer3DSW::body_get_space(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, RID());
+
+ Space3DSW *space = body->get_space();
+ if (!space)
+ return RID();
+ return space->get_self();
+};
+
+void PhysicsServer3DSW::body_set_mode(RID p_body, BodyMode p_mode) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_mode(p_mode);
+};
+
+PhysicsServer3D::BodyMode PhysicsServer3DSW::body_get_mode(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
+
+ return body->get_mode();
+};
+
+void PhysicsServer3DSW::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND(!shape);
+
+ body->add_shape(shape, p_transform, p_disabled);
+}
+
+void PhysicsServer3DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ Shape3DSW *shape = shape_owner.getornull(p_shape);
+ ERR_FAIL_COND(!shape);
+ ERR_FAIL_COND(!shape->is_configured());
+
+ body->set_shape(p_shape_idx, shape);
+}
+void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_shape_transform(p_shape_idx, p_transform);
+}
+
+int PhysicsServer3DSW::body_get_shape_count(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, -1);
+
+ return body->get_shape_count();
+}
+RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, RID());
+
+ Shape3DSW *shape = body->get_shape(p_shape_idx);
+ ERR_FAIL_COND_V(!shape, RID());
+
+ return shape->get_self();
+}
+
+void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+ ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
+ FLUSH_QUERY_CHECK(body);
+
+ body->set_shape_as_disabled(p_shape_idx, p_disabled);
+}
+
+Transform PhysicsServer3DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, Transform());
+
+ return body->get_shape_transform(p_shape_idx);
+}
+
+void PhysicsServer3DSW::body_remove_shape(RID p_body, int p_shape_idx) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->remove_shape(p_shape_idx);
+}
+
+void PhysicsServer3DSW::body_clear_shapes(RID p_body) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ while (body->get_shape_count())
+ body->remove_shape(0);
+}
+
+void PhysicsServer3DSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_continuous_collision_detection(p_enable);
+}
+
+bool PhysicsServer3DSW::body_is_continuous_collision_detection_enabled(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, false);
+
+ return body->is_continuous_collision_detection_enabled();
+}
+
+void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_collision_layer(p_layer);
+ body->wakeup();
+}
+
+uint32_t PhysicsServer3DSW::body_get_collision_layer(RID p_body) const {
+
+ const Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+
+ return body->get_collision_layer();
+}
+
+void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_collision_mask(p_mask);
+ body->wakeup();
+}
+
+uint32_t PhysicsServer3DSW::body_get_collision_mask(RID p_body) const {
+
+ const Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+
+ return body->get_collision_mask();
+}
+
+void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_instance_id(p_id);
+};
+
+ObjectID PhysicsServer3DSW::body_get_object_instance_id(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, ObjectID());
+
+ return body->get_instance_id();
+};
+
+void PhysicsServer3DSW::body_set_user_flags(RID p_body, uint32_t p_flags) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+};
+
+uint32_t PhysicsServer3DSW::body_get_user_flags(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+
+ return 0;
+};
+
+void PhysicsServer3DSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_param(p_param, p_value);
+};
+
+real_t PhysicsServer3DSW::body_get_param(RID p_body, BodyParameter p_param) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+
+ return body->get_param(p_param);
+};
+
+void PhysicsServer3DSW::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+ body->set_kinematic_margin(p_margin);
+}
+
+real_t PhysicsServer3DSW::body_get_kinematic_safe_margin(RID p_body) const {
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+
+ return body->get_kinematic_margin();
+}
+
+void PhysicsServer3DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_state(p_state, p_variant);
+};
+
+Variant PhysicsServer3DSW::body_get_state(RID p_body, BodyState p_state) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, Variant());
+
+ return body->get_state(p_state);
+};
+
+void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_force) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_applied_force(p_force);
+ body->wakeup();
+};
+
+Vector3 PhysicsServer3DSW::body_get_applied_force(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, Vector3());
+ return body->get_applied_force();
+};
+
+void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_applied_torque(p_torque);
+ body->wakeup();
+};
+
+Vector3 PhysicsServer3DSW::body_get_applied_torque(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, Vector3());
+
+ return body->get_applied_torque();
+};
+
+void PhysicsServer3DSW::body_add_central_force(RID p_body, const Vector3 &p_force) {
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->add_central_force(p_force);
+ body->wakeup();
+}
+
+void PhysicsServer3DSW::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->add_force(p_force, p_pos);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_add_torque(RID p_body, const Vector3 &p_torque) {
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->add_torque(p_torque);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ _update_shapes();
+
+ body->apply_central_impulse(p_impulse);
+ body->wakeup();
+}
+
+void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ _update_shapes();
+
+ body->apply_impulse(p_pos, p_impulse);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ _update_shapes();
+
+ body->apply_torque_impulse(p_impulse);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ _update_shapes();
+
+ Vector3 v = body->get_linear_velocity();
+ Vector3 axis = p_axis_velocity.normalized();
+ v -= axis * axis.dot(v);
+ v += p_axis_velocity;
+ body->set_linear_velocity(v);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_axis_lock(p_axis, p_lock);
+ body->wakeup();
+}
+
+bool PhysicsServer3DSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
+
+ const Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+ return body->is_axis_locked(p_axis);
+}
+
+void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->add_exception(p_body_b);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->remove_exception(p_body_b);
+ body->wakeup();
+};
+
+void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ for (int i = 0; i < body->get_exceptions().size(); i++) {
+ p_exceptions->push_back(body->get_exceptions()[i]);
+ }
+};
+
+void PhysicsServer3DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+};
+
+real_t PhysicsServer3DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, 0);
+ return 0;
+};
+
+void PhysicsServer3DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->set_omit_force_integration(p_omit);
+};
+
+bool PhysicsServer3DSW::body_is_omitting_force_integration(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, false);
+ return body->get_omit_force_integration();
+};
+
+void PhysicsServer3DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+ body->set_max_contacts_reported(p_contacts);
+}
+
+int PhysicsServer3DSW::body_get_max_contacts_reported(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, -1);
+ return body->get_max_contacts_reported();
+}
+
+void PhysicsServer3DSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+ body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
+}
+
+void PhysicsServer3DSW::body_set_ray_pickable(RID p_body, bool p_enable) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND(!body);
+ body->set_ray_pickable(p_enable);
+}
+
+bool PhysicsServer3DSW::body_is_ray_pickable(RID p_body) const {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, false);
+ return body->is_ray_pickable();
+}
+
+bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, false);
+ ERR_FAIL_COND_V(!body->get_space(), false);
+ ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
+
+ _update_shapes();
+
+ return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, body->get_kinematic_margin(), r_result, p_exclude_raycast_shapes);
+}
+
+int PhysicsServer3DSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, false);
+ ERR_FAIL_COND_V(!body->get_space(), false);
+ ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
+
+ _update_shapes();
+
+ return body->get_space()->test_body_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
+}
+
+PhysicsDirectBodyState3D *PhysicsServer3DSW::body_get_direct_state(RID p_body) {
+
+ Body3DSW *body = body_owner.getornull(p_body);
+ ERR_FAIL_COND_V(!body, NULL);
+ ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification.");
+
+ direct_state->body = body;
+ return direct_state;
+}
+
+/* JOINT API */
+
+RID PhysicsServer3DSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
+
+ Body3DSW *body_A = body_owner.getornull(p_body_A);
+ ERR_FAIL_COND_V(!body_A, RID());
+
+ if (!p_body_B.is_valid()) {
+ ERR_FAIL_COND_V(!body_A->get_space(), RID());
+ p_body_B = body_A->get_space()->get_static_global_body();
+ }
+
+ Body3DSW *body_B = body_owner.getornull(p_body_B);
+ ERR_FAIL_COND_V(!body_B, RID());
+
+ ERR_FAIL_COND_V(body_A == body_B, RID());
+
+ Joint3DSW *joint = memnew(PinJoint3DSW(body_A, p_local_A, body_B, p_local_B));
+ RID rid = joint_owner.make_rid(joint);
+ joint->set_self(rid);
+ return rid;
+}
+
+void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
+ PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
+ pin_joint->set_param(p_param, p_value);
+}
+real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, 0);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
+ PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
+ return pin_joint->get_param(p_param);
+}
+
+void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
+ PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
+ pin_joint->set_pos_a(p_A);
+}
+Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, Vector3());
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
+ PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
+ return pin_joint->get_position_a();
+}
+
+void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
+ PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
+ pin_joint->set_pos_b(p_B);
+}
+Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, Vector3());
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
+ PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
+ return pin_joint->get_position_b();
+}
+
+RID PhysicsServer3DSW::joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B) {
+
+ Body3DSW *body_A = body_owner.getornull(p_body_A);
+ ERR_FAIL_COND_V(!body_A, RID());
+
+ if (!p_body_B.is_valid()) {
+ ERR_FAIL_COND_V(!body_A->get_space(), RID());
+ p_body_B = body_A->get_space()->get_static_global_body();
+ }
+
+ Body3DSW *body_B = body_owner.getornull(p_body_B);
+ ERR_FAIL_COND_V(!body_B, RID());
+
+ ERR_FAIL_COND_V(body_A == body_B, RID());
+
+ Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_frame_A, p_frame_B));
+ RID rid = joint_owner.make_rid(joint);
+ joint->set_self(rid);
+ return rid;
+}
+
+RID PhysicsServer3DSW::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
+
+ Body3DSW *body_A = body_owner.getornull(p_body_A);
+ ERR_FAIL_COND_V(!body_A, RID());
+
+ if (!p_body_B.is_valid()) {
+ ERR_FAIL_COND_V(!body_A->get_space(), RID());
+ p_body_B = body_A->get_space()->get_static_global_body();
+ }
+
+ Body3DSW *body_B = body_owner.getornull(p_body_B);
+ ERR_FAIL_COND_V(!body_B, RID());
+
+ ERR_FAIL_COND_V(body_A == body_B, RID());
+
+ Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B));
+ RID rid = joint_owner.make_rid(joint);
+ joint->set_self(rid);
+ return rid;
+}
+
+void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
+ HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
+ hinge_joint->set_param(p_param, p_value);
+}
+real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, 0);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
+ HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
+ return hinge_joint->get_param(p_param);
+}
+
+void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
+ HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
+ hinge_joint->set_flag(p_flag, p_value);
+}
+bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, false);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
+ HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
+ return hinge_joint->get_flag(p_flag);
+}
+
+void PhysicsServer3DSW::joint_set_solver_priority(RID p_joint, int p_priority) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ joint->set_priority(p_priority);
+}
+
+int PhysicsServer3DSW::joint_get_solver_priority(RID p_joint) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, 0);
+ return joint->get_priority();
+}
+
+void PhysicsServer3DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+
+ joint->disable_collisions_between_bodies(p_disable);
+
+ if (2 == joint->get_body_count()) {
+ Body3DSW *body_a = *joint->get_body_ptr();
+ Body3DSW *body_b = *(joint->get_body_ptr() + 1);
+
+ if (p_disable) {
+ body_add_collision_exception(body_a->get_self(), body_b->get_self());
+ body_add_collision_exception(body_b->get_self(), body_a->get_self());
+ } else {
+ body_remove_collision_exception(body_a->get_self(), body_b->get_self());
+ body_remove_collision_exception(body_b->get_self(), body_a->get_self());
+ }
+ }
+}
+
+bool PhysicsServer3DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, true);
+
+ return joint->is_disabled_collisions_between_bodies();
+}
+
+PhysicsServer3DSW::JointType PhysicsServer3DSW::joint_get_type(RID p_joint) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, JOINT_PIN);
+ return joint->get_type();
+}
+
+RID PhysicsServer3DSW::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+
+ Body3DSW *body_A = body_owner.getornull(p_body_A);
+ ERR_FAIL_COND_V(!body_A, RID());
+
+ if (!p_body_B.is_valid()) {
+ ERR_FAIL_COND_V(!body_A->get_space(), RID());
+ p_body_B = body_A->get_space()->get_static_global_body();
+ }
+
+ Body3DSW *body_B = body_owner.getornull(p_body_B);
+ ERR_FAIL_COND_V(!body_B, RID());
+
+ ERR_FAIL_COND_V(body_A == body_B, RID());
+
+ Joint3DSW *joint = memnew(SliderJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
+ RID rid = joint_owner.make_rid(joint);
+ joint->set_self(rid);
+ return rid;
+}
+
+void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
+ SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
+ slider_joint->set_param(p_param, p_value);
+}
+real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, 0);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0);
+ SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
+ return slider_joint->get_param(p_param);
+}
+
+RID PhysicsServer3DSW::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+
+ Body3DSW *body_A = body_owner.getornull(p_body_A);
+ ERR_FAIL_COND_V(!body_A, RID());
+
+ if (!p_body_B.is_valid()) {
+ ERR_FAIL_COND_V(!body_A->get_space(), RID());
+ p_body_B = body_A->get_space()->get_static_global_body();
+ }
+
+ Body3DSW *body_B = body_owner.getornull(p_body_B);
+ ERR_FAIL_COND_V(!body_B, RID());
+
+ ERR_FAIL_COND_V(body_A == body_B, RID());
+
+ Joint3DSW *joint = memnew(ConeTwistJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
+ RID rid = joint_owner.make_rid(joint);
+ joint->set_self(rid);
+ return rid;
+}
+
+void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
+ ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
+ cone_twist_joint->set_param(p_param, p_value);
+}
+real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, 0);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0);
+ ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
+ return cone_twist_joint->get_param(p_param);
+}
+
+RID PhysicsServer3DSW::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+
+ Body3DSW *body_A = body_owner.getornull(p_body_A);
+ ERR_FAIL_COND_V(!body_A, RID());
+
+ if (!p_body_B.is_valid()) {
+ ERR_FAIL_COND_V(!body_A->get_space(), RID());
+ p_body_B = body_A->get_space()->get_static_global_body();
+ }
+
+ Body3DSW *body_B = body_owner.getornull(p_body_B);
+ ERR_FAIL_COND_V(!body_B, RID());
+
+ ERR_FAIL_COND_V(body_A == body_B, RID());
+
+ Joint3DSW *joint = memnew(Generic6DOFJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B, true));
+ RID rid = joint_owner.make_rid(joint);
+ joint->set_self(rid);
+ return rid;
+}
+
+void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
+ Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
+ generic_6dof_joint->set_param(p_axis, p_param, p_value);
+}
+real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, 0);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
+ Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
+ return generic_6dof_joint->get_param(p_axis, p_param);
+}
+
+void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND(!joint);
+ ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
+ Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
+ generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
+}
+bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_joint);
+ ERR_FAIL_COND_V(!joint, false);
+ ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
+ Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
+ return generic_6dof_joint->get_flag(p_axis, p_flag);
+}
+
+void PhysicsServer3DSW::free(RID p_rid) {
+
+ _update_shapes(); //just in case
+
+ if (shape_owner.owns(p_rid)) {
+
+ Shape3DSW *shape = shape_owner.getornull(p_rid);
+
+ while (shape->get_owners().size()) {
+ ShapeOwner3DSW *so = shape->get_owners().front()->key();
+ so->remove_shape(shape);
+ }
+
+ shape_owner.free(p_rid);
+ memdelete(shape);
+ } else if (body_owner.owns(p_rid)) {
+
+ Body3DSW *body = body_owner.getornull(p_rid);
+
+ /*
+ if (body->get_state_query())
+ _clear_query(body->get_state_query());
+
+ if (body->get_direct_state_query())
+ _clear_query(body->get_direct_state_query());
+ */
+
+ body->set_space(NULL);
+
+ while (body->get_shape_count()) {
+
+ body->remove_shape(0);
+ }
+
+ body_owner.free(p_rid);
+ memdelete(body);
+
+ } else if (area_owner.owns(p_rid)) {
+
+ Area3DSW *area = area_owner.getornull(p_rid);
+
+ /*
+ if (area->get_monitor_query())
+ _clear_query(area->get_monitor_query());
+ */
+
+ area->set_space(NULL);
+
+ while (area->get_shape_count()) {
+
+ area->remove_shape(0);
+ }
+
+ area_owner.free(p_rid);
+ memdelete(area);
+ } else if (space_owner.owns(p_rid)) {
+
+ Space3DSW *space = space_owner.getornull(p_rid);
+
+ while (space->get_objects().size()) {
+ CollisionObject3DSW *co = (CollisionObject3DSW *)space->get_objects().front()->get();
+ co->set_space(NULL);
+ }
+
+ active_spaces.erase(space);
+ free(space->get_default_area()->get_self());
+ free(space->get_static_global_body());
+
+ space_owner.free(p_rid);
+ memdelete(space);
+ } else if (joint_owner.owns(p_rid)) {
+
+ Joint3DSW *joint = joint_owner.getornull(p_rid);
+
+ for (int i = 0; i < joint->get_body_count(); i++) {
+
+ joint->get_body_ptr()[i]->remove_constraint(joint);
+ }
+ joint_owner.free(p_rid);
+ memdelete(joint);
+
+ } else {
+
+ ERR_FAIL_MSG("Invalid ID.");
+ }
+};
+
+void PhysicsServer3DSW::set_active(bool p_active) {
+
+ active = p_active;
+};
+
+void PhysicsServer3DSW::init() {
+
+ doing_sync = true;
+ last_step = 0.001;
+ iterations = 8; // 8?
+ stepper = memnew(Step3DSW);
+ direct_state = memnew(PhysicsDirectBodyState3DSW);
+};
+
+void PhysicsServer3DSW::step(real_t p_step) {
+
+#ifndef _3D_DISABLED
+
+ if (!active)
+ return;
+
+ _update_shapes();
+
+ doing_sync = false;
+
+ last_step = p_step;
+ PhysicsDirectBodyState3DSW::singleton->step = p_step;
+
+ island_count = 0;
+ active_objects = 0;
+ collision_pairs = 0;
+ for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
+
+ stepper->step((Space3DSW *)E->get(), p_step, iterations);
+ island_count += E->get()->get_island_count();
+ active_objects += E->get()->get_active_objects();
+ collision_pairs += E->get()->get_collision_pairs();
+ }
+#endif
+}
+
+void PhysicsServer3DSW::sync(){
+
+};
+
+void PhysicsServer3DSW::flush_queries() {
+
+#ifndef _3D_DISABLED
+
+ if (!active)
+ return;
+
+ doing_sync = true;
+
+ flushing_queries = true;
+
+ uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
+
+ for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
+
+ Space3DSW *space = (Space3DSW *)E->get();
+ space->call_queries();
+ }
+
+ flushing_queries = false;
+
+ if (EngineDebugger::is_profiling("servers")) {
+
+ uint64_t total_time[Space3DSW::ELAPSED_TIME_MAX];
+ static const char *time_name[Space3DSW::ELAPSED_TIME_MAX] = {
+ "integrate_forces",
+ "generate_islands",
+ "setup_constraints",
+ "solve_constraints",
+ "integrate_velocities"
+ };
+
+ for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) {
+ total_time[i] = 0;
+ }
+
+ for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
+
+ for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) {
+ total_time[i] += E->get()->get_elapsed_time(Space3DSW::ElapsedTime(i));
+ }
+ }
+
+ Array values;
+ values.resize(Space3DSW::ELAPSED_TIME_MAX * 2);
+ for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) {
+ values[i * 2 + 0] = time_name[i];
+ values[i * 2 + 1] = USEC_TO_SEC(total_time[i]);
+ }
+ values.push_back("flush_queries");
+ values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec() - time_beg));
+
+ values.push_front("physics");
+ EngineDebugger::profiler_add_frame_data("server", values);
+ }
+#endif
+};
+
+void PhysicsServer3DSW::finish() {
+
+ memdelete(stepper);
+ memdelete(direct_state);
+};
+
+int PhysicsServer3DSW::get_process_info(ProcessInfo p_info) {
+
+ switch (p_info) {
+
+ case INFO_ACTIVE_OBJECTS: {
+
+ return active_objects;
+ } break;
+ case INFO_COLLISION_PAIRS: {
+ return collision_pairs;
+ } break;
+ case INFO_ISLAND_COUNT: {
+
+ return island_count;
+ } break;
+ }
+
+ return 0;
+}
+
+void PhysicsServer3DSW::_update_shapes() {
+
+ while (pending_shape_update_list.first()) {
+ pending_shape_update_list.first()->self()->_shape_changed();
+ pending_shape_update_list.remove(pending_shape_update_list.first());
+ }
+}
+
+void PhysicsServer3DSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
+
+ CollCbkData *cbk = (CollCbkData *)p_userdata;
+
+ if (cbk->max == 0)
+ return;
+
+ if (cbk->amount == cbk->max) {
+ //find least deep
+ real_t min_depth = 1e20;
+ int min_depth_idx = 0;
+ for (int i = 0; i < cbk->amount; i++) {
+
+ real_t d = cbk->ptr[i * 2 + 0].distance_squared_to(cbk->ptr[i * 2 + 1]);
+ if (d < min_depth) {
+ min_depth = d;
+ min_depth_idx = i;
+ }
+ }
+
+ real_t d = p_point_A.distance_squared_to(p_point_B);
+ if (d < min_depth)
+ return;
+ cbk->ptr[min_depth_idx * 2 + 0] = p_point_A;
+ cbk->ptr[min_depth_idx * 2 + 1] = p_point_B;
+
+ } else {
+
+ cbk->ptr[cbk->amount * 2 + 0] = p_point_A;
+ cbk->ptr[cbk->amount * 2 + 1] = p_point_B;
+ cbk->amount++;
+ }
+}
+
+PhysicsServer3DSW *PhysicsServer3DSW::singleton = NULL;
+PhysicsServer3DSW::PhysicsServer3DSW() {
+ singleton = this;
+ BroadPhase3DSW::create_func = BroadPhaseOctree::_create;
+ island_count = 0;
+ active_objects = 0;
+ collision_pairs = 0;
+
+ active = true;
+ flushing_queries = false;
+};
+
+PhysicsServer3DSW::~PhysicsServer3DSW(){
+
+};
diff --git a/servers/physics/physics_server_sw.h b/servers/physics_3d/physics_server_3d_sw.h
index 459c7688f0..67123084c1 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics_3d/physics_server_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_server_sw.h */
+/* physics_server_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,17 +32,17 @@
#define PHYSICS_SERVER_SW
#include "core/rid_owner.h"
-#include "joints_sw.h"
-#include "servers/physics_server.h"
-#include "shape_sw.h"
-#include "space_sw.h"
-#include "step_sw.h"
+#include "joints_3d_sw.h"
+#include "servers/physics_server_3d.h"
+#include "shape_3d_sw.h"
+#include "space_3d_sw.h"
+#include "step_3d_sw.h"
-class PhysicsServerSW : public PhysicsServer {
+class PhysicsServer3DSW : public PhysicsServer3D {
- GDCLASS(PhysicsServerSW, PhysicsServer);
+ GDCLASS(PhysicsServer3DSW, PhysicsServer3D);
- friend class PhysicsDirectSpaceStateSW;
+ friend class PhysicsDirectSpaceState3DSW;
bool active;
int iterations;
bool doing_sync;
@@ -54,24 +54,24 @@ class PhysicsServerSW : public PhysicsServer {
bool flushing_queries;
- StepSW *stepper;
- Set<const SpaceSW *> active_spaces;
+ Step3DSW *stepper;
+ Set<const Space3DSW *> active_spaces;
- PhysicsDirectBodyStateSW *direct_state;
+ PhysicsDirectBodyState3DSW *direct_state;
- mutable RID_PtrOwner<ShapeSW> shape_owner;
- mutable RID_PtrOwner<SpaceSW> space_owner;
- mutable RID_PtrOwner<AreaSW> area_owner;
- mutable RID_PtrOwner<BodySW> body_owner;
- mutable RID_PtrOwner<JointSW> joint_owner;
+ mutable RID_PtrOwner<Shape3DSW> shape_owner;
+ mutable RID_PtrOwner<Space3DSW> space_owner;
+ mutable RID_PtrOwner<Area3DSW> area_owner;
+ mutable RID_PtrOwner<Body3DSW> body_owner;
+ mutable RID_PtrOwner<Joint3DSW> joint_owner;
//void _clear_query(QuerySW *p_query);
- friend class CollisionObjectSW;
- SelfList<CollisionObjectSW>::List pending_shape_update_list;
+ friend class CollisionObject3DSW;
+ SelfList<CollisionObject3DSW>::List pending_shape_update_list;
void _update_shapes();
public:
- static PhysicsServerSW *singleton;
+ static PhysicsServer3DSW *singleton;
struct CollCbkData {
@@ -104,7 +104,7 @@ public:
virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const;
// this function only works on physics process, errors and returns null otherwise
- virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space);
+ virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space);
virtual void space_set_debug_contacts(RID p_space, int p_max_contacts);
virtual Vector<Vector3> space_get_contacts(RID p_space) const;
@@ -241,13 +241,13 @@ public:
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001);
// this function only works on physics process, errors and returns null otherwise
- virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body);
+ virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body);
/* SOFT BODY */
virtual RID soft_body_create(bool p_init_sleeping = false) { return RID(); }
- virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) {}
+ virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) {}
virtual void soft_body_set_space(RID p_body, RID p_space) {}
virtual RID soft_body_get_space(RID p_body) const { return RID(); }
@@ -375,8 +375,8 @@ public:
int get_process_info(ProcessInfo p_info);
- PhysicsServerSW();
- ~PhysicsServerSW();
+ PhysicsServer3DSW();
+ ~PhysicsServer3DSW();
};
#endif
diff --git a/servers/physics/shape_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index 4a6ed6be58..52253d615a 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* shape_sw.cpp */
+/* shape_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "shape_sw.h"
+#include "shape_3d_sw.h"
#include "core/math/geometry.h"
#include "core/math/quick_hull.h"
@@ -38,16 +38,16 @@
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002
#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998
-void ShapeSW::configure(const AABB &p_aabb) {
+void Shape3DSW::configure(const AABB &p_aabb) {
aabb = p_aabb;
configured = true;
- for (Map<ShapeOwnerSW *, int>::Element *E = owners.front(); E; E = E->next()) {
- ShapeOwnerSW *co = (ShapeOwnerSW *)E->key();
+ for (Map<ShapeOwner3DSW *, int>::Element *E = owners.front(); E; E = E->next()) {
+ ShapeOwner3DSW *co = (ShapeOwner3DSW *)E->key();
co->_shape_changed();
}
}
-Vector3 ShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 Shape3DSW::get_support(const Vector3 &p_normal) const {
Vector3 res;
int amnt;
@@ -55,9 +55,9 @@ Vector3 ShapeSW::get_support(const Vector3 &p_normal) const {
return res;
}
-void ShapeSW::add_owner(ShapeOwnerSW *p_owner) {
+void Shape3DSW::add_owner(ShapeOwner3DSW *p_owner) {
- Map<ShapeOwnerSW *, int>::Element *E = owners.find(p_owner);
+ Map<ShapeOwner3DSW *, int>::Element *E = owners.find(p_owner);
if (E) {
E->get()++;
} else {
@@ -65,9 +65,9 @@ void ShapeSW::add_owner(ShapeOwnerSW *p_owner) {
}
}
-void ShapeSW::remove_owner(ShapeOwnerSW *p_owner) {
+void Shape3DSW::remove_owner(ShapeOwner3DSW *p_owner) {
- Map<ShapeOwnerSW *, int>::Element *E = owners.find(p_owner);
+ Map<ShapeOwner3DSW *, int>::Element *E = owners.find(p_owner);
ERR_FAIL_COND(!E);
E->get()--;
if (E->get() == 0) {
@@ -75,44 +75,44 @@ void ShapeSW::remove_owner(ShapeOwnerSW *p_owner) {
}
}
-bool ShapeSW::is_owner(ShapeOwnerSW *p_owner) const {
+bool Shape3DSW::is_owner(ShapeOwner3DSW *p_owner) const {
return owners.has(p_owner);
}
-const Map<ShapeOwnerSW *, int> &ShapeSW::get_owners() const {
+const Map<ShapeOwner3DSW *, int> &Shape3DSW::get_owners() const {
return owners;
}
-ShapeSW::ShapeSW() {
+Shape3DSW::Shape3DSW() {
custom_bias = 0;
configured = false;
}
-ShapeSW::~ShapeSW() {
+Shape3DSW::~Shape3DSW() {
ERR_FAIL_COND(owners.size());
}
-Plane PlaneShapeSW::get_plane() const {
+Plane PlaneShape3DSW::get_plane() const {
return plane;
}
-void PlaneShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void PlaneShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
// gibberish, a plane is infinity
r_min = -1e7;
r_max = 1e7;
}
-Vector3 PlaneShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 PlaneShape3DSW::get_support(const Vector3 &p_normal) const {
return p_normal * 1e15;
}
-bool PlaneShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool PlaneShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
bool inters = plane.intersects_segment(p_begin, p_end, &r_result);
if (inters)
@@ -120,12 +120,12 @@ bool PlaneShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en
return inters;
}
-bool PlaneShapeSW::intersect_point(const Vector3 &p_point) const {
+bool PlaneShape3DSW::intersect_point(const Vector3 &p_point) const {
return plane.distance_to(p_point) < 0;
}
-Vector3 PlaneShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 PlaneShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
if (plane.is_point_over(p_point)) {
return plane.project(p_point);
@@ -134,49 +134,49 @@ Vector3 PlaneShapeSW::get_closest_point_to(const Vector3 &p_point) const {
}
}
-Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 PlaneShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); //wtf
}
-void PlaneShapeSW::_setup(const Plane &p_plane) {
+void PlaneShape3DSW::_setup(const Plane &p_plane) {
plane = p_plane;
configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2)));
}
-void PlaneShapeSW::set_data(const Variant &p_data) {
+void PlaneShape3DSW::set_data(const Variant &p_data) {
_setup(p_data);
}
-Variant PlaneShapeSW::get_data() const {
+Variant PlaneShape3DSW::get_data() const {
return plane;
}
-PlaneShapeSW::PlaneShapeSW() {
+PlaneShape3DSW::PlaneShape3DSW() {
}
//
-real_t RayShapeSW::get_length() const {
+real_t RayShape3DSW::get_length() const {
return length;
}
-bool RayShapeSW::get_slips_on_slope() const {
+bool RayShape3DSW::get_slips_on_slope() const {
return slips_on_slope;
}
-void RayShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void RayShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
// don't think this will be even used
r_min = 0;
r_max = 1;
}
-Vector3 RayShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 RayShape3DSW::get_support(const Vector3 &p_normal) const {
if (p_normal.z > 0)
return Vector3(0, 0, length);
@@ -184,7 +184,7 @@ Vector3 RayShapeSW::get_support(const Vector3 &p_normal) const {
return Vector3(0, 0, 0);
}
-void RayShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
+void RayShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
@@ -200,17 +200,17 @@ void RayShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup
}
}
-bool RayShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool RayShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
return false; //simply not possible
}
-bool RayShapeSW::intersect_point(const Vector3 &p_point) const {
+bool RayShape3DSW::intersect_point(const Vector3 &p_point) const {
return false; //simply not possible
}
-Vector3 RayShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 RayShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
Vector3 s[2] = {
Vector3(0, 0, 0),
@@ -220,25 +220,25 @@ Vector3 RayShapeSW::get_closest_point_to(const Vector3 &p_point) const {
return Geometry::get_closest_point_to_segment(p_point, s);
}
-Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 RayShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3();
}
-void RayShapeSW::_setup(real_t p_length, bool p_slips_on_slope) {
+void RayShape3DSW::_setup(real_t p_length, bool p_slips_on_slope) {
length = p_length;
slips_on_slope = p_slips_on_slope;
configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length)));
}
-void RayShapeSW::set_data(const Variant &p_data) {
+void RayShape3DSW::set_data(const Variant &p_data) {
Dictionary d = p_data;
_setup(d["length"], d["slips_on_slope"]);
}
-Variant RayShapeSW::get_data() const {
+Variant RayShape3DSW::get_data() const {
Dictionary d;
d["length"] = length;
@@ -246,7 +246,7 @@ Variant RayShapeSW::get_data() const {
return d;
}
-RayShapeSW::RayShapeSW() {
+RayShape3DSW::RayShape3DSW() {
length = 1;
slips_on_slope = false;
@@ -254,12 +254,12 @@ RayShapeSW::RayShapeSW() {
/********** SPHERE *************/
-real_t SphereShapeSW::get_radius() const {
+real_t SphereShape3DSW::get_radius() const {
return radius;
}
-void SphereShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void SphereShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
real_t d = p_normal.dot(p_transform.origin);
@@ -271,28 +271,28 @@ void SphereShapeSW::project_range(const Vector3 &p_normal, const Transform &p_tr
r_max = d + (radius)*scale;
}
-Vector3 SphereShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 SphereShape3DSW::get_support(const Vector3 &p_normal) const {
return p_normal * radius;
}
-void SphereShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
+void SphereShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
*r_supports = p_normal * radius;
r_amount = 1;
}
-bool SphereShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool SphereShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
return Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal);
}
-bool SphereShapeSW::intersect_point(const Vector3 &p_point) const {
+bool SphereShape3DSW::intersect_point(const Vector3 &p_point) const {
return p_point.length() < radius;
}
-Vector3 SphereShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 SphereShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
Vector3 p = p_point;
float l = p.length();
@@ -301,36 +301,36 @@ Vector3 SphereShapeSW::get_closest_point_to(const Vector3 &p_point) const {
return (p / l) * radius;
}
-Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 SphereShape3DSW::get_moment_of_inertia(real_t p_mass) const {
real_t s = 0.4 * p_mass * radius * radius;
return Vector3(s, s, s);
}
-void SphereShapeSW::_setup(real_t p_radius) {
+void SphereShape3DSW::_setup(real_t p_radius) {
radius = p_radius;
configure(AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0)));
}
-void SphereShapeSW::set_data(const Variant &p_data) {
+void SphereShape3DSW::set_data(const Variant &p_data) {
_setup(p_data);
}
-Variant SphereShapeSW::get_data() const {
+Variant SphereShape3DSW::get_data() const {
return radius;
}
-SphereShapeSW::SphereShapeSW() {
+SphereShape3DSW::SphereShape3DSW() {
radius = 0;
}
/********** BOX *************/
-void BoxShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void BoxShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
// no matter the angle, the box is mirrored anyway
Vector3 local_normal = p_transform.basis.xform_inv(p_normal);
@@ -342,7 +342,7 @@ void BoxShapeSW::project_range(const Vector3 &p_normal, const Transform &p_trans
r_max = distance + length;
}
-Vector3 BoxShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 BoxShape3DSW::get_support(const Vector3 &p_normal) const {
Vector3 point(
(p_normal.x < 0) ? -half_extents.x : half_extents.x,
@@ -352,7 +352,7 @@ Vector3 BoxShapeSW::get_support(const Vector3 &p_normal) const {
return point;
}
-void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
+void BoxShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
static const int next[3] = { 1, 2, 0 };
static const int next2[3] = { 2, 0, 1 };
@@ -439,19 +439,19 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup
r_supports[0] = point;
}
-bool BoxShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool BoxShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
AABB aabb(-half_extents, half_extents * 2.0);
return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal);
}
-bool BoxShapeSW::intersect_point(const Vector3 &p_point) const {
+bool BoxShape3DSW::intersect_point(const Vector3 &p_point) const {
return (Math::abs(p_point.x) < half_extents.x && Math::abs(p_point.y) < half_extents.y && Math::abs(p_point.z) < half_extents.z);
}
-Vector3 BoxShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
int outside = 0;
Vector3 min_point;
@@ -502,7 +502,7 @@ Vector3 BoxShapeSW::get_closest_point_to(const Vector3 &p_point) const {
return min_point;
}
-Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 BoxShape3DSW::get_moment_of_inertia(real_t p_mass) const {
real_t lx = half_extents.x;
real_t ly = half_extents.y;
@@ -511,29 +511,29 @@ Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3((p_mass / 3.0) * (ly * ly + lz * lz), (p_mass / 3.0) * (lx * lx + lz * lz), (p_mass / 3.0) * (lx * lx + ly * ly));
}
-void BoxShapeSW::_setup(const Vector3 &p_half_extents) {
+void BoxShape3DSW::_setup(const Vector3 &p_half_extents) {
half_extents = p_half_extents.abs();
configure(AABB(-half_extents, half_extents * 2));
}
-void BoxShapeSW::set_data(const Variant &p_data) {
+void BoxShape3DSW::set_data(const Variant &p_data) {
_setup(p_data);
}
-Variant BoxShapeSW::get_data() const {
+Variant BoxShape3DSW::get_data() const {
return half_extents;
}
-BoxShapeSW::BoxShapeSW() {
+BoxShape3DSW::BoxShape3DSW() {
}
/********** CAPSULE *************/
-void CapsuleShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void CapsuleShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
Vector3 n = p_transform.basis.xform_inv(p_normal).normalized();
real_t h = (n.z > 0) ? height : -height;
@@ -545,7 +545,7 @@ void CapsuleShapeSW::project_range(const Vector3 &p_normal, const Transform &p_t
r_min = p_normal.dot(p_transform.xform(-n));
}
-Vector3 CapsuleShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 CapsuleShape3DSW::get_support(const Vector3 &p_normal) const {
Vector3 n = p_normal;
@@ -556,7 +556,7 @@ Vector3 CapsuleShapeSW::get_support(const Vector3 &p_normal) const {
return n;
}
-void CapsuleShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
+void CapsuleShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
Vector3 n = p_normal;
@@ -586,7 +586,7 @@ void CapsuleShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r
}
}
-bool CapsuleShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
Vector3 norm = (p_end - p_begin).normalized();
real_t min_d = 1e20;
@@ -644,7 +644,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_
return collision;
}
-bool CapsuleShapeSW::intersect_point(const Vector3 &p_point) const {
+bool CapsuleShape3DSW::intersect_point(const Vector3 &p_point) const {
if (Math::abs(p_point.z) < height * 0.5) {
return Vector3(p_point.x, p_point.y, 0).length() < radius;
@@ -655,7 +655,7 @@ bool CapsuleShapeSW::intersect_point(const Vector3 &p_point) const {
}
}
-Vector3 CapsuleShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 CapsuleShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
Vector3 s[2] = {
Vector3(0, 0, -height * 0.5),
@@ -670,7 +670,7 @@ Vector3 CapsuleShapeSW::get_closest_point_to(const Vector3 &p_point) const {
return p + (p_point - p).normalized() * radius;
}
-Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 CapsuleShape3DSW::get_moment_of_inertia(real_t p_mass) const {
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -681,14 +681,14 @@ Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const {
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
}
-void CapsuleShapeSW::_setup(real_t p_height, real_t p_radius) {
+void CapsuleShape3DSW::_setup(real_t p_height, real_t p_radius) {
height = p_height;
radius = p_radius;
configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0)));
}
-void CapsuleShapeSW::set_data(const Variant &p_data) {
+void CapsuleShape3DSW::set_data(const Variant &p_data) {
Dictionary d = p_data;
ERR_FAIL_COND(!d.has("radius"));
@@ -696,7 +696,7 @@ void CapsuleShapeSW::set_data(const Variant &p_data) {
_setup(d["height"], d["radius"]);
}
-Variant CapsuleShapeSW::get_data() const {
+Variant CapsuleShape3DSW::get_data() const {
Dictionary d;
d["radius"] = radius;
@@ -704,14 +704,14 @@ Variant CapsuleShapeSW::get_data() const {
return d;
}
-CapsuleShapeSW::CapsuleShapeSW() {
+CapsuleShape3DSW::CapsuleShape3DSW() {
height = radius = 0;
}
/********** CONVEX POLYGON *************/
-void ConvexPolygonShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void ConvexPolygonShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
int vertex_count = mesh.vertices.size();
if (vertex_count == 0)
@@ -730,7 +730,7 @@ void ConvexPolygonShapeSW::project_range(const Vector3 &p_normal, const Transfor
}
}
-Vector3 ConvexPolygonShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 ConvexPolygonShape3DSW::get_support(const Vector3 &p_normal) const {
Vector3 n = p_normal;
@@ -756,7 +756,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3 &p_normal) const {
return vrts[vert_support_idx];
}
-void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
+void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
const Geometry::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
@@ -826,7 +826,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect
r_amount = 1;
}
-bool ConvexPolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
const Geometry::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
@@ -866,7 +866,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vecto
return col;
}
-bool ConvexPolygonShapeSW::intersect_point(const Vector3 &p_point) const {
+bool ConvexPolygonShape3DSW::intersect_point(const Vector3 &p_point) const {
const Geometry::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
@@ -880,7 +880,7 @@ bool ConvexPolygonShapeSW::intersect_point(const Vector3 &p_point) const {
return true;
}
-Vector3 ConvexPolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
const Geometry::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
@@ -941,7 +941,7 @@ Vector3 ConvexPolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const
return min_point;
}
-Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 ConvexPolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -952,7 +952,7 @@ Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
}
-void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) {
+void ConvexPolygonShape3DSW::_setup(const Vector<Vector3> &p_vertices) {
Error err = QuickHull::build(p_vertices, mesh);
if (err != OK)
@@ -971,22 +971,22 @@ void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) {
configure(_aabb);
}
-void ConvexPolygonShapeSW::set_data(const Variant &p_data) {
+void ConvexPolygonShape3DSW::set_data(const Variant &p_data) {
_setup(p_data);
}
-Variant ConvexPolygonShapeSW::get_data() const {
+Variant ConvexPolygonShape3DSW::get_data() const {
return mesh.vertices;
}
-ConvexPolygonShapeSW::ConvexPolygonShapeSW() {
+ConvexPolygonShape3DSW::ConvexPolygonShape3DSW() {
}
/********** FACE POLYGON *************/
-void FaceShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void FaceShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
for (int i = 0; i < 3; i++) {
@@ -1001,7 +1001,7 @@ void FaceShapeSW::project_range(const Vector3 &p_normal, const Transform &p_tran
}
}
-Vector3 FaceShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 FaceShape3DSW::get_support(const Vector3 &p_normal) const {
int vert_support_idx = -1;
real_t support_max = 0;
@@ -1019,7 +1019,7 @@ Vector3 FaceShapeSW::get_support(const Vector3 &p_normal) const {
return vertex[vert_support_idx];
}
-void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
+void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
Vector3 n = p_normal;
@@ -1073,7 +1073,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su
r_supports[0] = vertex[vert_support_idx];
}
-bool FaceShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool FaceShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
bool c = Geometry::segment_intersects_triangle(p_begin, p_end, vertex[0], vertex[1], vertex[2], &r_result);
if (c) {
@@ -1086,27 +1086,27 @@ bool FaceShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end
return c;
}
-bool FaceShapeSW::intersect_point(const Vector3 &p_point) const {
+bool FaceShape3DSW::intersect_point(const Vector3 &p_point) const {
return false; //face is flat
}
-Vector3 FaceShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 FaceShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
return Face3(vertex[0], vertex[1], vertex[2]).get_closest_point_to(p_point);
}
-Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 FaceShape3DSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); // Sorry, but i don't think anyone cares, FaceShape!
}
-FaceShapeSW::FaceShapeSW() {
+FaceShape3DSW::FaceShape3DSW() {
configure(AABB());
}
-Vector<Vector3> ConcavePolygonShapeSW::get_faces() const {
+Vector<Vector3> ConcavePolygonShape3DSW::get_faces() const {
Vector<Vector3> rfaces;
rfaces.resize(faces.size() * 3);
@@ -1124,7 +1124,7 @@ Vector<Vector3> ConcavePolygonShapeSW::get_faces() const {
return rfaces;
}
-void ConcavePolygonShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void ConcavePolygonShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
int count = vertices.size();
if (count == 0) {
@@ -1145,7 +1145,7 @@ void ConcavePolygonShapeSW::project_range(const Vector3 &p_normal, const Transfo
}
}
-Vector3 ConcavePolygonShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 ConcavePolygonShape3DSW::get_support(const Vector3 &p_normal) const {
int count = vertices.size();
if (count == 0)
@@ -1171,7 +1171,7 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3 &p_normal) const {
return vptr[vert_support_idx];
}
-void ConcavePolygonShapeSW::_cull_segment(int p_idx, _SegmentCullParams *p_params) const {
+void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_params) const {
const BVH *bvh = &p_params->bvh[p_idx];
@@ -1223,7 +1223,7 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx, _SegmentCullParams *p_param
}
}
-bool ConcavePolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
+bool ConcavePolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
if (faces.size() == 0)
return false;
@@ -1258,17 +1258,17 @@ bool ConcavePolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vect
}
}
-bool ConcavePolygonShapeSW::intersect_point(const Vector3 &p_point) const {
+bool ConcavePolygonShape3DSW::intersect_point(const Vector3 &p_point) const {
return false; //face is flat
}
-Vector3 ConcavePolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 ConcavePolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
return Vector3();
}
-void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const {
+void ConcavePolygonShape3DSW::_cull(int p_idx, _CullParams *p_params) const {
const BVH *bvh = &p_params->bvh[p_idx];
@@ -1278,7 +1278,7 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const {
if (bvh->face_index >= 0) {
const Face *f = &p_params->faces[bvh->face_index];
- FaceShapeSW *face = p_params->face;
+ FaceShape3DSW *face = p_params->face;
face->normal = f->normal;
face->vertex[0] = p_params->vertices[f->indices[0]];
face->vertex[1] = p_params->vertices[f->indices[1]];
@@ -1299,7 +1299,7 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const {
}
}
-void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
+void ConcavePolygonShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
// make matrix local to concave
if (faces.size() == 0)
@@ -1312,7 +1312,7 @@ void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback,
const Vector3 *vr = vertices.ptr();
const BVH *br = bvh.ptr();
- FaceShapeSW face; // use this to send in the callback
+ FaceShape3DSW face; // use this to send in the callback
_CullParams params;
params.aabb = local_aabb;
@@ -1327,7 +1327,7 @@ void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback,
_cull(0, &params);
}
-Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 ConcavePolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -1433,7 +1433,7 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz
return bvh;
}
-void ConcavePolygonShapeSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx) {
+void ConcavePolygonShape3DSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx) {
int idx = p_idx;
@@ -1462,7 +1462,7 @@ void ConcavePolygonShapeSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_arra
memdelete(p_bvh_tree);
}
-void ConcavePolygonShapeSW::_setup(Vector<Vector3> p_faces) {
+void ConcavePolygonShape3DSW::_setup(Vector<Vector3> p_faces) {
int src_face_count = p_faces.size();
if (src_face_count == 0) {
@@ -1521,68 +1521,68 @@ void ConcavePolygonShapeSW::_setup(Vector<Vector3> p_faces) {
configure(_aabb); // this type of shape has no margin
}
-void ConcavePolygonShapeSW::set_data(const Variant &p_data) {
+void ConcavePolygonShape3DSW::set_data(const Variant &p_data) {
_setup(p_data);
}
-Variant ConcavePolygonShapeSW::get_data() const {
+Variant ConcavePolygonShape3DSW::get_data() const {
return get_faces();
}
-ConcavePolygonShapeSW::ConcavePolygonShapeSW() {
+ConcavePolygonShape3DSW::ConcavePolygonShape3DSW() {
}
/* HEIGHT MAP SHAPE */
-Vector<real_t> HeightMapShapeSW::get_heights() const {
+Vector<real_t> HeightMapShape3DSW::get_heights() const {
return heights;
}
-int HeightMapShapeSW::get_width() const {
+int HeightMapShape3DSW::get_width() const {
return width;
}
-int HeightMapShapeSW::get_depth() const {
+int HeightMapShape3DSW::get_depth() const {
return depth;
}
-real_t HeightMapShapeSW::get_cell_size() const {
+real_t HeightMapShape3DSW::get_cell_size() const {
return cell_size;
}
-void HeightMapShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
+void HeightMapShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
//not very useful, but not very used either
p_transform.xform(get_aabb()).project_range_in_plane(Plane(p_normal, 0), r_min, r_max);
}
-Vector3 HeightMapShapeSW::get_support(const Vector3 &p_normal) const {
+Vector3 HeightMapShape3DSW::get_support(const Vector3 &p_normal) const {
//not very useful, but not very used either
return get_aabb().get_support(p_normal);
}
-bool HeightMapShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const {
+bool HeightMapShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const {
return false;
}
-bool HeightMapShapeSW::intersect_point(const Vector3 &p_point) const {
+bool HeightMapShape3DSW::intersect_point(const Vector3 &p_point) const {
return false;
}
-Vector3 HeightMapShapeSW::get_closest_point_to(const Vector3 &p_point) const {
+Vector3 HeightMapShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
return Vector3();
}
-void HeightMapShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
+void HeightMapShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
}
-Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const {
+Vector3 HeightMapShape3DSW::get_moment_of_inertia(real_t p_mass) const {
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -1593,7 +1593,7 @@ Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const {
(p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y));
}
-void HeightMapShapeSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) {
+void HeightMapShape3DSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) {
heights = p_heights;
width = p_width;
@@ -1621,7 +1621,7 @@ void HeightMapShapeSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth
configure(aabb);
}
-void HeightMapShapeSW::set_data(const Variant &p_data) {
+void HeightMapShape3DSW::set_data(const Variant &p_data) {
ERR_FAIL_COND(p_data.get_type() != Variant::DICTIONARY);
Dictionary d = p_data;
@@ -1642,12 +1642,12 @@ void HeightMapShapeSW::set_data(const Variant &p_data) {
_setup(heights, width, depth, cell_size);
}
-Variant HeightMapShapeSW::get_data() const {
+Variant HeightMapShape3DSW::get_data() const {
ERR_FAIL_V(Variant());
}
-HeightMapShapeSW::HeightMapShapeSW() {
+HeightMapShape3DSW::HeightMapShape3DSW() {
width = 0;
depth = 0;
diff --git a/servers/physics/shape_sw.h b/servers/physics_3d/shape_3d_sw.h
index eaae64be66..dd29ec849b 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics_3d/shape_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* shape_sw.h */
+/* shape_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,7 +32,7 @@
#define SHAPE_SW_H
#include "core/math/geometry.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
/*
SHAPE_LINE, ///< plane:"plane"
@@ -45,24 +45,24 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat
*/
-class ShapeSW;
+class Shape3DSW;
-class ShapeOwnerSW {
+class ShapeOwner3DSW {
public:
virtual void _shape_changed() = 0;
- virtual void remove_shape(ShapeSW *p_shape) = 0;
+ virtual void remove_shape(Shape3DSW *p_shape) = 0;
- virtual ~ShapeOwnerSW() {}
+ virtual ~ShapeOwner3DSW() {}
};
-class ShapeSW {
+class Shape3DSW {
RID self;
AABB aabb;
bool configured;
real_t custom_bias;
- Map<ShapeOwnerSW *, int> owners;
+ Map<ShapeOwner3DSW *, int> owners;
protected:
void configure(const AABB &p_aabb);
@@ -77,7 +77,7 @@ public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- virtual PhysicsServer::ShapeType get_type() const = 0;
+ virtual PhysicsServer3D::ShapeType get_type() const = 0;
_FORCE_INLINE_ AABB get_aabb() const { return aabb; }
_FORCE_INLINE_ bool is_configured() const { return configured; }
@@ -98,28 +98,28 @@ public:
_FORCE_INLINE_ void set_custom_bias(real_t p_bias) { custom_bias = p_bias; }
_FORCE_INLINE_ real_t get_custom_bias() const { return custom_bias; }
- void add_owner(ShapeOwnerSW *p_owner);
- void remove_owner(ShapeOwnerSW *p_owner);
- bool is_owner(ShapeOwnerSW *p_owner) const;
- const Map<ShapeOwnerSW *, int> &get_owners() const;
+ void add_owner(ShapeOwner3DSW *p_owner);
+ void remove_owner(ShapeOwner3DSW *p_owner);
+ bool is_owner(ShapeOwner3DSW *p_owner) const;
+ const Map<ShapeOwner3DSW *, int> &get_owners() const;
- ShapeSW();
- virtual ~ShapeSW();
+ Shape3DSW();
+ virtual ~Shape3DSW();
};
-class ConcaveShapeSW : public ShapeSW {
+class ConcaveShape3DSW : public Shape3DSW {
public:
virtual bool is_concave() const { return true; }
- typedef void (*Callback)(void *p_userdata, ShapeSW *p_convex);
+ typedef void (*Callback)(void *p_userdata, Shape3DSW *p_convex);
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; }
virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0;
- ConcaveShapeSW() {}
+ ConcaveShape3DSW() {}
};
-class PlaneShapeSW : public ShapeSW {
+class PlaneShape3DSW : public Shape3DSW {
Plane plane;
@@ -129,7 +129,7 @@ public:
Plane get_plane() const;
virtual real_t get_area() const { return Math_INF; }
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_PLANE; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_PLANE; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; }
@@ -142,10 +142,10 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- PlaneShapeSW();
+ PlaneShape3DSW();
};
-class RayShapeSW : public ShapeSW {
+class RayShape3DSW : public Shape3DSW {
real_t length;
bool slips_on_slope;
@@ -157,7 +157,7 @@ public:
bool get_slips_on_slope() const;
virtual real_t get_area() const { return 0.0; }
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_RAY; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const;
@@ -171,10 +171,10 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- RayShapeSW();
+ RayShape3DSW();
};
-class SphereShapeSW : public ShapeSW {
+class SphereShape3DSW : public Shape3DSW {
real_t radius;
@@ -185,7 +185,7 @@ public:
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_SPHERE; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_SPHERE; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
@@ -199,10 +199,10 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- SphereShapeSW();
+ SphereShape3DSW();
};
-class BoxShapeSW : public ShapeSW {
+class BoxShape3DSW : public Shape3DSW {
Vector3 half_extents;
void _setup(const Vector3 &p_half_extents);
@@ -211,7 +211,7 @@ public:
_FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; }
virtual real_t get_area() const { return 8 * half_extents.x * half_extents.y * half_extents.z; }
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_BOX; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_BOX; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
@@ -225,10 +225,10 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- BoxShapeSW();
+ BoxShape3DSW();
};
-class CapsuleShapeSW : public ShapeSW {
+class CapsuleShape3DSW : public Shape3DSW {
real_t height;
real_t radius;
@@ -241,7 +241,7 @@ public:
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; }
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CAPSULE; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CAPSULE; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
@@ -255,10 +255,10 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- CapsuleShapeSW();
+ CapsuleShape3DSW();
};
-struct ConvexPolygonShapeSW : public ShapeSW {
+struct ConvexPolygonShape3DSW : public Shape3DSW {
Geometry::MeshData mesh;
@@ -267,7 +267,7 @@ struct ConvexPolygonShapeSW : public ShapeSW {
public:
const Geometry::MeshData &get_mesh() const { return mesh; }
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
@@ -281,13 +281,13 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- ConvexPolygonShapeSW();
+ ConvexPolygonShape3DSW();
};
struct _VolumeSW_BVH;
-struct FaceShapeSW;
+struct FaceShape3DSW;
-struct ConcavePolygonShapeSW : public ConcaveShapeSW {
+struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
// always a trimesh
struct Face {
@@ -318,7 +318,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW {
const Face *faces;
const Vector3 *vertices;
const BVH *bvh;
- FaceShapeSW *face;
+ FaceShape3DSW *face;
};
struct _SegmentCullParams {
@@ -346,7 +346,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW {
public:
Vector<Vector3> get_faces() const;
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
@@ -362,10 +362,10 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- ConcavePolygonShapeSW();
+ ConcavePolygonShape3DSW();
};
-struct HeightMapShapeSW : public ConcaveShapeSW {
+struct HeightMapShape3DSW : public ConcaveShape3DSW {
Vector<real_t> heights;
int width;
@@ -383,7 +383,7 @@ public:
int get_depth() const;
real_t get_cell_size() const;
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_HEIGHTMAP; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_HEIGHTMAP; }
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
virtual Vector3 get_support(const Vector3 &p_normal) const;
@@ -398,16 +398,16 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- HeightMapShapeSW();
+ HeightMapShape3DSW();
};
//used internally
-struct FaceShapeSW : public ShapeSW {
+struct FaceShape3DSW : public Shape3DSW {
Vector3 normal; //cache
Vector3 vertex[3];
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; }
const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; }
@@ -423,15 +423,15 @@ struct FaceShapeSW : public ShapeSW {
virtual void set_data(const Variant &p_data) {}
virtual Variant get_data() const { return Variant(); }
- FaceShapeSW();
+ FaceShape3DSW();
};
-struct MotionShapeSW : public ShapeSW {
+struct MotionShape3DSW : public Shape3DSW {
- ShapeSW *shape;
+ Shape3DSW *shape;
Vector3 motion;
- virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; }
+ virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
@@ -464,7 +464,7 @@ struct MotionShapeSW : public ShapeSW {
virtual void set_data(const Variant &p_data) {}
virtual Variant get_data() const { return Variant(); }
- MotionShapeSW() { configure(AABB()); }
+ MotionShape3DSW() { configure(AABB()); }
};
#endif // SHAPE_SW_H
diff --git a/servers/physics/space_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index 110520db5a..9bd507e178 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* space_sw.cpp */
+/* space_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,31 +28,31 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "space_sw.h"
+#include "space_3d_sw.h"
-#include "collision_solver_sw.h"
+#include "collision_solver_3d_sw.h"
#include "core/project_settings.h"
-#include "physics_server_sw.h"
+#include "physics_server_3d_sw.h"
-_FORCE_INLINE_ static bool _can_collide_with(CollisionObjectSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+_FORCE_INLINE_ static bool _can_collide_with(CollisionObject3DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (!(p_object->get_collision_layer() & p_collision_mask)) {
return false;
}
- if (p_object->get_type() == CollisionObjectSW::TYPE_AREA && !p_collide_with_areas)
+ if (p_object->get_type() == CollisionObject3DSW::TYPE_AREA && !p_collide_with_areas)
return false;
- if (p_object->get_type() == CollisionObjectSW::TYPE_BODY && !p_collide_with_bodies)
+ if (p_object->get_type() == CollisionObject3DSW::TYPE_BODY && !p_collide_with_bodies)
return false;
return true;
}
-int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+int PhysicsDirectSpaceState3DSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
ERR_FAIL_COND_V(space->locked, false);
- int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
int cc = 0;
//Transform ai = p_xform.affine_inverse();
@@ -70,7 +70,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu
if (p_exclude.has(space->intersection_query_results[i]->get_self()))
continue;
- const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
Transform inv_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
@@ -93,7 +93,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu
return cc;
}
-bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_ray) {
+bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_ray) {
ERR_FAIL_COND_V(space->locked, false);
@@ -103,14 +103,14 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
end = p_to;
normal = (end - begin).normalized();
- int amount = space->broadphase->cull_segment(begin, end, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int amount = space->broadphase->cull_segment(begin, end, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
//todo, create another array that references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision
bool collided = false;
Vector3 res_point, res_normal;
int res_shape;
- const CollisionObjectSW *res_obj;
+ const CollisionObject3DSW *res_obj;
real_t min_d = 1e10;
for (int i = 0; i < amount; i++) {
@@ -124,7 +124,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
if (p_exclude.has(space->intersection_query_results[i]->get_self()))
continue;
- const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
Transform inv_xform = col_obj->get_shape_inv_transform(shape_idx) * col_obj->get_inv_transform();
@@ -132,7 +132,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
Vector3 local_from = inv_xform.xform(begin);
Vector3 local_to = inv_xform.xform(end);
- const ShapeSW *shape = col_obj->get_shape(shape_idx);
+ const Shape3DSW *shape = col_obj->get_shape(shape_idx);
Vector3 shape_point, shape_normal;
@@ -171,17 +171,17 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
return true;
}
-int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (p_result_max <= 0)
return 0;
- ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_xform.xform(shape->get_aabb());
- int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
int cc = 0;
@@ -200,10 +200,10 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
if (p_exclude.has(space->intersection_query_results[i]->get_self()))
continue;
- const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
- if (!CollisionSolverSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), NULL, NULL, NULL, p_margin, 0))
+ if (!CollisionSolver3DSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), NULL, NULL, NULL, p_margin, 0))
continue;
if (r_results) {
@@ -222,22 +222,22 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
return cc;
}
-bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
+bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
- ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, false);
AABB aabb = p_xform.xform(shape->get_aabb());
aabb = aabb.merge(AABB(aabb.position + p_motion, aabb.size)); //motion
aabb = aabb.grow(p_margin);
- int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
real_t best_safe = 1;
real_t best_unsafe = 1;
Transform xform_inv = p_xform.affine_inverse();
- MotionShapeSW mshape;
+ MotionShape3DSW mshape;
mshape.shape = shape;
mshape.motion = xform_inv.basis.xform(p_motion);
@@ -253,7 +253,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
if (p_exclude.has(space->intersection_query_results[i]->get_self()))
continue; //ignore excluded
- const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
Vector3 point_A, point_B;
@@ -261,14 +261,14 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
Transform col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
//test initial overlap, does it collide if going all the way?
- if (CollisionSolverSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) {
+ if (CollisionSolver3DSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) {
continue;
}
//test initial overlap
sep_axis = p_motion.normalized();
- if (!CollisionSolverSW::solve_distance(shape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) {
+ if (!CollisionSolver3DSW::solve_distance(shape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) {
return false;
}
@@ -287,7 +287,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
Vector3 lA, lB;
- bool collided = !CollisionSolverSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, aabb, &sep);
+ bool collided = !CollisionSolver3DSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, aabb, &sep);
if (collided) {
@@ -315,8 +315,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
r_info->point = closest_B;
r_info->normal = (closest_A - closest_B).normalized();
best_first = false;
- if (col_obj->get_type() == CollisionObjectSW::TYPE_BODY) {
- const BodySW *body = static_cast<const BodySW *>(col_obj);
+ if (col_obj->get_type() == CollisionObject3DSW::TYPE_BODY) {
+ const Body3DSW *body = static_cast<const Body3DSW *>(col_obj);
r_info->linear_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(body->get_transform().origin - closest_B);
}
}
@@ -328,43 +328,43 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
return true;
}
-bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
if (p_result_max <= 0)
return 0;
- ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_shape_xform.xform(shape->get_aabb());
aabb = aabb.grow(p_margin);
- int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
bool collided = false;
r_result_count = 0;
- PhysicsServerSW::CollCbkData cbk;
+ PhysicsServer3DSW::CollCbkData cbk;
cbk.max = p_result_max;
cbk.amount = 0;
cbk.ptr = r_results;
- CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk;
+ CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk;
- PhysicsServerSW::CollCbkData *cbkptr = &cbk;
+ PhysicsServer3DSW::CollCbkData *cbkptr = &cbk;
for (int i = 0; i < amount; i++) {
if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
continue;
- const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
if (p_exclude.has(col_obj->get_self())) {
continue;
}
- if (CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
+ if (CollisionSolver3DSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
collided = true;
}
}
@@ -376,8 +376,8 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
struct _RestCallbackData {
- const CollisionObjectSW *object;
- const CollisionObjectSW *best_object;
+ const CollisionObject3DSW *object;
+ const CollisionObject3DSW *best_object;
int shape;
int best_shape;
Vector3 best_contact;
@@ -403,15 +403,15 @@ static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B,
rd->best_object = rd->object;
rd->best_shape = rd->shape;
}
-bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_shape_xform.xform(shape->get_aabb());
aabb = aabb.grow(p_margin);
- int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
+ int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
_RestCallbackData rcd;
rcd.best_len = 0;
@@ -424,7 +424,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
continue;
- const CollisionObjectSW *col_obj = space->intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
if (p_exclude.has(col_obj->get_self()))
@@ -432,7 +432,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
rcd.object = col_obj;
rcd.shape = shape_idx;
- bool sc = CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
+ bool sc = CollisionSolver3DSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
if (!sc)
continue;
}
@@ -445,9 +445,9 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
r_info->normal = rcd.best_normal;
r_info->point = rcd.best_contact;
r_info->rid = rcd.best_object->get_self();
- if (rcd.best_object->get_type() == CollisionObjectSW::TYPE_BODY) {
+ if (rcd.best_object->get_type() == CollisionObject3DSW::TYPE_BODY) {
- const BodySW *body = static_cast<const BodySW *>(rcd.best_object);
+ const Body3DSW *body = static_cast<const Body3DSW *>(rcd.best_object);
r_info->linear_velocity = body->get_linear_velocity() +
(body->get_angular_velocity()).cross(body->get_transform().origin - rcd.best_contact); // * mPos);
@@ -458,11 +458,11 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
return true;
}
-Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
+Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
- CollisionObjectSW *obj = PhysicsServerSW::singleton->area_owner.getornull(p_object);
+ CollisionObject3DSW *obj = PhysicsServer3DSW::singleton->area_owner.getornull(p_object);
if (!obj) {
- obj = PhysicsServerSW::singleton->body_owner.getornull(p_object);
+ obj = PhysicsServer3DSW::singleton->body_owner.getornull(p_object);
}
ERR_FAIL_COND_V(!obj, Vector3());
@@ -479,7 +479,7 @@ Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_obje
continue;
Transform shape_xform = obj->get_transform() * obj->get_shape_transform(i);
- ShapeSW *shape = obj->get_shape(i);
+ Shape3DSW *shape = obj->get_shape(i);
Vector3 point = shape->get_closest_point_to(shape_xform.affine_inverse().xform(p_point));
point = shape_xform.xform(point);
@@ -499,14 +499,14 @@ Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_obje
}
}
-PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() {
+PhysicsDirectSpaceState3DSW::PhysicsDirectSpaceState3DSW() {
space = NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
-int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) {
+int Space3DSW::_cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb) {
int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results);
@@ -516,13 +516,13 @@ int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) {
if (intersection_query_results[i] == p_body)
keep = false;
- else if (intersection_query_results[i]->get_type() == CollisionObjectSW::TYPE_AREA)
+ else if (intersection_query_results[i]->get_type() == CollisionObject3DSW::TYPE_AREA)
keep = false;
- else if ((static_cast<BodySW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0)
+ else if ((static_cast<Body3DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0)
keep = false;
- else if (static_cast<BodySW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
+ else if (static_cast<Body3DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
keep = false;
- else if (static_cast<BodySW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i]))
+ else if (static_cast<Body3DSW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i]))
keep = false;
if (!keep) {
@@ -540,7 +540,7 @@ int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) {
return amount;
}
-int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, real_t p_margin) {
+int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) {
AABB body_aabb;
@@ -581,10 +581,10 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
const int max_results = 32;
int recover_attempts = 4;
Vector3 sr[max_results * 2];
- PhysicsServerSW::CollCbkData cbk;
+ PhysicsServer3DSW::CollCbkData cbk;
cbk.max = max_results;
- PhysicsServerSW::CollCbkData *cbkptr = &cbk;
- CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk;
+ PhysicsServer3DSW::CollCbkData *cbkptr = &cbk;
+ CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk;
do {
@@ -598,30 +598,30 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
if (p_body->is_shape_set_as_disabled(j))
continue;
- ShapeSW *body_shape = p_body->get_shape(j);
+ Shape3DSW *body_shape = p_body->get_shape(j);
- if (body_shape->get_type() != PhysicsServer::SHAPE_RAY)
+ if (body_shape->get_type() != PhysicsServer3D::SHAPE_RAY)
continue;
Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
for (int i = 0; i < amount; i++) {
- const CollisionObjectSW *col_obj = intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
cbk.amount = 0;
cbk.ptr = sr;
- if (CollisionObjectSW::TYPE_BODY == col_obj->get_type()) {
- const BodySW *b = static_cast<const BodySW *>(col_obj);
- if (p_infinite_inertia && PhysicsServer::BODY_MODE_STATIC != b->get_mode() && PhysicsServer::BODY_MODE_KINEMATIC != b->get_mode()) {
+ if (CollisionObject3DSW::TYPE_BODY == col_obj->get_type()) {
+ const Body3DSW *b = static_cast<const Body3DSW *>(col_obj);
+ if (p_infinite_inertia && PhysicsServer3D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer3D::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
- ShapeSW *against_shape = col_obj->get_shape(shape_idx);
- if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
+ Shape3DSW *against_shape = col_obj->get_shape(shape_idx);
+ if (CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
if (cbk.amount > 0) {
collided = true;
}
@@ -639,7 +639,7 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
}
if (ray_index != -1) {
- PhysicsServer::SeparationResult &result = r_results[ray_index];
+ PhysicsServer3D::SeparationResult &result = r_results[ray_index];
for (int k = 0; k < cbk.amount; k++) {
Vector3 a = sr[k * 2 + 0];
@@ -658,8 +658,8 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
result.collider_id = col_obj->get_instance_id();
result.collider_shape = shape_idx;
//result.collider_metadata = col_obj->get_shape_metadata(shape_idx);
- if (col_obj->get_type() == CollisionObjectSW::TYPE_BODY) {
- BodySW *body = (BodySW *)col_obj;
+ if (col_obj->get_type() == CollisionObject3DSW::TYPE_BODY) {
+ Body3DSW *body = (Body3DSW *)col_obj;
Vector3 rel_vec = b - body->get_transform().get_origin();
//result.collider_velocity = Vector3(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity();
@@ -695,7 +695,7 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
return rays_found;
}
-bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
//give me back regular physics engine logic
//this is madness
@@ -726,7 +726,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
if (!shapes_found) {
if (r_result) {
- *r_result = PhysicsServer::MotionResult();
+ *r_result = PhysicsServer3D::MotionResult();
r_result->motion = p_motion;
}
@@ -748,13 +748,13 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
do {
- PhysicsServerSW::CollCbkData cbk;
+ PhysicsServer3DSW::CollCbkData cbk;
cbk.max = max_results;
cbk.amount = 0;
cbk.ptr = sr;
- PhysicsServerSW::CollCbkData *cbkptr = &cbk;
- CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk;
+ PhysicsServer3DSW::CollCbkData *cbkptr = &cbk;
+ CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk;
bool collided = false;
@@ -765,17 +765,17 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
continue;
Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
- ShapeSW *body_shape = p_body->get_shape(j);
- if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer::SHAPE_RAY) {
+ Shape3DSW *body_shape = p_body->get_shape(j);
+ if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer3D::SHAPE_RAY) {
continue;
}
for (int i = 0; i < amount; i++) {
- const CollisionObjectSW *col_obj = intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
- if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
+ if (CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
collided = cbk.amount > 0;
}
}
@@ -826,14 +826,14 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
continue;
Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
- ShapeSW *body_shape = p_body->get_shape(j);
+ Shape3DSW *body_shape = p_body->get_shape(j);
- if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer::SHAPE_RAY) {
+ if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer3D::SHAPE_RAY) {
continue;
}
Transform body_shape_xform_inv = body_shape_xform.affine_inverse();
- MotionShapeSW mshape;
+ MotionShape3DSW mshape;
mshape.shape = body_shape;
mshape.motion = body_shape_xform_inv.basis.xform(p_motion);
@@ -844,7 +844,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
for (int i = 0; i < amount; i++) {
- const CollisionObjectSW *col_obj = intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
//test initial overlap, does it collide if going all the way?
@@ -853,12 +853,12 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
Transform col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
//test initial overlap, does it collide if going all the way?
- if (CollisionSolverSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) {
+ if (CollisionSolver3DSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) {
continue;
}
sep_axis = p_motion.normalized();
- if (!CollisionSolverSW::solve_distance(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) {
+ if (!CollisionSolver3DSW::solve_distance(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) {
stuck = true;
break;
}
@@ -878,7 +878,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
Vector3 lA, lB;
- bool collided = !CollisionSolverSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep);
+ bool collided = !CollisionSolver3DSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep);
if (collided) {
@@ -940,7 +940,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
rcd.min_allowed_depth = test_motion_min_contact_depth;
Transform body_shape_xform = ugt * p_body->get_shape_transform(best_shape);
- ShapeSW *body_shape = p_body->get_shape(best_shape);
+ Shape3DSW *body_shape = p_body->get_shape(best_shape);
body_aabb.position += p_motion * unsafe;
@@ -948,12 +948,12 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
for (int i = 0; i < amount; i++) {
- const CollisionObjectSW *col_obj = intersection_query_results[i];
+ const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
rcd.object = col_obj;
rcd.shape = shape_idx;
- bool sc = CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
+ bool sc = CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
if (!sc)
continue;
}
@@ -969,7 +969,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
r_result->collision_point = rcd.best_contact;
//r_result->collider_metadata = rcd.best_object->get_shape_metadata(rcd.best_shape);
- const BodySW *body = static_cast<const BodySW *>(rcd.best_object);
+ const Body3DSW *body = static_cast<const Body3DSW *>(rcd.best_object);
//Vector3 rel_vec = r_result->collision_point - body->get_transform().get_origin();
// r_result->collider_velocity = Vector3(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity();
r_result->collider_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(body->get_transform().origin - rcd.best_contact); // * mPos);
@@ -995,10 +995,10 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
return collided;
}
-void *SpaceSW::_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_self) {
+void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self) {
- CollisionObjectSW::Type type_A = A->get_type();
- CollisionObjectSW::Type type_B = B->get_type();
+ CollisionObject3DSW::Type type_A = A->get_type();
+ CollisionObject3DSW::Type type_B = B->get_type();
if (type_A > type_B) {
SWAP(A, B);
@@ -1006,137 +1006,137 @@ void *SpaceSW::_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, Collisio
SWAP(type_A, type_B);
}
- SpaceSW *self = (SpaceSW *)p_self;
+ Space3DSW *self = (Space3DSW *)p_self;
self->collision_pairs++;
- if (type_A == CollisionObjectSW::TYPE_AREA) {
+ if (type_A == CollisionObject3DSW::TYPE_AREA) {
- AreaSW *area = static_cast<AreaSW *>(A);
- if (type_B == CollisionObjectSW::TYPE_AREA) {
+ Area3DSW *area = static_cast<Area3DSW *>(A);
+ if (type_B == CollisionObject3DSW::TYPE_AREA) {
- AreaSW *area_b = static_cast<AreaSW *>(B);
- Area2PairSW *area2_pair = memnew(Area2PairSW(area_b, p_subindex_B, area, p_subindex_A));
+ Area3DSW *area_b = static_cast<Area3DSW *>(B);
+ Area2Pair3DSW *area2_pair = memnew(Area2Pair3DSW(area_b, p_subindex_B, area, p_subindex_A));
return area2_pair;
} else {
- BodySW *body = static_cast<BodySW *>(B);
- AreaPairSW *area_pair = memnew(AreaPairSW(body, p_subindex_B, area, p_subindex_A));
+ Body3DSW *body = static_cast<Body3DSW *>(B);
+ AreaPair3DSW *area_pair = memnew(AreaPair3DSW(body, p_subindex_B, area, p_subindex_A));
return area_pair;
}
} else {
- BodyPairSW *b = memnew(BodyPairSW((BodySW *)A, p_subindex_A, (BodySW *)B, p_subindex_B));
+ BodyPair3DSW *b = memnew(BodyPair3DSW((Body3DSW *)A, p_subindex_A, (Body3DSW *)B, p_subindex_B));
return b;
}
return NULL;
}
-void SpaceSW::_broadphase_unpair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_self) {
+void Space3DSW::_broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_self) {
- SpaceSW *self = (SpaceSW *)p_self;
+ Space3DSW *self = (Space3DSW *)p_self;
self->collision_pairs--;
- ConstraintSW *c = (ConstraintSW *)p_data;
+ Constraint3DSW *c = (Constraint3DSW *)p_data;
memdelete(c);
}
-const SelfList<BodySW>::List &SpaceSW::get_active_body_list() const {
+const SelfList<Body3DSW>::List &Space3DSW::get_active_body_list() const {
return active_list;
}
-void SpaceSW::body_add_to_active_list(SelfList<BodySW> *p_body) {
+void Space3DSW::body_add_to_active_list(SelfList<Body3DSW> *p_body) {
active_list.add(p_body);
}
-void SpaceSW::body_remove_from_active_list(SelfList<BodySW> *p_body) {
+void Space3DSW::body_remove_from_active_list(SelfList<Body3DSW> *p_body) {
active_list.remove(p_body);
}
-void SpaceSW::body_add_to_inertia_update_list(SelfList<BodySW> *p_body) {
+void Space3DSW::body_add_to_inertia_update_list(SelfList<Body3DSW> *p_body) {
inertia_update_list.add(p_body);
}
-void SpaceSW::body_remove_from_inertia_update_list(SelfList<BodySW> *p_body) {
+void Space3DSW::body_remove_from_inertia_update_list(SelfList<Body3DSW> *p_body) {
inertia_update_list.remove(p_body);
}
-BroadPhaseSW *SpaceSW::get_broadphase() {
+BroadPhase3DSW *Space3DSW::get_broadphase() {
return broadphase;
}
-void SpaceSW::add_object(CollisionObjectSW *p_object) {
+void Space3DSW::add_object(CollisionObject3DSW *p_object) {
ERR_FAIL_COND(objects.has(p_object));
objects.insert(p_object);
}
-void SpaceSW::remove_object(CollisionObjectSW *p_object) {
+void Space3DSW::remove_object(CollisionObject3DSW *p_object) {
ERR_FAIL_COND(!objects.has(p_object));
objects.erase(p_object);
}
-const Set<CollisionObjectSW *> &SpaceSW::get_objects() const {
+const Set<CollisionObject3DSW *> &Space3DSW::get_objects() const {
return objects;
}
-void SpaceSW::body_add_to_state_query_list(SelfList<BodySW> *p_body) {
+void Space3DSW::body_add_to_state_query_list(SelfList<Body3DSW> *p_body) {
state_query_list.add(p_body);
}
-void SpaceSW::body_remove_from_state_query_list(SelfList<BodySW> *p_body) {
+void Space3DSW::body_remove_from_state_query_list(SelfList<Body3DSW> *p_body) {
state_query_list.remove(p_body);
}
-void SpaceSW::area_add_to_monitor_query_list(SelfList<AreaSW> *p_area) {
+void Space3DSW::area_add_to_monitor_query_list(SelfList<Area3DSW> *p_area) {
monitor_query_list.add(p_area);
}
-void SpaceSW::area_remove_from_monitor_query_list(SelfList<AreaSW> *p_area) {
+void Space3DSW::area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area) {
monitor_query_list.remove(p_area);
}
-void SpaceSW::area_add_to_moved_list(SelfList<AreaSW> *p_area) {
+void Space3DSW::area_add_to_moved_list(SelfList<Area3DSW> *p_area) {
area_moved_list.add(p_area);
}
-void SpaceSW::area_remove_from_moved_list(SelfList<AreaSW> *p_area) {
+void Space3DSW::area_remove_from_moved_list(SelfList<Area3DSW> *p_area) {
area_moved_list.remove(p_area);
}
-const SelfList<AreaSW>::List &SpaceSW::get_moved_area_list() const {
+const SelfList<Area3DSW>::List &Space3DSW::get_moved_area_list() const {
return area_moved_list;
}
-void SpaceSW::call_queries() {
+void Space3DSW::call_queries() {
while (state_query_list.first()) {
- BodySW *b = state_query_list.first()->self();
+ Body3DSW *b = state_query_list.first()->self();
state_query_list.remove(state_query_list.first());
b->call_queries();
}
while (monitor_query_list.first()) {
- AreaSW *a = monitor_query_list.first()->self();
+ Area3DSW *a = monitor_query_list.first()->self();
monitor_query_list.remove(monitor_query_list.first());
a->call_queries();
}
}
-void SpaceSW::setup() {
+void Space3DSW::setup() {
contact_debug_count = 0;
while (inertia_update_list.first()) {
@@ -1145,65 +1145,65 @@ void SpaceSW::setup() {
}
}
-void SpaceSW::update() {
+void Space3DSW::update() {
broadphase->update();
}
-void SpaceSW::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) {
+void Space3DSW::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break;
- case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break;
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio = p_value; break;
- case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break;
- case PhysicsServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break;
+ case PhysicsServer3D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break;
}
}
-real_t SpaceSW::get_param(PhysicsServer::SpaceParameter p_param) const {
+real_t Space3DSW::get_param(PhysicsServer3D::SpaceParameter p_param) const {
switch (p_param) {
- case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius;
- case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation;
- case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration;
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold;
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold;
- case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep;
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio;
- case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias;
- case PhysicsServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth;
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius;
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation;
+ case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration;
+ case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold;
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold;
+ case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep;
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio;
+ case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias;
+ case PhysicsServer3D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth;
}
return 0;
}
-void SpaceSW::lock() {
+void Space3DSW::lock() {
locked = true;
}
-void SpaceSW::unlock() {
+void Space3DSW::unlock() {
locked = false;
}
-bool SpaceSW::is_locked() const {
+bool Space3DSW::is_locked() const {
return locked;
}
-PhysicsDirectSpaceStateSW *SpaceSW::get_direct_state() {
+PhysicsDirectSpaceState3DSW *Space3DSW::get_direct_state() {
return direct_access;
}
-SpaceSW::SpaceSW() {
+Space3DSW::Space3DSW() {
collision_pairs = 0;
active_objects = 0;
@@ -1223,19 +1223,19 @@ SpaceSW::SpaceSW() {
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/time_before_sleep", PropertyInfo(Variant::FLOAT, "physics/3d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"));
body_angular_velocity_damp_ratio = 10;
- broadphase = BroadPhaseSW::create_func();
+ broadphase = BroadPhase3DSW::create_func();
broadphase->set_pair_callback(_broadphase_pair, this);
broadphase->set_unpair_callback(_broadphase_unpair, this);
area = NULL;
- direct_access = memnew(PhysicsDirectSpaceStateSW);
+ direct_access = memnew(PhysicsDirectSpaceState3DSW);
direct_access->space = this;
for (int i = 0; i < ELAPSED_TIME_MAX; i++)
elapsed_time[i] = 0;
}
-SpaceSW::~SpaceSW() {
+Space3DSW::~Space3DSW() {
memdelete(broadphase);
memdelete(direct_access);
diff --git a/servers/physics/space_sw.h b/servers/physics_3d/space_3d_sw.h
index 9e82720a75..fb4fb6aa1f 100644
--- a/servers/physics/space_sw.h
+++ b/servers/physics_3d/space_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* space_sw.h */
+/* space_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,22 +31,22 @@
#ifndef SPACE_SW_H
#define SPACE_SW_H
-#include "area_pair_sw.h"
-#include "area_sw.h"
-#include "body_pair_sw.h"
-#include "body_sw.h"
-#include "broad_phase_sw.h"
-#include "collision_object_sw.h"
+#include "area_3d_sw.h"
+#include "area_pair_3d_sw.h"
+#include "body_3d_sw.h"
+#include "body_pair_3d_sw.h"
+#include "broad_phase_3d_sw.h"
+#include "collision_object_3d_sw.h"
#include "core/hash_map.h"
#include "core/project_settings.h"
#include "core/typedefs.h"
-class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState {
+class PhysicsDirectSpaceState3DSW : public PhysicsDirectSpaceState3D {
- GDCLASS(PhysicsDirectSpaceStateSW, PhysicsDirectSpaceState);
+ GDCLASS(PhysicsDirectSpaceState3DSW, PhysicsDirectSpaceState3D);
public:
- SpaceSW *space;
+ Space3DSW *space;
virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false);
@@ -56,10 +56,10 @@ public:
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const;
- PhysicsDirectSpaceStateSW();
+ PhysicsDirectSpaceState3DSW();
};
-class SpaceSW {
+class Space3DSW {
public:
enum ElapsedTime {
@@ -75,22 +75,22 @@ public:
private:
uint64_t elapsed_time[ELAPSED_TIME_MAX];
- PhysicsDirectSpaceStateSW *direct_access;
+ PhysicsDirectSpaceState3DSW *direct_access;
RID self;
- BroadPhaseSW *broadphase;
- SelfList<BodySW>::List active_list;
- SelfList<BodySW>::List inertia_update_list;
- SelfList<BodySW>::List state_query_list;
- SelfList<AreaSW>::List monitor_query_list;
- SelfList<AreaSW>::List area_moved_list;
+ BroadPhase3DSW *broadphase;
+ SelfList<Body3DSW>::List active_list;
+ SelfList<Body3DSW>::List inertia_update_list;
+ SelfList<Body3DSW>::List state_query_list;
+ SelfList<Area3DSW>::List monitor_query_list;
+ SelfList<Area3DSW>::List area_moved_list;
- static void *_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_self);
- static void _broadphase_unpair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_self);
+ static void *_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self);
+ static void _broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_self);
- Set<CollisionObjectSW *> objects;
+ Set<CollisionObject3DSW *> objects;
- AreaSW *area;
+ Area3DSW *area;
real_t contact_recycle_radius;
real_t contact_max_separation;
@@ -103,7 +103,7 @@ private:
INTERSECTION_QUERY_MAX = 2048
};
- CollisionObjectSW *intersection_query_results[INTERSECTION_QUERY_MAX];
+ CollisionObject3DSW *intersection_query_results[INTERSECTION_QUERY_MAX];
int intersection_query_subindex_results[INTERSECTION_QUERY_MAX];
real_t body_linear_velocity_sleep_threshold;
@@ -122,37 +122,37 @@ private:
Vector<Vector3> contact_debug;
int contact_debug_count;
- friend class PhysicsDirectSpaceStateSW;
+ friend class PhysicsDirectSpaceState3DSW;
- int _cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb);
+ int _cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb);
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- void set_default_area(AreaSW *p_area) { area = p_area; }
- AreaSW *get_default_area() const { return area; }
+ void set_default_area(Area3DSW *p_area) { area = p_area; }
+ Area3DSW *get_default_area() const { return area; }
- const SelfList<BodySW>::List &get_active_body_list() const;
- void body_add_to_active_list(SelfList<BodySW> *p_body);
- void body_remove_from_active_list(SelfList<BodySW> *p_body);
- void body_add_to_inertia_update_list(SelfList<BodySW> *p_body);
- void body_remove_from_inertia_update_list(SelfList<BodySW> *p_body);
+ const SelfList<Body3DSW>::List &get_active_body_list() const;
+ void body_add_to_active_list(SelfList<Body3DSW> *p_body);
+ void body_remove_from_active_list(SelfList<Body3DSW> *p_body);
+ void body_add_to_inertia_update_list(SelfList<Body3DSW> *p_body);
+ void body_remove_from_inertia_update_list(SelfList<Body3DSW> *p_body);
- void body_add_to_state_query_list(SelfList<BodySW> *p_body);
- void body_remove_from_state_query_list(SelfList<BodySW> *p_body);
+ void body_add_to_state_query_list(SelfList<Body3DSW> *p_body);
+ void body_remove_from_state_query_list(SelfList<Body3DSW> *p_body);
- void area_add_to_monitor_query_list(SelfList<AreaSW> *p_area);
- void area_remove_from_monitor_query_list(SelfList<AreaSW> *p_area);
- void area_add_to_moved_list(SelfList<AreaSW> *p_area);
- void area_remove_from_moved_list(SelfList<AreaSW> *p_area);
- const SelfList<AreaSW>::List &get_moved_area_list() const;
+ void area_add_to_monitor_query_list(SelfList<Area3DSW> *p_area);
+ void area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area);
+ void area_add_to_moved_list(SelfList<Area3DSW> *p_area);
+ void area_remove_from_moved_list(SelfList<Area3DSW> *p_area);
+ const SelfList<Area3DSW>::List &get_moved_area_list() const;
- BroadPhaseSW *get_broadphase();
+ BroadPhase3DSW *get_broadphase();
- void add_object(CollisionObjectSW *p_object);
- void remove_object(CollisionObjectSW *p_object);
- const Set<CollisionObjectSW *> &get_objects() const;
+ void add_object(CollisionObject3DSW *p_object);
+ void remove_object(CollisionObject3DSW *p_object);
+ const Set<CollisionObject3DSW *> &get_objects() const;
_FORCE_INLINE_ real_t get_contact_recycle_radius() const { return contact_recycle_radius; }
_FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; }
@@ -171,8 +171,8 @@ public:
void lock();
void unlock();
- void set_param(PhysicsServer::SpaceParameter p_param, real_t p_value);
- real_t get_param(PhysicsServer::SpaceParameter p_param) const;
+ void set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::SpaceParameter p_param) const;
void set_island_count(int p_island_count) { island_count = p_island_count; }
int get_island_count() const { return island_count; }
@@ -182,7 +182,7 @@ public:
int get_collision_pairs() const { return collision_pairs; }
- PhysicsDirectSpaceStateSW *get_direct_state();
+ PhysicsDirectSpaceState3DSW *get_direct_state();
void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); }
_FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.empty(); }
@@ -198,11 +198,11 @@ public:
void set_elapsed_time(ElapsedTime p_time, uint64_t p_msec) { elapsed_time[p_time] = p_msec; }
uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; }
- int test_body_ray_separation(BodySW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, real_t p_margin);
- bool test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes);
+ int test_body_ray_separation(Body3DSW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin);
+ bool test_body_motion(Body3DSW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes);
- SpaceSW();
- ~SpaceSW();
+ Space3DSW();
+ ~Space3DSW();
};
#endif // SPACE__SW_H
diff --git a/servers/physics/step_sw.cpp b/servers/physics_3d/step_3d_sw.cpp
index f4055ecff7..dda88b45c6 100644
--- a/servers/physics/step_sw.cpp
+++ b/servers/physics_3d/step_3d_sw.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* step_sw.cpp */
+/* step_3d_sw.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,20 +28,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "step_sw.h"
-#include "joints_sw.h"
+#include "step_3d_sw.h"
+#include "joints_3d_sw.h"
#include "core/os/os.h"
-void StepSW::_populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW **p_constraint_island) {
+void Step3DSW::_populate_island(Body3DSW *p_body, Body3DSW **p_island, Constraint3DSW **p_constraint_island) {
p_body->set_island_step(_step);
p_body->set_island_next(*p_island);
*p_island = p_body;
- for (Map<ConstraintSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) {
+ for (Map<Constraint3DSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) {
- ConstraintSW *c = (ConstraintSW *)E->key();
+ Constraint3DSW *c = (Constraint3DSW *)E->key();
if (c->get_island_step() == _step)
continue; //already processed
c->set_island_step(_step);
@@ -51,17 +51,17 @@ void StepSW::_populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW **
for (int i = 0; i < c->get_body_count(); i++) {
if (i == E->get())
continue;
- BodySW *b = c->get_body_ptr()[i];
- if (b->get_island_step() == _step || b->get_mode() == PhysicsServer::BODY_MODE_STATIC || b->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC)
+ Body3DSW *b = c->get_body_ptr()[i];
+ if (b->get_island_step() == _step || b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC)
continue; //no go
_populate_island(c->get_body_ptr()[i], p_island, p_constraint_island);
}
}
}
-void StepSW::_setup_island(ConstraintSW *p_island, real_t p_delta) {
+void Step3DSW::_setup_island(Constraint3DSW *p_island, real_t p_delta) {
- ConstraintSW *ci = p_island;
+ Constraint3DSW *ci = p_island;
while (ci) {
ci->setup(p_delta);
//todo remove from island if process fails
@@ -69,7 +69,7 @@ void StepSW::_setup_island(ConstraintSW *p_island, real_t p_delta) {
}
}
-void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_delta) {
+void Step3DSW::_solve_island(Constraint3DSW *p_island, int p_iterations, real_t p_delta) {
int at_priority = 1;
@@ -77,7 +77,7 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de
for (int i = 0; i < p_iterations; i++) {
- ConstraintSW *ci = p_island;
+ Constraint3DSW *ci = p_island;
while (ci) {
ci->solve(p_delta);
ci = ci->get_island_next();
@@ -87,8 +87,8 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de
at_priority++;
{
- ConstraintSW *ci = p_island;
- ConstraintSW *prev = NULL;
+ Constraint3DSW *ci = p_island;
+ Constraint3DSW *prev = NULL;
while (ci) {
if (ci->get_priority() < at_priority) {
if (prev) {
@@ -107,14 +107,14 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de
}
}
-void StepSW::_check_suspend(BodySW *p_island, real_t p_delta) {
+void Step3DSW::_check_suspend(Body3DSW *p_island, real_t p_delta) {
bool can_sleep = true;
- BodySW *b = p_island;
+ Body3DSW *b = p_island;
while (b) {
- if (b->get_mode() == PhysicsServer::BODY_MODE_STATIC || b->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
}
@@ -130,7 +130,7 @@ void StepSW::_check_suspend(BodySW *p_island, real_t p_delta) {
b = p_island;
while (b) {
- if (b->get_mode() == PhysicsServer::BODY_MODE_STATIC || b->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
}
@@ -144,13 +144,13 @@ void StepSW::_check_suspend(BodySW *p_island, real_t p_delta) {
}
}
-void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
+void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
p_space->lock(); // can't access space during this
p_space->setup(); //update inertias, etc
- const SelfList<BodySW>::List *body_list = &p_space->get_active_body_list();
+ const SelfList<Body3DSW>::List *body_list = &p_space->get_active_body_list();
/* INTEGRATE FORCES */
@@ -159,7 +159,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
int active_count = 0;
- const SelfList<BodySW> *b = body_list->first();
+ const SelfList<Body3DSW> *b = body_list->first();
while (b) {
b->self()->integrate_forces(p_delta);
@@ -171,25 +171,25 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
{ //profile
profile_endtime = OS::get_singleton()->get_ticks_usec();
- p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_INTEGRATE_FORCES, profile_endtime - profile_begtime);
+ p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_INTEGRATE_FORCES, profile_endtime - profile_begtime);
profile_begtime = profile_endtime;
}
/* GENERATE CONSTRAINT ISLANDS */
- BodySW *island_list = NULL;
- ConstraintSW *constraint_island_list = NULL;
+ Body3DSW *island_list = NULL;
+ Constraint3DSW *constraint_island_list = NULL;
b = body_list->first();
int island_count = 0;
while (b) {
- BodySW *body = b->self();
+ Body3DSW *body = b->self();
if (body->get_island_step() != _step) {
- BodySW *island = NULL;
- ConstraintSW *constraint_island = NULL;
+ Body3DSW *island = NULL;
+ Constraint3DSW *constraint_island = NULL;
_populate_island(body, &island, &constraint_island);
island->set_island_list_next(island_list);
@@ -206,12 +206,12 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
p_space->set_island_count(island_count);
- const SelfList<AreaSW>::List &aml = p_space->get_moved_area_list();
+ const SelfList<Area3DSW>::List &aml = p_space->get_moved_area_list();
while (aml.first()) {
- for (const Set<ConstraintSW *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) {
+ for (const Set<Constraint3DSW *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) {
- ConstraintSW *c = E->get();
+ Constraint3DSW *c = E->get();
if (c->get_island_step() == _step)
continue;
c->set_island_step(_step);
@@ -219,19 +219,19 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
c->set_island_list_next(constraint_island_list);
constraint_island_list = c;
}
- p_space->area_remove_from_moved_list((SelfList<AreaSW> *)aml.first()); //faster to remove here
+ p_space->area_remove_from_moved_list((SelfList<Area3DSW> *)aml.first()); //faster to remove here
}
{ //profile
profile_endtime = OS::get_singleton()->get_ticks_usec();
- p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_GENERATE_ISLANDS, profile_endtime - profile_begtime);
+ p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_GENERATE_ISLANDS, profile_endtime - profile_begtime);
profile_begtime = profile_endtime;
}
/* SETUP CONSTRAINT ISLANDS */
{
- ConstraintSW *ci = constraint_island_list;
+ Constraint3DSW *ci = constraint_island_list;
while (ci) {
_setup_island(ci, p_delta);
@@ -241,14 +241,14 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
{ //profile
profile_endtime = OS::get_singleton()->get_ticks_usec();
- p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_SETUP_CONSTRAINTS, profile_endtime - profile_begtime);
+ p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_SETUP_CONSTRAINTS, profile_endtime - profile_begtime);
profile_begtime = profile_endtime;
}
/* SOLVE CONSTRAINT ISLANDS */
{
- ConstraintSW *ci = constraint_island_list;
+ Constraint3DSW *ci = constraint_island_list;
while (ci) {
//iterating each island separatedly improves cache efficiency
_solve_island(ci, p_iterations, p_delta);
@@ -258,7 +258,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
{ //profile
profile_endtime = OS::get_singleton()->get_ticks_usec();
- p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_SOLVE_CONSTRAINTS, profile_endtime - profile_begtime);
+ p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_SOLVE_CONSTRAINTS, profile_endtime - profile_begtime);
profile_begtime = profile_endtime;
}
@@ -266,7 +266,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
b = body_list->first();
while (b) {
- const SelfList<BodySW> *n = b->next();
+ const SelfList<Body3DSW> *n = b->next();
b->self()->integrate_velocities(p_delta);
b = n;
}
@@ -274,7 +274,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
/* SLEEP / WAKE UP ISLANDS */
{
- BodySW *bi = island_list;
+ Body3DSW *bi = island_list;
while (bi) {
_check_suspend(bi, p_delta);
@@ -284,7 +284,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
{ //profile
profile_endtime = OS::get_singleton()->get_ticks_usec();
- p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_INTEGRATE_VELOCITIES, profile_endtime - profile_begtime);
+ p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_INTEGRATE_VELOCITIES, profile_endtime - profile_begtime);
profile_begtime = profile_endtime;
}
@@ -293,7 +293,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
_step++;
}
-StepSW::StepSW() {
+Step3DSW::Step3DSW() {
_step = 1;
}
diff --git a/servers/physics/step_sw.h b/servers/physics_3d/step_3d_sw.h
index 40022ef8b9..c735688a9e 100644
--- a/servers/physics/step_sw.h
+++ b/servers/physics_3d/step_3d_sw.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* step_sw.h */
+/* step_3d_sw.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,20 +31,20 @@
#ifndef STEP_SW_H
#define STEP_SW_H
-#include "space_sw.h"
+#include "space_3d_sw.h"
-class StepSW {
+class Step3DSW {
uint64_t _step;
- void _populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW **p_constraint_island);
- void _setup_island(ConstraintSW *p_island, real_t p_delta);
- void _solve_island(ConstraintSW *p_island, int p_iterations, real_t p_delta);
- void _check_suspend(BodySW *p_island, real_t p_delta);
+ void _populate_island(Body3DSW *p_body, Body3DSW **p_island, Constraint3DSW **p_constraint_island);
+ void _setup_island(Constraint3DSW *p_island, real_t p_delta);
+ void _solve_island(Constraint3DSW *p_island, int p_iterations, real_t p_delta);
+ void _check_suspend(Body3DSW *p_island, real_t p_delta);
public:
- void step(SpaceSW *p_space, real_t p_delta, int p_iterations);
- StepSW();
+ void step(Space3DSW *p_space, real_t p_delta, int p_iterations);
+ Step3DSW();
};
#endif // STEP__SW_H
diff --git a/servers/physics_2d_server.cpp b/servers/physics_server_2d.cpp
index 1f92d6e419..11fa2acc1a 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_server_2d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_2d_server.cpp */
+/* physics_server_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physics_2d_server.h"
+#include "physics_server_2d.h"
#include "core/method_bind_ext.gen.inc"
#include "core/print_string.h"
#include "core/project_settings.h"
-Physics2DServer *Physics2DServer::singleton = NULL;
+PhysicsServer2D *PhysicsServer2D::singleton = NULL;
-void Physics2DDirectBodyState::integrate_forces() {
+void PhysicsDirectBodyState2D::integrate_forces() {
real_t step = get_step();
Vector2 lv = get_linear_velocity();
@@ -62,61 +62,61 @@ void Physics2DDirectBodyState::integrate_forces() {
set_angular_velocity(av);
}
-Object *Physics2DDirectBodyState::get_contact_collider_object(int p_contact_idx) const {
+Object *PhysicsDirectBodyState2D::get_contact_collider_object(int p_contact_idx) const {
ObjectID objid = get_contact_collider_id(p_contact_idx);
Object *obj = ObjectDB::get_instance(objid);
return obj;
}
-Physics2DServer *Physics2DServer::get_singleton() {
+PhysicsServer2D *PhysicsServer2D::get_singleton() {
return singleton;
}
-void Physics2DDirectBodyState::_bind_methods() {
+void PhysicsDirectBodyState2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_total_gravity"), &Physics2DDirectBodyState::get_total_gravity);
- ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &Physics2DDirectBodyState::get_total_linear_damp);
- ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &Physics2DDirectBodyState::get_total_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState2D::get_total_gravity);
+ ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState2D::get_total_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp);
- ClassDB::bind_method(D_METHOD("get_inverse_mass"), &Physics2DDirectBodyState::get_inverse_mass);
- ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &Physics2DDirectBodyState::get_inverse_inertia);
+ ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState2D::get_inverse_mass);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState2D::get_inverse_inertia);
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &Physics2DDirectBodyState::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &Physics2DDirectBodyState::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState2D::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState2D::get_linear_velocity);
- ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &Physics2DDirectBodyState::set_angular_velocity);
- ClassDB::bind_method(D_METHOD("get_angular_velocity"), &Physics2DDirectBodyState::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState2D::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState2D::get_angular_velocity);
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &Physics2DDirectBodyState::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &Physics2DDirectBodyState::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState2D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState2D::get_transform);
- ClassDB::bind_method(D_METHOD("add_central_force", "force"), &Physics2DDirectBodyState::add_central_force);
- ClassDB::bind_method(D_METHOD("add_force", "offset", "force"), &Physics2DDirectBodyState::add_force);
- ClassDB::bind_method(D_METHOD("add_torque", "torque"), &Physics2DDirectBodyState::add_torque);
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &Physics2DDirectBodyState::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &Physics2DDirectBodyState::apply_torque_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "offset", "impulse"), &Physics2DDirectBodyState::apply_impulse);
+ ClassDB::bind_method(D_METHOD("add_central_force", "force"), &PhysicsDirectBodyState2D::add_central_force);
+ ClassDB::bind_method(D_METHOD("add_force", "offset", "force"), &PhysicsDirectBodyState2D::add_force);
+ ClassDB::bind_method(D_METHOD("add_torque", "torque"), &PhysicsDirectBodyState2D::add_torque);
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "offset", "impulse"), &PhysicsDirectBodyState2D::apply_impulse);
- ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &Physics2DDirectBodyState::set_sleep_state);
- ClassDB::bind_method(D_METHOD("is_sleeping"), &Physics2DDirectBodyState::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState2D::set_sleep_state);
+ ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState2D::is_sleeping);
- ClassDB::bind_method(D_METHOD("get_contact_count"), &Physics2DDirectBodyState::get_contact_count);
+ ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState2D::get_contact_count);
- ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &Physics2DDirectBodyState::get_contact_local_position);
- ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &Physics2DDirectBodyState::get_contact_local_normal);
- ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &Physics2DDirectBodyState::get_contact_local_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider);
- ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_position);
- ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_id);
- ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_object);
- ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider_shape_metadata", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_shape_metadata);
- ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_velocity_at_position);
- ClassDB::bind_method(D_METHOD("get_step"), &Physics2DDirectBodyState::get_step);
- ClassDB::bind_method(D_METHOD("integrate_forces"), &Physics2DDirectBodyState::integrate_forces);
- ClassDB::bind_method(D_METHOD("get_space_state"), &Physics2DDirectBodyState::get_space_state);
+ ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_position);
+ ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_normal);
+ ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_position);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_id);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_object);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape_metadata", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape_metadata);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_velocity_at_position);
+ ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState2D::get_step);
+ ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState2D::integrate_forces);
+ ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState2D::get_space_state);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass");
@@ -130,70 +130,70 @@ void Physics2DDirectBodyState::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
}
-Physics2DDirectBodyState::Physics2DDirectBodyState() {}
+PhysicsDirectBodyState2D::PhysicsDirectBodyState2D() {}
///////////////////////////////////////////////////////
-void Physics2DShapeQueryParameters::set_shape(const RES &p_shape) {
+void PhysicsShapeQueryParameters2D::set_shape(const RES &p_shape) {
ERR_FAIL_COND(p_shape.is_null());
shape = p_shape->get_rid();
}
-void Physics2DShapeQueryParameters::set_shape_rid(const RID &p_shape) {
+void PhysicsShapeQueryParameters2D::set_shape_rid(const RID &p_shape) {
shape = p_shape;
}
-RID Physics2DShapeQueryParameters::get_shape_rid() const {
+RID PhysicsShapeQueryParameters2D::get_shape_rid() const {
return shape;
}
-void Physics2DShapeQueryParameters::set_transform(const Transform2D &p_transform) {
+void PhysicsShapeQueryParameters2D::set_transform(const Transform2D &p_transform) {
transform = p_transform;
}
-Transform2D Physics2DShapeQueryParameters::get_transform() const {
+Transform2D PhysicsShapeQueryParameters2D::get_transform() const {
return transform;
}
-void Physics2DShapeQueryParameters::set_motion(const Vector2 &p_motion) {
+void PhysicsShapeQueryParameters2D::set_motion(const Vector2 &p_motion) {
motion = p_motion;
}
-Vector2 Physics2DShapeQueryParameters::get_motion() const {
+Vector2 PhysicsShapeQueryParameters2D::get_motion() const {
return motion;
}
-void Physics2DShapeQueryParameters::set_margin(float p_margin) {
+void PhysicsShapeQueryParameters2D::set_margin(float p_margin) {
margin = p_margin;
}
-float Physics2DShapeQueryParameters::get_margin() const {
+float PhysicsShapeQueryParameters2D::get_margin() const {
return margin;
}
-void Physics2DShapeQueryParameters::set_collision_mask(int p_collision_mask) {
+void PhysicsShapeQueryParameters2D::set_collision_mask(int p_collision_mask) {
collision_mask = p_collision_mask;
}
-int Physics2DShapeQueryParameters::get_collision_mask() const {
+int PhysicsShapeQueryParameters2D::get_collision_mask() const {
return collision_mask;
}
-void Physics2DShapeQueryParameters::set_exclude(const Vector<RID> &p_exclude) {
+void PhysicsShapeQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) {
exclude.clear();
for (int i = 0; i < p_exclude.size(); i++)
exclude.insert(p_exclude[i]);
}
-Vector<RID> Physics2DShapeQueryParameters::get_exclude() const {
+Vector<RID> PhysicsShapeQueryParameters2D::get_exclude() const {
Vector<RID> ret;
ret.resize(exclude.size());
@@ -204,48 +204,48 @@ Vector<RID> Physics2DShapeQueryParameters::get_exclude() const {
return ret;
}
-void Physics2DShapeQueryParameters::set_collide_with_bodies(bool p_enable) {
+void PhysicsShapeQueryParameters2D::set_collide_with_bodies(bool p_enable) {
collide_with_bodies = p_enable;
}
-bool Physics2DShapeQueryParameters::is_collide_with_bodies_enabled() const {
+bool PhysicsShapeQueryParameters2D::is_collide_with_bodies_enabled() const {
return collide_with_bodies;
}
-void Physics2DShapeQueryParameters::set_collide_with_areas(bool p_enable) {
+void PhysicsShapeQueryParameters2D::set_collide_with_areas(bool p_enable) {
collide_with_areas = p_enable;
}
-bool Physics2DShapeQueryParameters::is_collide_with_areas_enabled() const {
+bool PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled() const {
return collide_with_areas;
}
-void Physics2DShapeQueryParameters::_bind_methods() {
+void PhysicsShapeQueryParameters2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &Physics2DShapeQueryParameters::set_shape);
- ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &Physics2DShapeQueryParameters::set_shape_rid);
- ClassDB::bind_method(D_METHOD("get_shape_rid"), &Physics2DShapeQueryParameters::get_shape_rid);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters2D::set_shape);
+ ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters2D::set_shape_rid);
+ ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters2D::get_shape_rid);
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &Physics2DShapeQueryParameters::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &Physics2DShapeQueryParameters::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters2D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters2D::get_transform);
- ClassDB::bind_method(D_METHOD("set_motion", "motion"), &Physics2DShapeQueryParameters::set_motion);
- ClassDB::bind_method(D_METHOD("get_motion"), &Physics2DShapeQueryParameters::get_motion);
+ ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsShapeQueryParameters2D::set_motion);
+ ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsShapeQueryParameters2D::get_motion);
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Physics2DShapeQueryParameters::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &Physics2DShapeQueryParameters::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters2D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters2D::get_margin);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Physics2DShapeQueryParameters::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &Physics2DShapeQueryParameters::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &PhysicsShapeQueryParameters2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsShapeQueryParameters2D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &Physics2DShapeQueryParameters::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &Physics2DShapeQueryParameters::get_exclude);
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters2D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters2D::get_exclude);
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &Physics2DShapeQueryParameters::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &Physics2DShapeQueryParameters::is_collide_with_bodies_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_bodies_enabled);
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &Physics2DShapeQueryParameters::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &Physics2DShapeQueryParameters::is_collide_with_areas_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled);
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_NONE, itos(Variant::_RID) + ":"), "set_exclude", "get_exclude");
@@ -258,7 +258,7 @@ void Physics2DShapeQueryParameters::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
}
-Physics2DShapeQueryParameters::Physics2DShapeQueryParameters() {
+PhysicsShapeQueryParameters2D::PhysicsShapeQueryParameters2D() {
margin = 0;
collision_mask = 0x7FFFFFFF;
@@ -266,7 +266,7 @@ Physics2DShapeQueryParameters::Physics2DShapeQueryParameters() {
collide_with_areas = false;
}
-Dictionary Physics2DDirectSpaceState::_intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
+Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
RayResult inters;
Set<RID> exclude;
@@ -290,7 +290,7 @@ Dictionary Physics2DDirectSpaceState::_intersect_ray(const Vector2 &p_from, cons
return d;
}
-Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) {
+Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
@@ -313,7 +313,7 @@ Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryP
return ret;
}
-Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParameters> &p_shape_query) {
+Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
@@ -328,7 +328,7 @@ Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParam
return ret;
}
-Array Physics2DDirectSpaceState::_intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
+Array PhysicsDirectSpaceState2D::_intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
Set<RID> exclude;
for (int i = 0; i < p_exclude.size(); i++)
@@ -361,17 +361,17 @@ Array Physics2DDirectSpaceState::_intersect_point_impl(const Vector2 &p_point, i
return r;
}
-Array Physics2DDirectSpaceState::_intersect_point(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
+Array PhysicsDirectSpaceState2D::_intersect_point(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
return _intersect_point_impl(p_point, p_max_results, p_exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
}
-Array Physics2DDirectSpaceState::_intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
+Array PhysicsDirectSpaceState2D::_intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
return _intersect_point_impl(p_point, p_max_results, p_exclude, p_layers, p_collide_with_bodies, p_collide_with_areas, true, p_canvas_intance_id);
}
-Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) {
+Array PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
@@ -387,7 +387,7 @@ Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryPar
r[i] = ret[i];
return r;
}
-Dictionary Physics2DDirectSpaceState::_get_rest_info(const Ref<Physics2DShapeQueryParameters> &p_shape_query) {
+Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary());
@@ -409,105 +409,105 @@ Dictionary Physics2DDirectSpaceState::_get_rest_info(const Ref<Physics2DShapeQue
return r;
}
-Physics2DDirectSpaceState::Physics2DDirectSpaceState() {
+PhysicsDirectSpaceState2D::PhysicsDirectSpaceState2D() {
}
-void Physics2DDirectSpaceState::_bind_methods() {
+void PhysicsDirectSpaceState2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("intersect_point", "point", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &Physics2DDirectSpaceState::_intersect_point, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("intersect_point_on_canvas", "point", "canvas_instance_id", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &Physics2DDirectSpaceState::_intersect_point_on_canvas, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &Physics2DDirectSpaceState::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &Physics2DDirectSpaceState::_intersect_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("cast_motion", "shape"), &Physics2DDirectSpaceState::_cast_motion);
- ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &Physics2DDirectSpaceState::_collide_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &Physics2DDirectSpaceState::_get_rest_info);
+ ClassDB::bind_method(D_METHOD("intersect_point", "point", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("intersect_point_on_canvas", "point", "canvas_instance_id", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point_on_canvas, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState2D::_intersect_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("cast_motion", "shape"), &PhysicsDirectSpaceState2D::_cast_motion);
+ ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState2D::_collide_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState2D::_get_rest_info);
}
-int Physics2DShapeQueryResult::get_result_count() const {
+int PhysicsShapeQueryResult2D::get_result_count() const {
return result.size();
}
-RID Physics2DShapeQueryResult::get_result_rid(int p_idx) const {
+RID PhysicsShapeQueryResult2D::get_result_rid(int p_idx) const {
return result[p_idx].rid;
}
-ObjectID Physics2DShapeQueryResult::get_result_object_id(int p_idx) const {
+ObjectID PhysicsShapeQueryResult2D::get_result_object_id(int p_idx) const {
return result[p_idx].collider_id;
}
-Object *Physics2DShapeQueryResult::get_result_object(int p_idx) const {
+Object *PhysicsShapeQueryResult2D::get_result_object(int p_idx) const {
return result[p_idx].collider;
}
-int Physics2DShapeQueryResult::get_result_object_shape(int p_idx) const {
+int PhysicsShapeQueryResult2D::get_result_object_shape(int p_idx) const {
return result[p_idx].shape;
}
-Physics2DShapeQueryResult::Physics2DShapeQueryResult() {
+PhysicsShapeQueryResult2D::PhysicsShapeQueryResult2D() {
}
-void Physics2DShapeQueryResult::_bind_methods() {
+void PhysicsShapeQueryResult2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_result_count"), &Physics2DShapeQueryResult::get_result_count);
- ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &Physics2DShapeQueryResult::get_result_rid);
- ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &Physics2DShapeQueryResult::get_result_object_id);
- ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &Physics2DShapeQueryResult::get_result_object);
- ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &Physics2DShapeQueryResult::get_result_object_shape);
+ ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult2D::get_result_count);
+ ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult2D::get_result_rid);
+ ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult2D::get_result_object_id);
+ ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult2D::get_result_object);
+ ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult2D::get_result_object_shape);
}
///////////////////////////////
-Vector2 Physics2DTestMotionResult::get_motion() const {
+Vector2 PhysicsTestMotionResult2D::get_motion() const {
return result.motion;
}
-Vector2 Physics2DTestMotionResult::get_motion_remainder() const {
+Vector2 PhysicsTestMotionResult2D::get_motion_remainder() const {
return result.remainder;
}
-Vector2 Physics2DTestMotionResult::get_collision_point() const {
+Vector2 PhysicsTestMotionResult2D::get_collision_point() const {
return result.collision_point;
}
-Vector2 Physics2DTestMotionResult::get_collision_normal() const {
+Vector2 PhysicsTestMotionResult2D::get_collision_normal() const {
return result.collision_normal;
}
-Vector2 Physics2DTestMotionResult::get_collider_velocity() const {
+Vector2 PhysicsTestMotionResult2D::get_collider_velocity() const {
return result.collider_velocity;
}
-ObjectID Physics2DTestMotionResult::get_collider_id() const {
+ObjectID PhysicsTestMotionResult2D::get_collider_id() const {
return result.collider_id;
}
-RID Physics2DTestMotionResult::get_collider_rid() const {
+RID PhysicsTestMotionResult2D::get_collider_rid() const {
return result.collider;
}
-Object *Physics2DTestMotionResult::get_collider() const {
+Object *PhysicsTestMotionResult2D::get_collider() const {
return ObjectDB::get_instance(result.collider_id);
}
-int Physics2DTestMotionResult::get_collider_shape() const {
+int PhysicsTestMotionResult2D::get_collider_shape() const {
return result.collider_shape;
}
-void Physics2DTestMotionResult::_bind_methods() {
+void PhysicsTestMotionResult2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_motion"), &Physics2DTestMotionResult::get_motion);
- ClassDB::bind_method(D_METHOD("get_motion_remainder"), &Physics2DTestMotionResult::get_motion_remainder);
- ClassDB::bind_method(D_METHOD("get_collision_point"), &Physics2DTestMotionResult::get_collision_point);
- ClassDB::bind_method(D_METHOD("get_collision_normal"), &Physics2DTestMotionResult::get_collision_normal);
- ClassDB::bind_method(D_METHOD("get_collider_velocity"), &Physics2DTestMotionResult::get_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collider_id"), &Physics2DTestMotionResult::get_collider_id);
- ClassDB::bind_method(D_METHOD("get_collider_rid"), &Physics2DTestMotionResult::get_collider_rid);
- ClassDB::bind_method(D_METHOD("get_collider"), &Physics2DTestMotionResult::get_collider);
- ClassDB::bind_method(D_METHOD("get_collider_shape"), &Physics2DTestMotionResult::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionResult2D::get_motion);
+ ClassDB::bind_method(D_METHOD("get_motion_remainder"), &PhysicsTestMotionResult2D::get_motion_remainder);
+ ClassDB::bind_method(D_METHOD("get_collision_point"), &PhysicsTestMotionResult2D::get_collision_point);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"), &PhysicsTestMotionResult2D::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &PhysicsTestMotionResult2D::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsTestMotionResult2D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsTestMotionResult2D::get_collider_rid);
+ ClassDB::bind_method(D_METHOD("get_collider"), &PhysicsTestMotionResult2D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsTestMotionResult2D::get_collider_shape);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "", "get_motion");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion_remainder"), "", "get_motion_remainder");
@@ -520,7 +520,7 @@ void Physics2DTestMotionResult::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape");
}
-Physics2DTestMotionResult::Physics2DTestMotionResult() {
+PhysicsTestMotionResult2D::PhysicsTestMotionResult2D() {
colliding = false;
@@ -529,7 +529,7 @@ Physics2DTestMotionResult::Physics2DTestMotionResult() {
///////////////////////////////////////
-bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) {
+bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
MotionResult *r = NULL;
if (p_result.is_valid())
@@ -537,154 +537,154 @@ bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, c
return body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r);
}
-void Physics2DServer::_bind_methods() {
+void PhysicsServer2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("line_shape_create"), &Physics2DServer::line_shape_create);
- ClassDB::bind_method(D_METHOD("ray_shape_create"), &Physics2DServer::ray_shape_create);
- ClassDB::bind_method(D_METHOD("segment_shape_create"), &Physics2DServer::segment_shape_create);
- ClassDB::bind_method(D_METHOD("circle_shape_create"), &Physics2DServer::circle_shape_create);
- ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &Physics2DServer::rectangle_shape_create);
- ClassDB::bind_method(D_METHOD("capsule_shape_create"), &Physics2DServer::capsule_shape_create);
- ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &Physics2DServer::convex_polygon_shape_create);
- ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &Physics2DServer::concave_polygon_shape_create);
+ ClassDB::bind_method(D_METHOD("line_shape_create"), &PhysicsServer2D::line_shape_create);
+ ClassDB::bind_method(D_METHOD("ray_shape_create"), &PhysicsServer2D::ray_shape_create);
+ ClassDB::bind_method(D_METHOD("segment_shape_create"), &PhysicsServer2D::segment_shape_create);
+ ClassDB::bind_method(D_METHOD("circle_shape_create"), &PhysicsServer2D::circle_shape_create);
+ ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &PhysicsServer2D::rectangle_shape_create);
+ ClassDB::bind_method(D_METHOD("capsule_shape_create"), &PhysicsServer2D::capsule_shape_create);
+ ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &PhysicsServer2D::convex_polygon_shape_create);
+ ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &PhysicsServer2D::concave_polygon_shape_create);
- ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &Physics2DServer::shape_set_data);
+ ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer2D::shape_set_data);
- ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &Physics2DServer::shape_get_type);
- ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &Physics2DServer::shape_get_data);
+ ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer2D::shape_get_type);
+ ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer2D::shape_get_data);
- ClassDB::bind_method(D_METHOD("space_create"), &Physics2DServer::space_create);
- ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &Physics2DServer::space_set_active);
- ClassDB::bind_method(D_METHOD("space_is_active", "space"), &Physics2DServer::space_is_active);
- ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &Physics2DServer::space_set_param);
- ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &Physics2DServer::space_get_param);
- ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &Physics2DServer::space_get_direct_state);
+ ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer2D::space_create);
+ ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer2D::space_set_active);
+ ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer2D::space_is_active);
+ ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer2D::space_set_param);
+ ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer2D::space_get_param);
+ ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer2D::space_get_direct_state);
- ClassDB::bind_method(D_METHOD("area_create"), &Physics2DServer::area_create);
- ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &Physics2DServer::area_set_space);
- ClassDB::bind_method(D_METHOD("area_get_space", "area"), &Physics2DServer::area_get_space);
+ ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer2D::area_create);
+ ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer2D::area_set_space);
+ ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer2D::area_get_space);
- ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &Physics2DServer::area_set_space_override_mode);
- ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &Physics2DServer::area_get_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer2D::area_set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer2D::area_get_space_override_mode);
- ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &Physics2DServer::area_add_shape, DEFVAL(Transform2D()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &Physics2DServer::area_set_shape);
- ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &Physics2DServer::area_set_shape_transform);
- ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &Physics2DServer::area_set_shape_disabled);
+ ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer2D::area_add_shape, DEFVAL(Transform2D()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer2D::area_set_shape);
+ ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer2D::area_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &PhysicsServer2D::area_set_shape_disabled);
- ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &Physics2DServer::area_get_shape_count);
- ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &Physics2DServer::area_get_shape);
- ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &Physics2DServer::area_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer2D::area_get_shape_count);
+ ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer2D::area_get_shape);
+ ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer2D::area_get_shape_transform);
- ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &Physics2DServer::area_remove_shape);
- ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &Physics2DServer::area_clear_shapes);
+ ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer2D::area_remove_shape);
+ ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer2D::area_clear_shapes);
- ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &Physics2DServer::area_set_collision_layer);
- ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &Physics2DServer::area_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer2D::area_set_collision_layer);
+ ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer2D::area_set_collision_mask);
- ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &Physics2DServer::area_set_param);
- ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &Physics2DServer::area_set_transform);
+ ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer2D::area_set_param);
+ ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer2D::area_set_transform);
- ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &Physics2DServer::area_get_param);
- ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &Physics2DServer::area_get_transform);
+ ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer2D::area_get_param);
+ ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer2D::area_get_transform);
- ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &Physics2DServer::area_attach_object_instance_id);
- ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &Physics2DServer::area_get_object_instance_id);
+ ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer2D::area_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer2D::area_get_object_instance_id);
- ClassDB::bind_method(D_METHOD("area_attach_canvas_instance_id", "area", "id"), &Physics2DServer::area_attach_canvas_instance_id);
- ClassDB::bind_method(D_METHOD("area_get_canvas_instance_id", "area"), &Physics2DServer::area_get_canvas_instance_id);
+ ClassDB::bind_method(D_METHOD("area_attach_canvas_instance_id", "area", "id"), &PhysicsServer2D::area_attach_canvas_instance_id);
+ ClassDB::bind_method(D_METHOD("area_get_canvas_instance_id", "area"), &PhysicsServer2D::area_get_canvas_instance_id);
- ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &Physics2DServer::area_set_monitor_callback);
- ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &Physics2DServer::area_set_area_monitor_callback);
- ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &Physics2DServer::area_set_monitorable);
+ ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer2D::area_set_monitor_callback);
+ ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &PhysicsServer2D::area_set_area_monitor_callback);
+ ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &PhysicsServer2D::area_set_monitorable);
- ClassDB::bind_method(D_METHOD("body_create"), &Physics2DServer::body_create);
+ ClassDB::bind_method(D_METHOD("body_create"), &PhysicsServer2D::body_create);
- ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &Physics2DServer::body_set_space);
- ClassDB::bind_method(D_METHOD("body_get_space", "body"), &Physics2DServer::body_get_space);
+ ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer2D::body_set_space);
+ ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer2D::body_get_space);
- ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &Physics2DServer::body_set_mode);
- ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &Physics2DServer::body_get_mode);
+ ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer2D::body_set_mode);
+ ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer2D::body_get_mode);
- ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &Physics2DServer::body_add_shape, DEFVAL(Transform2D()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &Physics2DServer::body_set_shape);
- ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &Physics2DServer::body_set_shape_transform);
- ClassDB::bind_method(D_METHOD("body_set_shape_metadata", "body", "shape_idx", "metadata"), &Physics2DServer::body_set_shape_metadata);
+ ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer2D::body_add_shape, DEFVAL(Transform2D()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer2D::body_set_shape);
+ ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer2D::body_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_set_shape_metadata", "body", "shape_idx", "metadata"), &PhysicsServer2D::body_set_shape_metadata);
- ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &Physics2DServer::body_get_shape_count);
- ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &Physics2DServer::body_get_shape);
- ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &Physics2DServer::body_get_shape_transform);
- ClassDB::bind_method(D_METHOD("body_get_shape_metadata", "body", "shape_idx"), &Physics2DServer::body_get_shape_metadata);
+ ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer2D::body_get_shape_count);
+ ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer2D::body_get_shape);
+ ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer2D::body_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_get_shape_metadata", "body", "shape_idx"), &PhysicsServer2D::body_get_shape_metadata);
- ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &Physics2DServer::body_remove_shape);
- ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &Physics2DServer::body_clear_shapes);
+ ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer2D::body_remove_shape);
+ ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer2D::body_clear_shapes);
- ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &Physics2DServer::body_set_shape_disabled);
- ClassDB::bind_method(D_METHOD("body_set_shape_as_one_way_collision", "body", "shape_idx", "enable", "margin"), &Physics2DServer::body_set_shape_as_one_way_collision);
+ ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &PhysicsServer2D::body_set_shape_disabled);
+ ClassDB::bind_method(D_METHOD("body_set_shape_as_one_way_collision", "body", "shape_idx", "enable", "margin"), &PhysicsServer2D::body_set_shape_as_one_way_collision);
- ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &Physics2DServer::body_attach_object_instance_id);
- ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &Physics2DServer::body_get_object_instance_id);
+ ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer2D::body_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer2D::body_get_object_instance_id);
- ClassDB::bind_method(D_METHOD("body_attach_canvas_instance_id", "body", "id"), &Physics2DServer::body_attach_canvas_instance_id);
- ClassDB::bind_method(D_METHOD("body_get_canvas_instance_id", "body"), &Physics2DServer::body_get_canvas_instance_id);
+ ClassDB::bind_method(D_METHOD("body_attach_canvas_instance_id", "body", "id"), &PhysicsServer2D::body_attach_canvas_instance_id);
+ ClassDB::bind_method(D_METHOD("body_get_canvas_instance_id", "body"), &PhysicsServer2D::body_get_canvas_instance_id);
- ClassDB::bind_method(D_METHOD("body_set_continuous_collision_detection_mode", "body", "mode"), &Physics2DServer::body_set_continuous_collision_detection_mode);
- ClassDB::bind_method(D_METHOD("body_get_continuous_collision_detection_mode", "body"), &Physics2DServer::body_get_continuous_collision_detection_mode);
+ ClassDB::bind_method(D_METHOD("body_set_continuous_collision_detection_mode", "body", "mode"), &PhysicsServer2D::body_set_continuous_collision_detection_mode);
+ ClassDB::bind_method(D_METHOD("body_get_continuous_collision_detection_mode", "body"), &PhysicsServer2D::body_get_continuous_collision_detection_mode);
- ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &Physics2DServer::body_set_collision_layer);
- ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &Physics2DServer::body_get_collision_layer);
+ ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer2D::body_set_collision_layer);
+ ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer2D::body_get_collision_layer);
- ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &Physics2DServer::body_set_collision_mask);
- ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &Physics2DServer::body_get_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer2D::body_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer2D::body_get_collision_mask);
- ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &Physics2DServer::body_set_param);
- ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &Physics2DServer::body_get_param);
+ ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer2D::body_set_param);
+ ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer2D::body_get_param);
- ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &Physics2DServer::body_set_state);
- ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &Physics2DServer::body_get_state);
+ ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer2D::body_set_state);
+ ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer2D::body_get_state);
- ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &Physics2DServer::body_apply_central_impulse);
- ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &Physics2DServer::body_apply_torque_impulse);
- ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &Physics2DServer::body_apply_impulse);
- ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &Physics2DServer::body_add_central_force);
- ClassDB::bind_method(D_METHOD("body_add_force", "body", "offset", "force"), &Physics2DServer::body_add_force);
- ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &Physics2DServer::body_add_torque);
- ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &Physics2DServer::body_set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &PhysicsServer2D::body_apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer2D::body_apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer2D::body_apply_impulse);
+ ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &PhysicsServer2D::body_add_central_force);
+ ClassDB::bind_method(D_METHOD("body_add_force", "body", "offset", "force"), &PhysicsServer2D::body_add_force);
+ ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &PhysicsServer2D::body_add_torque);
+ ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer2D::body_set_axis_velocity);
- ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &Physics2DServer::body_add_collision_exception);
- ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &Physics2DServer::body_remove_collision_exception);
+ ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer2D::body_add_collision_exception);
+ ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer2D::body_remove_collision_exception);
- ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &Physics2DServer::body_set_max_contacts_reported);
- ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &Physics2DServer::body_get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer2D::body_set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer2D::body_get_max_contacts_reported);
- ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &Physics2DServer::body_set_omit_force_integration);
- ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &Physics2DServer::body_is_omitting_force_integration);
+ ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer2D::body_set_omit_force_integration);
+ ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer2D::body_is_omitting_force_integration);
- ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &Physics2DServer::body_set_force_integration_callback, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer2D::body_set_force_integration_callback, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &Physics2DServer::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &Physics2DServer::body_get_direct_state);
+ ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer2D::body_get_direct_state);
/* JOINT API */
- ClassDB::bind_method(D_METHOD("joint_set_param", "joint", "param", "value"), &Physics2DServer::joint_set_param);
- ClassDB::bind_method(D_METHOD("joint_get_param", "joint", "param"), &Physics2DServer::joint_get_param);
+ ClassDB::bind_method(D_METHOD("joint_set_param", "joint", "param", "value"), &PhysicsServer2D::joint_set_param);
+ ClassDB::bind_method(D_METHOD("joint_get_param", "joint", "param"), &PhysicsServer2D::joint_get_param);
- ClassDB::bind_method(D_METHOD("pin_joint_create", "anchor", "body_a", "body_b"), &Physics2DServer::pin_joint_create, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("groove_joint_create", "groove1_a", "groove2_a", "anchor_b", "body_a", "body_b"), &Physics2DServer::groove_joint_create, DEFVAL(RID()), DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("damped_spring_joint_create", "anchor_a", "anchor_b", "body_a", "body_b"), &Physics2DServer::damped_spring_joint_create, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("pin_joint_create", "anchor", "body_a", "body_b"), &PhysicsServer2D::pin_joint_create, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("groove_joint_create", "groove1_a", "groove2_a", "anchor_b", "body_a", "body_b"), &PhysicsServer2D::groove_joint_create, DEFVAL(RID()), DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("damped_spring_joint_create", "anchor_a", "anchor_b", "body_a", "body_b"), &PhysicsServer2D::damped_spring_joint_create, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("damped_string_joint_set_param", "joint", "param", "value"), &Physics2DServer::damped_string_joint_set_param);
- ClassDB::bind_method(D_METHOD("damped_string_joint_get_param", "joint", "param"), &Physics2DServer::damped_string_joint_get_param);
+ ClassDB::bind_method(D_METHOD("damped_string_joint_set_param", "joint", "param", "value"), &PhysicsServer2D::damped_string_joint_set_param);
+ ClassDB::bind_method(D_METHOD("damped_string_joint_get_param", "joint", "param"), &PhysicsServer2D::damped_string_joint_get_param);
- ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &Physics2DServer::joint_get_type);
+ ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer2D::joint_get_type);
- ClassDB::bind_method(D_METHOD("free_rid", "rid"), &Physics2DServer::free);
+ ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer2D::free);
- ClassDB::bind_method(D_METHOD("set_active", "active"), &Physics2DServer::set_active);
+ ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer2D::set_active);
- ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &Physics2DServer::get_process_info);
+ ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer2D::get_process_info);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION);
@@ -764,22 +764,22 @@ void Physics2DServer::_bind_methods() {
BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT);
}
-Physics2DServer::Physics2DServer() {
+PhysicsServer2D::PhysicsServer2D() {
singleton = this;
}
-Physics2DServer::~Physics2DServer() {
+PhysicsServer2D::~PhysicsServer2D() {
singleton = NULL;
}
-Vector<Physics2DServerManager::ClassInfo> Physics2DServerManager::physics_2d_servers;
-int Physics2DServerManager::default_server_id = -1;
-int Physics2DServerManager::default_server_priority = -1;
-const String Physics2DServerManager::setting_property_name("physics/2d/physics_engine");
+Vector<PhysicsServer2DManager::ClassInfo> PhysicsServer2DManager::physics_2d_servers;
+int PhysicsServer2DManager::default_server_id = -1;
+int PhysicsServer2DManager::default_server_priority = -1;
+const String PhysicsServer2DManager::setting_property_name("physics/2d/physics_engine");
-void Physics2DServerManager::on_servers_changed() {
+void PhysicsServer2DManager::on_servers_changed() {
String physics_servers("DEFAULT");
for (int i = get_servers_count() - 1; 0 <= i; --i) {
@@ -788,7 +788,7 @@ void Physics2DServerManager::on_servers_changed() {
ProjectSettings::get_singleton()->set_custom_property_info(setting_property_name, PropertyInfo(Variant::STRING, setting_property_name, PROPERTY_HINT_ENUM, physics_servers));
}
-void Physics2DServerManager::register_server(const String &p_name, CreatePhysics2DServerCallback p_creat_callback) {
+void PhysicsServer2DManager::register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback) {
ERR_FAIL_COND(!p_creat_callback);
ERR_FAIL_COND(find_server_id(p_name) != -1);
@@ -796,7 +796,7 @@ void Physics2DServerManager::register_server(const String &p_name, CreatePhysics
on_servers_changed();
}
-void Physics2DServerManager::set_default_server(const String &p_name, int p_priority) {
+void PhysicsServer2DManager::set_default_server(const String &p_name, int p_priority) {
const int id = find_server_id(p_name);
ERR_FAIL_COND(id == -1); // Not found
@@ -806,7 +806,7 @@ void Physics2DServerManager::set_default_server(const String &p_name, int p_prio
}
}
-int Physics2DServerManager::find_server_id(const String &p_name) {
+int PhysicsServer2DManager::find_server_id(const String &p_name) {
for (int i = physics_2d_servers.size() - 1; 0 <= i; --i) {
if (p_name == physics_2d_servers[i].name) {
@@ -816,21 +816,21 @@ int Physics2DServerManager::find_server_id(const String &p_name) {
return -1;
}
-int Physics2DServerManager::get_servers_count() {
+int PhysicsServer2DManager::get_servers_count() {
return physics_2d_servers.size();
}
-String Physics2DServerManager::get_server_name(int p_id) {
+String PhysicsServer2DManager::get_server_name(int p_id) {
ERR_FAIL_INDEX_V(p_id, get_servers_count(), "");
return physics_2d_servers[p_id].name;
}
-Physics2DServer *Physics2DServerManager::new_default_server() {
+PhysicsServer2D *PhysicsServer2DManager::new_default_server() {
ERR_FAIL_COND_V(default_server_id == -1, NULL);
return physics_2d_servers[default_server_id].create_callback();
}
-Physics2DServer *Physics2DServerManager::new_server(const String &p_name) {
+PhysicsServer2D *PhysicsServer2DManager::new_server(const String &p_name) {
int id = find_server_id(p_name);
if (id == -1) {
return NULL;
diff --git a/servers/physics_2d_server.h b/servers/physics_server_2d.h
index c923ef16b7..632371565c 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_server_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_2d_server.h */
+/* physics_server_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,11 +35,11 @@
#include "core/reference.h"
#include "core/resource.h"
-class Physics2DDirectSpaceState;
+class PhysicsDirectSpaceState2D;
-class Physics2DDirectBodyState : public Object {
+class PhysicsDirectBodyState2D : public Object {
- GDCLASS(Physics2DDirectBodyState, Object);
+ GDCLASS(PhysicsDirectBodyState2D, Object);
protected:
static void _bind_methods();
@@ -88,18 +88,18 @@ public:
virtual real_t get_step() const = 0;
virtual void integrate_forces();
- virtual Physics2DDirectSpaceState *get_space_state() = 0;
+ virtual PhysicsDirectSpaceState2D *get_space_state() = 0;
- Physics2DDirectBodyState();
+ PhysicsDirectBodyState2D();
};
-class Physics2DShapeQueryResult;
+class PhysicsShapeQueryResult2D;
//used for script
-class Physics2DShapeQueryParameters : public Reference {
+class PhysicsShapeQueryParameters2D : public Reference {
- GDCLASS(Physics2DShapeQueryParameters, Reference);
- friend class Physics2DDirectSpaceState;
+ GDCLASS(PhysicsShapeQueryParameters2D, Reference);
+ friend class PhysicsDirectSpaceState2D;
RID shape;
Transform2D transform;
Vector2 motion;
@@ -139,21 +139,21 @@ public:
void set_exclude(const Vector<RID> &p_exclude);
Vector<RID> get_exclude() const;
- Physics2DShapeQueryParameters();
+ PhysicsShapeQueryParameters2D();
};
-class Physics2DDirectSpaceState : public Object {
+class PhysicsDirectSpaceState2D : public Object {
- GDCLASS(Physics2DDirectSpaceState, Object);
+ GDCLASS(PhysicsDirectSpaceState2D, Object);
Dictionary _intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
Array _intersect_point(const Vector2 &p_point, int p_max_results = 32, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
Array _intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results = 32, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
Array _intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclud, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas = false, ObjectID p_canvas_instance_id = ObjectID());
- Array _intersect_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results = 32);
- Array _cast_motion(const Ref<Physics2DShapeQueryParameters> &p_shape_query);
- Array _collide_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results = 32);
- Dictionary _get_rest_info(const Ref<Physics2DShapeQueryParameters> &p_shape_query);
+ Array _intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32);
+ Array _cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query);
+ Array _collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32);
+ Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query);
protected:
static void _bind_methods();
@@ -203,16 +203,16 @@ public:
virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
- Physics2DDirectSpaceState();
+ PhysicsDirectSpaceState2D();
};
-class Physics2DShapeQueryResult : public Reference {
+class PhysicsShapeQueryResult2D : public Reference {
- GDCLASS(Physics2DShapeQueryResult, Reference);
+ GDCLASS(PhysicsShapeQueryResult2D, Reference);
- Vector<Physics2DDirectSpaceState::ShapeResult> result;
+ Vector<PhysicsDirectSpaceState2D::ShapeResult> result;
- friend class Physics2DDirectSpaceState;
+ friend class PhysicsDirectSpaceState2D;
protected:
static void _bind_methods();
@@ -224,24 +224,24 @@ public:
Object *get_result_object(int p_idx) const;
int get_result_object_shape(int p_idx) const;
- Physics2DShapeQueryResult();
+ PhysicsShapeQueryResult2D();
};
-class Physics2DTestMotionResult;
+class PhysicsTestMotionResult2D;
-class Physics2DServer : public Object {
+class PhysicsServer2D : public Object {
- GDCLASS(Physics2DServer, Object);
+ GDCLASS(PhysicsServer2D, Object);
- static Physics2DServer *singleton;
+ static PhysicsServer2D *singleton;
- virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
+ virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>());
protected:
static void _bind_methods();
public:
- static Physics2DServer *get_singleton();
+ static PhysicsServer2D *get_singleton();
enum ShapeType {
SHAPE_LINE, ///< plane:"plane"
@@ -296,7 +296,7 @@ public:
virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0;
// this function only works on physics process, errors and returns null otherwise
- virtual Physics2DDirectSpaceState *space_get_direct_state(RID p_space) = 0;
+ virtual PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) = 0;
virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) = 0;
virtual Vector<Vector2> space_get_contacts(RID p_space) const = 0;
@@ -490,7 +490,7 @@ public:
virtual void body_set_pickable(RID p_body, bool p_pickable) = 0;
// this function only works on physics process, errors and returns null otherwise
- virtual Physics2DDirectBodyState *body_get_direct_state(RID p_body) = 0;
+ virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) = 0;
struct MotionResult {
@@ -602,23 +602,23 @@ public:
virtual int get_process_info(ProcessInfo p_info) = 0;
- Physics2DServer();
- ~Physics2DServer();
+ PhysicsServer2D();
+ ~PhysicsServer2D();
};
-class Physics2DTestMotionResult : public Reference {
+class PhysicsTestMotionResult2D : public Reference {
- GDCLASS(Physics2DTestMotionResult, Reference);
+ GDCLASS(PhysicsTestMotionResult2D, Reference);
- Physics2DServer::MotionResult result;
+ PhysicsServer2D::MotionResult result;
bool colliding;
- friend class Physics2DServer;
+ friend class PhysicsServer2D;
protected:
static void _bind_methods();
public:
- Physics2DServer::MotionResult *get_result_ptr() const { return const_cast<Physics2DServer::MotionResult *>(&result); }
+ PhysicsServer2D::MotionResult *get_result_ptr() const { return const_cast<PhysicsServer2D::MotionResult *>(&result); }
//bool is_colliding() const;
Vector2 get_motion() const;
@@ -632,21 +632,21 @@ public:
Object *get_collider() const;
int get_collider_shape() const;
- Physics2DTestMotionResult();
+ PhysicsTestMotionResult2D();
};
-typedef Physics2DServer *(*CreatePhysics2DServerCallback)();
+typedef PhysicsServer2D *(*CreatePhysicsServer2DCallback)();
-class Physics2DServerManager {
+class PhysicsServer2DManager {
struct ClassInfo {
String name;
- CreatePhysics2DServerCallback create_callback;
+ CreatePhysicsServer2DCallback create_callback;
ClassInfo() :
name(""),
create_callback(NULL) {}
- ClassInfo(String p_name, CreatePhysics2DServerCallback p_create_callback) :
+ ClassInfo(String p_name, CreatePhysicsServer2DCallback p_create_callback) :
name(p_name),
create_callback(p_create_callback) {}
@@ -672,28 +672,28 @@ private:
static void on_servers_changed();
public:
- static void register_server(const String &p_name, CreatePhysics2DServerCallback p_creat_callback);
+ static void register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback);
static void set_default_server(const String &p_name, int p_priority = 0);
static int find_server_id(const String &p_name);
static int get_servers_count();
static String get_server_name(int p_id);
- static Physics2DServer *new_default_server();
- static Physics2DServer *new_server(const String &p_name);
+ static PhysicsServer2D *new_default_server();
+ static PhysicsServer2D *new_server(const String &p_name);
};
-VARIANT_ENUM_CAST(Physics2DServer::ShapeType);
-VARIANT_ENUM_CAST(Physics2DServer::SpaceParameter);
-VARIANT_ENUM_CAST(Physics2DServer::AreaParameter);
-VARIANT_ENUM_CAST(Physics2DServer::AreaSpaceOverrideMode);
-VARIANT_ENUM_CAST(Physics2DServer::BodyMode);
-VARIANT_ENUM_CAST(Physics2DServer::BodyParameter);
-VARIANT_ENUM_CAST(Physics2DServer::BodyState);
-VARIANT_ENUM_CAST(Physics2DServer::CCDMode);
-VARIANT_ENUM_CAST(Physics2DServer::JointParam);
-VARIANT_ENUM_CAST(Physics2DServer::JointType);
-VARIANT_ENUM_CAST(Physics2DServer::DampedStringParam);
-//VARIANT_ENUM_CAST( Physics2DServer::ObjectType );
-VARIANT_ENUM_CAST(Physics2DServer::AreaBodyStatus);
-VARIANT_ENUM_CAST(Physics2DServer::ProcessInfo);
+VARIANT_ENUM_CAST(PhysicsServer2D::ShapeType);
+VARIANT_ENUM_CAST(PhysicsServer2D::SpaceParameter);
+VARIANT_ENUM_CAST(PhysicsServer2D::AreaParameter);
+VARIANT_ENUM_CAST(PhysicsServer2D::AreaSpaceOverrideMode);
+VARIANT_ENUM_CAST(PhysicsServer2D::BodyMode);
+VARIANT_ENUM_CAST(PhysicsServer2D::BodyParameter);
+VARIANT_ENUM_CAST(PhysicsServer2D::BodyState);
+VARIANT_ENUM_CAST(PhysicsServer2D::CCDMode);
+VARIANT_ENUM_CAST(PhysicsServer2D::JointParam);
+VARIANT_ENUM_CAST(PhysicsServer2D::JointType);
+VARIANT_ENUM_CAST(PhysicsServer2D::DampedStringParam);
+//VARIANT_ENUM_CAST( PhysicsServer2D::ObjectType );
+VARIANT_ENUM_CAST(PhysicsServer2D::AreaBodyStatus);
+VARIANT_ENUM_CAST(PhysicsServer2D::ProcessInfo);
#endif
diff --git a/servers/physics_server.cpp b/servers/physics_server_3d.cpp
index 57f3a7979e..0ee471231b 100644
--- a/servers/physics_server.cpp
+++ b/servers/physics_server_3d.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_server.cpp */
+/* physics_server_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "physics_server.h"
+#include "physics_server_3d.h"
#include "core/method_bind_ext.gen.inc"
#include "core/print_string.h"
#include "core/project_settings.h"
-PhysicsServer *PhysicsServer::singleton = NULL;
+PhysicsServer3D *PhysicsServer3D::singleton = NULL;
-void PhysicsDirectBodyState::integrate_forces() {
+void PhysicsDirectBodyState3D::integrate_forces() {
real_t step = get_step();
Vector3 lv = get_linear_velocity();
@@ -61,64 +61,64 @@ void PhysicsDirectBodyState::integrate_forces() {
set_angular_velocity(av);
}
-Object *PhysicsDirectBodyState::get_contact_collider_object(int p_contact_idx) const {
+Object *PhysicsDirectBodyState3D::get_contact_collider_object(int p_contact_idx) const {
ObjectID objid = get_contact_collider_id(p_contact_idx);
Object *obj = ObjectDB::get_instance(objid);
return obj;
}
-PhysicsServer *PhysicsServer::get_singleton() {
+PhysicsServer3D *PhysicsServer3D::get_singleton() {
return singleton;
}
-void PhysicsDirectBodyState::_bind_methods() {
+void PhysicsDirectBodyState3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState::get_total_gravity);
- ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState::get_total_linear_damp);
- ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState::get_total_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState3D::get_total_gravity);
+ ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState3D::get_total_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp);
- ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState::get_center_of_mass);
- ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState::get_principal_inertia_axes);
+ ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState3D::get_center_of_mass);
+ ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState3D::get_principal_inertia_axes);
- ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState::get_inverse_mass);
- ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState::get_inverse_inertia);
+ ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState3D::get_inverse_mass);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState3D::get_inverse_inertia);
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState3D::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState3D::get_linear_velocity);
- ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState::set_angular_velocity);
- ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState3D::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState3D::get_angular_velocity);
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState3D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState3D::get_transform);
- ClassDB::bind_method(D_METHOD("add_central_force", "force"), &PhysicsDirectBodyState::add_central_force);
- ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &PhysicsDirectBodyState::add_force);
- ClassDB::bind_method(D_METHOD("add_torque", "torque"), &PhysicsDirectBodyState::add_torque);
- ClassDB::bind_method(D_METHOD("apply_central_impulse", "j"), &PhysicsDirectBodyState::apply_central_impulse);
- ClassDB::bind_method(D_METHOD("apply_impulse", "position", "j"), &PhysicsDirectBodyState::apply_impulse);
- ClassDB::bind_method(D_METHOD("apply_torque_impulse", "j"), &PhysicsDirectBodyState::apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("add_central_force", "force"), &PhysicsDirectBodyState3D::add_central_force);
+ ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &PhysicsDirectBodyState3D::add_force);
+ ClassDB::bind_method(D_METHOD("add_torque", "torque"), &PhysicsDirectBodyState3D::add_torque);
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "j"), &PhysicsDirectBodyState3D::apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "position", "j"), &PhysicsDirectBodyState3D::apply_impulse);
+ ClassDB::bind_method(D_METHOD("apply_torque_impulse", "j"), &PhysicsDirectBodyState3D::apply_torque_impulse);
- ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState::set_sleep_state);
- ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState3D::set_sleep_state);
+ ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState3D::is_sleeping);
- ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState::get_contact_count);
+ ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState3D::get_contact_count);
- ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_position);
- ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_normal);
- ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState::get_contact_impulse);
- ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider);
- ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_position);
- ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_id);
- ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_object);
- ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_shape);
- ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_velocity_at_position);
- ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState::get_step);
- ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState::integrate_forces);
- ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState::get_space_state);
+ ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_position);
+ ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_normal);
+ ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_impulse);
+ ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_position);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_id);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_object);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_velocity_at_position);
+ ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState3D::get_step);
+ ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState3D::integrate_forces);
+ ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState3D::get_space_state);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass");
@@ -134,62 +134,62 @@ void PhysicsDirectBodyState::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
}
-PhysicsDirectBodyState::PhysicsDirectBodyState() {}
+PhysicsDirectBodyState3D::PhysicsDirectBodyState3D() {}
///////////////////////////////////////////////////////
-void PhysicsShapeQueryParameters::set_shape(const RES &p_shape) {
+void PhysicsShapeQueryParameters3D::set_shape(const RES &p_shape) {
ERR_FAIL_COND(p_shape.is_null());
shape = p_shape->get_rid();
}
-void PhysicsShapeQueryParameters::set_shape_rid(const RID &p_shape) {
+void PhysicsShapeQueryParameters3D::set_shape_rid(const RID &p_shape) {
shape = p_shape;
}
-RID PhysicsShapeQueryParameters::get_shape_rid() const {
+RID PhysicsShapeQueryParameters3D::get_shape_rid() const {
return shape;
}
-void PhysicsShapeQueryParameters::set_transform(const Transform &p_transform) {
+void PhysicsShapeQueryParameters3D::set_transform(const Transform &p_transform) {
transform = p_transform;
}
-Transform PhysicsShapeQueryParameters::get_transform() const {
+Transform PhysicsShapeQueryParameters3D::get_transform() const {
return transform;
}
-void PhysicsShapeQueryParameters::set_margin(float p_margin) {
+void PhysicsShapeQueryParameters3D::set_margin(float p_margin) {
margin = p_margin;
}
-float PhysicsShapeQueryParameters::get_margin() const {
+float PhysicsShapeQueryParameters3D::get_margin() const {
return margin;
}
-void PhysicsShapeQueryParameters::set_collision_mask(int p_collision_mask) {
+void PhysicsShapeQueryParameters3D::set_collision_mask(int p_collision_mask) {
collision_mask = p_collision_mask;
}
-int PhysicsShapeQueryParameters::get_collision_mask() const {
+int PhysicsShapeQueryParameters3D::get_collision_mask() const {
return collision_mask;
}
-void PhysicsShapeQueryParameters::set_exclude(const Vector<RID> &p_exclude) {
+void PhysicsShapeQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) {
exclude.clear();
for (int i = 0; i < p_exclude.size(); i++)
exclude.insert(p_exclude[i]);
}
-Vector<RID> PhysicsShapeQueryParameters::get_exclude() const {
+Vector<RID> PhysicsShapeQueryParameters3D::get_exclude() const {
Vector<RID> ret;
ret.resize(exclude.size());
@@ -200,45 +200,45 @@ Vector<RID> PhysicsShapeQueryParameters::get_exclude() const {
return ret;
}
-void PhysicsShapeQueryParameters::set_collide_with_bodies(bool p_enable) {
+void PhysicsShapeQueryParameters3D::set_collide_with_bodies(bool p_enable) {
collide_with_bodies = p_enable;
}
-bool PhysicsShapeQueryParameters::is_collide_with_bodies_enabled() const {
+bool PhysicsShapeQueryParameters3D::is_collide_with_bodies_enabled() const {
return collide_with_bodies;
}
-void PhysicsShapeQueryParameters::set_collide_with_areas(bool p_enable) {
+void PhysicsShapeQueryParameters3D::set_collide_with_areas(bool p_enable) {
collide_with_areas = p_enable;
}
-bool PhysicsShapeQueryParameters::is_collide_with_areas_enabled() const {
+bool PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled() const {
return collide_with_areas;
}
-void PhysicsShapeQueryParameters::_bind_methods() {
+void PhysicsShapeQueryParameters3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters::set_shape);
- ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters::set_shape_rid);
- ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters::get_shape_rid);
+ ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters3D::set_shape);
+ ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters3D::set_shape_rid);
+ ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters3D::get_shape_rid);
- ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters::set_transform);
- ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters3D::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters3D::get_transform);
- ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters::set_margin);
- ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters3D::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters3D::get_margin);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters::set_exclude);
- ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters::get_exclude);
+ ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters3D::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters3D::get_exclude);
- ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters::set_collide_with_bodies);
- ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters::is_collide_with_bodies_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_bodies_enabled);
- ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters::set_collide_with_areas);
- ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters::is_collide_with_areas_enabled);
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled);
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_NONE, itos(Variant::_RID) + ":"), "set_exclude", "get_exclude");
@@ -250,7 +250,7 @@ void PhysicsShapeQueryParameters::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled");
}
-PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() {
+PhysicsShapeQueryParameters3D::PhysicsShapeQueryParameters3D() {
margin = 0;
collision_mask = 0x7FFFFFFF;
@@ -260,7 +260,7 @@ PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() {
/////////////////////////////////////
-Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
RayResult inters;
Set<RID> exclude;
@@ -283,7 +283,7 @@ Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const
return d;
}
-Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) {
+Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
@@ -305,7 +305,7 @@ Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParam
return ret;
}
-Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameters> &p_shape_query, const Vector3 &p_motion) {
+Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, const Vector3 &p_motion) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
@@ -319,7 +319,7 @@ Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameter
ret[1] = closest_unsafe;
return ret;
}
-Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) {
+Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
@@ -335,7 +335,7 @@ Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParamet
r[i] = ret[i];
return r;
}
-Dictionary PhysicsDirectSpaceState::_get_rest_info(const Ref<PhysicsShapeQueryParameters> &p_shape_query) {
+Dictionary PhysicsDirectSpaceState3D::_get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary());
@@ -356,176 +356,176 @@ Dictionary PhysicsDirectSpaceState::_get_rest_info(const Ref<PhysicsShapeQueryPa
return r;
}
-PhysicsDirectSpaceState::PhysicsDirectSpaceState() {
+PhysicsDirectSpaceState3D::PhysicsDirectSpaceState3D() {
}
-void PhysicsDirectSpaceState::_bind_methods() {
+void PhysicsDirectSpaceState3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_mask", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_intersect_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState::_cast_motion);
- ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_collide_shape, DEFVAL(32));
- ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState::_get_rest_info);
+ ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_mask", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState3D::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState3D::_intersect_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState3D::_cast_motion);
+ ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState3D::_collide_shape, DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState3D::_get_rest_info);
}
-int PhysicsShapeQueryResult::get_result_count() const {
+int PhysicsShapeQueryResult3D::get_result_count() const {
return result.size();
}
-RID PhysicsShapeQueryResult::get_result_rid(int p_idx) const {
+RID PhysicsShapeQueryResult3D::get_result_rid(int p_idx) const {
return result[p_idx].rid;
}
-ObjectID PhysicsShapeQueryResult::get_result_object_id(int p_idx) const {
+ObjectID PhysicsShapeQueryResult3D::get_result_object_id(int p_idx) const {
return result[p_idx].collider_id;
}
-Object *PhysicsShapeQueryResult::get_result_object(int p_idx) const {
+Object *PhysicsShapeQueryResult3D::get_result_object(int p_idx) const {
return result[p_idx].collider;
}
-int PhysicsShapeQueryResult::get_result_object_shape(int p_idx) const {
+int PhysicsShapeQueryResult3D::get_result_object_shape(int p_idx) const {
return result[p_idx].shape;
}
-PhysicsShapeQueryResult::PhysicsShapeQueryResult() {
+PhysicsShapeQueryResult3D::PhysicsShapeQueryResult3D() {
}
-void PhysicsShapeQueryResult::_bind_methods() {
+void PhysicsShapeQueryResult3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult::get_result_count);
- ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult::get_result_rid);
- ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult::get_result_object_id);
- ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult::get_result_object);
- ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult::get_result_object_shape);
+ ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult3D::get_result_count);
+ ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult3D::get_result_rid);
+ ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult3D::get_result_object_id);
+ ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult3D::get_result_object);
+ ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult3D::get_result_object_shape);
}
///////////////////////////////////////
-void PhysicsServer::_bind_methods() {
+void PhysicsServer3D::_bind_methods() {
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer::shape_create);
- ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer::shape_set_data);
+ ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer3D::shape_create);
+ ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer3D::shape_set_data);
- ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer::shape_get_type);
- ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer::shape_get_data);
+ ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer3D::shape_get_type);
+ ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer3D::shape_get_data);
- ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer::space_create);
- ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer::space_set_active);
- ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer::space_is_active);
- ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer::space_set_param);
- ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer::space_get_param);
- ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer::space_get_direct_state);
+ ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer3D::space_create);
+ ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer3D::space_set_active);
+ ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer3D::space_is_active);
+ ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer3D::space_set_param);
+ ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer3D::space_get_param);
+ ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer3D::space_get_direct_state);
- ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer::area_create);
- ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer::area_set_space);
- ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer::area_get_space);
+ ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer3D::area_create);
+ ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer3D::area_set_space);
+ ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer3D::area_get_space);
- ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer::area_set_space_override_mode);
- ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer::area_get_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer3D::area_set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer3D::area_get_space_override_mode);
- ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer::area_add_shape, DEFVAL(Transform()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer::area_set_shape);
- ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer::area_set_shape_transform);
- ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &PhysicsServer::area_set_shape_disabled);
+ ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer3D::area_add_shape, DEFVAL(Transform()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer3D::area_set_shape);
+ ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer3D::area_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &PhysicsServer3D::area_set_shape_disabled);
- ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer::area_get_shape_count);
- ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer::area_get_shape);
- ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer::area_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer3D::area_get_shape_count);
+ ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer3D::area_get_shape);
+ ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer3D::area_get_shape_transform);
- ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer::area_remove_shape);
- ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer::area_clear_shapes);
+ ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer3D::area_remove_shape);
+ ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer3D::area_clear_shapes);
- ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer::area_set_collision_layer);
- ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer::area_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer3D::area_set_collision_layer);
+ ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer3D::area_set_collision_mask);
- ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer::area_set_param);
- ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer::area_set_transform);
+ ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer3D::area_set_param);
+ ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer3D::area_set_transform);
- ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer::area_get_param);
- ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer::area_get_transform);
+ ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer3D::area_get_param);
+ ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer3D::area_get_transform);
- ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer::area_attach_object_instance_id);
- ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer::area_get_object_instance_id);
+ ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer3D::area_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer3D::area_get_object_instance_id);
- ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer::area_set_monitor_callback);
- ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &PhysicsServer::area_set_area_monitor_callback);
- ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &PhysicsServer::area_set_monitorable);
+ ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer3D::area_set_monitor_callback);
+ ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &PhysicsServer3D::area_set_area_monitor_callback);
+ ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &PhysicsServer3D::area_set_monitorable);
- ClassDB::bind_method(D_METHOD("area_set_ray_pickable", "area", "enable"), &PhysicsServer::area_set_ray_pickable);
- ClassDB::bind_method(D_METHOD("area_is_ray_pickable", "area"), &PhysicsServer::area_is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("area_set_ray_pickable", "area", "enable"), &PhysicsServer3D::area_set_ray_pickable);
+ ClassDB::bind_method(D_METHOD("area_is_ray_pickable", "area"), &PhysicsServer3D::area_is_ray_pickable);
- ClassDB::bind_method(D_METHOD("body_create", "mode", "init_sleeping"), &PhysicsServer::body_create, DEFVAL(BODY_MODE_RIGID), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("body_create", "mode", "init_sleeping"), &PhysicsServer3D::body_create, DEFVAL(BODY_MODE_RIGID), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer::body_set_space);
- ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer::body_get_space);
+ ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer3D::body_set_space);
+ ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer3D::body_get_space);
- ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer::body_set_mode);
- ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer::body_get_mode);
+ ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer3D::body_set_mode);
+ ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer3D::body_get_mode);
- ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer::body_set_collision_layer);
- ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer::body_get_collision_layer);
+ ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer3D::body_set_collision_layer);
+ ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer3D::body_get_collision_layer);
- ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer::body_set_collision_mask);
- ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer::body_get_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer3D::body_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer3D::body_get_collision_mask);
- ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer::body_add_shape, DEFVAL(Transform()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer::body_set_shape);
- ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer::body_set_shape_transform);
- ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &PhysicsServer::body_set_shape_disabled);
+ ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer3D::body_add_shape, DEFVAL(Transform()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer3D::body_set_shape);
+ ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer3D::body_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &PhysicsServer3D::body_set_shape_disabled);
- ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer::body_get_shape_count);
- ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer::body_get_shape);
- ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer::body_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer3D::body_get_shape_count);
+ ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer3D::body_get_shape);
+ ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer3D::body_get_shape_transform);
- ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer::body_remove_shape);
- ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer::body_clear_shapes);
+ ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer3D::body_remove_shape);
+ ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer3D::body_clear_shapes);
- ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer::body_attach_object_instance_id);
- ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer::body_get_object_instance_id);
+ ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer3D::body_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer3D::body_get_object_instance_id);
- ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer::body_set_enable_continuous_collision_detection);
- ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer::body_is_continuous_collision_detection_enabled);
+ ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer3D::body_set_enable_continuous_collision_detection);
+ ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer3D::body_is_continuous_collision_detection_enabled);
- ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer::body_set_param);
- ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer::body_get_param);
+ ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer3D::body_set_param);
+ ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer3D::body_get_param);
- ClassDB::bind_method(D_METHOD("body_set_kinematic_safe_margin", "body", "margin"), &PhysicsServer::body_set_kinematic_safe_margin);
- ClassDB::bind_method(D_METHOD("body_get_kinematic_safe_margin", "body"), &PhysicsServer::body_get_kinematic_safe_margin);
+ ClassDB::bind_method(D_METHOD("body_set_kinematic_safe_margin", "body", "margin"), &PhysicsServer3D::body_set_kinematic_safe_margin);
+ ClassDB::bind_method(D_METHOD("body_get_kinematic_safe_margin", "body"), &PhysicsServer3D::body_get_kinematic_safe_margin);
- ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer::body_set_state);
- ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer::body_get_state);
+ ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer3D::body_set_state);
+ ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer3D::body_get_state);
- ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &PhysicsServer::body_add_central_force);
- ClassDB::bind_method(D_METHOD("body_add_force", "body", "force", "position"), &PhysicsServer::body_add_force);
- ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &PhysicsServer::body_add_torque);
+ ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &PhysicsServer3D::body_add_central_force);
+ ClassDB::bind_method(D_METHOD("body_add_force", "body", "force", "position"), &PhysicsServer3D::body_add_force);
+ ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &PhysicsServer3D::body_add_torque);
- ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &PhysicsServer::body_apply_central_impulse);
- ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer::body_apply_impulse);
- ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer::body_apply_torque_impulse);
- ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer::body_set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &PhysicsServer3D::body_apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer3D::body_apply_impulse);
+ ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer3D::body_apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer3D::body_set_axis_velocity);
- ClassDB::bind_method(D_METHOD("body_set_axis_lock", "body", "axis", "lock"), &PhysicsServer::body_set_axis_lock);
- ClassDB::bind_method(D_METHOD("body_is_axis_locked", "body", "axis"), &PhysicsServer::body_is_axis_locked);
+ ClassDB::bind_method(D_METHOD("body_set_axis_lock", "body", "axis", "lock"), &PhysicsServer3D::body_set_axis_lock);
+ ClassDB::bind_method(D_METHOD("body_is_axis_locked", "body", "axis"), &PhysicsServer3D::body_is_axis_locked);
- ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer::body_add_collision_exception);
- ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer::body_remove_collision_exception);
+ ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer3D::body_add_collision_exception);
+ ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer3D::body_remove_collision_exception);
- ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer::body_set_max_contacts_reported);
- ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer::body_get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer3D::body_set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer3D::body_get_max_contacts_reported);
- ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer::body_set_omit_force_integration);
- ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer::body_is_omitting_force_integration);
+ ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer3D::body_set_omit_force_integration);
+ ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer3D::body_is_omitting_force_integration);
- ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer::body_set_force_integration_callback, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer3D::body_set_force_integration_callback, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer::body_set_ray_pickable);
- ClassDB::bind_method(D_METHOD("body_is_ray_pickable", "body"), &PhysicsServer::body_is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer3D::body_set_ray_pickable);
+ ClassDB::bind_method(D_METHOD("body_is_ray_pickable", "body"), &PhysicsServer3D::body_is_ray_pickable);
- ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer::body_get_direct_state);
+ ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer3D::body_get_direct_state);
/* JOINT API */
@@ -535,15 +535,15 @@ void PhysicsServer::_bind_methods() {
BIND_ENUM_CONSTANT(JOINT_CONE_TWIST);
BIND_ENUM_CONSTANT(JOINT_6DOF);
- ClassDB::bind_method(D_METHOD("joint_create_pin", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer::joint_create_pin);
- ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer::pin_joint_set_param);
- ClassDB::bind_method(D_METHOD("pin_joint_get_param", "joint", "param"), &PhysicsServer::pin_joint_get_param);
+ ClassDB::bind_method(D_METHOD("joint_create_pin", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer3D::joint_create_pin);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::pin_joint_set_param);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_param", "joint", "param"), &PhysicsServer3D::pin_joint_get_param);
- ClassDB::bind_method(D_METHOD("pin_joint_set_local_a", "joint", "local_A"), &PhysicsServer::pin_joint_set_local_a);
- ClassDB::bind_method(D_METHOD("pin_joint_get_local_a", "joint"), &PhysicsServer::pin_joint_get_local_a);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_local_a", "joint", "local_A"), &PhysicsServer3D::pin_joint_set_local_a);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_local_a", "joint"), &PhysicsServer3D::pin_joint_get_local_a);
- ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer::pin_joint_set_local_b);
- ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer::pin_joint_get_local_b);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer3D::pin_joint_set_local_b);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer3D::pin_joint_get_local_b);
BIND_ENUM_CONSTANT(PIN_JOINT_BIAS);
BIND_ENUM_CONSTANT(PIN_JOINT_DAMPING);
@@ -561,18 +561,18 @@ void PhysicsServer::_bind_methods() {
BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT);
BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR);
- ClassDB::bind_method(D_METHOD("joint_create_hinge", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer::joint_create_hinge);
+ ClassDB::bind_method(D_METHOD("joint_create_hinge", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer3D::joint_create_hinge);
- ClassDB::bind_method(D_METHOD("hinge_joint_set_param", "joint", "param", "value"), &PhysicsServer::hinge_joint_set_param);
- ClassDB::bind_method(D_METHOD("hinge_joint_get_param", "joint", "param"), &PhysicsServer::hinge_joint_get_param);
+ ClassDB::bind_method(D_METHOD("hinge_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::hinge_joint_set_param);
+ ClassDB::bind_method(D_METHOD("hinge_joint_get_param", "joint", "param"), &PhysicsServer3D::hinge_joint_get_param);
- ClassDB::bind_method(D_METHOD("hinge_joint_set_flag", "joint", "flag", "enabled"), &PhysicsServer::hinge_joint_set_flag);
- ClassDB::bind_method(D_METHOD("hinge_joint_get_flag", "joint", "flag"), &PhysicsServer::hinge_joint_get_flag);
+ ClassDB::bind_method(D_METHOD("hinge_joint_set_flag", "joint", "flag", "enabled"), &PhysicsServer3D::hinge_joint_set_flag);
+ ClassDB::bind_method(D_METHOD("hinge_joint_get_flag", "joint", "flag"), &PhysicsServer3D::hinge_joint_get_flag);
- ClassDB::bind_method(D_METHOD("joint_create_slider", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_slider);
+ ClassDB::bind_method(D_METHOD("joint_create_slider", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_create_slider);
- ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer::slider_joint_set_param);
- ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer::slider_joint_get_param);
+ ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::slider_joint_set_param);
+ ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer3D::slider_joint_get_param);
BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_UPPER);
BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_LOWER);
@@ -599,10 +599,10 @@ void PhysicsServer::_bind_methods() {
BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING);
BIND_ENUM_CONSTANT(SLIDER_JOINT_MAX);
- ClassDB::bind_method(D_METHOD("joint_create_cone_twist", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_cone_twist);
+ ClassDB::bind_method(D_METHOD("joint_create_cone_twist", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_create_cone_twist);
- ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer::cone_twist_joint_set_param);
- ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer::cone_twist_joint_get_param);
+ ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::cone_twist_joint_set_param);
+ ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer3D::cone_twist_joint_get_param);
BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SWING_SPAN);
BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_TWIST_SPAN);
@@ -632,24 +632,24 @@ void PhysicsServer::_bind_methods() {
BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_MOTOR);
BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR);
- ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer::joint_get_type);
+ ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer3D::joint_get_type);
- ClassDB::bind_method(D_METHOD("joint_set_solver_priority", "joint", "priority"), &PhysicsServer::joint_set_solver_priority);
- ClassDB::bind_method(D_METHOD("joint_get_solver_priority", "joint"), &PhysicsServer::joint_get_solver_priority);
+ ClassDB::bind_method(D_METHOD("joint_set_solver_priority", "joint", "priority"), &PhysicsServer3D::joint_set_solver_priority);
+ ClassDB::bind_method(D_METHOD("joint_get_solver_priority", "joint"), &PhysicsServer3D::joint_get_solver_priority);
- ClassDB::bind_method(D_METHOD("joint_create_generic_6dof", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_generic_6dof);
+ ClassDB::bind_method(D_METHOD("joint_create_generic_6dof", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_create_generic_6dof);
- ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_param", "joint", "axis", "param", "value"), &PhysicsServer::generic_6dof_joint_set_param);
- ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_param", "joint", "axis", "param"), &PhysicsServer::generic_6dof_joint_get_param);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_param", "joint", "axis", "param", "value"), &PhysicsServer3D::generic_6dof_joint_set_param);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_param", "joint", "axis", "param"), &PhysicsServer3D::generic_6dof_joint_get_param);
- ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag", "joint", "axis", "flag", "enable"), &PhysicsServer::generic_6dof_joint_set_flag);
- ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag", "joint", "axis", "flag"), &PhysicsServer::generic_6dof_joint_get_flag);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag", "joint", "axis", "flag", "enable"), &PhysicsServer3D::generic_6dof_joint_set_flag);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag", "joint", "axis", "flag"), &PhysicsServer3D::generic_6dof_joint_get_flag);
- ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer::free);
+ ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer3D::free);
- ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer::set_active);
+ ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer3D::set_active);
- ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer::get_process_info);
+ ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer3D::get_process_info);
BIND_ENUM_CONSTANT(SHAPE_PLANE);
BIND_ENUM_CONSTANT(SHAPE_RAY);
@@ -723,23 +723,23 @@ void PhysicsServer::_bind_methods() {
#endif
}
-PhysicsServer::PhysicsServer() {
+PhysicsServer3D::PhysicsServer3D() {
ERR_FAIL_COND(singleton != NULL);
singleton = this;
}
-PhysicsServer::~PhysicsServer() {
+PhysicsServer3D::~PhysicsServer3D() {
singleton = NULL;
}
-Vector<PhysicsServerManager::ClassInfo> PhysicsServerManager::physics_servers;
-int PhysicsServerManager::default_server_id = -1;
-int PhysicsServerManager::default_server_priority = -1;
-const String PhysicsServerManager::setting_property_name("physics/3d/physics_engine");
+Vector<PhysicsServer3DManager::ClassInfo> PhysicsServer3DManager::physics_servers;
+int PhysicsServer3DManager::default_server_id = -1;
+int PhysicsServer3DManager::default_server_priority = -1;
+const String PhysicsServer3DManager::setting_property_name("physics/3d/physics_engine");
-void PhysicsServerManager::on_servers_changed() {
+void PhysicsServer3DManager::on_servers_changed() {
String physics_servers2("DEFAULT");
for (int i = get_servers_count() - 1; 0 <= i; --i) {
@@ -748,7 +748,7 @@ void PhysicsServerManager::on_servers_changed() {
ProjectSettings::get_singleton()->set_custom_property_info(setting_property_name, PropertyInfo(Variant::STRING, setting_property_name, PROPERTY_HINT_ENUM, physics_servers2));
}
-void PhysicsServerManager::register_server(const String &p_name, CreatePhysicsServerCallback p_creat_callback) {
+void PhysicsServer3DManager::register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback) {
ERR_FAIL_COND(!p_creat_callback);
ERR_FAIL_COND(find_server_id(p_name) != -1);
@@ -756,7 +756,7 @@ void PhysicsServerManager::register_server(const String &p_name, CreatePhysicsSe
on_servers_changed();
}
-void PhysicsServerManager::set_default_server(const String &p_name, int p_priority) {
+void PhysicsServer3DManager::set_default_server(const String &p_name, int p_priority) {
const int id = find_server_id(p_name);
ERR_FAIL_COND(id == -1); // Not found
@@ -766,7 +766,7 @@ void PhysicsServerManager::set_default_server(const String &p_name, int p_priori
}
}
-int PhysicsServerManager::find_server_id(const String &p_name) {
+int PhysicsServer3DManager::find_server_id(const String &p_name) {
for (int i = physics_servers.size() - 1; 0 <= i; --i) {
if (p_name == physics_servers[i].name) {
@@ -776,21 +776,21 @@ int PhysicsServerManager::find_server_id(const String &p_name) {
return -1;
}
-int PhysicsServerManager::get_servers_count() {
+int PhysicsServer3DManager::get_servers_count() {
return physics_servers.size();
}
-String PhysicsServerManager::get_server_name(int p_id) {
+String PhysicsServer3DManager::get_server_name(int p_id) {
ERR_FAIL_INDEX_V(p_id, get_servers_count(), "");
return physics_servers[p_id].name;
}
-PhysicsServer *PhysicsServerManager::new_default_server() {
+PhysicsServer3D *PhysicsServer3DManager::new_default_server() {
ERR_FAIL_COND_V(default_server_id == -1, NULL);
return physics_servers[default_server_id].create_callback();
}
-PhysicsServer *PhysicsServerManager::new_server(const String &p_name) {
+PhysicsServer3D *PhysicsServer3DManager::new_server(const String &p_name) {
int id = find_server_id(p_name);
if (id == -1) {
return NULL;
diff --git a/servers/physics_server.h b/servers/physics_server_3d.h
index f1388c8758..ddef8a9b20 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* physics_server.h */
+/* physics_server_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -34,11 +34,11 @@
#include "core/object.h"
#include "core/resource.h"
-class PhysicsDirectSpaceState;
+class PhysicsDirectSpaceState3D;
-class PhysicsDirectBodyState : public Object {
+class PhysicsDirectBodyState3D : public Object {
- GDCLASS(PhysicsDirectBodyState, Object);
+ GDCLASS(PhysicsDirectBodyState3D, Object);
protected:
static void _bind_methods();
@@ -90,17 +90,17 @@ public:
virtual real_t get_step() const = 0;
virtual void integrate_forces();
- virtual PhysicsDirectSpaceState *get_space_state() = 0;
+ virtual PhysicsDirectSpaceState3D *get_space_state() = 0;
- PhysicsDirectBodyState();
+ PhysicsDirectBodyState3D();
};
-class PhysicsShapeQueryResult;
+class PhysicsShapeQueryResult3D;
-class PhysicsShapeQueryParameters : public Reference {
+class PhysicsShapeQueryParameters3D : public Reference {
- GDCLASS(PhysicsShapeQueryParameters, Reference);
- friend class PhysicsDirectSpaceState;
+ GDCLASS(PhysicsShapeQueryParameters3D, Reference);
+ friend class PhysicsDirectSpaceState3D;
RID shape;
Transform transform;
@@ -137,19 +137,19 @@ public:
void set_collide_with_areas(bool p_enable);
bool is_collide_with_areas_enabled() const;
- PhysicsShapeQueryParameters();
+ PhysicsShapeQueryParameters3D();
};
-class PhysicsDirectSpaceState : public Object {
+class PhysicsDirectSpaceState3D : public Object {
- GDCLASS(PhysicsDirectSpaceState, Object);
+ GDCLASS(PhysicsDirectSpaceState3D, Object);
private:
Dictionary _intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_collision_mask = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
- Array _intersect_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results = 32);
- Array _cast_motion(const Ref<PhysicsShapeQueryParameters> &p_shape_query, const Vector3 &p_motion);
- Array _collide_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results = 32);
- Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters> &p_shape_query);
+ Array _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
+ Array _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, const Vector3 &p_motion);
+ Array _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32);
+ Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query);
protected:
static void _bind_methods();
@@ -197,16 +197,16 @@ public:
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0;
- PhysicsDirectSpaceState();
+ PhysicsDirectSpaceState3D();
};
-class PhysicsShapeQueryResult : public Reference {
+class PhysicsShapeQueryResult3D : public Reference {
- GDCLASS(PhysicsShapeQueryResult, Reference);
+ GDCLASS(PhysicsShapeQueryResult3D, Reference);
- Vector<PhysicsDirectSpaceState::ShapeResult> result;
+ Vector<PhysicsDirectSpaceState3D::ShapeResult> result;
- friend class PhysicsDirectSpaceState;
+ friend class PhysicsDirectSpaceState3D;
protected:
static void _bind_methods();
@@ -218,20 +218,20 @@ public:
Object *get_result_object(int p_idx) const;
int get_result_object_shape(int p_idx) const;
- PhysicsShapeQueryResult();
+ PhysicsShapeQueryResult3D();
};
-class PhysicsServer : public Object {
+class PhysicsServer3D : public Object {
- GDCLASS(PhysicsServer, Object);
+ GDCLASS(PhysicsServer3D, Object);
- static PhysicsServer *singleton;
+ static PhysicsServer3D *singleton;
protected:
static void _bind_methods();
public:
- static PhysicsServer *get_singleton();
+ static PhysicsServer3D *get_singleton();
enum ShapeType {
SHAPE_PLANE, ///< plane:"plane"
@@ -281,7 +281,7 @@ public:
virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0;
// this function only works on physics process, errors and returns null otherwise
- virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space) = 0;
+ virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) = 0;
virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) = 0;
virtual Vector<Vector3> space_get_contacts(RID p_space) const = 0;
@@ -478,7 +478,7 @@ public:
virtual bool body_is_ray_pickable(RID p_body) const = 0;
// this function only works on physics process, errors and returns null otherwise
- virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body) = 0;
+ virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) = 0;
struct MotionResult {
@@ -521,7 +521,7 @@ public:
virtual RID soft_body_create(bool p_init_sleeping = false) = 0;
- virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) = 0;
+ virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) = 0;
virtual void soft_body_set_space(RID p_body, RID p_space) = 0;
virtual RID soft_body_get_space(RID p_body) const = 0;
@@ -772,22 +772,22 @@ public:
virtual int get_process_info(ProcessInfo p_info) = 0;
- PhysicsServer();
- ~PhysicsServer();
+ PhysicsServer3D();
+ ~PhysicsServer3D();
};
-typedef PhysicsServer *(*CreatePhysicsServerCallback)();
+typedef PhysicsServer3D *(*CreatePhysicsServer3DCallback)();
-class PhysicsServerManager {
+class PhysicsServer3DManager {
struct ClassInfo {
String name;
- CreatePhysicsServerCallback create_callback;
+ CreatePhysicsServer3DCallback create_callback;
ClassInfo() :
name(""),
create_callback(NULL) {}
- ClassInfo(String p_name, CreatePhysicsServerCallback p_create_callback) :
+ ClassInfo(String p_name, CreatePhysicsServer3DCallback p_create_callback) :
name(p_name),
create_callback(p_create_callback) {}
@@ -813,32 +813,32 @@ private:
static void on_servers_changed();
public:
- static void register_server(const String &p_name, CreatePhysicsServerCallback p_creat_callback);
+ static void register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback);
static void set_default_server(const String &p_name, int p_priority = 0);
static int find_server_id(const String &p_name);
static int get_servers_count();
static String get_server_name(int p_id);
- static PhysicsServer *new_default_server();
- static PhysicsServer *new_server(const String &p_name);
+ static PhysicsServer3D *new_default_server();
+ static PhysicsServer3D *new_server(const String &p_name);
};
-VARIANT_ENUM_CAST(PhysicsServer::ShapeType);
-VARIANT_ENUM_CAST(PhysicsServer::SpaceParameter);
-VARIANT_ENUM_CAST(PhysicsServer::AreaParameter);
-VARIANT_ENUM_CAST(PhysicsServer::AreaSpaceOverrideMode);
-VARIANT_ENUM_CAST(PhysicsServer::BodyMode);
-VARIANT_ENUM_CAST(PhysicsServer::BodyParameter);
-VARIANT_ENUM_CAST(PhysicsServer::BodyState);
-VARIANT_ENUM_CAST(PhysicsServer::BodyAxis);
-VARIANT_ENUM_CAST(PhysicsServer::PinJointParam);
-VARIANT_ENUM_CAST(PhysicsServer::JointType);
-VARIANT_ENUM_CAST(PhysicsServer::HingeJointParam);
-VARIANT_ENUM_CAST(PhysicsServer::HingeJointFlag);
-VARIANT_ENUM_CAST(PhysicsServer::SliderJointParam);
-VARIANT_ENUM_CAST(PhysicsServer::ConeTwistJointParam);
-VARIANT_ENUM_CAST(PhysicsServer::G6DOFJointAxisParam);
-VARIANT_ENUM_CAST(PhysicsServer::G6DOFJointAxisFlag);
-VARIANT_ENUM_CAST(PhysicsServer::AreaBodyStatus);
-VARIANT_ENUM_CAST(PhysicsServer::ProcessInfo);
+VARIANT_ENUM_CAST(PhysicsServer3D::ShapeType);
+VARIANT_ENUM_CAST(PhysicsServer3D::SpaceParameter);
+VARIANT_ENUM_CAST(PhysicsServer3D::AreaParameter);
+VARIANT_ENUM_CAST(PhysicsServer3D::AreaSpaceOverrideMode);
+VARIANT_ENUM_CAST(PhysicsServer3D::BodyMode);
+VARIANT_ENUM_CAST(PhysicsServer3D::BodyParameter);
+VARIANT_ENUM_CAST(PhysicsServer3D::BodyState);
+VARIANT_ENUM_CAST(PhysicsServer3D::BodyAxis);
+VARIANT_ENUM_CAST(PhysicsServer3D::PinJointParam);
+VARIANT_ENUM_CAST(PhysicsServer3D::JointType);
+VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointParam);
+VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointFlag);
+VARIANT_ENUM_CAST(PhysicsServer3D::SliderJointParam);
+VARIANT_ENUM_CAST(PhysicsServer3D::ConeTwistJointParam);
+VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisParam);
+VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisFlag);
+VARIANT_ENUM_CAST(PhysicsServer3D::AreaBodyStatus);
+VARIANT_ENUM_CAST(PhysicsServer3D::ProcessInfo);
#endif
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index fd65f57380..c53ffcc7b5 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "register_server_types.h"
+
#include "core/engine.h"
#include "core/project_settings.h"
@@ -56,30 +57,31 @@
#include "audio_server.h"
#include "camera/camera_feed.h"
#include "camera_server.h"
-#include "navigation_2d_server.h"
-#include "navigation_server.h"
-#include "physics/physics_server_sw.h"
-#include "physics_2d/physics_2d_server_sw.h"
-#include "physics_2d/physics_2d_server_wrap_mt.h"
-#include "physics_2d_server.h"
-#include "physics_server.h"
-#include "visual/shader_types.h"
-#include "visual_server.h"
+#include "display_server.h"
+#include "navigation_server_2d.h"
+#include "navigation_server_3d.h"
+#include "physics_2d/physics_server_2d_sw.h"
+#include "physics_2d/physics_server_2d_wrap_mt.h"
+#include "physics_3d/physics_server_3d_sw.h"
+#include "physics_server_2d.h"
+#include "physics_server_3d.h"
+#include "rendering_server.h"
+#include "servers/rendering/shader_types.h"
ShaderTypes *shader_types = NULL;
-PhysicsServer *_createGodotPhysicsCallback() {
- return memnew(PhysicsServerSW);
+PhysicsServer3D *_createGodotPhysics3DCallback() {
+ return memnew(PhysicsServer3DSW);
}
-Physics2DServer *_createGodotPhysics2DCallback() {
- return Physics2DServerWrapMT::init_server<Physics2DServerSW>();
+PhysicsServer2D *_createGodotPhysics2DCallback() {
+ return PhysicsServer2DWrapMT::init_server<PhysicsServer2DSW>();
}
static bool has_server_feature_callback(const String &p_feature) {
- if (VisualServer::get_singleton()) {
- if (VisualServer::get_singleton()->has_os_feature(p_feature)) {
+ if (RenderingServer::get_singleton()) {
+ if (RenderingServer::get_singleton()->has_os_feature(p_feature)) {
return true;
}
}
@@ -95,10 +97,11 @@ void register_server_types() {
OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
- ClassDB::register_virtual_class<VisualServer>();
+ ClassDB::register_virtual_class<DisplayServer>();
+ ClassDB::register_virtual_class<RenderingServer>();
ClassDB::register_class<AudioServer>();
- ClassDB::register_virtual_class<PhysicsServer>();
- ClassDB::register_virtual_class<Physics2DServer>();
+ ClassDB::register_virtual_class<PhysicsServer3D>();
+ ClassDB::register_virtual_class<PhysicsServer2D>();
ClassDB::register_class<ARVRServer>();
ClassDB::register_class<CameraServer>();
@@ -156,30 +159,30 @@ void register_server_types() {
ClassDB::register_class<CameraFeed>();
- ClassDB::register_virtual_class<Physics2DDirectBodyState>();
- ClassDB::register_virtual_class<Physics2DDirectSpaceState>();
- ClassDB::register_virtual_class<Physics2DShapeQueryResult>();
- ClassDB::register_class<Physics2DTestMotionResult>();
- ClassDB::register_class<Physics2DShapeQueryParameters>();
+ ClassDB::register_virtual_class<PhysicsDirectBodyState2D>();
+ ClassDB::register_virtual_class<PhysicsDirectSpaceState2D>();
+ ClassDB::register_virtual_class<PhysicsShapeQueryResult2D>();
+ ClassDB::register_class<PhysicsTestMotionResult2D>();
+ ClassDB::register_class<PhysicsShapeQueryParameters2D>();
- ClassDB::register_class<PhysicsShapeQueryParameters>();
- ClassDB::register_virtual_class<PhysicsDirectBodyState>();
- ClassDB::register_virtual_class<PhysicsDirectSpaceState>();
- ClassDB::register_virtual_class<PhysicsShapeQueryResult>();
+ ClassDB::register_class<PhysicsShapeQueryParameters3D>();
+ ClassDB::register_virtual_class<PhysicsDirectBodyState3D>();
+ ClassDB::register_virtual_class<PhysicsDirectSpaceState3D>();
+ ClassDB::register_virtual_class<PhysicsShapeQueryResult3D>();
// Physics 2D
- GLOBAL_DEF(Physics2DServerManager::setting_property_name, "DEFAULT");
- ProjectSettings::get_singleton()->set_custom_property_info(Physics2DServerManager::setting_property_name, PropertyInfo(Variant::STRING, Physics2DServerManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"));
+ GLOBAL_DEF(PhysicsServer2DManager::setting_property_name, "DEFAULT");
+ ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServer2DManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServer2DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"));
- Physics2DServerManager::register_server("GodotPhysics", &_createGodotPhysics2DCallback);
- Physics2DServerManager::set_default_server("GodotPhysics");
+ PhysicsServer2DManager::register_server("GodotPhysics", &_createGodotPhysics2DCallback);
+ PhysicsServer2DManager::set_default_server("GodotPhysics");
// Physics 3D
- GLOBAL_DEF(PhysicsServerManager::setting_property_name, "DEFAULT");
- ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServerManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServerManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"));
+ GLOBAL_DEF(PhysicsServer3DManager::setting_property_name, "DEFAULT");
+ ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServer3DManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServer3DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"));
- PhysicsServerManager::register_server("GodotPhysics", &_createGodotPhysicsCallback);
- PhysicsServerManager::set_default_server("GodotPhysics");
+ PhysicsServer3DManager::register_server("GodotPhysics", &_createGodotPhysics3DCallback);
+ PhysicsServer3DManager::set_default_server("GodotPhysics");
}
void unregister_server_types() {
@@ -189,12 +192,12 @@ void unregister_server_types() {
void register_server_singletons() {
- Engine::get_singleton()->add_singleton(Engine::Singleton("VisualServer", VisualServer::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer", PhysicsServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("Physics2DServer", Physics2DServer::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer", NavigationServer::get_singleton_mut()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("Navigation2DServer", Navigation2DServer::get_singleton_mut()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer", NavigationServer3D::get_singleton_mut()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton_mut()));
Engine::get_singleton()->add_singleton(Engine::Singleton("ARVRServer", ARVRServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton()));
}
diff --git a/servers/visual/SCsub b/servers/rendering/SCsub
index fca18bfea0..fca18bfea0 100644
--- a/servers/visual/SCsub
+++ b/servers/rendering/SCsub
diff --git a/servers/visual/rasterizer.cpp b/servers/rendering/rasterizer.cpp
index a3f93a3f8c..a3f93a3f8c 100644
--- a/servers/visual/rasterizer.cpp
+++ b/servers/rendering/rasterizer.cpp
diff --git a/servers/visual/rasterizer.h b/servers/rendering/rasterizer.h
index 84eda2d80c..f63d1077bb 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/rendering/rasterizer.h
@@ -32,7 +32,7 @@
#define RASTERIZER_H
#include "core/math/camera_matrix.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#include "core/pair.h"
#include "core/self_list.h"
@@ -55,35 +55,35 @@ public:
virtual RID sky_create() = 0;
virtual void sky_set_radiance_size(RID p_sky, int p_radiance_size) = 0;
- virtual void sky_set_mode(RID p_sky, VS::SkyMode p_samples) = 0;
+ virtual void sky_set_mode(RID p_sky, RS::SkyMode p_samples) = 0;
virtual void sky_set_material(RID p_sky, RID p_material) = 0;
/* ENVIRONMENT API */
virtual RID environment_create() = 0;
- virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) = 0;
+ virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) = 0;
virtual void environment_set_sky(RID p_env, RID p_sky) = 0;
virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0;
virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) = 0;
virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0;
virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0;
virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
- virtual void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) = 0;
+ virtual void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) = 0;
// FIXME: Disabled during Vulkan refactoring, should be ported.
#if 0
virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0;
#endif
- virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) = 0;
+ virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) = 0;
virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0;
virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0;
- virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) = 0;
+ virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) = 0;
- virtual void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) = 0;
+ virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) = 0;
- virtual void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) = 0;
+ virtual void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) = 0;
virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) = 0;
@@ -92,13 +92,13 @@ public:
virtual void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) = 0;
virtual bool is_environment(RID p_env) const = 0;
- virtual VS::EnvironmentBG environment_get_background(RID p_env) const = 0;
+ virtual RS::EnvironmentBG environment_get_background(RID p_env) const = 0;
virtual int environment_get_canvas_max_layer(RID p_env) const = 0;
virtual RID camera_effects_create() = 0;
- virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) = 0;
- virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) = 0;
+ virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) = 0;
+ virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) = 0;
virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) = 0;
virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) = 0;
@@ -119,7 +119,7 @@ public:
struct InstanceBase {
- VS::InstanceType base_type;
+ RS::InstanceType base_type;
RID base;
RID skeleton;
@@ -142,7 +142,7 @@ public:
Vector<float> blend_values;
- VS::ShadowCastingSetting cast_shadows;
+ RS::ShadowCastingSetting cast_shadows;
//fit in 32 bits
bool mirror : 8;
@@ -208,8 +208,8 @@ public:
InstanceBase() :
dependency_item(this) {
- base_type = VS::INSTANCE_NONE;
- cast_shadows = VS::SHADOW_CASTING_SETTING_ON;
+ base_type = RS::INSTANCE_NONE;
+ cast_shadows = RS::SHADOW_CASTING_SETTING_ON;
receive_shadows = true;
visible = true;
depth_layer = 0;
@@ -255,10 +255,10 @@ public:
virtual void set_scene_pass(uint64_t p_pass) = 0;
virtual void set_time(double p_time, double p_step) = 0;
- virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) = 0;
+ virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) = 0;
virtual RID render_buffers_create() = 0;
- virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) = 0;
+ virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) = 0;
virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_curve) = 0;
virtual bool screen_space_roughness_limiter_is_active() const = 0;
@@ -277,7 +277,7 @@ public:
/* TEXTURE API */
virtual RID texture_2d_create(const Ref<Image> &p_image) = 0;
- virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) = 0;
+ virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) = 0;
virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) = 0; //all slices, then all the mipmaps, must be coherent
virtual RID texture_proxy_create(RID p_base) = 0; //all slices, then all the mipmaps, must be coherent
@@ -305,11 +305,11 @@ public:
virtual void texture_set_path(RID p_texture, const String &p_path) = 0;
virtual String texture_get_path(RID p_texture) const = 0;
- virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) = 0;
- virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) = 0;
- virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0;
+ virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) = 0;
+ virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) = 0;
+ virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0;
- virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) = 0;
+ virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) = 0;
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0;
@@ -349,19 +349,19 @@ public:
virtual RID mesh_create() = 0;
/// Returns stride
- virtual void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) = 0;
+ virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) = 0;
virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
- virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0;
- virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
+ virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) = 0;
+ virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0;
- virtual VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0;
+ virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0;
virtual int mesh_get_surface_count(RID p_mesh) const = 0;
@@ -376,7 +376,7 @@ public:
virtual RID multimesh_create() = 0;
- virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0;
+ virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0;
virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
@@ -404,7 +404,7 @@ public:
/* IMMEDIATE API */
virtual RID immediate_create() = 0;
- virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) = 0;
+ virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) = 0;
virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) = 0;
virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal) = 0;
virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent) = 0;
@@ -430,14 +430,14 @@ public:
/* Light API */
- virtual RID light_create(VS::LightType p_type) = 0;
+ virtual RID light_create(RS::LightType p_type) = 0;
- RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); }
- RID omni_light_create() { return light_create(VS::LIGHT_OMNI); }
- RID spot_light_create() { return light_create(VS::LIGHT_SPOT); }
+ RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); }
+ RID omni_light_create() { return light_create(RS::LIGHT_OMNI); }
+ RID spot_light_create() { return light_create(RS::LIGHT_SPOT); }
virtual void light_set_color(RID p_light, const Color &p_color) = 0;
- virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value) = 0;
+ virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value) = 0;
virtual void light_set_shadow(RID p_light, bool p_enabled) = 0;
virtual void light_set_shadow_color(RID p_light, const Color &p_color) = 0;
virtual void light_set_projector(RID p_light, RID p_texture) = 0;
@@ -446,22 +446,22 @@ public:
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
virtual void light_set_use_gi(RID p_light, bool p_enable) = 0;
- virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) = 0;
+ virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) = 0;
- virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) = 0;
+ virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) = 0;
virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0;
virtual bool light_directional_get_blend_splits(RID p_light) const = 0;
- virtual void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) = 0;
- virtual VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const = 0;
+ virtual void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) = 0;
+ virtual RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const = 0;
- virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) = 0;
- virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) = 0;
+ virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) = 0;
+ virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) = 0;
virtual bool light_has_shadow(RID p_light) const = 0;
- virtual VS::LightType light_get_type(RID p_light) const = 0;
+ virtual RS::LightType light_get_type(RID p_light) const = 0;
virtual AABB light_get_aabb(RID p_light) const = 0;
- virtual float light_get_param(RID p_light, VS::LightParam p_param) = 0;
+ virtual float light_get_param(RID p_light, RS::LightParam p_param) = 0;
virtual Color light_get_color(RID p_light) = 0;
virtual bool light_get_use_gi(RID p_light) = 0;
virtual uint64_t light_get_version(RID p_light) const = 0;
@@ -470,7 +470,7 @@ public:
virtual RID reflection_probe_create() = 0;
- virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) = 0;
+ virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) = 0;
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) = 0;
@@ -485,7 +485,7 @@ public:
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0;
- virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0;
+ virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0;
virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0;
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const = 0;
@@ -591,7 +591,7 @@ public:
virtual bool particles_is_inactive(RID p_particles) const = 0;
- virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) = 0;
+ virtual void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) = 0;
virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0;
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0;
@@ -628,7 +628,7 @@ public:
virtual void render_target_disable_clear_request(RID p_render_target) = 0;
virtual void render_target_do_clear_request(RID p_render_target) = 0;
- virtual VS::InstanceType get_base_type(RID p_rid) const = 0;
+ virtual RS::InstanceType get_base_type(RID p_rid) const = 0;
virtual bool free(RID p_rid) = 0;
virtual bool has_os_feature(const String &p_feature) const = 0;
@@ -639,9 +639,9 @@ public:
virtual void render_info_begin_capture() = 0;
virtual void render_info_end_capture() = 0;
- virtual int get_captured_render_info(VS::RenderInfo p_info) = 0;
+ virtual int get_captured_render_info(RS::RenderInfo p_info) = 0;
- virtual int get_render_info(VS::RenderInfo p_info) = 0;
+ virtual int get_render_info(RS::RenderInfo p_info) = 0;
virtual String get_video_adapter_name() const = 0;
virtual String get_video_adapter_vendor() const = 0;
@@ -656,12 +656,12 @@ public:
}
#define TIMESTAMP_BEGIN() \
{ \
- if (VSG::storage->capturing_timestamps) VSG::storage->capture_timestamps_begin(); \
+ if (RSG::storage->capturing_timestamps) RSG::storage->capture_timestamps_begin(); \
}
#define RENDER_TIMESTAMP(m_text) \
{ \
- if (VSG::storage->capturing_timestamps) VSG::storage->capture_timestamp(m_text); \
+ if (RSG::storage->capturing_timestamps) RSG::storage->capture_timestamp(m_text); \
}
bool capturing_timestamps = false;
@@ -706,13 +706,13 @@ public:
int layer_max;
int item_mask;
int item_shadow_mask;
- VS::CanvasLightMode mode;
+ RS::CanvasLightMode mode;
RID texture;
Vector2 texture_offset;
RID canvas;
bool use_shadow;
int shadow_buffer_size;
- VS::CanvasLightShadowFilter shadow_filter;
+ RS::CanvasLightShadowFilter shadow_filter;
Color shadow_color;
float shadow_smooth;
@@ -749,14 +749,14 @@ public:
scale = 1.0;
energy = 1.0;
item_shadow_mask = -1;
- mode = VS::CANVAS_LIGHT_MODE_ADD;
+ mode = RS::CANVAS_LIGHT_MODE_ADD;
// texture_cache = NULL;
next_ptr = NULL;
mask_next_ptr = NULL;
filter_next_ptr = NULL;
use_shadow = false;
shadow_buffer_size = 2048;
- shadow_filter = VS::CANVAS_LIGHT_FILTER_NONE;
+ shadow_filter = RS::CANVAS_LIGHT_FILTER_NONE;
shadow_smooth = 0.0;
render_index_cache = -1;
}
@@ -764,7 +764,7 @@ public:
typedef uint64_t TextureBindingID;
- virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) = 0;
+ virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) = 0;
virtual void free_texture_binding(TextureBindingID p_binding) = 0;
//easier wrap to avoid mistakes
@@ -775,14 +775,14 @@ public:
TextureBindingID binding_id;
- _FORCE_INLINE_ void create(VS::CanvasItemTextureFilter p_item_filter, VS::CanvasItemTextureRepeat p_item_repeat, RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
- if (p_filter == VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) {
+ _FORCE_INLINE_ void create(RS::CanvasItemTextureFilter p_item_filter, RS::CanvasItemTextureRepeat p_item_repeat, RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
+ if (p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) {
p_filter = p_item_filter;
}
- if (p_repeat == VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) {
+ if (p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) {
p_repeat = p_item_repeat;
}
- if (p_texture != RID() || p_normalmap != RID() || p_specular != RID() || p_filter != VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT || p_repeat != VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT || p_multimesh.is_valid()) {
+ if (p_texture != RID() || p_normalmap != RID() || p_specular != RID() || p_filter != RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT || p_repeat != RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT || p_multimesh.is_valid()) {
ERR_FAIL_COND(binding_id != 0);
binding_id = singleton->request_texture_binding(p_texture, p_normalmap, p_specular, p_filter, p_repeat, p_multimesh);
}
@@ -882,8 +882,8 @@ public:
float margin[4];
bool draw_center;
Color color;
- VS::NinePatchAxisMode axis_x;
- VS::NinePatchAxisMode axis_y;
+ RS::NinePatchAxisMode axis_x;
+ RS::NinePatchAxisMode axis_y;
Color specular_shininess;
TextureBinding texture_binding;
CommandNinePatch() {
@@ -894,7 +894,7 @@ public:
struct CommandPolygon : public Command {
- VS::PrimitiveType primitive;
+ RS::PrimitiveType primitive;
Polygon polygon;
Color specular_shininess;
TextureBinding texture_binding;
@@ -958,7 +958,7 @@ public:
};
struct ViewportRender {
- VisualServer *owner;
+ RenderingServer *owner;
void *udata;
Rect2 rect;
};
@@ -968,7 +968,7 @@ public:
bool visible;
bool behind;
bool update_when_visible;
- //VS::MaterialBlendMode blend_mode;
+ //RS::MaterialBlendMode blend_mode;
int light_mask;
int z_final;
@@ -1241,7 +1241,7 @@ public:
Transform2D xform;
Transform2D xform_cache;
int light_mask;
- VS::CanvasOccluderPolygonCullMode cull_cache;
+ RS::CanvasOccluderPolygonCullMode cull_cache;
LightOccluderInstance *next;
@@ -1249,7 +1249,7 @@ public:
enabled = true;
next = NULL;
light_mask = 1;
- cull_cache = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
+ cull_cache = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
}
};
@@ -1260,7 +1260,7 @@ public:
virtual RID occluder_polygon_create() = 0;
virtual void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) = 0;
- virtual void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) = 0;
+ virtual void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) = 0;
virtual void draw_window_margins(int *p_margins, RID *p_margin_textures) = 0;
@@ -1294,7 +1294,7 @@ public:
};
virtual void prepare_for_blitting_render_targets() = 0;
- virtual void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
+ virtual void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
virtual void end_frame(bool p_swap_buffers) = 0;
virtual void finalize() = 0;
diff --git a/servers/visual/rasterizer_rd/SCsub b/servers/rendering/rasterizer_rd/SCsub
index cc17feeb05..cc17feeb05 100644
--- a/servers/visual/rasterizer_rd/SCsub
+++ b/servers/rendering/rasterizer_rd/SCsub
diff --git a/servers/visual/rasterizer_rd/light_cluster_builder.cpp b/servers/rendering/rasterizer_rd/light_cluster_builder.cpp
index 943ef1c7fa..943ef1c7fa 100644
--- a/servers/visual/rasterizer_rd/light_cluster_builder.cpp
+++ b/servers/rendering/rasterizer_rd/light_cluster_builder.cpp
diff --git a/servers/visual/rasterizer_rd/light_cluster_builder.h b/servers/rendering/rasterizer_rd/light_cluster_builder.h
index 83014a7dd0..3411ed07a0 100644
--- a/servers/visual/rasterizer_rd/light_cluster_builder.h
+++ b/servers/rendering/rasterizer_rd/light_cluster_builder.h
@@ -31,7 +31,7 @@
#ifndef LIGHT_CLUSTER_BUILDER_H
#define LIGHT_CLUSTER_BUILDER_H
-#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h"
class LightClusterBuilder {
public:
diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp
index 38b1e3b3a6..8d52ffd7b9 100644
--- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp
@@ -104,7 +104,7 @@ void RasterizerCanvasRD::_update_specular_shininess(const Color &p_transform, ui
*r_ss |= uint32_t(CLAMP(p_transform.r * 255.0, 0, 255));
}
-RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
+RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
Vector<RD::Uniform> uniform_set;
@@ -168,13 +168,13 @@ RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap,
return RD::get_singleton()->uniform_set_create(uniform_set, shader.default_version_rd_shader, 0);
}
-RasterizerCanvas::TextureBindingID RasterizerCanvasRD::request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
+RasterizerCanvas::TextureBindingID RasterizerCanvasRD::request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
- if (p_filter == VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) {
+ if (p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) {
p_filter = default_samplers.default_filter;
}
- if (p_repeat == VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) {
+ if (p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) {
p_repeat = default_samplers.default_repeat;
}
@@ -287,7 +287,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
vd.offset = base_offset * sizeof(float);
- vd.location = VS::ARRAY_VERTEX;
+ vd.location = RS::ARRAY_VERTEX;
vd.stride = stride * sizeof(float);
descriptions.write[0] = vd;
@@ -307,7 +307,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
vd.offset = base_offset * sizeof(float);
- vd.location = VS::ARRAY_COLOR;
+ vd.location = RS::ARRAY_COLOR;
vd.stride = stride * sizeof(float);
descriptions.write[1] = vd;
@@ -335,7 +335,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
vd.offset = 0;
- vd.location = VS::ARRAY_COLOR;
+ vd.location = RS::ARRAY_COLOR;
vd.stride = 0;
descriptions.write[1] = vd;
@@ -347,7 +347,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
vd.offset = base_offset * sizeof(float);
- vd.location = VS::ARRAY_TEX_UV;
+ vd.location = RS::ARRAY_TEX_UV;
vd.stride = stride * sizeof(float);
descriptions.write[2] = vd;
@@ -363,7 +363,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
vd.offset = 0;
- vd.location = VS::ARRAY_TEX_UV;
+ vd.location = RS::ARRAY_TEX_UV;
vd.stride = 0;
descriptions.write[2] = vd;
@@ -375,7 +375,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT;
vd.offset = base_offset * sizeof(float);
- vd.location = VS::ARRAY_BONES;
+ vd.location = RS::ARRAY_BONES;
vd.stride = stride * sizeof(float);
descriptions.write[3] = vd;
@@ -404,7 +404,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
RD::VertexDescription vd;
vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT;
vd.offset = 0;
- vd.location = VS::ARRAY_BONES;
+ vd.location = RS::ARRAY_BONES;
vd.stride = 0;
descriptions.write[3] = vd;
@@ -558,7 +558,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
light_cache[light_count] = light;
light_count++;
- if (light->mode == VS::CANVAS_LIGHT_MODE_MASK) {
+ if (light->mode == RS::CANVAS_LIGHT_MODE_MASK) {
base_flags |= FLAGS_USING_LIGHT_MASK;
}
if (light_count == state.max_lights_per_item) {
@@ -888,13 +888,13 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
ERR_CONTINUE(!pb);
//bind pipeline
{
- static const PipelineVariant variant[VS::PRIMITIVE_MAX] = { PIPELINE_VARIANT_ATTRIBUTE_POINTS, PIPELINE_VARIANT_ATTRIBUTE_LINES, PIPELINE_VARIANT_ATTRIBUTE_LINES_STRIP, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLES, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLE_STRIP };
- ERR_CONTINUE(polygon->primitive < 0 || polygon->primitive >= VS::PRIMITIVE_MAX);
+ static const PipelineVariant variant[RS::PRIMITIVE_MAX] = { PIPELINE_VARIANT_ATTRIBUTE_POINTS, PIPELINE_VARIANT_ATTRIBUTE_LINES, PIPELINE_VARIANT_ATTRIBUTE_LINES_STRIP, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLES, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLE_STRIP };
+ ERR_CONTINUE(polygon->primitive < 0 || polygon->primitive >= RS::PRIMITIVE_MAX);
RID pipeline = pipeline_variants->variants[light_mode][variant[polygon->primitive]].get_render_pipeline(pb->vertex_format_id, p_framebuffer_format);
RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, pipeline);
}
- if (polygon->primitive == VS::PRIMITIVE_LINES) {
+ if (polygon->primitive == RS::PRIMITIVE_LINES) {
//not supported in most hardware, so pointless
//RD::get_singleton()->draw_list_set_line_width(p_draw_list, polygon->line_width);
}
@@ -1024,7 +1024,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
// materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
glBindVertexArray(s->array_id);
- glVertexAttrib4f(VS::ARRAY_COLOR, mesh->modulate.r, mesh->modulate.g, mesh->modulate.b, mesh->modulate.a);
+ glVertexAttrib4f(RS::ARRAY_COLOR, mesh->modulate.r, mesh->modulate.g, mesh->modulate.b, mesh->modulate.a);
if (s->index_array_len) {
glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len >= (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0);
@@ -1054,7 +1054,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map);
- state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != VS::MULTIMESH_CUSTOM_DATA_NONE);
+ state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE);
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCING, true);
//reset shader and force rebind
state.using_texture_rect = true;
@@ -1088,7 +1088,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
int color_ofs;
- if (multi_mesh->transform_format == VS::MULTIMESH_TRANSFORM_3D) {
+ if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) {
glEnableVertexAttribArray(10);
glVertexAttribPointer(10, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(8 * 4));
glVertexAttribDivisor(10, 1);
@@ -1103,18 +1103,18 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
switch (multi_mesh->color_format) {
- case VS::MULTIMESH_COLOR_NONE: {
+ case RS::MULTIMESH_COLOR_NONE: {
glDisableVertexAttribArray(11);
glVertexAttrib4f(11, 1, 1, 1, 1);
} break;
- case VS::MULTIMESH_COLOR_8BIT: {
+ case RS::MULTIMESH_COLOR_8BIT: {
glEnableVertexAttribArray(11);
glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, CAST_INT_TO_UCHAR_PTR(color_ofs));
glVertexAttribDivisor(11, 1);
custom_data_ofs += 4;
} break;
- case VS::MULTIMESH_COLOR_FLOAT: {
+ case RS::MULTIMESH_COLOR_FLOAT: {
glEnableVertexAttribArray(11);
glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(color_ofs));
glVertexAttribDivisor(11, 1);
@@ -1124,17 +1124,17 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
switch (multi_mesh->custom_data_format) {
- case VS::MULTIMESH_CUSTOM_DATA_NONE: {
+ case RS::MULTIMESH_CUSTOM_DATA_NONE: {
glDisableVertexAttribArray(12);
glVertexAttrib4f(12, 1, 1, 1, 1);
} break;
- case VS::MULTIMESH_CUSTOM_DATA_8BIT: {
+ case RS::MULTIMESH_CUSTOM_DATA_8BIT: {
glEnableVertexAttribArray(12);
glVertexAttribPointer(12, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, CAST_INT_TO_UCHAR_PTR(custom_data_ofs));
glVertexAttribDivisor(12, 1);
} break;
- case VS::MULTIMESH_CUSTOM_DATA_FLOAT: {
+ case RS::MULTIMESH_CUSTOM_DATA_FLOAT: {
glEnableVertexAttribArray(12);
glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(custom_data_ofs));
glVertexAttribDivisor(12, 1);
@@ -1167,9 +1167,9 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
if (particles->inactive && !particles->emitting)
break;
- glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); //not used, so keep white
+ glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); //not used, so keep white
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
storage->particles_request_process(particles_cmd->particles);
//enable instancing
@@ -1208,7 +1208,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
int amount = particles->amount;
- if (particles->draw_order != VS::PARTICLES_DRAW_ORDER_LIFETIME) {
+ if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_LIFETIME) {
glEnableVertexAttribArray(8); //xform x
glVertexAttribPointer(8, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 3));
@@ -1712,7 +1712,7 @@ RID RasterizerCanvasRD::occluder_polygon_create() {
OccluderPolygon occluder;
occluder.point_count = 0;
- occluder.cull_mode = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
+ occluder.cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
return occluder_polygon_owner.make_rid(occluder);
}
@@ -1805,7 +1805,7 @@ void RasterizerCanvasRD::occluder_polygon_set_shape_as_lines(RID p_occluder, con
}
}
}
-void RasterizerCanvasRD::occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) {
+void RasterizerCanvasRD::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
ERR_FAIL_COND(!oc);
oc->cull_mode = p_mode;
@@ -1849,7 +1849,7 @@ void RasterizerCanvasRD::ShaderData::set_code(const String &p_code) {
RasterizerCanvasRD *canvas_singleton = (RasterizerCanvasRD *)RasterizerCanvas::singleton;
- Error err = canvas_singleton->shader.compiler.compile(VS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code);
+ Error err = canvas_singleton->shader.compiler.compile(RS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code);
ERR_FAIL_COND(err != OK);
@@ -2138,18 +2138,18 @@ void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, V
u.binding = 0;
u.ids.resize(12);
RID *ids_ptr = u.ids.ptrw();
- ids_ptr[0] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[1] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[2] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[3] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[4] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[5] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[6] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[7] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[8] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[9] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[10] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[11] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[0] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[1] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[2] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[3] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[4] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[5] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[6] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[7] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[8] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[9] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[10] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[11] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
uniforms.push_back(u);
}
@@ -2204,8 +2204,8 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) {
{ //create default samplers
- default_samplers.default_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
- default_samplers.default_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
+ default_samplers.default_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
+ default_samplers.default_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
}
{ //shader variants
@@ -2418,7 +2418,7 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) {
{ //bindings
bindings.id_generator = 0;
//generate for 0
- bindings.default_empty = request_texture_binding(RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, RID());
+ bindings.default_empty = request_texture_binding(RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, RID());
{ //state allocate
state.canvas_state_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(State::Buffer));
diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h
index 894a00a436..0c151975bc 100644
--- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h
@@ -31,13 +31,13 @@
#ifndef RASTERIZER_CANVAS_RD_H
#define RASTERIZER_CANVAS_RD_H
-#include "servers/visual/rasterizer.h"
-#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h"
-#include "servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
-#include "servers/visual/rasterizer_rd/shader_compiler_rd.h"
-#include "servers/visual/rasterizer_rd/shaders/canvas.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl.gen.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h"
+#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
+#include "servers/rendering/rasterizer_rd/shader_compiler_rd.h"
+#include "servers/rendering/rasterizer_rd/shaders/canvas.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl.gen.h"
+#include "servers/rendering/rendering_device.h"
class RasterizerCanvasRD : public RasterizerCanvas {
@@ -229,8 +229,8 @@ class RasterizerCanvasRD : public RasterizerCanvas {
RID normalmap;
RID specular;
RID multimesh;
- VS::CanvasItemTextureFilter texture_filter;
- VS::CanvasItemTextureRepeat texture_repeat;
+ RS::CanvasItemTextureFilter texture_filter;
+ RS::CanvasItemTextureRepeat texture_repeat;
bool operator==(const TextureBindingKey &p_key) const {
return texture == p_key.texture && normalmap == p_key.normalmap && specular == p_key.specular && multimesh == p_key.specular && texture_filter == p_key.texture_filter && texture_repeat == p_key.texture_repeat;
}
@@ -269,12 +269,12 @@ class RasterizerCanvasRD : public RasterizerCanvas {
TextureBindingID default_empty;
} bindings;
- RID _create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
+ RID _create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
void _dispose_bindings();
struct {
- VS::CanvasItemTextureFilter default_filter;
- VS::CanvasItemTextureRepeat default_repeat;
+ RS::CanvasItemTextureFilter default_filter;
+ RS::CanvasItemTextureRepeat default_repeat;
} default_samplers;
/******************/
@@ -332,7 +332,7 @@ class RasterizerCanvasRD : public RasterizerCanvas {
struct OccluderPolygon {
- VS::CanvasOccluderPolygonCullMode cull_mode;
+ RS::CanvasOccluderPolygonCullMode cull_mode;
int point_count;
RID vertex_buffer;
RID vertex_array;
@@ -470,7 +470,7 @@ class RasterizerCanvasRD : public RasterizerCanvas {
_FORCE_INLINE_ void _update_specular_shininess(const Color &p_transform, uint32_t *r_ss);
public:
- TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
+ TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
void free_texture_binding(TextureBindingID p_binding);
PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>());
@@ -483,7 +483,7 @@ public:
RID occluder_polygon_create();
void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines);
- void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode);
+ void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode);
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform);
diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp
index 355ebfa409..9ccc1f172e 100644
--- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp
@@ -29,9 +29,11 @@
/*************************************************************************/
#include "rasterizer_effects_rd.h"
+
#include "core/os/os.h"
#include "core/project_settings.h"
-#include "cubemap_coeffs.h"
+
+#include "thirdparty/misc/cubemap_coeffs.h"
static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) {
p_array[0] = p_basis.elements[0][0];
@@ -365,7 +367,7 @@ void RasterizerEffectsRD::luminance_reduction(RID p_source_texture, const Size2i
RD::get_singleton()->compute_list_end();
}
-void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, VisualServer::DOFBokehShape p_bokeh_shape, VS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
+void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
bokeh.push_constant.blur_far_active = p_dof_far;
bokeh.push_constant.blur_far_begin = p_dof_far_begin;
@@ -408,16 +410,16 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1);
RD::get_singleton()->compute_list_add_barrier(compute_list);
- if (p_bokeh_shape == VS::DOF_BOKEH_BOX || p_bokeh_shape == VS::DOF_BOKEH_HEXAGON) {
+ if (p_bokeh_shape == RS::DOF_BOKEH_BOX || p_bokeh_shape == RS::DOF_BOKEH_HEXAGON) {
//second pass
- RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[p_bokeh_shape == VS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]);
+ RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]);
static const int quality_samples[4] = { 6, 12, 12, 24 };
bokeh.push_constant.steps = quality_samples[p_quality];
- if (p_quality == VS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == VS::DOF_BLUR_QUALITY_LOW) {
+ if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
//box and hexagon are more or less the same, and they can work in either half (very low and low quality) or full (medium and high quality_ sizes)
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture1), 0);
@@ -444,7 +446,7 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
//third pass
bokeh.push_constant.second_pass = true;
- if (p_quality == VS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == VS::DOF_BLUR_QUALITY_LOW) {
+ if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture2), 0);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_halfsize_texture1), 1);
@@ -458,7 +460,7 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1);
RD::get_singleton()->compute_list_add_barrier(compute_list);
- if (p_quality == VS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == VS::DOF_BLUR_QUALITY_LOW) {
+ if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
//forth pass, upscale for low quality
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[BOKEH_COMPOSITE]);
@@ -528,7 +530,7 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
RD::get_singleton()->compute_list_end();
}
-void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness) {
+void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness) {
//minify first
ssao.minify_push_constant.orthogonal = p_projection.is_orthogonal();
@@ -628,7 +630,7 @@ void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer,
ssao.blur_push_constant.axis[0] = 1;
ssao.blur_push_constant.axis[1] = 0;
- if (p_blur != VS::ENV_SSAO_BLUR_DISABLED) {
+ if (p_blur != RS::ENV_SSAO_BLUR_DISABLED) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[p_half_size ? SSAO_BLUR_PASS_HALF : SSAO_BLUR_PASS]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_ao1), 0);
diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h
index 562a7b674b..69da5dc6d4 100644
--- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h
@@ -32,21 +32,21 @@
#define RASTERIZER_EFFECTS_RD_H
#include "core/math/camera_matrix.h"
-#include "servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
-#include "servers/visual/rasterizer_rd/shaders/blur.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/copy.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/ssao.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/ssao_blur.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/ssao_minify.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/tonemap.glsl.gen.h"
-
-#include "servers/visual_server.h"
+#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
+#include "servers/rendering/rasterizer_rd/shaders/blur.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/copy.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/ssao.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/tonemap.glsl.gen.h"
+
+#include "servers/rendering_server.h"
class RasterizerEffectsRD {
@@ -404,7 +404,7 @@ public:
void make_mipmap(RID p_source_rd_texture, RID p_framebuffer_half, const Vector2 &p_pixel_size);
void copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_rect, float p_z_near, float p_z_far, float p_bias, bool p_dp_flip);
void luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false);
- void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, VS::DOFBokehShape p_bokeh_shape, VS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
+ void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
struct TonemapSettings {
@@ -424,7 +424,7 @@ public:
bool glow_use_bicubic_upscale = false;
RID glow_texture;
- VS::EnvironmentToneMapper tonemap_mode = VS::ENV_TONE_MAPPER_LINEAR;
+ RS::EnvironmentToneMapper tonemap_mode = RS::ENV_TONE_MAPPER_LINEAR;
float exposure = 1.0;
float white = 1.0;
@@ -443,7 +443,7 @@ public:
void tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings);
- void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness);
+ void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness);
void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve);
void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size);
diff --git a/servers/visual/rasterizer_rd/rasterizer_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_rd.cpp
index 206320376b..9c54f0caae 100644
--- a/servers/visual/rasterizer_rd/rasterizer_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_rd.cpp
@@ -34,7 +34,7 @@ void RasterizerRD::prepare_for_blitting_render_targets() {
RD::get_singleton()->prepare_screen_for_drawing();
}
-void RasterizerRD::blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) {
+void RasterizerRD::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin_for_screen(p_screen);
diff --git a/servers/visual/rasterizer_rd/rasterizer_rd.h b/servers/rendering/rasterizer_rd/rasterizer_rd.h
index d14e9fb36e..756b9499ca 100644
--- a/servers/visual/rasterizer_rd/rasterizer_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_rd.h
@@ -33,10 +33,10 @@
#include "core/os/os.h"
#include "core/thread_work_pool.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual/rasterizer_rd/rasterizer_canvas_rd.h"
-#include "servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h"
-#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h"
class RasterizerRD : public Rasterizer {
protected:
@@ -66,7 +66,7 @@ public:
void initialize();
void begin_frame(double frame_step);
void prepare_for_blitting_render_targets();
- void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount);
+ void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
void end_frame(bool p_swap_buffers);
void finalize();
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
index 1bc181bea3..bf3cd045f1 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
@@ -30,8 +30,8 @@
#include "rasterizer_scene_high_end_rd.h"
#include "core/project_settings.h"
-#include "servers/visual/rendering_device.h"
-#include "servers/visual/visual_server_raster.h"
+#include "servers/rendering/rendering_device.h"
+#include "servers/rendering/rendering_server_raster.h"
static _FORCE_INLINE_ void store_transform(const Transform &p_mtx, float *p_array) {
p_array[0] = p_mtx.basis.elements[0][0];
@@ -163,7 +163,7 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
RasterizerSceneHighEndRD *scene_singleton = (RasterizerSceneHighEndRD *)RasterizerSceneHighEndRD::singleton;
- Error err = scene_singleton->shader.compiler.compile(VS::SHADER_SPATIAL, code, &actions, path, gen_code);
+ Error err = scene_singleton->shader.compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code);
ERR_FAIL_COND(err != OK);
@@ -273,9 +273,9 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
RD::PolygonCullMode cull_mode_rd = cull_mode_rd_table[i][cull];
- for (int j = 0; j < VS::PRIMITIVE_MAX; j++) {
+ for (int j = 0; j < RS::PRIMITIVE_MAX; j++) {
- RD::RenderPrimitive primitive_rd_table[VS::PRIMITIVE_MAX] = {
+ RD::RenderPrimitive primitive_rd_table[RS::PRIMITIVE_MAX] = {
RD::RENDER_PRIMITIVE_POINTS,
RD::RENDER_PRIMITIVE_LINES,
RD::RENDER_PRIMITIVE_LINESTRIPS,
@@ -413,7 +413,7 @@ RasterizerStorageRD::ShaderData *RasterizerSceneHighEndRD::_create_shader_func()
}
void RasterizerSceneHighEndRD::MaterialData::set_render_priority(int p_priority) {
- priority = p_priority - VS::MATERIAL_RENDER_PRIORITY_MIN; //8 bits
+ priority = p_priority - RS::MATERIAL_RENDER_PRIORITY_MIN; //8 bits
}
void RasterizerSceneHighEndRD::MaterialData::set_next_pass(RID p_pass) {
@@ -569,7 +569,7 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::clear() {
}
}
-void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, VS::ViewportMSAA p_msaa) {
+void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) {
clear();
width = p_width;
@@ -659,10 +659,10 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements,
id.flags = 0;
id.mask = e->instance->layer_mask;
- if (e->instance->base_type == VS::INSTANCE_MULTIMESH) {
+ if (e->instance->base_type == RS::INSTANCE_MULTIMESH) {
id.flags |= INSTANCE_DATA_FLAG_MULTIMESH;
uint32_t stride;
- if (storage->multimesh_get_transform_format(e->instance->base) == VS::MULTIMESH_TRANSFORM_2D) {
+ if (storage->multimesh_get_transform_format(e->instance->base) == RS::MULTIMESH_TRANSFORM_2D) {
id.flags |= INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D;
stride = 2;
} else {
@@ -678,7 +678,7 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements,
}
id.flags |= (stride << INSTANCE_DATA_FLAGS_MULTIMESH_STRIDE_SHIFT);
- } else if (e->instance->base_type == VS::INSTANCE_MESH) {
+ } else if (e->instance->base_type == RS::INSTANCE_MESH) {
if (e->instance->skeleton.is_valid()) {
id.flags |= INSTANCE_DATA_FLAG_SKELETON;
}
@@ -749,7 +749,6 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, default_vec4_xform_uniform_set, TRANSFORMS_UNIFORM_SET);
MaterialData *prev_material = nullptr;
- // ShaderData *prev_shader = nullptr;
RID prev_vertex_array_rd;
RID prev_index_array_rd;
@@ -770,7 +769,7 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
//find cull variant
ShaderData::CullVariant cull_variant;
- if ((p_pass_mode == PASS_MODE_SHADOW || p_pass_mode == PASS_MODE_SHADOW_DP) && e->instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
+ if ((p_pass_mode == PASS_MODE_SHADOW || p_pass_mode == PASS_MODE_SHADOW_DP) && e->instance->cast_shadows == RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
cull_variant = ShaderData::CULL_VARIANT_DOUBLE_SIDED;
} else {
bool mirror = e->instance->mirror;
@@ -781,16 +780,16 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
}
//find primitive and vertex format
- VS::PrimitiveType primitive;
+ RS::PrimitiveType primitive;
switch (e->instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
primitive = storage->mesh_surface_get_primitive(e->instance->base, e->surface_index);
if (e->instance->skeleton.is_valid()) {
xforms_uniform_set = storage->skeleton_get_3d_uniform_set(e->instance->skeleton, default_shader_rd, TRANSFORMS_UNIFORM_SET);
}
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
RID mesh = storage->multimesh_get_mesh(e->instance->base);
ERR_CONTINUE(!mesh.is_valid()); //should be a bug
primitive = storage->mesh_surface_get_primitive(mesh, e->surface_index);
@@ -798,10 +797,10 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
xforms_uniform_set = storage->multimesh_get_3d_uniform_set(e->instance->base, default_shader_rd, TRANSFORMS_UNIFORM_SET);
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
ERR_CONTINUE(true); //should be a bug
} break;
- case VS::INSTANCE_PARTICLES: {
+ case RS::INSTANCE_PARTICLES: {
ERR_CONTINUE(true); //should be a bug
} break;
default: {
@@ -809,12 +808,11 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
}
}
- ShaderVersion shader_version;
+ ShaderVersion shader_version = SHADER_VERSION_MAX; // Assigned to silence wrong -Wmaybe-initialized.
switch (p_pass_mode) {
case PASS_MODE_COLOR:
case PASS_MODE_COLOR_TRANSPARENT: {
-
if (e->uses_lightmap) {
shader_version = SHADER_VERSION_LIGHTMAP_COLOR_PASS;
} else if (e->uses_vct) {
@@ -822,7 +820,6 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
} else {
shader_version = SHADER_VERSION_COLOR_PASS;
}
-
} break;
case PASS_MODE_COLOR_SPECULAR: {
if (e->uses_lightmap) {
@@ -855,23 +852,23 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
pipeline = &shader->pipelines[cull_variant][primitive][shader_version];
- RD::VertexFormatID vertex_format;
+ RD::VertexFormatID vertex_format = -1;
RID vertex_array_rd;
RID index_array_rd;
switch (e->instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
storage->mesh_surface_get_arrays_and_format(e->instance->base, e->surface_index, pipeline->get_vertex_input_mask(), vertex_array_rd, index_array_rd, vertex_format);
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
RID mesh = storage->multimesh_get_mesh(e->instance->base);
ERR_CONTINUE(!mesh.is_valid()); //should be a bug
storage->mesh_surface_get_arrays_and_format(mesh, e->surface_index, pipeline->get_vertex_input_mask(), vertex_array_rd, index_array_rd, vertex_format);
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
ERR_CONTINUE(true); //should be a bug
} break;
- case VS::INSTANCE_PARTICLES: {
+ case RS::INSTANCE_PARTICLES: {
ERR_CONTINUE(true); //should be a bug
} break;
default: {
@@ -918,17 +915,17 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
RD::get_singleton()->draw_list_set_push_constant(draw_list, &push_constant, sizeof(PushConstant));
switch (e->instance->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
RD::get_singleton()->draw_list_draw(draw_list, index_array_rd.is_valid());
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
uint32_t instances = storage->multimesh_get_instances_to_draw(e->instance->base);
RD::get_singleton()->draw_list_draw(draw_list, index_array_rd.is_valid(), instances);
} break;
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
} break;
- case VS::INSTANCE_PARTICLES: {
+ case RS::INSTANCE_PARTICLES: {
} break;
default: {
@@ -971,7 +968,7 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
//time global variables
scene_state.ubo.time = time;
- if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
+ if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
scene_state.ubo.use_ambient_light = true;
scene_state.ubo.ambient_light_color_energy[0] = 1;
@@ -984,8 +981,8 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
} else if (is_environment(p_environment)) {
- VS::EnvironmentBG env_bg = environment_get_background(p_environment);
- VS::EnvironmentAmbientSource ambient_src = environment_get_ambient_light_ambient_source(p_environment);
+ RS::EnvironmentBG env_bg = environment_get_background(p_environment);
+ RS::EnvironmentAmbientSource ambient_src = environment_get_ambient_light_ambient_source(p_environment);
float bg_energy = environment_get_bg_energy(p_environment);
scene_state.ubo.ambient_light_color_energy[3] = bg_energy;
@@ -993,9 +990,9 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
scene_state.ubo.ambient_color_sky_mix = environment_get_ambient_sky_contribution(p_environment);
//ambient
- if (ambient_src == VS::ENV_AMBIENT_SOURCE_BG && (env_bg == VS::ENV_BG_CLEAR_COLOR || env_bg == VS::ENV_BG_COLOR)) {
+ if (ambient_src == RS::ENV_AMBIENT_SOURCE_BG && (env_bg == RS::ENV_BG_CLEAR_COLOR || env_bg == RS::ENV_BG_COLOR)) {
- Color color = env_bg == VS::ENV_BG_CLEAR_COLOR ? p_default_bg_color : environment_get_bg_color(p_environment);
+ Color color = env_bg == RS::ENV_BG_CLEAR_COLOR ? p_default_bg_color : environment_get_bg_color(p_environment);
color = color.to_linear();
scene_state.ubo.ambient_light_color_energy[0] = color.r * bg_energy;
@@ -1016,13 +1013,13 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
sky_transform = sky_transform.inverse() * p_cam_transform.basis;
store_transform_3x3(sky_transform, scene_state.ubo.radiance_inverse_xform);
- scene_state.ubo.use_ambient_cubemap = (ambient_src == VS::ENV_AMBIENT_SOURCE_BG && env_bg == VS::ENV_BG_SKY) || ambient_src == VS::ENV_AMBIENT_SOURCE_SKY;
- scene_state.ubo.use_ambient_light = scene_state.ubo.use_ambient_cubemap || ambient_src == VS::ENV_AMBIENT_SOURCE_COLOR;
+ scene_state.ubo.use_ambient_cubemap = (ambient_src == RS::ENV_AMBIENT_SOURCE_BG && env_bg == RS::ENV_BG_SKY) || ambient_src == RS::ENV_AMBIENT_SOURCE_SKY;
+ scene_state.ubo.use_ambient_light = scene_state.ubo.use_ambient_cubemap || ambient_src == RS::ENV_AMBIENT_SOURCE_COLOR;
}
//specular
- VS::EnvironmentReflectionSource ref_src = environment_get_reflection_source(p_environment);
- if ((ref_src == VS::ENV_REFLECTION_SOURCE_BG && env_bg == VS::ENV_BG_SKY) || ref_src == VS::ENV_REFLECTION_SOURCE_SKY) {
+ RS::EnvironmentReflectionSource ref_src = environment_get_reflection_source(p_environment);
+ if ((ref_src == RS::ENV_REFLECTION_SOURCE_BG && env_bg == RS::ENV_BG_SKY) || ref_src == RS::ENV_REFLECTION_SOURCE_SKY) {
scene_state.ubo.use_reflection_cubemap = true;
} else {
scene_state.ubo.use_reflection_cubemap = false;
@@ -1067,12 +1064,12 @@ void RasterizerSceneHighEndRD::_add_geometry(InstanceBase *p_instance, uint32_t
m_src = p_instance->material_override.is_valid() ? p_instance->material_override : p_material;
- if (unlikely(get_debug_draw_mode() != VS::VIEWPORT_DEBUG_DRAW_DISABLED)) {
- if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
+ if (unlikely(get_debug_draw_mode() != RS::VIEWPORT_DEBUG_DRAW_DISABLED)) {
+ if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
m_src = overdraw_material;
- } else if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_WIREFRAME) {
+ } else if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME) {
m_src = wireframe_material;
- } else if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_LIGHTING) {
+ } else if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_LIGHTING) {
m_src = default_material;
}
}
@@ -1129,7 +1126,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
if (p_pass_mode != PASS_MODE_COLOR && p_pass_mode != PASS_MODE_COLOR_SPECULAR) {
- if (has_blend_alpha || has_read_screen_alpha || (has_base_alpha && !p_material->shader_data->uses_depth_pre_pass) || p_material->shader_data->depth_draw == ShaderData::DEPTH_DRAW_DISABLED || p_material->shader_data->depth_test == ShaderData::DEPTH_TEST_DISABLED || p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) {
+ if (has_blend_alpha || has_read_screen_alpha || (has_base_alpha && !p_material->shader_data->uses_depth_pre_pass) || p_material->shader_data->depth_draw == ShaderData::DEPTH_DRAW_DISABLED || p_material->shader_data->depth_test == ShaderData::DEPTH_TEST_DISABLED || p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_OFF) {
//conditions in which no depth pass should be processed
return;
}
@@ -1172,7 +1169,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
}
e->geometry_index = p_geometry_index;
e->material_index = e->material->index;
- e->uses_instancing = e->instance->base_type == VS::INSTANCE_MULTIMESH;
+ e->uses_instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH;
e->uses_lightmap = e->instance->lightmap.is_valid();
e->uses_vct = e->instance->gi_probe_instances.size();
e->shader_index = e->shader_index;
@@ -1180,7 +1177,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
e->priority = p_material->priority;
if (p_material->shader_data->uses_time) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
}
@@ -1204,7 +1201,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
//add geometry for drawing
switch (inst->base_type) {
- case VS::INSTANCE_MESH: {
+ case RS::INSTANCE_MESH: {
const RID *materials = NULL;
uint32_t surface_count;
@@ -1228,7 +1225,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
} break;
- case VS::INSTANCE_MULTIMESH: {
+ case RS::INSTANCE_MULTIMESH: {
if (storage->multimesh_get_instances_to_draw(inst->base) == 0) {
//not visible, 0 instances
@@ -1256,7 +1253,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
} break;
#if 0
- case VS::INSTANCE_IMMEDIATE: {
+ case RS::INSTANCE_IMMEDIATE: {
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
ERR_CONTINUE(!immediate);
@@ -1264,7 +1261,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
_add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass);
} break;
- case VS::INSTANCE_PARTICLES: {
+ case RS::INSTANCE_PARTICLES: {
RasterizerStorageGLES3::Particles *particles = storage->particles_owner.getornull(inst->base);
ERR_CONTINUE(!particles);
@@ -1442,10 +1439,10 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
ERR_CONTINUE(base.is_null());
- VS::LightType type = storage->light_get_type(base);
+ RS::LightType type = storage->light_get_type(base);
switch (type) {
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
if (scene_state.ubo.directional_light_count >= scene_state.max_directional_lights) {
continue;
@@ -1463,14 +1460,14 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
float sign = storage->light_is_negative(base) ? -1 : 1;
- light_data.energy = sign * storage->light_get_param(base, VS::LIGHT_PARAM_ENERGY) * Math_PI;
+ light_data.energy = sign * storage->light_get_param(base, RS::LIGHT_PARAM_ENERGY) * Math_PI;
Color linear_col = storage->light_get_color(base).to_linear();
light_data.color[0] = linear_col.r;
light_data.color[1] = linear_col.g;
light_data.color[2] = linear_col.b;
- light_data.specular = storage->light_get_param(base, VS::LIGHT_PARAM_SPECULAR);
+ light_data.specular = storage->light_get_param(base, RS::LIGHT_PARAM_SPECULAR);
light_data.mask = storage->light_get_cull_mask(base);
Color shadow_col = storage->light_get_shadow_color(base).to_linear();
@@ -1483,9 +1480,9 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
if (light_data.shadow_enabled) {
- VS::LightDirectionalShadowMode smode = storage->light_directional_get_shadow_mode(base);
+ RS::LightDirectionalShadowMode smode = storage->light_directional_get_shadow_mode(base);
- int limit = smode == VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL ? 0 : (smode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS ? 1 : 3);
+ int limit = smode == RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL ? 0 : (smode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS ? 1 : 3);
light_data.blend_splits = storage->light_directional_get_blend_splits(base);
for (int j = 0; j < 4; j++) {
Rect2 atlas_rect = light_instance_get_directional_shadow_atlas_rect(li, j);
@@ -1504,7 +1501,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
store_camera(shadow_mtx, light_data.shadow_matrices[j]);
}
- float fade_start = storage->light_get_param(base, VS::LIGHT_PARAM_SHADOW_FADE_START);
+ float fade_start = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_FADE_START);
light_data.fade_from = -light_data.shadow_split_offsets[3] * MIN(fade_start, 0.999); //using 1.0 would break smoothstep
light_data.fade_to = -light_data.shadow_split_offsets[3];
}
@@ -1532,8 +1529,8 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
scene_state.ubo.directional_light_count++;
} break;
- case VS::LIGHT_SPOT:
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_SPOT:
+ case RS::LIGHT_OMNI: {
if (light_count >= scene_state.max_lights) {
continue;
@@ -1546,15 +1543,15 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
float sign = storage->light_is_negative(base) ? -1 : 1;
Color linear_col = storage->light_get_color(base).to_linear();
- light_data.attenuation_energy[0] = Math::make_half_float(storage->light_get_param(base, VS::LIGHT_PARAM_ATTENUATION));
- light_data.attenuation_energy[1] = Math::make_half_float(sign * storage->light_get_param(base, VS::LIGHT_PARAM_ENERGY) * Math_PI);
+ light_data.attenuation_energy[0] = Math::make_half_float(storage->light_get_param(base, RS::LIGHT_PARAM_ATTENUATION));
+ light_data.attenuation_energy[1] = Math::make_half_float(sign * storage->light_get_param(base, RS::LIGHT_PARAM_ENERGY) * Math_PI);
light_data.color_specular[0] = MIN(uint32_t(linear_col.r * 255), 255);
light_data.color_specular[1] = MIN(uint32_t(linear_col.g * 255), 255);
light_data.color_specular[2] = MIN(uint32_t(linear_col.b * 255), 255);
- light_data.color_specular[3] = MIN(uint32_t(storage->light_get_param(base, VS::LIGHT_PARAM_SPECULAR) * 255), 255);
+ light_data.color_specular[3] = MIN(uint32_t(storage->light_get_param(base, RS::LIGHT_PARAM_SPECULAR) * 255), 255);
- float radius = MAX(0.001, storage->light_get_param(base, VS::LIGHT_PARAM_RANGE));
+ float radius = MAX(0.001, storage->light_get_param(base, RS::LIGHT_PARAM_RANGE));
light_data.inv_radius = 1.0 / radius;
Vector3 pos = p_camera_inverse_transform.xform(light_transform.origin);
@@ -1569,8 +1566,8 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
light_data.direction[1] = direction.y;
light_data.direction[2] = direction.z;
- light_data.cone_attenuation_angle[0] = Math::make_half_float(storage->light_get_param(base, VS::LIGHT_PARAM_SPOT_ATTENUATION));
- float spot_angle = storage->light_get_param(base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ light_data.cone_attenuation_angle[0] = Math::make_half_float(storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ATTENUATION));
+ float spot_angle = storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ANGLE);
light_data.cone_attenuation_angle[1] = Math::make_half_float(Math::cos(Math::deg2rad(spot_angle)));
light_data.mask = storage->light_get_cull_mask(base);
@@ -1593,7 +1590,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
Rect2 rect = light_instance_get_shadow_atlas_rect(li, p_shadow_atlas);
- if (type == VS::LIGHT_OMNI) {
+ if (type == RS::LIGHT_OMNI) {
light_data.atlas_rect[0] = rect.position.x;
light_data.atlas_rect[1] = rect.position.y;
@@ -1603,7 +1600,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
Transform proj = (p_camera_inverse_transform * light_transform).inverse();
store_transform(proj, light_data.shadow_matrix);
- } else if (type == VS::LIGHT_SPOT) {
+ } else if (type == RS::LIGHT_SPOT) {
Transform modelview = (p_camera_inverse_transform * light_transform).inverse();
CameraMatrix bias;
@@ -1618,7 +1615,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
light_instance_set_index(li, light_count);
- cluster_builder.add_light(type == VS::LIGHT_SPOT ? LightClusterBuilder::LIGHT_TYPE_SPOT : LightClusterBuilder::LIGHT_TYPE_OMNI, light_transform, radius, spot_angle);
+ cluster_builder.add_light(type == RS::LIGHT_SPOT ? LightClusterBuilder::LIGHT_TYPE_SPOT : LightClusterBuilder::LIGHT_TYPE_OMNI, light_transform, radius, spot_angle);
light_count++;
} break;
@@ -1673,7 +1670,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
RENDER_TIMESTAMP("Setup 3D Scene");
- if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
+ if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
p_light_cull_count = 0;
p_reflection_probe_cull_count = 0;
p_gi_probe_cull_count = 0;
@@ -1723,7 +1720,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
//we need to allocate both these, if not allocated
_allocate_normal_texture(render_buffer);
_allocate_roughness_texture(render_buffer);
- } else if (p_environment.is_valid() && (environment_is_ssao_enabled(p_environment) || get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER)) {
+ } else if (p_environment.is_valid() && (environment_is_ssao_enabled(p_environment) || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER)) {
depth_pass_mode = PASS_MODE_DEPTH_NORMAL;
}
@@ -1788,25 +1785,25 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
Color clear_color;
bool keep_color = false;
- if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
+ if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
clear_color = Color(0, 0, 0, 1); //in overdraw mode, BG should always be black
} else if (is_environment(p_environment)) {
- VS::EnvironmentBG bg_mode = environment_get_background(p_environment);
+ RS::EnvironmentBG bg_mode = environment_get_background(p_environment);
float bg_energy = environment_get_bg_energy(p_environment);
switch (bg_mode) {
- case VS::ENV_BG_CLEAR_COLOR: {
+ case RS::ENV_BG_CLEAR_COLOR: {
clear_color = p_default_bg_color;
clear_color.r *= bg_energy;
clear_color.g *= bg_energy;
clear_color.b *= bg_energy;
} break;
- case VS::ENV_BG_COLOR: {
+ case RS::ENV_BG_COLOR: {
clear_color = environment_get_bg_color(p_environment);
clear_color.r *= bg_energy;
clear_color.g *= bg_energy;
clear_color.b *= bg_energy;
} break;
- case VS::ENV_BG_SKY: {
+ case RS::ENV_BG_SKY: {
RID sky = environment_get_sky(p_environment);
if (sky.is_valid()) {
@@ -1825,13 +1822,13 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
draw_sky = true;
}
} break;
- case VS::ENV_BG_CANVAS: {
+ case RS::ENV_BG_CANVAS: {
keep_color = true;
} break;
- case VS::ENV_BG_KEEP: {
+ case RS::ENV_BG_KEEP: {
keep_color = true;
} break;
- case VS::ENV_BG_CAMERA_FEED: {
+ case RS::ENV_BG_CAMERA_FEED: {
} break;
default: {
@@ -1849,7 +1846,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
_fill_instances(render_list.elements, render_list.element_count, false);
bool can_continue = true; //unless the middle buffers are needed
- bool debug_giprobes = get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO || get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING || get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION;
+ bool debug_giprobes = get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION;
bool using_separate_specular = false;
bool depth_pre_pass = depth_framebuffer.is_valid();
@@ -1899,7 +1896,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
CameraMatrix cm = (dc * p_cam_projection) * CameraMatrix(p_cam_transform.affine_inverse());
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, will_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, will_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ);
for (int i = 0; i < p_gi_probe_cull_count; i++) {
- _debug_giprobe(p_gi_probe_cull_result[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0);
+ _debug_giprobe(p_gi_probe_cull_result[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0);
}
RD::get_singleton()->draw_list_end();
}
@@ -2108,18 +2105,18 @@ void RasterizerSceneHighEndRD::_update_render_base_uniform_set() {
u.binding = 1;
u.ids.resize(12);
RID *ids_ptr = u.ids.ptrw();
- ids_ptr[0] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[1] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[2] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[3] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[4] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[5] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[6] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[7] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[8] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[9] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[10] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[11] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[0] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[1] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[2] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[3] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[4] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[5] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[6] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[7] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[8] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[9] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[10] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[11] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
uniforms.push_back(u);
}
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h
index 960b95ee86..4c3422cedb 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h
@@ -31,11 +31,11 @@
#ifndef RASTERIZER_SCENE_HIGHEND_RD_H
#define RASTERIZER_SCENE_HIGHEND_RD_H
-#include "servers/visual/rasterizer_rd/light_cluster_builder.h"
-#include "servers/visual/rasterizer_rd/rasterizer_scene_rd.h"
-#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h"
-#include "servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
-#include "servers/visual/rasterizer_rd/shaders/scene_high_end.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/light_cluster_builder.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_scene_rd.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h"
+#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h"
+#include "servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl.gen.h"
class RasterizerSceneHighEndRD : public RasterizerSceneRD {
@@ -111,7 +111,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
bool valid;
RID version;
uint32_t vertex_input_mask;
- RenderPipelineVertexFormatCacheRD pipelines[CULL_VARIANT_MAX][VS::PRIMITIVE_MAX][SHADER_VERSION_MAX];
+ RenderPipelineVertexFormatCacheRD pipelines[CULL_VARIANT_MAX][RS::PRIMITIVE_MAX][SHADER_VERSION_MAX];
String path;
@@ -211,7 +211,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
void ensure_specular();
void clear();
- virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, VS::ViewportMSAA p_msaa);
+ virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa);
RID uniform_set;
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
index 41682d3135..842f7046c9 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
@@ -32,7 +32,7 @@
#include "core/os/os.h"
#include "core/project_settings.h"
-#include "servers/visual/visual_server_raster.h"
+#include "servers/rendering/rendering_server_raster.h"
uint64_t RasterizerSceneRD::auto_exposure_counter = 2;
@@ -212,7 +212,7 @@ void RasterizerSceneRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
}
sky->radiance_size = p_radiance_size;
- if (sky->mode == VS::SKY_MODE_REALTIME && sky->radiance_size != 256) {
+ if (sky->mode == RS::SKY_MODE_REALTIME && sky->radiance_size != 256) {
WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally.");
sky->radiance_size = 256;
}
@@ -225,7 +225,7 @@ void RasterizerSceneRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
_clear_reflection_data(sky->reflection);
}
-void RasterizerSceneRD::sky_set_mode(RID p_sky, VS::SkyMode p_mode) {
+void RasterizerSceneRD::sky_set_mode(RID p_sky, RS::SkyMode p_mode) {
Sky *sky = sky_owner.getornull(p_sky);
ERR_FAIL_COND(!sky);
@@ -235,7 +235,7 @@ void RasterizerSceneRD::sky_set_mode(RID p_sky, VS::SkyMode p_mode) {
sky->mode = p_mode;
- if (sky->mode == VS::SKY_MODE_REALTIME && sky->radiance_size != 256) {
+ if (sky->mode == RS::SKY_MODE_REALTIME && sky->radiance_size != 256) {
WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally.");
sky_set_radiance_size(p_sky, 256);
}
@@ -267,7 +267,7 @@ void RasterizerSceneRD::_update_dirty_skys() {
uint32_t w = sky->radiance_size, h = sky->radiance_size;
int layers = roughness_layers;
- if (sky->mode == VS::SKY_MODE_REALTIME) {
+ if (sky->mode == RS::SKY_MODE_REALTIME) {
layers = 8;
if (roughness_layers != 8) {
WARN_PRINT("When using REALTIME skies, roughness_layers should be set to 8 in the project settings for best quality reflections");
@@ -287,7 +287,7 @@ void RasterizerSceneRD::_update_dirty_skys() {
sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView());
- _update_reflection_data(sky->reflection, sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == VS::SKY_MODE_REALTIME);
+ _update_reflection_data(sky->reflection, sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME);
} else {
//regular cubemap, lower quality (aliasing, less memory)
@@ -302,7 +302,7 @@ void RasterizerSceneRD::_update_dirty_skys() {
sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView());
- _update_reflection_data(sky->reflection, sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == VS::SKY_MODE_REALTIME);
+ _update_reflection_data(sky->reflection, sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME);
}
texture_set_dirty = true;
}
@@ -410,16 +410,18 @@ RID RasterizerSceneRD::_get_sky_textures(Sky *p_sky, SkyTextureSetVersion p_vers
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 1; // half res
- if (p_sky->half_res_pass.is_valid() && (p_version != SKY_TEXTURE_SET_HALF_RES) && (p_version < SKY_TEXTURE_SET_CUBEMAP_HALF_RES0 || p_version > SKY_TEXTURE_SET_CUBEMAP_HALF_RES5)) {
- if (p_version >= SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES0) {
- u.ids.push_back(p_sky->reflection.layers[0].mipmaps[1].views[p_version - SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES0]);
- } else if (p_version >= SKY_TEXTURE_SET_CUBEMAP0) {
- u.ids.push_back(p_sky->reflection.layers[0].mipmaps[1].views[p_version - SKY_TEXTURE_SET_CUBEMAP0]);
+ if (p_sky->half_res_pass.is_valid() && p_version != SKY_TEXTURE_SET_HALF_RES && p_version != SKY_TEXTURE_SET_CUBEMAP_HALF_RES) {
+ if (p_version >= SKY_TEXTURE_SET_CUBEMAP) {
+ u.ids.push_back(p_sky->reflection.layers[0].views[1]);
} else {
u.ids.push_back(p_sky->half_res_pass);
}
} else {
- u.ids.push_back(storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_WHITE));
+ if (p_version < SKY_TEXTURE_SET_CUBEMAP) {
+ u.ids.push_back(storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_WHITE));
+ } else {
+ u.ids.push_back(storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
+ }
}
uniforms.push_back(u);
}
@@ -427,16 +429,18 @@ RID RasterizerSceneRD::_get_sky_textures(Sky *p_sky, SkyTextureSetVersion p_vers
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 2; // quarter res
- if (p_sky->quarter_res_pass.is_valid() && (p_version != SKY_TEXTURE_SET_QUARTER_RES) && (p_version < SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES0 || p_version > SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES5)) {
- if (p_version >= SKY_TEXTURE_SET_CUBEMAP_HALF_RES0) {
- u.ids.push_back(p_sky->reflection.layers[0].mipmaps[2].views[p_version - SKY_TEXTURE_SET_CUBEMAP_HALF_RES0]);
- } else if (p_version >= SKY_TEXTURE_SET_CUBEMAP0) {
- u.ids.push_back(p_sky->reflection.layers[0].mipmaps[2].views[p_version - SKY_TEXTURE_SET_CUBEMAP0]);
+ if (p_sky->quarter_res_pass.is_valid() && p_version != SKY_TEXTURE_SET_QUARTER_RES && p_version != SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES) {
+ if (p_version >= SKY_TEXTURE_SET_CUBEMAP) {
+ u.ids.push_back(p_sky->reflection.layers[0].views[2]);
} else {
u.ids.push_back(p_sky->quarter_res_pass);
}
} else {
- u.ids.push_back(storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_WHITE));
+ if (p_version < SKY_TEXTURE_SET_CUBEMAP) {
+ u.ids.push_back(storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_WHITE));
+ } else {
+ u.ids.push_back(storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_CUBEMAP_BLACK));
+ }
}
uniforms.push_back(u);
}
@@ -600,7 +604,7 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position,
sky->prev_time = time;
sky->reflection.dirty = true;
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
if (material != sky->prev_material) {
@@ -733,7 +737,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
cm = correction * cm;
if (shader_data->uses_quarter_res) {
- RenderPipelineVertexFormatCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_QUARTER_RES];
+ RenderPipelineVertexFormatCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_QUARTER_RES];
Vector<Color> clear_colors;
clear_colors.push_back(Color(0.0, 0.0, 0.0));
@@ -742,7 +746,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
for (int i = 0; i < 6; i++) {
Transform local_view;
local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]);
- RID texture_uniform_set = _get_sky_textures(sky, SkyTextureSetVersion(SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES0 + i));
+ RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES);
cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[2].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
storage->get_effects()->render_sky(cubemap_draw_list, time, sky->reflection.layers[0].mipmaps[2].framebuffers[i], sky_scene_state.sampler_uniform_set, sky_scene_state.light_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin);
@@ -751,7 +755,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
}
if (shader_data->uses_half_res) {
- RenderPipelineVertexFormatCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_HALF_RES];
+ RenderPipelineVertexFormatCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_HALF_RES];
Vector<Color> clear_colors;
clear_colors.push_back(Color(0.0, 0.0, 0.0));
@@ -760,7 +764,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
for (int i = 0; i < 6; i++) {
Transform local_view;
local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]);
- RID texture_uniform_set = _get_sky_textures(sky, SkyTextureSetVersion(SKY_TEXTURE_SET_CUBEMAP_HALF_RES0 + i));
+ RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_CUBEMAP_HALF_RES);
cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[1].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
storage->get_effects()->render_sky(cubemap_draw_list, time, sky->reflection.layers[0].mipmaps[1].framebuffers[i], sky_scene_state.sampler_uniform_set, sky_scene_state.light_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin);
@@ -774,14 +778,14 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
for (int i = 0; i < 6; i++) {
Transform local_view;
local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]);
- RID texture_uniform_set = _get_sky_textures(sky, SkyTextureSetVersion(SKY_TEXTURE_SET_CUBEMAP0 + i));
+ RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_CUBEMAP);
cubemap_draw_list = RD::get_singleton()->draw_list_begin(sky->reflection.layers[0].mipmaps[0].framebuffers[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD);
storage->get_effects()->render_sky(cubemap_draw_list, time, sky->reflection.layers[0].mipmaps[0].framebuffers[i], sky_scene_state.sampler_uniform_set, sky_scene_state.light_uniform_set, pipeline, material->uniform_set, texture_uniform_set, cm, local_view.basis, multiplier, p_transform.origin);
RD::get_singleton()->draw_list_end();
}
if (sky_use_cubemap_array) {
- if (sky->mode == VS::SKY_MODE_QUALITY) {
+ if (sky->mode == RS::SKY_MODE_QUALITY) {
for (int i = 1; i < sky->reflection.layers.size(); i++) {
_create_reflection_importance_sample(sky->reflection, sky_use_cubemap_array, 10, i);
}
@@ -791,7 +795,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
_update_reflection_mipmaps(sky->reflection);
} else {
- if (sky->mode == VS::SKY_MODE_QUALITY) {
+ if (sky->mode == RS::SKY_MODE_QUALITY) {
for (int i = 1; i < sky->reflection.layers[0].mipmaps.size(); i++) {
_create_reflection_importance_sample(sky->reflection, sky_use_cubemap_array, 10, i);
}
@@ -829,9 +833,6 @@ void RasterizerSceneRD::SkyShaderData::set_code(const String &p_code) {
actions.render_mode_flags["use_half_res_pass"] = &uses_half_res;
actions.render_mode_flags["use_quarter_res_pass"] = &uses_quarter_res;
- // TODO: Consider using usage flags instead
- //actions.usage_flag_pointers["HALF_RES_TEXTURE"] = &uses_half_res;
- //actions.usage_flag_pointers["QUARTER_RES_TEXTURE"] = &uses_quarter_res;
actions.usage_flag_pointers["TIME"] = &uses_time;
actions.usage_flag_pointers["POSITION"] = &uses_position;
@@ -856,7 +857,7 @@ void RasterizerSceneRD::SkyShaderData::set_code(const String &p_code) {
RasterizerSceneRD *scene_singleton = (RasterizerSceneRD *)RasterizerSceneRD::singleton;
- Error err = scene_singleton->sky_shader.compiler.compile(VS::SHADER_SKY, code, &actions, path, gen_code);
+ Error err = scene_singleton->sky_shader.compiler.compile(RS::SHADER_SKY, code, &actions, path, gen_code);
ERR_FAIL_COND(err != OK);
@@ -1081,7 +1082,7 @@ RID RasterizerSceneRD::environment_create() {
return environment_owner.make_rid(Environent());
}
-void RasterizerSceneRD::environment_set_background(RID p_env, VS::EnvironmentBG p_bg) {
+void RasterizerSceneRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->background = p_bg;
@@ -1116,7 +1117,7 @@ void RasterizerSceneRD::environment_set_canvas_max_layer(RID p_env, int p_max_la
ERR_FAIL_COND(!env);
env->canvas_max_layer = p_max_layer;
}
-void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, VS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) {
+void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->ambient_light = p_color;
@@ -1127,9 +1128,9 @@ void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_
env->ao_color = p_ao_color;
}
-VS::EnvironmentBG RasterizerSceneRD::environment_get_background(RID p_env) const {
+RS::EnvironmentBG RasterizerSceneRD::environment_get_background(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
- ERR_FAIL_COND_V(!env, VS::ENV_BG_MAX);
+ ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX);
return env->background;
}
RID RasterizerSceneRD::environment_get_sky(RID p_env) const {
@@ -1167,9 +1168,9 @@ Color RasterizerSceneRD::environment_get_ambient_light_color(RID p_env) const {
ERR_FAIL_COND_V(!env, Color());
return env->ambient_light;
}
-VS::EnvironmentAmbientSource RasterizerSceneRD::environment_get_ambient_light_ambient_source(RID p_env) const {
+RS::EnvironmentAmbientSource RasterizerSceneRD::environment_get_ambient_light_ambient_source(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
- ERR_FAIL_COND_V(!env, VS::ENV_AMBIENT_SOURCE_BG);
+ ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG);
return env->ambient_source;
}
float RasterizerSceneRD::environment_get_ambient_light_ambient_energy(RID p_env) const {
@@ -1182,9 +1183,9 @@ float RasterizerSceneRD::environment_get_ambient_sky_contribution(RID p_env) con
ERR_FAIL_COND_V(!env, 0);
return env->ambient_sky_contribution;
}
-VS::EnvironmentReflectionSource RasterizerSceneRD::environment_get_reflection_source(RID p_env) const {
+RS::EnvironmentReflectionSource RasterizerSceneRD::environment_get_reflection_source(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
- ERR_FAIL_COND_V(!env, VS::ENV_REFLECTION_SOURCE_DISABLED);
+ ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED);
return env->reflection_source;
}
@@ -1194,7 +1195,7 @@ Color RasterizerSceneRD::environment_get_ao_color(RID p_env) const {
return env->ao_color;
}
-void RasterizerSceneRD::environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
+void RasterizerSceneRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->exposure = p_exposure;
@@ -1210,7 +1211,7 @@ void RasterizerSceneRD::environment_set_tonemap(RID p_env, VS::EnvironmentToneMa
env->auto_exp_scale = p_auto_exp_scale;
}
-void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
+void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -1227,7 +1228,7 @@ void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_lev
env->glow_bicubic_upscale = p_bicubic_upscale;
}
-void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {
+void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -1241,7 +1242,7 @@ void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_r
env->ssao_blur = p_blur;
}
-void RasterizerSceneRD::environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) {
+void RasterizerSceneRD::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) {
ssao_quality = p_quality;
ssao_half_size = p_half_size;
}
@@ -1362,7 +1363,7 @@ bool RasterizerSceneRD::reflection_probe_instance_needs_redraw(RID p_instance) {
return true;
}
- if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS) {
+ if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) {
return true;
}
@@ -1386,12 +1387,12 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
- if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->size != 256) {
+ if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->size != 256) {
WARN_PRINT("ReflectionProbes set to UPDATE_ALWAYS must have an atlas size of 256. Please update the atlas size in the ProjectSettings.");
reflection_atlas_set_size(p_reflection_atlas, 256, atlas->count);
}
- if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->reflections[0].data.layers[0].mipmaps.size() != 8) {
+ if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->reflections[0].data.layers[0].mipmaps.size() != 8) {
// Invalidate reflection atlas, need to regenerate
RD::get_singleton()->free(atlas->reflection);
atlas->reflection = RID();
@@ -1408,7 +1409,7 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R
if (atlas->reflection.is_null()) {
int mipmaps = MIN(roughness_layers, Image::get_image_required_mipmaps(atlas->size, atlas->size, Image::FORMAT_RGBAH) + 1);
- mipmaps = storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS ? 8 : mipmaps; // always use 8 mipmaps with real time filtering
+ mipmaps = storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS ? 8 : mipmaps; // always use 8 mipmaps with real time filtering
{
//reflection atlas was unused, create:
RD::TextureFormat tf;
@@ -1433,7 +1434,7 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R
}
atlas->reflections.resize(atlas->count);
for (int i = 0; i < atlas->count; i++) {
- _update_reflection_data(atlas->reflections.write[i].data, atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS);
+ _update_reflection_data(atlas->reflections.write[i].data, atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS);
for (int j = 0; j < 6; j++) {
Vector<RID> fb;
fb.push_back(atlas->reflections.write[i].data.layers[0].mipmaps[0].views[j]);
@@ -1492,7 +1493,7 @@ bool RasterizerSceneRD::reflection_probe_instance_postprocess_step(RID p_instanc
return false;
}
- if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS) {
+ if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) {
// Using real time reflections, all roughness is done in one step
_create_reflection_fast_filter(atlas->reflections.write[rpi->atlas_index].data, false);
rpi->rendering = false;
@@ -1936,10 +1937,10 @@ int RasterizerSceneRD::get_directional_light_shadow_size(RID p_light_intance) {
ERR_FAIL_COND_V(!light_instance, 0);
switch (storage->light_directional_get_shadow_mode(light_instance->light)) {
- case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
+ case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL:
break; //none
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: r.size.height /= 2; break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: r.size /= 2; break;
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: r.size.height /= 2; break;
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: r.size /= 2; break;
}
return MAX(r.size.width, r.size.height);
@@ -1952,13 +1953,13 @@ RID RasterizerSceneRD::camera_effects_create() {
return camera_effects_owner.make_rid(CameraEffects());
}
-void RasterizerSceneRD::camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) {
+void RasterizerSceneRD::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {
dof_blur_quality = p_quality;
dof_blur_use_jitter = p_use_jitter;
}
-void RasterizerSceneRD::camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) {
+void RasterizerSceneRD::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {
dof_blur_bokeh_shape = p_shape;
}
@@ -2013,7 +2014,7 @@ void RasterizerSceneRD::light_instance_set_shadow_transform(RID p_light_instance
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
- if (storage->light_get_type(light_instance->light) != VS::LIGHT_DIRECTIONAL) {
+ if (storage->light_get_type(light_instance->light) != RS::LIGHT_DIRECTIONAL) {
p_pass = 0;
}
@@ -2256,7 +2257,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_SAMPLER;
u.binding = 10;
- u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
+ u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
uniforms.push_back(u);
}
@@ -2445,7 +2446,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_SAMPLER;
u.binding = 10;
- u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
+ u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
uniforms.push_back(u);
}
{
@@ -2515,7 +2516,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_SAMPLER;
u.binding = 10;
- u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
+ u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
uniforms.push_back(u);
}
@@ -2588,16 +2589,16 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
RID light = light_instance_get_base_light(light_instance);
l.type = storage->light_get_type(light);
- l.attenuation = storage->light_get_param(light, VS::LIGHT_PARAM_ATTENUATION);
- l.energy = storage->light_get_param(light, VS::LIGHT_PARAM_ENERGY) * storage->light_get_param(light, VS::LIGHT_PARAM_INDIRECT_ENERGY);
- l.radius = to_cell.basis.xform(Vector3(storage->light_get_param(light, VS::LIGHT_PARAM_RANGE), 0, 0)).length();
+ l.attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_ATTENUATION);
+ l.energy = storage->light_get_param(light, RS::LIGHT_PARAM_ENERGY) * storage->light_get_param(light, RS::LIGHT_PARAM_INDIRECT_ENERGY);
+ l.radius = to_cell.basis.xform(Vector3(storage->light_get_param(light, RS::LIGHT_PARAM_RANGE), 0, 0)).length();
Color color = storage->light_get_color(light).to_linear();
l.color[0] = color.r;
l.color[1] = color.g;
l.color[2] = color.b;
- l.spot_angle_radians = Math::deg2rad(storage->light_get_param(light, VS::LIGHT_PARAM_SPOT_ANGLE));
- l.spot_attenuation = storage->light_get_param(light, VS::LIGHT_PARAM_SPOT_ATTENUATION);
+ l.spot_angle_radians = Math::deg2rad(storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ANGLE));
+ l.spot_attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ATTENUATION);
Transform xform = light_instance_get_base_transform(light_instance);
@@ -2974,7 +2975,7 @@ void RasterizerSceneRD::_debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_lis
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_SAMPLER;
u.binding = 3;
- u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
+ u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
uniforms.push_back(u);
}
@@ -3270,7 +3271,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
//swap final reduce with prev luminance
SWAP(rb->luminance.current, rb->luminance.reduce.write[rb->luminance.reduce.size() - 1]);
- VisualServerRaster::redraw_request(); //redraw all the time if auto exposure rendering is on
+ RenderingServerRaster::redraw_request(); //redraw all the time if auto exposure rendering is on
}
int max_glow_level = -1;
@@ -3285,7 +3286,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
_render_buffers_uniform_set_changed(p_render_buffers);
}
- for (int i = 0; i < VS::MAX_GLOW_LEVELS; i++) {
+ for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) {
if (env->glow_levels & (1 << i)) {
if (i >= rb->blur[1].mipmaps.size()) {
@@ -3334,7 +3335,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
if (can_use_effects && env && env->glow_enabled) {
tonemap.use_glow = true;
tonemap.glow_mode = RasterizerEffectsRD::TonemapSettings::GlowMode(env->glow_blend_mode);
- tonemap.glow_intensity = env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_MIX ? env->glow_mix : env->glow_intensity;
+ tonemap.glow_intensity = env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_MIX ? env->glow_mix : env->glow_intensity;
tonemap.glow_level_flags = glow_mask;
tonemap.glow_texture_size.x = rb->blur[1].mipmaps[0].width;
tonemap.glow_texture_size.y = rb->blur[1].mipmaps[0].height;
@@ -3362,7 +3363,7 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(!rb);
- if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS) {
+ if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS) {
if (p_shadow_atlas.is_valid()) {
RID shadow_atlas_texture = shadow_atlas_get_texture(p_shadow_atlas);
Size2 rtsize = storage->render_target_get_size(rb->render_target);
@@ -3371,7 +3372,7 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s
}
}
- if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS) {
+ if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS) {
if (directional_shadow_get_texture().is_valid()) {
RID shadow_atlas_texture = directional_shadow_get_texture();
Size2 rtsize = storage->render_target_get_size(rb->render_target);
@@ -3380,7 +3381,7 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s
}
}
- if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE) {
+ if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE) {
if (rb->luminance.current.is_valid()) {
Size2 rtsize = storage->render_target_get_size(rb->render_target);
@@ -3388,18 +3389,18 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s
}
}
- if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_SSAO && rb->ssao.ao[0].is_valid()) {
+ if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SSAO && rb->ssao.ao[0].is_valid()) {
Size2 rtsize = storage->render_target_get_size(rb->render_target);
RID ao_buf = rb->ssao.ao_full.is_valid() ? rb->ssao.ao_full : rb->ssao.ao[0];
effects->copy_to_rect(ao_buf, storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize), false, true);
}
- if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_ROUGHNESS_LIMITER && _render_buffers_get_roughness_texture(p_render_buffers).is_valid()) {
+ if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_ROUGHNESS_LIMITER && _render_buffers_get_roughness_texture(p_render_buffers).is_valid()) {
Size2 rtsize = storage->render_target_get_size(rb->render_target);
effects->copy_to_rect(_render_buffers_get_roughness_texture(p_render_buffers), storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize), false, true);
}
- if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER && _render_buffers_get_normal_texture(p_render_buffers).is_valid()) {
+ if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER && _render_buffers_get_normal_texture(p_render_buffers).is_valid()) {
Size2 rtsize = storage->render_target_get_size(rb->render_target);
effects->copy_to_rect(_render_buffers_get_normal_texture(p_render_buffers), storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize));
}
@@ -3422,7 +3423,7 @@ RID RasterizerSceneRD::render_buffers_get_ao_texture(RID p_render_buffers) {
return rb->ssao.ao_full.is_valid() ? rb->ssao.ao_full : rb->ssao.ao[0];
}
-void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) {
+void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) {
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
rb->width = p_width;
@@ -3512,7 +3513,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
CameraMatrix light_projection;
Transform light_transform;
- if (storage->light_get_type(light_instance->light) == VS::LIGHT_DIRECTIONAL) {
+ if (storage->light_get_type(light_instance->light) == RS::LIGHT_DIRECTIONAL) {
//set pssm stuff
if (light_instance->last_scene_shadow_pass != scene_pass) {
light_instance->directional_rect = _get_directional_shadow_rect(directional_shadow.size, directional_shadow.light_count, directional_shadow.current_light);
@@ -3528,7 +3529,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
atlas_rect.size.width = light_instance->directional_rect.size.x;
atlas_rect.size.height = light_instance->directional_rect.size.y;
- if (storage->light_directional_get_shadow_mode(light_instance->light) == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
+ if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
atlas_rect.size.width /= 2;
atlas_rect.size.height /= 2;
@@ -3542,7 +3543,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
atlas_rect.position.y += atlas_rect.size.height;
}
- } else if (storage->light_directional_get_shadow_mode(light_instance->light) == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
+ } else if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
atlas_rect.size.height /= 2;
@@ -3558,10 +3559,10 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
light_instance->shadow_transform[p_pass].atlas_rect.position /= directional_shadow.size;
light_instance->shadow_transform[p_pass].atlas_rect.size /= directional_shadow.size;
- float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE));
- zfar = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_RANGE);
- bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_BIAS) * bias_mult;
- normal_bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * bias_mult;
+ float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE));
+ zfar = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_RANGE);
+ bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_BIAS) * bias_mult;
+ normal_bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * bias_mult;
ShadowMap *shadow_map = _get_shadow_map(atlas_rect.size);
render_fb = shadow_map->fb;
@@ -3595,13 +3596,13 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
atlas_rect.size.height = shadow_size;
atlas_fb = shadow_atlas->fb;
- zfar = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_RANGE);
- bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_BIAS);
- normal_bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS);
+ zfar = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_RANGE);
+ bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_BIAS);
+ normal_bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS);
- if (storage->light_get_type(light_instance->light) == VS::LIGHT_OMNI) {
+ if (storage->light_get_type(light_instance->light) == RS::LIGHT_OMNI) {
- if (storage->light_omni_get_shadow_mode(light_instance->light) == VS::LIGHT_OMNI_SHADOW_CUBE) {
+ if (storage->light_omni_get_shadow_mode(light_instance->light) == RS::LIGHT_OMNI_SHADOW_CUBE) {
ShadowCubemap *cubemap = _get_shadow_cubemap(shadow_size / 2);
@@ -3629,7 +3630,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
render_texture = shadow_map->depth;
}
- } else if (storage->light_get_type(light_instance->light) == VS::LIGHT_SPOT) {
+ } else if (storage->light_get_type(light_instance->light) == RS::LIGHT_SPOT) {
light_projection = light_instance->shadow_transform[0].camera;
light_transform = light_instance->shadow_transform[0].transform;
@@ -3768,7 +3769,7 @@ bool RasterizerSceneRD::free(RID p_rid) {
return true;
}
-void RasterizerSceneRD::set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {
+void RasterizerSceneRD::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {
debug_draw = p_debug_draw;
}
@@ -3905,10 +3906,12 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
// Initialize sky
Vector<String> sky_modes;
- sky_modes.push_back("\n#define AT_CUBEMAP_PASS false\n#define AT_HALF_RES_PASS false\n#define AT_QUARTER_RES_PASS false\n"); // Full size
- sky_modes.push_back("\n#define AT_CUBEMAP_PASS false\n#define AT_HALF_RES_PASS true\n#define AT_QUARTER_RES_PASS false\n"); // Half Res
- sky_modes.push_back("\n#define AT_CUBEMAP_PASS false\n#define AT_HALF_RES_PASS false\n#define AT_QUARTER_RES_PASS true\n"); // Quarter res
- sky_modes.push_back("\n#define AT_CUBEMAP_PASS true\n#define AT_HALF_RES_PASS false\n#define AT_QUARTER_RES_PASS false\n"); // Cubemap
+ sky_modes.push_back(""); // Full size
+ sky_modes.push_back("\n#define USE_HALF_RES_PASS\n"); // Half Res
+ sky_modes.push_back("\n#define USE_QUARTER_RES_PASS\n"); // Quarter res
+ sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n"); // Cubemap
+ sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n#define USE_HALF_RES_PASS\n"); // Half Res Cubemap
+ sky_modes.push_back("\n#define USE_CUBEMAP_PASS\n#define USE_QUARTER_RES_PASS\n"); // Quarter res Cubemap
sky_shader.shader.initialize(sky_modes, defines);
}
@@ -3926,8 +3929,8 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
actions.renames["SKY_COORDS"] = "panorama_coords";
actions.renames["SCREEN_UV"] = "uv";
actions.renames["TIME"] = "params.time";
- actions.renames["HALF_RES_TEXTURE"] = "half_res";
- actions.renames["QUARTER_RES_TEXTURE"] = "quarter_res";
+ actions.renames["HALF_RES_COLOR"] = "half_res_color";
+ actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color";
actions.renames["RADIANCE"] = "radiance";
actions.renames["LIGHT0_ENABLED"] = "directional_lights.data[0].enabled";
actions.renames["LIGHT0_DIRECTION"] = "directional_lights.data[0].direction";
@@ -3949,8 +3952,8 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
actions.renames["AT_HALF_RES_PASS"] = "AT_HALF_RES_PASS";
actions.renames["AT_QUARTER_RES_PASS"] = "AT_QUARTER_RES_PASS";
actions.custom_samplers["RADIANCE"] = "material_samplers[3]";
- actions.custom_samplers["SUBPASS2"] = "material_samplers[1]";
- actions.custom_samplers["SUBPASS4"] = "material_samplers[1]";
+ actions.usage_defines["HALF_RES_COLOR"] = "\n#define USES_HALF_RES_COLOR\n";
+ actions.usage_defines["QUARTER_RES_COLOR"] = "\n#define USES_QUARTER_RES_COLOR\n";
actions.sampler_array_name = "material_samplers";
actions.base_texture_binding_index = 1;
@@ -3982,27 +3985,27 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
u.binding = 0;
u.ids.resize(12);
RID *ids_ptr = u.ids.ptrw();
- ids_ptr[0] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[1] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[2] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[3] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[4] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[5] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
- ids_ptr[6] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[7] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[8] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[9] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[10] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
- ids_ptr[11] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[0] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[1] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[2] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[3] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[4] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[5] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ ids_ptr[6] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[7] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[8] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[9] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[10] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ ids_ptr[11] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
uniforms.push_back(u);
}
sky_scene_state.sampler_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_SAMPLERS);
}
- camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape"))));
- camera_effects_set_dof_blur_quality(VS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))), GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter"));
- environment_set_ssao_quality(VS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
+ camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape"))));
+ camera_effects_set_dof_blur_quality(RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))), GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter"));
+ environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
screen_space_roughness_limiter = GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter");
screen_space_roughness_limiter_curve = GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve");
}
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
index e779854327..0a1cc8ebd7 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
@@ -32,12 +32,12 @@
#define RASTERIZER_SCENE_RD_H
#include "core/rid_owner.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h"
-#include "servers/visual/rasterizer_rd/shaders/giprobe.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl.gen.h"
-#include "servers/visual/rasterizer_rd/shaders/sky.glsl.gen.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h"
+#include "servers/rendering/rasterizer_rd/shaders/giprobe.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl.gen.h"
+#include "servers/rendering/rasterizer_rd/shaders/sky.glsl.gen.h"
+#include "servers/rendering/rendering_device.h"
class RasterizerSceneRD : public RasterizerScene {
public:
@@ -73,7 +73,7 @@ protected:
struct RenderBufferData {
- virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, VS::ViewportMSAA p_msaa) = 0;
+ virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) = 0;
virtual ~RenderBufferData() {}
};
virtual RenderBufferData *_create_render_buffer_data() = 0;
@@ -98,7 +98,7 @@ protected:
void _draw_sky(bool p_can_continue, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform);
private:
- VS::ViewportDebugDraw debug_draw = VS::VIEWPORT_DEBUG_DRAW_DISABLED;
+ RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED;
double time_step = 0;
static RasterizerSceneRD *singleton;
@@ -149,6 +149,8 @@ private:
SKY_VERSION_HALF_RES,
SKY_VERSION_QUARTER_RES,
SKY_VERSION_CUBEMAP,
+ SKY_VERSION_CUBEMAP_HALF_RES,
+ SKY_VERSION_CUBEMAP_QUARTER_RES,
SKY_VERSION_MAX
};
@@ -222,24 +224,9 @@ private:
SKY_TEXTURE_SET_BACKGROUND,
SKY_TEXTURE_SET_HALF_RES,
SKY_TEXTURE_SET_QUARTER_RES,
- SKY_TEXTURE_SET_CUBEMAP0,
- SKY_TEXTURE_SET_CUBEMAP1,
- SKY_TEXTURE_SET_CUBEMAP2,
- SKY_TEXTURE_SET_CUBEMAP3,
- SKY_TEXTURE_SET_CUBEMAP4,
- SKY_TEXTURE_SET_CUBEMAP5,
- SKY_TEXTURE_SET_CUBEMAP_HALF_RES0,
- SKY_TEXTURE_SET_CUBEMAP_HALF_RES1,
- SKY_TEXTURE_SET_CUBEMAP_HALF_RES2,
- SKY_TEXTURE_SET_CUBEMAP_HALF_RES3,
- SKY_TEXTURE_SET_CUBEMAP_HALF_RES4,
- SKY_TEXTURE_SET_CUBEMAP_HALF_RES5,
- SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES0,
- SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES1,
- SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES2,
- SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES3,
- SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES4,
- SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES5,
+ SKY_TEXTURE_SET_CUBEMAP,
+ SKY_TEXTURE_SET_CUBEMAP_HALF_RES,
+ SKY_TEXTURE_SET_CUBEMAP_QUARTER_RES,
SKY_TEXTURE_SET_MAX
};
@@ -268,7 +255,7 @@ private:
int radiance_size = 256;
- VS::SkyMode mode = VS::SKY_MODE_QUALITY;
+ RS::SkyMode mode = RS::SKY_MODE_QUALITY;
ReflectionData reflection;
bool dirty = false;
@@ -584,7 +571,7 @@ private:
Rect2 atlas_rect;
};
- VS::LightType light_type;
+ RS::LightType light_type;
ShadowTransform shadow_transform[4];
@@ -621,23 +608,23 @@ private:
struct Environent {
// BG
- VS::EnvironmentBG background = VS::ENV_BG_CLEAR_COLOR;
+ RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR;
RID sky;
float sky_custom_fov = 0.0;
Basis sky_orientation;
Color bg_color;
float bg_energy = 1.0;
int canvas_max_layer = 0;
- VS::EnvironmentAmbientSource ambient_source = VS::ENV_AMBIENT_SOURCE_BG;
+ RS::EnvironmentAmbientSource ambient_source = RS::ENV_AMBIENT_SOURCE_BG;
Color ambient_light;
float ambient_light_energy = 1.0;
float ambient_sky_contribution = 1.0;
- VS::EnvironmentReflectionSource reflection_source = VS::ENV_REFLECTION_SOURCE_BG;
+ RS::EnvironmentReflectionSource reflection_source = RS::ENV_REFLECTION_SOURCE_BG;
Color ao_color;
/// Tonemap
- VS::EnvironmentToneMapper tone_mapper;
+ RS::EnvironmentToneMapper tone_mapper;
float exposure = 1.0;
float white = 1.0;
bool auto_exposure = false;
@@ -655,7 +642,7 @@ private:
float glow_strength = 1.0;
float glow_bloom = 0.0;
float glow_mix = 0.01;
- VS::EnvironmentGlowBlendMode glow_blend_mode = VS::ENV_GLOW_BLEND_MODE_SOFTLIGHT;
+ RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT;
float glow_hdr_bleed_threshold = 1.0;
float glow_hdr_luminance_cap = 12.0;
float glow_hdr_bleed_scale = 2.0;
@@ -670,10 +657,10 @@ private:
float ssao_direct_light_affect = 0.0;
float ssao_ao_channel_affect = 0.0;
float ssao_blur_edge_sharpness = 4.0;
- VS::EnvironmentSSAOBlur ssao_blur = VS::ENV_SSAO_BLUR_3x3;
+ RS::EnvironmentSSAOBlur ssao_blur = RS::ENV_SSAO_BLUR_3x3;
};
- VS::EnvironmentSSAOQuality ssao_quality = VS::ENV_SSAO_QUALITY_MEDIUM;
+ RS::EnvironmentSSAOQuality ssao_quality = RS::ENV_SSAO_QUALITY_MEDIUM;
bool ssao_half_size = false;
static uint64_t auto_exposure_counter;
@@ -698,8 +685,8 @@ private:
float override_exposure = 1;
};
- VS::DOFBlurQuality dof_blur_quality = VS::DOF_BLUR_QUALITY_MEDIUM;
- VS::DOFBokehShape dof_blur_bokeh_shape = VS::DOF_BOKEH_HEXAGON;
+ RS::DOFBlurQuality dof_blur_quality = RS::DOF_BLUR_QUALITY_MEDIUM;
+ RS::DOFBokehShape dof_blur_bokeh_shape = RS::DOF_BOKEH_HEXAGON;
bool dof_blur_use_jitter = false;
mutable RID_Owner<CameraEffects> camera_effects_owner;
@@ -710,7 +697,7 @@ private:
RenderBufferData *data = nullptr;
int width = 0, height = 0;
- VS::ViewportMSAA msaa = VS::VIEWPORT_MSAA_DISABLED;
+ RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED;
RID render_target;
uint64_t auto_exposure_version = 1;
@@ -804,7 +791,7 @@ public:
RID sky_create();
void sky_set_radiance_size(RID p_sky, int p_radiance_size);
- void sky_set_mode(RID p_sky, VS::SkyMode p_mode);
+ void sky_set_mode(RID p_sky, RS::SkyMode p_mode);
void sky_set_material(RID p_sky, RID p_material);
RID sky_get_radiance_texture_rd(RID p_sky) const;
@@ -815,16 +802,16 @@ public:
RID environment_create();
- void environment_set_background(RID p_env, VS::EnvironmentBG p_bg);
+ void environment_set_background(RID p_env, RS::EnvironmentBG p_bg);
void environment_set_sky(RID p_env, RID p_sky);
void environment_set_sky_custom_fov(RID p_env, float p_scale);
void environment_set_sky_orientation(RID p_env, const Basis &p_orientation);
void environment_set_bg_color(RID p_env, const Color &p_color);
void environment_set_bg_energy(RID p_env, float p_energy);
void environment_set_canvas_max_layer(RID p_env, int p_max_layer);
- void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color());
+ void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color());
- VS::EnvironmentBG environment_get_background(RID p_env) const;
+ RS::EnvironmentBG environment_get_background(RID p_env) const;
RID environment_get_sky(RID p_env) const;
float environment_get_sky_custom_fov(RID p_env) const;
Basis environment_get_sky_orientation(RID p_env) const;
@@ -832,27 +819,27 @@ public:
float environment_get_bg_energy(RID p_env) const;
int environment_get_canvas_max_layer(RID p_env) const;
Color environment_get_ambient_light_color(RID p_env) const;
- VS::EnvironmentAmbientSource environment_get_ambient_light_ambient_source(RID p_env) const;
+ RS::EnvironmentAmbientSource environment_get_ambient_light_ambient_source(RID p_env) const;
float environment_get_ambient_light_ambient_energy(RID p_env) const;
float environment_get_ambient_sky_contribution(RID p_env) const;
- VS::EnvironmentReflectionSource environment_get_reflection_source(RID p_env) const;
+ RS::EnvironmentReflectionSource environment_get_reflection_source(RID p_env) const;
Color environment_get_ao_color(RID p_env) const;
bool is_environment(RID p_env) const;
- void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale);
+ void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale);
void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {}
void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {}
- void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness);
- void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size);
+ void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness);
+ void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size);
bool environment_is_ssao_enabled(RID p_env) const;
float environment_get_ssao_ao_affect(RID p_env) const;
float environment_get_ssao_light_affect(RID p_env) const;
bool environment_is_ssr_enabled(RID p_env) const;
- void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale);
+ void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale);
void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {}
void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {}
@@ -861,8 +848,8 @@ public:
virtual RID camera_effects_create();
- virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter);
- virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape);
+ virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter);
+ virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape);
virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount);
virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure);
@@ -953,7 +940,7 @@ public:
return li->light_index;
}
- _FORCE_INLINE_ VS::LightType light_instance_get_type(RID p_light_instance) {
+ _FORCE_INLINE_ RS::LightType light_instance_get_type(RID p_light_instance) {
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->light_type;
}
@@ -1085,7 +1072,7 @@ public:
GIProbeQuality gi_probe_get_quality() const;
RID render_buffers_create();
- void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa);
+ void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa);
RID render_buffers_get_ao_texture(RID p_render_buffers);
RID render_buffers_get_back_buffer_texture(RID p_render_buffers);
@@ -1110,8 +1097,8 @@ public:
virtual void update();
- virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw);
- _FORCE_INLINE_ VS::ViewportDebugDraw get_debug_draw_mode() const { return debug_draw; }
+ virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw);
+ _FORCE_INLINE_ RS::ViewportDebugDraw get_debug_draw_mode() const { return debug_draw; }
virtual void set_time(double p_time, double p_step);
diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp
index 6e7f0aac07..83af15602c 100644
--- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp
@@ -31,7 +31,7 @@
#include "rasterizer_storage_rd.h"
#include "core/engine.h"
#include "core/project_settings.h"
-#include "servers/visual/shader_language.h"
+#include "servers/rendering/shader_language.h"
Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format) {
@@ -608,7 +608,7 @@ RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) {
return texture_owner.make_rid(texture);
}
-RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) {
+RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) {
return RID();
}
@@ -826,25 +826,25 @@ String RasterizerStorageRD::texture_get_path(RID p_texture) const {
return String();
}
-void RasterizerStorageRD::texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {
+void RasterizerStorageRD::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_3d_callback_ud = p_userdata;
tex->detect_3d_callback = p_callback;
}
-void RasterizerStorageRD::texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {
+void RasterizerStorageRD::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_normal_callback_ud = p_userdata;
tex->detect_normal_callback = p_callback;
}
-void RasterizerStorageRD::texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
+void RasterizerStorageRD::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_roughness_callback_ud = p_userdata;
tex->detect_roughness_callback = p_callback;
}
-void RasterizerStorageRD::texture_debug_usage(List<VS::TextureInfo> *r_info) {
+void RasterizerStorageRD::texture_debug_usage(List<RS::TextureInfo> *r_info) {
}
void RasterizerStorageRD::texture_set_proxy(RID p_proxy, RID p_base) {
@@ -1664,7 +1664,7 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
RasterizerStorageRD *singleton = (RasterizerStorageRD *)RasterizerStorage::base_singleton;
#ifdef TOOLS_ENABLED
Texture *roughness_detect_texture = nullptr;
- VS::TextureDetectRoughnessChannel roughness_channel;
+ RS::TextureDetectRoughnessChannel roughness_channel;
Texture *normal_detect_texture = nullptr;
#endif
@@ -1727,7 +1727,7 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
if (tex->detect_roughness_callback && (p_texture_uniforms[i].hint >= ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R || p_texture_uniforms[i].hint <= ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_GRAY)) {
//find the normal texture
roughness_detect_texture = tex;
- roughness_channel = VS::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R);
+ roughness_channel = RS::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R);
}
#endif
@@ -1782,7 +1782,7 @@ RID RasterizerStorageRD::mesh_create() {
}
/// Returns stride
-void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) {
+void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -1797,67 +1797,67 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_
uint32_t stride = 0;
- for (int i = 0; i < VS::ARRAY_WEIGHTS; i++) {
+ for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) {
if ((p_surface.format & (1 << i))) {
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
- if (p_surface.format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (p_surface.format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
stride += sizeof(float) * 2;
} else {
stride += sizeof(float) * 3;
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
- if (p_surface.format & VS::ARRAY_COMPRESS_NORMAL) {
+ if (p_surface.format & RS::ARRAY_COMPRESS_NORMAL) {
stride += sizeof(int8_t) * 4;
} else {
stride += sizeof(float) * 4;
}
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
- if (p_surface.format & VS::ARRAY_COMPRESS_TANGENT) {
+ if (p_surface.format & RS::ARRAY_COMPRESS_TANGENT) {
stride += sizeof(int8_t) * 4;
} else {
stride += sizeof(float) * 4;
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
- if (p_surface.format & VS::ARRAY_COMPRESS_COLOR) {
+ if (p_surface.format & RS::ARRAY_COMPRESS_COLOR) {
stride += sizeof(int8_t) * 4;
} else {
stride += sizeof(float) * 4;
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
- if (p_surface.format & VS::ARRAY_COMPRESS_TEX_UV) {
+ if (p_surface.format & RS::ARRAY_COMPRESS_TEX_UV) {
stride += sizeof(int16_t) * 2;
} else {
stride += sizeof(float) * 2;
}
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
- if (p_surface.format & VS::ARRAY_COMPRESS_TEX_UV2) {
+ if (p_surface.format & RS::ARRAY_COMPRESS_TEX_UV2) {
stride += sizeof(int16_t) * 2;
} else {
stride += sizeof(float) * 2;
}
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
//assumed weights too
//unique format, internally 16 bits, exposed as single array for 32
@@ -1945,16 +1945,16 @@ int RasterizerStorageRD::mesh_get_blend_shape_count(RID p_mesh) const {
return mesh->blend_shape_count;
}
-void RasterizerStorageRD::mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) {
+void RasterizerStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX((int)p_mode, 2);
mesh->blend_shape_mode = p_mode;
}
-VS::BlendShapeMode RasterizerStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const {
+RS::BlendShapeMode RasterizerStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const {
Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, VS::BLEND_SHAPE_MODE_NORMALIZED);
+ ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
return mesh->blend_shape_mode;
}
@@ -1986,15 +1986,15 @@ RID RasterizerStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) co
return mesh->surfaces[p_surface]->material;
}
-VS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const {
+RS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const {
Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, VS::SurfaceData());
- ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, VS::SurfaceData());
+ ERR_FAIL_COND_V(!mesh, RS::SurfaceData());
+ ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData());
Mesh::Surface &s = *mesh->surfaces[p_surface];
- VS::SurfaceData sd;
+ RS::SurfaceData sd;
sd.format = s.format;
sd.vertex_data = RD::get_singleton()->buffer_get_data(s.vertex_buffer);
sd.vertex_count = s.vertex_count;
@@ -2006,7 +2006,7 @@ VS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface)
}
sd.aabb = s.aabb;
for (uint32_t i = 0; i < s.lod_count; i++) {
- VS::SurfaceData::LOD lod;
+ RS::SurfaceData::LOD lod;
lod.edge_length = s.lods[i].edge_length;
lod.index_data = RD::get_singleton()->buffer_get_data(s.lods[i].index_buffer);
sd.lods.push_back(lod);
@@ -2058,7 +2058,7 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
for (uint32_t i = 0; i < mesh->surface_count; i++) {
AABB laabb;
- if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->bone_aabbs.size()) {
+ if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->bone_aabbs.size()) {
int bs = mesh->surfaces[i]->bone_aabbs.size();
const AABB *skbones = mesh->surfaces[i]->bone_aabbs.ptr();
@@ -2201,7 +2201,7 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
uint32_t stride = 0;
- for (int i = 0; i < VS::ARRAY_WEIGHTS; i++) {
+ for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) {
RD::VertexDescription vd;
RID buffer;
@@ -2212,33 +2212,33 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
buffer = mesh_default_rd_buffers[i];
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT;
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT;
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
//assumed weights too
vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT;
@@ -2253,9 +2253,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
- if (s->format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (s->format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
stride += sizeof(float) * 2;
} else {
@@ -2264,9 +2264,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
- if (s->format & VS::ARRAY_COMPRESS_NORMAL) {
+ if (s->format & RS::ARRAY_COMPRESS_NORMAL) {
vd.format = RD::DATA_FORMAT_R8G8B8A8_SNORM;
stride += sizeof(int8_t) * 4;
} else {
@@ -2275,9 +2275,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
}
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
- if (s->format & VS::ARRAY_COMPRESS_TANGENT) {
+ if (s->format & RS::ARRAY_COMPRESS_TANGENT) {
vd.format = RD::DATA_FORMAT_R8G8B8A8_SNORM;
stride += sizeof(int8_t) * 4;
} else {
@@ -2286,9 +2286,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
- if (s->format & VS::ARRAY_COMPRESS_COLOR) {
+ if (s->format & RS::ARRAY_COMPRESS_COLOR) {
vd.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
stride += sizeof(int8_t) * 4;
} else {
@@ -2297,9 +2297,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
- if (s->format & VS::ARRAY_COMPRESS_TEX_UV) {
+ if (s->format & RS::ARRAY_COMPRESS_TEX_UV) {
vd.format = RD::DATA_FORMAT_R16G16_SFLOAT;
stride += sizeof(int16_t) * 2;
} else {
@@ -2308,9 +2308,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
}
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
- if (s->format & VS::ARRAY_COMPRESS_TEX_UV2) {
+ if (s->format & RS::ARRAY_COMPRESS_TEX_UV2) {
vd.format = RD::DATA_FORMAT_R16G16_SFLOAT;
stride += sizeof(int16_t) * 2;
} else {
@@ -2319,7 +2319,7 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
}
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
//assumed weights too
//unique format, internally 16 bits, exposed as single array for 32
@@ -2358,7 +2358,7 @@ RID RasterizerStorageRD::multimesh_create() {
return multimesh_owner.make_rid(MultiMesh());
}
-void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
+void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
@@ -2382,13 +2382,13 @@ void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, V
multimesh->instances = p_instances;
multimesh->xform_format = p_transform_format;
multimesh->uses_colors = p_use_colors;
- multimesh->color_offset_cache = p_transform_format == VS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
+ multimesh->color_offset_cache = p_transform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
multimesh->uses_custom_data = p_use_custom_data;
multimesh->custom_data_offset_cache = multimesh->color_offset_cache + (p_use_colors ? 4 : 0);
multimesh->stride_cache = multimesh->custom_data_offset_cache + (p_use_custom_data ? 4 : 0);
multimesh->buffer_set = false;
- //print_line("allocate, elements: " + itos(p_instances) + " 2D: " + itos(p_transform_format == VS::MULTIMESH_TRANSFORM_2D) + " colors " + itos(multimesh->uses_colors) + " data " + itos(multimesh->uses_custom_data) + " stride " + itos(multimesh->stride_cache) + " total size " + itos(multimesh->stride_cache * multimesh->instances));
+ //print_line("allocate, elements: " + itos(p_instances) + " 2D: " + itos(p_transform_format == RS::MULTIMESH_TRANSFORM_2D) + " colors " + itos(multimesh->uses_colors) + " data " + itos(multimesh->uses_custom_data) + " stride " + itos(multimesh->stride_cache) + " total size " + itos(multimesh->stride_cache * multimesh->instances));
multimesh->data_cache = Vector<float>();
multimesh->aabb = AABB();
multimesh->aabb_dirty = false;
@@ -2521,7 +2521,7 @@ void RasterizerStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const
const float *data = p_data + multimesh->stride_cache * i;
Transform t;
- if (multimesh->xform_format == VS::MULTIMESH_TRANSFORM_3D) {
+ if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
t.basis.elements[0][0] = data[0];
t.basis.elements[0][1] = data[1];
@@ -2562,7 +2562,7 @@ void RasterizerStorageRD::multimesh_instance_set_transform(RID p_multimesh, int
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
- ERR_FAIL_COND(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_3D);
+ ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D);
_multimesh_make_local(multimesh);
@@ -2593,7 +2593,7 @@ void RasterizerStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, i
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
- ERR_FAIL_COND(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_2D);
+ ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D);
_multimesh_make_local(multimesh);
@@ -2671,7 +2671,7 @@ Transform RasterizerStorageRD::multimesh_instance_get_transform(RID p_multimesh,
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform());
- ERR_FAIL_COND_V(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_3D, Transform());
+ ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D, Transform());
_multimesh_make_local(multimesh);
@@ -2702,7 +2702,7 @@ Transform2D RasterizerStorageRD::multimesh_instance_get_transform_2d(RID p_multi
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform2D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
- ERR_FAIL_COND_V(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_2D, Transform2D());
+ ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D, Transform2D());
_multimesh_make_local(multimesh);
@@ -3094,24 +3094,24 @@ void RasterizerStorageRD::_update_dirty_skeletons() {
/* LIGHT */
-RID RasterizerStorageRD::light_create(VS::LightType p_type) {
+RID RasterizerStorageRD::light_create(RS::LightType p_type) {
Light light;
light.type = p_type;
- light.param[VS::LIGHT_PARAM_ENERGY] = 1.0;
- light.param[VS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
- light.param[VS::LIGHT_PARAM_SPECULAR] = 0.5;
- light.param[VS::LIGHT_PARAM_RANGE] = 1.0;
- light.param[VS::LIGHT_PARAM_SPOT_ANGLE] = 45;
- light.param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45;
- light.param[VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
- light.param[VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
- light.param[VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
- light.param[VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
- light.param[VS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8;
- light.param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1;
- light.param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1;
+ light.param[RS::LIGHT_PARAM_ENERGY] = 1.0;
+ light.param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0;
+ light.param[RS::LIGHT_PARAM_SPECULAR] = 0.5;
+ light.param[RS::LIGHT_PARAM_RANGE] = 1.0;
+ light.param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45;
+ light.param[RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45;
+ light.param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0;
+ light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1;
+ light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3;
+ light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6;
+ light.param[RS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8;
+ light.param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1;
+ light.param[RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1;
return light_owner.make_rid(light);
}
@@ -3123,21 +3123,21 @@ void RasterizerStorageRD::light_set_color(RID p_light, const Color &p_color) {
light->color = p_color;
}
-void RasterizerStorageRD::light_set_param(RID p_light, VS::LightParam p_param, float p_value) {
+void RasterizerStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
- ERR_FAIL_INDEX(p_param, VS::LIGHT_PARAM_MAX);
+ ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
switch (p_param) {
- case VS::LIGHT_PARAM_RANGE:
- case VS::LIGHT_PARAM_SPOT_ANGLE:
- case VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
- case VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
- case VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
- case VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
- case VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
- case VS::LIGHT_PARAM_SHADOW_BIAS: {
+ case RS::LIGHT_PARAM_RANGE:
+ case RS::LIGHT_PARAM_SPOT_ANGLE:
+ case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE:
+ case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET:
+ case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET:
+ case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET:
+ case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
+ case RS::LIGHT_PARAM_SHADOW_BIAS: {
light->version++;
light->instance_dependency.instance_notify_changed(true, false);
@@ -3211,7 +3211,7 @@ void RasterizerStorageRD::light_set_use_gi(RID p_light, bool p_enabled) {
light->version++;
light->instance_dependency.instance_notify_changed(true, false);
}
-void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {
+void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3222,15 +3222,15 @@ void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, VS::LightOmniS
light->instance_dependency.instance_notify_changed(true, false);
}
-VS::LightOmniShadowMode RasterizerStorageRD::light_omni_get_shadow_mode(RID p_light) {
+RS::LightOmniShadowMode RasterizerStorageRD::light_omni_get_shadow_mode(RID p_light) {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI_SHADOW_CUBE);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
return light->omni_shadow_mode;
}
-void RasterizerStorageRD::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {
+void RasterizerStorageRD::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3258,15 +3258,15 @@ bool RasterizerStorageRD::light_directional_get_blend_splits(RID p_light) const
return light->directional_blend_splits;
}
-VS::LightDirectionalShadowMode RasterizerStorageRD::light_directional_get_shadow_mode(RID p_light) {
+RS::LightDirectionalShadowMode RasterizerStorageRD::light_directional_get_shadow_mode(RID p_light) {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
return light->directional_shadow_mode;
}
-void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {
+void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3274,10 +3274,10 @@ void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_li
light->directional_range_mode = p_range_mode;
}
-VS::LightDirectionalShadowDepthRangeMode RasterizerStorageRD::light_directional_get_shadow_depth_range_mode(RID p_light) const {
+RS::LightDirectionalShadowDepthRangeMode RasterizerStorageRD::light_directional_get_shadow_depth_range_mode(RID p_light) const {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
return light->directional_range_mode;
}
@@ -3304,18 +3304,18 @@ AABB RasterizerStorageRD::light_get_aabb(RID p_light) const {
switch (light->type) {
- case VS::LIGHT_SPOT: {
+ case RS::LIGHT_SPOT: {
- float len = light->param[VS::LIGHT_PARAM_RANGE];
- float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len;
+ float len = light->param[RS::LIGHT_PARAM_RANGE];
+ float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
};
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_OMNI: {
- float r = light->param[VS::LIGHT_PARAM_RANGE];
+ float r = light->param[RS::LIGHT_PARAM_RANGE];
return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
};
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
return AABB();
};
@@ -3331,7 +3331,7 @@ RID RasterizerStorageRD::reflection_probe_create() {
return reflection_probe_owner.make_rid(ReflectionProbe());
}
-void RasterizerStorageRD::reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) {
+void RasterizerStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3450,10 +3450,10 @@ AABB RasterizerStorageRD::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
-VS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
+RS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
- ERR_FAIL_COND_V(!reflection_probe, VS::REFLECTION_PROBE_UPDATE_ALWAYS);
+ ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
return reflection_probe->update_mode;
}
@@ -4266,25 +4266,25 @@ void RasterizerStorageRD::skeleton_update_dependency(RID p_skeleton, RasterizerS
p_instance->update_dependency(&skeleton->instance_dependency);
}
-VS::InstanceType RasterizerStorageRD::get_base_type(RID p_rid) const {
+RS::InstanceType RasterizerStorageRD::get_base_type(RID p_rid) const {
if (mesh_owner.owns(p_rid)) {
- return VS::INSTANCE_MESH;
+ return RS::INSTANCE_MESH;
}
if (multimesh_owner.owns(p_rid)) {
- return VS::INSTANCE_MULTIMESH;
+ return RS::INSTANCE_MULTIMESH;
}
if (reflection_probe_owner.owns(p_rid)) {
- return VS::INSTANCE_REFLECTION_PROBE;
+ return RS::INSTANCE_REFLECTION_PROBE;
}
if (gi_probe_owner.owns(p_rid)) {
- return VS::INSTANCE_GI_PROBE;
+ return RS::INSTANCE_GI_PROBE;
}
if (light_owner.owns(p_rid)) {
- return VS::INSTANCE_LIGHT;
+ return RS::INSTANCE_LIGHT;
}
- return VS::INSTANCE_NONE;
+ return RS::INSTANCE_NONE;
}
void RasterizerStorageRD::update_dirty_resources() {
_update_queued_materials();
@@ -4374,7 +4374,7 @@ bool RasterizerStorageRD::free(RID p_rid) {
mesh_owner.free(p_rid);
} else if (multimesh_owner.owns(p_rid)) {
_update_dirty_multimeshes();
- multimesh_allocate(p_rid, 0, VS::MULTIMESH_TRANSFORM_2D);
+ multimesh_allocate(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
multimesh->instance_dependency.instance_notify_deleted(p_rid);
multimesh_owner.free(p_rid);
@@ -4612,40 +4612,40 @@ RasterizerStorageRD::RasterizerStorageRD() {
}
//default samplers
- for (int i = 1; i < VS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) {
- for (int j = 1; j < VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) {
+ for (int i = 1; i < RS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) {
+ for (int j = 1; j < RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) {
RD::SamplerState sampler_state;
switch (i) {
- case VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: {
+ case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: {
sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST;
sampler_state.min_filter = RD::SAMPLER_FILTER_NEAREST;
sampler_state.max_lod = 0;
} break;
- case VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: {
+ case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: {
sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.max_lod = 0;
} break;
- case VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: {
+ case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: {
sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST;
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR;
} break;
- case VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: {
+ case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: {
sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR;
} break;
- case VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: {
+ case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: {
sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST;
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.use_anisotropy = true;
sampler_state.anisotropy_max = GLOBAL_GET("rendering/quality/filters/max_anisotropy");
} break;
- case VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: {
+ case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: {
sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR;
@@ -4657,17 +4657,17 @@ RasterizerStorageRD::RasterizerStorageRD() {
}
}
switch (j) {
- case VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: {
+ case RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: {
sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
} break;
- case VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: {
+ case RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: {
sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_REPEAT;
sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_REPEAT;
} break;
- case VS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: {
+ case RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: {
sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_MIRRORED_REPEAT;
sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_MIRRORED_REPEAT;
} break;
@@ -4808,8 +4808,8 @@ RasterizerStorageRD::~RasterizerStorageRD() {
}
//def samplers
- for (int i = 1; i < VS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) {
- for (int j = 1; j < VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) {
+ for (int i = 1; i < RS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) {
+ for (int j = 1; j < RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) {
RD::get_singleton()->free(default_rd_samplers[i][j]);
}
}
diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h
index 410cd4adb4..e69be644d7 100644
--- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h
@@ -32,11 +32,11 @@
#define RASTERIZER_STORAGE_RD_H
#include "core/rid_owner.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual/rasterizer_rd/rasterizer_effects_rd.h"
-#include "servers/visual/rasterizer_rd/shader_compiler_rd.h"
-#include "servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl.gen.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering/rasterizer_rd/rasterizer_effects_rd.h"
+#include "servers/rendering/rasterizer_rd/shader_compiler_rd.h"
+#include "servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl.gen.h"
+#include "servers/rendering/rendering_device.h"
class RasterizerStorageRD : public RasterizerStorage {
public:
@@ -138,13 +138,13 @@ private:
RID proxy_to;
Vector<RID> proxies;
- VS::TextureDetectCallback detect_3d_callback = nullptr;
+ RS::TextureDetectCallback detect_3d_callback = nullptr;
void *detect_3d_callback_ud = nullptr;
- VS::TextureDetectCallback detect_normal_callback = nullptr;
+ RS::TextureDetectCallback detect_normal_callback = nullptr;
void *detect_normal_callback_ud = nullptr;
- VS::TextureDetectRoughnessCallback detect_roughness_callback = nullptr;
+ RS::TextureDetectRoughnessCallback detect_roughness_callback = nullptr;
void *detect_roughness_callback_ud = nullptr;
};
@@ -171,7 +171,7 @@ private:
Ref<Image> _validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format);
RID default_rd_textures[DEFAULT_RD_TEXTURE_MAX];
- RID default_rd_samplers[VS::CANVAS_ITEM_TEXTURE_FILTER_MAX][VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
+ RID default_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
/* SHADER */
@@ -218,7 +218,7 @@ private:
struct Mesh {
struct Surface {
- VS::PrimitiveType primitive;
+ RS::PrimitiveType primitive;
uint32_t format = 0;
RID vertex_buffer;
@@ -271,7 +271,7 @@ private:
};
uint32_t blend_shape_count = 0;
- VS::BlendShapeMode blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED;
+ RS::BlendShapeMode blend_shape_mode = RS::BLEND_SHAPE_MODE_NORMALIZED;
Surface **surfaces = nullptr;
uint32_t surface_count = 0;
@@ -296,7 +296,7 @@ private:
struct MultiMesh {
RID mesh;
int instances = 0;
- VS::MultimeshTransformFormat xform_format = VS::MULTIMESH_TRANSFORM_3D;
+ RS::MultimeshTransformFormat xform_format = RS::MULTIMESH_TRANSFORM_3D;
bool uses_colors = false;
bool uses_custom_data = false;
int visible_instances = -1;
@@ -359,8 +359,8 @@ private:
struct Light {
- VS::LightType type;
- float param[VS::LIGHT_PARAM_MAX];
+ RS::LightType type;
+ float param[RS::LIGHT_PARAM_MAX];
Color color = Color(1, 1, 1, 1);
Color shadow_color;
RID projector;
@@ -369,9 +369,9 @@ private:
bool reverse_cull = false;
bool use_gi = true;
uint32_t cull_mask = 0xFFFFFFFF;
- VS::LightOmniShadowMode omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
- VS::LightDirectionalShadowMode directional_shadow_mode = VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL;
- VS::LightDirectionalShadowDepthRangeMode directional_range_mode = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE;
+ RS::LightOmniShadowMode omni_shadow_mode = RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
+ RS::LightDirectionalShadowMode directional_shadow_mode = RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL;
+ RS::LightDirectionalShadowDepthRangeMode directional_range_mode = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE;
bool directional_blend_splits = false;
uint64_t version = 0;
@@ -384,7 +384,7 @@ private:
struct ReflectionProbe {
- VS::ReflectionProbeUpdateMode update_mode = VS::REFLECTION_PROBE_UPDATE_ONCE;
+ RS::ReflectionProbeUpdateMode update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE;
int resolution = 256;
float intensity = 1.0;
Color interior_ambient;
@@ -498,7 +498,7 @@ public:
/* TEXTURE API */
virtual RID texture_2d_create(const Ref<Image> &p_image);
- virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type);
+ virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type);
virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices); //all slices, then all the mipmaps, must be coherent
virtual RID texture_proxy_create(RID p_base);
@@ -524,11 +524,11 @@ public:
virtual void texture_set_path(RID p_texture, const String &p_path);
virtual String texture_get_path(RID p_texture) const;
- virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata);
- virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata);
- virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata);
+ virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata);
+ virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata);
+ virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata);
- virtual void texture_debug_usage(List<VS::TextureInfo> *r_info);
+ virtual void texture_debug_usage(List<RS::TextureInfo> *r_info);
virtual void texture_set_proxy(RID p_proxy, RID p_base);
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable);
@@ -564,7 +564,7 @@ public:
_FORCE_INLINE_ RID texture_rd_get_default(DefaultRDTexture p_texture) {
return default_rd_textures[p_texture];
}
- _FORCE_INLINE_ RID sampler_rd_get_default(VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat) {
+ _FORCE_INLINE_ RID sampler_rd_get_default(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) {
return default_rd_samplers[p_filter][p_repeat];
}
@@ -615,19 +615,19 @@ public:
virtual RID mesh_create();
/// Return stride
- virtual void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface);
+ virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface);
virtual int mesh_get_blend_shape_count(RID p_mesh) const;
- virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode);
- virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
+ virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode);
+ virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data);
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material);
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const;
- virtual VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const;
+ virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const;
virtual int mesh_get_surface_count(RID p_mesh) const;
@@ -655,10 +655,10 @@ public:
return mesh->material_cache.ptr();
}
- _FORCE_INLINE_ VS::PrimitiveType mesh_surface_get_primitive(RID p_mesh, uint32_t p_surface_index) {
+ _FORCE_INLINE_ RS::PrimitiveType mesh_surface_get_primitive(RID p_mesh, uint32_t p_surface_index) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_MAX);
- ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, VS::PRIMITIVE_MAX);
+ ERR_FAIL_COND_V(!mesh, RS::PRIMITIVE_MAX);
+ ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, RS::PRIMITIVE_MAX);
return mesh->surfaces[p_surface_index]->primitive;
}
@@ -732,7 +732,7 @@ public:
RID multimesh_create();
- void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false);
+ void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false);
int multimesh_get_instance_count(RID p_multimesh) const;
void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
@@ -756,7 +756,7 @@ public:
AABB multimesh_get_aabb(RID p_multimesh) const;
- _FORCE_INLINE_ VS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
+ _FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
return multimesh->xform_format;
}
@@ -797,7 +797,7 @@ public:
/* IMMEDIATE API */
RID immediate_create() { return RID(); }
- void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
+ void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {}
void immediate_normal(RID p_immediate, const Vector3 &p_normal) {}
void immediate_tangent(RID p_immediate, const Plane &p_tangent) {}
@@ -843,14 +843,14 @@ public:
}
/* Light API */
- RID light_create(VS::LightType p_type);
+ RID light_create(RS::LightType p_type);
- RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); }
- RID omni_light_create() { return light_create(VS::LIGHT_OMNI); }
- RID spot_light_create() { return light_create(VS::LIGHT_SPOT); }
+ RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); }
+ RID omni_light_create() { return light_create(RS::LIGHT_OMNI); }
+ RID spot_light_create() { return light_create(RS::LIGHT_SPOT); }
void light_set_color(RID p_light, const Color &p_color);
- void light_set_param(RID p_light, VS::LightParam p_param, float p_value);
+ void light_set_param(RID p_light, RS::LightParam p_param, float p_value);
void light_set_shadow(RID p_light, bool p_enabled);
void light_set_shadow_color(RID p_light, const Color &p_color);
void light_set_projector(RID p_light, RID p_texture);
@@ -859,26 +859,26 @@ public:
void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled);
void light_set_use_gi(RID p_light, bool p_enabled);
- void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode);
+ void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode);
- void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode);
+ void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode);
void light_directional_set_blend_splits(RID p_light, bool p_enable);
bool light_directional_get_blend_splits(RID p_light) const;
- void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode);
- VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const;
+ void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode);
+ RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const;
- VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light);
- VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
+ RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light);
+ RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
- _FORCE_INLINE_ VS::LightType light_get_type(RID p_light) const {
+ _FORCE_INLINE_ RS::LightType light_get_type(RID p_light) const {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->type;
}
AABB light_get_aabb(RID p_light) const;
- _FORCE_INLINE_ float light_get_param(RID p_light, VS::LightParam p_param) {
+ _FORCE_INLINE_ float light_get_param(RID p_light, RS::LightParam p_param) {
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, 0);
@@ -913,7 +913,7 @@ public:
_FORCE_INLINE_ bool light_has_shadow(RID p_light) const {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->shadow;
}
@@ -921,7 +921,7 @@ public:
_FORCE_INLINE_ bool light_is_negative(RID p_light) const {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL);
+ ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->negative;
}
@@ -933,7 +933,7 @@ public:
RID reflection_probe_create();
- void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode);
+ void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode);
void reflection_probe_set_intensity(RID p_probe, float p_intensity);
void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient);
void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy);
@@ -948,7 +948,7 @@ public:
void reflection_probe_set_resolution(RID p_probe, int p_resolution);
AABB reflection_probe_get_aabb(RID p_probe) const;
- VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
+ RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
uint32_t reflection_probe_get_cull_mask(RID p_probe) const;
Vector3 reflection_probe_get_extents(RID p_probe) const;
Vector3 reflection_probe_get_origin_offset(RID p_probe) const;
@@ -1059,7 +1059,7 @@ public:
void particles_set_fractional_delta(RID p_particles, bool p_enable) {}
void particles_restart(RID p_particles) {}
- void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {}
+ void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {}
void particles_set_draw_passes(RID p_particles, int p_count) {}
void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {}
@@ -1098,7 +1098,7 @@ public:
Size2 render_target_get_size(RID p_render_target);
RID render_target_get_rd_framebuffer(RID p_render_target);
- VS::InstanceType get_base_type(RID p_rid) const;
+ RS::InstanceType get_base_type(RID p_rid) const;
bool free(RID p_rid);
@@ -1110,9 +1110,9 @@ public:
void render_info_begin_capture() {}
void render_info_end_capture() {}
- int get_captured_render_info(VS::RenderInfo p_info) { return 0; }
+ int get_captured_render_info(RS::RenderInfo p_info) { return 0; }
- int get_render_info(VS::RenderInfo p_info) { return 0; }
+ int get_render_info(RS::RenderInfo p_info) { return 0; }
String get_video_adapter_name() const { return String(); }
String get_video_adapter_vendor() const { return String(); }
diff --git a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp
index 4ee020aa69..4ee020aa69 100644
--- a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp
+++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp
diff --git a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h
index 05c5968360..ecb1b42b06 100644
--- a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h
+++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h
@@ -32,7 +32,7 @@
#define RENDER_PIPELINE_CACHE_RD_H
#include "core/spin_lock.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rendering_device.h"
class RenderPipelineVertexFormatCacheRD {
diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
index ecff8d81f6..b3a4b0ede8 100644
--- a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp
+++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
@@ -1037,7 +1037,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
return code;
}
-Error ShaderCompilerRD::compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
+Error ShaderCompilerRD::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types());
@@ -1099,145 +1099,145 @@ ShaderCompilerRD::ShaderCompilerRD() {
/** SPATIAL SHADER **/
- actions[VS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
- actions[VS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
- actions[VS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
- actions[VS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
- actions[VS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "inv_projection_matrix";
- actions[VS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
-
- actions[VS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
- actions[VS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
- actions[VS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
- actions[VS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
- actions[VS::SHADER_SPATIAL].renames["POSITION"] = "position";
- actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
- actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
- actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
- actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize";
- actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "gl_InstanceID";
+ actions[RS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
+ actions[RS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
+ actions[RS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
+ actions[RS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
+ actions[RS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "inv_projection_matrix";
+ actions[RS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
+
+ actions[RS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
+ actions[RS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
+ actions[RS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
+ actions[RS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
+ actions[RS::SHADER_SPATIAL].renames["POSITION"] = "position";
+ actions[RS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
+ actions[RS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
+ actions[RS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
+ actions[RS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize";
+ actions[RS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "gl_InstanceID";
//builtins
- actions[VS::SHADER_SPATIAL].renames["TIME"] = "time";
- actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
-
- actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
- actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
- actions[VS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
- actions[VS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
- actions[VS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
- actions[VS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
- actions[VS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
- actions[VS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
- actions[VS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
- actions[VS::SHADER_SPATIAL].renames["RIM"] = "rim";
- actions[VS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
- actions[VS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
- actions[VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
- actions[VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
- actions[VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
- actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
- actions[VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
- actions[VS::SHADER_SPATIAL].renames["AO"] = "ao";
- actions[VS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
- actions[VS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
- actions[VS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
- actions[VS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
- actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
- actions[VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
- actions[VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_buffer";
- actions[VS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
- actions[VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
- actions[VS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
+ actions[RS::SHADER_SPATIAL].renames["TIME"] = "time";
+ actions[RS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
+
+ actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
+ actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
+ actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
+ actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
+ actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
+ actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
+ actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
+ actions[RS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
+ actions[RS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
+ actions[RS::SHADER_SPATIAL].renames["RIM"] = "rim";
+ actions[RS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
+ actions[RS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
+ actions[RS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
+ actions[RS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
+ actions[RS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
+ actions[RS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
+ actions[RS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
+ actions[RS::SHADER_SPATIAL].renames["AO"] = "ao";
+ actions[RS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
+ actions[RS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
+ actions[RS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
+ actions[RS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
+ actions[RS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
+ actions[RS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
+ actions[RS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_buffer";
+ actions[RS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
+ actions[RS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
+ actions[RS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
//for light
- actions[VS::SHADER_SPATIAL].renames["VIEW"] = "view";
- actions[VS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
- actions[VS::SHADER_SPATIAL].renames["LIGHT"] = "light";
- actions[VS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
- actions[VS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
- actions[VS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
-
- actions[VS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
- actions[VS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
- actions[VS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
- actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
- actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
- actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
- actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
- actions[VS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
- actions[VS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
- actions[VS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
- actions[VS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
- actions[VS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
- actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
-
- actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
- actions[VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
- actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
-
- actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
- actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
-
- actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
+ actions[RS::SHADER_SPATIAL].renames["VIEW"] = "view";
+ actions[RS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
+ actions[RS::SHADER_SPATIAL].renames["LIGHT"] = "light";
+ actions[RS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
+ actions[RS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
+ actions[RS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
+
+ actions[RS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
+ actions[RS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
+ actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
+ actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
+ actions[RS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
+ actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
+
+ actions[RS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
+
+ actions[RS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+
+ actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley");
if (!force_lambert) {
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
}
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx");
if (!force_blinn) {
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
} else {
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
}
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
- actions[VS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
+ actions[RS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
/* PARTICLES SHADER */
- actions[VS::SHADER_PARTICLES].renames["COLOR"] = "out_color";
- actions[VS::SHADER_PARTICLES].renames["VELOCITY"] = "out_velocity_active.xyz";
- actions[VS::SHADER_PARTICLES].renames["MASS"] = "mass";
- actions[VS::SHADER_PARTICLES].renames["ACTIVE"] = "shader_active";
- actions[VS::SHADER_PARTICLES].renames["RESTART"] = "restart";
- actions[VS::SHADER_PARTICLES].renames["CUSTOM"] = "out_custom";
- actions[VS::SHADER_PARTICLES].renames["TRANSFORM"] = "xform";
- actions[VS::SHADER_PARTICLES].renames["TIME"] = "time";
- actions[VS::SHADER_PARTICLES].renames["LIFETIME"] = "lifetime";
- actions[VS::SHADER_PARTICLES].renames["DELTA"] = "local_delta";
- actions[VS::SHADER_PARTICLES].renames["NUMBER"] = "particle_number";
- actions[VS::SHADER_PARTICLES].renames["INDEX"] = "index";
- actions[VS::SHADER_PARTICLES].renames["GRAVITY"] = "current_gravity";
- actions[VS::SHADER_PARTICLES].renames["EMISSION_TRANSFORM"] = "emission_transform";
- actions[VS::SHADER_PARTICLES].renames["RANDOM_SEED"] = "random_seed";
-
- actions[VS::SHADER_PARTICLES].render_mode_defines["disable_force"] = "#define DISABLE_FORCE\n";
- actions[VS::SHADER_PARTICLES].render_mode_defines["disable_velocity"] = "#define DISABLE_VELOCITY\n";
- actions[VS::SHADER_PARTICLES].render_mode_defines["keep_data"] = "#define ENABLE_KEEP_DATA\n";
+ actions[RS::SHADER_PARTICLES].renames["COLOR"] = "out_color";
+ actions[RS::SHADER_PARTICLES].renames["VELOCITY"] = "out_velocity_active.xyz";
+ actions[RS::SHADER_PARTICLES].renames["MASS"] = "mass";
+ actions[RS::SHADER_PARTICLES].renames["ACTIVE"] = "shader_active";
+ actions[RS::SHADER_PARTICLES].renames["RESTART"] = "restart";
+ actions[RS::SHADER_PARTICLES].renames["CUSTOM"] = "out_custom";
+ actions[RS::SHADER_PARTICLES].renames["TRANSFORM"] = "xform";
+ actions[RS::SHADER_PARTICLES].renames["TIME"] = "time";
+ actions[RS::SHADER_PARTICLES].renames["LIFETIME"] = "lifetime";
+ actions[RS::SHADER_PARTICLES].renames["DELTA"] = "local_delta";
+ actions[RS::SHADER_PARTICLES].renames["NUMBER"] = "particle_number";
+ actions[RS::SHADER_PARTICLES].renames["INDEX"] = "index";
+ actions[RS::SHADER_PARTICLES].renames["GRAVITY"] = "current_gravity";
+ actions[RS::SHADER_PARTICLES].renames["EMISSION_TRANSFORM"] = "emission_transform";
+ actions[RS::SHADER_PARTICLES].renames["RANDOM_SEED"] = "random_seed";
+
+ actions[RS::SHADER_PARTICLES].render_mode_defines["disable_force"] = "#define DISABLE_FORCE\n";
+ actions[RS::SHADER_PARTICLES].render_mode_defines["disable_velocity"] = "#define DISABLE_VELOCITY\n";
+ actions[RS::SHADER_PARTICLES].render_mode_defines["keep_data"] = "#define ENABLE_KEEP_DATA\n";
#endif
}
diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.h b/servers/rendering/rasterizer_rd/shader_compiler_rd.h
index 95e1f0aa23..7d78469e9c 100644
--- a/servers/visual/rasterizer_rd/shader_compiler_rd.h
+++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.h
@@ -32,9 +32,9 @@
#define SHADER_COMPILER_RD_H
#include "core/pair.h"
-#include "servers/visual/shader_language.h"
-#include "servers/visual/shader_types.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/shader_language.h"
+#include "servers/rendering/shader_types.h"
+#include "servers/rendering_server.h"
class ShaderCompilerRD {
public:
@@ -114,7 +114,7 @@ private:
DefaultIdentifierActions actions;
public:
- Error compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
+ Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
void initialize(DefaultIdentifierActions p_actions);
ShaderCompilerRD();
diff --git a/servers/visual/rasterizer_rd/shader_rd.cpp b/servers/rendering/rasterizer_rd/shader_rd.cpp
index 857a29f7f4..3dcfd0faf9 100644
--- a/servers/visual/rasterizer_rd/shader_rd.cpp
+++ b/servers/rendering/rasterizer_rd/shader_rd.cpp
@@ -29,9 +29,10 @@
/*************************************************************************/
#include "shader_rd.h"
+
#include "core/string_builder.h"
#include "rasterizer_rd.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rendering_device.h"
void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, const char *p_compute_code, const char *p_name) {
diff --git a/servers/visual/rasterizer_rd/shader_rd.h b/servers/rendering/rasterizer_rd/shader_rd.h
index 6635b08cc8..6635b08cc8 100644
--- a/servers/visual/rasterizer_rd/shader_rd.h
+++ b/servers/rendering/rasterizer_rd/shader_rd.h
diff --git a/servers/visual/rasterizer_rd/shaders/SCsub b/servers/rendering/rasterizer_rd/shaders/SCsub
index 2dcb2a703f..2dcb2a703f 100644
--- a/servers/visual/rasterizer_rd/shaders/SCsub
+++ b/servers/rendering/rasterizer_rd/shaders/SCsub
diff --git a/servers/visual/rasterizer_rd/shaders/blur.glsl b/servers/rendering/rasterizer_rd/shaders/blur.glsl
index 87c20ebaef..87c20ebaef 100644
--- a/servers/visual/rasterizer_rd/shaders/blur.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/blur.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/blur_inc.glsl b/servers/rendering/rasterizer_rd/shaders/blur_inc.glsl
index 33ba9de7bb..33ba9de7bb 100644
--- a/servers/visual/rasterizer_rd/shaders/blur_inc.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/blur_inc.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl b/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl
index 7153fe6b17..7153fe6b17 100644
--- a/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/canvas.glsl b/servers/rendering/rasterizer_rd/shaders/canvas.glsl
index 28135fce31..28135fce31 100644
--- a/servers/visual/rasterizer_rd/shaders/canvas.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/canvas.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl b/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl
index 7b30cc8fe9..7b30cc8fe9 100644
--- a/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl b/servers/rendering/rasterizer_rd/shaders/canvas_uniforms_inc.glsl
index 1ac43480cd..1ac43480cd 100644
--- a/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/canvas_uniforms_inc.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/copy.glsl b/servers/rendering/rasterizer_rd/shaders/copy.glsl
index cbb9b546a3..cbb9b546a3 100644
--- a/servers/visual/rasterizer_rd/shaders/copy.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/copy.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl
index 9f3ecf6053..9f3ecf6053 100644
--- a/servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl
index e0b0899dfa..193d0a8a3c 100644
--- a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl
@@ -94,35 +94,36 @@ void main() {
// determine which texel this is
#ifndef USE_TEXTURE_ARRAY
- int level = 0;
+ // NOTE (macOS/MoltenVK): Do not rename, "level" variable name conflicts with the Metal "level(float lod)" mipmap sampling function name.
+ int mip_level = 0;
if (id.x < (128 * 128)) {
- level = 0;
+ mip_level = 0;
} else if (id.x < (128 * 128 + 64 * 64)) {
- level = 1;
+ mip_level = 1;
id.x -= (128 * 128);
} else if (id.x < (128 * 128 + 64 * 64 + 32 * 32)) {
- level = 2;
+ mip_level = 2;
id.x -= (128 * 128 + 64 * 64);
} else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16)) {
- level = 3;
+ mip_level = 3;
id.x -= (128 * 128 + 64 * 64 + 32 * 32);
} else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8)) {
- level = 4;
+ mip_level = 4;
id.x -= (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16);
} else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4)) {
- level = 5;
+ mip_level = 5;
id.x -= (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8);
} else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2)) {
- level = 6;
+ mip_level = 6;
id.x -= (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4);
} else {
return;
}
- int res = BASE_RESOLUTION >> level;
+ int res = BASE_RESOLUTION >> mip_level;
#else // Using Texture Arrays so all levels are the same resolution
int res = BASE_RESOLUTION;
- int level = int(id.x / (BASE_RESOLUTION * BASE_RESOLUTION));
- id.x -= level * BASE_RESOLUTION * BASE_RESOLUTION;
+ int mip_level = int(id.x / (BASE_RESOLUTION * BASE_RESOLUTION));
+ id.x -= mip_level * BASE_RESOLUTION * BASE_RESOLUTION;
#endif
// determine dir / pos for the texel
@@ -212,29 +213,29 @@ void main() {
vec4 coeffsWeight[3];
for (int iCoeff = 0; iCoeff < 3; iCoeff++) {
- coeffsDir0[iCoeff] = data.coeffs[level][0][iCoeff][index];
- coeffsDir1[iCoeff] = data.coeffs[level][1][iCoeff][index];
- coeffsDir2[iCoeff] = data.coeffs[level][2][iCoeff][index];
- coeffsLevel[iCoeff] = data.coeffs[level][3][iCoeff][index];
- coeffsWeight[iCoeff] = data.coeffs[level][4][iCoeff][index];
+ coeffsDir0[iCoeff] = data.coeffs[mip_level][0][iCoeff][index];
+ coeffsDir1[iCoeff] = data.coeffs[mip_level][1][iCoeff][index];
+ coeffsDir2[iCoeff] = data.coeffs[mip_level][2][iCoeff][index];
+ coeffsLevel[iCoeff] = data.coeffs[mip_level][3][iCoeff][index];
+ coeffsWeight[iCoeff] = data.coeffs[mip_level][4][iCoeff][index];
}
for (int iSubTap = 0; iSubTap < 4; iSubTap++) {
- // determine sample attributes (dir, weight, level)
+ // determine sample attributes (dir, weight, mip_level)
vec3 sample_dir = frameX * (coeffsDir0[0][iSubTap] + coeffsDir0[1][iSubTap] * theta2 + coeffsDir0[2][iSubTap] * phi2) + frameY * (coeffsDir1[0][iSubTap] + coeffsDir1[1][iSubTap] * theta2 + coeffsDir1[2][iSubTap] * phi2) + frameZ * (coeffsDir2[0][iSubTap] + coeffsDir2[1][iSubTap] * theta2 + coeffsDir2[2][iSubTap] * phi2);
float sample_level = coeffsLevel[0][iSubTap] + coeffsLevel[1][iSubTap] * theta2 + coeffsLevel[2][iSubTap] * phi2;
float sample_weight = coeffsWeight[0][iSubTap] + coeffsWeight[1][iSubTap] * theta2 + coeffsWeight[2][iSubTap] * phi2;
#else
- vec4 coeffsDir0 = data.coeffs[level][0][index];
- vec4 coeffsDir1 = data.coeffs[level][1][index];
- vec4 coeffsDir2 = data.coeffs[level][2][index];
- vec4 coeffsLevel = data.coeffs[level][3][index];
- vec4 coeffsWeight = data.coeffs[level][4][index];
+ vec4 coeffsDir0 = data.coeffs[mip_level][0][index];
+ vec4 coeffsDir1 = data.coeffs[mip_level][1][index];
+ vec4 coeffsDir2 = data.coeffs[mip_level][2][index];
+ vec4 coeffsLevel = data.coeffs[mip_level][3][index];
+ vec4 coeffsWeight = data.coeffs[mip_level][4][index];
for (int iSubTap = 0; iSubTap < 4; iSubTap++) {
- // determine sample attributes (dir, weight, level)
+ // determine sample attributes (dir, weight, mip_level)
vec3 sample_dir = frameX * coeffsDir0[iSubTap] + frameY * coeffsDir1[iSubTap] + frameZ * coeffsDir2[iSubTap];
float sample_level = coeffsLevel[iSubTap];
@@ -248,7 +249,7 @@ void main() {
sample_dir /= max(abs(sample_dir[0]), max(abs(sample_dir[1]), abs(sample_dir[2])));
sample_level += 0.75 * log2(dot(sample_dir, sample_dir));
#ifndef USE_TEXTURE_ARRAY
- sample_level += float(level) / 6.0; // Hack to increase the perceived roughness and reduce upscaling artifacts
+ sample_level += float(mip_level) / 6.0; // Hack to increase the perceived roughness and reduce upscaling artifacts
#endif
// sample cubemap
color.xyz += textureLod(source_cubemap, normalize(sample_dir), sample_level).xyz * sample_weight;
@@ -266,7 +267,7 @@ void main() {
id.xy *= uvec2(2, 2);
#endif
- switch (level) {
+ switch (mip_level) {
case 0:
imageStore(dest_cubemap0, ivec3(id), color);
#ifdef USE_TEXTURE_ARRAY
diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl
index e85996fa1a..e85996fa1a 100644
--- a/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/giprobe.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe.glsl
index fd09f96a57..fd09f96a57 100644
--- a/servers/visual/rasterizer_rd/shaders/giprobe.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl
index b1784e7eee..b1784e7eee 100644
--- a/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl
index d089236723..d089236723 100644
--- a/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl
index c832223b1e..c832223b1e 100644
--- a/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl b/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl
index 4bf5b7e7f1..4bf5b7e7f1 100644
--- a/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl b/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl
index 3637b1abb2..3637b1abb2 100644
--- a/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
index 07f4770b14..07f4770b14 100644
--- a/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl
index baef1e060f..baef1e060f 100644
--- a/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/sky.glsl b/servers/rendering/rasterizer_rd/shaders/sky.glsl
index b73f9345e7..3f433eb2ee 100644
--- a/servers/visual/rasterizer_rd/shaders/sky.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/sky.glsl
@@ -43,6 +43,19 @@ layout(push_constant, binding = 1, std430) uniform Params {
}
params;
+#define SAMPLER_NEAREST_CLAMP 0
+#define SAMPLER_LINEAR_CLAMP 1
+#define SAMPLER_NEAREST_WITH_MIPMAPS_CLAMP 2
+#define SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP 3
+#define SAMPLER_NEAREST_WITH_MIPMAPS_ANISOTROPIC_CLAMP 4
+#define SAMPLER_LINEAR_WITH_MIPMAPS_ANISOTROPIC_CLAMP 5
+#define SAMPLER_NEAREST_REPEAT 6
+#define SAMPLER_LINEAR_REPEAT 7
+#define SAMPLER_NEAREST_WITH_MIPMAPS_REPEAT 8
+#define SAMPLER_LINEAR_WITH_MIPMAPS_REPEAT 9
+#define SAMPLER_NEAREST_WITH_MIPMAPS_ANISOTROPIC_REPEAT 10
+#define SAMPLER_LINEAR_WITH_MIPMAPS_ANISOTROPIC_REPEAT 11
+
layout(set = 0, binding = 0) uniform sampler material_samplers[12];
#ifdef USE_MATERIAL_UNIFORMS
@@ -56,8 +69,31 @@ MATERIAL_UNIFORMS
#endif
layout(set = 2, binding = 0) uniform textureCube radiance;
+#ifdef USE_CUBEMAP_PASS
+layout(set = 2, binding = 1) uniform textureCube half_res;
+layout(set = 2, binding = 2) uniform textureCube quarter_res;
+#else
layout(set = 2, binding = 1) uniform texture2D half_res;
layout(set = 2, binding = 2) uniform texture2D quarter_res;
+#endif
+
+#ifdef USE_CUBEMAP_PASS
+#define AT_CUBEMAP_PASS true
+#else
+#define AT_CUBEMAP_PASS false
+#endif
+
+#ifdef USE_HALF_RES_PASS
+#define AT_HALF_RES_PASS true
+#else
+#define AT_HALF_RES_PASS false
+#endif
+
+#ifdef USE_QUARTER_RES_PASS
+#define AT_QUARTER_RES_PASS true
+#else
+#define AT_QUARTER_RES_PASS false
+#endif
struct DirectionalLightData {
vec3 direction;
@@ -101,6 +137,26 @@ void main() {
vec3 color = vec3(0.0, 0.0, 0.0);
float alpha = 1.0; // Only available to subpasses
+ vec4 half_res_color = vec4(1.0);
+ vec4 quarter_res_color = vec4(1.0);
+
+#ifdef USE_CUBEMAP_PASS
+ float using_cubemap = 1.0;
+#ifdef USES_HALF_RES_COLOR
+ half_res_color = texture(samplerCube(half_res, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), cube_normal);
+#endif
+#ifdef USES_QUARTER_RES_COLOR
+ quarter_res_color = texture(samplerCube(quarter_res, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), cube_normal);
+#endif
+#else
+ float using_cubemap = 0.0;
+#ifdef USES_HALF_RES_COLOR
+ half_res_color = textureLod(sampler2D(half_res, material_samplers[SAMPLER_LINEAR_CLAMP]), uv, 0.0);
+#endif
+#ifdef USES_QUARTER_RES_COLOR
+ quarter_res_color = textureLod(sampler2D(quarter_res, material_samplers[SAMPLER_LINEAR_CLAMP]), uv, 0.0);
+#endif
+#endif
// unused, just here to make our compiler happy, make sure we don't execute any light code the user adds in..
#ifndef REALLYINCLUDETHIS
diff --git a/servers/visual/rasterizer_rd/shaders/ssao.glsl b/servers/rendering/rasterizer_rd/shaders/ssao.glsl
index c9d7134610..c9d7134610 100644
--- a/servers/visual/rasterizer_rd/shaders/ssao.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/ssao.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl b/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl
index e90c788e08..e90c788e08 100644
--- a/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl b/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl
index 8728154347..8728154347 100644
--- a/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl
diff --git a/servers/visual/rasterizer_rd/shaders/tonemap.glsl b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
index 524ca5e2ea..524ca5e2ea 100644
--- a/servers/visual/rasterizer_rd/shaders/tonemap.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
diff --git a/servers/visual/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 3c1795161d..3c1795161d 100644
--- a/servers/visual/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
diff --git a/servers/visual/rendering_device.h b/servers/rendering/rendering_device.h
index ed55afd961..4705bcaa75 100644
--- a/servers/visual/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -32,6 +32,7 @@
#define RENDERING_DEVICE_H
#include "core/object.h"
+#include "servers/display_server.h"
class RenderingDevice : public Object {
GDCLASS(RenderingDevice, Object)
@@ -896,8 +897,8 @@ public:
/**** SCREEN ****/
/****************/
- virtual int screen_get_width(int p_screen = 0) const = 0;
- virtual int screen_get_height(int p_screen = 0) const = 0;
+ virtual int screen_get_width(DisplayServer::WindowID p_screen = 0) const = 0;
+ virtual int screen_get_height(DisplayServer::WindowID p_screen = 0) const = 0;
virtual FramebufferFormatID screen_get_framebuffer_format() const = 0;
/********************/
@@ -920,7 +921,7 @@ public:
typedef int64_t DrawListID;
- virtual DrawListID draw_list_begin_for_screen(int p_screen = 0, const Color &p_clear_color = Color()) = 0;
+ virtual DrawListID draw_list_begin_for_screen(DisplayServer::WindowID p_screen = 0, const Color &p_clear_color = Color()) = 0;
virtual DrawListID draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2()) = 0;
virtual Error draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, DrawListID *r_split_ids, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2()) = 0;
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/rendering/rendering_server_canvas.cpp
index c192b77988..261bd4c275 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/rendering/rendering_server_canvas.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_canvas.cpp */
+/* rendering_server_canvas.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_server_canvas.h"
-#include "visual_server_globals.h"
-#include "visual_server_raster.h"
-#include "visual_server_viewport.h"
+#include "rendering_server_canvas.h"
+#include "rendering_server_globals.h"
+#include "rendering_server_raster.h"
+#include "rendering_server_viewport.h"
-static const int z_range = VS::CANVAS_ITEM_Z_MAX - VS::CANVAS_ITEM_Z_MIN + 1;
+static const int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1;
-void VisualServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
+void RenderingServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
RENDER_TIMESTAMP("Cull CanvasItem Tree");
@@ -66,12 +66,12 @@ void VisualServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas
RENDER_TIMESTAMP("Render Canvas Items");
- VSG::canvas_render->canvas_render_items(p_to_render_target, list, p_modulate, p_lights, p_transform);
+ RSG::canvas_render->canvas_render_items(p_to_render_target, list, p_modulate, p_lights, p_transform);
}
-void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2D p_transform, VisualServerCanvas::Item *p_material_owner, VisualServerCanvas::Item **r_items, int &r_index) {
+void _collect_ysort_children(RenderingServerCanvas::Item *p_canvas_item, Transform2D p_transform, RenderingServerCanvas::Item *p_material_owner, RenderingServerCanvas::Item **r_items, int &r_index) {
int child_item_count = p_canvas_item->child_items.size();
- VisualServerCanvas::Item **child_items = p_canvas_item->child_items.ptrw();
+ RenderingServerCanvas::Item **child_items = p_canvas_item->child_items.ptrw();
for (int i = 0; i < child_item_count; i++) {
if (child_items[i]->visible) {
if (r_items) {
@@ -89,14 +89,14 @@ void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2
}
}
-void _mark_ysort_dirty(VisualServerCanvas::Item *ysort_owner, RID_PtrOwner<VisualServerCanvas::Item> &canvas_item_owner) {
+void _mark_ysort_dirty(RenderingServerCanvas::Item *ysort_owner, RID_PtrOwner<RenderingServerCanvas::Item> &canvas_item_owner) {
do {
ysort_owner->ysort_children_count = -1;
ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : NULL;
} while (ysort_owner && ysort_owner->sort_y);
}
-void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {
+void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {
Item *ci = p_canvas_item;
@@ -159,7 +159,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2
}
if (ci->z_relative)
- p_z = CLAMP(p_z + ci->z_index, VS::CANVAS_ITEM_Z_MIN, VS::CANVAS_ITEM_Z_MAX);
+ p_z = CLAMP(p_z + ci->z_index, RS::CANVAS_ITEM_Z_MIN, RS::CANVAS_ITEM_Z_MAX);
else
p_z = ci->z_index;
@@ -180,7 +180,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2
}
if (ci->update_when_visible) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
if ((ci->commands != NULL && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) {
@@ -191,7 +191,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2
ci->global_rect_cache.position -= p_clip_rect.position;
ci->light_masked = false;
- int zidx = p_z - VS::CANVAS_ITEM_Z_MIN;
+ int zidx = p_z - RS::CANVAS_ITEM_Z_MIN;
if (z_last_list[zidx]) {
z_last_list[zidx]->next = ci;
@@ -219,7 +219,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2
}
}
-void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) {
+void RenderingServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) {
if (!p_masked_lights)
return;
@@ -242,7 +242,7 @@ void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Ite
}
}
-void VisualServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
+void RenderingServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
RENDER_TIMESTAMP(">Render Canvas");
@@ -296,7 +296,7 @@ void VisualServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, co
RENDER_TIMESTAMP("<End Render Canvas");
}
-RID VisualServerCanvas::canvas_create() {
+RID RenderingServerCanvas::canvas_create() {
Canvas *canvas = memnew(Canvas);
ERR_FAIL_COND_V(!canvas, RID());
@@ -305,7 +305,7 @@ RID VisualServerCanvas::canvas_create() {
return rid;
}
-void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
+void RenderingServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
@@ -316,18 +316,18 @@ void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, con
ERR_FAIL_COND(idx == -1);
canvas->child_items.write[idx].mirror = p_mirroring;
}
-void VisualServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
+void RenderingServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->modulate = p_color;
}
-void VisualServerCanvas::canvas_set_disable_scale(bool p_disable) {
+void RenderingServerCanvas::canvas_set_disable_scale(bool p_disable) {
disable_scale = p_disable;
}
-void VisualServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
+void RenderingServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
@@ -336,7 +336,7 @@ void VisualServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_s
canvas->parent_scale = p_scale;
}
-RID VisualServerCanvas::canvas_item_create() {
+RID RenderingServerCanvas::canvas_item_create() {
Item *canvas_item = memnew(Item);
ERR_FAIL_COND_V(!canvas_item, RID());
@@ -344,7 +344,7 @@ RID VisualServerCanvas::canvas_item_create() {
return canvas_item_owner.make_rid(canvas_item);
}
-void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
+void RenderingServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -394,7 +394,7 @@ void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
canvas_item->parent = p_parent;
}
-void VisualServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) {
+void RenderingServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -403,7 +403,7 @@ void VisualServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) {
_mark_ysort_dirty(canvas_item, canvas_item_owner);
}
-void VisualServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
+void RenderingServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -411,28 +411,28 @@ void VisualServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
canvas_item->light_mask = p_mask;
}
-void VisualServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
+void RenderingServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->xform = p_transform;
}
-void VisualServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) {
+void RenderingServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clip = p_clip;
}
-void VisualServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->distance_field = p_enable;
}
-void VisualServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
+void RenderingServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -440,14 +440,14 @@ void VisualServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_r
canvas_item->custom_rect = p_custom_rect;
canvas_item->rect = p_rect;
}
-void VisualServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) {
+void RenderingServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->modulate = p_color;
}
-void VisualServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
+void RenderingServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -455,7 +455,7 @@ void VisualServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &
canvas_item->self_modulate = p_color;
}
-void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -463,7 +463,7 @@ void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_e
canvas_item->behind = p_enable;
}
-void VisualServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_update) {
+void RenderingServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_update) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -471,21 +471,21 @@ void VisualServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_
canvas_item->update_when_visible = p_update;
}
-void VisualServerCanvas::canvas_item_set_default_texture_filter(RID p_item, VS::CanvasItemTextureFilter p_filter) {
+void RenderingServerCanvas::canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->texture_filter = p_filter;
}
-void VisualServerCanvas::canvas_item_set_default_texture_repeat(RID p_item, VS::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->texture_repeat = p_repeat;
}
-void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
+void RenderingServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -511,7 +511,7 @@ void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from,
line->specular_shininess = Color(1, 1, 1, 1);
}
-void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
+void RenderingServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
ERR_FAIL_COND(p_points.size() < 2);
Item *canvas_item = canvas_item_owner.getornull(p_item);
@@ -520,7 +520,7 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
ERR_FAIL_COND(!pline);
- pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID());
+ pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID());
if (true || p_width <= 1) {
#define TODO make thick lines possible
@@ -535,7 +535,7 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point
}
}
- pline->primitive = VS::PRIMITIVE_LINES;
+ pline->primitive = RS::PRIMITIVE_LINES;
pline->specular_shininess = Color(1, 1, 1, 1);
pline->polygon.create(indices, p_points, p_colors);
} else {
@@ -603,7 +603,7 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point
}
}
-void VisualServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
+void RenderingServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
ERR_FAIL_COND(p_points.size() < 2);
Item *canvas_item = canvas_item_owner.getornull(p_item);
@@ -612,19 +612,19 @@ void VisualServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Poin
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
ERR_FAIL_COND(!pline);
- pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID());
+ pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID());
if (true || p_width <= 1) {
#define TODO make thick lines possible
- pline->primitive = VS::PRIMITIVE_LINES;
+ pline->primitive = RS::PRIMITIVE_LINES;
pline->specular_shininess = Color(1, 1, 1, 1);
pline->polygon.create(Vector<int>(), p_points, p_colors);
} else {
}
}
-void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
+void RenderingServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -635,7 +635,7 @@ void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, c
rect->rect = p_rect;
}
-void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) {
+void RenderingServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -643,9 +643,9 @@ void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
Item::CommandPolygon *circle = canvas_item->alloc_command<Item::CommandPolygon>();
ERR_FAIL_COND(!circle);
- circle->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID());
+ circle->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID());
- circle->primitive = VS::PRIMITIVE_TRIANGLES;
+ circle->primitive = RS::PRIMITIVE_TRIANGLES;
circle->specular_shininess = Color(1, 1, 1, 1);
Vector<int> indices;
@@ -673,7 +673,7 @@ void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
circle->polygon.create(indices, points, color);
}
-void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -707,7 +707,7 @@ void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
rect->specular_shininess = p_specular_color_shininess;
}
-void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -752,7 +752,7 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R
}
}
-void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode, VS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode, RS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -772,7 +772,7 @@ void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_r
style->axis_x = p_x_axis_mode;
style->axis_y = p_y_axis_mode;
}
-void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
uint32_t pc = p_points.size();
ERR_FAIL_COND(pc == 0 || pc > 4);
@@ -803,7 +803,7 @@ void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Poin
prim->specular_shininess = p_specular_color_shininess;
}
-void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -820,13 +820,13 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
Item::CommandPolygon *polygon = canvas_item->alloc_command<Item::CommandPolygon>();
ERR_FAIL_COND(!polygon);
- polygon->primitive = VS::PRIMITIVE_TRIANGLES;
+ polygon->primitive = RS::PRIMITIVE_TRIANGLES;
polygon->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
polygon->specular_shininess = p_specular_color_shininess;
polygon->polygon.create(indices, p_points, p_colors, p_uvs);
}
-void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -846,10 +846,10 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
polygon->specular_shininess = p_specular_color_shininess;
polygon->polygon.create(indices, p_points, p_colors, p_uvs, p_bones, p_weights);
- polygon->primitive = VS::PRIMITIVE_TRIANGLES;
+ polygon->primitive = RS::PRIMITIVE_TRIANGLES;
}
-void VisualServerCanvas::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
+void RenderingServerCanvas::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -859,7 +859,7 @@ void VisualServerCanvas::canvas_item_add_set_transform(RID p_item, const Transfo
tr->xform = p_transform;
}
-void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -872,7 +872,7 @@ void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, con
m->transform = p_transform;
m->modulate = p_modulate;
}
-void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -884,10 +884,10 @@ void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles,
part->specular_shininess = p_specular_color_shininess;
//take the chance and request processing for them, at least once until they become visible again
- VSG::storage->particles_request_process(p_particles);
+ RSG::storage->particles_request_process(p_particles);
}
-void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -899,7 +899,7 @@ void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p
mm->specular_shininess = p_specular_color_shininess;
}
-void VisualServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
+void RenderingServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -908,7 +908,7 @@ void VisualServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore)
ERR_FAIL_COND(!ci);
ci->ignore = p_ignore;
}
-void VisualServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -917,16 +917,16 @@ void VisualServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_e
_mark_ysort_dirty(canvas_item, canvas_item_owner);
}
-void VisualServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) {
+void RenderingServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) {
- ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN || p_z > VS::CANVAS_ITEM_Z_MAX);
+ ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN || p_z > RS::CANVAS_ITEM_Z_MAX);
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->z_index = p_z;
}
-void VisualServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -934,7 +934,7 @@ void VisualServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, boo
canvas_item->z_relative = p_enable;
}
-void VisualServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
+void RenderingServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -942,7 +942,7 @@ void VisualServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton)
canvas_item->skeleton = p_skeleton;
}
-void VisualServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) {
+void RenderingServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -961,14 +961,14 @@ void VisualServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_e
}
}
-void VisualServerCanvas::canvas_item_clear(RID p_item) {
+void RenderingServerCanvas::canvas_item_clear(RID p_item) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clear();
}
-void VisualServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
+void RenderingServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -988,7 +988,7 @@ void VisualServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
}
}
-void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
+void RenderingServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -996,7 +996,7 @@ void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
canvas_item->material = p_material;
}
-void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -1004,13 +1004,13 @@ void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_
canvas_item->use_parent_material = p_enable;
}
-RID VisualServerCanvas::canvas_light_create() {
+RID RenderingServerCanvas::canvas_light_create() {
RasterizerCanvas::Light *clight = memnew(RasterizerCanvas::Light);
- clight->light_internal = VSG::canvas_render->light_create();
+ clight->light_internal = RSG::canvas_render->light_create();
return canvas_light_owner.make_rid(clight);
}
-void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
+void RenderingServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1033,65 +1033,65 @@ void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
}
}
-void VisualServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) {
+void RenderingServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->enabled = p_enabled;
}
-void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
+void RenderingServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->scale = p_scale;
}
-void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
+void RenderingServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->xform = p_transform;
}
-void VisualServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
+void RenderingServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->texture = p_texture;
clight->version++;
- VSG::canvas_render->light_set_texture(clight->light_internal, p_texture);
+ RSG::canvas_render->light_set_texture(clight->light_internal, p_texture);
}
-void VisualServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
+void RenderingServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->texture_offset = p_offset;
}
-void VisualServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
+void RenderingServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->color = p_color;
}
-void VisualServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
+void RenderingServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->height = p_height;
}
-void VisualServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
+void RenderingServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->energy = p_energy;
}
-void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
+void RenderingServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1099,7 +1099,7 @@ void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int
clight->z_min = p_min_z;
clight->z_max = p_max_z;
}
-void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
+void RenderingServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1107,21 +1107,21 @@ void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_lay
clight->layer_max = p_max_layer;
clight->layer_min = p_min_layer;
}
-void VisualServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
+void RenderingServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->item_mask = p_mask;
}
-void VisualServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
+void RenderingServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->item_shadow_mask = p_mask;
}
-void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode) {
+void RenderingServerCanvas::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1129,7 +1129,7 @@ void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode
clight->mode = p_mode;
}
-void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
+void RenderingServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1139,10 +1139,10 @@ void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_ena
}
clight->use_shadow = p_enabled;
clight->version++;
- VSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size);
+ RSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size);
}
-void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size) {
+void RenderingServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size) {
ERR_FAIL_COND(p_size < 32 || p_size > 16384);
@@ -1156,17 +1156,17 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_
clight->shadow_buffer_size = next_power_of_2(p_size);
clight->version++;
- VSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size);
+ RSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size);
}
-void VisualServerCanvas::canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter) {
+void RenderingServerCanvas::canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_filter = p_filter;
}
-void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
+void RenderingServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1174,20 +1174,20 @@ void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color
clight->shadow_color = p_color;
}
-void VisualServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
+void RenderingServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_smooth = p_smooth;
}
-RID VisualServerCanvas::canvas_light_occluder_create() {
+RID RenderingServerCanvas::canvas_light_occluder_create() {
RasterizerCanvas::LightOccluderInstance *occluder = memnew(RasterizerCanvas::LightOccluderInstance);
return canvas_light_occluder_owner.make_rid(occluder);
}
-void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
+void RenderingServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1209,14 +1209,14 @@ void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder,
canvas->occluders.insert(occluder);
}
}
-void VisualServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
+void RenderingServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->enabled = p_enabled;
}
-void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
+void RenderingServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1244,14 +1244,14 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p
}
}
}
-void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
+void RenderingServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->xform = p_xform;
}
-void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
+void RenderingServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1259,13 +1259,13 @@ void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, in
occluder->light_mask = p_mask;
}
-RID VisualServerCanvas::canvas_occluder_polygon_create() {
+RID RenderingServerCanvas::canvas_occluder_polygon_create() {
LightOccluderPolygon *occluder_poly = memnew(LightOccluderPolygon);
- occluder_poly->occluder = VSG::canvas_render->occluder_polygon_create();
+ occluder_poly->occluder = RSG::canvas_render->occluder_polygon_create();
return canvas_light_occluder_polygon_owner.make_rid(occluder_poly);
}
-void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
+void RenderingServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
if (p_shape.size() < 3) {
canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, p_shape);
@@ -1295,7 +1295,7 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygo
canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, lines);
}
-void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape) {
+void RenderingServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape) {
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
@@ -1313,24 +1313,24 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occlud
}
}
- VSG::canvas_render->occluder_polygon_set_shape_as_lines(occluder_poly->occluder, p_shape);
+ RSG::canvas_render->occluder_polygon_set_shape_as_lines(occluder_poly->occluder, p_shape);
for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
E->get()->aabb_cache = occluder_poly->aabb;
}
}
-void VisualServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode) {
+void RenderingServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode) {
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
occluder_poly->cull_mode = p_mode;
- VSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode);
+ RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode);
for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
E->get()->cull_cache = p_mode;
}
}
-bool VisualServerCanvas::free(RID p_rid) {
+bool RenderingServerCanvas::free(RID p_rid) {
if (canvas_owner.owns(p_rid)) {
@@ -1339,10 +1339,10 @@ bool VisualServerCanvas::free(RID p_rid) {
while (canvas->viewports.size()) {
- VisualServerViewport::Viewport *vp = VSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get());
+ RenderingServerViewport::Viewport *vp = RSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get());
ERR_FAIL_COND_V(!vp, true);
- Map<RID, VisualServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
+ Map<RID, RenderingServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
ERR_FAIL_COND_V(!E, true);
vp->canvas_map.erase(p_rid);
@@ -1416,7 +1416,7 @@ bool VisualServerCanvas::free(RID p_rid) {
canvas->lights.erase(canvas_light);
}
- VSG::canvas_render->free(canvas_light->light_internal);
+ RSG::canvas_render->free(canvas_light->light_internal);
canvas_light_owner.free(p_rid);
memdelete(canvas_light);
@@ -1447,7 +1447,7 @@ bool VisualServerCanvas::free(RID p_rid) {
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
ERR_FAIL_COND_V(!occluder_poly, true);
- VSG::canvas_render->free(occluder_poly->occluder);
+ RSG::canvas_render->free(occluder_poly->occluder);
while (occluder_poly->owners.size()) {
@@ -1464,7 +1464,7 @@ bool VisualServerCanvas::free(RID p_rid) {
return true;
}
-VisualServerCanvas::VisualServerCanvas() {
+RenderingServerCanvas::RenderingServerCanvas() {
z_list = (RasterizerCanvas::Item **)memalloc(z_range * sizeof(RasterizerCanvas::Item *));
z_last_list = (RasterizerCanvas::Item **)memalloc(z_range * sizeof(RasterizerCanvas::Item *));
@@ -1472,7 +1472,7 @@ VisualServerCanvas::VisualServerCanvas() {
disable_scale = false;
}
-VisualServerCanvas::~VisualServerCanvas() {
+RenderingServerCanvas::~RenderingServerCanvas() {
memfree(z_list);
memfree(z_last_list);
diff --git a/servers/visual/visual_server_canvas.h b/servers/rendering/rendering_server_canvas.h
index dea4183752..c79b74f287 100644
--- a/servers/visual/visual_server_canvas.h
+++ b/servers/rendering/rendering_server_canvas.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_canvas.h */
+/* rendering_server_canvas.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -32,9 +32,9 @@
#define VISUALSERVERCANVAS_H
#include "rasterizer.h"
-#include "visual_server_viewport.h"
+#include "rendering_server_viewport.h"
-class VisualServerCanvas {
+class RenderingServerCanvas {
public:
struct Item : public RasterizerCanvas::Item {
@@ -52,8 +52,8 @@ public:
Color ysort_modulate;
Transform2D ysort_xform;
Vector2 ysort_pos;
- VS::CanvasItemTextureFilter texture_filter;
- VS::CanvasItemTextureRepeat texture_repeat;
+ RS::CanvasItemTextureFilter texture_filter;
+ RS::CanvasItemTextureRepeat texture_repeat;
Vector<Item *> child_items;
@@ -70,8 +70,8 @@ public:
ysort_children_count = -1;
ysort_xform = Transform2D();
ysort_pos = Vector2();
- texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
- texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
+ texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
+ texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
}
};
@@ -98,13 +98,13 @@ public:
bool active;
Rect2 aabb;
- VS::CanvasOccluderPolygonCullMode cull_mode;
+ RS::CanvasOccluderPolygonCullMode cull_mode;
RID occluder;
Set<RasterizerCanvas::LightOccluderInstance *> owners;
LightOccluderPolygon() {
active = false;
- cull_mode = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
+ cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
}
};
@@ -112,7 +112,7 @@ public:
RID_PtrOwner<RasterizerCanvas::LightOccluderInstance> canvas_light_occluder_owner;
- struct Canvas : public VisualServerViewport::CanvasBase {
+ struct Canvas : public RenderingServerViewport::CanvasBase {
Set<RID> viewports;
struct ChildItem {
@@ -194,23 +194,23 @@ public:
void canvas_item_set_update_when_visible(RID p_item, bool p_update);
- void canvas_item_set_default_texture_filter(RID p_item, VS::CanvasItemTextureFilter p_filter);
- void canvas_item_set_default_texture_repeat(RID p_item, VS::CanvasItemTextureRepeat p_repeat);
+ void canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter);
+ void canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat);
void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0);
void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0);
void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0);
void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color);
void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color);
- void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_clip_uv = false, VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
- void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_clip_uv = false, RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode = RS::NINE_PATCH_STRETCH, RS::NinePatchAxisMode p_y_axis_mode = RS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
+ void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform);
void canvas_item_add_clip_ignore(RID p_item, bool p_ignore);
void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable);
@@ -241,11 +241,11 @@ public:
void canvas_light_set_item_cull_mask(RID p_light, int p_mask);
void canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask);
- void canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode);
+ void canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode);
void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled);
void canvas_light_set_shadow_buffer_size(RID p_light, int p_size);
- void canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter);
+ void canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter);
void canvas_light_set_shadow_color(RID p_light, const Color &p_color);
void canvas_light_set_shadow_smooth(RID p_light, float p_smooth);
@@ -260,11 +260,11 @@ public:
void canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed);
void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape);
- void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode);
+ void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode);
bool free(RID p_rid);
- VisualServerCanvas();
- ~VisualServerCanvas();
+ RenderingServerCanvas();
+ ~RenderingServerCanvas();
};
#endif // VISUALSERVERCANVAS_H
diff --git a/platform/iphone/platform_refcount.h b/servers/rendering/rendering_server_globals.cpp
index 9029418462..251cf64184 100644
--- a/platform/iphone/platform_refcount.h
+++ b/servers/rendering/rendering_server_globals.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* platform_refcount.h */
+/* rendering_server_globals.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,21 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/safe_refcount.h"
+#include "rendering_server_globals.h"
-#ifdef IPHONE_ENABLED
+RasterizerStorage *RenderingServerGlobals::storage = NULL;
+RasterizerCanvas *RenderingServerGlobals::canvas_render = NULL;
+RasterizerScene *RenderingServerGlobals::scene_render = NULL;
+Rasterizer *RenderingServerGlobals::rasterizer = NULL;
-#define REFCOUNT_T int
-#define REFCOUNT_GET_T int const volatile &
-
-#include <libkern/OSAtomic.h>
-
-inline int atomic_conditional_increment(volatile int *v) {
- return (*v == 0) ? 0 : OSAtomicIncrement32(v);
-}
-
-inline int atomic_decrement(volatile int *v) {
- return OSAtomicDecrement32(v);
-}
-
-#endif
+RenderingServerCanvas *RenderingServerGlobals::canvas = NULL;
+RenderingServerViewport *RenderingServerGlobals::viewport = NULL;
+RenderingServerScene *RenderingServerGlobals::scene = NULL;
diff --git a/servers/visual/visual_server_globals.h b/servers/rendering/rendering_server_globals.h
index 5a9d365eca..b33f328b69 100644
--- a/servers/visual/visual_server_globals.h
+++ b/servers/rendering/rendering_server_globals.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_globals.h */
+/* rendering_server_globals.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,27 +28,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VISUAL_SERVER_GLOBALS_H
-#define VISUAL_SERVER_GLOBALS_H
+#ifndef RENDERING_SERVER_GLOBALS_H
+#define RENDERING_SERVER_GLOBALS_H
#include "rasterizer.h"
-class VisualServerCanvas;
-class VisualServerViewport;
-class VisualServerScene;
+class RenderingServerCanvas;
+class RenderingServerViewport;
+class RenderingServerScene;
-class VisualServerGlobals {
+class RenderingServerGlobals {
public:
static RasterizerStorage *storage;
static RasterizerCanvas *canvas_render;
static RasterizerScene *scene_render;
static Rasterizer *rasterizer;
- static VisualServerCanvas *canvas;
- static VisualServerViewport *viewport;
- static VisualServerScene *scene;
+ static RenderingServerCanvas *canvas;
+ static RenderingServerViewport *viewport;
+ static RenderingServerScene *scene;
};
-#define VSG VisualServerGlobals
+#define RSG RenderingServerGlobals
-#endif // VISUAL_SERVER_GLOBALS_H
+#endif // RENDERING_SERVER_GLOBALS_H
diff --git a/servers/visual/visual_server_raster.cpp b/servers/rendering/rendering_server_raster.cpp
index 35ec52a5c0..7cc06527e4 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/rendering/rendering_server_raster.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_raster.cpp */
+/* rendering_server_raster.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,23 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_server_raster.h"
+#include "rendering_server_raster.h"
#include "core/io/marshalls.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "core/sort_array.h"
-#include "visual_server_canvas.h"
-#include "visual_server_globals.h"
-#include "visual_server_scene.h"
+#include "rendering_server_canvas.h"
+#include "rendering_server_globals.h"
+#include "rendering_server_scene.h"
// careful, these may run in different threads than the visual server
-int VisualServerRaster::changes = 0;
+int RenderingServerRaster::changes = 0;
/* BLACK BARS */
-void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
+void RenderingServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
black_margin[MARGIN_LEFT] = p_left;
black_margin[MARGIN_TOP] = p_top;
@@ -52,7 +52,7 @@ void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_rig
black_margin[MARGIN_BOTTOM] = p_bottom;
}
-void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
+void RenderingServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
black_image[MARGIN_LEFT] = p_left;
black_image[MARGIN_TOP] = p_top;
@@ -60,30 +60,30 @@ void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_righ
black_image[MARGIN_BOTTOM] = p_bottom;
}
-void VisualServerRaster::_draw_margins() {
+void RenderingServerRaster::_draw_margins() {
- VSG::canvas_render->draw_window_margins(black_margin, black_image);
+ RSG::canvas_render->draw_window_margins(black_margin, black_image);
};
/* FREE */
-void VisualServerRaster::free(RID p_rid) {
+void RenderingServerRaster::free(RID p_rid) {
- if (VSG::storage->free(p_rid))
+ if (RSG::storage->free(p_rid))
return;
- if (VSG::canvas->free(p_rid))
+ if (RSG::canvas->free(p_rid))
return;
- if (VSG::viewport->free(p_rid))
+ if (RSG::viewport->free(p_rid))
return;
- if (VSG::scene->free(p_rid))
+ if (RSG::scene->free(p_rid))
return;
- if (VSG::scene_render->free(p_rid))
+ if (RSG::scene_render->free(p_rid))
return;
}
/* EVENT QUEUING */
-void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) {
+void RenderingServerRaster::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) {
ERR_FAIL_NULL(p_where);
FrameDrawnCallbacks fdc;
@@ -94,27 +94,27 @@ void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const Str
frame_drawn_callbacks.push_back(fdc);
}
-void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
+void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
//needs to be done before changes is reset to 0, to not force the editor to redraw
- VS::get_singleton()->emit_signal("frame_pre_draw");
+ RS::get_singleton()->emit_signal("frame_pre_draw");
changes = 0;
- VSG::rasterizer->begin_frame(frame_step);
+ RSG::rasterizer->begin_frame(frame_step);
TIMESTAMP_BEGIN()
- VSG::scene_render->update(); //update scenes stuff before updating instances
+ RSG::scene_render->update(); //update scenes stuff before updating instances
- VSG::scene->update_dirty_instances(); //update scene stuff
+ RSG::scene->update_dirty_instances(); //update scene stuff
- VSG::scene->render_probes();
- VSG::viewport->draw_viewports();
- VSG::canvas_render->update();
+ RSG::scene->render_probes();
+ RSG::viewport->draw_viewports();
+ RSG::canvas_render->update();
_draw_margins();
- VSG::rasterizer->end_frame(p_swap_buffers);
+ RSG::rasterizer->end_frame(p_swap_buffers);
while (frame_drawn_callbacks.front()) {
@@ -131,128 +131,128 @@ void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
frame_drawn_callbacks.pop_front();
}
- VS::get_singleton()->emit_signal("frame_post_draw");
+ RS::get_singleton()->emit_signal("frame_post_draw");
- if (VSG::storage->get_captured_timestamps_count()) {
+ if (RSG::storage->get_captured_timestamps_count()) {
Vector<FrameProfileArea> new_profile;
- new_profile.resize(VSG::storage->get_captured_timestamps_count());
+ new_profile.resize(RSG::storage->get_captured_timestamps_count());
- uint64_t base_cpu = VSG::storage->get_captured_timestamp_cpu_time(0);
- uint64_t base_gpu = VSG::storage->get_captured_timestamp_gpu_time(0);
- for (uint32_t i = 0; i < VSG::storage->get_captured_timestamps_count(); i++) {
- uint64_t time_cpu = VSG::storage->get_captured_timestamp_cpu_time(i) - base_cpu;
- uint64_t time_gpu = VSG::storage->get_captured_timestamp_gpu_time(i) - base_gpu;
+ uint64_t base_cpu = RSG::storage->get_captured_timestamp_cpu_time(0);
+ uint64_t base_gpu = RSG::storage->get_captured_timestamp_gpu_time(0);
+ for (uint32_t i = 0; i < RSG::storage->get_captured_timestamps_count(); i++) {
+ uint64_t time_cpu = RSG::storage->get_captured_timestamp_cpu_time(i) - base_cpu;
+ uint64_t time_gpu = RSG::storage->get_captured_timestamp_gpu_time(i) - base_gpu;
new_profile.write[i].gpu_msec = float(time_gpu / 1000) / 1000.0;
new_profile.write[i].cpu_msec = float(time_cpu) / 1000.0;
- new_profile.write[i].name = VSG::storage->get_captured_timestamp_name(i);
+ new_profile.write[i].name = RSG::storage->get_captured_timestamp_name(i);
}
frame_profile = new_profile;
}
- frame_profile_frame = VSG::storage->get_captured_timestamps_frame();
+ frame_profile_frame = RSG::storage->get_captured_timestamps_frame();
}
-void VisualServerRaster::sync() {
+void RenderingServerRaster::sync() {
}
-bool VisualServerRaster::has_changed() const {
+bool RenderingServerRaster::has_changed() const {
return changes > 0;
}
-void VisualServerRaster::init() {
+void RenderingServerRaster::init() {
- VSG::rasterizer->initialize();
+ RSG::rasterizer->initialize();
}
-void VisualServerRaster::finish() {
+void RenderingServerRaster::finish() {
if (test_cube.is_valid()) {
free(test_cube);
}
- VSG::rasterizer->finalize();
+ RSG::rasterizer->finalize();
}
/* STATUS INFORMATION */
-int VisualServerRaster::get_render_info(RenderInfo p_info) {
+int RenderingServerRaster::get_render_info(RenderInfo p_info) {
- return VSG::storage->get_render_info(p_info);
+ return RSG::storage->get_render_info(p_info);
}
-String VisualServerRaster::get_video_adapter_name() const {
+String RenderingServerRaster::get_video_adapter_name() const {
- return VSG::storage->get_video_adapter_name();
+ return RSG::storage->get_video_adapter_name();
}
-String VisualServerRaster::get_video_adapter_vendor() const {
+String RenderingServerRaster::get_video_adapter_vendor() const {
- return VSG::storage->get_video_adapter_vendor();
+ return RSG::storage->get_video_adapter_vendor();
}
-void VisualServerRaster::set_frame_profiling_enabled(bool p_enable) {
- VSG::storage->capturing_timestamps = p_enable;
+void RenderingServerRaster::set_frame_profiling_enabled(bool p_enable) {
+ RSG::storage->capturing_timestamps = p_enable;
}
-uint64_t VisualServerRaster::get_frame_profile_frame() {
+uint64_t RenderingServerRaster::get_frame_profile_frame() {
return frame_profile_frame;
}
-Vector<VisualServer::FrameProfileArea> VisualServerRaster::get_frame_profile() {
+Vector<RenderingServer::FrameProfileArea> RenderingServerRaster::get_frame_profile() {
return frame_profile;
}
/* TESTING */
-void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
+void RenderingServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
redraw_request();
- VSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
+ RSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
}
-void VisualServerRaster::set_default_clear_color(const Color &p_color) {
- VSG::viewport->set_default_clear_color(p_color);
+void RenderingServerRaster::set_default_clear_color(const Color &p_color) {
+ RSG::viewport->set_default_clear_color(p_color);
}
-bool VisualServerRaster::has_feature(Features p_feature) const {
+bool RenderingServerRaster::has_feature(Features p_feature) const {
return false;
}
-RID VisualServerRaster::get_test_cube() {
+RID RenderingServerRaster::get_test_cube() {
if (!test_cube.is_valid()) {
test_cube = _make_test_cube();
}
return test_cube;
}
-bool VisualServerRaster::has_os_feature(const String &p_feature) const {
+bool RenderingServerRaster::has_os_feature(const String &p_feature) const {
- return VSG::storage->has_os_feature(p_feature);
+ return RSG::storage->has_os_feature(p_feature);
}
-void VisualServerRaster::set_debug_generate_wireframes(bool p_generate) {
+void RenderingServerRaster::set_debug_generate_wireframes(bool p_generate) {
- VSG::storage->set_debug_generate_wireframes(p_generate);
+ RSG::storage->set_debug_generate_wireframes(p_generate);
}
-void VisualServerRaster::call_set_use_vsync(bool p_enable) {
- OS::get_singleton()->_set_use_vsync(p_enable);
+void RenderingServerRaster::call_set_use_vsync(bool p_enable) {
+ DisplayServer::get_singleton()->_set_use_vsync(p_enable);
}
-bool VisualServerRaster::is_low_end() const {
+bool RenderingServerRaster::is_low_end() const {
// FIXME: Commented out when rebasing vulkan branch on master,
// causes a crash, it seems rasterizer is not initialized yet the
// first time it's called.
- //return VSG::rasterizer->is_low_end();
+ //return RSG::rasterizer->is_low_end();
return false;
}
-VisualServerRaster::VisualServerRaster() {
+RenderingServerRaster::RenderingServerRaster() {
- VSG::canvas = memnew(VisualServerCanvas);
- VSG::viewport = memnew(VisualServerViewport);
- VSG::scene = memnew(VisualServerScene);
- VSG::rasterizer = Rasterizer::create();
- VSG::storage = VSG::rasterizer->get_storage();
- VSG::canvas_render = VSG::rasterizer->get_canvas();
- VSG::scene_render = VSG::rasterizer->get_scene();
+ RSG::canvas = memnew(RenderingServerCanvas);
+ RSG::viewport = memnew(RenderingServerViewport);
+ RSG::scene = memnew(RenderingServerScene);
+ RSG::rasterizer = Rasterizer::create();
+ RSG::storage = RSG::rasterizer->get_storage();
+ RSG::canvas_render = RSG::rasterizer->get_canvas();
+ RSG::scene_render = RSG::rasterizer->get_scene();
frame_profile_frame = 0;
@@ -262,10 +262,10 @@ VisualServerRaster::VisualServerRaster() {
}
}
-VisualServerRaster::~VisualServerRaster() {
+RenderingServerRaster::~RenderingServerRaster() {
- memdelete(VSG::canvas);
- memdelete(VSG::viewport);
- memdelete(VSG::rasterizer);
- memdelete(VSG::scene);
+ memdelete(RSG::canvas);
+ memdelete(RSG::viewport);
+ memdelete(RSG::rasterizer);
+ memdelete(RSG::scene);
}
diff --git a/servers/visual/visual_server_raster.h b/servers/rendering/rendering_server_raster.h
index b6afbbff93..d69968868e 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/rendering/rendering_server_raster.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_raster.h */
+/* rendering_server_raster.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,18 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VISUAL_SERVER_RASTER_H
-#define VISUAL_SERVER_RASTER_H
+#ifndef RENDERING_SERVER_RASTER_H
+#define RENDERING_SERVER_RASTER_H
#include "core/math/octree.h"
-#include "servers/visual/rasterizer.h"
-#include "servers/visual_server.h"
-#include "visual_server_canvas.h"
-#include "visual_server_globals.h"
-#include "visual_server_scene.h"
-#include "visual_server_viewport.h"
+#include "rendering_server_canvas.h"
+#include "rendering_server_globals.h"
+#include "rendering_server_scene.h"
+#include "rendering_server_viewport.h"
+#include "servers/rendering/rasterizer.h"
+#include "servers/rendering_server.h"
-class VisualServerRaster : public VisualServer {
+class RenderingServerRaster : public RenderingServer {
enum {
@@ -145,7 +145,7 @@ public:
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); }
//from now on, calls forwarded to this singleton
-#define BINDBASE VSG::storage
+#define BINDBASE RSG::storage
/* TEXTURE API */
@@ -424,7 +424,7 @@ public:
BIND1(particles_request_process, RID)
BIND1(particles_restart, RID)
- BIND2(particles_set_draw_order, RID, VS::ParticlesDrawOrder)
+ BIND2(particles_set_draw_order, RID, RS::ParticlesDrawOrder)
BIND2(particles_set_draw_passes, RID, int)
BIND3(particles_set_draw_pass_mesh, RID, int, RID)
@@ -434,7 +434,7 @@ public:
#undef BINDBASE
//from now on, calls forwarded to this singleton
-#define BINDBASE VSG::scene
+#define BINDBASE RSG::scene
/* CAMERA API */
@@ -450,7 +450,7 @@ public:
#undef BINDBASE
//from now on, calls forwarded to this singleton
-#define BINDBASE VSG::viewport
+#define BINDBASE RSG::viewport
/* VIEWPORT TARGET API */
@@ -466,7 +466,6 @@ public:
BIND3(viewport_attach_to_screen, RID, const Rect2 &, int)
BIND2(viewport_set_render_direct_to_screen, RID, bool)
- BIND1(viewport_detach, RID)
BIND2(viewport_set_update_mode, RID, ViewportUpdateMode)
BIND2(viewport_set_vflip, RID, bool)
@@ -498,7 +497,7 @@ public:
#undef BINDBASE
//from now on, calls forwarded to this singleton
-#define BINDBASE VSG::scene_render
+#define BINDBASE RSG::scene_render
BIND1(directional_shadow_atlas_set_size, int)
@@ -553,7 +552,7 @@ public:
/* SCENARIO API */
#undef BINDBASE
-#define BINDBASE VSG::scene
+#define BINDBASE RSG::scene
BIND0R(RID, scenario_create)
@@ -596,7 +595,7 @@ public:
#undef BINDBASE
//from now on, calls forwarded to this singleton
-#define BINDBASE VSG::canvas
+#define BINDBASE RSG::canvas
/* CANVAS (2D) */
@@ -736,8 +735,8 @@ public:
virtual bool is_low_end() const;
- VisualServerRaster();
- ~VisualServerRaster();
+ RenderingServerRaster();
+ ~RenderingServerRaster();
#undef DISPLAY_CHANGED
diff --git a/servers/visual/visual_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp
index 1a9ecae23a..04e4b8dace 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/rendering/rendering_server_scene.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_scene.cpp */
+/* rendering_server_scene.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,23 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_server_scene.h"
+#include "rendering_server_scene.h"
#include "core/os/os.h"
-#include "visual_server_globals.h"
-#include "visual_server_raster.h"
+#include "rendering_server_globals.h"
+#include "rendering_server_raster.h"
#include <new>
/* CAMERA API */
-RID VisualServerScene::camera_create() {
+RID RenderingServerScene::camera_create() {
Camera *camera = memnew(Camera);
return camera_owner.make_rid(camera);
}
-void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
+void RenderingServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -54,7 +54,7 @@ void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degree
camera->zfar = p_z_far;
}
-void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
+void RenderingServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -64,7 +64,7 @@ void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float
camera->zfar = p_z_far;
}
-void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
+void RenderingServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::FRUSTUM;
@@ -74,14 +74,14 @@ void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p
camera->zfar = p_z_far;
}
-void VisualServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
+void RenderingServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->transform = p_transform.orthonormalized();
}
-void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
+void RenderingServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -89,21 +89,21 @@ void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
camera->visible_layers = p_layers;
}
-void VisualServerScene::camera_set_environment(RID p_camera, RID p_env) {
+void RenderingServerScene::camera_set_environment(RID p_camera, RID p_env) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->env = p_env;
}
-void VisualServerScene::camera_set_camera_effects(RID p_camera, RID p_fx) {
+void RenderingServerScene::camera_set_camera_effects(RID p_camera, RID p_fx) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->effects = p_fx;
}
-void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
+void RenderingServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -112,9 +112,9 @@ void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enab
/* SCENARIO API */
-void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) {
+void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) {
- //VisualServerScene *self = (VisualServerScene*)p_self;
+ //RenderingServerScene *self = (RenderingServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -123,7 +123,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
SWAP(A, B); //lesser always first
}
- if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -141,7 +141,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
geom->lighting_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ } else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -155,7 +155,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
geom->reflection_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type == VS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ } else if (B->base_type == RS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -165,10 +165,10 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
pinfo.L = geom->lightmap_captures.push_back(B);
List<InstanceLightmapCaptureData::PairInfo>::Element *E = lightmap_capture->geometries.push_back(pinfo);
- ((VisualServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture
+ ((RenderingServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture
return E; //this element should make freeing faster
- } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ } else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -188,7 +188,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
return E; //this element should make freeing faster
- } else if (B->base_type == VS::INSTANCE_GI_PROBE && A->base_type == VS::INSTANCE_LIGHT) {
+ } else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
return gi_probe->lights.insert(A);
@@ -196,9 +196,9 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
return NULL;
}
-void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
+void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
- //VisualServerScene *self = (VisualServerScene*)p_self;
+ //RenderingServerScene *self = (RenderingServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -207,7 +207,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
SWAP(A, B); //lesser always first
}
- if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -222,7 +222,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
}
geom->lighting_dirty = true;
- } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ } else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -233,7 +233,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
reflection_probe->geometries.erase(E);
geom->reflection_dirty = true;
- } else if (B->base_type == VS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ } else if (B->base_type == RS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -242,9 +242,9 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
geom->lightmap_captures.erase(E->get().L);
lightmap_capture->geometries.erase(E);
- ((VisualServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture
+ ((RenderingServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture
- } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
+ } else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -260,7 +260,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
geom->gi_probes_dirty = true;
- } else if (B->base_type == VS::INSTANCE_GI_PROBE && A->base_type == VS::INSTANCE_LIGHT) {
+ } else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
Set<Instance *>::Element *E = reinterpret_cast<Set<Instance *>::Element *>(udata);
@@ -269,7 +269,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
}
}
-RID VisualServerScene::scenario_create() {
+RID RenderingServerScene::scenario_create() {
Scenario *scenario = memnew(Scenario);
ERR_FAIL_COND_V(!scenario, RID());
@@ -278,54 +278,54 @@ RID VisualServerScene::scenario_create() {
scenario->octree.set_pair_callback(_instance_pair, this);
scenario->octree.set_unpair_callback(_instance_unpair, this);
- scenario->reflection_probe_shadow_atlas = VSG::scene_render->shadow_atlas_create();
- VSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 0, 4);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 1, 4);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 2, 4);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 3, 8);
- scenario->reflection_atlas = VSG::scene_render->reflection_atlas_create();
+ scenario->reflection_probe_shadow_atlas = RSG::scene_render->shadow_atlas_create();
+ RSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest
+ RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 0, 4);
+ RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 1, 4);
+ RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 2, 4);
+ RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 3, 8);
+ scenario->reflection_atlas = RSG::scene_render->reflection_atlas_create();
return scenario_rid;
}
-void VisualServerScene::scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode) {
+void RenderingServerScene::scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->debug = p_debug_mode;
}
-void VisualServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
+void RenderingServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->environment = p_environment;
}
-void VisualServerScene::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) {
+void RenderingServerScene::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->camera_effects = p_camera_effects;
}
-void VisualServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
+void RenderingServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->fallback_environment = p_environment;
}
-void VisualServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
+void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
- VSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
+ RSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
}
/* INSTANCING API */
-void VisualServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies) {
+void RenderingServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies) {
if (p_update_aabb)
p_instance->update_aabb = true;
@@ -338,7 +338,7 @@ void VisualServerScene::_instance_queue_update(Instance *p_instance, bool p_upda
_instance_update_list.add(&p_instance->update_item);
}
-RID VisualServerScene::instance_create() {
+RID RenderingServerScene::instance_create() {
Instance *instance = memnew(Instance);
ERR_FAIL_COND_V(!instance, RID());
@@ -349,14 +349,14 @@ RID VisualServerScene::instance_create() {
return instance_rid;
}
-void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
+void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
Scenario *scenario = instance->scenario;
- if (instance->base_type != VS::INSTANCE_NONE) {
+ if (instance->base_type != RS::INSTANCE_NONE) {
//free anything related to that base
if (scenario && instance->octree_id) {
@@ -365,7 +365,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
}
switch (instance->base_type) {
- case VS::INSTANCE_LIGHT: {
+ case RS::INSTANCE_LIGHT: {
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
#ifdef DEBUG_ENABLED
@@ -377,17 +377,17 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
instance->scenario->directional_lights.erase(light->D);
light->D = NULL;
}
- VSG::scene_render->free(light->instance);
+ RSG::scene_render->free(light->instance);
} break;
- case VS::INSTANCE_REFLECTION_PROBE: {
+ case RS::INSTANCE_REFLECTION_PROBE: {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
- VSG::scene_render->free(reflection_probe->instance);
+ RSG::scene_render->free(reflection_probe->instance);
if (reflection_probe->update_list.in_list()) {
reflection_probe_render_list.remove(&reflection_probe->update_list);
}
} break;
- case VS::INSTANCE_LIGHTMAP_CAPTURE: {
+ case RS::INSTANCE_LIGHTMAP_CAPTURE: {
InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(instance->base_data);
//erase dependencies, since no longer a lightmap
@@ -395,7 +395,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
instance_set_use_lightmap(lightmap_capture->users.front()->get()->self, RID(), RID());
}
} break;
- case VS::INSTANCE_GI_PROBE: {
+ case RS::INSTANCE_GI_PROBE: {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
#ifdef DEBUG_ENABLED
@@ -420,7 +420,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
instance->lightmap = RID();
}
- VSG::scene_render->free(gi_probe->probe_instance);
+ RSG::scene_render->free(gi_probe->probe_instance);
} break;
default: {
@@ -436,53 +436,53 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
instance->materials.clear();
}
- instance->base_type = VS::INSTANCE_NONE;
+ instance->base_type = RS::INSTANCE_NONE;
instance->base = RID();
if (p_base.is_valid()) {
- instance->base_type = VSG::storage->get_base_type(p_base);
- ERR_FAIL_COND(instance->base_type == VS::INSTANCE_NONE);
+ instance->base_type = RSG::storage->get_base_type(p_base);
+ ERR_FAIL_COND(instance->base_type == RS::INSTANCE_NONE);
switch (instance->base_type) {
- case VS::INSTANCE_LIGHT: {
+ case RS::INSTANCE_LIGHT: {
InstanceLightData *light = memnew(InstanceLightData);
- if (scenario && VSG::storage->light_get_type(p_base) == VS::LIGHT_DIRECTIONAL) {
+ if (scenario && RSG::storage->light_get_type(p_base) == RS::LIGHT_DIRECTIONAL) {
light->D = scenario->directional_lights.push_back(instance);
}
- light->instance = VSG::scene_render->light_instance_create(p_base);
+ light->instance = RSG::scene_render->light_instance_create(p_base);
instance->base_data = light;
} break;
- case VS::INSTANCE_MESH:
- case VS::INSTANCE_MULTIMESH:
- case VS::INSTANCE_IMMEDIATE:
- case VS::INSTANCE_PARTICLES: {
+ case RS::INSTANCE_MESH:
+ case RS::INSTANCE_MULTIMESH:
+ case RS::INSTANCE_IMMEDIATE:
+ case RS::INSTANCE_PARTICLES: {
InstanceGeometryData *geom = memnew(InstanceGeometryData);
instance->base_data = geom;
- if (instance->base_type == VS::INSTANCE_MESH) {
- instance->blend_values.resize(VSG::storage->mesh_get_blend_shape_count(p_base));
+ if (instance->base_type == RS::INSTANCE_MESH) {
+ instance->blend_values.resize(RSG::storage->mesh_get_blend_shape_count(p_base));
}
} break;
- case VS::INSTANCE_REFLECTION_PROBE: {
+ case RS::INSTANCE_REFLECTION_PROBE: {
InstanceReflectionProbeData *reflection_probe = memnew(InstanceReflectionProbeData);
reflection_probe->owner = instance;
instance->base_data = reflection_probe;
- reflection_probe->instance = VSG::scene_render->reflection_probe_instance_create(p_base);
+ reflection_probe->instance = RSG::scene_render->reflection_probe_instance_create(p_base);
} break;
- case VS::INSTANCE_LIGHTMAP_CAPTURE: {
+ case RS::INSTANCE_LIGHTMAP_CAPTURE: {
InstanceLightmapCaptureData *lightmap_capture = memnew(InstanceLightmapCaptureData);
instance->base_data = lightmap_capture;
- //lightmap_capture->instance = VSG::scene_render->lightmap_capture_instance_create(p_base);
+ //lightmap_capture->instance = RSG::scene_render->lightmap_capture_instance_create(p_base);
} break;
- case VS::INSTANCE_GI_PROBE: {
+ case RS::INSTANCE_GI_PROBE: {
InstanceGIProbeData *gi_probe = memnew(InstanceGIProbeData);
instance->base_data = gi_probe;
@@ -492,7 +492,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
gi_probe_update_list.add(&gi_probe->update_element);
}
- gi_probe->probe_instance = VSG::scene_render->gi_probe_instance_create(p_base);
+ gi_probe->probe_instance = RSG::scene_render->gi_probe_instance_create(p_base);
} break;
default: {
@@ -502,12 +502,12 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
instance->base = p_base;
//forcefully update the dependency now, so if for some reason it gets removed, we can immediately clear it
- VSG::storage->base_update_dependency(p_base, instance);
+ RSG::storage->base_update_dependency(p_base, instance);
}
_instance_queue_update(instance, true, true);
}
-void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
+void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -523,7 +523,7 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
switch (instance->base_type) {
- case VS::INSTANCE_LIGHT: {
+ case RS::INSTANCE_LIGHT: {
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
#ifdef DEBUG_ENABLED
@@ -536,12 +536,12 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
light->D = NULL;
}
} break;
- case VS::INSTANCE_REFLECTION_PROBE: {
+ case RS::INSTANCE_REFLECTION_PROBE: {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
- VSG::scene_render->reflection_probe_release_atlas_index(reflection_probe->instance);
+ RSG::scene_render->reflection_probe_release_atlas_index(reflection_probe->instance);
} break;
- case VS::INSTANCE_GI_PROBE: {
+ case RS::INSTANCE_GI_PROBE: {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
@@ -578,15 +578,15 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
switch (instance->base_type) {
- case VS::INSTANCE_LIGHT: {
+ case RS::INSTANCE_LIGHT: {
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
- if (VSG::storage->light_get_type(instance->base) == VS::LIGHT_DIRECTIONAL) {
+ if (RSG::storage->light_get_type(instance->base) == RS::LIGHT_DIRECTIONAL) {
light->D = scenario->directional_lights.push_back(instance);
}
} break;
- case VS::INSTANCE_GI_PROBE: {
+ case RS::INSTANCE_GI_PROBE: {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
if (!gi_probe->update_element.in_list()) {
@@ -600,14 +600,14 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
_instance_queue_update(instance, true, true);
}
}
-void VisualServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
+void RenderingServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->layer_mask = p_mask;
}
-void VisualServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
+void RenderingServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -631,14 +631,14 @@ void VisualServerScene::instance_set_transform(RID p_instance, const Transform &
instance->transform = p_transform;
_instance_queue_update(instance, true);
}
-void VisualServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
+void RenderingServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->object_id = p_id;
}
-void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
+void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -651,14 +651,14 @@ void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_sh
instance->blend_values.write[p_shape] = p_weight;
}
-void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
+void RenderingServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
- if (instance->base_type == VS::INSTANCE_MESH) {
+ if (instance->base_type == RS::INSTANCE_MESH) {
//may not have been updated yet, may also have not been set yet. When updated will be correcte, worst case
- instance->materials.resize(MAX(p_surface + 1, VSG::storage->mesh_get_surface_count(instance->base)));
+ instance->materials.resize(MAX(p_surface + 1, RSG::storage->mesh_get_surface_count(instance->base)));
}
ERR_FAIL_INDEX(p_surface, instance->materials.size());
@@ -668,7 +668,7 @@ void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surf
_instance_queue_update(instance, false, true);
}
-void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
+void RenderingServerScene::instance_set_visible(RID p_instance, bool p_visible) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -679,27 +679,27 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
instance->visible = p_visible;
switch (instance->base_type) {
- case VS::INSTANCE_LIGHT: {
- if (VSG::storage->light_get_type(instance->base) != VS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_LIGHT, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0);
+ case RS::INSTANCE_LIGHT: {
+ if (RSG::storage->light_get_type(instance->base) != RS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) {
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_LIGHT, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0);
}
} break;
- case VS::INSTANCE_REFLECTION_PROBE: {
+ case RS::INSTANCE_REFLECTION_PROBE: {
if (instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_REFLECTION_PROBE, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0);
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_REFLECTION_PROBE, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0);
}
} break;
- case VS::INSTANCE_LIGHTMAP_CAPTURE: {
+ case RS::INSTANCE_LIGHTMAP_CAPTURE: {
if (instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_LIGHTMAP_CAPTURE, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0);
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_LIGHTMAP_CAPTURE, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0);
}
} break;
- case VS::INSTANCE_GI_PROBE: {
+ case RS::INSTANCE_GI_PROBE: {
if (instance->octree_id && instance->scenario) {
- instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_GI_PROBE, p_visible ? (VS::INSTANCE_GEOMETRY_MASK | (1 << VS::INSTANCE_LIGHT)) : 0);
+ instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_GI_PROBE, p_visible ? (RS::INSTANCE_GEOMETRY_MASK | (1 << RS::INSTANCE_LIGHT)) : 0);
}
} break;
@@ -707,11 +707,11 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
}
}
}
-inline bool is_geometry_instance(VisualServer::InstanceType p_type) {
- return p_type == VS::INSTANCE_MESH || p_type == VS::INSTANCE_MULTIMESH || p_type == VS::INSTANCE_PARTICLES || p_type == VS::INSTANCE_IMMEDIATE;
+inline bool is_geometry_instance(RenderingServer::InstanceType p_type) {
+ return p_type == RS::INSTANCE_MESH || p_type == RS::INSTANCE_MULTIMESH || p_type == RS::INSTANCE_PARTICLES || p_type == RS::INSTANCE_IMMEDIATE;
}
-void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap) {
+void RenderingServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -726,7 +726,7 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap
if (p_lightmap_instance.is_valid()) {
Instance *lightmap_instance = instance_owner.getornull(p_lightmap_instance);
ERR_FAIL_COND(!lightmap_instance);
- ERR_FAIL_COND(lightmap_instance->base_type != VS::INSTANCE_LIGHTMAP_CAPTURE);
+ ERR_FAIL_COND(lightmap_instance->base_type != RS::INSTANCE_LIGHTMAP_CAPTURE);
instance->lightmap_capture = lightmap_instance;
InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(((Instance *)instance->lightmap_capture)->base_data);
@@ -735,7 +735,7 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap
}
}
-void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
+void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -761,7 +761,7 @@ void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
_instance_queue_update(instance, true, false);
}
-void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
+void RenderingServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -773,15 +773,15 @@ void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton)
if (p_skeleton.is_valid()) {
//update the dependency now, so if cleared, we remove it
- VSG::storage->skeleton_update_dependency(p_skeleton, instance);
+ RSG::storage->skeleton_update_dependency(p_skeleton, instance);
}
_instance_queue_update(instance, true, true);
}
-void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
+void RenderingServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
}
-void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
+void RenderingServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -789,13 +789,13 @@ void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, rea
_instance_queue_update(instance, true, false);
}
-Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
+Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
- const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
+ const_cast<RenderingServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
int culled = 0;
Instance *cull[1024];
@@ -813,12 +813,12 @@ Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID
return instances;
}
-Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
+Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
- const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
+ const_cast<RenderingServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
int culled = 0;
Instance *cull[1024];
@@ -835,12 +835,12 @@ Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, co
return instances;
}
-Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
+Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
- const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
+ const_cast<RenderingServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
int culled = 0;
Instance *cull[1024];
@@ -860,21 +860,21 @@ Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p
return instances;
}
-void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled) {
+void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
- //ERR_FAIL_COND(((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK));
+ //ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK));
switch (p_flags) {
- case VS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
+ case RS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
instance->baked_light = p_enabled;
} break;
- case VS::INSTANCE_FLAG_USE_DYNAMIC_GI: {
+ case RS::INSTANCE_FLAG_USE_DYNAMIC_GI: {
if (p_enabled == instance->dynamic_gi) {
//bye, redundant
@@ -892,7 +892,7 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
instance->dynamic_gi = p_enabled;
} break;
- case VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: {
+ case RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: {
instance->redraw_if_visible = p_enabled;
@@ -901,7 +901,7 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
}
}
}
-void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
+void RenderingServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -909,7 +909,7 @@ void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instanc
instance->cast_shadows = p_shadow_casting_setting;
_instance_queue_update(instance, false, true);
}
-void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
+void RenderingServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -918,48 +918,48 @@ void VisualServerScene::instance_geometry_set_material_override(RID p_instance,
_instance_queue_update(instance, false, true);
}
-void VisualServerScene::instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) {
+void RenderingServerScene::instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) {
}
-void VisualServerScene::instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) {
+void RenderingServerScene::instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) {
}
-void VisualServerScene::_update_instance(Instance *p_instance) {
+void RenderingServerScene::_update_instance(Instance *p_instance) {
p_instance->version++;
- if (p_instance->base_type == VS::INSTANCE_LIGHT) {
+ if (p_instance->base_type == RS::INSTANCE_LIGHT) {
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
- VSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform);
+ RSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform);
light->shadow_dirty = true;
}
- if (p_instance->base_type == VS::INSTANCE_REFLECTION_PROBE) {
+ if (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
- VSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform);
+ RSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform);
reflection_probe->reflection_dirty = true;
}
- if (p_instance->base_type == VS::INSTANCE_GI_PROBE) {
+ if (p_instance->base_type == RS::INSTANCE_GI_PROBE) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(p_instance->base_data);
- VSG::scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform);
+ RSG::scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform);
}
- if (p_instance->base_type == VS::INSTANCE_PARTICLES) {
+ if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
- VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
+ RSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
}
if (p_instance->aabb.has_no_surface()) {
return;
}
- if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
//make sure lights are updated if it casts shadow
@@ -1000,15 +1000,15 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
uint32_t pairable_mask = 0;
bool pairable = false;
- if (p_instance->base_type == VS::INSTANCE_LIGHT || p_instance->base_type == VS::INSTANCE_REFLECTION_PROBE || p_instance->base_type == VS::INSTANCE_LIGHTMAP_CAPTURE) {
+ if (p_instance->base_type == RS::INSTANCE_LIGHT || p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE || p_instance->base_type == RS::INSTANCE_LIGHTMAP_CAPTURE) {
- pairable_mask = p_instance->visible ? VS::INSTANCE_GEOMETRY_MASK : 0;
+ pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK : 0;
pairable = true;
}
- if (p_instance->base_type == VS::INSTANCE_GI_PROBE) {
+ if (p_instance->base_type == RS::INSTANCE_GI_PROBE) {
//lights and geometries
- pairable_mask = p_instance->visible ? VS::INSTANCE_GEOMETRY_MASK | (1 << VS::INSTANCE_LIGHT) : 0;
+ pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK | (1 << RS::INSTANCE_LIGHT) : 0;
pairable = true;
}
@@ -1026,68 +1026,68 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
}
}
-void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
+void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
AABB new_aabb;
- ERR_FAIL_COND(p_instance->base_type != VS::INSTANCE_NONE && !p_instance->base.is_valid());
+ ERR_FAIL_COND(p_instance->base_type != RS::INSTANCE_NONE && !p_instance->base.is_valid());
switch (p_instance->base_type) {
- case VisualServer::INSTANCE_NONE: {
+ case RenderingServer::INSTANCE_NONE: {
// do nothing
} break;
- case VisualServer::INSTANCE_MESH: {
+ case RenderingServer::INSTANCE_MESH: {
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
- new_aabb = VSG::storage->mesh_get_aabb(p_instance->base, p_instance->skeleton);
+ new_aabb = RSG::storage->mesh_get_aabb(p_instance->base, p_instance->skeleton);
} break;
- case VisualServer::INSTANCE_MULTIMESH: {
+ case RenderingServer::INSTANCE_MULTIMESH: {
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
- new_aabb = VSG::storage->multimesh_get_aabb(p_instance->base);
+ new_aabb = RSG::storage->multimesh_get_aabb(p_instance->base);
} break;
- case VisualServer::INSTANCE_IMMEDIATE: {
+ case RenderingServer::INSTANCE_IMMEDIATE: {
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
- new_aabb = VSG::storage->immediate_get_aabb(p_instance->base);
+ new_aabb = RSG::storage->immediate_get_aabb(p_instance->base);
} break;
- case VisualServer::INSTANCE_PARTICLES: {
+ case RenderingServer::INSTANCE_PARTICLES: {
if (p_instance->custom_aabb)
new_aabb = *p_instance->custom_aabb;
else
- new_aabb = VSG::storage->particles_get_aabb(p_instance->base);
+ new_aabb = RSG::storage->particles_get_aabb(p_instance->base);
} break;
- case VisualServer::INSTANCE_LIGHT: {
+ case RenderingServer::INSTANCE_LIGHT: {
- new_aabb = VSG::storage->light_get_aabb(p_instance->base);
+ new_aabb = RSG::storage->light_get_aabb(p_instance->base);
} break;
- case VisualServer::INSTANCE_REFLECTION_PROBE: {
+ case RenderingServer::INSTANCE_REFLECTION_PROBE: {
- new_aabb = VSG::storage->reflection_probe_get_aabb(p_instance->base);
+ new_aabb = RSG::storage->reflection_probe_get_aabb(p_instance->base);
} break;
- case VisualServer::INSTANCE_GI_PROBE: {
+ case RenderingServer::INSTANCE_GI_PROBE: {
- new_aabb = VSG::storage->gi_probe_get_bounds(p_instance->base);
+ new_aabb = RSG::storage->gi_probe_get_bounds(p_instance->base);
} break;
- case VisualServer::INSTANCE_LIGHTMAP_CAPTURE: {
+ case RenderingServer::INSTANCE_LIGHTMAP_CAPTURE: {
- new_aabb = VSG::storage->lightmap_capture_get_bounds(p_instance->base);
+ new_aabb = RSG::storage->lightmap_capture_get_bounds(p_instance->base);
} break;
default: {
@@ -1281,7 +1281,7 @@ _FORCE_INLINE_ static Color _light_capture_voxel_cone_trace(const RasterizerStor
return Color(color.x, color.y, color.z, alpha);
}
-void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance) {
+void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instance) {
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
@@ -1313,12 +1313,12 @@ void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance)
//this could use some sort of blending..
for (List<Instance *>::Element *E = geom->lightmap_captures.front(); E; E = E->next()) {
- const Vector<RasterizerStorage::LightmapCaptureOctree> *octree = VSG::storage->lightmap_capture_get_octree_ptr(E->get()->base);
+ const Vector<RasterizerStorage::LightmapCaptureOctree> *octree = RSG::storage->lightmap_capture_get_octree_ptr(E->get()->base);
//print_line("octree size: " + itos(octree->size()));
if (octree->size() == 0)
continue;
- Transform to_cell_xform = VSG::storage->lightmap_capture_get_octree_cell_transform(E->get()->base);
- int cell_subdiv = VSG::storage->lightmap_capture_get_octree_cell_subdiv(E->get()->base);
+ Transform to_cell_xform = RSG::storage->lightmap_capture_get_octree_cell_transform(E->get()->base);
+ int cell_subdiv = RSG::storage->lightmap_capture_get_octree_cell_subdiv(E->get()->base);
to_cell_xform = to_cell_xform * E->get()->transform.affine_inverse();
const RasterizerStorage::LightmapCaptureOctree *octree_r = octree->ptr();
@@ -1334,7 +1334,7 @@ void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance)
}
}
-bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) {
+bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) {
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
@@ -1343,24 +1343,24 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
bool animated_material_found = false;
- switch (VSG::storage->light_get_type(p_instance->base)) {
+ switch (RSG::storage->light_get_type(p_instance->base)) {
- case VS::LIGHT_DIRECTIONAL: {
+ case RS::LIGHT_DIRECTIONAL: {
float max_distance = p_cam_projection.get_z_far();
- float shadow_max = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
+ float shadow_max = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
if (shadow_max > 0 && !p_cam_orthogonal) { //its impractical (and leads to unwanted behaviors) to set max distance in orthogonal camera
max_distance = MIN(shadow_max, max_distance);
}
max_distance = MAX(max_distance, p_cam_projection.get_z_near() + 0.001);
float min_distance = MIN(p_cam_projection.get_z_near(), max_distance);
- VS::LightDirectionalShadowDepthRangeMode depth_range_mode = VSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base);
+ RS::LightDirectionalShadowDepthRangeMode depth_range_mode = RSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base);
- if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) {
+ if (depth_range_mode == RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) {
//optimize min/max
Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform);
- int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK);
Plane base(p_cam_transform.origin, -p_cam_transform.basis.get_axis(2));
//check distance max and min
@@ -1371,7 +1371,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
for (int i = 0; i < cull_count; i++) {
Instance *instance = instance_shadow_cull_result[i];
- if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
continue;
}
@@ -1402,24 +1402,24 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
float range = max_distance - min_distance;
int splits = 0;
- switch (VSG::storage->light_directional_get_shadow_mode(p_instance->base)) {
- case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: splits = 1; break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: splits = 2; break;
- case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: splits = 4; break;
+ switch (RSG::storage->light_directional_get_shadow_mode(p_instance->base)) {
+ case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: splits = 1; break;
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: splits = 2; break;
+ case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: splits = 4; break;
}
float distances[5];
distances[0] = min_distance;
for (int i = 0; i < splits; i++) {
- distances[i + 1] = min_distance + VSG::storage->light_get_param(p_instance->base, VS::LightParam(VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range;
+ distances[i + 1] = min_distance + RSG::storage->light_get_param(p_instance->base, RS::LightParam(RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range;
};
distances[splits] = max_distance;
- float texture_size = VSG::scene_render->get_directional_light_shadow_size(light->instance);
+ float texture_size = RSG::scene_render->get_directional_light_shadow_size(light->instance);
- bool overlap = VSG::storage->light_directional_get_blend_splits(p_instance->base);
+ bool overlap = RSG::storage->light_directional_get_blend_splits(p_instance->base);
float first_radius = 0.0;
@@ -1532,7 +1532,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
//z_max_cam = z_vec.dot(center) + radius;
z_min_cam = z_vec.dot(center) - radius;
- if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) {
+ if (depth_range_mode == RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) {
//this trick here is what stabilizes the shadow (make potential jaggies to not move)
//at the cost of some wasted resolution. Still the quality increase is very well worth it
@@ -1560,7 +1560,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
light_frustum_planes.write[4] = Plane(z_vec, z_max + 1e6);
light_frustum_planes.write[5] = Plane(-z_vec, -z_min); // z_min is ok, since casters further than far-light plane are not needed
- int cull_count = p_scenario->octree.cull_convex(light_frustum_planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(light_frustum_planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK);
// a pre pass will need to be needed to determine the actual z-near to be used
@@ -1570,7 +1570,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
float min, max;
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
@@ -1596,25 +1596,25 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
ortho_transform.basis = transform.basis;
ortho_transform.origin = x_vec * (x_min_cam + half_x) + y_vec * (y_min_cam + half_y) + z_vec * z_max;
- VSG::scene_render->light_instance_set_shadow_transform(light->instance, ortho_camera, ortho_transform, 0, distances[i + 1], i, bias_scale);
+ RSG::scene_render->light_instance_set_shadow_transform(light->instance, ortho_camera, ortho_transform, 0, distances[i + 1], i, bias_scale);
}
- VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
+ RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
}
} break;
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_OMNI: {
- VS::LightOmniShadowMode shadow_mode = VSG::storage->light_omni_get_shadow_mode(p_instance->base);
+ RS::LightOmniShadowMode shadow_mode = RSG::storage->light_omni_get_shadow_mode(p_instance->base);
- if (shadow_mode == VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !VSG::scene_render->light_instances_can_render_shadow_cube()) {
+ if (shadow_mode == RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !RSG::scene_render->light_instances_can_render_shadow_cube()) {
for (int i = 0; i < 2; i++) {
//using this one ensures that raster deferred will have it
RENDER_TIMESTAMP("Culling Shadow Paraboloid" + itos(i));
- float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
+ float radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE);
float z = i == 0 ? -1 : 1;
Vector<Plane> planes;
@@ -1625,13 +1625,13 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
planes.write[3] = light_transform.xform(Plane(Vector3(0, 1, z).normalized(), radius));
planes.write[4] = light_transform.xform(Plane(Vector3(0, -1, z).normalized(), radius));
- int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK);
Plane near_plane(light_transform.origin, light_transform.basis.get_axis(2) * z);
for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
@@ -1645,12 +1645,12 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
}
- VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, i);
- VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
+ RSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, i);
+ RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
}
} else { //shadow cube
- float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
+ float radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE);
CameraMatrix cm;
cm.set_perspective(90, 1, 0.01, radius);
@@ -1680,13 +1680,13 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
Vector<Plane> planes = cm.get_projection_planes(xform);
- int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK);
Plane near_plane(xform.origin, -xform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
@@ -1699,33 +1699,33 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
}
- VSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, xform, radius, 0, i);
- VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
+ RSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, xform, radius, 0, i);
+ RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
}
//restore the regular DP matrix
- VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, 0);
+ RSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, 0);
}
} break;
- case VS::LIGHT_SPOT: {
+ case RS::LIGHT_SPOT: {
RENDER_TIMESTAMP("Culling Spot Light");
- float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
- float angle = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ float radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE);
+ float angle = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SPOT_ANGLE);
CameraMatrix cm;
cm.set_perspective(angle * 2.0, 1.0, 0.01, radius);
Vector<Plane> planes = cm.get_projection_planes(light_transform);
- int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK);
Plane near_plane(light_transform.origin, -light_transform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
+ if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
@@ -1738,8 +1738,8 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
}
- VSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, light_transform, radius, 0, 0);
- VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, 0, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
+ RSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, light_transform, radius, 0, 0);
+ RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, 0, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
} break;
}
@@ -1747,7 +1747,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
return animated_material_found;
}
-void VisualServerScene::render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
+void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
// render to mono camera
#ifndef _3D_DISABLED
@@ -1798,7 +1798,7 @@ void VisualServerScene::render_camera(RID p_render_buffers, RID p_camera, RID p_
#endif
}
-void VisualServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
+void RenderingServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
// render for AR/VR interface
Camera *camera = camera_owner.getornull(p_camera);
@@ -1882,7 +1882,7 @@ void VisualServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> &
_render_scene(p_render_buffers, cam_transform, camera_matrix, false, camera->env, camera->effects, p_scenario, p_shadow_atlas, RID(), -1);
};
-void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, bool p_using_shadows) {
+void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, bool p_using_shadows) {
// Note, in stereo rendering:
// - p_cam_transform will be a transform in the middle of our two eyes
// - p_cam_projection is a wider frustrum that encompasses both eyes
@@ -1892,7 +1892,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
render_pass++;
uint32_t camera_layer_mask = p_visible_layers;
- VSG::scene_render->set_scene_pass(render_pass);
+ RSG::scene_render->set_scene_pass(render_pass);
RENDER_TIMESTAMP("Frustum Culling");
@@ -1932,7 +1932,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
if ((camera_layer_mask & ins->layer_mask) == 0) {
//failure
- } else if (ins->base_type == VS::INSTANCE_LIGHT && ins->visible) {
+ } else if (ins->base_type == RS::INSTANCE_LIGHT && ins->visible) {
if (light_cull_count < MAX_LIGHTS_CULLED) {
@@ -1942,14 +1942,14 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
//do not add this light if no geometry is affected by it..
light_cull_result[light_cull_count] = ins;
light_instance_cull_result[light_cull_count] = light->instance;
- if (p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(ins->base)) {
- VSG::scene_render->light_instance_mark_visible(light->instance); //mark it visible for shadow allocation later
+ if (p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(ins->base)) {
+ RSG::scene_render->light_instance_mark_visible(light->instance); //mark it visible for shadow allocation later
}
light_cull_count++;
}
}
- } else if (ins->base_type == VS::INSTANCE_REFLECTION_PROBE && ins->visible) {
+ } else if (ins->base_type == RS::INSTANCE_REFLECTION_PROBE && ins->visible) {
if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
@@ -1961,7 +1961,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
if (!reflection_probe->geometries.empty()) {
//do not add this light if no geometry is affected by it..
- if (reflection_probe->reflection_dirty || VSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) {
+ if (reflection_probe->reflection_dirty || RSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) {
if (!reflection_probe->update_list.in_list()) {
reflection_probe->render_step = 0;
reflection_probe_render_list.add_last(&reflection_probe->update_list);
@@ -1970,7 +1970,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
reflection_probe->reflection_dirty = false;
}
- if (VSG::scene_render->reflection_probe_instance_has_reflection(reflection_probe->instance)) {
+ if (RSG::scene_render->reflection_probe_instance_has_reflection(reflection_probe->instance)) {
reflection_probe_instance_cull_result[reflection_probe_cull_count] = reflection_probe->instance;
reflection_probe_cull_count++;
}
@@ -1978,7 +1978,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
}
}
- } else if (ins->base_type == VS::INSTANCE_GI_PROBE && ins->visible) {
+ } else if (ins->base_type == RS::INSTANCE_GI_PROBE && ins->visible) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(ins->base_data);
if (!gi_probe->update_element.in_list()) {
@@ -1990,25 +1990,25 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
gi_probe_cull_count++;
}
- } else if (((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
+ } else if (((1 << ins->base_type) & RS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
keep = true;
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
if (ins->redraw_if_visible) {
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
- if (ins->base_type == VS::INSTANCE_PARTICLES) {
+ if (ins->base_type == RS::INSTANCE_PARTICLES) {
//particles visible? process them
- if (VSG::storage->particles_is_inactive(ins->base)) {
+ if (RSG::storage->particles_is_inactive(ins->base)) {
//but if nothing is going on, don't do it.
keep = false;
} else {
- VSG::storage->particles_request_process(ins->base);
+ RSG::storage->particles_request_process(ins->base);
//particles visible? request redraw
- VisualServerRaster::redraw_request();
+ RenderingServerRaster::redraw_request();
}
}
@@ -2098,7 +2098,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
//check shadow..
if (light) {
- if (p_using_shadows && p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(E->get()->base)) {
+ if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->get()->base)) {
lights_with_shadow[directional_shadow_count++] = E->get();
}
//add to list
@@ -2106,7 +2106,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
}
}
- VSG::scene_render->set_directional_shadow_count(directional_shadow_count);
+ RSG::scene_render->set_directional_shadow_count(directional_shadow_count);
for (int i = 0; i < directional_shadow_count; i++) {
@@ -2126,7 +2126,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
Instance *ins = light_cull_result[i];
- if (!p_shadow_atlas.is_valid() || !VSG::storage->light_has_shadow(ins->base))
+ if (!p_shadow_atlas.is_valid() || !RSG::storage->light_has_shadow(ins->base))
continue;
InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
@@ -2142,11 +2142,11 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
// near plane half width and height
Vector2 vp_half_extents = p_cam_projection.get_viewport_half_extents();
- switch (VSG::storage->light_get_type(ins->base)) {
+ switch (RSG::storage->light_get_type(ins->base)) {
- case VS::LIGHT_OMNI: {
+ case RS::LIGHT_OMNI: {
- float radius = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_RANGE);
+ float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE);
//get two points parallel to near plane
Vector3 points[2] = {
@@ -2168,10 +2168,10 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
float screen_diameter = points[0].distance_to(points[1]) * 2;
coverage = screen_diameter / (vp_half_extents.x + vp_half_extents.y);
} break;
- case VS::LIGHT_SPOT: {
+ case RS::LIGHT_SPOT: {
- float radius = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_RANGE);
- float angle = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_SPOT_ANGLE);
+ float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE);
+ float angle = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_SPOT_ANGLE);
float w = radius * Math::sin(Math::deg2rad(angle));
float d = radius * Math::cos(Math::deg2rad(angle));
@@ -2209,7 +2209,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
light->shadow_dirty = false;
}
- bool redraw = VSG::scene_render->shadow_atlas_update_light(p_shadow_atlas, light->instance, coverage, light->last_version);
+ bool redraw = RSG::scene_render->shadow_atlas_update_light(p_shadow_atlas, light->instance, coverage, light->last_version);
if (redraw) {
//must redraw!
@@ -2221,7 +2221,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
}
}
-void VisualServerScene::_render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
+void RenderingServerScene::_render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
Scenario *scenario = scenario_owner.getornull(p_scenario);
@@ -2244,10 +2244,10 @@ void VisualServerScene::_render_scene(RID p_render_buffers, const Transform p_ca
/* PROCESS GEOMETRY AND DRAW SCENE */
RENDER_TIMESTAMP("Render Scene ");
- VSG::scene_render->render_scene(p_render_buffers, p_cam_transform, p_cam_projection, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, instance_cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, gi_probe_instance_cull_result, gi_probe_cull_count, environment, camera_effects, p_shadow_atlas, p_reflection_probe.is_valid() ? RID() : scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass);
+ RSG::scene_render->render_scene(p_render_buffers, p_cam_transform, p_cam_projection, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, instance_cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, gi_probe_instance_cull_result, gi_probe_cull_count, environment, camera_effects, p_shadow_atlas, p_reflection_probe.is_valid() ? RID() : scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass);
}
-void VisualServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) {
+void RenderingServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) {
#ifndef _3D_DISABLED
@@ -2259,21 +2259,21 @@ void VisualServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario,
else
environment = scenario->fallback_environment;
RENDER_TIMESTAMP("Render Empty Scene ");
- VSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, NULL, 0, NULL, 0, NULL, 0, NULL, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0);
+ RSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, NULL, 0, NULL, 0, NULL, 0, NULL, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0);
#endif
}
-bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) {
+bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
Scenario *scenario = p_instance->scenario;
ERR_FAIL_COND_V(!scenario, true);
- VisualServerRaster::redraw_request(); //update, so it updates in editor
+ RenderingServerRaster::redraw_request(); //update, so it updates in editor
if (p_step == 0) {
- if (!VSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) {
+ if (!RSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) {
return true; //all full
}
}
@@ -2297,9 +2297,9 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int
Vector3(0, -1, 0)
};
- Vector3 extents = VSG::storage->reflection_probe_get_extents(p_instance->base);
- Vector3 origin_offset = VSG::storage->reflection_probe_get_origin_offset(p_instance->base);
- float max_distance = VSG::storage->reflection_probe_get_origin_max_distance(p_instance->base);
+ Vector3 extents = RSG::storage->reflection_probe_get_extents(p_instance->base);
+ Vector3 origin_offset = RSG::storage->reflection_probe_get_origin_offset(p_instance->base);
+ float max_distance = RSG::storage->reflection_probe_get_origin_max_distance(p_instance->base);
Vector3 edge = view_normals[p_step] * extents;
float distance = ABS(view_normals[p_step].dot(edge) - view_normals[p_step].dot(origin_offset)); //distance from origin offset to actual view distance limit
@@ -2317,26 +2317,26 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int
RID shadow_atlas;
- bool use_shadows = VSG::storage->reflection_probe_renders_shadows(p_instance->base);
+ bool use_shadows = RSG::storage->reflection_probe_renders_shadows(p_instance->base);
if (use_shadows) {
shadow_atlas = scenario->reflection_probe_shadow_atlas;
}
RENDER_TIMESTAMP("Render Reflection Probe, Step " + itos(p_step));
- _prepare_scene(xform, cm, false, RID(), RID(), VSG::storage->reflection_probe_get_cull_mask(p_instance->base), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, use_shadows);
+ _prepare_scene(xform, cm, false, RID(), RID(), RSG::storage->reflection_probe_get_cull_mask(p_instance->base), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, use_shadows);
_render_scene(RID(), xform, cm, false, RID(), RID(), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, p_step);
} else {
//do roughness postprocess step until it believes it's done
RENDER_TIMESTAMP("Post-Process Reflection Probe, Step " + itos(p_step));
- return VSG::scene_render->reflection_probe_instance_postprocess_step(reflection_probe->instance);
+ return RSG::scene_render->reflection_probe_instance_postprocess_step(reflection_probe->instance);
}
return false;
}
-void VisualServerScene::render_probes() {
+void RenderingServerScene::render_probes() {
/* REFLECTION PROBES */
@@ -2349,9 +2349,9 @@ void VisualServerScene::render_probes() {
SelfList<InstanceReflectionProbeData> *next = ref_probe->next();
RID base = ref_probe->self()->owner->base;
- switch (VSG::storage->reflection_probe_get_update_mode(base)) {
+ switch (RSG::storage->reflection_probe_get_update_mode(base)) {
- case VS::REFLECTION_PROBE_UPDATE_ONCE: {
+ case RS::REFLECTION_PROBE_UPDATE_ONCE: {
if (busy) //already rendering something
break;
@@ -2364,7 +2364,7 @@ void VisualServerScene::render_probes() {
busy = true; //do not render another one of this kind
} break;
- case VS::REFLECTION_PROBE_UPDATE_ALWAYS: {
+ case RS::REFLECTION_PROBE_UPDATE_ALWAYS: {
int step = 0;
bool done = false;
@@ -2422,16 +2422,16 @@ void VisualServerScene::render_probes() {
if (
instance_caches[idx] != instance_light->instance ||
- cache->has_shadow != VSG::storage->light_has_shadow(instance->base) ||
- cache->type != VSG::storage->light_get_type(instance->base) ||
+ cache->has_shadow != RSG::storage->light_has_shadow(instance->base) ||
+ cache->type != RSG::storage->light_get_type(instance->base) ||
cache->transform != instance->transform ||
- cache->color != VSG::storage->light_get_color(instance->base) ||
- cache->energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY) ||
- cache->bake_energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY) ||
- cache->radius != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE) ||
- cache->attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION) ||
- cache->spot_angle != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE) ||
- cache->spot_attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION)) {
+ cache->color != RSG::storage->light_get_color(instance->base) ||
+ cache->energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY) ||
+ cache->bake_energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY) ||
+ cache->radius != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE) ||
+ cache->attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION) ||
+ cache->spot_angle != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE) ||
+ cache->spot_attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION)) {
cache_dirty = true;
}
}
@@ -2456,16 +2456,16 @@ void VisualServerScene::render_probes() {
if (
instance_caches[idx] != instance_light->instance ||
- cache->has_shadow != VSG::storage->light_has_shadow(instance->base) ||
- cache->type != VSG::storage->light_get_type(instance->base) ||
+ cache->has_shadow != RSG::storage->light_has_shadow(instance->base) ||
+ cache->type != RSG::storage->light_get_type(instance->base) ||
cache->transform != instance->transform ||
- cache->color != VSG::storage->light_get_color(instance->base) ||
- cache->energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY) ||
- cache->bake_energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY) ||
- cache->radius != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE) ||
- cache->attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION) ||
- cache->spot_angle != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE) ||
- cache->spot_attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION)) {
+ cache->color != RSG::storage->light_get_color(instance->base) ||
+ cache->energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY) ||
+ cache->bake_energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY) ||
+ cache->radius != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE) ||
+ cache->attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION) ||
+ cache->spot_angle != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE) ||
+ cache->spot_attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION)) {
cache_dirty = true;
}
}
@@ -2480,7 +2480,7 @@ void VisualServerScene::render_probes() {
cache_count = idx;
}
- bool update_lights = VSG::scene_render->gi_probe_needs_update(probe->probe_instance);
+ bool update_lights = RSG::scene_render->gi_probe_needs_update(probe->probe_instance);
if (cache_dirty) {
probe->light_cache.resize(cache_count);
@@ -2501,16 +2501,16 @@ void VisualServerScene::render_probes() {
InstanceGIProbeData::LightCache *cache = &caches[idx];
instance_caches[idx] = instance_light->instance;
- cache->has_shadow = VSG::storage->light_has_shadow(instance->base);
- cache->type = VSG::storage->light_get_type(instance->base);
+ cache->has_shadow = RSG::storage->light_has_shadow(instance->base);
+ cache->type = RSG::storage->light_get_type(instance->base);
cache->transform = instance->transform;
- cache->color = VSG::storage->light_get_color(instance->base);
- cache->energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY);
- cache->bake_energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY);
- cache->radius = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE);
- cache->attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION);
- cache->spot_angle = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE);
- cache->spot_attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION);
+ cache->color = RSG::storage->light_get_color(instance->base);
+ cache->energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY);
+ cache->bake_energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY);
+ cache->radius = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE);
+ cache->attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION);
+ cache->spot_angle = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE);
+ cache->spot_attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION);
idx++;
}
@@ -2524,16 +2524,16 @@ void VisualServerScene::render_probes() {
InstanceGIProbeData::LightCache *cache = &caches[idx];
instance_caches[idx] = instance_light->instance;
- cache->has_shadow = VSG::storage->light_has_shadow(instance->base);
- cache->type = VSG::storage->light_get_type(instance->base);
+ cache->has_shadow = RSG::storage->light_has_shadow(instance->base);
+ cache->type = RSG::storage->light_get_type(instance->base);
cache->transform = instance->transform;
- cache->color = VSG::storage->light_get_color(instance->base);
- cache->energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY);
- cache->bake_energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY);
- cache->radius = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE);
- cache->attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION);
- cache->spot_angle = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE);
- cache->spot_attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION);
+ cache->color = RSG::storage->light_get_color(instance->base);
+ cache->energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY);
+ cache->bake_energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY);
+ cache->radius = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE);
+ cache->attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION);
+ cache->spot_angle = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE);
+ cache->spot_attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION);
idx++;
}
@@ -2571,7 +2571,7 @@ void VisualServerScene::render_probes() {
}
}
- VSG::scene_render->gi_probe_update(probe->probe_instance, update_lights, probe->light_instances, instance_cull_count, (RasterizerScene::InstanceBase **)instance_cull_result);
+ RSG::scene_render->gi_probe_update(probe->probe_instance, update_lights, probe->light_instances, instance_cull_count, (RasterizerScene::InstanceBase **)instance_cull_result);
gi_probe_update_list.remove(gi_probe);
@@ -2579,7 +2579,7 @@ void VisualServerScene::render_probes() {
}
}
-void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
+void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
if (p_instance->update_aabb) {
_update_instance_aabb(p_instance);
@@ -2590,20 +2590,20 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
p_instance->instance_increase_version();
if (p_instance->base.is_valid()) {
- VSG::storage->base_update_dependency(p_instance->base, p_instance);
+ RSG::storage->base_update_dependency(p_instance->base, p_instance);
}
if (p_instance->material_override.is_valid()) {
- VSG::storage->material_update_dependency(p_instance->material_override, p_instance);
+ RSG::storage->material_update_dependency(p_instance->material_override, p_instance);
}
- if (p_instance->base_type == VS::INSTANCE_MESH) {
+ if (p_instance->base_type == RS::INSTANCE_MESH) {
//remove materials no longer used and un-own them
- int new_mat_count = VSG::storage->mesh_get_surface_count(p_instance->base);
+ int new_mat_count = RSG::storage->mesh_get_surface_count(p_instance->base);
p_instance->materials.resize(new_mat_count);
- int new_blend_shape_count = VSG::storage->mesh_get_blend_shape_count(p_instance->base);
+ int new_blend_shape_count = RSG::storage->mesh_get_blend_shape_count(p_instance->base);
if (new_blend_shape_count != p_instance->blend_values.size()) {
p_instance->blend_values.resize(new_blend_shape_count);
for (int i = 0; i < new_blend_shape_count; i++) {
@@ -2612,21 +2612,21 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
}
}
- if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
bool can_cast_shadows = true;
bool is_animated = false;
- if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) {
+ if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_OFF) {
can_cast_shadows = false;
} else if (p_instance->material_override.is_valid()) {
- can_cast_shadows = VSG::storage->material_casts_shadows(p_instance->material_override);
- is_animated = VSG::storage->material_is_animated(p_instance->material_override);
+ can_cast_shadows = RSG::storage->material_casts_shadows(p_instance->material_override);
+ is_animated = RSG::storage->material_is_animated(p_instance->material_override);
} else {
- if (p_instance->base_type == VS::INSTANCE_MESH) {
+ if (p_instance->base_type == RS::INSTANCE_MESH) {
RID mesh = p_instance->base;
if (mesh.is_valid()) {
@@ -2634,21 +2634,21 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
for (int i = 0; i < p_instance->materials.size(); i++) {
- RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : VSG::storage->mesh_surface_get_material(mesh, i);
+ RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : RSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
- if (VSG::storage->material_casts_shadows(mat)) {
+ if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
- if (VSG::storage->material_is_animated(mat)) {
+ if (RSG::storage->material_is_animated(mat)) {
is_animated = true;
}
- VSG::storage->material_update_dependency(mat, p_instance);
+ RSG::storage->material_update_dependency(mat, p_instance);
}
}
@@ -2657,30 +2657,30 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
}
}
- } else if (p_instance->base_type == VS::INSTANCE_MULTIMESH) {
- RID mesh = VSG::storage->multimesh_get_mesh(p_instance->base);
+ } else if (p_instance->base_type == RS::INSTANCE_MULTIMESH) {
+ RID mesh = RSG::storage->multimesh_get_mesh(p_instance->base);
if (mesh.is_valid()) {
bool cast_shadows = false;
- int sc = VSG::storage->mesh_get_surface_count(mesh);
+ int sc = RSG::storage->mesh_get_surface_count(mesh);
for (int i = 0; i < sc; i++) {
- RID mat = VSG::storage->mesh_surface_get_material(mesh, i);
+ RID mat = RSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
- if (VSG::storage->material_casts_shadows(mat)) {
+ if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
- if (VSG::storage->material_is_animated(mat)) {
+ if (RSG::storage->material_is_animated(mat)) {
is_animated = true;
}
- VSG::storage->material_update_dependency(mat, p_instance);
+ RSG::storage->material_update_dependency(mat, p_instance);
}
}
@@ -2688,52 +2688,52 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
can_cast_shadows = false;
}
- VSG::storage->base_update_dependency(mesh, p_instance);
+ RSG::storage->base_update_dependency(mesh, p_instance);
}
- } else if (p_instance->base_type == VS::INSTANCE_IMMEDIATE) {
+ } else if (p_instance->base_type == RS::INSTANCE_IMMEDIATE) {
- RID mat = VSG::storage->immediate_get_material(p_instance->base);
+ RID mat = RSG::storage->immediate_get_material(p_instance->base);
- can_cast_shadows = !mat.is_valid() || VSG::storage->material_casts_shadows(mat);
+ can_cast_shadows = !mat.is_valid() || RSG::storage->material_casts_shadows(mat);
- if (mat.is_valid() && VSG::storage->material_is_animated(mat)) {
+ if (mat.is_valid() && RSG::storage->material_is_animated(mat)) {
is_animated = true;
}
if (mat.is_valid()) {
- VSG::storage->material_update_dependency(mat, p_instance);
+ RSG::storage->material_update_dependency(mat, p_instance);
}
- } else if (p_instance->base_type == VS::INSTANCE_PARTICLES) {
+ } else if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
bool cast_shadows = false;
- int dp = VSG::storage->particles_get_draw_passes(p_instance->base);
+ int dp = RSG::storage->particles_get_draw_passes(p_instance->base);
for (int i = 0; i < dp; i++) {
- RID mesh = VSG::storage->particles_get_draw_pass_mesh(p_instance->base, i);
+ RID mesh = RSG::storage->particles_get_draw_pass_mesh(p_instance->base, i);
if (!mesh.is_valid())
continue;
- int sc = VSG::storage->mesh_get_surface_count(mesh);
+ int sc = RSG::storage->mesh_get_surface_count(mesh);
for (int j = 0; j < sc; j++) {
- RID mat = VSG::storage->mesh_surface_get_material(mesh, j);
+ RID mat = RSG::storage->mesh_surface_get_material(mesh, j);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
- if (VSG::storage->material_casts_shadows(mat)) {
+ if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
- if (VSG::storage->material_is_animated(mat)) {
+ if (RSG::storage->material_is_animated(mat)) {
is_animated = true;
}
- VSG::storage->material_update_dependency(mat, p_instance);
+ RSG::storage->material_update_dependency(mat, p_instance);
}
}
}
@@ -2758,7 +2758,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
}
if (p_instance->skeleton.is_valid()) {
- VSG::storage->skeleton_update_dependency(p_instance->skeleton, p_instance);
+ RSG::storage->skeleton_update_dependency(p_instance->skeleton, p_instance);
}
p_instance->clean_up_dependencies();
@@ -2772,9 +2772,9 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
p_instance->update_dependencies = false;
}
-void VisualServerScene::update_dirty_instances() {
+void RenderingServerScene::update_dirty_instances() {
- VSG::storage->update_dirty_resources();
+ RSG::storage->update_dirty_resources();
while (_instance_update_list.first()) {
@@ -2782,7 +2782,7 @@ void VisualServerScene::update_dirty_instances() {
}
}
-bool VisualServerScene::free(RID p_rid) {
+bool RenderingServerScene::free(RID p_rid) {
if (camera_owner.owns(p_rid)) {
@@ -2798,8 +2798,8 @@ bool VisualServerScene::free(RID p_rid) {
while (scenario->instances.first()) {
instance_set_scenario(scenario->instances.first()->self()->self, RID());
}
- VSG::scene_render->free(scenario->reflection_probe_shadow_atlas);
- VSG::scene_render->free(scenario->reflection_atlas);
+ RSG::scene_render->free(scenario->reflection_probe_shadow_atlas);
+ RSG::scene_render->free(scenario->reflection_atlas);
scenario_owner.free(p_rid);
memdelete(scenario);
@@ -2827,13 +2827,13 @@ bool VisualServerScene::free(RID p_rid) {
return true;
}
-VisualServerScene *VisualServerScene::singleton = NULL;
+RenderingServerScene *RenderingServerScene::singleton = NULL;
-VisualServerScene::VisualServerScene() {
+RenderingServerScene::RenderingServerScene() {
render_pass = 1;
singleton = this;
}
-VisualServerScene::~VisualServerScene() {
+RenderingServerScene::~RenderingServerScene() {
}
diff --git a/servers/visual/visual_server_scene.h b/servers/rendering/rendering_server_scene.h
index 8dbd60d3ff..9e09136216 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/rendering/rendering_server_scene.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_scene.h */
+/* rendering_server_scene.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -31,7 +31,7 @@
#ifndef VISUALSERVERSCENE_H
#define VISUALSERVERSCENE_H
-#include "servers/visual/rasterizer.h"
+#include "servers/rendering/rasterizer.h"
#include "core/math/geometry.h"
#include "core/math/octree.h"
@@ -41,7 +41,7 @@
#include "core/self_list.h"
#include "servers/arvr/arvr_interface.h"
-class VisualServerScene {
+class RenderingServerScene {
public:
enum {
@@ -55,7 +55,7 @@ public:
uint64_t render_pass;
- static VisualServerScene *singleton;
+ static RenderingServerScene *singleton;
/* CAMERA API */
@@ -109,7 +109,7 @@ public:
struct Scenario {
- VS::ScenarioDebugMode debug;
+ RS::ScenarioDebugMode debug;
RID self;
Octree<Instance, true> octree;
@@ -123,7 +123,7 @@ public:
SelfList<Instance>::List instances;
- Scenario() { debug = VS::SCENARIO_DEBUG_DISABLED; }
+ Scenario() { debug = RS::SCENARIO_DEBUG_DISABLED; }
};
mutable RID_PtrOwner<Scenario> scenario_owner;
@@ -133,7 +133,7 @@ public:
virtual RID scenario_create();
- virtual void scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode);
+ virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode);
virtual void scenario_set_environment(RID p_scenario, RID p_environment);
virtual void scenario_set_camera_effects(RID p_scenario, RID p_fx);
virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment);
@@ -323,7 +323,7 @@ public:
struct LightCache {
- VS::LightType type;
+ RS::LightType type;
Transform transform;
Color color;
float energy;
@@ -406,8 +406,8 @@ public:
virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const;
- virtual void instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled);
- virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting);
+ virtual void instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled);
+ virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting);
virtual void instance_geometry_set_material_override(RID p_instance, RID p_material);
virtual void instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin);
@@ -433,8 +433,8 @@ public:
bool free(RID p_rid);
- VisualServerScene();
- virtual ~VisualServerScene();
+ RenderingServerScene();
+ virtual ~RenderingServerScene();
};
#endif // VISUALSERVERSCENE_H
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/rendering/rendering_server_viewport.cpp
index 43262042cc..f80b914760 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/rendering/rendering_server_viewport.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_viewport.cpp */
+/* rendering_server_viewport.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_server_viewport.h"
+#include "rendering_server_viewport.h"
#include "core/project_settings.h"
-#include "visual_server_canvas.h"
-#include "visual_server_globals.h"
-#include "visual_server_scene.h"
+#include "rendering_server_canvas.h"
+#include "rendering_server_globals.h"
+#include "rendering_server_scene.h"
-static Transform2D _canvas_get_transform(VisualServerViewport::Viewport *p_viewport, VisualServerCanvas::Canvas *p_canvas, VisualServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) {
+static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_viewport, RenderingServerCanvas::Canvas *p_canvas, RenderingServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) {
Transform2D xf = p_viewport->global_transform;
@@ -47,7 +47,7 @@ static Transform2D _canvas_get_transform(VisualServerViewport::Viewport *p_viewp
xf = xf * p_canvas_data->transform;
- if (scale != 1.0 && !VSG::canvas->disable_scale) {
+ if (scale != 1.0 && !RSG::canvas->disable_scale) {
Vector2 pivot = p_vp_size * 0.5;
Transform2D xfpivot;
xfpivot.set_origin(pivot);
@@ -62,7 +62,7 @@ static Transform2D _canvas_get_transform(VisualServerViewport::Viewport *p_viewp
return xf;
}
-void VisualServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
+void RenderingServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
RENDER_TIMESTAMP(">Begin Rendering 3D Scene");
@@ -72,51 +72,51 @@ void VisualServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_
}
if (p_viewport->use_arvr && arvr_interface.is_valid()) {
- VSG::scene->render_camera(p_viewport->render_buffers, arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
+ RSG::scene->render_camera(p_viewport->render_buffers, arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
} else {
- VSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
+ RSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
}
RENDER_TIMESTAMP("<End Rendering 3D Scene");
}
-void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
+void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
/* Camera should always be BEFORE any other 3D */
bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front
int scenario_canvas_max_layer = 0;
- Color bgcolor = VSG::storage->get_default_clear_color();
+ Color bgcolor = RSG::storage->get_default_clear_color();
- if (!p_viewport->hide_canvas && !p_viewport->disable_environment && VSG::scene->scenario_owner.owns(p_viewport->scenario)) {
+ if (!p_viewport->hide_canvas && !p_viewport->disable_environment && RSG::scene->scenario_owner.owns(p_viewport->scenario)) {
- VisualServerScene::Scenario *scenario = VSG::scene->scenario_owner.getornull(p_viewport->scenario);
+ RenderingServerScene::Scenario *scenario = RSG::scene->scenario_owner.getornull(p_viewport->scenario);
ERR_FAIL_COND(!scenario);
- if (VSG::scene_render->is_environment(scenario->environment)) {
- scenario_draw_canvas_bg = VSG::scene_render->environment_get_background(scenario->environment) == VS::ENV_BG_CANVAS;
+ if (RSG::scene_render->is_environment(scenario->environment)) {
+ scenario_draw_canvas_bg = RSG::scene_render->environment_get_background(scenario->environment) == RS::ENV_BG_CANVAS;
- scenario_canvas_max_layer = VSG::scene_render->environment_get_canvas_max_layer(scenario->environment);
+ scenario_canvas_max_layer = RSG::scene_render->environment_get_canvas_max_layer(scenario->environment);
}
}
- bool can_draw_3d = VSG::scene->camera_owner.owns(p_viewport->camera);
+ bool can_draw_3d = RSG::scene->camera_owner.owns(p_viewport->camera);
- if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) {
+ if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) {
if (p_viewport->transparent_bg) {
bgcolor = Color(0, 0, 0, 0);
}
- if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
- p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER;
+ if (p_viewport->clear_mode == RS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
+ p_viewport->clear_mode = RS::VIEWPORT_CLEAR_NEVER;
}
}
if ((scenario_draw_canvas_bg || can_draw_3d) && !p_viewport->render_buffers.is_valid()) {
//wants to draw 3D but there is no render buffer, create
- p_viewport->render_buffers = VSG::scene_render->render_buffers_create();
- VSG::scene_render->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, p_viewport->size.width, p_viewport->size.height, p_viewport->msaa);
+ p_viewport->render_buffers = RSG::scene_render->render_buffers_create();
+ RSG::scene_render->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, p_viewport->size.width, p_viewport->size.height, p_viewport->msaa);
}
- VSG::storage->render_target_request_clear(p_viewport->render_target, bgcolor);
+ RSG::storage->render_target_request_clear(p_viewport->render_target, bgcolor);
if (!scenario_draw_canvas_bg && can_draw_3d) {
_draw_3d(p_viewport, p_eye);
@@ -138,7 +138,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
RENDER_TIMESTAMP("Cull Canvas Lights");
for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas);
+ RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
@@ -149,7 +149,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
RasterizerCanvas::Light *cl = F->get();
if (cl->enabled && cl->texture.is_valid()) {
//not super efficient..
- Size2 tsize = VSG::storage->texture_size_with_proxy(cl->texture);
+ Size2 tsize = RSG::storage->texture_size_with_proxy(cl->texture);
tsize *= cl->scale;
Vector2 offset = tsize / 2.0;
@@ -177,7 +177,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
lights_with_shadow = cl;
cl->radius_cache = cl->rect_cache.size.length();
}
- if (cl->mode == VS::CANVAS_LIGHT_MODE_MASK) {
+ if (cl->mode == RS::CANVAS_LIGHT_MODE_MASK) {
cl->mask_next_ptr = lights_with_mask;
lights_with_mask = cl;
}
@@ -186,7 +186,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
}
//guess this is not needed, but keeping because it may be
- //VSG::canvas_render->light_internal_update(cl->light_internal, cl);
+ //RSG::canvas_render->light_internal_update(cl->light_internal, cl);
}
}
@@ -204,7 +204,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
//make list of occluders
for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
- VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas);
+ RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
@@ -226,17 +226,17 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
RENDER_TIMESTAMP("Render Shadow");
- VSG::canvas_render->light_update_shadow(light->light_internal, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders);
+ RSG::canvas_render->light_update_shadow(light->light_internal, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders);
light = light->shadows_next_ptr;
}
- //VSG::canvas_render->reset_canvas();
+ //RSG::canvas_render->reset_canvas();
RENDER_TIMESTAMP("<End rendering 2D Shadows");
}
if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().get_layer() > scenario_canvas_max_layer) {
if (!can_draw_3d) {
- VSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
+ RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else {
_draw_3d(p_viewport, p_eye);
}
@@ -245,7 +245,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) {
- VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get()->canvas);
+ RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get()->canvas);
Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size);
@@ -260,12 +260,12 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
ptr = ptr->filter_next_ptr;
}
- VSG::canvas->render_canvas(p_viewport->render_target, canvas, xform, canvas_lights, lights_with_mask, clip_rect);
+ RSG::canvas->render_canvas(p_viewport->render_target, canvas, xform, canvas_lights, lights_with_mask, clip_rect);
i++;
if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) {
if (!can_draw_3d) {
- VSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
+ RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else {
_draw_3d(p_viewport, p_eye);
}
@@ -276,22 +276,22 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
if (scenario_draw_canvas_bg) {
if (!can_draw_3d) {
- VSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
+ RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else {
_draw_3d(p_viewport, p_eye);
}
}
- //VSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow);
+ //RSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow);
}
- if (VSG::storage->render_target_is_clear_requested(p_viewport->render_target)) {
+ if (RSG::storage->render_target_is_clear_requested(p_viewport->render_target)) {
//was never cleared in the end, force clear it
- VSG::storage->render_target_do_clear_request(p_viewport->render_target);
+ RSG::storage->render_target_do_clear_request(p_viewport->render_target);
}
}
-void VisualServerViewport::draw_viewports() {
+void RenderingServerViewport::draw_viewports() {
#if 0
// get our arvr interface in case we need it
@@ -312,15 +312,18 @@ void VisualServerViewport::draw_viewports() {
//sort viewports
active_viewports.sort_custom<ViewportSort>();
- Map<int, Vector<Rasterizer::BlitToScreen>> blit_to_screen_list;
+ Map<DisplayServer::WindowID, Vector<Rasterizer::BlitToScreen>> blit_to_screen_list;
//draw viewports
RENDER_TIMESTAMP(">Render Viewports");
- for (int i = 0; i < active_viewports.size(); i++) {
+ //determine what is visible
+ draw_viewports_pass++;
+
+ for (int i = active_viewports.size() - 1; i >= 0; i--) { //to compute parent dependency, must go in reverse draw order
Viewport *vp = active_viewports[i];
- if (vp->update_mode == VS::VIEWPORT_UPDATE_DISABLED)
+ if (vp->update_mode == RS::VIEWPORT_UPDATE_DISABLED)
continue;
if (!vp->render_target.is_valid()) {
@@ -328,29 +331,55 @@ void VisualServerViewport::draw_viewports() {
}
//ERR_CONTINUE(!vp->render_target.is_valid());
- bool visible = vp->viewport_to_screen_rect != Rect2() || vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE || (vp->update_mode == VS::VIEWPORT_UPDATE_WHEN_VISIBLE && VSG::storage->render_target_was_used(vp->render_target));
+ bool visible = vp->viewport_to_screen_rect != Rect2();
+
+ if (vp->update_mode == RS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) {
+ visible = true;
+ }
+
+ if (vp->update_mode == RS::VIEWPORT_UPDATE_WHEN_VISIBLE && RSG::storage->render_target_was_used(vp->render_target)) {
+ visible = true;
+ }
+
+ if (vp->update_mode == RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE) {
+ Viewport *parent = viewport_owner.getornull(vp->parent);
+ if (parent && parent->last_pass == draw_viewports_pass) {
+ visible = true;
+ }
+ }
+
visible = visible && vp->size.x > 1 && vp->size.y > 1;
- if (!visible)
- continue;
+ if (visible) {
+ vp->last_pass = draw_viewports_pass;
+ }
+ }
+
+ for (int i = 0; i < active_viewports.size(); i++) {
+
+ Viewport *vp = active_viewports[i];
+
+ if (vp->last_pass != draw_viewports_pass) {
+ continue; //should not draw
+ }
RENDER_TIMESTAMP(">Rendering Viewport " + itos(i));
- VSG::storage->render_target_set_as_unused(vp->render_target);
+ RSG::storage->render_target_set_as_unused(vp->render_target);
#if 0
if (vp->use_arvr && arvr_interface.is_valid()) {
// override our size, make sure it matches our required size
vp->size = arvr_interface->get_render_targetsize();
- VSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y);
+ RSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y);
// render mono or left eye first
ARVRInterface::Eyes leftOrMono = arvr_interface->is_stereo() ? ARVRInterface::EYE_LEFT : ARVRInterface::EYE_MONO;
// check for an external texture destination for our left eye/mono
- VSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(leftOrMono));
+ RSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(leftOrMono));
// set our render target as current
- VSG::rasterizer->set_current_render_target(vp->render_target);
+ RSG::rasterizer->set_current_render_target(vp->render_target);
// and draw left eye/mono
_draw_viewport(vp, leftOrMono);
@@ -359,10 +388,10 @@ void VisualServerViewport::draw_viewports() {
// render right eye
if (leftOrMono == ARVRInterface::EYE_LEFT) {
// check for an external texture destination for our right eye
- VSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(ARVRInterface::EYE_RIGHT));
+ RSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(ARVRInterface::EYE_RIGHT));
// commit for eye may have changed the render target
- VSG::rasterizer->set_current_render_target(vp->render_target);
+ RSG::rasterizer->set_current_render_target(vp->render_target);
_draw_viewport(vp, ARVRInterface::EYE_RIGHT);
arvr_interface->commit_for_eye(ARVRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect);
@@ -373,27 +402,32 @@ void VisualServerViewport::draw_viewports() {
} else {
#endif
{
- VSG::storage->render_target_set_external_texture(vp->render_target, 0);
+ RSG::storage->render_target_set_external_texture(vp->render_target, 0);
- VSG::scene_render->set_debug_draw_mode(vp->debug_draw);
- VSG::storage->render_info_begin_capture();
+ RSG::scene_render->set_debug_draw_mode(vp->debug_draw);
+ RSG::storage->render_info_begin_capture();
// render standard mono camera
_draw_viewport(vp);
- VSG::storage->render_info_end_capture();
- vp->render_info[VS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_OBJECTS_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_VERTICES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
- vp->render_info[VS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
+ RSG::storage->render_info_end_capture();
+ vp->render_info[RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_OBJECTS_IN_FRAME);
+ vp->render_info[RS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_VERTICES_IN_FRAME);
+ vp->render_info[RS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_MATERIAL_CHANGES_IN_FRAME);
+ vp->render_info[RS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_SHADER_CHANGES_IN_FRAME);
+ vp->render_info[RS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_SURFACE_CHANGES_IN_FRAME);
+ vp->render_info[RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_DRAW_CALLS_IN_FRAME);
- if (vp->viewport_to_screen_rect != Rect2() && (!vp->viewport_render_direct_to_screen || !VSG::rasterizer->is_low_end())) {
+ if (vp->viewport_to_screen != DisplayServer::INVALID_WINDOW_ID && (!vp->viewport_render_direct_to_screen || !RSG::rasterizer->is_low_end())) {
//copy to screen if set as such
Rasterizer::BlitToScreen blit;
blit.render_target = vp->render_target;
- blit.rect = vp->viewport_to_screen_rect;
+ if (vp->viewport_to_screen_rect != Rect2()) {
+ blit.rect = vp->viewport_to_screen_rect;
+ } else {
+ blit.rect.position = Vector2();
+ blit.rect.size = vp->size;
+ }
if (!blit_to_screen_list.has(vp->viewport_to_screen)) {
blit_to_screen_list[vp->viewport_to_screen] = Vector<Rasterizer::BlitToScreen>();
@@ -403,24 +437,24 @@ void VisualServerViewport::draw_viewports() {
}
}
- if (vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) {
- vp->update_mode = VS::VIEWPORT_UPDATE_DISABLED;
+ if (vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) {
+ vp->update_mode = RS::VIEWPORT_UPDATE_DISABLED;
}
RENDER_TIMESTAMP("<Rendering Viewport " + itos(i));
}
- VSG::scene_render->set_debug_draw_mode(VS::VIEWPORT_DEBUG_DRAW_DISABLED);
+ RSG::scene_render->set_debug_draw_mode(RS::VIEWPORT_DEBUG_DRAW_DISABLED);
RENDER_TIMESTAMP("<Render Viewports");
//this needs to be called to make screen swapping more efficient
- VSG::rasterizer->prepare_for_blitting_render_targets();
+ RSG::rasterizer->prepare_for_blitting_render_targets();
for (Map<int, Vector<Rasterizer::BlitToScreen>>::Element *E = blit_to_screen_list.front(); E; E = E->next()) {
- VSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size());
+ RSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size());
}
}
-RID VisualServerViewport::viewport_create() {
+RID RenderingServerViewport::viewport_create() {
Viewport *viewport = memnew(Viewport);
@@ -429,38 +463,40 @@ RID VisualServerViewport::viewport_create() {
viewport->self = rid;
viewport->hide_scenario = false;
viewport->hide_canvas = false;
- viewport->render_target = VSG::storage->render_target_create();
- viewport->shadow_atlas = VSG::scene_render->shadow_atlas_create();
+ viewport->render_target = RSG::storage->render_target_create();
+ viewport->shadow_atlas = RSG::scene_render->shadow_atlas_create();
viewport->viewport_render_direct_to_screen = false;
return rid;
}
-void VisualServerViewport::viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) {
+void RenderingServerViewport::viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->use_arvr = p_use_arvr;
}
-void VisualServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
+void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
ERR_FAIL_COND(p_width < 0 && p_height < 0);
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- // if (viewport->size.width == p_width && viewport->size.height == p_height) {
- // return; //nothing to do
- // }
viewport->size = Size2(p_width, p_height);
- VSG::storage->render_target_set_size(viewport->render_target, p_width, p_height);
+ RSG::storage->render_target_set_size(viewport->render_target, p_width, p_height);
if (viewport->render_buffers.is_valid()) {
- VSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa);
+ if (p_width == 0 || p_height == 0) {
+ RSG::scene_render->free(viewport->render_buffers);
+ viewport->render_buffers = RID();
+ } else {
+ RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa);
+ }
}
}
-void VisualServerViewport::viewport_set_active(RID p_viewport, bool p_active) {
+void RenderingServerViewport::viewport_set_active(RID p_viewport, bool p_active) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -473,7 +509,7 @@ void VisualServerViewport::viewport_set_active(RID p_viewport, bool p_active) {
}
}
-void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
+void RenderingServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -481,7 +517,7 @@ void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_pa
viewport->parent = p_parent_viewport;
}
-void VisualServerViewport::viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode) {
+void RenderingServerViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -489,24 +525,37 @@ void VisualServerViewport::viewport_set_clear_mode(RID p_viewport, VS::ViewportC
viewport->clear_mode = p_clear_mode;
}
-void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, int p_screen) {
+void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- // If using GLES2 we can optimize this operation by rendering directly to system_fbo
- // instead of rendering to fbo and copying to system_fbo after
- if (VSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
+ if (p_screen != DisplayServer::INVALID_WINDOW_ID) {
+ // If using GLES2 we can optimize this operation by rendering directly to system_fbo
+ // instead of rendering to fbo and copying to system_fbo after
+ if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
- VSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y);
- VSG::storage->render_target_set_position(viewport->render_target, p_rect.position.x, p_rect.position.y);
- }
+ RSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y);
+ RSG::storage->render_target_set_position(viewport->render_target, p_rect.position.x, p_rect.position.y);
+ }
+
+ viewport->viewport_to_screen_rect = p_rect;
+ viewport->viewport_to_screen = p_screen;
+ } else {
+
+ // if render_direct_to_screen was used, reset size and position
+ if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
+
+ RSG::storage->render_target_set_position(viewport->render_target, 0, 0);
+ RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y);
+ }
- viewport->viewport_to_screen_rect = p_rect;
- viewport->viewport_to_screen = p_screen;
+ viewport->viewport_to_screen_rect = Rect2();
+ viewport->viewport_to_screen = DisplayServer::INVALID_WINDOW_ID;
+ }
}
-void VisualServerViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) {
+void RenderingServerViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -516,38 +565,22 @@ void VisualServerViewport::viewport_set_render_direct_to_screen(RID p_viewport,
// if disabled, reset render_target size and position
if (!p_enable) {
- VSG::storage->render_target_set_position(viewport->render_target, 0, 0);
- VSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y);
+ RSG::storage->render_target_set_position(viewport->render_target, 0, 0);
+ RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y);
}
- VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN, p_enable);
+ RSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN, p_enable);
viewport->viewport_render_direct_to_screen = p_enable;
// if attached to screen already, setup screen size and position, this needs to happen after setting flag to avoid an unnecessary buffer allocation
- if (VSG::rasterizer->is_low_end() && viewport->viewport_to_screen_rect != Rect2() && p_enable) {
-
- VSG::storage->render_target_set_size(viewport->render_target, viewport->viewport_to_screen_rect.size.x, viewport->viewport_to_screen_rect.size.y);
- VSG::storage->render_target_set_position(viewport->render_target, viewport->viewport_to_screen_rect.position.x, viewport->viewport_to_screen_rect.position.y);
- }
-}
-
-void VisualServerViewport::viewport_detach(RID p_viewport) {
+ if (RSG::rasterizer->is_low_end() && viewport->viewport_to_screen_rect != Rect2() && p_enable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
- ERR_FAIL_COND(!viewport);
-
- // if render_direct_to_screen was used, reset size and position
- if (VSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
-
- VSG::storage->render_target_set_position(viewport->render_target, 0, 0);
- VSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y);
+ RSG::storage->render_target_set_size(viewport->render_target, viewport->viewport_to_screen_rect.size.x, viewport->viewport_to_screen_rect.size.y);
+ RSG::storage->render_target_set_position(viewport->render_target, viewport->viewport_to_screen_rect.position.x, viewport->viewport_to_screen_rect.position.y);
}
-
- viewport->viewport_to_screen_rect = Rect2();
- viewport->viewport_to_screen = 0;
}
-void VisualServerViewport::viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode) {
+void RenderingServerViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -555,29 +588,29 @@ void VisualServerViewport::viewport_set_update_mode(RID p_viewport, VS::Viewport
viewport->update_mode = p_mode;
}
-RID VisualServerViewport::viewport_get_texture(RID p_viewport) const {
+RID RenderingServerViewport::viewport_get_texture(RID p_viewport) const {
const Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
- return VSG::storage->render_target_get_texture(viewport->render_target);
+ return RSG::storage->render_target_get_texture(viewport->render_target);
}
-void VisualServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) {
+void RenderingServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->hide_scenario = p_hide;
}
-void VisualServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) {
+void RenderingServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->hide_canvas = p_hide;
}
-void VisualServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
+void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -585,27 +618,27 @@ void VisualServerViewport::viewport_set_disable_environment(RID p_viewport, bool
viewport->disable_environment = p_disable;
}
-void VisualServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
+void RenderingServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->camera = p_camera;
}
-void VisualServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
+void RenderingServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->scenario = p_scenario;
}
-void VisualServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
+void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(viewport->canvas_map.has(p_canvas));
- VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas);
+ RenderingServerCanvas::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->viewports.insert(p_viewport);
@@ -615,18 +648,18 @@ void VisualServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas)
viewport->canvas_map[p_canvas].canvas = canvas;
}
-void VisualServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
+void RenderingServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas);
+ RenderingServerCanvas::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
viewport->canvas_map.erase(p_canvas);
canvas->viewports.erase(p_viewport);
}
-void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
+void RenderingServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -634,23 +667,23 @@ void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_c
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
viewport->canvas_map[p_canvas].transform = p_offset;
}
-void VisualServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
+void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled);
+ RSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled);
viewport->transparent_bg = p_enabled;
}
-void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
+void RenderingServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->global_transform = p_transform;
}
-void VisualServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
+void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -660,25 +693,25 @@ void VisualServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_ca
viewport->canvas_map[p_canvas].sublayer = p_sublayer;
}
-void VisualServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) {
+void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->shadow_atlas_size = p_size;
- VSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size);
+ RSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size);
}
-void VisualServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
+void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- VSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
+ RSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
}
-void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa) {
+void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -688,13 +721,13 @@ void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_
}
viewport->msaa = p_msaa;
if (viewport->render_buffers.is_valid()) {
- VSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, p_msaa);
+ RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, p_msaa);
}
}
-int VisualServerViewport::viewport_get_render_info(RID p_viewport, VS::ViewportRenderInfo p_info) {
+int RenderingServerViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfo p_info) {
- ERR_FAIL_INDEX_V(p_info, VS::VIEWPORT_RENDER_INFO_MAX, -1);
+ ERR_FAIL_INDEX_V(p_info, RS::VIEWPORT_RENDER_INFO_MAX, -1);
Viewport *viewport = viewport_owner.getornull(p_viewport);
if (!viewport)
@@ -703,7 +736,7 @@ int VisualServerViewport::viewport_get_render_info(RID p_viewport, VS::ViewportR
return viewport->render_info[p_info];
}
-void VisualServerViewport::viewport_set_debug_draw(RID p_viewport, VS::ViewportDebugDraw p_draw) {
+void RenderingServerViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -711,16 +744,16 @@ void VisualServerViewport::viewport_set_debug_draw(RID p_viewport, VS::ViewportD
viewport->debug_draw = p_draw;
}
-bool VisualServerViewport::free(RID p_rid) {
+bool RenderingServerViewport::free(RID p_rid) {
if (viewport_owner.owns(p_rid)) {
Viewport *viewport = viewport_owner.getornull(p_rid);
- VSG::storage->free(viewport->render_target);
- VSG::scene_render->free(viewport->shadow_atlas);
+ RSG::storage->free(viewport->render_target);
+ RSG::scene_render->free(viewport->shadow_atlas);
if (viewport->render_buffers.is_valid()) {
- VSG::scene_render->free(viewport->render_buffers);
+ RSG::scene_render->free(viewport->render_buffers);
}
while (viewport->canvas_map.front()) {
@@ -739,9 +772,9 @@ bool VisualServerViewport::free(RID p_rid) {
return false;
}
-void VisualServerViewport::set_default_clear_color(const Color &p_color) {
- VSG::storage->set_default_clear_color(p_color);
+void RenderingServerViewport::set_default_clear_color(const Color &p_color) {
+ RSG::storage->set_default_clear_color(p_color);
}
-VisualServerViewport::VisualServerViewport() {
+RenderingServerViewport::RenderingServerViewport() {
}
diff --git a/servers/visual/visual_server_viewport.h b/servers/rendering/rendering_server_viewport.h
index 30b53f3935..f574c58d96 100644
--- a/servers/visual/visual_server_viewport.h
+++ b/servers/rendering/rendering_server_viewport.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_viewport.h */
+/* rendering_server_viewport.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,9 +35,9 @@
#include "core/self_list.h"
#include "rasterizer.h"
#include "servers/arvr/arvr_interface.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
-class VisualServerViewport {
+class RenderingServerViewport {
public:
struct CanvasBase {
};
@@ -53,14 +53,14 @@ public:
RID camera;
RID scenario;
- VS::ViewportUpdateMode update_mode;
+ RS::ViewportUpdateMode update_mode;
RID render_target;
RID render_target_texture;
RID render_buffers;
- VS::ViewportMSAA msaa;
+ RS::ViewportMSAA msaa;
- int viewport_to_screen;
+ DisplayServer::WindowID viewport_to_screen;
Rect2 viewport_to_screen_rect;
bool viewport_render_direct_to_screen;
@@ -73,10 +73,12 @@ public:
RID shadow_atlas;
int shadow_atlas_size;
- int render_info[VS::VIEWPORT_RENDER_INFO_MAX];
- VS::ViewportDebugDraw debug_draw;
+ uint64_t last_pass = 0;
- VS::ViewportClearMode clear_mode;
+ int render_info[RS::VIEWPORT_RENDER_INFO_MAX];
+ RS::ViewportDebugDraw debug_draw;
+
+ RS::ViewportClearMode clear_mode;
bool transparent_bg;
@@ -113,22 +115,24 @@ public:
Map<RID, CanvasData> canvas_map;
Viewport() {
- update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE;
- clear_mode = VS::VIEWPORT_CLEAR_ALWAYS;
+ update_mode = RS::VIEWPORT_UPDATE_WHEN_VISIBLE;
+ clear_mode = RS::VIEWPORT_CLEAR_ALWAYS;
transparent_bg = false;
disable_environment = false;
- viewport_to_screen = 0;
+ viewport_to_screen = DisplayServer::INVALID_WINDOW_ID;
shadow_atlas_size = 0;
keep_3d_linear = false;
- debug_draw = VS::VIEWPORT_DEBUG_DRAW_DISABLED;
- msaa = VS::VIEWPORT_MSAA_DISABLED;
- for (int i = 0; i < VS::VIEWPORT_RENDER_INFO_MAX; i++) {
+ debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED;
+ msaa = RS::VIEWPORT_MSAA_DISABLED;
+ for (int i = 0; i < RS::VIEWPORT_RENDER_INFO_MAX; i++) {
render_info[i] = 0;
}
use_arvr = false;
}
};
+ uint64_t draw_viewports_pass = 0;
+
mutable RID_PtrOwner<Viewport> viewport_owner;
struct ViewportSort {
@@ -139,9 +143,9 @@ public:
if (left_to_screen == right_to_screen) {
- return p_left->parent == p_right->self;
+ return p_right->parent == p_left->self;
}
- return right_to_screen;
+ return (right_to_screen ? 0 : 1) < (left_to_screen ? 0 : 1);
}
};
@@ -158,16 +162,15 @@ public:
void viewport_set_size(RID p_viewport, int p_width, int p_height);
- void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), int p_screen = 0);
+ void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), DisplayServer::WindowID p_screen = DisplayServer::MAIN_WINDOW_ID);
void viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable);
- void viewport_detach(RID p_viewport);
void viewport_set_active(RID p_viewport, bool p_active);
void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport);
- void viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode);
+ void viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode);
void viewport_set_vflip(RID p_viewport, bool p_enable);
- void viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode);
+ void viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode);
RID viewport_get_texture(RID p_viewport) const;
@@ -188,18 +191,18 @@ public:
void viewport_set_shadow_atlas_size(RID p_viewport, int p_size);
void viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv);
- void viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa);
+ void viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa);
- virtual int viewport_get_render_info(RID p_viewport, VS::ViewportRenderInfo p_info);
- virtual void viewport_set_debug_draw(RID p_viewport, VS::ViewportDebugDraw p_draw);
+ virtual int viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfo p_info);
+ virtual void viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw);
void set_default_clear_color(const Color &p_color);
void draw_viewports();
bool free(RID p_rid);
- VisualServerViewport();
- virtual ~VisualServerViewport() {}
+ RenderingServerViewport();
+ virtual ~RenderingServerViewport() {}
};
#endif // VISUALSERVERVIEWPORT_H
diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/rendering/rendering_server_wrap_mt.cpp
index 90d301c0cd..5d6d523901 100644
--- a/servers/visual/visual_server_wrap_mt.cpp
+++ b/servers/rendering/rendering_server_wrap_mt.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_wrap_mt.cpp */
+/* rendering_server_wrap_mt.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,42 +28,43 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_server_wrap_mt.h"
+#include "rendering_server_wrap_mt.h"
#include "core/os/os.h"
#include "core/project_settings.h"
+#include "servers/display_server.h"
-void VisualServerWrapMT::thread_exit() {
+void RenderingServerWrapMT::thread_exit() {
exit = true;
}
-void VisualServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) {
+void RenderingServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) {
if (!atomic_decrement(&draw_pending)) {
- visual_server->draw(p_swap_buffers, frame_step);
+ rendering_server->draw(p_swap_buffers, frame_step);
}
}
-void VisualServerWrapMT::thread_flush() {
+void RenderingServerWrapMT::thread_flush() {
atomic_decrement(&draw_pending);
}
-void VisualServerWrapMT::_thread_callback(void *_instance) {
+void RenderingServerWrapMT::_thread_callback(void *_instance) {
- VisualServerWrapMT *vsmt = reinterpret_cast<VisualServerWrapMT *>(_instance);
+ RenderingServerWrapMT *vsmt = reinterpret_cast<RenderingServerWrapMT *>(_instance);
vsmt->thread_loop();
}
-void VisualServerWrapMT::thread_loop() {
+void RenderingServerWrapMT::thread_loop() {
server_thread = Thread::get_caller_id();
- OS::get_singleton()->make_rendering_thread();
+ DisplayServer::get_singleton()->make_rendering_thread();
- visual_server->init();
+ rendering_server->init();
exit = false;
draw_thread_up = true;
@@ -74,66 +75,66 @@ void VisualServerWrapMT::thread_loop() {
command_queue.flush_all(); // flush all
- visual_server->finish();
+ rendering_server->finish();
}
/* EVENT QUEUING */
-void VisualServerWrapMT::sync() {
+void RenderingServerWrapMT::sync() {
if (create_thread) {
atomic_increment(&draw_pending);
- command_queue.push_and_sync(this, &VisualServerWrapMT::thread_flush);
+ command_queue.push_and_sync(this, &RenderingServerWrapMT::thread_flush);
} else {
command_queue.flush_all(); //flush all pending from other threads
}
}
-void VisualServerWrapMT::draw(bool p_swap_buffers, double frame_step) {
+void RenderingServerWrapMT::draw(bool p_swap_buffers, double frame_step) {
if (create_thread) {
atomic_increment(&draw_pending);
- command_queue.push(this, &VisualServerWrapMT::thread_draw, p_swap_buffers, frame_step);
+ command_queue.push(this, &RenderingServerWrapMT::thread_draw, p_swap_buffers, frame_step);
} else {
- visual_server->draw(p_swap_buffers, frame_step);
+ rendering_server->draw(p_swap_buffers, frame_step);
}
}
-void VisualServerWrapMT::init() {
+void RenderingServerWrapMT::init() {
if (create_thread) {
- print_verbose("VisualServerWrapMT: Creating render thread");
- OS::get_singleton()->release_rendering_thread();
+ print_verbose("RenderingServerWrapMT: Creating render thread");
+ DisplayServer::get_singleton()->release_rendering_thread();
if (create_thread) {
thread = Thread::create(_thread_callback, this);
- print_verbose("VisualServerWrapMT: Starting render thread");
+ print_verbose("RenderingServerWrapMT: Starting render thread");
}
while (!draw_thread_up) {
OS::get_singleton()->delay_usec(1000);
}
- print_verbose("VisualServerWrapMT: Finished render thread");
+ print_verbose("RenderingServerWrapMT: Finished render thread");
} else {
- visual_server->init();
+ rendering_server->init();
}
}
-void VisualServerWrapMT::finish() {
+void RenderingServerWrapMT::finish() {
if (thread) {
- command_queue.push(this, &VisualServerWrapMT::thread_exit);
+ command_queue.push(this, &RenderingServerWrapMT::thread_exit);
Thread::wait_to_finish(thread);
memdelete(thread);
thread = NULL;
} else {
- visual_server->finish();
+ rendering_server->finish();
}
sky_free_cached_ids();
@@ -162,20 +163,20 @@ void VisualServerWrapMT::finish() {
canvas_occluder_polygon_free_cached_ids();
}
-void VisualServerWrapMT::set_use_vsync_callback(bool p_enable) {
+void RenderingServerWrapMT::set_use_vsync_callback(bool p_enable) {
singleton_mt->call_set_use_vsync(p_enable);
}
-VisualServerWrapMT *VisualServerWrapMT::singleton_mt = NULL;
+RenderingServerWrapMT *RenderingServerWrapMT::singleton_mt = NULL;
-VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread) :
+RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
singleton_mt = this;
- OS::switch_vsync_function = set_use_vsync_callback; //as this goes to another thread, make sure it goes properly
+ DisplayServer::switch_vsync_function = set_use_vsync_callback; //as this goes to another thread, make sure it goes properly
- visual_server = p_contained;
+ rendering_server = p_contained;
create_thread = p_create_thread;
thread = NULL;
draw_pending = 0;
@@ -189,8 +190,8 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_
}
}
-VisualServerWrapMT::~VisualServerWrapMT() {
+RenderingServerWrapMT::~RenderingServerWrapMT() {
- memdelete(visual_server);
+ memdelete(rendering_server);
//finish();
}
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/rendering/rendering_server_wrap_mt.h
index 0d4683e43d..ee4065094b 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/rendering/rendering_server_wrap_mt.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server_wrap_mt.h */
+/* rendering_server_wrap_mt.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VISUAL_SERVER_WRAP_MT_H
-#define VISUAL_SERVER_WRAP_MT_H
+#ifndef RENDERING_SERVER_WRAP_MT_H
+#define RENDERING_SERVER_WRAP_MT_H
#include "core/command_queue_mt.h"
#include "core/os/thread.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
-class VisualServerWrapMT : public VisualServer {
+class RenderingServerWrapMT : public RenderingServer {
// the real visual server
- mutable VisualServer *visual_server;
+ mutable RenderingServer *rendering_server;
mutable CommandQueueMT command_queue;
@@ -63,7 +63,7 @@ class VisualServerWrapMT : public VisualServer {
//#define DEBUG_SYNC
- static VisualServerWrapMT *singleton_mt;
+ static RenderingServerWrapMT *singleton_mt;
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__));
@@ -72,28 +72,28 @@ class VisualServerWrapMT : public VisualServer {
#endif
public:
-#define ServerName VisualServer
-#define ServerNameWrapMT VisualServerWrapMT
-#define server_name visual_server
+#define ServerName RenderingServer
+#define ServerNameWrapMT RenderingServerWrapMT
+#define server_name rendering_server
#include "servers/server_wrap_mt_common.h"
//these go pass-through, as they can be called from any thread
- virtual RID texture_2d_create(const Ref<Image> &p_image) { return visual_server->texture_2d_create(p_image); }
- virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, TextureLayeredType p_layered_type) { return visual_server->texture_2d_layered_create(p_layers, p_layered_type); }
- virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return visual_server->texture_3d_create(p_slices); }
- virtual RID texture_proxy_create(RID p_base) { return visual_server->texture_proxy_create(p_base); }
+ virtual RID texture_2d_create(const Ref<Image> &p_image) { return rendering_server->texture_2d_create(p_image); }
+ virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, TextureLayeredType p_layered_type) { return rendering_server->texture_2d_layered_create(p_layers, p_layered_type); }
+ virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return rendering_server->texture_3d_create(p_slices); }
+ virtual RID texture_proxy_create(RID p_base) { return rendering_server->texture_proxy_create(p_base); }
//goes pass-through
- virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) { visual_server->texture_2d_update_immediate(p_texture, p_image, p_layer); }
+ virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) { rendering_server->texture_2d_update_immediate(p_texture, p_image, p_layer); }
//these go through command queue if they are in another thread
FUNC3(texture_2d_update, RID, const Ref<Image> &, int)
FUNC4(texture_3d_update, RID, const Ref<Image> &, int, int)
FUNC2(texture_proxy_update, RID, RID)
//these also go pass-through
- virtual RID texture_2d_placeholder_create() { return visual_server->texture_2d_placeholder_create(); }
- virtual RID texture_2d_layered_placeholder_create() { return visual_server->texture_2d_layered_placeholder_create(); }
- virtual RID texture_3d_placeholder_create() { return visual_server->texture_3d_placeholder_create(); }
+ virtual RID texture_2d_placeholder_create() { return rendering_server->texture_2d_placeholder_create(); }
+ virtual RID texture_2d_layered_placeholder_create() { return rendering_server->texture_2d_layered_placeholder_create(); }
+ virtual RID texture_3d_placeholder_create() { return rendering_server->texture_3d_placeholder_create(); }
FUNC1RC(Ref<Image>, texture_2d_get, RID)
FUNC2RC(Ref<Image>, texture_2d_layer_get, RID, int)
@@ -145,7 +145,7 @@ public:
/* MESH API */
virtual RID mesh_create_from_surfaces(const Vector<SurfaceData> &p_surfaces) {
- return visual_server->mesh_create_from_surfaces(p_surfaces);
+ return rendering_server->mesh_create_from_surfaces(p_surfaces);
}
FUNCRID(mesh)
@@ -346,7 +346,7 @@ public:
FUNC1(particles_request_process, RID)
FUNC1(particles_restart, RID)
- FUNC2(particles_set_draw_order, RID, VS::ParticlesDrawOrder)
+ FUNC2(particles_set_draw_order, RID, RS::ParticlesDrawOrder)
FUNC2(particles_set_draw_passes, RID, int)
FUNC3(particles_set_draw_pass_mesh, RID, int, RID)
@@ -379,9 +379,8 @@ public:
FUNC2(viewport_set_clear_mode, RID, ViewportClearMode)
- FUNC3(viewport_attach_to_screen, RID, const Rect2 &, int)
+ FUNC3(viewport_attach_to_screen, RID, const Rect2 &, DisplayServer::WindowID)
FUNC2(viewport_set_render_direct_to_screen, RID, bool)
- FUNC1(viewport_detach, RID)
FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode)
@@ -407,7 +406,7 @@ public:
//this passes directly to avoid stalling, but it's pretty dangerous, so don't call after freeing a viewport
virtual int viewport_get_render_info(RID p_viewport, ViewportRenderInfo p_info) {
- return visual_server->viewport_get_render_info(p_viewport, p_info);
+ return rendering_server->viewport_get_render_info(p_viewport, p_info);
}
FUNC2(viewport_set_debug_draw, RID, ViewportDebugDraw)
@@ -618,15 +617,15 @@ public:
//this passes directly to avoid stalling
virtual int get_render_info(RenderInfo p_info) {
- return visual_server->get_render_info(p_info);
+ return rendering_server->get_render_info(p_info);
}
virtual String get_video_adapter_name() const {
- return visual_server->get_video_adapter_name();
+ return rendering_server->get_video_adapter_name();
}
virtual String get_video_adapter_vendor() const {
- return visual_server->get_video_adapter_vendor();
+ return rendering_server->get_video_adapter_vendor();
}
FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool)
@@ -637,10 +636,10 @@ public:
FUNC1(set_debug_generate_wireframes, bool)
virtual bool has_feature(Features p_feature) const {
- return visual_server->has_feature(p_feature);
+ return rendering_server->has_feature(p_feature);
}
virtual bool has_os_feature(const String &p_feature) const {
- return visual_server->has_os_feature(p_feature);
+ return rendering_server->has_os_feature(p_feature);
}
FUNC1(call_set_use_vsync, bool)
@@ -648,23 +647,23 @@ public:
static void set_use_vsync_callback(bool p_enable);
virtual bool is_low_end() const {
- return visual_server->is_low_end();
+ return rendering_server->is_low_end();
}
virtual uint64_t get_frame_profile_frame() {
- return visual_server->get_frame_profile_frame();
+ return rendering_server->get_frame_profile_frame();
}
virtual void set_frame_profiling_enabled(bool p_enabled) {
- visual_server->set_frame_profiling_enabled(p_enabled);
+ rendering_server->set_frame_profiling_enabled(p_enabled);
}
virtual Vector<FrameProfileArea> get_frame_profile() {
- return visual_server->get_frame_profile();
+ return rendering_server->get_frame_profile();
}
- VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread);
- ~VisualServerWrapMT();
+ RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread);
+ ~RenderingServerWrapMT();
#undef ServerName
#undef ServerNameWrapMT
diff --git a/servers/visual/shader_language.cpp b/servers/rendering/shader_language.cpp
index 98786fad3b..cf2a01c07c 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -31,7 +31,7 @@
#include "shader_language.h"
#include "core/os/os.h"
#include "core/print_string.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
static bool _is_text_char(CharType c) {
@@ -2165,7 +2165,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
}
if (!fail) {
- if (VisualServer::get_singleton()->is_low_end()) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
if (builtin_func_defs[idx].high_end) {
fail = true;
unsupported_builtin = true;
@@ -4772,7 +4772,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
if (tk.type == TK_BRACKET_OPEN) {
bool unknown_size = false;
- if (VisualServer::get_singleton()->is_low_end() && is_const) {
+ if (RenderingServer::get_singleton()->is_low_end() && is_const) {
_set_error("Local const arrays are supported only on high-end platform!");
return ERR_PARSE_ERROR;
}
@@ -4818,7 +4818,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
tk = _get_token();
if (tk.type == TK_OP_ASSIGN) {
- if (VisualServer::get_singleton()->is_low_end()) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
_set_error("Array initialization is supported only on high-end platform!");
return ERR_PARSE_ERROR;
}
@@ -5136,7 +5136,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
} else if (tk.type == TK_CF_SWITCH) {
- if (VisualServer::get_singleton()->is_low_end()) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
_set_error("\"switch\" operator is supported only on high-end platform!");
return ERR_PARSE_ERROR;
}
@@ -5617,7 +5617,7 @@ String ShaderLanguage::_get_qualifier_str(ArgumentQualifier p_qualifier) const {
}
Error ShaderLanguage::_validate_datatype(DataType p_type) {
- if (VisualServer::get_singleton()->is_low_end()) {
+ if (RenderingServer::get_singleton()->is_low_end()) {
bool invalid_type = false;
switch (p_type) {
@@ -6763,7 +6763,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
int idx = 0;
- bool low_end = VisualServer::get_singleton()->is_low_end();
+ bool low_end = RenderingServer::get_singleton()->is_low_end();
while (builtin_func_defs[idx].name) {
if (low_end && builtin_func_defs[idx].high_end) {
@@ -6776,7 +6776,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
} else { // sub-class
int idx = 0;
- bool low_end = VisualServer::get_singleton()->is_low_end();
+ bool low_end = RenderingServer::get_singleton()->is_low_end();
while (builtin_func_defs[idx].name) {
if (low_end && builtin_func_defs[idx].high_end) {
@@ -6854,7 +6854,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
int idx = 0;
String calltip;
- bool low_end = VisualServer::get_singleton()->is_low_end();
+ bool low_end = RenderingServer::get_singleton()->is_low_end();
while (builtin_func_defs[idx].name) {
diff --git a/servers/visual/shader_language.h b/servers/rendering/shader_language.h
index bdc15cc4aa..bdc15cc4aa 100644
--- a/servers/visual/shader_language.h
+++ b/servers/rendering/shader_language.h
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
new file mode 100644
index 0000000000..b144d6d612
--- /dev/null
+++ b/servers/rendering/shader_types.cpp
@@ -0,0 +1,328 @@
+/*************************************************************************/
+/* shader_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "shader_types.h"
+
+const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(RS::ShaderMode p_mode) {
+
+ return shader_modes[p_mode].functions;
+}
+
+const Vector<StringName> &ShaderTypes::get_modes(RS::ShaderMode p_mode) {
+
+ return shader_modes[p_mode].modes;
+}
+
+const Set<String> &ShaderTypes::get_types() {
+ return shader_types;
+}
+
+ShaderTypes *ShaderTypes::singleton = NULL;
+
+static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) {
+
+ return ShaderLanguage::BuiltInInfo(p_type, true);
+}
+
+ShaderTypes::ShaderTypes() {
+ singleton = this;
+
+ /*************** SPATIAL ***********************/
+
+ shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
+
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["UV2"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_ID"] = constt(ShaderLanguage::TYPE_INT);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].can_discard = false;
+
+ //builtins
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_MATRIX"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3;
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
+
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRONT_FACING"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SPECULAR"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM_TINT"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT_GLOSS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["AO_LIGHT_AFFECT"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
+
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
+
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_NORMAL_MATRIX"] = constt(ShaderLanguage::TYPE_MAT3);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].can_discard = true;
+
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ATTENUATION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ALBEDO"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["TRANSMISSION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ROUGHNESS"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["DIFFUSE_LIGHT"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_LIGHT"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
+
+ shader_modes[RS::SHADER_SPATIAL].functions["light"].can_discard = true;
+
+ //order used puts first enum mode (default) first
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_mix");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_add");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_sub");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_mul");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_opaque");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_always");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_never");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_prepass_alpha");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_test_disabled");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_back");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_front");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_disabled");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("unshaded");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("wireframe");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_lambert");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_lambert_wrap");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_oren_nayar");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_burley");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_toon");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_schlick_ggx");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_blinn");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_phong");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_toon");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_disabled");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("skip_vertex_transform");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("world_vertex_coords");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("shadows_disabled");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("ambient_light_disabled");
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("shadow_to_opacity");
+
+ shader_modes[RS::SHADER_SPATIAL].modes.push_back("vertex_lighting");
+
+ /************ CANVAS ITEM **************************/
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["CANVAS_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["SCREEN_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].can_discard = false;
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SHADOW_VERTEX"] = ShaderLanguage::TYPE_VEC2;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["LIGHT_VERTEX"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].can_discard = true;
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_VERTEX"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SHADOW_MODULATE"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].can_discard = true;
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("skip_vertex_transform");
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_mix");
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_add");
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_sub");
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_mul");
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_premul_alpha");
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_disabled");
+
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("unshaded");
+ shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("light_only");
+
+ /************ PARTICLES **************************/
+
+ shader_modes[RS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["MASS"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["ACTIVE"] = ShaderLanguage::TYPE_BOOL;
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["RESTART"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["CUSTOM"] = ShaderLanguage::TYPE_VEC4;
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["TRANSFORM"] = ShaderLanguage::TYPE_MAT4;
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["LIFETIME"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["DELTA"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["NUMBER"] = constt(ShaderLanguage::TYPE_UINT);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["INDEX"] = constt(ShaderLanguage::TYPE_INT);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["EMISSION_TRANSFORM"] = constt(ShaderLanguage::TYPE_MAT4);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["RANDOM_SEED"] = constt(ShaderLanguage::TYPE_UINT);
+ shader_modes[RS::SHADER_PARTICLES].functions["vertex"].can_discard = false;
+
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back("disable_force");
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back("disable_velocity");
+ shader_modes[RS::SHADER_PARTICLES].modes.push_back("keep_data");
+
+ /************ SKY **************************/
+
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["RADIANCE"] = constt(ShaderLanguage::TYPE_SAMPLERCUBE);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["AT_HALF_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["AT_QUARTER_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["AT_CUBEMAP_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
+ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
+
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["EYEDIR"] = constt(ShaderLanguage::TYPE_VEC3);
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["SKY_COORDS"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["HALF_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
+ shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["QUARTER_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
+
+ shader_modes[RS::SHADER_SKY].modes.push_back("use_half_res_pass");
+ shader_modes[RS::SHADER_SKY].modes.push_back("use_quarter_res_pass");
+
+ shader_types.insert("spatial");
+ shader_types.insert("canvas_item");
+ shader_types.insert("particles");
+ shader_types.insert("sky");
+}
diff --git a/servers/visual/shader_types.h b/servers/rendering/shader_types.h
index 7d674bfb5c..499a761265 100644
--- a/servers/visual/shader_types.h
+++ b/servers/rendering/shader_types.h
@@ -32,7 +32,7 @@
#define SHADERTYPES_H
#include "core/ordered_hash_map.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#include "shader_language.h"
class ShaderTypes {
@@ -43,7 +43,7 @@ class ShaderTypes {
Vector<StringName> modes;
};
- Map<VS::ShaderMode, Type> shader_modes;
+ Map<RS::ShaderMode, Type> shader_modes;
static ShaderTypes *singleton;
@@ -52,8 +52,8 @@ class ShaderTypes {
public:
static ShaderTypes *get_singleton() { return singleton; }
- const Map<StringName, ShaderLanguage::FunctionInfo> &get_functions(VS::ShaderMode p_mode);
- const Vector<StringName> &get_modes(VS::ShaderMode p_mode);
+ const Map<StringName, ShaderLanguage::FunctionInfo> &get_functions(RS::ShaderMode p_mode);
+ const Vector<StringName> &get_modes(RS::ShaderMode p_mode);
const Set<String> &get_types();
ShaderTypes();
diff --git a/servers/visual_server.cpp b/servers/rendering_server.cpp
index b50ad89b1e..084b8f7952 100644
--- a/servers/visual_server.cpp
+++ b/servers/rendering_server.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server.cpp */
+/* rendering_server.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,20 +28,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "visual_server.h"
+#include "rendering_server.h"
#include "core/method_bind_ext.gen.inc"
#include "core/project_settings.h"
-VisualServer *VisualServer::singleton = NULL;
-VisualServer *(*VisualServer::create_func)() = NULL;
+RenderingServer *RenderingServer::singleton = NULL;
+RenderingServer *(*RenderingServer::create_func)() = NULL;
-VisualServer *VisualServer::get_singleton() {
+RenderingServer *RenderingServer::get_singleton() {
return singleton;
}
-VisualServer *VisualServer::create() {
+RenderingServer *RenderingServer::create() {
ERR_FAIL_COND_V(singleton, NULL);
@@ -51,7 +51,7 @@ VisualServer *VisualServer::create() {
return NULL;
}
-Array VisualServer::_texture_debug_usage_bind() {
+Array RenderingServer::_texture_debug_usage_bind() {
List<TextureInfo> list;
texture_debug_usage(&list);
@@ -71,7 +71,7 @@ Array VisualServer::_texture_debug_usage_bind() {
return arr;
}
-Array VisualServer::_shader_get_param_list_bind(RID p_shader) const {
+Array RenderingServer::_shader_get_param_list_bind(RID p_shader) const {
List<PropertyInfo> l;
shader_get_param_list(p_shader, &l);
@@ -87,19 +87,19 @@ static Array to_array(const Vector<ObjectID> &ids) {
return a;
}
-Array VisualServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
+Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);
return to_array(ids);
}
-Array VisualServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
+Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);
return to_array(ids);
}
-Array VisualServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const {
+Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const {
Vector<Plane> planes;
for (int i = 0; i < p_convex.size(); ++i) {
@@ -112,7 +112,7 @@ Array VisualServer::_instances_cull_convex_bind(const Array &p_convex, RID p_sce
return to_array(ids);
}
-RID VisualServer::get_test_texture() {
+RID RenderingServer::get_test_texture() {
if (test_texture.is_valid()) {
return test_texture;
@@ -160,7 +160,7 @@ RID VisualServer::get_test_texture() {
return test_texture;
}
-void VisualServer::_free_internal_rids() {
+void RenderingServer::_free_internal_rids() {
if (test_texture.is_valid())
free(test_texture);
@@ -170,7 +170,7 @@ void VisualServer::_free_internal_rids() {
free(test_material);
}
-RID VisualServer::_make_test_cube() {
+RID RenderingServer::_make_test_cube() {
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -223,17 +223,17 @@ RID VisualServer::_make_test_cube() {
RID test_cube = mesh_create();
Array d;
- d.resize(VS::ARRAY_MAX);
- d[VisualServer::ARRAY_NORMAL] = normals;
- d[VisualServer::ARRAY_TANGENT] = tangents;
- d[VisualServer::ARRAY_TEX_UV] = uvs;
- d[VisualServer::ARRAY_VERTEX] = vertices;
+ d.resize(RS::ARRAY_MAX);
+ d[RenderingServer::ARRAY_NORMAL] = normals;
+ d[RenderingServer::ARRAY_TANGENT] = tangents;
+ d[RenderingServer::ARRAY_TEX_UV] = uvs;
+ d[RenderingServer::ARRAY_VERTEX] = vertices;
Vector<int> indices;
indices.resize(vertices.size());
for (int i = 0; i < vertices.size(); i++)
indices.set(i, i);
- d[VisualServer::ARRAY_INDEX] = indices;
+ d[RenderingServer::ARRAY_INDEX] = indices;
mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
@@ -252,7 +252,7 @@ RID VisualServer::_make_test_cube() {
return test_cube;
}
-RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
+RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -299,7 +299,7 @@ RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
RID mesh = mesh_create();
Array d;
- d.resize(VS::ARRAY_MAX);
+ d.resize(RS::ARRAY_MAX);
d[ARRAY_VERTEX] = vertices;
d[ARRAY_NORMAL] = normals;
@@ -309,7 +309,7 @@ RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
return mesh;
}
-RID VisualServer::get_white_texture() {
+RID RenderingServer::get_white_texture() {
if (white_texture.is_valid())
return white_texture;
@@ -329,27 +329,27 @@ RID VisualServer::get_white_texture() {
#define SMALL_VEC2 Vector2(0.00001, 0.00001)
#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
-Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) {
+Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) {
uint8_t *vw = r_vertex_array.ptrw();
- uint8_t *iw;
+ uint8_t *iw = NULL;
if (r_index_array.size()) {
iw = r_index_array.ptrw();
}
int max_bone = 0;
- for (int ai = 0; ai < VS::ARRAY_MAX; ai++) {
+ for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {
if (!(p_format & (1 << ai))) // no array
continue;
switch (ai) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
- if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) {
+ if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
Vector<Vector2> array = p_arrays[ai];
ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
@@ -408,7 +408,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
@@ -443,7 +443,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
@@ -481,7 +481,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER);
@@ -513,7 +513,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
@@ -542,7 +542,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
@@ -569,13 +569,13 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
}
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
Vector<real_t> array = p_arrays[ai];
- ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(array.size() != p_vertex_array_len * RS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
const real_t *src = array.ptr();
@@ -583,9 +583,9 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
for (int i = 0; i < p_vertex_array_len; i++) {
- uint16_t data[VS::ARRAY_WEIGHTS_SIZE];
- for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
- data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535);
+ uint16_t data[RS::ARRAY_WEIGHTS_SIZE];
+ for (int j = 0; j < RS::ARRAY_WEIGHTS_SIZE; j++) {
+ data[j] = CLAMP(src[i * RS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535);
}
copymem(&vw[p_offsets[ai] + i * p_stride], data, 2 * 4);
@@ -593,21 +593,21 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
Vector<int> array = p_arrays[ai];
- ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(array.size() != p_vertex_array_len * RS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER);
const int *src = array.ptr();
for (int i = 0; i < p_vertex_array_len; i++) {
- uint16_t data[VS::ARRAY_WEIGHTS_SIZE];
- for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) {
- data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j];
+ uint16_t data[RS::ARRAY_WEIGHTS_SIZE];
+ for (int j = 0; j < RS::ARRAY_WEIGHTS_SIZE; j++) {
+ data[j] = src[i * RS::ARRAY_WEIGHTS_SIZE + j];
max_bone = MAX(data[j], max_bone);
}
@@ -615,8 +615,9 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
+ ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA);
ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER);
@@ -647,7 +648,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
}
- if (p_format & VS::ARRAY_FORMAT_BONES) {
+ if (p_format & RS::ARRAY_FORMAT_BONES) {
//create AABBs for each detected bone
int total_bones = max_bone + 1;
@@ -661,9 +662,9 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
}
- Vector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX];
- Vector<int> bones = p_arrays[VS::ARRAY_BONES];
- Vector<float> weights = p_arrays[VS::ARRAY_WEIGHTS];
+ Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX];
+ Vector<int> bones = p_arrays[RS::ARRAY_BONES];
+ Vector<float> weights = p_arrays[RS::ARRAY_WEIGHTS];
bool any_valid = false;
@@ -706,22 +707,22 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
return OK;
}
-uint32_t VisualServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const {
+uint32_t RenderingServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const {
uint32_t offsets[ARRAY_MAX];
mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
return offsets[p_array_index];
}
-uint32_t VisualServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const {
+uint32_t RenderingServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const {
uint32_t offsets[ARRAY_MAX];
return mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets);
}
-uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const {
+uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const {
int total_elem_size = 0;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
r_offsets[i] = 0; //reset
@@ -732,7 +733,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
elem_size = 2;
@@ -749,7 +750,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
if (p_format & ARRAY_COMPRESS_NORMAL) {
elem_size = sizeof(uint32_t);
@@ -759,7 +760,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
if (p_format & ARRAY_COMPRESS_TANGENT) {
elem_size = sizeof(uint32_t);
} else {
@@ -767,7 +768,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
if (p_format & ARRAY_COMPRESS_COLOR) {
elem_size = sizeof(uint32_t);
@@ -775,7 +776,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
elem_size = sizeof(float) * 4;
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
if (p_format & ARRAY_COMPRESS_TEX_UV) {
elem_size = sizeof(uint32_t);
} else {
@@ -784,7 +785,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
if (p_format & ARRAY_COMPRESS_TEX_UV2) {
elem_size = sizeof(uint32_t);
} else {
@@ -792,17 +793,17 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
}
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
elem_size = sizeof(uint16_t) * 4;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
elem_size = sizeof(uint16_t) * 4;
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
if (p_index_len <= 0) {
ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
@@ -830,10 +831,10 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format,
return total_elem_size;
}
-Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) {
+Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) {
- ERR_FAIL_INDEX_V(p_primitive, VS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_arrays.size() != VS::ARRAY_MAX, ERR_INVALID_PARAMETER);
+ ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER);
uint32_t format = 0;
@@ -848,7 +849,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
format |= (1 << i);
- if (i == VS::ARRAY_VERTEX) {
+ if (i == RS::ARRAY_VERTEX) {
Variant var = p_arrays[i];
switch (var.get_type()) {
@@ -865,13 +866,13 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
array_len = PackedVector3Array(p_arrays[i]).size();
ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA);
- } else if (i == VS::ARRAY_INDEX) {
+ } else if (i == RS::ARRAY_INDEX) {
index_array_len = PackedInt32Array(p_arrays[i]).size();
}
}
- ERR_FAIL_COND_V((format & VS::ARRAY_FORMAT_VERTEX) == 0, ERR_INVALID_PARAMETER); // mandatory
+ ERR_FAIL_COND_V((format & RS::ARRAY_FORMAT_VERTEX) == 0, ERR_INVALID_PARAMETER); // mandatory
if (p_blend_shapes.size()) {
//validate format for morphs
@@ -885,15 +886,15 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
bsformat |= (1 << j);
}
- ERR_FAIL_COND_V((bsformat) != (format & (VS::ARRAY_FORMAT_INDEX - 1)), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V((bsformat) != (format & (RS::ARRAY_FORMAT_INDEX - 1)), ERR_INVALID_PARAMETER);
}
}
- uint32_t offsets[VS::ARRAY_MAX];
+ uint32_t offsets[RS::ARRAY_MAX];
int total_elem_size = 0;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
offsets[i] = 0; //reset
@@ -904,7 +905,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
Variant arr = p_arrays[0];
if (arr.get_type() == Variant::PACKED_VECTOR2_ARRAY) {
@@ -922,7 +923,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
if (p_compress_format & ARRAY_COMPRESS_NORMAL) {
elem_size = sizeof(uint32_t);
@@ -932,7 +933,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
if (p_compress_format & ARRAY_COMPRESS_TANGENT) {
elem_size = sizeof(uint32_t);
} else {
@@ -940,7 +941,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
if (p_compress_format & ARRAY_COMPRESS_COLOR) {
elem_size = sizeof(uint32_t);
@@ -948,7 +949,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
elem_size = sizeof(float) * 4;
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
if (p_compress_format & ARRAY_COMPRESS_TEX_UV) {
elem_size = sizeof(uint32_t);
} else {
@@ -957,7 +958,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
if (p_compress_format & ARRAY_COMPRESS_TEX_UV2) {
elem_size = sizeof(uint32_t);
} else {
@@ -965,17 +966,17 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
}
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
elem_size = sizeof(uint16_t) * 4;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
elem_size = sizeof(uint16_t) * 4;
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
if (index_array_len <= 0) {
ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
@@ -1009,7 +1010,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
Vector<uint8_t> vertex_array;
vertex_array.resize(array_size);
- int index_array_size = offsets[VS::ARRAY_INDEX] * index_array_len;
+ int index_array_size = offsets[RS::ARRAY_INDEX] * index_array_len;
Vector<uint8_t> index_array;
index_array.resize(index_array_size);
@@ -1091,7 +1092,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_
return OK;
}
-void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) {
+void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) {
SurfaceData sd;
Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format);
@@ -1101,13 +1102,13 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
mesh_add_surface(p_mesh, sd);
}
-Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p_vertex_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len) const {
+Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p_vertex_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len) const {
uint32_t offsets[ARRAY_MAX];
int total_elem_size = 0;
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
offsets[i] = 0; //reset
@@ -1118,7 +1119,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
elem_size = 2;
@@ -1131,7 +1132,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
if (p_format & ARRAY_COMPRESS_NORMAL) {
elem_size = sizeof(uint32_t);
@@ -1141,7 +1142,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
if (p_format & ARRAY_COMPRESS_TANGENT) {
elem_size = sizeof(uint32_t);
} else {
@@ -1149,7 +1150,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
}
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
if (p_format & ARRAY_COMPRESS_COLOR) {
elem_size = sizeof(uint32_t);
@@ -1157,7 +1158,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
elem_size = sizeof(float) * 4;
}
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
if (p_format & ARRAY_COMPRESS_TEX_UV) {
elem_size = sizeof(uint32_t);
} else {
@@ -1166,7 +1167,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
if (p_format & ARRAY_COMPRESS_TEX_UV2) {
elem_size = sizeof(uint32_t);
} else {
@@ -1174,17 +1175,17 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
}
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
elem_size = sizeof(uint16_t) * 4;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
elem_size = sizeof(uint16_t) * 4;
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
if (p_index_len <= 0) {
ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
@@ -1211,18 +1212,18 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
}
Array ret;
- ret.resize(VS::ARRAY_MAX);
+ ret.resize(RS::ARRAY_MAX);
const uint8_t *r = p_vertex_data.ptr();
- for (int i = 0; i < VS::ARRAY_MAX; i++) {
+ for (int i = 0; i < RS::ARRAY_MAX; i++) {
if (!(p_format & (1 << i)))
continue;
switch (i) {
- case VS::ARRAY_VERTEX: {
+ case RS::ARRAY_VERTEX: {
if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
@@ -1261,7 +1262,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
}
} break;
- case VS::ARRAY_NORMAL: {
+ case RS::ARRAY_NORMAL: {
Vector<Vector3> arr;
arr.resize(p_vertex_len);
@@ -1289,7 +1290,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
} break;
- case VS::ARRAY_TANGENT: {
+ case RS::ARRAY_TANGENT: {
Vector<float> arr;
arr.resize(p_vertex_len * 4);
if (p_format & ARRAY_COMPRESS_TANGENT) {
@@ -1317,7 +1318,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
ret[i] = arr;
} break;
- case VS::ARRAY_COLOR: {
+ case RS::ARRAY_COLOR: {
Vector<Color> arr;
arr.resize(p_vertex_len);
@@ -1343,7 +1344,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
ret[i] = arr;
} break;
- case VS::ARRAY_TEX_UV: {
+ case RS::ARRAY_TEX_UV: {
Vector<Vector2> arr;
arr.resize(p_vertex_len);
@@ -1371,7 +1372,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
ret[i] = arr;
} break;
- case VS::ARRAY_TEX_UV2: {
+ case RS::ARRAY_TEX_UV2: {
Vector<Vector2> arr;
arr.resize(p_vertex_len);
@@ -1398,7 +1399,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
ret[i] = arr;
} break;
- case VS::ARRAY_WEIGHTS: {
+ case RS::ARRAY_WEIGHTS: {
Vector<float> arr;
arr.resize(p_vertex_len * 4);
@@ -1417,7 +1418,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
ret[i] = arr;
} break;
- case VS::ARRAY_BONES: {
+ case RS::ARRAY_BONES: {
Vector<int> arr;
arr.resize(p_vertex_len * 4);
@@ -1435,7 +1436,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
ret[i] = arr;
} break;
- case VS::ARRAY_INDEX: {
+ case RS::ARRAY_INDEX: {
/* determine whether using 16 or 32 bits indices */
const uint8_t *ir = p_index_data.ptr();
@@ -1471,13 +1472,13 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p
return ret;
}
-Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
+Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
return mesh_create_arrays_from_surface_data(sd);
}
-Dictionary VisualServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {
+Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {
SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary());
@@ -1512,7 +1513,7 @@ Dictionary VisualServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const
return ret;
}
-Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
+Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
ERR_FAIL_COND_V(sd.vertex_count == 0, Array());
@@ -1539,7 +1540,7 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac
}
}
-Array VisualServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {
+Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {
Vector<uint8_t> vertex_data = p_data.vertex_data;
@@ -1554,9 +1555,9 @@ Array VisualServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_da
return _get_array_from_surface(format, vertex_data, vertex_len, index_data, index_len);
}
#if 0
-Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
+Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
- Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
+ Vector<AABB> vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
Array arr;
for (int i = 0; i < vec.size(); i++) {
arr[i] = vec[i];
@@ -1564,388 +1565,388 @@ Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surfa
return arr;
}
#endif
-void VisualServer::_bind_methods() {
+void RenderingServer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync);
- ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0));
+ ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync);
+ ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));
#ifndef _MSC_VER
#warning TODO all texture methods need re-binding
#endif
- ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &VisualServer::texture_2d_create);
- ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &VisualServer::texture_2d_get);
+ ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &RenderingServer::texture_2d_create);
+ ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &RenderingServer::texture_2d_get);
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create);
- ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &VisualServer::sky_set_material);
+ ClassDB::bind_method(D_METHOD("sky_create"), &RenderingServer::sky_create);
+ ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &RenderingServer::sky_set_material);
#endif
- ClassDB::bind_method(D_METHOD("shader_create"), &VisualServer::shader_create);
- ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &VisualServer::shader_set_code);
- ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &VisualServer::shader_get_code);
- ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &VisualServer::_shader_get_param_list_bind);
- ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &VisualServer::shader_set_default_texture_param);
- ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &VisualServer::shader_get_default_texture_param);
- ClassDB::bind_method(D_METHOD("shader_get_param_default", "material", "parameter"), &VisualServer::shader_get_param_default);
-
- ClassDB::bind_method(D_METHOD("material_create"), &VisualServer::material_create);
- ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &VisualServer::material_set_shader);
- ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param);
- ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param);
- ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority);
-
- ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass);
-
- ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create);
- ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &VisualServer::mesh_surface_get_format_offset);
- ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &VisualServer::mesh_surface_get_format_stride);
- ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primitive", "arrays", "blend_shapes", "lods", "compress_format"), &VisualServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(Dictionary()), DEFVAL(ARRAY_COMPRESS_DEFAULT));
- ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count);
- ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode);
- ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode);
- ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region);
- ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material);
- ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material);
- ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_arrays);
- ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_blend_shape_arrays);
- ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &VisualServer::mesh_get_surface_count);
- ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &VisualServer::mesh_set_custom_aabb);
- ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &VisualServer::mesh_get_custom_aabb);
- ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &VisualServer::mesh_clear);
-
- ClassDB::bind_method(D_METHOD("multimesh_create"), &VisualServer::multimesh_create);
- ClassDB::bind_method(D_METHOD("multimesh_allocate", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &VisualServer::multimesh_allocate, DEFVAL(false), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &VisualServer::multimesh_get_instance_count);
- ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &VisualServer::multimesh_set_mesh);
- ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform);
- ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform_2d);
- ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &VisualServer::multimesh_instance_set_color);
- ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &VisualServer::multimesh_instance_set_custom_data);
- ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &VisualServer::multimesh_get_mesh);
- ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &VisualServer::multimesh_get_aabb);
- ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform);
- ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform_2d);
- ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &VisualServer::multimesh_instance_get_color);
- ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &VisualServer::multimesh_instance_get_custom_data);
- ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &VisualServer::multimesh_set_visible_instances);
- ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &VisualServer::multimesh_get_visible_instances);
- ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &VisualServer::multimesh_set_buffer);
- ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &VisualServer::multimesh_get_buffer);
+ ClassDB::bind_method(D_METHOD("shader_create"), &RenderingServer::shader_create);
+ ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code);
+ ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code);
+ ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &RenderingServer::_shader_get_param_list_bind);
+ ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &RenderingServer::shader_set_default_texture_param);
+ ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &RenderingServer::shader_get_default_texture_param);
+ ClassDB::bind_method(D_METHOD("shader_get_param_default", "material", "parameter"), &RenderingServer::shader_get_param_default);
+
+ ClassDB::bind_method(D_METHOD("material_create"), &RenderingServer::material_create);
+ ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &RenderingServer::material_set_shader);
+ ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &RenderingServer::material_set_param);
+ ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &RenderingServer::material_get_param);
+ ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &RenderingServer::material_set_render_priority);
+
+ ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &RenderingServer::material_set_next_pass);
+
+ ClassDB::bind_method(D_METHOD("mesh_create"), &RenderingServer::mesh_create);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &RenderingServer::mesh_surface_get_format_offset);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &RenderingServer::mesh_surface_get_format_stride);
+ ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primitive", "arrays", "blend_shapes", "lods", "compress_format"), &RenderingServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(Dictionary()), DEFVAL(ARRAY_COMPRESS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &RenderingServer::mesh_get_blend_shape_count);
+ ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &RenderingServer::mesh_set_blend_shape_mode);
+ ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &RenderingServer::mesh_get_blend_shape_mode);
+ ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_region);
+ ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &RenderingServer::mesh_surface_set_material);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &RenderingServer::mesh_surface_get_material);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_arrays);
+ ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_blend_shape_arrays);
+ ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &RenderingServer::mesh_get_surface_count);
+ ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &RenderingServer::mesh_set_custom_aabb);
+ ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &RenderingServer::mesh_get_custom_aabb);
+ ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &RenderingServer::mesh_clear);
+
+ ClassDB::bind_method(D_METHOD("multimesh_create"), &RenderingServer::multimesh_create);
+ ClassDB::bind_method(D_METHOD("multimesh_allocate", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &RenderingServer::multimesh_allocate, DEFVAL(false), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &RenderingServer::multimesh_get_instance_count);
+ ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &RenderingServer::multimesh_set_mesh);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform_2d);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &RenderingServer::multimesh_instance_set_color);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &RenderingServer::multimesh_instance_set_custom_data);
+ ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &RenderingServer::multimesh_get_mesh);
+ ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &RenderingServer::multimesh_get_aabb);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform_2d);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &RenderingServer::multimesh_instance_get_color);
+ ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &RenderingServer::multimesh_instance_get_custom_data);
+ ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances);
+ ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances);
+ ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer);
+ ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer);
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("immediate_create"), &VisualServer::immediate_create);
- ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &VisualServer::immediate_begin, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &VisualServer::immediate_vertex);
- ClassDB::bind_method(D_METHOD("immediate_vertex_2d", "immediate", "vertex"), &VisualServer::immediate_vertex_2d);
- ClassDB::bind_method(D_METHOD("immediate_normal", "immediate", "normal"), &VisualServer::immediate_normal);
- ClassDB::bind_method(D_METHOD("immediate_tangent", "immediate", "tangent"), &VisualServer::immediate_tangent);
- ClassDB::bind_method(D_METHOD("immediate_color", "immediate", "color"), &VisualServer::immediate_color);
- ClassDB::bind_method(D_METHOD("immediate_uv", "immediate", "tex_uv"), &VisualServer::immediate_uv);
- ClassDB::bind_method(D_METHOD("immediate_uv2", "immediate", "tex_uv"), &VisualServer::immediate_uv2);
- ClassDB::bind_method(D_METHOD("immediate_end", "immediate"), &VisualServer::immediate_end);
- ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &VisualServer::immediate_clear);
- ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &VisualServer::immediate_set_material);
- ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &VisualServer::immediate_get_material);
+ ClassDB::bind_method(D_METHOD("immediate_create"), &RenderingServer::immediate_create);
+ ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &RenderingServer::immediate_begin, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &RenderingServer::immediate_vertex);
+ ClassDB::bind_method(D_METHOD("immediate_vertex_2d", "immediate", "vertex"), &RenderingServer::immediate_vertex_2d);
+ ClassDB::bind_method(D_METHOD("immediate_normal", "immediate", "normal"), &RenderingServer::immediate_normal);
+ ClassDB::bind_method(D_METHOD("immediate_tangent", "immediate", "tangent"), &RenderingServer::immediate_tangent);
+ ClassDB::bind_method(D_METHOD("immediate_color", "immediate", "color"), &RenderingServer::immediate_color);
+ ClassDB::bind_method(D_METHOD("immediate_uv", "immediate", "tex_uv"), &RenderingServer::immediate_uv);
+ ClassDB::bind_method(D_METHOD("immediate_uv2", "immediate", "tex_uv"), &RenderingServer::immediate_uv2);
+ ClassDB::bind_method(D_METHOD("immediate_end", "immediate"), &RenderingServer::immediate_end);
+ ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &RenderingServer::immediate_clear);
+ ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &RenderingServer::immediate_set_material);
+ ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &RenderingServer::immediate_get_material);
#endif
- ClassDB::bind_method(D_METHOD("skeleton_create"), &VisualServer::skeleton_create);
- ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &VisualServer::skeleton_allocate, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &VisualServer::skeleton_get_bone_count);
- ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform);
- ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform);
- ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform_2d);
- ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform_2d);
+ ClassDB::bind_method(D_METHOD("skeleton_create"), &RenderingServer::skeleton_create);
+ ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &RenderingServer::skeleton_allocate, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &RenderingServer::skeleton_get_bone_count);
+ ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform);
+ ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform);
+ ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform_2d);
+ ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform_2d);
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("directional_light_create"), &VisualServer::directional_light_create);
- ClassDB::bind_method(D_METHOD("omni_light_create"), &VisualServer::omni_light_create);
- ClassDB::bind_method(D_METHOD("spot_light_create"), &VisualServer::spot_light_create);
-
- ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &VisualServer::light_set_color);
- ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &VisualServer::light_set_param);
- ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &VisualServer::light_set_shadow);
- ClassDB::bind_method(D_METHOD("light_set_shadow_color", "light", "color"), &VisualServer::light_set_shadow_color);
- ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &VisualServer::light_set_projector);
- ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &VisualServer::light_set_negative);
- ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &VisualServer::light_set_cull_mask);
- ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &VisualServer::light_set_reverse_cull_face_mode);
- ClassDB::bind_method(D_METHOD("light_set_use_gi", "light", "enabled"), &VisualServer::light_set_use_gi);
-
- ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &VisualServer::light_omni_set_shadow_mode);
-
- ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &VisualServer::light_directional_set_shadow_mode);
- ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &VisualServer::light_directional_set_blend_splits);
- ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &VisualServer::light_directional_set_shadow_depth_range_mode);
-
- ClassDB::bind_method(D_METHOD("reflection_probe_create"), &VisualServer::reflection_probe_create);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &VisualServer::reflection_probe_set_update_mode);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &VisualServer::reflection_probe_set_intensity);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &VisualServer::reflection_probe_set_interior_ambient);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &VisualServer::reflection_probe_set_interior_ambient_energy);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &VisualServer::reflection_probe_set_interior_ambient_probe_contribution);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &VisualServer::reflection_probe_set_max_distance);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &VisualServer::reflection_probe_set_extents);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &VisualServer::reflection_probe_set_origin_offset);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &VisualServer::reflection_probe_set_as_interior);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &VisualServer::reflection_probe_set_enable_box_projection);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &VisualServer::reflection_probe_set_enable_shadows);
- ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &VisualServer::reflection_probe_set_cull_mask);
+ ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create);
+ ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create);
+ ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create);
+
+ ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color);
+ ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param);
+ ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &RenderingServer::light_set_shadow);
+ ClassDB::bind_method(D_METHOD("light_set_shadow_color", "light", "color"), &RenderingServer::light_set_shadow_color);
+ ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &RenderingServer::light_set_projector);
+ ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative);
+ ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask);
+ ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode);
+ ClassDB::bind_method(D_METHOD("light_set_use_gi", "light", "enabled"), &RenderingServer::light_set_use_gi);
+
+ ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode);
+
+ ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &RenderingServer::light_directional_set_shadow_mode);
+ ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits);
+ ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &RenderingServer::light_directional_set_shadow_depth_range_mode);
+
+ ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &RenderingServer::reflection_probe_set_interior_ambient);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_interior_ambient_energy);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &RenderingServer::reflection_probe_set_interior_ambient_probe_contribution);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &RenderingServer::reflection_probe_set_extents);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows);
+ ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);
#ifndef _MSC_VER
#warning TODO all giprobe methods need re-binding
#endif
#if 0
- ClassDB::bind_method(D_METHOD("gi_probe_create"), &VisualServer::gi_probe_create);
- ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &VisualServer::gi_probe_set_bounds);
- ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &VisualServer::gi_probe_get_bounds);
- ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &VisualServer::gi_probe_set_cell_size);
- ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &VisualServer::gi_probe_get_cell_size);
- ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &VisualServer::gi_probe_set_to_cell_xform);
- ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &VisualServer::gi_probe_get_to_cell_xform);
- ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &VisualServer::gi_probe_set_dynamic_data);
- ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &VisualServer::gi_probe_get_dynamic_data);
- ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &VisualServer::gi_probe_set_dynamic_range);
- ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &VisualServer::gi_probe_get_dynamic_range);
- ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &VisualServer::gi_probe_set_energy);
- ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &VisualServer::gi_probe_get_energy);
- ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &VisualServer::gi_probe_set_bias);
- ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &VisualServer::gi_probe_get_bias);
- ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &VisualServer::gi_probe_set_normal_bias);
- ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &VisualServer::gi_probe_get_normal_bias);
- ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &VisualServer::gi_probe_set_propagation);
- ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &VisualServer::gi_probe_get_propagation);
- ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &VisualServer::gi_probe_set_interior);
- ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &VisualServer::gi_probe_is_interior);
- ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &VisualServer::gi_probe_set_compress);
- ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &VisualServer::gi_probe_is_compressed);
+ ClassDB::bind_method(D_METHOD("gi_probe_create"), &RenderingServer::gi_probe_create);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &RenderingServer::gi_probe_set_bounds);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &RenderingServer::gi_probe_get_bounds);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &RenderingServer::gi_probe_set_cell_size);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &RenderingServer::gi_probe_get_cell_size);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &RenderingServer::gi_probe_set_to_cell_xform);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &RenderingServer::gi_probe_get_to_cell_xform);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &RenderingServer::gi_probe_set_dynamic_data);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &RenderingServer::gi_probe_get_dynamic_data);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &RenderingServer::gi_probe_set_dynamic_range);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &RenderingServer::gi_probe_get_dynamic_range);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &RenderingServer::gi_probe_set_energy);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &RenderingServer::gi_probe_get_energy);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &RenderingServer::gi_probe_set_bias);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &RenderingServer::gi_probe_get_bias);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &RenderingServer::gi_probe_set_normal_bias);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &RenderingServer::gi_probe_get_normal_bias);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &RenderingServer::gi_probe_set_propagation);
+ ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &RenderingServer::gi_probe_get_propagation);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &RenderingServer::gi_probe_set_interior);
+ ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &RenderingServer::gi_probe_is_interior);
+ ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &RenderingServer::gi_probe_set_compress);
+ ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &RenderingServer::gi_probe_is_compressed);
#endif
- ClassDB::bind_method(D_METHOD("lightmap_capture_create"), &VisualServer::lightmap_capture_create);
- ClassDB::bind_method(D_METHOD("lightmap_capture_set_bounds", "capture", "bounds"), &VisualServer::lightmap_capture_set_bounds);
- ClassDB::bind_method(D_METHOD("lightmap_capture_get_bounds", "capture"), &VisualServer::lightmap_capture_get_bounds);
- ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree", "capture", "octree"), &VisualServer::lightmap_capture_set_octree);
- ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_transform", "capture", "xform"), &VisualServer::lightmap_capture_set_octree_cell_transform);
- ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_transform", "capture"), &VisualServer::lightmap_capture_get_octree_cell_transform);
- ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_subdiv", "capture", "subdiv"), &VisualServer::lightmap_capture_set_octree_cell_subdiv);
- ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_subdiv", "capture"), &VisualServer::lightmap_capture_get_octree_cell_subdiv);
- ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &VisualServer::lightmap_capture_get_octree);
- ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &VisualServer::lightmap_capture_set_energy);
- ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &VisualServer::lightmap_capture_get_energy);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_create"), &RenderingServer::lightmap_capture_create);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_set_bounds", "capture", "bounds"), &RenderingServer::lightmap_capture_set_bounds);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_get_bounds", "capture"), &RenderingServer::lightmap_capture_get_bounds);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree", "capture", "octree"), &RenderingServer::lightmap_capture_set_octree);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_transform", "capture", "xform"), &RenderingServer::lightmap_capture_set_octree_cell_transform);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_transform", "capture"), &RenderingServer::lightmap_capture_get_octree_cell_transform);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_subdiv", "capture", "subdiv"), &RenderingServer::lightmap_capture_set_octree_cell_subdiv);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_subdiv", "capture"), &RenderingServer::lightmap_capture_get_octree_cell_subdiv);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &RenderingServer::lightmap_capture_get_octree);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &RenderingServer::lightmap_capture_set_energy);
+ ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &RenderingServer::lightmap_capture_get_energy);
#endif
- ClassDB::bind_method(D_METHOD("particles_create"), &VisualServer::particles_create);
- ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &VisualServer::particles_set_emitting);
- ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &VisualServer::particles_get_emitting);
- ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &VisualServer::particles_set_amount);
- ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &VisualServer::particles_set_lifetime);
- ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &VisualServer::particles_set_one_shot);
- ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &VisualServer::particles_set_pre_process_time);
- ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &VisualServer::particles_set_explosiveness_ratio);
- ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &VisualServer::particles_set_randomness_ratio);
- ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &VisualServer::particles_set_custom_aabb);
- ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &VisualServer::particles_set_speed_scale);
- ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &VisualServer::particles_set_use_local_coordinates);
- ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &VisualServer::particles_set_process_material);
- ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &VisualServer::particles_set_fixed_fps);
- ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &VisualServer::particles_set_fractional_delta);
- ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &VisualServer::particles_is_inactive);
- ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &VisualServer::particles_request_process);
- ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &VisualServer::particles_restart);
- ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &VisualServer::particles_set_draw_order);
- ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &VisualServer::particles_set_draw_passes);
- ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &VisualServer::particles_set_draw_pass_mesh);
- ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &VisualServer::particles_get_current_aabb);
- ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &VisualServer::particles_set_emission_transform);
-
- ClassDB::bind_method(D_METHOD("camera_create"), &VisualServer::camera_create);
- ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &VisualServer::camera_set_perspective);
- ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &VisualServer::camera_set_orthogonal);
- ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &VisualServer::camera_set_frustum);
- ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &VisualServer::camera_set_transform);
- ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &VisualServer::camera_set_cull_mask);
- ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &VisualServer::camera_set_environment);
- ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &VisualServer::camera_set_use_vertical_aspect);
-
- ClassDB::bind_method(D_METHOD("viewport_create"), &VisualServer::viewport_create);
- ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &VisualServer::viewport_set_use_arvr);
- ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &VisualServer::viewport_set_size);
- ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &VisualServer::viewport_set_active);
- ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &VisualServer::viewport_set_parent_viewport);
- ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &VisualServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(0));
- ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &VisualServer::viewport_set_render_direct_to_screen);
- ClassDB::bind_method(D_METHOD("viewport_detach", "viewport"), &VisualServer::viewport_detach);
- ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &VisualServer::viewport_set_update_mode);
- ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &VisualServer::viewport_set_clear_mode);
- ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &VisualServer::viewport_get_texture);
- ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &VisualServer::viewport_set_hide_scenario);
- ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &VisualServer::viewport_set_hide_canvas);
- ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &VisualServer::viewport_set_disable_environment);
- ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &VisualServer::viewport_attach_camera);
- ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &VisualServer::viewport_set_scenario);
- ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &VisualServer::viewport_attach_canvas);
- ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &VisualServer::viewport_remove_canvas);
- ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &VisualServer::viewport_set_canvas_transform);
- ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &VisualServer::viewport_set_transparent_background);
- ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &VisualServer::viewport_set_global_canvas_transform);
- ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &VisualServer::viewport_set_canvas_stacking);
- ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &VisualServer::viewport_set_shadow_atlas_size);
- ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &VisualServer::viewport_set_shadow_atlas_quadrant_subdivision);
- ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &VisualServer::viewport_set_msaa);
- ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &VisualServer::viewport_get_render_info);
- ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &VisualServer::viewport_set_debug_draw);
-
- ClassDB::bind_method(D_METHOD("environment_create"), &VisualServer::environment_create);
- ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &VisualServer::environment_set_background);
- ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &VisualServer::environment_set_sky);
- ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &VisualServer::environment_set_sky_custom_fov);
- ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &VisualServer::environment_set_sky_orientation);
- ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &VisualServer::environment_set_bg_color);
- ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &VisualServer::environment_set_bg_energy);
- ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &VisualServer::environment_set_canvas_max_layer);
- ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contibution", "reflection_source", "ao_color"), &VisualServer::environment_set_ambient_light, DEFVAL(VS::ENV_AMBIENT_SOURCE_BG), DEFVAL(1.0), DEFVAL(0.0), DEFVAL(VS::ENV_REFLECTION_SOURCE_BG), DEFVAL(Color()));
- ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale"), &VisualServer::environment_set_glow);
- ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &VisualServer::environment_set_tonemap);
- ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &VisualServer::environment_set_adjustment);
- ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &VisualServer::environment_set_ssr);
- ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "bias", "light_affect", "ao_channel_affect", "blur", "bilateral_sharpness"), &VisualServer::environment_set_ssao);
- ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "color", "sun_color", "sun_amount"), &VisualServer::environment_set_fog);
-
- ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "enable", "depth_begin", "depth_end", "depth_curve", "transmit", "transmit_curve"), &VisualServer::environment_set_fog_depth);
-
- ClassDB::bind_method(D_METHOD("environment_set_fog_height", "env", "enable", "min_height", "max_height", "height_curve"), &VisualServer::environment_set_fog_height);
-
- ClassDB::bind_method(D_METHOD("scenario_create"), &VisualServer::scenario_create);
- ClassDB::bind_method(D_METHOD("scenario_set_debug", "scenario", "debug_mode"), &VisualServer::scenario_set_debug);
- ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &VisualServer::scenario_set_environment);
- ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &VisualServer::scenario_set_fallback_environment);
+ ClassDB::bind_method(D_METHOD("particles_create"), &RenderingServer::particles_create);
+ ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &RenderingServer::particles_set_emitting);
+ ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &RenderingServer::particles_get_emitting);
+ ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &RenderingServer::particles_set_amount);
+ ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &RenderingServer::particles_set_lifetime);
+ ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &RenderingServer::particles_set_one_shot);
+ ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &RenderingServer::particles_set_pre_process_time);
+ ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &RenderingServer::particles_set_explosiveness_ratio);
+ ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &RenderingServer::particles_set_randomness_ratio);
+ ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &RenderingServer::particles_set_custom_aabb);
+ ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &RenderingServer::particles_set_speed_scale);
+ ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &RenderingServer::particles_set_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &RenderingServer::particles_set_process_material);
+ ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &RenderingServer::particles_set_fixed_fps);
+ ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &RenderingServer::particles_set_fractional_delta);
+ ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &RenderingServer::particles_is_inactive);
+ ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &RenderingServer::particles_request_process);
+ ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &RenderingServer::particles_restart);
+ ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &RenderingServer::particles_set_draw_order);
+ ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &RenderingServer::particles_set_draw_passes);
+ ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &RenderingServer::particles_set_draw_pass_mesh);
+ ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &RenderingServer::particles_get_current_aabb);
+ ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &RenderingServer::particles_set_emission_transform);
+
+ ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create);
+ ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &RenderingServer::camera_set_perspective);
+ ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &RenderingServer::camera_set_orthogonal);
+ ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &RenderingServer::camera_set_frustum);
+ ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &RenderingServer::camera_set_transform);
+ ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &RenderingServer::camera_set_cull_mask);
+ ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &RenderingServer::camera_set_environment);
+ ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect);
+
+ ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create);
+ ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &RenderingServer::viewport_set_use_arvr);
+ ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size);
+ ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active);
+ ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport);
+ ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &RenderingServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID));
+ ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &RenderingServer::viewport_set_render_direct_to_screen);
+
+ ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode);
+ ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode);
+ ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture);
+ ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &RenderingServer::viewport_set_hide_scenario);
+ ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &RenderingServer::viewport_set_hide_canvas);
+ ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &RenderingServer::viewport_set_disable_environment);
+ ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &RenderingServer::viewport_attach_camera);
+ ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &RenderingServer::viewport_set_scenario);
+ ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas);
+ ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas);
+ ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform);
+ ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &RenderingServer::viewport_set_transparent_background);
+ ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &RenderingServer::viewport_set_global_canvas_transform);
+ ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &RenderingServer::viewport_set_canvas_stacking);
+ ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &RenderingServer::viewport_set_shadow_atlas_size);
+ ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_shadow_atlas_quadrant_subdivision);
+ ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &RenderingServer::viewport_set_msaa);
+ ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &RenderingServer::viewport_get_render_info);
+ ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &RenderingServer::viewport_set_debug_draw);
+
+ ClassDB::bind_method(D_METHOD("environment_create"), &RenderingServer::environment_create);
+ ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &RenderingServer::environment_set_background);
+ ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &RenderingServer::environment_set_sky);
+ ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &RenderingServer::environment_set_sky_custom_fov);
+ ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &RenderingServer::environment_set_sky_orientation);
+ ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &RenderingServer::environment_set_bg_color);
+ ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &RenderingServer::environment_set_bg_energy);
+ ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer);
+ ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contibution", "reflection_source", "ao_color"), &RenderingServer::environment_set_ambient_light, DEFVAL(RS::ENV_AMBIENT_SOURCE_BG), DEFVAL(1.0), DEFVAL(0.0), DEFVAL(RS::ENV_REFLECTION_SOURCE_BG), DEFVAL(Color()));
+ ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale"), &RenderingServer::environment_set_glow);
+ ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &RenderingServer::environment_set_tonemap);
+ ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &RenderingServer::environment_set_adjustment);
+ ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &RenderingServer::environment_set_ssr);
+ ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "bias", "light_affect", "ao_channel_affect", "blur", "bilateral_sharpness"), &RenderingServer::environment_set_ssao);
+ ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "color", "sun_color", "sun_amount"), &RenderingServer::environment_set_fog);
+
+ ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "enable", "depth_begin", "depth_end", "depth_curve", "transmit", "transmit_curve"), &RenderingServer::environment_set_fog_depth);
+
+ ClassDB::bind_method(D_METHOD("environment_set_fog_height", "env", "enable", "min_height", "max_height", "height_curve"), &RenderingServer::environment_set_fog_height);
+
+ ClassDB::bind_method(D_METHOD("scenario_create"), &RenderingServer::scenario_create);
+ ClassDB::bind_method(D_METHOD("scenario_set_debug", "scenario", "debug_mode"), &RenderingServer::scenario_set_debug);
+ ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &RenderingServer::scenario_set_environment);
+ ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &RenderingServer::scenario_set_fallback_environment);
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &VisualServer::instance_create2);
- ClassDB::bind_method(D_METHOD("instance_create"), &VisualServer::instance_create);
- ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &VisualServer::instance_set_base);
- ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &VisualServer::instance_set_scenario);
- ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &VisualServer::instance_set_layer_mask);
- ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &VisualServer::instance_set_transform);
- ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &VisualServer::instance_attach_object_instance_id);
- ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &VisualServer::instance_set_blend_shape_weight);
- ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &VisualServer::instance_set_surface_material);
- ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &VisualServer::instance_set_visible);
- ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &VisualServer::instance_set_use_lightmap);
- ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &VisualServer::instance_set_custom_aabb);
- ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &VisualServer::instance_attach_skeleton);
- ClassDB::bind_method(D_METHOD("instance_set_exterior", "instance", "enabled"), &VisualServer::instance_set_exterior);
- ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &VisualServer::instance_set_extra_visibility_margin);
- ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &VisualServer::instance_geometry_set_flag);
- ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &VisualServer::instance_geometry_set_cast_shadows_setting);
- ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &VisualServer::instance_geometry_set_material_override);
- ClassDB::bind_method(D_METHOD("instance_geometry_set_draw_range", "instance", "min", "max", "min_margin", "max_margin"), &VisualServer::instance_geometry_set_draw_range);
- ClassDB::bind_method(D_METHOD("instance_geometry_set_as_instance_lod", "instance", "as_lod_of_instance"), &VisualServer::instance_geometry_set_as_instance_lod);
-
- ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &VisualServer::_instances_cull_aabb_bind, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &VisualServer::_instances_cull_ray_bind, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &VisualServer::_instances_cull_convex_bind, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &RenderingServer::instance_create2);
+ ClassDB::bind_method(D_METHOD("instance_create"), &RenderingServer::instance_create);
+ ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &RenderingServer::instance_set_base);
+ ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &RenderingServer::instance_set_scenario);
+ ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &RenderingServer::instance_set_layer_mask);
+ ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform);
+ ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight);
+ ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_material);
+ ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible);
+ ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &RenderingServer::instance_set_use_lightmap);
+ ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb);
+ ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &RenderingServer::instance_attach_skeleton);
+ ClassDB::bind_method(D_METHOD("instance_set_exterior", "instance", "enabled"), &RenderingServer::instance_set_exterior);
+ ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &RenderingServer::instance_set_extra_visibility_margin);
+ ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &RenderingServer::instance_geometry_set_flag);
+ ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &RenderingServer::instance_geometry_set_cast_shadows_setting);
+ ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &RenderingServer::instance_geometry_set_material_override);
+ ClassDB::bind_method(D_METHOD("instance_geometry_set_draw_range", "instance", "min", "max", "min_margin", "max_margin"), &RenderingServer::instance_geometry_set_draw_range);
+ ClassDB::bind_method(D_METHOD("instance_geometry_set_as_instance_lod", "instance", "as_lod_of_instance"), &RenderingServer::instance_geometry_set_as_instance_lod);
+
+ ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &RenderingServer::_instances_cull_convex_bind, DEFVAL(RID()));
#endif
- ClassDB::bind_method(D_METHOD("canvas_create"), &VisualServer::canvas_create);
- ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &VisualServer::canvas_set_item_mirroring);
- ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &VisualServer::canvas_set_modulate);
+ ClassDB::bind_method(D_METHOD("canvas_create"), &RenderingServer::canvas_create);
+ ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &RenderingServer::canvas_set_item_mirroring);
+ ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &RenderingServer::canvas_set_modulate);
#ifndef _MSC_VER
#warning TODO method bindings need to be fixed
#endif
#if 0
- ClassDB::bind_method(D_METHOD("canvas_item_create"), &VisualServer::canvas_item_create);
- ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &VisualServer::canvas_item_set_parent);
- ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &VisualServer::canvas_item_set_visible);
- ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &VisualServer::canvas_item_set_light_mask);
- ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &VisualServer::canvas_item_set_transform);
- ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &VisualServer::canvas_item_set_clip);
- ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &VisualServer::canvas_item_set_distance_field_mode);
- ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &VisualServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));
- ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &VisualServer::canvas_item_set_modulate);
- ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &VisualServer::canvas_item_set_self_modulate);
- ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &VisualServer::canvas_item_set_draw_behind_parent);
- ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &VisualServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &VisualServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &VisualServer::canvas_item_add_rect);
- ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &VisualServer::canvas_item_add_circle);
- ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &VisualServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles);
- ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &VisualServer::canvas_item_add_set_transform);
- ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &VisualServer::canvas_item_add_clip_ignore);
- ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &VisualServer::canvas_item_set_sort_children_by_y);
+ ClassDB::bind_method(D_METHOD("canvas_item_create"), &RenderingServer::canvas_item_create);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &RenderingServer::canvas_item_set_parent);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &RenderingServer::canvas_item_set_visible);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &RenderingServer::canvas_item_set_light_mask);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &RenderingServer::canvas_item_set_transform);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &RenderingServer::canvas_item_set_clip);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &RenderingServer::canvas_item_set_distance_field_mode);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &RenderingServer::canvas_item_set_custom_rect, DEFVAL(Rect2()));
+ ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &RenderingServer::canvas_item_set_modulate);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &RenderingServer::canvas_item_set_self_modulate);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &RenderingServer::canvas_item_set_draw_behind_parent);
+ ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &RenderingServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &RenderingServer::canvas_item_add_rect);
+ ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &RenderingServer::canvas_item_add_circle);
+ ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &RenderingServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &RenderingServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &RenderingServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &RenderingServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &RenderingServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased"), &RenderingServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &RenderingServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &RenderingServer::canvas_item_add_particles);
+ ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform);
+ ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y);
#endif
- ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &VisualServer::canvas_item_set_z_index);
- ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &VisualServer::canvas_item_set_z_as_relative_to_parent);
- ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &VisualServer::canvas_item_set_copy_to_backbuffer);
- ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &VisualServer::canvas_item_clear);
- ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &VisualServer::canvas_item_set_draw_index);
- ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &VisualServer::canvas_item_set_material);
- ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &VisualServer::canvas_item_set_use_parent_material);
- ClassDB::bind_method(D_METHOD("canvas_light_create"), &VisualServer::canvas_light_create);
- ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &VisualServer::canvas_light_attach_to_canvas);
- ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &VisualServer::canvas_light_set_enabled);
- ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &VisualServer::canvas_light_set_scale);
- ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &VisualServer::canvas_light_set_transform);
- ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &VisualServer::canvas_light_set_texture);
- ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &VisualServer::canvas_light_set_texture_offset);
- ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &VisualServer::canvas_light_set_color);
- ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &VisualServer::canvas_light_set_height);
- ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &VisualServer::canvas_light_set_energy);
- ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &VisualServer::canvas_light_set_z_range);
- ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &VisualServer::canvas_light_set_layer_range);
- ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_cull_mask);
- ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_shadow_cull_mask);
- ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &VisualServer::canvas_light_set_mode);
- ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &VisualServer::canvas_light_set_shadow_enabled);
- ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &VisualServer::canvas_light_set_shadow_buffer_size);
- ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &VisualServer::canvas_light_set_shadow_filter);
- ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &VisualServer::canvas_light_set_shadow_color);
- ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &VisualServer::canvas_light_set_shadow_smooth);
-
- ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &VisualServer::canvas_light_occluder_create);
- ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &VisualServer::canvas_light_occluder_attach_to_canvas);
- ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &VisualServer::canvas_light_occluder_set_enabled);
- ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &VisualServer::canvas_light_occluder_set_polygon);
- ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &VisualServer::canvas_light_occluder_set_transform);
- ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &VisualServer::canvas_light_occluder_set_light_mask);
-
- ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &VisualServer::canvas_occluder_polygon_create);
- ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &VisualServer::canvas_occluder_polygon_set_shape);
- ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &VisualServer::canvas_occluder_polygon_set_shape_as_lines);
- ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &VisualServer::canvas_occluder_polygon_set_cull_mode);
-
- ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_margins);
- ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_images);
-
- ClassDB::bind_method(D_METHOD("free_rid", "rid"), &VisualServer::free); // shouldn't conflict with Object::free()
-
- ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &VisualServer::request_frame_drawn_callback);
- ClassDB::bind_method(D_METHOD("has_changed"), &VisualServer::has_changed);
- ClassDB::bind_method(D_METHOD("init"), &VisualServer::init);
- ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish);
- ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info);
- ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &VisualServer::get_video_adapter_name);
- ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &VisualServer::get_video_adapter_vendor);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer);
+ ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material);
+ ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &RenderingServer::canvas_item_set_use_parent_material);
+ ClassDB::bind_method(D_METHOD("canvas_light_create"), &RenderingServer::canvas_light_create);
+ ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &RenderingServer::canvas_light_attach_to_canvas);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_enabled);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &RenderingServer::canvas_light_set_scale);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &RenderingServer::canvas_light_set_transform);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &RenderingServer::canvas_light_set_texture);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &RenderingServer::canvas_light_set_texture_offset);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &RenderingServer::canvas_light_set_color);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &RenderingServer::canvas_light_set_height);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &RenderingServer::canvas_light_set_energy);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &RenderingServer::canvas_light_set_z_range);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &RenderingServer::canvas_light_set_layer_range);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_cull_mask);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_shadow_cull_mask);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &RenderingServer::canvas_light_set_mode);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_shadow_enabled);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &RenderingServer::canvas_light_set_shadow_buffer_size);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color);
+ ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth);
+
+ ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &RenderingServer::canvas_light_occluder_create);
+ ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &RenderingServer::canvas_light_occluder_attach_to_canvas);
+ ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &RenderingServer::canvas_light_occluder_set_enabled);
+ ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &RenderingServer::canvas_light_occluder_set_polygon);
+ ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &RenderingServer::canvas_light_occluder_set_transform);
+ ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &RenderingServer::canvas_light_occluder_set_light_mask);
+
+ ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &RenderingServer::canvas_occluder_polygon_create);
+ ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &RenderingServer::canvas_occluder_polygon_set_shape);
+ ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &RenderingServer::canvas_occluder_polygon_set_shape_as_lines);
+ ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &RenderingServer::canvas_occluder_polygon_set_cull_mode);
+
+ ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &RenderingServer::black_bars_set_margins);
+ ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &RenderingServer::black_bars_set_images);
+
+ ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free); // shouldn't conflict with Object::free()
+
+ ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &RenderingServer::request_frame_drawn_callback);
+ ClassDB::bind_method(D_METHOD("has_changed"), &RenderingServer::has_changed);
+ ClassDB::bind_method(D_METHOD("init"), &RenderingServer::init);
+ ClassDB::bind_method(D_METHOD("finish"), &RenderingServer::finish);
+ ClassDB::bind_method(D_METHOD("get_render_info", "info"), &RenderingServer::get_render_info);
+ ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name);
+ ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor);
#ifndef _3D_DISABLED
- ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh);
- ClassDB::bind_method(D_METHOD("get_test_cube"), &VisualServer::get_test_cube);
+ ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh);
+ ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube);
#endif
- ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture);
- ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture);
+ ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture);
+ ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture);
- ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &VisualServer::set_boot_image, DEFVAL(true));
- ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color);
+ ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color);
- ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature);
- ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature);
- ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes);
+ ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature);
+ ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature);
+ ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes);
BIND_CONSTANT(NO_INDEX_ARRAY);
BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
@@ -2060,6 +2061,7 @@ void VisualServer::_bind_methods() {
BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED);
BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE);
BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE);
+ BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS);
BIND_ENUM_CONSTANT(VIEWPORT_CLEAR_ALWAYS);
@@ -2225,18 +2227,18 @@ void VisualServer::_bind_methods() {
ADD_SIGNAL(MethodInfo("frame_post_draw"));
}
-void VisualServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) {
+void RenderingServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) {
ERR_FAIL_COND(p_margins.size() != 4);
//canvas_item_add_style_box(p_item,p_rect,p_source,p_texture,Vector2(p_margins[0],p_margins[1]),Vector2(p_margins[2],p_margins[3]),true,p_modulate);
}
-void VisualServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
+void RenderingServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
camera_set_orthogonal(p_camera, p_size, p_z_near, p_z_far);
}
-void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {
+void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -2258,23 +2260,23 @@ void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::M
}
Array d;
- d.resize(VS::ARRAY_MAX);
+ d.resize(RS::ARRAY_MAX);
d[ARRAY_VERTEX] = vertices;
d[ARRAY_NORMAL] = normals;
mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d);
}
-void VisualServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {
+void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {
Geometry::MeshData mdata = Geometry::build_convex_mesh(p_planes);
mesh_add_surface_from_mesh_data(p_mesh, mdata);
}
-void VisualServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex) {
+void RenderingServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex) {
immediate_vertex(p_immediate, Vector3(p_vertex.x, p_vertex.y, 0));
}
-RID VisualServer::instance_create2(RID p_base, RID p_scenario) {
+RID RenderingServer::instance_create2(RID p_base, RID p_scenario) {
RID instance = instance_create();
instance_set_base(instance, p_base);
@@ -2282,7 +2284,7 @@ RID VisualServer::instance_create2(RID p_base, RID p_scenario) {
return instance;
}
-VisualServer::VisualServer() {
+RenderingServer::RenderingServer() {
//ERR_FAIL_COND(singleton);
singleton = this;
@@ -2355,7 +2357,7 @@ VisualServer::VisualServer() {
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/screen_space_roughness_limiter_curve", PropertyInfo(Variant::FLOAT, "rendering/quality/filters/screen_space_roughness_limiter_curve", PROPERTY_HINT_EXP_EASING, "0.01,8,0.01"));
}
-VisualServer::~VisualServer() {
+RenderingServer::~RenderingServer() {
singleton = NULL;
}
diff --git a/servers/visual_server.h b/servers/rendering_server.h
index dfe5e7feed..76f16bd7f6 100644
--- a/servers/visual_server.h
+++ b/servers/rendering_server.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* visual_server.h */
+/* rendering_server.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef VISUAL_SERVER_H
-#define VISUAL_SERVER_H
+#ifndef RENDERING_SERVER_H
+#define RENDERING_SERVER_H
#include "core/image.h"
#include "core/math/geometry.h"
@@ -37,12 +37,13 @@
#include "core/object.h"
#include "core/rid.h"
#include "core/variant.h"
+#include "servers/display_server.h"
-class VisualServer : public Object {
+class RenderingServer : public Object {
- GDCLASS(VisualServer, Object);
+ GDCLASS(RenderingServer, Object);
- static VisualServer *singleton;
+ static RenderingServer *singleton;
int mm_policy;
@@ -59,12 +60,12 @@ protected:
Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb);
- static VisualServer *(*create_func)();
+ static RenderingServer *(*create_func)();
static void _bind_methods();
public:
- static VisualServer *get_singleton();
- static VisualServer *create();
+ static RenderingServer *get_singleton();
+ static RenderingServer *create();
enum {
NO_INDEX_ARRAY = -1,
@@ -584,14 +585,14 @@ public:
virtual void viewport_set_active(RID p_viewport, bool p_active) = 0;
virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0;
- virtual void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), int p_screen = 0) = 0;
+ virtual void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), DisplayServer::WindowID p_screen = DisplayServer::MAIN_WINDOW_ID) = 0;
virtual void viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) = 0;
- virtual void viewport_detach(RID p_viewport) = 0;
enum ViewportUpdateMode {
VIEWPORT_UPDATE_DISABLED,
VIEWPORT_UPDATE_ONCE, //then goes to disabled, must be manually updated
VIEWPORT_UPDATE_WHEN_VISIBLE, // default
+ VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE,
VIEWPORT_UPDATE_ALWAYS
};
@@ -1102,55 +1103,55 @@ public:
virtual bool is_low_end() const = 0;
- VisualServer();
- virtual ~VisualServer();
+ RenderingServer();
+ virtual ~RenderingServer();
};
// make variant understand the enums
-VARIANT_ENUM_CAST(VisualServer::TextureLayeredType);
-VARIANT_ENUM_CAST(VisualServer::CubeMapLayer);
-VARIANT_ENUM_CAST(VisualServer::ShaderMode);
-VARIANT_ENUM_CAST(VisualServer::ArrayType);
-VARIANT_ENUM_CAST(VisualServer::ArrayFormat);
-VARIANT_ENUM_CAST(VisualServer::PrimitiveType);
-VARIANT_ENUM_CAST(VisualServer::BlendShapeMode);
-VARIANT_ENUM_CAST(VisualServer::MultimeshTransformFormat);
-VARIANT_ENUM_CAST(VisualServer::LightType);
-VARIANT_ENUM_CAST(VisualServer::LightParam);
-VARIANT_ENUM_CAST(VisualServer::LightOmniShadowMode);
-VARIANT_ENUM_CAST(VisualServer::LightDirectionalShadowMode);
-VARIANT_ENUM_CAST(VisualServer::LightDirectionalShadowDepthRangeMode);
-VARIANT_ENUM_CAST(VisualServer::ReflectionProbeUpdateMode);
-VARIANT_ENUM_CAST(VisualServer::ParticlesDrawOrder);
-VARIANT_ENUM_CAST(VisualServer::ViewportUpdateMode);
-VARIANT_ENUM_CAST(VisualServer::ViewportClearMode);
-VARIANT_ENUM_CAST(VisualServer::ViewportMSAA);
-VARIANT_ENUM_CAST(VisualServer::ViewportRenderInfo);
-VARIANT_ENUM_CAST(VisualServer::ViewportDebugDraw);
-VARIANT_ENUM_CAST(VisualServer::SkyMode);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentBG);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentAmbientSource);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentReflectionSource);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentGlowBlendMode);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentToneMapper);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOQuality);
-VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOBlur);
-VARIANT_ENUM_CAST(VisualServer::DOFBlurQuality);
-VARIANT_ENUM_CAST(VisualServer::DOFBokehShape);
-VARIANT_ENUM_CAST(VisualServer::ScenarioDebugMode);
-VARIANT_ENUM_CAST(VisualServer::InstanceType);
-VARIANT_ENUM_CAST(VisualServer::InstanceFlags);
-VARIANT_ENUM_CAST(VisualServer::ShadowCastingSetting);
-VARIANT_ENUM_CAST(VisualServer::NinePatchAxisMode);
-VARIANT_ENUM_CAST(VisualServer::CanvasItemTextureFilter);
-VARIANT_ENUM_CAST(VisualServer::CanvasItemTextureRepeat);
-VARIANT_ENUM_CAST(VisualServer::CanvasLightMode);
-VARIANT_ENUM_CAST(VisualServer::CanvasLightShadowFilter);
-VARIANT_ENUM_CAST(VisualServer::CanvasOccluderPolygonCullMode);
-VARIANT_ENUM_CAST(VisualServer::RenderInfo);
-VARIANT_ENUM_CAST(VisualServer::Features);
-
-//typedef VisualServer VS; // makes it easier to use
-#define VS VisualServer
+VARIANT_ENUM_CAST(RenderingServer::TextureLayeredType);
+VARIANT_ENUM_CAST(RenderingServer::CubeMapLayer);
+VARIANT_ENUM_CAST(RenderingServer::ShaderMode);
+VARIANT_ENUM_CAST(RenderingServer::ArrayType);
+VARIANT_ENUM_CAST(RenderingServer::ArrayFormat);
+VARIANT_ENUM_CAST(RenderingServer::PrimitiveType);
+VARIANT_ENUM_CAST(RenderingServer::BlendShapeMode);
+VARIANT_ENUM_CAST(RenderingServer::MultimeshTransformFormat);
+VARIANT_ENUM_CAST(RenderingServer::LightType);
+VARIANT_ENUM_CAST(RenderingServer::LightParam);
+VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowMode);
+VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowMode);
+VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowDepthRangeMode);
+VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeUpdateMode);
+VARIANT_ENUM_CAST(RenderingServer::ParticlesDrawOrder);
+VARIANT_ENUM_CAST(RenderingServer::ViewportUpdateMode);
+VARIANT_ENUM_CAST(RenderingServer::ViewportClearMode);
+VARIANT_ENUM_CAST(RenderingServer::ViewportMSAA);
+VARIANT_ENUM_CAST(RenderingServer::ViewportRenderInfo);
+VARIANT_ENUM_CAST(RenderingServer::ViewportDebugDraw);
+VARIANT_ENUM_CAST(RenderingServer::SkyMode);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentBG);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentAmbientSource);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentReflectionSource);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentGlowBlendMode);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentToneMapper);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSAOQuality);
+VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSAOBlur);
+VARIANT_ENUM_CAST(RenderingServer::DOFBlurQuality);
+VARIANT_ENUM_CAST(RenderingServer::DOFBokehShape);
+VARIANT_ENUM_CAST(RenderingServer::ScenarioDebugMode);
+VARIANT_ENUM_CAST(RenderingServer::InstanceType);
+VARIANT_ENUM_CAST(RenderingServer::InstanceFlags);
+VARIANT_ENUM_CAST(RenderingServer::ShadowCastingSetting);
+VARIANT_ENUM_CAST(RenderingServer::NinePatchAxisMode);
+VARIANT_ENUM_CAST(RenderingServer::CanvasItemTextureFilter);
+VARIANT_ENUM_CAST(RenderingServer::CanvasItemTextureRepeat);
+VARIANT_ENUM_CAST(RenderingServer::CanvasLightMode);
+VARIANT_ENUM_CAST(RenderingServer::CanvasLightShadowFilter);
+VARIANT_ENUM_CAST(RenderingServer::CanvasOccluderPolygonCullMode);
+VARIANT_ENUM_CAST(RenderingServer::RenderInfo);
+VARIANT_ENUM_CAST(RenderingServer::Features);
+
+//typedef RenderingServer VS; // makes it easier to use
+#define RS RenderingServer
#endif
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
deleted file mode 100644
index 7307f7527a..0000000000
--- a/servers/visual/shader_types.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-/*************************************************************************/
-/* shader_types.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "shader_types.h"
-
-const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(VS::ShaderMode p_mode) {
-
- return shader_modes[p_mode].functions;
-}
-
-const Vector<StringName> &ShaderTypes::get_modes(VS::ShaderMode p_mode) {
-
- return shader_modes[p_mode].modes;
-}
-
-const Set<String> &ShaderTypes::get_types() {
- return shader_types;
-}
-
-ShaderTypes *ShaderTypes::singleton = NULL;
-
-static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) {
-
- return ShaderLanguage::BuiltInInfo(p_type, true);
-}
-
-ShaderTypes::ShaderTypes() {
- singleton = this;
-
- /*************** SPATIAL ***********************/
-
- shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
-
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["UV2"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_ID"] = constt(ShaderLanguage::TYPE_INT);
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].can_discard = false;
-
- //builtins
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_MATRIX"] = ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3;
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
-
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["FRONT_FACING"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SPECULAR"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM_TINT"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT_GLOSS"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["AO_LIGHT_AFFECT"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
-
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
-
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_NORMAL_MATRIX"] = constt(ShaderLanguage::TYPE_MAT3);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SPATIAL].functions["fragment"].can_discard = true;
-
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
-
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ATTENUATION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ALBEDO"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["TRANSMISSION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ROUGHNESS"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["DIFFUSE_LIGHT"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_LIGHT"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
-
- shader_modes[VS::SHADER_SPATIAL].functions["light"].can_discard = true;
-
- //order used puts first enum mode (default) first
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_mix");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_add");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_sub");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_mul");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_opaque");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_always");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_never");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_prepass_alpha");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_test_disabled");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_back");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_front");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_disabled");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("unshaded");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("wireframe");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_lambert");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_lambert_wrap");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_oren_nayar");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_burley");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_toon");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_schlick_ggx");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_blinn");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_phong");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_toon");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_disabled");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("skip_vertex_transform");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("world_vertex_coords");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("shadows_disabled");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("ambient_light_disabled");
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("shadow_to_opacity");
-
- shader_modes[VS::SHADER_SPATIAL].modes.push_back("vertex_lighting");
-
- /************ CANVAS ITEM **************************/
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["CANVAS_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["SCREEN_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].can_discard = false;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SHADOW_VERTEX"] = ShaderLanguage::TYPE_VEC2;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["LIGHT_VERTEX"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].can_discard = true;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_VERTEX"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SHADOW_MODULATE"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].can_discard = true;
-
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("skip_vertex_transform");
-
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_mix");
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_add");
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_sub");
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_mul");
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_premul_alpha");
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_disabled");
-
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("unshaded");
- shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("light_only");
-
- /************ PARTICLES **************************/
-
- shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["MASS"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["ACTIVE"] = ShaderLanguage::TYPE_BOOL;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["RESTART"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["CUSTOM"] = ShaderLanguage::TYPE_VEC4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["TRANSFORM"] = ShaderLanguage::TYPE_MAT4;
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["LIFETIME"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["DELTA"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["NUMBER"] = constt(ShaderLanguage::TYPE_UINT);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["INDEX"] = constt(ShaderLanguage::TYPE_INT);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["EMISSION_TRANSFORM"] = constt(ShaderLanguage::TYPE_MAT4);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["RANDOM_SEED"] = constt(ShaderLanguage::TYPE_UINT);
- shader_modes[VS::SHADER_PARTICLES].functions["vertex"].can_discard = false;
-
- shader_modes[VS::SHADER_PARTICLES].modes.push_back("disable_force");
- shader_modes[VS::SHADER_PARTICLES].modes.push_back("disable_velocity");
- shader_modes[VS::SHADER_PARTICLES].modes.push_back("keep_data");
-
- /************ SKY **************************/
-
- shader_modes[VS::SHADER_SKY].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT;
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["EYEDIR"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["SKY_COORDS"] = constt(ShaderLanguage::TYPE_VEC2);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["POSITION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["HALF_RES_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["QUARTER_RES_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["RADIANCE"] = constt(ShaderLanguage::TYPE_SAMPLERCUBE);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["AT_HALF_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["AT_QUARTER_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["AT_CUBEMAP_PASS"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT0_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT0_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT0_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT0_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT1_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT1_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT1_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT1_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT2_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT2_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT2_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT2_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT3_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT3_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT3_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT);
- shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["LIGHT3_COLOR"] = constt(ShaderLanguage::TYPE_VEC3);
-
- shader_modes[VS::SHADER_SKY].modes.push_back("use_half_res_pass");
- shader_modes[VS::SHADER_SKY].modes.push_back("use_quarter_res_pass");
-
- shader_types.insert("spatial");
- shader_types.insert("canvas_item");
- shader_types.insert("particles");
- shader_types.insert("sky");
-}
diff --git a/servers/visual/visual_server_globals.cpp b/servers/visual/visual_server_globals.cpp
deleted file mode 100644
index 248d27e08a..0000000000
--- a/servers/visual/visual_server_globals.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************************************/
-/* visual_server_globals.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "visual_server_globals.h"
-
-RasterizerStorage *VisualServerGlobals::storage = NULL;
-RasterizerCanvas *VisualServerGlobals::canvas_render = NULL;
-RasterizerScene *VisualServerGlobals::scene_render = NULL;
-Rasterizer *VisualServerGlobals::rasterizer = NULL;
-
-VisualServerCanvas *VisualServerGlobals::canvas = NULL;
-VisualServerViewport *VisualServerGlobals::viewport = NULL;
-VisualServerScene *VisualServerGlobals::scene = NULL;
diff --git a/servers/visual/visual_server_light_baker.cpp b/servers/visual/visual_server_light_baker.cpp
deleted file mode 100644
index 4f9ade5017..0000000000
--- a/servers/visual/visual_server_light_baker.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*************************************************************************/
-/* visual_server_light_baker.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "visual_server_light_baker.h"
-
-VisualServerLightBaker::VisualServerLightBaker() {
-}
diff --git a/servers/visual/visual_server_light_baker.h b/servers/visual/visual_server_light_baker.h
deleted file mode 100644
index d88090c473..0000000000
--- a/servers/visual/visual_server_light_baker.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*************************************************************************/
-/* visual_server_light_baker.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef VISUALSERVERLIGHTBAKER_H
-#define VISUALSERVERLIGHTBAKER_H
-
-#include "servers/visual_server.h"
-
-class VisualServerLightBaker {
-public:
- struct BakeCell {
-
- uint32_t cells[8];
- uint32_t neighbours[7]; //one unused
- uint32_t albedo; //albedo in RGBE
- uint32_t emission; //emissive light in RGBE
- uint32_t light[4]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast)
- float alpha; //used for upsampling
- uint32_t directional_pass; //used for baking directional
- };
-
- VisualServerLightBaker();
-};
-
-#endif // VISUALSERVERLIGHTBAKER_H
diff --git a/thirdparty/README.md b/thirdparty/README.md
index b52b68fe47..3d41c9d166 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -360,6 +360,10 @@ Collection of single-file libraries used in Godot components.
* Upstream: https://sourceforge.net/projects/polyclipping
* Version: 6.4.2 + Godot changes (added optional exceptions handling)
* License: BSL-1.0
+- `cubemap_coeffs.h`
+ * Upstream: https://research.activision.com/publications/archives/fast-filtering-of-reflection-probes
+ File coeffs_const_8.txt
+ * License: MIT
- `fastlz.{c,h}`
* Upstream: https://github.com/ariya/FastLZ
* Version: git (f121734, 2007)
diff --git a/servers/visual/rasterizer_rd/cubemap_coeffs.h b/thirdparty/misc/cubemap_coeffs.h
index 1db03ce7c4..1db03ce7c4 100644
--- a/servers/visual/rasterizer_rd/cubemap_coeffs.h
+++ b/thirdparty/misc/cubemap_coeffs.h