summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.mailmap6
-rw-r--r--AUTHORS.md8
-rw-r--r--COPYRIGHT.txt12
-rw-r--r--DONORS.md104
-rw-r--r--SConstruct1
-rw-r--r--core/core_bind.cpp47
-rw-r--r--core/core_bind.h5
-rw-r--r--core/input/input_event.cpp6
-rw-r--r--core/input/input_map.cpp2
-rw-r--r--core/io/image.cpp8
-rw-r--r--core/io/packet_peer.cpp46
-rw-r--r--core/io/packet_peer.h23
-rw-r--r--core/io/resource_uid.cpp3
-rw-r--r--core/io/stream_peer.cpp57
-rw-r--r--core/io/stream_peer.h25
-rw-r--r--core/math/bvh_cull.inc2
-rw-r--r--core/math/bvh_debug.inc27
-rw-r--r--core/math/bvh_split.inc16
-rw-r--r--core/math/face3.cpp4
-rw-r--r--core/math/static_raycaster.cpp (renamed from modules/gdnative/net/register_types.h)15
-rw-r--r--core/math/static_raycaster.h111
-rw-r--r--core/math/transform_2d.cpp2
-rw-r--r--core/math/vector2.cpp2
-rw-r--r--core/multiplayer/multiplayer_peer.cpp181
-rw-r--r--core/multiplayer/multiplayer_peer.h80
-rw-r--r--core/os/os.cpp5
-rw-r--r--core/os/os.h1
-rw-r--r--core/os/thread.cpp6
-rw-r--r--core/os/thread.h9
-rw-r--r--core/register_core_types.cpp3
-rw-r--r--core/string/translation.cpp13
-rw-r--r--core/string/translation.h5
-rw-r--r--core/templates/rid_owner.h16
-rw-r--r--core/variant/callable.cpp4
-rw-r--r--core/variant/callable.h2
-rw-r--r--core/variant/native_ptr.h3
-rw-r--r--core/variant/variant_call.cpp2
-rw-r--r--doc/classes/@GlobalScope.xml71
-rw-r--r--doc/classes/AnimatableBody2D.xml2
-rw-r--r--doc/classes/AnimatableBody3D.xml2
-rw-r--r--doc/classes/CharacterBody2D.xml53
-rw-r--r--doc/classes/CharacterBody3D.xml23
-rw-r--r--doc/classes/ColorPicker.xml1
-rw-r--r--doc/classes/ColorPickerButton.xml1
-rw-r--r--doc/classes/Dictionary.xml3
-rw-r--r--doc/classes/Engine.xml25
-rw-r--r--doc/classes/HTTPClient.xml1
-rw-r--r--doc/classes/HTTPRequest.xml2
-rw-r--r--doc/classes/LineEdit.xml18
-rw-r--r--doc/classes/MultiplayerAPI.xml1
-rw-r--r--doc/classes/MultiplayerPeer.xml5
-rw-r--r--doc/classes/MultiplayerPeerExtension.xml99
-rw-r--r--doc/classes/Node.xml6
-rw-r--r--doc/classes/OS.xml2
-rw-r--r--doc/classes/PacketPeer.xml1
-rw-r--r--doc/classes/PacketPeerDTLS.xml1
-rw-r--r--doc/classes/PacketPeerExtension.xml35
-rw-r--r--doc/classes/PacketPeerStream.xml1
-rw-r--r--doc/classes/PacketPeerUDP.xml1
-rw-r--r--doc/classes/PhysicsBody2D.xml10
-rw-r--r--doc/classes/PhysicsBody3D.xml10
-rw-r--r--doc/classes/PhysicsServer2D.xml6
-rw-r--r--doc/classes/PhysicsServer3D.xml6
-rw-r--r--doc/classes/RigidDynamicBody2D.xml33
-rw-r--r--doc/classes/RigidDynamicBody3D.xml33
-rw-r--r--doc/classes/Signal.xml14
-rw-r--r--doc/classes/StreamPeer.xml1
-rw-r--r--doc/classes/StreamPeerExtension.xml48
-rw-r--r--doc/classes/StreamPeerSSL.xml1
-rw-r--r--doc/classes/StreamPeerTCP.xml1
-rw-r--r--doc/classes/TCPServer.xml1
-rw-r--r--doc/classes/TabContainer.xml24
-rw-r--r--doc/classes/Tabs.xml7
-rw-r--r--doc/classes/Thread.xml9
-rw-r--r--doc/classes/TileData.xml30
-rw-r--r--doc/classes/TileMap.xml18
-rw-r--r--doc/classes/Translation.xml18
-rw-r--r--doc/classes/Tween.xml1
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp206
-rw-r--r--drivers/vulkan/vulkan_context.cpp8
-rw-r--r--editor/debugger/script_editor_debugger.cpp8
-rw-r--r--editor/editor_data.cpp32
-rw-r--r--editor/editor_dir_dialog.cpp1
-rw-r--r--editor/editor_node.cpp105
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_plugin.cpp6
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/editor_spin_slider.cpp55
-rw-r--r--editor/editor_spin_slider.h1
-rw-r--r--editor/editor_themes.cpp1
-rw-r--r--editor/export_template_manager.cpp2
-rw-r--r--editor/filesystem_dock.cpp6
-rw-r--r--editor/icons/Breakpoint.svg1
-rw-r--r--editor/import/resource_importer_scene.cpp15
-rw-r--r--editor/import/scene_importer_mesh.cpp499
-rw-r--r--editor/import/scene_importer_mesh.h14
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp15
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp17
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp2
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp12
-rw-r--r--editor/plugins/item_list_editor_plugin.h2
-rw-r--r--editor/plugins/lightmap_gi_editor_plugin.cpp4
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp13
-rw-r--r--editor/plugins/occluder_instance_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp9
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp30
-rw-r--r--editor/plugins/script_editor_plugin.h1
-rw-r--r--editor/plugins/texture_editor_plugin.cpp27
-rw-r--r--editor/plugins/texture_editor_plugin.h2
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp5
-rw-r--r--editor/plugins/theme_editor_preview.cpp4
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp93
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp2
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp21
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.h1
-rw-r--r--editor/plugins/voxel_gi_editor_plugin.cpp2
-rw-r--r--editor/scene_tree_dock.cpp62
-rw-r--r--editor/scene_tree_editor.cpp8
-rw-r--r--main/main.cpp17
-rw-r--r--methods.py11
-rw-r--r--misc/dist/osx_tools.app/Contents/Resources/Godot.icnsbin67500 -> 271163 bytes
-rw-r--r--modules/bullet/SCsub11
-rw-r--r--modules/bullet/bullet_physics_server.cpp360
-rw-r--r--modules/bullet/rigid_body_bullet.cpp12
-rw-r--r--modules/bullet/space_bullet.cpp10
-rw-r--r--modules/csg/csg.cpp40
-rw-r--r--modules/csg/csg_shape.cpp450
-rw-r--r--modules/csg/csg_shape.h18
-rw-r--r--modules/csg/doc_classes/CSGPolygon3D.xml15
-rw-r--r--modules/enet/doc_classes/ENetMultiplayerPeer.xml2
-rw-r--r--modules/enet/doc_classes/ENetPacketPeer.xml1
-rw-r--r--modules/enet/enet_multiplayer_peer.cpp39
-rw-r--r--modules/enet/enet_multiplayer_peer.h40
-rw-r--r--modules/gdnative/SCsub1
-rw-r--r--modules/gdnative/config.py5
-rw-r--r--modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/PacketPeerGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/StreamPeerGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml9
-rw-r--r--modules/gdnative/gdnative_api.json91
-rw-r--r--modules/gdnative/gdnative_builders.py1
-rw-r--r--modules/gdnative/include/net/godot_net.h122
-rw-r--r--modules/gdnative/include/net/godot_webrtc.h123
-rw-r--r--modules/gdnative/net/SCsub12
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp136
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.h79
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.cpp72
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.h59
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.cpp77
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.h60
-rw-r--r--modules/gdnative/net/webrtc_gdnative.cpp60
-rw-r--r--modules/gdnative/register_types.cpp3
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp15
-rw-r--r--modules/gdscript/gdscript_compiler.cpp36
-rw-r--r--modules/gdscript/gdscript_editor.cpp2
-rw-r--r--modules/gdscript/gdscript_vm.cpp12
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp17
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.h3
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp59
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.h4
-rw-r--r--modules/gdscript/language_server/lsp.hpp22
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd5
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.gd11
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.out8
-rw-r--r--modules/gltf/doc_classes/GLTFLight.xml16
-rw-r--r--modules/gltf/editor_scene_exporter_gltf_plugin.cpp2
-rw-r--r--modules/gltf/gltf_document.cpp642
-rw-r--r--modules/gltf/gltf_document.h63
-rw-r--r--modules/gltf/gltf_light.h8
-rw-r--r--modules/gltf/gltf_state.h5
-rw-r--r--modules/gridmap/grid_map.cpp5
-rw-r--r--modules/mobile_vr/register_types.cpp17
-rw-r--r--modules/mono/csharp_script.cpp4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs4
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.cpp8
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.h4
-rw-r--r--modules/navigation/godot_navigation_server.cpp82
-rw-r--r--modules/navigation/nav_map.cpp4
-rw-r--r--modules/raycast/SCsub1
-rw-r--r--modules/raycast/lightmap_raycaster.cpp9
-rw-r--r--modules/raycast/lightmap_raycaster.h2
-rw-r--r--modules/raycast/raycast_occlusion_cull.cpp14
-rw-r--r--modules/raycast/register_types.cpp5
-rw-r--r--modules/raycast/static_raycaster.cpp137
-rw-r--r--modules/raycast/static_raycaster.h (renamed from modules/gdnative/net/register_types.cpp)45
-rw-r--r--modules/text_server_adv/text_server_adv.cpp256
-rw-r--r--modules/text_server_adv/text_server_adv.h1
-rw-r--r--modules/text_server_fb/text_server_fb.cpp268
-rw-r--r--modules/webrtc/SCsub5
-rw-r--r--modules/webrtc/config.py2
-rw-r--r--modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml106
-rw-r--r--modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml5
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml71
-rw-r--r--modules/webrtc/register_types.cpp26
-rw-r--r--modules/webrtc/webrtc_data_channel_extension.cpp215
-rw-r--r--modules/webrtc/webrtc_data_channel_extension.h (renamed from modules/webrtc/webrtc_data_channel_gdnative.h)53
-rw-r--r--modules/webrtc/webrtc_data_channel_gdnative.cpp143
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.cpp30
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.h10
-rw-r--r--modules/webrtc/webrtc_peer_connection.cpp24
-rw-r--r--modules/webrtc/webrtc_peer_connection.h7
-rw-r--r--modules/webrtc/webrtc_peer_connection_extension.cpp131
-rw-r--r--modules/webrtc/webrtc_peer_connection_extension.h (renamed from modules/webrtc/webrtc_peer_connection_gdnative.h)47
-rw-r--r--modules/webrtc/webrtc_peer_connection_gdnative.cpp121
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.h3
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml1
-rw-r--r--modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml5
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml1
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp25
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h7
-rw-r--r--modules/webxr/register_types.cpp21
-rw-r--r--platform/javascript/.eslintrc.js8
-rw-r--r--platform/javascript/display_server_javascript.cpp7
-rw-r--r--platform/javascript/display_server_javascript.h2
-rw-r--r--platform/javascript/js/libs/library_godot_audio.js2
-rw-r--r--platform/osx/export/export_plugin.cpp53
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm20
-rw-r--r--scene/2d/cpu_particles_2d.cpp2
-rw-r--r--scene/2d/navigation_region_2d.cpp2
-rw-r--r--scene/2d/physical_bone_2d.cpp20
-rw-r--r--scene/2d/physics_body_2d.cpp248
-rw-r--r--scene/2d/physics_body_2d.h64
-rw-r--r--scene/2d/skeleton_2d.cpp2
-rw-r--r--scene/2d/tile_map.cpp280
-rw-r--r--scene/2d/tile_map.h13
-rw-r--r--scene/3d/bone_attachment_3d.cpp2
-rw-r--r--scene/3d/collision_shape_3d.cpp3
-rw-r--r--scene/3d/gpu_particles_3d.cpp2
-rw-r--r--scene/3d/physics_body_3d.cpp262
-rw-r--r--scene/3d/physics_body_3d.h60
-rw-r--r--scene/3d/skeleton_ik_3d.cpp4
-rw-r--r--scene/3d/vehicle_body_3d.cpp6
-rw-r--r--scene/animation/SCsub3
-rw-r--r--scene/animation/easing_equations.h405
-rw-r--r--scene/animation/tween.cpp25
-rw-r--r--scene/gui/code_edit.cpp25
-rw-r--r--scene/gui/color_picker.cpp8
-rw-r--r--scene/gui/graph_edit.cpp5
-rw-r--r--scene/gui/graph_node.cpp24
-rw-r--r--scene/gui/graph_node.h5
-rw-r--r--scene/gui/line_edit.cpp30
-rw-r--r--scene/gui/line_edit.h7
-rw-r--r--scene/gui/rich_text_label.cpp3
-rw-r--r--scene/gui/tab_container.cpp6
-rw-r--r--scene/gui/tabs.cpp32
-rw-r--r--scene/gui/text_edit.cpp39
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/gui/texture_progress_bar.cpp5
-rw-r--r--scene/gui/tree.cpp127
-rw-r--r--scene/gui/tree.h6
-rw-r--r--scene/main/http_request.cpp8
-rw-r--r--scene/main/node.cpp38
-rw-r--r--scene/main/node.h6
-rw-r--r--scene/main/scene_tree.cpp2
-rw-r--r--scene/resources/packed_scene.cpp16
-rw-r--r--scene/resources/primitive_meshes.cpp8
-rw-r--r--scene/resources/primitive_meshes.h2
-rw-r--r--scene/resources/skeleton_modification_2d.cpp42
-rw-r--r--scene/resources/skeleton_modification_2d_fabrik.cpp4
-rw-r--r--scene/resources/skeleton_modification_2d_twoboneik.cpp2
-rw-r--r--scene/resources/skeleton_modification_3d.cpp40
-rw-r--r--scene/resources/skeleton_modification_3d_fabrik.cpp4
-rw-r--r--scene/resources/surface_tool.cpp1
-rw-r--r--scene/resources/texture.cpp8
-rw-r--r--scene/resources/texture.h2
-rw-r--r--scene/resources/tile_set.cpp106
-rw-r--r--scene/resources/tile_set.h8
-rw-r--r--servers/physics_2d/body_2d_sw.cpp4
-rw-r--r--servers/physics_2d/body_direct_state_2d_sw.cpp10
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp272
-rw-r--r--servers/physics_2d/space_2d_sw.cpp32
-rw-r--r--servers/physics_2d/space_2d_sw.h1
-rw-r--r--servers/physics_3d/body_3d_sw.cpp4
-rw-r--r--servers/physics_3d/body_direct_state_3d_sw.cpp8
-rw-r--r--servers/physics_3d/physics_server_3d_sw.cpp374
-rw-r--r--servers/physics_3d/soft_body_3d_sw.cpp6
-rw-r--r--servers/physics_3d/space_3d_sw.cpp36
-rw-r--r--servers/physics_3d/space_3d_sw.h1
-rw-r--r--servers/physics_server_2d.cpp3
-rw-r--r--servers/physics_server_2d.h3
-rw-r--r--servers/physics_server_3d.cpp3
-rw-r--r--servers/physics_server_3d.h3
-rw-r--r--servers/rendering/rasterizer_dummy.h6
-rw-r--r--servers/rendering/renderer_canvas_cull.cpp200
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp2
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp2
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp25
-rw-r--r--servers/rendering/renderer_rd/renderer_compositor_rd.cpp2
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp18
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_gi_rd.h2
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp325
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.h75
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp2
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp667
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.h101
-rw-r--r--servers/rendering/renderer_rd/shader_rd.cpp10
-rw-r--r--servers/rendering/renderer_rd/shader_rd.h2
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl2
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl2
-rw-r--r--servers/rendering/renderer_scene_cull.cpp106
-rw-r--r--servers/rendering/renderer_viewport.cpp90
-rw-r--r--servers/rendering_server.h2
-rw-r--r--servers/xr/xr_interface_extension.cpp17
-rw-r--r--tests/test_physics_2d.cpp2
-rw-r--r--tests/test_physics_3d.cpp2
-rw-r--r--tests/test_translation.h31
-rw-r--r--thirdparty/README.md16
-rw-r--r--thirdparty/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp1
-rw-r--r--thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h3
-rw-r--r--thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp6
-rw-r--r--thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp135
-rw-r--r--thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h47
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp13
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h20
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp5
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h2
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp9
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp1
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp21
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h49
-rw-r--r--thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp4
-rw-r--r--thirdparty/bullet/BulletSoftBody/btDeformableBodySolver.cpp8
-rw-r--r--thirdparty/bullet/BulletSoftBody/btDeformableMousePickingForce.h2
-rw-r--r--thirdparty/bullet/BulletSoftBody/btSoftBody.h4
-rw-r--r--thirdparty/bullet/LinearMath/btIDebugDraw.h6
-rw-r--r--thirdparty/bullet/LinearMath/btScalar.h2
-rw-r--r--thirdparty/bullet/LinearMath/btSerializer.h7
-rw-r--r--thirdparty/bullet/VERSION.txt1
-rw-r--r--thirdparty/bullet/patches/bullet-fix-warnings.patch42
-rw-r--r--thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch176
-rw-r--r--thirdparty/meshoptimizer/simplifier.cpp62
-rw-r--r--thirdparty/misc/easing_equations.cpp319
344 files changed, 7744 insertions, 5426 deletions
diff --git a/.gitignore b/.gitignore
index 00d87b6bf6..5b3414fe7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -390,3 +390,6 @@ gcov.css
# https://clangd.llvm.org/ cache folder
.clangd/
.cache/
+
+# Generated by unit tests files
+tests/data/*.translation
diff --git a/.mailmap b/.mailmap
index 28bd3c8e56..d303b81396 100644
--- a/.mailmap
+++ b/.mailmap
@@ -29,6 +29,8 @@ Eric M <itsjusteza@gmail.com>
Eric Rybicki <info@ericrybicki.com> <stratos695@googlemail.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com> <35656626+SeleckyErik@users.noreply.github.com>
+Eveline Jarosz <marqin.pl@gmail.com>
+Eveline Jarosz <marqin.pl@gmail.com> <marqin.pl+git@gmail.com>
Fabian <supagu@gmail.com>
Ferenc Arn <tagcup@yahoo.com>
Ferenc Arn <tagcup@yahoo.com> <tagcup@users.noreply.github.com>
@@ -43,8 +45,6 @@ Guilherme Felipe <guilhermefelipecgs@gmail.com>
Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
HaSa1002 <johawitt@outlook.de>
Hein-Pieter van Braam-Stewart <hp@tmm.cx>
-Hubert Jarosz <marqin.pl@gmail.com>
-Hubert Jarosz <marqin.pl@gmail.com> <marqin.pl+git@gmail.com>
Hugo Locurcio <hugo.locurcio@hugo.pro> <hugo.l@openmailbox.org>
Hugo Locurcio <hugo.locurcio@hugo.pro> <Calinou@users.noreply.github.com>
Hugo Locurcio <hugo.locurcio@hugo.pro> Calinou <calinou@opmbx.org>
@@ -107,6 +107,7 @@ Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Pieter-Jan Briers <pieterjan.briers+git@gmail.com> <pieterjan.briers@gmail.com>
Poommetee Ketson <poommetee@protonmail.com>
Przemysław Gołąb (n-pigeon) <golab.przemyslaw@gmail.com>
+Rafał Mikrut <mikrutrafal@protonmail.com>
Rafał Mikrut <mikrutrafal@protonmail.com> <mikrutrafal54@gmail.com>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@posteo.de>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@users.noreply.github.com>
@@ -116,6 +117,7 @@ RaphaelHunter <raphael10241024@gmail.com> <Raphael10241024@gmail.com>
RaphaelHunter <raphael10241024@gmail.com> <raphael20141024@gmail.com>
Rémi Verschelde <rverschelde@gmail.com> <remi@verschelde.fr>
Rhody Lugo <rhodylugo@gmail.com> <rhodylugo@me.com>
+Ricardo Subtil <ricasubtil@gmail.com>
Robin Hübner <profan@prfn.se> <robinhubner@gmail.com>
romulox_x <romulox_x@yahoo.com>
Ruslan Mustakov <r.mustakov@gmail.com> <ruslan.mustakov@xored.com>
diff --git a/AUTHORS.md b/AUTHORS.md
index 5147da3700..0a0e3a9c21 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -36,6 +36,7 @@ name is available.
Andrii Doroshenko (Xrayez)
Andy Moss (MillionOstrich)
Angad Kambli (angad-k)
+ Anilforextra (AnilBK)
Anish Bhobe (KidRigger)
Anton Yabchinskiy (a12n)
Anutrix
@@ -76,6 +77,7 @@ name is available.
Eric Rybicki (ericrybick)
Erik Selecký (rxlecky)
est31
+ Eveline Jarosz (Marqin)
Fabian Mathews (supagu)
Fabio Alessandrelli (Faless)
fabriceci
@@ -99,7 +101,6 @@ name is available.
Hiroshi Ogawa (hi-ogawa)
homer666
hoontee
- Hubert Jarosz (Marqin)
Hugo Locurcio (Calinou)
Ian Bishop (ianb96)
Ibrahn Sahir (ibrahn)
@@ -109,9 +110,9 @@ name is available.
J08nY
Jakub Grzesik (kubecz3k)
James Buck (jbuck3)
+ Jean-Michel Bernard (jmb462)
Jérôme Gully (Nutriz)
Jia Jun Chai (SkyLucilfer)
- jmb462
Joan Fons Sanchez (JFonS)
Johannes Witt (HaSa1002)
Johan Manuel (29jm)
@@ -119,6 +120,7 @@ name is available.
Juan Linietsky (reduz)
Julian Murgia (StraToN)
Julien Nguyen (Blackiris)
+ Jummit
Justo Delgado (mrcdk)
Kelly Thomas (KellyThomas)
kleonc
@@ -137,7 +139,7 @@ name is available.
Marc Gilleron (Zylann)
Marcin Zawiejski (dragmz)
Marcus Brummer (mbrlabs)
- Marcus (MCrafterzz)
+ Marcus Elg (MCrafterzz)
Mariano Javier Suligoy (MarianoGnu)
Mario Schlack (hurikhan)
Martin Capitanio (capnm)
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt
index da60213038..e84302620e 100644
--- a/COPYRIGHT.txt
+++ b/COPYRIGHT.txt
@@ -80,6 +80,13 @@ Copyright: 2008-2016, The Android Open Source Project
2002, Google, Inc.
License: Apache-2.0
+Files: ./scene/animation/easing_equations.h
+Comment: Robert Penner's Easing Functions
+Copyright: 2001, Robert Penner
+ 2007-2021 Juan Linietsky, Ariel Manzur.
+ 2014-2021 Godot Engine contributors.
+License: Expat
+
Files: ./servers/physics_3d/collision_solver_3d_sat.cpp
Comment: Open Dynamics Engine
Copyright: 2001-2003, Russell L. Smith, Alen Ladavac, Nguyen Binh
@@ -307,11 +314,6 @@ Comment: Fast Filtering of Reflection Probes
Copyright: 2016, Activision Publishing, Inc.
License: Expat
-Files: ./thirdparty/misc/easing_equations.cpp
-Comment: Robert Penner's Easing Functions
-Copyright: 2001, Robert Penner
-License: BSD-3-clause
-
Files: ./thirdparty/misc/fastlz.c
./thirdparty/misc/fastlz.h
Comment: FastLZ
diff --git a/DONORS.md b/DONORS.md
index 1a49465e83..c1e034f67e 100644
--- a/DONORS.md
+++ b/DONORS.md
@@ -23,7 +23,6 @@ generous deed immortalized in the next stable release of Godot Engine.
## Silver sponsors
ASIFA-Hollywood <https://www.asifa-hollywood.org>
- LITSLINK <https://litslink.com>
## Bronze sponsors
@@ -41,6 +40,7 @@ generous deed immortalized in the next stable release of Godot Engine.
AD Ford
alex brown
+ Andrew Bowen
Andrew Dunai
Angry Skull
anti666
@@ -65,7 +65,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Jonah Stich
Justin Arnold
Justo Delgado Baudí
- Kamil Brzezinskip
Marcel Kräml
Marek Belski
Matthieu Huvé
@@ -93,24 +92,26 @@ generous deed immortalized in the next stable release of Godot Engine.
Acheron
Adam Brown
albinaask
- Alvaro A Baena R
Andres Hernandez
+ Arisaka Mayuki
Asher Glick
Barugon
+ Benito
Carlo Cabanilla
Daniel James
David Gehrig
David Graham
David Snopek
- Don B
Ed Morley
Ellen Poe
Florian Rämisch
Gamejunkey
+ Jacobus Dens
Jakub Grzesik
Javier Roman
Joan Fons
Johnny IV Young
+ Jonathan Wright
Jon Woodward
Karl Werf
Klavdij Voncina
@@ -119,13 +120,14 @@ generous deed immortalized in the next stable release of Godot Engine.
Maciej Pendolski
Manuele Finocchiaro
Markus Wiesner
- Mason Bially
Matthew Hillier
Michael
+ Mick
Monster Vial
Officine Pixel S.n.c.
+ Patrick Brock
+ Pedro Silva
Petrus Prinsloo
- Rene
Retro Village
Rob Messick
Roland Fredenhagen
@@ -133,8 +135,10 @@ generous deed immortalized in the next stable release of Godot Engine.
Sarksus
Scott B
Sean
+ segfault-god
Sergey
Sofox
+ Stephan Kessler
Stephen Molyneaux
Taylor Ritenour
Tom Langwaldt
@@ -142,22 +146,21 @@ generous deed immortalized in the next stable release of Godot Engine.
tukon
Vagabond Arcade
Vitaliy Sapronenko
- William Wold
Xeno Coliseum
Zaven Muradyan
Adam Nakonieczny
+ Adam Nelson
+ Alexander Erlemann
Alexander J Maynard
- Alex de la Mare
- Alexey Dyadchenko
Alex Khayrullin
alice gambrell
Andrew Cunningham
Andrew Farr
+ Andriy
Antanas Paskauskas
Antoni Batchelli
Arch Henderson III
- Arisaka Mayuki
Arthur S. Muszynski
Ben Botwin
Brandon Hawkinson
@@ -181,11 +184,8 @@ generous deed immortalized in the next stable release of Godot Engine.
Daniel Tebbutt
Darrian Little
Dennis Belfrage
- Dev To be curious
- Digital Denizen
Dimitri Nüscheler
Donn Eddy
- Easypete
Edgar Sun
Eric
Eric Brand
@@ -200,6 +200,7 @@ generous deed immortalized in the next stable release of Godot Engine.
General Chicken
Geoffroy Warin
GGGames.org
+ gisora
GrayDwarf
Guilherme Felipe de C. G. da Silva
Harvey Fong
@@ -210,22 +211,22 @@ generous deed immortalized in the next stable release of Godot Engine.
Hunter Barabas
Jake Burga
James Couzens
+ James Zahn
Jan Sælid
Jared
Jared White
- Jeppe Zapp
+ Jennifer Wilcox
Jesús Chicharro
Joel Fivat
Johnathan Kupferer
- John Knight
Jonathan Turner
+ Josef Stumpfegger
Jose Malheiro
Jose Manuel Muñoz Perez
Joseph Crane
Joshie Sparks
Joshua Flores
Joshua Lesperance
- Juan T Chen
Juan Velandia
Judd
Julián Absatz
@@ -237,13 +238,13 @@ generous deed immortalized in the next stable release of Godot Engine.
kinfox
Kis Levente Lorand
Kos
- Lain Ballard
Laszlo Kiss
leetNightshade
Leo Fidel R Liban
Liam Smyth
LoparPanda
Luca Vazzano
+ Luke
MadScientistCarl
Marcus Dobler
Marcus Richter
@@ -253,6 +254,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Martin Soucek
matt
Matt Greene
+ Matthew Hall
Matthias Toepp
Mecha Kaiju X
medecau
@@ -264,27 +266,24 @@ generous deed immortalized in the next stable release of Godot Engine.
MikadoSC
Mike Barbee
minz1
- MuffinManKen
nate etan
Nick Abousselam
+ Nicola Cocchiaro
Nicole Barovic
+ Nikita Bliznyuk
Oliver Dick
Oscar Campos
- Patrick Ting
Paul Hocker
Paul Von Zimmerman
Pavel Kotlyar
- Pedro Silva
Pete Goodwin
- Peter Richmond
Petr Malac
PhaineOfCatz
- pl
+ Piotr Wyszyński
+ Pyxl
Raymond Harris
- Renato Fontes
Rene Tailleur
Rhodochrone
- Ricardo Alcantara
Rob
Robert McDermott
Robert Willes
@@ -295,6 +294,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Ronnie Ashlock
Ronny Mühle
Ryan Scott
+ Samuel Hummerstone
Samuel Judd
Samuel Smart
Sean Morgan
@@ -304,6 +304,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Sergey Fonaryov
Sergey Minakov
Shishir Tandale
+ Sing Chun Lee
SKison
Song Junwoo
spacechase0
@@ -316,6 +317,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Thomas Kurz
Tim Howard
Tobias Bocanegra
+ Tobias Raggl
Todd Smith
Torbulous
toto bibi
@@ -333,37 +335,36 @@ generous deed immortalized in the next stable release of Godot Engine.
Yifan Lai
Yuancheng Zhang
Zie Weaver
- Zoran Kukulj
## Silver donors
1D_Inc
Aaron Oldenburg
+ A. B.
Actual_Dio
Adam Brunnmeier
Adam Carr
Adam Long
Adam McCurdy
Adam N Webber
+ Adam R Pope
Adam Smeltzer
Adam Szymański
Adisibio
Adrien de Pierres
- Agar3s - Giovanny Beltrán
Ahmet Kalyoncu
Aidan O'Flannagain
Aki Mimoto
Alan Beauchamp
+ Alberto Salazar Muñoz
Alberto Vilches
Albin Jonasson Svärdsby
Alder Stefano
AleMax
+ Ales Jelovcan
Alessandro Senese
- Alexander Erlemann
Alexander Ravenheart
- Alexander Ryndin
Alexander Walter (SilvanuZ)
- Alexandre Beaudoin
Alex Chan
Alex Clavelle
alex raeside
@@ -379,6 +380,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Ano Nim
Anthony Avina
Anton Bouwer
+ Antti Vesanen
Arch Toasty
Arda Erol
Armin Preiml
@@ -394,14 +396,17 @@ generous deed immortalized in the next stable release of Godot Engine.
Bartosz Bielecki
Benedikt
Benoit Jauvin-Girard
+ Ben Ridley
Ben Vercammen
Bernd Jänichen
Bernhard Werner
Bill Thibault
+ bitbrain
Bjarne Voigtländer
Black Block
blackjacksike
Blair Allen
+ Blunderjack
Bobby CC Wong
Borkzilla
Bram
@@ -409,19 +414,19 @@ generous deed immortalized in the next stable release of Godot Engine.
Brian Klein
Brodie Fairhall
Bronson Zgeb
- Bùi Việt Thành
+ Bruno Hurth
Burney Waring
bwhirt
Caleb Gartner
Caleb Makela
Cameron Meyer
Carlos Cejudo
+ Carlos Rios
Carl van der Geest
Casey
Cassidy James
Cédric Givord
Chad Steadman
- Charles Alston
Chris Chapin
Chris Langford
Christian Clavet
@@ -447,13 +452,16 @@ generous deed immortalized in the next stable release of Godot Engine.
David Bôle
David May
David Maziarka
+ David Rapisarda
deadwithbread
Devin Carraway
Diego Pereira
Dima Fedotov
+ Dimitri Roche
Dmitry Fisher
Dmytro Korchynskyi
Dominik Wetzel
+ Don B
Douglas Plumley
Dragontrapper
Dr Ewan Murray
@@ -473,12 +481,12 @@ generous deed immortalized in the next stable release of Godot Engine.
Eric Walkingshaw
Eric Williams
Erkki Seppälä
- Evan Rose
Faisal Alkubaisi
Fancy Ants Studios
fby
Fekinox
Felix Bohmann
+ Filip Lundby
Forty Doubleu
Francisco Garcia Florez
Francois Holland
@@ -489,6 +497,7 @@ generous deed immortalized in the next stable release of Godot Engine.
George Marques
Georgi Petkov
Graham Overby
+ Green Fox
Greg Lincoln
Greg Olson
Greyson Richey
@@ -503,7 +512,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Hunter Jones
Ian ORourke
Ian Williams
- Iiari
IndustrialRobot
Ivan Nikolaev
iveks
@@ -515,6 +523,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Jako Danar
James
James A F Manley
+ James Gary
James Guardino
James Quincy
James Thomas
@@ -546,7 +555,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Jonatan R
Jonathan Bieber
Jonathan G
- Jonathan Wright
Jon Bonazza
Jon Sully
Jordan West
@@ -565,9 +573,9 @@ generous deed immortalized in the next stable release of Godot Engine.
Julian Murgia
June Little
Justin Hamilton
+ Justin Hurst
Justin Oaksford
Justin Spedding
- Justin W. Flory
KaDokta
Karol Porzycki
Keedong Park
@@ -575,7 +583,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Keith Bradner
Kenji Kawabata
Ken Minardo
- Kenneth Lee
Kent Jofur
Ketafuki
Kevin van Rooijen
@@ -585,6 +592,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Kolandrious
Konstantin Goncharov
kormai
+ Kquona
Krishna Nadoor
Kristian Nygaard Jensen
KR McGinley
@@ -596,7 +604,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Kyuppin
Lasse le Dous
Laurent CHEA
- Laurent Tréguier
Laxman Pradhan
LEMMiNO
Leonardo Dimano
@@ -614,11 +621,12 @@ generous deed immortalized in the next stable release of Godot Engine.
Mark Malone
Markus Martin
Markus Michael Egger
+ Markus Ort
Martin FIbik
Martin Holas
Martin Liška
Martin Trbola
- Marvin
+ Martin Zabinski
Mathieu
Matt Edwards
Matthew Booe
@@ -642,6 +650,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Mike
Mike Birkhead
Mike Copley
+ Mitchell
Mitchell J. Wagner
MJacred
ModularMind
@@ -666,25 +675,21 @@ generous deed immortalized in the next stable release of Godot Engine.
Nicolas Goll-Perrier
Nicolas Rosset
Nicolas SAN AGUSTIN
+ Nils Nordmark
Nima Farid
Noel Billig
- Nuno Dionísio
NZ
oceoh
Okatima
Oleg Reva
- Omar Delarosa
- Orfist
Oriol Muñoz Princep
oscar1000108
Oscar Domingo
Pascal
- Patrick Brock
Patrick Nafarrete
Paul Gieske
Paweł Kowal
Paweł Łyczkowski
- p_brighenti
Peter Höglund
Philip Cohoe
Philip Ludington (MrPhil)
@@ -695,43 +700,44 @@ generous deed immortalized in the next stable release of Godot Engine.
pwab
RabidTunes
Rackat
+ RackBar Dingum
Rad Cat
Rafa Laguna
Raffaele Aramo
Rainer Amler
Rami Hanano
Rammeow
- RAMupgrade
Remi Rampin
Reneator
+ René Habermann
Riccardo Marini
Richard Hayes
Richard Ivánek
Richard Néveri
Riley
- Robert Farr (Larington)
Rob Ruana
Rodrigo Loli
Roger Smith
+ Roglozor
Roland Rząsa
Roman Tinkov
Ronald Ho Hip (CrimsonZA)
Ronan
- Ross Squires
Roy Scayged
+ Ryan
Ryan Groom
Sam Caulfield
Sam Edson
Scott Longley
Sean Lynch
Sebastian Michailidis
- segfault-god
SeongWan Kim
SeungJong k
Shaidak
Shane
Shane Sicienski
Shane Spoor
+ Silver1063
simdee
Simon Jonas Larsen
Simon Schoenenberger
@@ -741,10 +747,12 @@ generous deed immortalized in the next stable release of Godot Engine.
smbe19
smo1704
Solene Waked
+ Sophie Winter
Spencer Everhart
Squirrel
Stéphane Roussel
Steve Cloete
+ Steven Drovie
summerblind
Sung soo Choi
Svenne Krap
@@ -753,6 +761,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Tarch
Terry
the9thdude
+ The Domis4
Theodore Lindsey
TheVoiceInMyHead
thomas
@@ -790,6 +799,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Vi Watch
Vladimir Savin
Vladislav Smirnov
+ VoxelVisions.com
Vytenis Narušis
werner mendizabal
Wiley Thompson
diff --git a/SConstruct b/SConstruct
index b6c98eea77..b539dc59b7 100644
--- a/SConstruct
+++ b/SConstruct
@@ -91,6 +91,7 @@ env_base.__class__.add_program = methods.add_program
env_base.__class__.CommandNoCache = methods.CommandNoCache
env_base.__class__.Run = methods.Run
env_base.__class__.disable_warnings = methods.disable_warnings
+env_base.__class__.force_optimization_on_debug = methods.force_optimization_on_debug
env_base.__class__.module_check_dependencies = methods.module_check_dependencies
env_base["x86_libtheora_opt_gcc"] = False
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index e029b85450..1f028702f6 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -1786,13 +1786,13 @@ void Thread::_start_func(void *ud) {
// We must check if we are in case b).
int target_param_count = 0;
int target_default_arg_count = 0;
- Ref<Script> script = t->target_instance->get_script();
+ Ref<Script> script = t->target_callable.get_object()->get_script();
if (script.is_valid()) {
- MethodInfo mi = script->get_method_info(t->target_method);
+ MethodInfo mi = script->get_method_info(t->target_callable.get_method());
target_param_count = mi.arguments.size();
target_default_arg_count = mi.default_arguments.size();
} else {
- MethodBind *method = ClassDB::get_method(t->target_instance->get_class_name(), t->target_method);
+ MethodBind *method = ClassDB::get_method(t->target_callable.get_object()->get_class_name(), t->target_callable.get_method());
target_param_count = method->get_argument_count();
target_default_arg_count = method->get_default_argument_count();
}
@@ -1801,41 +1801,21 @@ void Thread::_start_func(void *ud) {
}
}
- ::Thread::set_name(t->target_method);
+ ::Thread::set_name(t->target_callable.get_method());
- t->ret = t->target_instance->call(t->target_method, arg, argc, ce);
+ t->target_callable.call(arg, argc, t->ret, ce);
if (ce.error != Callable::CallError::CALL_OK) {
- String reason;
- switch (ce.error) {
- case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
- reason = "Invalid Argument #" + itos(ce.argument);
- } break;
- case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
- reason = "Too Many Arguments";
- } break;
- case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
- reason = "Too Few Arguments";
- } break;
- case Callable::CallError::CALL_ERROR_INVALID_METHOD: {
- reason = "Method Not Found";
- } break;
- default: {
- }
- }
-
- ERR_FAIL_MSG("Could not call function '" + t->target_method.operator String() + "' to start thread " + t->get_id() + ": " + reason + ".");
+ ERR_FAIL_MSG("Could not call function '" + t->target_callable.get_method().operator String() + "' to start thread " + t->get_id() + ": " + Variant::get_callable_error_text(t->target_callable, arg, argc, ce) + ".");
}
}
-Error Thread::start(Object *p_instance, const StringName &p_method, const Variant &p_userdata, Priority p_priority) {
+Error Thread::start(const Callable &p_callable, const Variant &p_userdata, Priority p_priority) {
ERR_FAIL_COND_V_MSG(active.is_set(), ERR_ALREADY_IN_USE, "Thread already started.");
- ERR_FAIL_COND_V(!p_instance, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_method == StringName(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_callable.is_null(), ERR_INVALID_PARAMETER);
ERR_FAIL_INDEX_V(p_priority, PRIORITY_MAX, ERR_INVALID_PARAMETER);
ret = Variant();
- target_method = p_method;
- target_instance = p_instance;
+ target_callable = p_callable;
userdata = p_userdata;
active.set();
@@ -1861,15 +1841,14 @@ Variant Thread::wait_to_finish() {
thread.wait_to_finish();
Variant r = ret;
active.clear();
- target_method = StringName();
- target_instance = nullptr;
+ target_callable = Callable();
userdata = Variant();
return r;
}
void Thread::_bind_methods() {
- ClassDB::bind_method(D_METHOD("start", "instance", "method", "userdata", "priority"), &Thread::start, DEFVAL(Variant()), DEFVAL(PRIORITY_NORMAL));
+ ClassDB::bind_method(D_METHOD("start", "callable", "userdata", "priority"), &Thread::start, DEFVAL(Variant()), DEFVAL(PRIORITY_NORMAL));
ClassDB::bind_method(D_METHOD("get_id"), &Thread::get_id);
ClassDB::bind_method(D_METHOD("is_active"), &Thread::is_active);
ClassDB::bind_method(D_METHOD("wait_to_finish"), &Thread::wait_to_finish);
@@ -2221,7 +2200,7 @@ Object *Engine::get_singleton_object(const StringName &p_name) const {
void Engine::register_singleton(const StringName &p_name, Object *p_object) {
ERR_FAIL_COND_MSG(has_singleton(p_name), "Singleton already registered: " + String(p_name));
- ERR_FAIL_COND_MSG(p_name.operator String().is_valid_identifier(), "Singleton name is not a valid identifier: " + String(p_name));
+ ERR_FAIL_COND_MSG(!String(p_name).is_valid_identifier(), "Singleton name is not a valid identifier: " + p_name);
::Engine::Singleton s;
s.class_name = p_name;
s.name = p_name;
@@ -2297,13 +2276,11 @@ void Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("unregister_singleton", "name"), &Engine::unregister_singleton);
ClassDB::bind_method(D_METHOD("get_singleton_list"), &Engine::get_singleton_list);
- ClassDB::bind_method(D_METHOD("set_editor_hint", "enabled"), &Engine::set_editor_hint);
ClassDB::bind_method(D_METHOD("is_editor_hint"), &Engine::is_editor_hint);
ClassDB::bind_method(D_METHOD("set_print_error_messages", "enabled"), &Engine::set_print_error_messages);
ClassDB::bind_method(D_METHOD("is_printing_error_messages"), &Engine::is_printing_error_messages);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_hint"), "set_editor_hint", "is_editor_hint");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "print_error_messages"), "set_print_error_messages", "is_printing_error_messages");
ADD_PROPERTY(PropertyInfo(Variant::INT, "physics_ticks_per_second"), "set_physics_ticks_per_second", "get_physics_ticks_per_second");
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps");
diff --git a/core/core_bind.h b/core/core_bind.h
index a5d5a7c8ce..84a284f948 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -539,8 +539,7 @@ protected:
Variant ret;
Variant userdata;
SafeFlag active;
- Object *target_instance = nullptr;
- StringName target_method;
+ Callable target_callable;
::Thread thread;
static void _bind_methods();
static void _start_func(void *ud);
@@ -553,7 +552,7 @@ public:
PRIORITY_MAX
};
- Error start(Object *p_instance, const StringName &p_method, const Variant &p_userdata = Variant(), Priority p_priority = PRIORITY_NORMAL);
+ Error start(const Callable &p_callable, const Variant &p_userdata = Variant(), Priority p_priority = PRIORITY_NORMAL);
String get_id() const;
bool is_active() const;
Variant wait_to_finish();
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 50b2099236..1d2b5f19ee 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -864,6 +864,8 @@ void InputEventMouseMotion::_bind_methods() {
///////////////////////////////////
void InputEventJoypadMotion::set_axis(JoyAxis p_axis) {
+ ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
+
axis = p_axis;
emit_changed();
}
@@ -1557,9 +1559,13 @@ bool InputEventShortcut::is_pressed() const {
}
String InputEventShortcut::as_text() const {
+ ERR_FAIL_COND_V(shortcut.is_null(), "None");
+
return vformat(RTR("Input Event with Shortcut=%s"), shortcut->get_as_text());
}
String InputEventShortcut::to_string() {
+ ERR_FAIL_COND_V(shortcut.is_null(), "None");
+
return vformat("InputEventShortcut: shortcut=%s", shortcut->get_as_text());
}
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 8bec80a99e..1ec4299093 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -467,7 +467,7 @@ const OrderedHashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
// ///// UI Text Input Shortcuts /////
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(KEY_SPACE | KEY_MASK_CMD));
+ inputs.push_back(InputEventKey::create_reference(KEY_SPACE | KEY_MASK_CTRL));
default_builtin_cache.insert("ui_text_completion_query", inputs);
inputs = List<Ref<InputEvent>>();
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 3112dd217f..c70f4b86bd 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -2506,7 +2506,7 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po
clipped_src_rect.position.y = ABS(p_dest.y);
}
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
+ if (clipped_src_rect.has_no_area()) {
return;
}
@@ -2561,7 +2561,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
clipped_src_rect.position.y = ABS(p_dest.y);
}
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
+ if (clipped_src_rect.has_no_area()) {
return;
}
@@ -2615,7 +2615,7 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
clipped_src_rect.position.y = ABS(p_dest.y);
}
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
+ if (clipped_src_rect.has_no_area()) {
return;
}
@@ -2664,7 +2664,7 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
clipped_src_rect.position.y = ABS(p_dest.y);
}
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
+ if (clipped_src_rect.has_no_area()) {
return;
}
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 8da44fd290..87d2b66e5b 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -138,6 +138,7 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_var", "allow_objects"), &PacketPeer::_bnd_get_var, DEFVAL(false));
ClassDB::bind_method(D_METHOD("put_var", "var", "full_objects"), &PacketPeer::put_var, DEFVAL(false));
+
ClassDB::bind_method(D_METHOD("get_packet"), &PacketPeer::_get_packet);
ClassDB::bind_method(D_METHOD("put_packet", "buffer"), &PacketPeer::_put_packet);
ClassDB::bind_method(D_METHOD("get_packet_error"), &PacketPeer::_get_packet_error);
@@ -151,6 +152,51 @@ void PacketPeer::_bind_methods() {
/***************/
+int PacketPeerExtension::get_available_packet_count() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_packet_count, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_get_available_packet_count is unimplemented!");
+ return -1;
+}
+
+Error PacketPeerExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_get_packet_native is unimplemented!");
+ return FAILED;
+}
+
+Error PacketPeerExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_put_packet_native is unimplemented!");
+ return FAILED;
+}
+
+int PacketPeerExtension::get_max_packet_size() const {
+ int size;
+ if (GDVIRTUAL_CALL(_get_max_packet_size, size)) {
+ return size;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_get_max_packet_size is unimplemented!");
+ return 0;
+}
+
+void PacketPeerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
+ GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
+ GDVIRTUAL_BIND(_get_available_packet_count);
+ GDVIRTUAL_BIND(_get_max_packet_size);
+}
+
+/***************/
+
void PacketPeerStream::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::set_stream_peer);
ClassDB::bind_method(D_METHOD("get_stream_peer"), &PacketPeerStream::get_stream_peer);
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 9a345af3d0..bc1f4aaabf 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -35,6 +35,10 @@
#include "core/object/class_db.h"
#include "core/templates/ring_buffer.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
class PacketPeer : public RefCounted {
GDCLASS(PacketPeer, RefCounted);
@@ -73,6 +77,25 @@ public:
~PacketPeer() {}
};
+class PacketPeerExtension : public PacketPeer {
+ GDCLASS(PacketPeerExtension, PacketPeer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual int get_available_packet_count() const override;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
+ virtual int get_max_packet_size() const override;
+
+ /* GDExtension */
+ GDVIRTUAL0RC(int, _get_available_packet_count);
+ GDVIRTUAL2R(int, _get_packet, GDNativeConstPtr<const uint8_t *>, GDNativePtr<int>);
+ GDVIRTUAL2R(int, _put_packet, GDNativeConstPtr<const uint8_t>, int);
+ GDVIRTUAL0RC(int, _get_max_packet_size);
+};
+
class PacketPeerStream : public PacketPeer {
GDCLASS(PacketPeerStream, PacketPeer);
diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp
index 97d683f415..290a71043c 100644
--- a/core/io/resource_uid.cpp
+++ b/core/io/resource_uid.cpp
@@ -126,8 +126,7 @@ String ResourceUID::get_id_path(ID p_id) const {
MutexLock l(mutex);
ERR_FAIL_COND_V(!unique_ids.has(p_id), String());
const CharString &cs = unique_ids[p_id].cs;
- String s(cs.ptr());
- return s;
+ return String::utf8(cs.ptr());
}
void ResourceUID::remove_id(ID p_id) {
MutexLock l(mutex);
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 27f8d4e88f..8ab025dda1 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -410,6 +410,63 @@ void StreamPeer::_bind_methods() {
////////////////////////////////
+int StreamPeerExtension::get_available_bytes() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_bytes, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_get_available_bytes is unimplemented!");
+ return -1;
+}
+
+Error StreamPeerExtension::get_data(uint8_t *r_buffer, int p_bytes) {
+ int err;
+ int received = 0;
+ if (GDVIRTUAL_CALL(_get_data, r_buffer, p_bytes, &received, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_get_data is unimplemented!");
+ return FAILED;
+}
+
+Error StreamPeerExtension::get_partial_data(uint8_t *r_buffer, int p_bytes, int &r_received) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_partial_data, r_buffer, p_bytes, &r_received, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_get_partial_data is unimplemented!");
+ return FAILED;
+}
+
+Error StreamPeerExtension::put_data(const uint8_t *p_data, int p_bytes) {
+ int err;
+ int sent = 0;
+ if (GDVIRTUAL_CALL(_put_data, p_data, p_bytes, &sent, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_put_data is unimplemented!");
+ return FAILED;
+}
+
+Error StreamPeerExtension::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_data, p_data, p_bytes, &r_sent, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_put_partial_data is unimplemented!");
+ return FAILED;
+}
+
+void StreamPeerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_get_data, "r_buffer", "r_bytes", "r_received");
+ GDVIRTUAL_BIND(_get_partial_data, "r_buffer", "r_bytes", "r_received");
+ GDVIRTUAL_BIND(_put_data, "p_data", "p_bytes", "r_sent");
+ GDVIRTUAL_BIND(_put_partial_data, "p_data", "p_bytes", "r_sent");
+ GDVIRTUAL_BIND(_get_available_bytes);
+}
+
+////////////////////////////////
+
void StreamPeerBuffer::_bind_methods() {
ClassDB::bind_method(D_METHOD("seek", "position"), &StreamPeerBuffer::seek);
ClassDB::bind_method(D_METHOD("get_size"), &StreamPeerBuffer::get_size);
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index effc3850af..89432951c5 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -33,6 +33,10 @@
#include "core/object/ref_counted.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
class StreamPeer : public RefCounted {
GDCLASS(StreamPeer, RefCounted);
OBJ_CATEGORY("Networking");
@@ -58,6 +62,7 @@ public:
virtual int get_available_bytes() const = 0;
+ /* helpers */
void set_big_endian(bool p_big_endian);
bool is_big_endian_enabled() const;
@@ -92,6 +97,26 @@ public:
StreamPeer() {}
};
+class StreamPeerExtension : public StreamPeer {
+ GDCLASS(StreamPeerExtension, StreamPeer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual Error put_data(const uint8_t *p_data, int p_bytes) override;
+ virtual Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) override;
+ virtual Error get_data(uint8_t *p_buffer, int p_bytes) override;
+ virtual Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) override;
+ virtual int get_available_bytes() const override;
+
+ GDVIRTUAL3R(int, _put_data, GDNativeConstPtr<const uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL3R(int, _put_partial_data, GDNativeConstPtr<const uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL3R(int, _get_data, GDNativePtr<uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL3R(int, _get_partial_data, GDNativePtr<uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL0RC(int, _get_available_bytes);
+};
+
class StreamPeerBuffer : public StreamPeer {
GDCLASS(StreamPeerBuffer, StreamPeer);
diff --git a/core/math/bvh_cull.inc b/core/math/bvh_cull.inc
index cba8ea6cb3..d7edc8a884 100644
--- a/core/math/bvh_cull.inc
+++ b/core/math/bvh_cull.inc
@@ -14,7 +14,7 @@ struct CullParams {
uint32_t pairable_type;
// optional components for different tests
- Vector3 point;
+ Point point;
BVHABB_CLASS abb;
typename BVHABB_CLASS::ConvexHull hull;
typename BVHABB_CLASS::Segment segment;
diff --git a/core/math/bvh_debug.inc b/core/math/bvh_debug.inc
index a97304334c..55db794ee3 100644
--- a/core/math/bvh_debug.inc
+++ b/core/math/bvh_debug.inc
@@ -6,24 +6,21 @@ void _debug_recursive_print_tree(int p_tree_id) const {
}
String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const {
- String sz = "(";
- sz += itos(aabb.min.x);
- sz += " ~ ";
- sz += itos(-aabb.neg_max.x);
- sz += ") (";
+ Point size = aabb.calculate_size();
- sz += itos(aabb.min.y);
- sz += " ~ ";
- sz += itos(-aabb.neg_max.y);
- sz += ") (";
+ String sz;
+ float vol = 0.0;
- sz += itos(aabb.min.z);
- sz += " ~ ";
- sz += itos(-aabb.neg_max.z);
- sz += ") ";
+ for (int i = 0; i < Point::AXES_COUNT; ++i) {
+ sz += "(";
+ sz += itos(aabb.min[i]);
+ sz += " ~ ";
+ sz += itos(-aabb.neg_max[i]);
+ sz += ") ";
+
+ vol += size[i];
+ }
- Vector3 size = aabb.calculate_size();
- float vol = size.x * size.y * size.z;
sz += "vol " + itos(vol);
return sz;
diff --git a/core/math/bvh_split.inc b/core/math/bvh_split.inc
index 3fcc4c7b10..6f54d06ce7 100644
--- a/core/math/bvh_split.inc
+++ b/core/math/bvh_split.inc
@@ -28,11 +28,15 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u
Point centre = full_bound.calculate_centre();
Point size = full_bound.calculate_size();
- int order[3];
+ int order[Point::AXIS_COUNT];
order[0] = size.min_axis();
- order[2] = size.max_axis();
- order[1] = 3 - (order[0] + order[2]);
+ order[Point::AXIS_COUNT - 1] = size.max_axis();
+
+ static_assert(Point::AXIS_COUNT <= 3);
+ if (Point::AXIS_COUNT == 3) {
+ order[1] = 3 - (order[0] + order[2]);
+ }
// simplest case, split on the longest axis
int split_axis = order[0];
@@ -54,7 +58,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u
// detect when split on longest axis failed
int min_threshold = MAX_ITEMS / 4;
- int min_group_size[3];
+ int min_group_size[Point::AXIS_COUNT];
min_group_size[0] = MIN(num_a, num_b);
if (min_group_size[0] < min_threshold) {
// slow but sure .. first move everything back into a
@@ -64,7 +68,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u
num_b = 0;
// now calculate the best split
- for (int axis = 1; axis < 3; axis++) {
+ for (int axis = 1; axis < Point::AXIS_COUNT; axis++) {
split_axis = order[axis];
int count = 0;
@@ -82,7 +86,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u
// best axis
int best_axis = 0;
int best_min = min_group_size[0];
- for (int axis = 1; axis < 3; axis++) {
+ for (int axis = 1; axis < Point::AXIS_COUNT; axis++) {
if (min_group_size[axis] > best_min) {
best_min = min_group_size[axis];
best_axis = axis;
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 9af3f868d2..045ab67ce8 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -151,8 +151,8 @@ Face3::Side Face3::get_side_of(const Face3 &p_face, ClockDirection p_clock_dir)
}
Vector3 Face3::get_random_point_inside() const {
- real_t a = Math::random(0, 1);
- real_t b = Math::random(0, 1);
+ real_t a = Math::random(0.0, 1.0);
+ real_t b = Math::random(0.0, 1.0);
if (a > b) {
SWAP(a, b);
}
diff --git a/modules/gdnative/net/register_types.h b/core/math/static_raycaster.cpp
index c99c6f6fbf..da05d49428 100644
--- a/modules/gdnative/net/register_types.h
+++ b/core/math/static_raycaster.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* register_types.h */
+/* static_raycaster.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,10 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NET_REGISTER_TYPES_H
-#define NET_REGISTER_TYPES_H
+#include "static_raycaster.h"
-void register_net_types();
-void unregister_net_types();
+StaticRaycaster *(*StaticRaycaster::create_function)() = nullptr;
-#endif // NET_REGISTER_TYPES_H
+Ref<StaticRaycaster> StaticRaycaster::create() {
+ if (create_function) {
+ return Ref<StaticRaycaster>(create_function());
+ }
+ return Ref<StaticRaycaster>();
+}
diff --git a/core/math/static_raycaster.h b/core/math/static_raycaster.h
new file mode 100644
index 0000000000..3759c788a7
--- /dev/null
+++ b/core/math/static_raycaster.h
@@ -0,0 +1,111 @@
+/*************************************************************************/
+/* static_raycaster.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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 STATIC_RAYCASTER_H
+#define STATIC_RAYCASTER_H
+
+#include "core/object/ref_counted.h"
+
+#if !defined(__aligned)
+
+#if defined(_WIN32) && defined(_MSC_VER)
+#define __aligned(...) __declspec(align(__VA_ARGS__))
+#else
+#define __aligned(...) __attribute__((aligned(__VA_ARGS__)))
+#endif
+
+#endif
+
+class StaticRaycaster : public RefCounted {
+ GDCLASS(StaticRaycaster, RefCounted)
+protected:
+ static StaticRaycaster *(*create_function)();
+
+public:
+ // compatible with embree3 rays
+ struct __aligned(16) Ray {
+ const static unsigned int INVALID_GEOMETRY_ID = ((unsigned int)-1); // from rtcore_common.h
+
+ /*! Default construction does nothing. */
+ _FORCE_INLINE_ Ray() :
+ geomID(INVALID_GEOMETRY_ID) {}
+
+ /*! Constructs a ray from origin, direction, and ray segment. Near
+ * has to be smaller than far. */
+ _FORCE_INLINE_ Ray(const Vector3 &org,
+ const Vector3 &dir,
+ float tnear = 0.0f,
+ float tfar = INFINITY) :
+ org(org),
+ tnear(tnear),
+ dir(dir),
+ time(0.0f),
+ tfar(tfar),
+ mask(-1),
+ u(0.0),
+ v(0.0),
+ primID(INVALID_GEOMETRY_ID),
+ geomID(INVALID_GEOMETRY_ID),
+ instID(INVALID_GEOMETRY_ID) {}
+
+ /*! Tests if we hit something. */
+ _FORCE_INLINE_ explicit operator bool() const { return geomID != INVALID_GEOMETRY_ID; }
+
+ public:
+ Vector3 org; //!< Ray origin + tnear
+ float tnear; //!< Start of ray segment
+ Vector3 dir; //!< Ray direction + tfar
+ float time; //!< Time of this ray for motion blur.
+ float tfar; //!< End of ray segment
+ unsigned int mask; //!< used to mask out objects during traversal
+ unsigned int id; //!< ray ID
+ unsigned int flags; //!< ray flags
+
+ Vector3 normal; //!< Not normalized geometry normal
+ float u; //!< Barycentric u coordinate of hit
+ float v; //!< Barycentric v coordinate of hit
+ unsigned int primID; //!< primitive ID
+ unsigned int geomID; //!< geometry ID
+ unsigned int instID; //!< instance ID
+ };
+
+ virtual bool intersect(Ray &p_ray) = 0;
+ virtual void intersect(Vector<Ray> &r_rays) = 0;
+
+ virtual void add_mesh(const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices, unsigned int p_id) = 0;
+ virtual void commit() = 0;
+
+ virtual void set_mesh_filter(const Set<int> &p_mesh_ids) = 0;
+ virtual void clear_mesh_filter() = 0;
+
+ static Ref<StaticRaycaster> create();
+};
+
+#endif // STATIC_RAYCASTER_H
diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp
index 060b619892..496a557844 100644
--- a/core/math/transform_2d.cpp
+++ b/core/math/transform_2d.cpp
@@ -279,7 +279,7 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, const
}
//construct matrix
- Transform2D res(Math::atan2(v.y, v.x), p1.lerp(p2, p_c));
+ Transform2D res(v.angle(), p1.lerp(p2, p_c));
res.scale_basis(s1.lerp(s2, p_c));
return res;
}
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index b53dc05a00..16e43d7d06 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -79,7 +79,7 @@ real_t Vector2::angle_to(const Vector2 &p_vector2) const {
}
real_t Vector2::angle_to_point(const Vector2 &p_vector2) const {
- return Math::atan2(y - p_vector2.y, x - p_vector2.x);
+ return (*this - p_vector2).angle();
}
real_t Vector2::dot(const Vector2 &p_other) const {
diff --git a/core/multiplayer/multiplayer_peer.cpp b/core/multiplayer/multiplayer_peer.cpp
index 40847102d8..3c33948e2f 100644
--- a/core/multiplayer/multiplayer_peer.cpp
+++ b/core/multiplayer/multiplayer_peer.cpp
@@ -53,6 +53,30 @@ uint32_t MultiplayerPeer::generate_unique_id() const {
return hash;
}
+void MultiplayerPeer::set_transfer_channel(int p_channel) {
+ transfer_channel = p_channel;
+}
+
+int MultiplayerPeer::get_transfer_channel() const {
+ return transfer_channel;
+}
+
+void MultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
+ transfer_mode = p_mode;
+}
+
+Multiplayer::TransferMode MultiplayerPeer::get_transfer_mode() const {
+ return transfer_mode;
+}
+
+void MultiplayerPeer::set_refuse_new_connections(bool p_enable) {
+ refuse_connections = p_enable;
+}
+
+bool MultiplayerPeer::is_refusing_new_connections() const {
+ return refuse_connections;
+}
+
void MultiplayerPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_transfer_channel", "channel"), &MultiplayerPeer::set_transfer_channel);
ClassDB::bind_method(D_METHOD("get_transfer_channel"), &MultiplayerPeer::get_transfer_channel);
@@ -88,3 +112,160 @@ void MultiplayerPeer::_bind_methods() {
ADD_SIGNAL(MethodInfo("connection_succeeded"));
ADD_SIGNAL(MethodInfo("connection_failed"));
}
+
+/*************/
+
+int MultiplayerPeerExtension::get_available_packet_count() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_packet_count, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_available_packet_count is unimplemented!");
+ return -1;
+}
+
+Error MultiplayerPeerExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_packet_native is unimplemented!");
+ return FAILED;
+}
+
+Error MultiplayerPeerExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_put_packet_native is unimplemented!");
+ return FAILED;
+}
+
+int MultiplayerPeerExtension::get_max_packet_size() const {
+ int size;
+ if (GDVIRTUAL_CALL(_get_max_packet_size, size)) {
+ return size;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_max_packet_size is unimplemented!");
+ return 0;
+}
+
+void MultiplayerPeerExtension::set_transfer_channel(int p_channel) {
+ if (GDVIRTUAL_CALL(_set_transfer_channel, p_channel)) {
+ return;
+ }
+ MultiplayerPeer::set_transfer_channel(p_channel);
+}
+
+int MultiplayerPeerExtension::get_transfer_channel() const {
+ int channel;
+ if (GDVIRTUAL_CALL(_get_transfer_channel, channel)) {
+ return channel;
+ }
+ return MultiplayerPeer::get_transfer_channel();
+}
+
+void MultiplayerPeerExtension::set_transfer_mode(Multiplayer::TransferMode p_mode) {
+ if (GDVIRTUAL_CALL(_set_transfer_mode, p_mode)) {
+ return;
+ }
+ MultiplayerPeer::set_transfer_mode(p_mode);
+}
+
+Multiplayer::TransferMode MultiplayerPeerExtension::get_transfer_mode() const {
+ int mode;
+ if (GDVIRTUAL_CALL(_get_transfer_mode, mode)) {
+ return (Multiplayer::TransferMode)mode;
+ }
+ return MultiplayerPeer::get_transfer_mode();
+}
+
+void MultiplayerPeerExtension::set_target_peer(int p_peer_id) {
+ if (GDVIRTUAL_CALL(_set_target_peer, p_peer_id)) {
+ return;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_set_target_peer is unimplemented!");
+}
+
+int MultiplayerPeerExtension::get_packet_peer() const {
+ int peer;
+ if (GDVIRTUAL_CALL(_get_packet_peer, peer)) {
+ return peer;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_packet_peer is unimplemented!");
+ return 0;
+}
+
+bool MultiplayerPeerExtension::is_server() const {
+ bool server;
+ if (GDVIRTUAL_CALL(_is_server, server)) {
+ return server;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_is_server is unimplemented!");
+ return false;
+}
+
+void MultiplayerPeerExtension::poll() {
+ int err;
+ if (GDVIRTUAL_CALL(_poll, err)) {
+ return;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_poll is unimplemented!");
+}
+
+int MultiplayerPeerExtension::get_unique_id() const {
+ int id;
+ if (GDVIRTUAL_CALL(_get_unique_id, id)) {
+ return id;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_unique_id is unimplemented!");
+ return 0;
+}
+
+void MultiplayerPeerExtension::set_refuse_new_connections(bool p_enable) {
+ if (GDVIRTUAL_CALL(_set_refuse_new_connections, p_enable)) {
+ return;
+ }
+ MultiplayerPeer::set_refuse_new_connections(p_enable);
+}
+
+bool MultiplayerPeerExtension::is_refusing_new_connections() const {
+ bool refusing;
+ if (GDVIRTUAL_CALL(_is_refusing_new_connections, refusing)) {
+ return refusing;
+ }
+ return MultiplayerPeer::is_refusing_new_connections();
+}
+
+MultiplayerPeer::ConnectionStatus MultiplayerPeerExtension::get_connection_status() const {
+ int status;
+ if (GDVIRTUAL_CALL(_get_connection_status, status)) {
+ return (ConnectionStatus)status;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_connection_status is unimplemented!");
+ return CONNECTION_DISCONNECTED;
+}
+
+void MultiplayerPeerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
+ GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
+ GDVIRTUAL_BIND(_get_available_packet_count);
+ GDVIRTUAL_BIND(_get_max_packet_size);
+
+ GDVIRTUAL_BIND(_set_transfer_channel, "p_channel");
+ GDVIRTUAL_BIND(_get_transfer_channel);
+
+ GDVIRTUAL_BIND(_set_transfer_mode, "p_mode");
+ GDVIRTUAL_BIND(_get_transfer_mode);
+
+ GDVIRTUAL_BIND(_set_target_peer, "p_peer");
+
+ GDVIRTUAL_BIND(_get_packet_peer);
+ GDVIRTUAL_BIND(_is_server);
+ GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_get_unique_id);
+ GDVIRTUAL_BIND(_set_refuse_new_connections, "p_enable");
+ GDVIRTUAL_BIND(_is_refusing_new_connections);
+ GDVIRTUAL_BIND(_get_connection_status);
+}
diff --git a/core/multiplayer/multiplayer_peer.h b/core/multiplayer/multiplayer_peer.h
index ba00c3b41b..126ba9e645 100644
--- a/core/multiplayer/multiplayer_peer.h
+++ b/core/multiplayer/multiplayer_peer.h
@@ -34,12 +34,21 @@
#include "core/io/packet_peer.h"
#include "core/multiplayer/multiplayer.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
class MultiplayerPeer : public PacketPeer {
GDCLASS(MultiplayerPeer, PacketPeer);
protected:
static void _bind_methods();
+private:
+ int transfer_channel = 0;
+ Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
+ bool refuse_connections = false;
+
public:
enum {
TARGET_PEER_BROADCAST = 0,
@@ -52,10 +61,13 @@ public:
CONNECTION_CONNECTED,
};
- virtual void set_transfer_channel(int p_channel) = 0;
- virtual int get_transfer_channel() const = 0;
- virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) = 0;
- virtual Multiplayer::TransferMode get_transfer_mode() const = 0;
+ virtual void set_transfer_channel(int p_channel);
+ virtual int get_transfer_channel() const;
+ virtual void set_transfer_mode(Multiplayer::TransferMode p_mode);
+ virtual Multiplayer::TransferMode get_transfer_mode() const;
+ virtual void set_refuse_new_connections(bool p_enable);
+ virtual bool is_refusing_new_connections() const;
+
virtual void set_target_peer(int p_peer_id) = 0;
virtual int get_packet_peer() const = 0;
@@ -66,15 +78,67 @@ public:
virtual int get_unique_id() const = 0;
- virtual void set_refuse_new_connections(bool p_enable) = 0;
- virtual bool is_refusing_new_connections() const = 0;
-
virtual ConnectionStatus get_connection_status() const = 0;
+
uint32_t generate_unique_id() const;
MultiplayerPeer() {}
};
-VARIANT_ENUM_CAST(MultiplayerPeer::ConnectionStatus)
+VARIANT_ENUM_CAST(MultiplayerPeer::ConnectionStatus);
+
+class MultiplayerPeerExtension : public MultiplayerPeer {
+ GDCLASS(MultiplayerPeerExtension, MultiplayerPeer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ /* PacketPeer */
+ virtual int get_available_packet_count() const override;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
+ virtual int get_max_packet_size() const override;
+
+ /* MultiplayerPeer */
+ virtual void set_transfer_channel(int p_channel) override;
+ virtual int get_transfer_channel() const override;
+ virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
+ virtual Multiplayer::TransferMode get_transfer_mode() const override;
+ virtual void set_target_peer(int p_peer_id) override;
+
+ virtual int get_packet_peer() const override;
+
+ virtual bool is_server() const override;
+
+ virtual void poll() override;
+
+ virtual int get_unique_id() const override;
+
+ virtual void set_refuse_new_connections(bool p_enable) override;
+ virtual bool is_refusing_new_connections() const override;
+
+ virtual ConnectionStatus get_connection_status() const override;
+
+ /* PacketPeer GDExtension */
+ GDVIRTUAL0RC(int, _get_available_packet_count);
+ GDVIRTUAL2R(int, _get_packet, GDNativeConstPtr<const uint8_t *>, GDNativePtr<int>);
+ GDVIRTUAL2R(int, _put_packet, GDNativeConstPtr<const uint8_t>, int);
+ GDVIRTUAL0RC(int, _get_max_packet_size);
+
+ /* MultiplayerPeer GDExtension */
+ GDVIRTUAL1(_set_transfer_channel, int);
+ GDVIRTUAL0RC(int, _get_transfer_channel);
+ GDVIRTUAL1(_set_transfer_mode, int);
+ GDVIRTUAL0RC(int, _get_transfer_mode);
+ GDVIRTUAL1(_set_target_peer, int);
+ GDVIRTUAL0RC(int, _get_packet_peer);
+ GDVIRTUAL0RC(bool, _is_server);
+ GDVIRTUAL0R(int, _poll);
+ GDVIRTUAL0RC(int, _get_unique_id);
+ GDVIRTUAL1(_set_refuse_new_connections, bool);
+ GDVIRTUAL0RC(bool, _is_refusing_new_connections);
+ GDVIRTUAL0RC(int, _get_connection_status);
+};
#endif // NETWORKED_MULTIPLAYER_PEER_H
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 7505f3ff34..69366f688c 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -282,6 +282,11 @@ String OS::get_bundle_resource_dir() const {
return ".";
}
+// Path to macOS .app bundle embedded icon
+String OS::get_bundle_icon_path() const {
+ return String();
+}
+
// OS specific path for user://
String OS::get_user_data_dir() const {
return ".";
diff --git a/core/os/os.h b/core/os/os.h
index c027428477..29d33ce4f0 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -252,6 +252,7 @@ public:
virtual String get_config_path() const;
virtual String get_cache_path() const;
virtual String get_bundle_resource_dir() const;
+ virtual String get_bundle_icon_path() const;
virtual String get_user_data_dir() const;
virtual String get_resource_dir() const;
diff --git a/core/os/thread.cpp b/core/os/thread.cpp
index 92e43963d2..27aefc98de 100644
--- a/core/os/thread.cpp
+++ b/core/os/thread.cpp
@@ -28,9 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-// Define PLATFORM_CUSTOM_THREAD_H in platform_config.h
-// Overriding the platform implementation is required in some proprietary platforms
-#ifndef PLATFORM_CUSTOM_THREAD_H
+#ifndef PLATFORM_THREAD_OVERRIDE // See details in thread.h
#include "thread.h"
@@ -130,4 +128,4 @@ Thread::~Thread() {
}
#endif
-#endif // PLATFORM_CUSTOM_THREAD_H
+#endif // PLATFORM_THREAD_OVERRIDE
diff --git a/core/os/thread.h b/core/os/thread.h
index 3a0938c7f7..59cb58ac57 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -28,10 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-// Define PLATFORM_CUSTOM_THREAD_H in platform_config.h
+// Define PLATFORM_THREAD_OVERRIDE in your platform's `platform_config.h`
+// to use a custom Thread implementation defined in `platform/[your_platform]/platform_thread.h`
// Overriding the platform implementation is required in some proprietary platforms
-#ifdef PLATFORM_CUSTOM_THREAD_H
-#include PLATFORM_CUSTOM_THREAD_H
+#ifdef PLATFORM_THREAD_OVERRIDE
+#include "platform_thread.h"
#else
#ifndef THREAD_H
#define THREAD_H
@@ -121,4 +122,4 @@ public:
};
#endif // THREAD_H
-#endif // PLATFORM_CUSTOM_THREAD_H
+#endif // PLATFORM_THREAD_OVERRIDE
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 3a037f9dd1..e33c21cc00 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -169,11 +169,13 @@ void register_core_types() {
GDREGISTER_VIRTUAL_CLASS(IP);
GDREGISTER_VIRTUAL_CLASS(StreamPeer);
+ GDREGISTER_CLASS(StreamPeerExtension);
GDREGISTER_CLASS(StreamPeerBuffer);
GDREGISTER_CLASS(StreamPeerTCP);
GDREGISTER_CLASS(TCPServer);
GDREGISTER_VIRTUAL_CLASS(PacketPeer);
+ GDREGISTER_CLASS(PacketPeerExtension);
GDREGISTER_CLASS(PacketPeerStream);
GDREGISTER_CLASS(PacketPeerUDP);
GDREGISTER_CLASS(UDPServer);
@@ -197,6 +199,7 @@ void register_core_types() {
ResourceLoader::add_resource_format_loader(resource_format_loader_crypto);
GDREGISTER_VIRTUAL_CLASS(MultiplayerPeer);
+ GDREGISTER_VIRTUAL_CLASS(MultiplayerPeerExtension);
GDREGISTER_VIRTUAL_CLASS(MultiplayerReplicator);
GDREGISTER_CLASS(MultiplayerAPI);
GDREGISTER_CLASS(MainLoop);
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index cb7d924556..5c0eb388f5 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -875,6 +875,11 @@ void Translation::add_plural_message(const StringName &p_src_text, const Vector<
}
StringName Translation::get_message(const StringName &p_src_text, const StringName &p_context) const {
+ StringName ret;
+ if (GDVIRTUAL_CALL(_get_message, p_src_text, p_context, ret)) {
+ return ret;
+ }
+
if (p_context != StringName()) {
WARN_PRINT("Translation class doesn't handle context. Using context in get_message() on a Translation instance is probably a mistake. \nUse a derived Translation class that handles context, such as TranslationPO class");
}
@@ -888,6 +893,11 @@ StringName Translation::get_message(const StringName &p_src_text, const StringNa
}
StringName Translation::get_plural_message(const StringName &p_src_text, const StringName &p_plural_text, int p_n, const StringName &p_context) const {
+ StringName ret;
+ if (GDVIRTUAL_CALL(_get_plural_message, p_src_text, p_plural_text, p_n, p_context, ret)) {
+ return ret;
+ }
+
WARN_PRINT("Translation class doesn't handle plural messages. Calling get_plural_message() on a Translation instance is probably a mistake. \nUse a derived Translation class that handles plurals, such as TranslationPO class");
return get_message(p_src_text);
}
@@ -923,6 +933,9 @@ void Translation::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_messages"), &Translation::_set_messages);
ClassDB::bind_method(D_METHOD("_get_messages"), &Translation::_get_messages);
+ GDVIRTUAL_BIND(_get_plural_message, "src_message", "src_plural_message", "n", "context");
+ GDVIRTUAL_BIND(_get_message, "src_message", "context");
+
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "messages", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_messages", "_get_messages");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
}
diff --git a/core/string/translation.h b/core/string/translation.h
index 4f179ac0fe..6aec0bb8ea 100644
--- a/core/string/translation.h
+++ b/core/string/translation.h
@@ -32,6 +32,8 @@
#define TRANSLATION_H
#include "core/io/resource.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
class Translation : public Resource {
GDCLASS(Translation, Resource);
@@ -48,6 +50,9 @@ class Translation : public Resource {
protected:
static void _bind_methods();
+ GDVIRTUAL2RC(StringName, _get_message, StringName, StringName);
+ GDVIRTUAL4RC(StringName, _get_plural_message, StringName, StringName, int, StringName);
+
public:
void set_locale(const String &p_locale);
_FORCE_INLINE_ String get_locale() const { return locale; }
diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h
index e947d2211c..71d41eacc4 100644
--- a/core/templates/rid_owner.h
+++ b/core/templates/rid_owner.h
@@ -151,7 +151,7 @@ public:
return _allocate_rid();
}
- _FORCE_INLINE_ T *getornull(const RID &p_rid, bool p_initialize = false) {
+ _FORCE_INLINE_ T *get_or_null(const RID &p_rid, bool p_initialize = false) {
if (p_rid == RID()) {
return nullptr;
}
@@ -210,12 +210,12 @@ public:
return ptr;
}
void initialize_rid(RID p_rid) {
- T *mem = getornull(p_rid, true);
+ T *mem = get_or_null(p_rid, true);
ERR_FAIL_COND(!mem);
memnew_placement(mem, T);
}
void initialize_rid(RID p_rid, const T &p_value) {
- T *mem = getornull(p_rid, true);
+ T *mem = get_or_null(p_rid, true);
ERR_FAIL_COND(!mem);
memnew_placement(mem, T(p_value));
}
@@ -399,8 +399,8 @@ public:
alloc.initialize_rid(p_rid, p_ptr);
}
- _FORCE_INLINE_ T *getornull(const RID &p_rid) {
- T **ptr = alloc.getornull(p_rid);
+ _FORCE_INLINE_ T *get_or_null(const RID &p_rid) {
+ T **ptr = alloc.get_or_null(p_rid);
if (unlikely(!ptr)) {
return nullptr;
}
@@ -408,7 +408,7 @@ public:
}
_FORCE_INLINE_ void replace(const RID &p_rid, T *p_new_ptr) {
- T **ptr = alloc.getornull(p_rid);
+ T **ptr = alloc.get_or_null(p_rid);
ERR_FAIL_COND(!ptr);
*ptr = p_new_ptr;
}
@@ -469,8 +469,8 @@ public:
alloc.initialize_rid(p_rid, p_ptr);
}
- _FORCE_INLINE_ T *getornull(const RID &p_rid) {
- return alloc.getornull(p_rid);
+ _FORCE_INLINE_ T *get_or_null(const RID &p_rid) {
+ return alloc.get_or_null(p_rid);
}
_FORCE_INLINE_ bool owns(const RID &p_rid) {
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index f487e718f4..dcded6e61f 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -377,11 +377,11 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const {
return obj->emit_signal(name, p_arguments, p_argcount);
}
-Error Signal::connect(const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
+Error Signal::connect(const Callable &p_callable, uint32_t p_flags) {
Object *object = get_object();
ERR_FAIL_COND_V(!object, ERR_UNCONFIGURED);
- return object->connect(name, p_callable, p_binds, p_flags);
+ return object->connect(name, p_callable, varray(), p_flags);
}
void Signal::disconnect(const Callable &p_callable) {
diff --git a/core/variant/callable.h b/core/variant/callable.h
index 52094af3aa..de886492ea 100644
--- a/core/variant/callable.h
+++ b/core/variant/callable.h
@@ -159,7 +159,7 @@ public:
operator String() const;
Error emit(const Variant **p_arguments, int p_argcount) const;
- Error connect(const Callable &p_callable, const Vector<Variant> &p_binds = Vector<Variant>(), uint32_t p_flags = 0);
+ Error connect(const Callable &p_callable, uint32_t p_flags = 0);
void disconnect(const Callable &p_callable);
bool is_connected(const Callable &p_callable) const;
diff --git a/core/variant/native_ptr.h b/core/variant/native_ptr.h
index b4ec0df7d6..913d4d8f7c 100644
--- a/core/variant/native_ptr.h
+++ b/core/variant/native_ptr.h
@@ -55,7 +55,7 @@ struct GDNativePtr {
#define GDVIRTUAL_NATIVE_PTR(m_type) \
template <> \
- struct GDNativeConstPtr<m_type> { \
+ struct GDNativeConstPtr<const m_type> { \
const m_type *data = nullptr; \
GDNativeConstPtr(const m_type *p_assign) { data = p_assign; } \
static const char *get_name() { return "const " #m_type; } \
@@ -117,6 +117,7 @@ GDVIRTUAL_NATIVE_PTR(char16_t)
GDVIRTUAL_NATIVE_PTR(char32_t)
GDVIRTUAL_NATIVE_PTR(wchar_t)
GDVIRTUAL_NATIVE_PTR(uint8_t)
+GDVIRTUAL_NATIVE_PTR(uint8_t *)
GDVIRTUAL_NATIVE_PTR(int8_t)
GDVIRTUAL_NATIVE_PTR(uint16_t)
GDVIRTUAL_NATIVE_PTR(int16_t)
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index c3fe4117ac..32d6778a2b 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1690,7 +1690,7 @@ static void _register_variant_builtin_methods() {
bind_method(Signal, get_object_id, sarray(), varray());
bind_method(Signal, get_name, sarray(), varray());
- bind_method(Signal, connect, sarray("callable", "binds", "flags"), varray(Array(), 0));
+ bind_method(Signal, connect, sarray("callable", "flags"), varray(0));
bind_method(Signal, disconnect, sarray("callable"), varray());
bind_method(Signal, is_connected, sarray("callable"), varray());
bind_method(Signal, get_connections, sarray(), varray());
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 0334bab32a..fe0d7e4408 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -23,7 +23,7 @@
Returns the absolute value of float parameter [code]x[/code] (i.e. positive value).
[codeblock]
# a is 1.2
- a = absf(-1.2)
+ var a = absf(-1.2)
[/codeblock]
</description>
</method>
@@ -34,7 +34,7 @@
Returns the absolute value of int parameter [code]x[/code] (i.e. positive value).
[codeblock]
# a is 1
- a = absi(-1)
+ var a = absi(-1)
[/codeblock]
</description>
</method>
@@ -45,7 +45,7 @@
Returns the arc cosine of [code]x[/code] in radians. Use to get the angle of cosine [code]x[/code]. [code]x[/code] must be between [code]-1.0[/code] and [code]1.0[/code] (inclusive), otherwise, [method acos] will return [constant @GDScript.NAN].
[codeblock]
# c is 0.523599 or 30 degrees if converted with rad2deg(c)
- c = acos(0.866025)
+ var c = acos(0.866025)
[/codeblock]
</description>
</method>
@@ -56,7 +56,7 @@
Returns the arc sine of [code]x[/code] in radians. Use to get the angle of sine [code]x[/code]. [code]x[/code] must be between [code]-1.0[/code] and [code]1.0[/code] (inclusive), otherwise, [method asin] will return [constant @GDScript.NAN].
[codeblock]
# s is 0.523599 or 30 degrees if converted with rad2deg(s)
- s = asin(0.5)
+ var s = asin(0.5)
[/codeblock]
</description>
</method>
@@ -64,11 +64,12 @@
<return type="float" />
<argument index="0" name="x" type="float" />
<description>
- Returns the arc tangent of [code]x[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code].
+ Returns the arc tangent of [code]x[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry.
The method cannot know in which quadrant the angle should fall. See [method atan2] if you have both [code]y[/code] and [code]x[/code].
[codeblock]
- a = atan(0.5) # a is 0.463648
+ var a = atan(0.5) # a is 0.463648
[/codeblock]
+ If [code]x[/code] is between [code]-PI / 2[/code] and [code]PI / 2[/code] (inclusive), [code]atan(tan(x))[/code] is equal to [code]x[/code].
</description>
</method>
<method name="atan2">
@@ -79,7 +80,7 @@
Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
Important note: The Y coordinate comes first, by convention.
[codeblock]
- a = atan2(0, -1) # a is 3.141593
+ var a = atan2(0, -1) # a is 3.141593
[/codeblock]
</description>
</method>
@@ -105,8 +106,8 @@
<description>
Rounds [code]x[/code] upward (towards positive infinity), returning the smallest whole number that is not less than [code]x[/code].
[codeblock]
- i = ceil(1.45) # i is 2
- i = ceil(1.001) # i is 2
+ var i = ceil(1.45) # i is 2.0
+ i = ceil(1.001) # i is 2.0
[/codeblock]
See also [method floor], [method round], and [method snapped].
</description>
@@ -127,9 +128,9 @@
<description>
Clamps the float [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code].
[codeblock]
- speed = 42.1
+ var speed = 42.1
# a is 20.0
- a = clampf(speed, 1.0, 20.0)
+ var a = clampf(speed, 1.0, 20.0)
speed = -10.0
# a is -1.0
@@ -145,9 +146,9 @@
<description>
Clamps the integer [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code].
[codeblock]
- speed = 42
+ var speed = 42
# a is 20
- a = clampi(speed, 1, 20)
+ var a = clampi(speed, 1, 20)
speed = -10
# a is -1
@@ -161,9 +162,9 @@
<description>
Returns the cosine of angle [code]angle_rad[/code] in radians.
[codeblock]
- # Prints 1 then -1
- print(cos(PI * 2))
- print(cos(PI))
+ cos(PI * 2) # Returns 1.0
+ cos(PI) # Returns -1.0
+ cos(deg2rad(90)) # Returns 0.0
[/codeblock]
</description>
</method>
@@ -192,7 +193,7 @@
Converts an angle expressed in degrees to radians.
[codeblock]
# r is 3.141593
- r = deg2rad(180)
+ var r = deg2rad(180)
[/codeblock]
</description>
</method>
@@ -201,7 +202,18 @@
<argument index="0" name="x" type="float" />
<argument index="1" name="curve" type="float" />
<description>
- Easing function, based on exponent. The curve values are: 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
+ Returns an "eased" value of [code]x[/code] based on an easing function defined with [code]curve[/code]. This easing function is based on an exponent. The [code]curve[/code] can be any floating-point number, with specific values leading to the following behaviors:
+ [codeblock]
+ - Lower than -1.0 (exclusive): Ease in-out
+ - 1.0: Linear
+ - Between -1.0 and 0.0 (exclusive): Ease out-in
+ - 0.0: Constant
+ - Between 0.0 to 1.0 (exclusive): Ease in
+ - 1.0: Linear
+ - Greater than 1.0 (exclusive): Ease out
+ [/codeblock]
+ [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/ease_cheatsheet.png]ease() curve values cheatsheet[/url]
+ See also [method smoothstep]. If you need to perform more advanced transitions, use [Tween] or [AnimationPlayer].
</description>
</method>
<method name="error_string">
@@ -219,7 +231,7 @@
[b]e[/b] has an approximate value of 2.71828, and can be obtained with [code]exp(1)[/code].
For exponents to other bases use the method [method pow].
[codeblock]
- a = exp(2) # Approximately 7.39
+ var a = exp(2) # Approximately 7.39
[/codeblock]
</description>
</method>
@@ -230,7 +242,7 @@
Rounds [code]x[/code] downward (towards negative infinity), returning the largest whole number that is not more than [code]x[/code].
[codeblock]
# a is 2.0
- a = floor(2.99)
+ var a = floor(2.99)
# a is -3.0
a = floor(-2.99)
[/codeblock]
@@ -550,7 +562,7 @@
<description>
Converts one or more arguments of any type to string in the best way possible and prints them to the console.
[codeblock]
- a = [1, 2, 3]
+ var a = [1, 2, 3]
print("a", "b", a) # Prints ab[1, 2, 3]
[/codeblock]
[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.
@@ -729,7 +741,7 @@
<description>
Sets seed for the random number generator.
[codeblock]
- my_seed = "Godot Rocks"
+ var my_seed = "Godot Rocks"
seed(my_seed.hash())
[/codeblock]
</description>
@@ -770,7 +782,8 @@
<description>
Returns the sine of angle [code]angle_rad[/code] in radians.
[codeblock]
- sin(0.523599) # Returns 0.5
+ sin(0.523599) # Returns 0.5
+ sin(deg2rad(90)) # Returns 1.0
[/codeblock]
</description>
</method>
@@ -780,7 +793,7 @@
<description>
Returns the hyperbolic sine of [code]x[/code].
[codeblock]
- a = log(2.0) # Returns 0.693147
+ var a = log(2.0) # Returns 0.693147
sinh(a) # Returns 0.75
[/codeblock]
</description>
@@ -800,6 +813,8 @@
smoothstep(0, 2, 1.0) # Returns 0.5
smoothstep(0, 2, 2.0) # Returns 1.0
[/codeblock]
+ Compared to [method ease] with a curve value of [code]-1.6521[/code], [method smoothstep] returns the smoothest possible curve with no sudden changes in the derivative. If you need to perform more advanced transitions, use [Tween] or [AnimationPlayer].
+ [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/smoothstep_ease_comparison.png]Comparison between smoothstep() and ease(x, -1.6521) return values[/url]
</description>
</method>
<method name="snapped">
@@ -833,7 +848,7 @@
Returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation.
[codeblock]
# n is 0
- n = step_decimals(5)
+ var n = step_decimals(5)
# n is 4
n = step_decimals(1.0005)
# n is 9
@@ -853,8 +868,8 @@
<description>
Converts a formatted string that was returned by [method var2str] to the original value.
[codeblock]
- a = '{ "a": 1, "b": 2 }'
- b = str2var(a)
+ var a = '{ "a": 1, "b": 2 }'
+ var b = str2var(a)
print(b["a"]) # Prints 1
[/codeblock]
</description>
@@ -875,7 +890,7 @@
<description>
Returns the hyperbolic tangent of [code]x[/code].
[codeblock]
- a = log(2.0) # Returns 0.693147
+ var a = log(2.0) # Returns 0.693147
tanh(a) # Returns 0.6
[/codeblock]
</description>
diff --git a/doc/classes/AnimatableBody2D.xml b/doc/classes/AnimatableBody2D.xml
index e58f4bd692..bc169cf9c9 100644
--- a/doc/classes/AnimatableBody2D.xml
+++ b/doc/classes/AnimatableBody2D.xml
@@ -11,7 +11,7 @@
<tutorials>
</tutorials>
<members>
- <member name="sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false">
+ <member name="sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="true">
If [code]true[/code], the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method PhysicsBody2D.move_and_collide].
</member>
</members>
diff --git a/doc/classes/AnimatableBody3D.xml b/doc/classes/AnimatableBody3D.xml
index 71a48a5aa6..86cff38c51 100644
--- a/doc/classes/AnimatableBody3D.xml
+++ b/doc/classes/AnimatableBody3D.xml
@@ -14,7 +14,7 @@
<link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link>
</tutorials>
<members>
- <member name="sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false">
+ <member name="sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="true">
If [code]true[/code], the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method PhysicsBody3D.move_and_collide].
</member>
</members>
diff --git a/doc/classes/CharacterBody2D.xml b/doc/classes/CharacterBody2D.xml
index 882aa8bd71..e14c2dc110 100644
--- a/doc/classes/CharacterBody2D.xml
+++ b/doc/classes/CharacterBody2D.xml
@@ -28,6 +28,12 @@
Returns the surface normal of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code].
</description>
</method>
+ <method name="get_last_motion" qualifiers="const">
+ <return type="Vector2" />
+ <description>
+ Returns the last motion applied to the [CharacterBody2D] during the last call to [method move_and_slide]. The movement can be split into multiple motions when sliding occurs, and this method return the last one, which is useful to retrieve the current direction of the movement.
+ </description>
+ </method>
<method name="get_last_slide_collision">
<return type="KinematicCollision2D" />
<description>
@@ -40,6 +46,18 @@
Returns the linear velocity of the platform at the last collision point. Only valid after calling [method move_and_slide].
</description>
</method>
+ <method name="get_position_delta" qualifiers="const">
+ <return type="Vector2" />
+ <description>
+ Returns the travel (position delta) that occurred during the last call to [method move_and_slide].
+ </description>
+ </method>
+ <method name="get_real_velocity" qualifiers="const">
+ <return type="Vector2" />
+ <description>
+ Returns the current real velocity since the last call to [method move_and_slide]. For example, when you climb a slope, you will move diagonally even though the velocity is horizontal. This method returns the diagonal movement, as opposed to [member motion_velocity] which returns the requested velocity.
+ </description>
+ </method>
<method name="get_slide_collision">
<return type="KinematicCollision2D" />
<argument index="0" name="slide_idx" type="int" />
@@ -68,6 +86,12 @@
Returns the number of times the body collided and changed direction during the last call to [method move_and_slide].
</description>
</method>
+ <method name="get_wall_normal" qualifiers="const">
+ <return type="Vector2" />
+ <description>
+ Returns the surface normal of the wall at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_wall] returns [code]true[/code].
+ </description>
+ </method>
<method name="is_on_ceiling" qualifiers="const">
<return type="bool" />
<description>
@@ -107,9 +131,9 @@
<method name="move_and_slide">
<return type="bool" />
<description>
- Moves the body based on [member linear_velocity]. If the body collides with another, it will slide along the other body (by default only on floor) rather than stop immediately. If the other body is a [CharacterBody2D] or [RigidDynamicBody2D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
+ Moves the body based on [member motion_velocity]. If the body collides with another, it will slide along the other body (by default only on floor) rather than stop immediately. If the other body is a [CharacterBody2D] or [RigidDynamicBody2D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
- Modifies [member linear_velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for detailed information about collisions that occurred, use [method get_slide_collision].
+ Modifies [member motion_velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for detailed information about collisions that occurred, use [method get_slide_collision].
When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
The general behaviour and available properties change according to the [member motion_mode].
Returns [code]true[/code] if the body collided, otherwise, returns [code]false[/code].
@@ -133,25 +157,29 @@
<member name="floor_max_angle" type="float" setter="set_floor_max_angle" getter="get_floor_max_angle" default="0.785398">
Maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall, when calling [method move_and_slide]. The default value equals 45 degrees.
</member>
- <member name="floor_snap_length" type="float" setter="set_floor_snap_length" getter="get_floor_snap_length" default="0.0">
+ <member name="floor_snap_length" type="float" setter="set_floor_snap_length" getter="get_floor_snap_length" default="1.0">
Sets a snapping distance. When set to a value different from [code]0.0[/code], the body is kept attached to slopes when calling [method move_and_slide]. The snapping vector is determined by the given distance along the opposite direction of the [member up_direction].
As long as the snapping vector is in contact with the ground and the body moves against `up_direction`, the body will remain attached to the surface. Snapping is not applied if the body moves along `up_direction`, so it will be able to detach from the ground when jumping.
</member>
- <member name="floor_stop_on_slope" type="bool" setter="set_floor_stop_on_slope_enabled" getter="is_floor_stop_on_slope_enabled" default="false">
- If [code]true[/code], the body will not slide on floor's slopes when you include gravity in [code]linear_velocity[/code] when calling [method move_and_slide] and the body is standing still.
+ <member name="floor_stop_on_slope" type="bool" setter="set_floor_stop_on_slope_enabled" getter="is_floor_stop_on_slope_enabled" default="true">
+ If [code]true[/code], the body will not slide on slopes when calling [method move_and_slide] when the body is standing still.
+ If [code]false[/code], the body will slide on floor's slopes when [member motion_velocity] applies a downward force.
</member>
<member name="free_mode_min_slide_angle" type="float" setter="set_free_mode_min_slide_angle" getter="get_free_mode_min_slide_angle" default="0.261799">
Minimum angle (in radians) where the body is allowed to slide when it encounters a slope. The default value equals 15 degrees.
</member>
- <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)">
- Current velocity vector in pixels per second, used and modified during calls to [method move_and_slide].
- </member>
<member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="4">
Maximum number of times the body can change direction before it stops when calling [method move_and_slide].
</member>
<member name="motion_mode" type="int" setter="set_motion_mode" getter="get_motion_mode" enum="CharacterBody2D.MotionMode" default="0">
Sets the motion mode which defines the behaviour of [method move_and_slide]. See [enum MotionMode] constants for available modes.
</member>
+ <member name="motion_velocity" type="Vector2" setter="set_motion_velocity" getter="get_motion_velocity" default="Vector2(0, 0)">
+ Current velocity vector in pixels per second, used and modified during calls to [method move_and_slide].
+ </member>
+ <member name="moving_platform_apply_velocity_on_leave" type="int" setter="set_moving_platform_apply_velocity_on_leave" getter="get_moving_platform_apply_velocity_on_leave" enum="CharacterBody2D.MovingPlatformApplyVelocityOnLeave" default="0">
+ Sets the behaviour to apply when you leave a moving platform. By default, to be physically accurate, when you leave the last platform velocity is applied. See [enum MovingPlatformApplyVelocityOnLeave] constants for available behaviour.
+ </member>
<member name="moving_platform_floor_layers" type="int" setter="set_moving_platform_floor_layers" getter="get_moving_platform_floor_layers" default="4294967295">
Collision layers that will be included for detecting floor bodies that will act as moving platforms to be followed by the [CharacterBody2D]. By default, all floor bodies are detected and propagate their velocity.
</member>
@@ -172,5 +200,14 @@
<constant name="MOTION_MODE_FREE" value="1" enum="MotionMode">
Apply when there is no notion of floor or ceiling. All collisions will be reported as [code]on_wall[/code]. In this mode, when you slide, the speed will always be constant. This mode is suitable for top-down games.
</constant>
+ <constant name="PLATFORM_VEL_ON_LEAVE_ALWAYS" value="0" enum="MovingPlatformApplyVelocityOnLeave">
+ Add the last platform velocity to the [member motion_velocity] when you leave a moving platform.
+ </constant>
+ <constant name="PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY" value="1" enum="MovingPlatformApplyVelocityOnLeave">
+ Add the last platform velocity to the [member motion_velocity] when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.
+ </constant>
+ <constant name="PLATFORM_VEL_ON_LEAVE_NEVER" value="2" enum="MovingPlatformApplyVelocityOnLeave">
+ Do nothing when leaving a platform.
+ </constant>
</constants>
</class>
diff --git a/doc/classes/CharacterBody3D.xml b/doc/classes/CharacterBody3D.xml
index f13796bfe7..24b26fb16e 100644
--- a/doc/classes/CharacterBody3D.xml
+++ b/doc/classes/CharacterBody3D.xml
@@ -32,7 +32,7 @@
<method name="get_last_motion" qualifiers="const">
<return type="Vector3" />
<description>
- Returns the last motion applied to the [CharacterBody3D] during the last call to [method move_and_slide]. The movement can be split if needed into multiple motion, this method return the last one, it's useful to retrieve the current direction of the movement.
+ Returns the last motion applied to the [CharacterBody3D] during the last call to [method move_and_slide]. The movement can be split into multiple motions when sliding occurs, and this method return the last one, which is useful to retrieve the current direction of the movement.
</description>
</method>
<method name="get_last_slide_collision">
@@ -56,7 +56,7 @@
<method name="get_real_velocity" qualifiers="const">
<return type="Vector3" />
<description>
- Returns the current real velocity since the last call to [method move_and_slide]. For example, when you climb a slope, you will move diagonally even though the velocity is horizontal. This method returns the diagonal movement, as opposed to [member linear_velocity] which returns the requested velocity.
+ Returns the current real velocity since the last call to [method move_and_slide]. For example, when you climb a slope, you will move diagonally even though the velocity is horizontal. This method returns the diagonal movement, as opposed to [member motion_velocity] which returns the requested velocity.
</description>
</method>
<method name="get_slide_collision">
@@ -117,9 +117,9 @@
<method name="move_and_slide">
<return type="bool" />
<description>
- Moves the body based on [member linear_velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody3D] or [RigidDynamicBody3D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
+ Moves the body based on [member motion_velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody3D] or [RigidDynamicBody3D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
- Modifies [member linear_velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for more detailed information about collisions that occurred, use [method get_slide_collision].
+ Modifies [member motion_velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for more detailed information about collisions that occurred, use [method get_slide_collision].
When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
Returns [code]true[/code] if the body collided, otherwise, returns [code]false[/code].
</description>
@@ -146,11 +146,9 @@
Sets a snapping distance. When set to a value different from [code]0.0[/code], the body is kept attached to slopes when calling [method move_and_slide]. The snapping vector is determined by the given distance along the opposite direction of the [member up_direction].
As long as the snapping vector is in contact with the ground and the body moves against `up_direction`, the body will remain attached to the surface. Snapping is not applied if the body moves along `up_direction`, so it will be able to detach from the ground when jumping.
</member>
- <member name="floor_stop_on_slope" type="bool" setter="set_floor_stop_on_slope_enabled" getter="is_floor_stop_on_slope_enabled" default="false">
- If [code]true[/code], the body will not slide on slopes when you include gravity in [code]linear_velocity[/code] when calling [method move_and_slide] and the body is standing still.
- </member>
- <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)">
- Current velocity vector (typically meters per second), used and modified during calls to [method move_and_slide].
+ <member name="floor_stop_on_slope" type="bool" setter="set_floor_stop_on_slope_enabled" getter="is_floor_stop_on_slope_enabled" default="true">
+ If [code]true[/code], the body will not slide on slopes when calling [method move_and_slide] when the body is standing still.
+ If [code]false[/code], the body will slide on floor's slopes when [member motion_velocity] applies a downward force.
</member>
<member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="6">
Maximum number of times the body can change direction before it stops when calling [method move_and_slide].
@@ -158,6 +156,9 @@
<member name="motion_mode" type="int" setter="set_motion_mode" getter="get_motion_mode" enum="CharacterBody3D.MotionMode" default="0">
Sets the motion mode which defines the behaviour of [method move_and_slide]. See [enum MotionMode] constants for available modes.
</member>
+ <member name="motion_velocity" type="Vector3" setter="set_motion_velocity" getter="get_motion_velocity" default="Vector3(0, 0, 0)">
+ Current velocity vector (typically meters per second), used and modified during calls to [method move_and_slide].
+ </member>
<member name="moving_platform_apply_velocity_on_leave" type="int" setter="set_moving_platform_apply_velocity_on_leave" getter="get_moving_platform_apply_velocity_on_leave" enum="CharacterBody3D.MovingPlatformApplyVelocityOnLeave" default="0">
Sets the behaviour to apply when you leave a moving platform. By default, to be physically accurate, when you leave the last platform velocity is applied. See [enum MovingPlatformApplyVelocityOnLeave] constants for available behaviour.
</member>
@@ -185,10 +186,10 @@
Apply when there is no notion of floor or ceiling. All collisions will be reported as [code]on_wall[/code]. In this mode, when you slide, the speed will always be constant. This mode is suitable for games without ground like space games.
</constant>
<constant name="PLATFORM_VEL_ON_LEAVE_ALWAYS" value="0" enum="MovingPlatformApplyVelocityOnLeave">
- Add the last platform velocity to the [member linear_velocity] when you leave a moving platform.
+ Add the last platform velocity to the [member motion_velocity] when you leave a moving platform.
</constant>
<constant name="PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY" value="1" enum="MovingPlatformApplyVelocityOnLeave">
- Add the last platform velocity to the [member linear_velocity] when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.
+ Add the last platform velocity to the [member motion_velocity] when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.
</constant>
<constant name="PLATFORM_VEL_ON_LEAVE_NEVER" value="2" enum="MovingPlatformApplyVelocityOnLeave">
Do nothing when leaving a platform.
diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml
index 571ffd592a..f33016cc6c 100644
--- a/doc/classes/ColorPicker.xml
+++ b/doc/classes/ColorPicker.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
Displays a color picker widget. Useful for selecting a color from an RGB/RGBA colorspace.
+ [b]Note:[/b] This control is the color picker widget itself. You can use a [ColorPickerButton] instead if you need a button that brings up a [ColorPicker] in a pop-up.
</description>
<tutorials>
<link title="Tween Demo">https://godotengine.org/asset-library/asset/146</link>
diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml
index dcef1c55f7..1cdfbd760e 100644
--- a/doc/classes/ColorPickerButton.xml
+++ b/doc/classes/ColorPickerButton.xml
@@ -6,6 +6,7 @@
<description>
Encapsulates a [ColorPicker] making it accessible by pressing a button. Pressing the button will toggle the [ColorPicker] visibility.
See also [BaseButton] which contains common properties and methods associated with this node.
+ [b]Note:[/b] By default, the button may not be wide enough for the color preview swatch to be visible. Make sure to set [member Control.rect_min_size] to a big enough value to give the button enough space.
</description>
<tutorials>
<link title="GUI Drag And Drop Demo">https://godotengine.org/asset-library/asset/133</link>
diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml
index 0575ea3eef..2eb75d48a3 100644
--- a/doc/classes/Dictionary.xml
+++ b/doc/classes/Dictionary.xml
@@ -213,7 +213,8 @@
<return type="bool" />
<argument index="0" name="key" type="Variant" />
<description>
- Erase a dictionary key/value pair by key. Returns [code]true[/code] if the given key was present in the dictionary, [code]false[/code] otherwise. Does not erase elements while iterating over the dictionary.
+ Erase a dictionary key/value pair by key. Returns [code]true[/code] if the given key was present in the dictionary, [code]false[/code] otherwise.
+ [b]Note:[/b] Don't erase elements while iterating over the dictionary. You can iterate over the [method keys] array instead.
</description>
</method>
<method name="get" qualifiers="const">
diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml
index 6e22c58024..f05a216301 100644
--- a/doc/classes/Engine.xml
+++ b/doc/classes/Engine.xml
@@ -147,6 +147,20 @@
Returns [code]true[/code] if a singleton with given [code]name[/code] exists in global scope.
</description>
</method>
+ <method name="is_editor_hint" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if the script is currently running inside the editor, [code]false[/code] otherwise. This is useful for [code]@tool[/code] scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor:
+ [codeblock]
+ if Engine.is_editor_hint():
+ draw_gizmos()
+ else:
+ simulate_physics()
+ [/codeblock]
+ See [url=https://docs.godotengine.org/en/latest/tutorials/plugins/running_code_in_the_editor.html]Running code in the editor[/url] in the documentation for more information.
+ [b]Note:[/b] To detect whether the script is run from an editor [i]build[/i] (e.g. when pressing [kbd]F5[/kbd]), use [method OS.has_feature] with the [code]"editor"[/code] argument instead. [code]OS.has_feature("editor")[/code] will evaluate to [code]true[/code] both when the code is running in the editor and when running the project from the editor, but it will evaluate to [code]false[/code] when the code is run from an exported project.
+ </description>
+ </method>
<method name="is_in_physics_frame" qualifiers="const">
<return type="bool" />
<description>
@@ -168,17 +182,6 @@
</method>
</methods>
<members>
- <member name="editor_hint" type="bool" setter="set_editor_hint" getter="is_editor_hint" default="true">
- If [code]true[/code], the script is currently running inside the editor. This is useful for [code]@tool[/code] scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor:
- [codeblock]
- if Engine.editor_hint:
- draw_gizmos()
- else:
- simulate_physics()
- [/codeblock]
- See [url=https://docs.godotengine.org/en/latest/tutorials/plugins/running_code_in_the_editor.html]Running code in the editor[/url] in the documentation for more information.
- [b]Note:[/b] To detect whether the script is run from an editor [i]build[/i] (e.g. when pressing [kbd]F5[/kbd]), use [method OS.has_feature] with the [code]"editor"[/code] argument instead. [code]OS.has_feature("editor")[/code] will evaluate to [code]true[/code] both when the code is running in the editor and when running the project from the editor, but it will evaluate to [code]false[/code] when the code is run from an exported project.
- </member>
<member name="physics_jitter_fix" type="float" setter="set_physics_jitter_fix" getter="get_physics_jitter_fix" default="0.5">
Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
[b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics_jitter_fix] to [code]0[/code].
diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml
index 29aaf3c756..9f33c400f4 100644
--- a/doc/classes/HTTPClient.xml
+++ b/doc/classes/HTTPClient.xml
@@ -8,6 +8,7 @@
[b]Note:[/b] This client only needs to connect to a host once (see [method connect_to_host]) to send multiple requests. Because of this, methods that take URLs usually take just the part after the host instead of the full URL, as the client is already connected to a host. See [method request] for a full example and to get started.
A [HTTPClient] should be reused between multiple requests or to connect to different hosts instead of creating one client per request. Supports SSL and SSL server certificate verification. HTTP status codes in the 2xx range indicate success, 3xx redirection (i.e. "try again, but over here"), 4xx something was wrong with the request, and 5xx something went wrong on the server's side.
For more information on HTTP, see https://developer.mozilla.org/en-US/docs/Web/HTTP (or read RFC 2616 to get it straight from the source: https://tools.ietf.org/html/rfc2616).
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
[b]Note:[/b] It's recommended to use transport encryption (SSL/TLS) and to avoid sending sensitive information (such as login credentials) in HTTP GET URL parameters. Consider using HTTP POST requests or HTTP headers for such information instead.
[b]Note:[/b] When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to [url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS]CORS[/url]. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the [code]Access-Control-Allow-Origin: *[/code] HTTP header.
[b]Note:[/b] SSL/TLS support is currently limited to TLS 1.0, TLS 1.1, and TLS 1.2. Attempting to connect to a TLS 1.3-only server will return an error.
diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml
index 00927b98c5..558e51aefe 100644
--- a/doc/classes/HTTPRequest.xml
+++ b/doc/classes/HTTPRequest.xml
@@ -7,6 +7,7 @@
A node with the ability to send HTTP requests. Uses [HTTPClient] internally.
Can be used to make HTTP requests, i.e. download or upload files or web content via HTTP.
[b]Warning:[/b] See the notes and warnings on [HTTPClient] for limitations, especially regarding SSL security.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
[b]Example of contacting a REST API and printing one of its returned fields:[/b]
[codeblocks]
[gdscript]
@@ -149,7 +150,6 @@
}
[/csharp]
[/codeblocks]
-
[b]Gzipped response bodies[/b]: HTTPRequest will automatically handle decompression of response bodies. A [code]Accept-Encoding[/code] header will be automatically added to each of your requests, unless one is already specified. Any response with a [code]Content-Encoding: gzip[/code] header will automatically be decompressed and delivered to you as uncompressed bytes.
</description>
<tutorials>
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index 834b5a41db..83e3f5b05a 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -82,6 +82,24 @@
Returns the scroll offset due to [member caret_column], as a number of characters.
</description>
</method>
+ <method name="get_selection_from_column" qualifiers="const">
+ <return type="int" />
+ <description>
+ Returns the selection begin column.
+ </description>
+ </method>
+ <method name="get_selection_to_column" qualifiers="const">
+ <return type="int" />
+ <description>
+ Returns the selection end column.
+ </description>
+ </method>
+ <method name="has_selection" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if the user has selected text.
+ </description>
+ </method>
<method name="insert_text_at_caret">
<return type="void" />
<argument index="0" name="text" type="String" />
diff --git a/doc/classes/MultiplayerAPI.xml b/doc/classes/MultiplayerAPI.xml
index 0da461dd61..e0da08f5bd 100644
--- a/doc/classes/MultiplayerAPI.xml
+++ b/doc/classes/MultiplayerAPI.xml
@@ -8,6 +8,7 @@
By default, [SceneTree] has a reference to this class that is used to provide multiplayer capabilities (i.e. RPCs) across the whole scene.
It is possible to override the MultiplayerAPI instance used by specific Nodes by setting the [member Node.custom_multiplayer] property, effectively allowing to run both client and server in the same scene.
[b]Note:[/b] The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/MultiplayerPeer.xml b/doc/classes/MultiplayerPeer.xml
index 411317cdc8..15517f7c2f 100644
--- a/doc/classes/MultiplayerPeer.xml
+++ b/doc/classes/MultiplayerPeer.xml
@@ -6,6 +6,7 @@
<description>
Manages the connection to multiplayer peers. Assigns unique IDs to each client connected to the server. See also [MultiplayerAPI].
[b]Note:[/b] The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
<link title="High-level multiplayer">https://docs.godotengine.org/en/latest/tutorials/networking/high_level_multiplayer.html</link>
@@ -52,14 +53,14 @@
</method>
</methods>
<members>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" default="true">
+ <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" default="false">
If [code]true[/code], this [MultiplayerPeer] refuses new connections.
</member>
<member name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="0">
The channel to use to send packets. Many network APIs such as ENet and WebRTC allow the creation of multiple independent channels which behaves, in a way, like separate connections. This means that reliable data will only block delivery of other packets on that channel, and ordering will only be in respect to the channel the packet is being sent on. Using different channels to send [b]different and independent[/b] state updates is a common way to optimize network usage and decrease latency in fast-paced games.
[b]Note:[/b] The default channel ([code]0[/code]) actually works as 3 separate channels (one for each [enum TransferMode]) so that [constant TRANSFER_MODE_RELIABLE] and [constant TRANSFER_MODE_ORDERED] does not interact with each other by default. Refer to the specific network API documentation (e.g. ENet or WebRTC) to learn how to set up channels correctly.
</member>
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="TransferMode" default="0">
+ <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="TransferMode" default="2">
The manner in which to send packets to the [code]target_peer[/code]. See [enum TransferMode].
</member>
</members>
diff --git a/doc/classes/MultiplayerPeerExtension.xml b/doc/classes/MultiplayerPeerExtension.xml
new file mode 100644
index 0000000000..46f9b22758
--- /dev/null
+++ b/doc/classes/MultiplayerPeerExtension.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="MultiplayerPeerExtension" inherits="MultiplayerPeer" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_available_packet_count" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_connection_status" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_size" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="const uint8_t **" />
+ <argument index="1" name="r_buffer_size" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet_peer" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_transfer_channel" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_transfer_mode" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_unique_id" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_refusing_new_connections" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_server" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_poll" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_buffer" type="const uint8_t*" />
+ <argument index="1" name="p_buffer_size" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_refuse_new_connections" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_enable" type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_target_peer" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_peer" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_transfer_channel" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_channel" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_transfer_mode" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_mode" type="int" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 608d76cd9f..b4edcf49f4 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -700,9 +700,6 @@
<member name="custom_multiplayer" type="MultiplayerAPI" setter="set_custom_multiplayer" getter="get_custom_multiplayer">
The override to the default [MultiplayerAPI]. Set to [code]null[/code] to use the default [SceneTree] one.
</member>
- <member name="filename" type="String" setter="set_filename" getter="get_filename">
- When a scene is instantiated from a file, its topmost node contains the filename from which it was loaded.
- </member>
<member name="multiplayer" type="MultiplayerAPI" setter="" getter="get_multiplayer">
The [MultiplayerAPI] instance associated with this node. Either the [member custom_multiplayer], or the default SceneTree one (if inside tree).
</member>
@@ -719,6 +716,9 @@
<member name="process_priority" type="int" setter="set_process_priority" getter="get_process_priority" default="0">
The node's priority in the execution order of the enabled processing callbacks (i.e. [constant NOTIFICATION_PROCESS], [constant NOTIFICATION_PHYSICS_PROCESS] and their internal counterparts). Nodes whose process priority value is [i]lower[/i] will have their processing callbacks executed first.
</member>
+ <member name="scene_file_path" type="String" setter="set_scene_file_path" getter="get_scene_file_path">
+ If a scene is instantiated from a file, its topmost node contains the absolute file path from which it was loaded in [member scene_file_path] (e.g. [code]res://levels/1.tscn[/code]). Otherwise, [member scene_file_path] is set to an empty string.
+ </member>
</members>
<signals>
<signal name="ready">
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index e2ac8568c9..9d0d185c42 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -49,6 +49,7 @@
[/codeblocks]
See [method execute] if you wish to run an external command and retrieve the results.
[b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
+ [b]Note:[/b] On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export.
</description>
</method>
<method name="delay_msec" qualifiers="const">
@@ -119,6 +120,7 @@
[/csharp]
[/codeblocks]
[b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
+ [b]Note:[/b] On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export.
</description>
</method>
<method name="find_keycode_from_string" qualifiers="const">
diff --git a/doc/classes/PacketPeer.xml b/doc/classes/PacketPeer.xml
index fb94209d72..7c02ccc250 100644
--- a/doc/classes/PacketPeer.xml
+++ b/doc/classes/PacketPeer.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
PacketPeer is an abstraction and base class for packet-based protocols (such as UDP). It provides an API for sending and receiving packets both as raw data or variables. This makes it easy to transfer data over a protocol, without having to encode data as low-level bytes or having to worry about network ordering.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/PacketPeerDTLS.xml b/doc/classes/PacketPeerDTLS.xml
index b05743fb5a..4d1c83afe7 100644
--- a/doc/classes/PacketPeerDTLS.xml
+++ b/doc/classes/PacketPeerDTLS.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
This class represents a DTLS peer connection. It can be used to connect to a DTLS server, and is returned by [method DTLSServer.take_connection].
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
[b]Warning:[/b] SSL/TLS certificate revocation and certificate pinning are currently not supported. Revoked certificates are accepted as long as they are otherwise valid. If this is a concern, you may want to use automatically managed certificates with a short validity period.
</description>
<tutorials>
diff --git a/doc/classes/PacketPeerExtension.xml b/doc/classes/PacketPeerExtension.xml
new file mode 100644
index 0000000000..f6b925eb30
--- /dev/null
+++ b/doc/classes/PacketPeerExtension.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="PacketPeerExtension" inherits="PacketPeer" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_available_packet_count" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_size" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="const uint8_t **" />
+ <argument index="1" name="r_buffer_size" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_buffer" type="const uint8_t*" />
+ <argument index="1" name="p_buffer_size" type="int" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/doc/classes/PacketPeerStream.xml b/doc/classes/PacketPeerStream.xml
index a92aaf037e..1c5bec297c 100644
--- a/doc/classes/PacketPeerStream.xml
+++ b/doc/classes/PacketPeerStream.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
PacketStreamPeer provides a wrapper for working using packets over a stream. This allows for using packet based code with StreamPeers. PacketPeerStream implements a custom protocol over the StreamPeer, so the user should not read or write to the wrapped StreamPeer directly.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml
index ecaddc5b9f..9b77859b50 100644
--- a/doc/classes/PacketPeerUDP.xml
+++ b/doc/classes/PacketPeerUDP.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
UDP packet peer. Can be used to send raw UDP packets as well as [Variant]s.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/PhysicsBody2D.xml b/doc/classes/PhysicsBody2D.xml
index ee28500838..e108ab6298 100644
--- a/doc/classes/PhysicsBody2D.xml
+++ b/doc/classes/PhysicsBody2D.xml
@@ -25,11 +25,12 @@
</method>
<method name="move_and_collide">
<return type="KinematicCollision2D" />
- <argument index="0" name="rel_vec" type="Vector2" />
+ <argument index="0" name="linear_velocity" type="Vector2" />
<argument index="1" name="test_only" type="bool" default="false" />
<argument index="2" name="safe_margin" type="float" default="0.08" />
<description>
- Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision2D], which contains information about the collision.
+ Moves the body along the vector [code]linear_velocity[/code]. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
+ The body will stop if it collides. Returns a [KinematicCollision2D], which contains information about the collision.
If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given.
[code]safe_margin[/code] is the extra margin used for collision recovery (see [member CharacterBody2D.collision/safe_margin] for more details).
</description>
@@ -44,11 +45,12 @@
<method name="test_move">
<return type="bool" />
<argument index="0" name="from" type="Transform2D" />
- <argument index="1" name="rel_vec" type="Vector2" />
+ <argument index="1" name="linear_velocity" type="Vector2" />
<argument index="2" name="collision" type="KinematicCollision2D" default="null" />
<argument index="3" name="safe_margin" type="float" default="0.08" />
<description>
- Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [code]rel_vec[/code]. Returns [code]true[/code] if a collision would occur.
+ Checks for collisions without moving the body. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
+ Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [code]linear_velocity[/code]. Returns [code]true[/code] if a collision would occur.
[code]collision[/code] is an optional object of type [KinematicCollision2D], which contains additional information about the collision (should there be one).
[code]safe_margin[/code] is the extra margin used for collision recovery (see [member CharacterBody2D.collision/safe_margin] for more details).
</description>
diff --git a/doc/classes/PhysicsBody3D.xml b/doc/classes/PhysicsBody3D.xml
index 174e49ea2d..8718c0caa2 100644
--- a/doc/classes/PhysicsBody3D.xml
+++ b/doc/classes/PhysicsBody3D.xml
@@ -32,12 +32,13 @@
</method>
<method name="move_and_collide">
<return type="KinematicCollision3D" />
- <argument index="0" name="rel_vec" type="Vector3" />
+ <argument index="0" name="linear_velocity" type="Vector3" />
<argument index="1" name="test_only" type="bool" default="false" />
<argument index="2" name="safe_margin" type="float" default="0.001" />
<argument index="3" name="max_collisions" type="int" default="1" />
<description>
- Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision3D], which contains information about the collision.
+ Moves the body along the vector [code]linear_velocity[/code]. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
+ The body will stop if it collides. Returns a [KinematicCollision3D], which contains information about the collision.
If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given.
[code]safe_margin[/code] is the extra margin used for collision recovery (see [member CharacterBody3D.collision/safe_margin] for more details).
[code]max_collisions[/code] allows to retrieve more than one collision result.
@@ -61,12 +62,13 @@
<method name="test_move">
<return type="bool" />
<argument index="0" name="from" type="Transform3D" />
- <argument index="1" name="rel_vec" type="Vector3" />
+ <argument index="1" name="linear_velocity" type="Vector3" />
<argument index="2" name="collision" type="KinematicCollision3D" default="null" />
<argument index="3" name="safe_margin" type="float" default="0.001" />
<argument index="4" name="max_collisions" type="int" default="1" />
<description>
- Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given [Transform3D], then tries to move the body along the vector [code]rel_vec[/code]. Returns [code]true[/code] if a collision would occur.
+ Checks for collisions without moving the body. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
+ Virtually sets the node's position, scale and rotation to that of the given [Transform3D], then tries to move the body along the vector [code]linear_velocity[/code]. Returns [code]true[/code] if a collision would occur.
[code]collision[/code] is an optional object of type [KinematicCollision3D], which contains additional information about the collision (should there be one).
[code]safe_margin[/code] is the extra margin used for collision recovery (see [member CharacterBody3D.collision/safe_margin] for more details).
[code]max_collisions[/code] allows to retrieve more than one collision result.
diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml
index 7e5d7ca704..791a04e4c2 100644
--- a/doc/classes/PhysicsServer2D.xml
+++ b/doc/classes/PhysicsServer2D.xml
@@ -851,8 +851,6 @@
<constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="6" enum="SpaceParameter">
Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
</constant>
- <constant name="SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH" value="7" enum="SpaceParameter">
- </constant>
<constant name="SHAPE_WORLD_BOUNDARY" value="0" enum="ShapeType">
This is the constant for creating world boundary shapes. A world boundary shape is an [i]infinite[/i] line with an origin point, and a normal. Thus, it can be used for front/behind checks.
</constant>
@@ -928,8 +926,8 @@
<constant name="BODY_MODE_DYNAMIC" value="2" enum="BodyMode">
Constant for dynamic bodies. In this mode, a body can be pushed by other bodies and has forces applied.
</constant>
- <constant name="BODY_MODE_DYNAMIC_LOCKED" value="3" enum="BodyMode">
- Constant for locked dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces.
+ <constant name="BODY_MODE_DYNAMIC_LINEAR" value="3" enum="BodyMode">
+ Constant for linear dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces.
</constant>
<constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
Constant to set/get a body's bounce factor.
diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml
index 9f48c36b62..1d1ca54dbb 100644
--- a/doc/classes/PhysicsServer3D.xml
+++ b/doc/classes/PhysicsServer3D.xml
@@ -1278,8 +1278,8 @@
<constant name="BODY_MODE_DYNAMIC" value="2" enum="BodyMode">
Constant for dynamic bodies. In this mode, a body can be pushed by other bodies and has forces applied.
</constant>
- <constant name="BODY_MODE_DYNAMIC_LOCKED" value="3" enum="BodyMode">
- Constant for locked dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces.
+ <constant name="BODY_MODE_DYNAMIC_LINEAR" value="3" enum="BodyMode">
+ Constant for linear dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces.
</constant>
<constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
Constant to set/get a body's bounce factor.
@@ -1361,8 +1361,6 @@
<constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="7" enum="SpaceParameter">
Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
</constant>
- <constant name="SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH" value="8" enum="SpaceParameter">
- </constant>
<constant name="BODY_AXIS_LINEAR_X" value="1" enum="BodyAxis">
</constant>
<constant name="BODY_AXIS_LINEAR_Y" value="2" enum="BodyAxis">
diff --git a/doc/classes/RigidDynamicBody2D.xml b/doc/classes/RigidDynamicBody2D.xml
index 059379242b..9baed392eb 100644
--- a/doc/classes/RigidDynamicBody2D.xml
+++ b/doc/classes/RigidDynamicBody2D.xml
@@ -5,11 +5,10 @@
</brief_description>
<description>
This node implements simulated 2D physics. You do not control a RigidDynamicBody2D directly. Instead, you apply forces to it (gravity, impulses, etc.) and the physics simulation calculates the resulting movement based on its mass, friction, and other physical properties.
- A RigidDynamicBody2D has 4 behavior [member mode]s: Dynamic, Static, DynamicLocked, and Kinematic.
+ You can switch the body's behavior using [member lock_rotation], [member freeze], and [member freeze_mode].
[b]Note:[/b] You should not change a RigidDynamicBody2D's [code]position[/code] or [code]linear_velocity[/code] every frame or even very often. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state.
Please also keep in mind that physics bodies manage their own transform which overwrites the ones you set. So any direct or indirect transformation (including scaling of the node or its parent) will be visible in the editor only, and immediately reset at runtime.
If you need to override the default physics behavior or add a transformation at runtime, you can write a custom force integration. See [member custom_integrator].
- The center of mass is always located at the node's origin without taking into account the [CollisionShape2D] centroid offsets.
</description>
<tutorials>
<link title="2D Physics Platformer Demo">https://godotengine.org/asset-library/asset/119</link>
@@ -120,6 +119,15 @@
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration is disabled for this body. Aside from collision response, the body will only move as determined by the [method _integrate_forces] function.
</member>
+ <member name="freeze" type="bool" setter="set_freeze_enabled" getter="is_freeze_enabled" default="false">
+ If [code]true[/code], the body is frozen. Gravity and forces are not applied anymore.
+ See [member freeze_mode] to set the body's behavior when frozen.
+ For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead.
+ </member>
+ <member name="freeze_mode" type="int" setter="set_freeze_mode" getter="get_freeze_mode" enum="RigidDynamicBody2D.FreezeMode" default="0">
+ The body's freeze mode. Can be used to set the body's behavior when [member freeze] is enabled. See [enum FreezeMode] for possible values.
+ For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead.
+ </member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
Multiplies the gravity applied to the body. The body's gravity is calculated from the [b]Default Gravity[/b] value in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] and/or any additional gravity vector applied by [Area2D]s.
</member>
@@ -134,13 +142,12 @@
<member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)">
The body's linear velocity.
</member>
+ <member name="lock_rotation" type="bool" setter="set_lock_rotation_enabled" getter="is_lock_rotation_enabled" default="false">
+ If [code]true[/code], the body cannot rotate. Gravity and forces only apply linear movement.
+ </member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0">
The body's mass.
</member>
- <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidDynamicBody2D.Mode" default="0">
- The body's mode. See [enum Mode] for possible values.
- For a body that uses only Static or Kinematic mode, use [StaticBody2D] or [AnimatableBody2D] instead.
- </member>
<member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override">
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
@@ -198,17 +205,11 @@
</signal>
</signals>
<constants>
- <constant name="MODE_DYNAMIC" value="0" enum="Mode">
- Dynamic body mode. This is the default mode of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code.
- </constant>
- <constant name="MODE_STATIC" value="1" enum="Mode">
- Static body mode. The body behaves like a [StaticBody2D], and must be moved by code.
- </constant>
- <constant name="MODE_DYNAMIC_LOCKED" value="2" enum="Mode">
- Locked dynamic body mode. Similar to [constant MODE_DYNAMIC], but the body can not rotate.
+ <constant name="FREEZE_MODE_STATIC" value="0" enum="FreezeMode">
+ Static body freeze mode (default). The body is not affected by gravity and forces. It can be only moved by user code and doesn't collide with other bodies along its path.
</constant>
- <constant name="MODE_KINEMATIC" value="3" enum="Mode">
- Kinematic body mode. The body behaves like a [AnimatableBody2D], and must be moved by code.
+ <constant name="FREEZE_MODE_KINEMATIC" value="1" enum="FreezeMode">
+ Kinematic body freeze mode. Similar to [constant FREEZE_MODE_STATIC], but collides with other bodies along its path when moved. Useful for a frozen body that needs to be animated.
</constant>
<constant name="CENTER_OF_MASS_MODE_AUTO" value="0" enum="CenterOfMassMode">
In this mode, the body's center of mass is calculated automatically based on its shapes.
diff --git a/doc/classes/RigidDynamicBody3D.xml b/doc/classes/RigidDynamicBody3D.xml
index 9b6bcd840b..7d1c7fecfa 100644
--- a/doc/classes/RigidDynamicBody3D.xml
+++ b/doc/classes/RigidDynamicBody3D.xml
@@ -5,10 +5,9 @@
</brief_description>
<description>
This is the node that implements full 3D physics. This means that you do not control a RigidDynamicBody3D directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
- A RigidDynamicBody3D has 4 behavior [member mode]s: Dynamic, Static, DynamicLocked, and Kinematic.
+ You can switch the body's behavior using [member lock_rotation], [member freeze], and [member freeze_mode].
[b]Note:[/b] Don't change a RigidDynamicBody3D's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state.
If you need to override the default physics behavior, you can write a custom force integration function. See [member custom_integrator].
- With Bullet physics (the default), the center of mass is the RigidDynamicBody3D center. With GodotPhysics, the center of mass is the average of the [CollisionShape3D] centers.
</description>
<tutorials>
<link title="Physics introduction">https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html</link>
@@ -123,6 +122,15 @@
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
</member>
+ <member name="freeze" type="bool" setter="set_freeze_enabled" getter="is_freeze_enabled" default="false">
+ If [code]true[/code], the body is frozen. Gravity and forces are not applied anymore.
+ See [member freeze_mode] to set the body's behavior when frozen.
+ For a body that is always frozen, use [StaticBody3D] or [AnimatableBody3D] instead.
+ </member>
+ <member name="freeze_mode" type="int" setter="set_freeze_mode" getter="get_freeze_mode" enum="RigidDynamicBody3D.FreezeMode" default="0">
+ The body's freeze mode. Can be used to set the body's behavior when [member freeze] is enabled. See [enum FreezeMode] for possible values.
+ For a body that is always frozen, use [StaticBody3D] or [AnimatableBody3D] instead.
+ </member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
This is multiplied by the global 3D gravity setting found in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] to produce RigidDynamicBody3D's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member>
@@ -137,13 +145,12 @@
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)">
The body's linear velocity. Can be used sporadically, but [b]don't set this every frame[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member>
+ <member name="lock_rotation" type="bool" setter="set_lock_rotation_enabled" getter="is_lock_rotation_enabled" default="false">
+ If [code]true[/code], the body cannot rotate. Gravity and forces only apply linear movement.
+ </member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0">
The body's mass.
</member>
- <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidDynamicBody3D.Mode" default="0">
- The body's mode. See [enum Mode] for possible values.
- For a body that uses only Static or Kinematic mode, use [StaticBody3D] or [AnimatableBody3D] instead.
- </member>
<member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override">
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
@@ -203,17 +210,11 @@
</signal>
</signals>
<constants>
- <constant name="MODE_DYNAMIC" value="0" enum="Mode">
- Dynamic body mode. This is the default mode of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code.
- </constant>
- <constant name="MODE_STATIC" value="1" enum="Mode">
- Static body mode. The body behaves like a [StaticBody3D], and can only move by user code.
- </constant>
- <constant name="MODE_DYNAMIC_LOCKED" value="2" enum="Mode">
- Locked dynamic body mode. Similar to [constant MODE_DYNAMIC], but the body can not rotate.
+ <constant name="FREEZE_MODE_STATIC" value="0" enum="FreezeMode">
+ Static body freeze mode (default). The body is not affected by gravity and forces. It can be only moved by user code and doesn't collide with other bodies along its path.
</constant>
- <constant name="MODE_KINEMATIC" value="3" enum="Mode">
- Kinematic body mode. The body behaves like a [AnimatableBody3D], and can only move by user code.
+ <constant name="FREEZE_MODE_KINEMATIC" value="1" enum="FreezeMode">
+ Kinematic body freeze mode. Similar to [constant FREEZE_MODE_STATIC], but collides with other bodies along its path when moved. Useful for a frozen body that needs to be animated.
</constant>
<constant name="CENTER_OF_MASS_MODE_AUTO" value="0" enum="CenterOfMassMode">
In this mode, the body's center of mass is calculated automatically based on its shapes.
diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml
index b70725123b..f78266a20c 100644
--- a/doc/classes/Signal.xml
+++ b/doc/classes/Signal.xml
@@ -32,10 +32,16 @@
<method name="connect">
<return type="int" />
<argument index="0" name="callable" type="Callable" />
- <argument index="1" name="binds" type="Array" default="[]" />
- <argument index="2" name="flags" type="int" default="0" />
- <description>
- Connects this signal to the specified [Callable], optionally providing binds and connection flags.
+ <argument index="1" name="flags" type="int" default="0" />
+ <description>
+ Connects this signal to the specified [Callable], optionally providing connection flags. You can provide additional arguments to the connected method call by using [method Callable.bind].
+ [codeblock]
+ for button in $Buttons.get_children():
+ button.pressed.connect(on_pressed.bind(button))
+
+ func on_pressed(button):
+ print(button.name, " was pressed")
+ [/codeblock]
</description>
</method>
<method name="disconnect">
diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml
index 316bd77a16..0622626846 100644
--- a/doc/classes/StreamPeer.xml
+++ b/doc/classes/StreamPeer.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
StreamPeer is an abstraction and base class for stream-based protocols (such as TCP). It provides an API for sending and receiving data through streams as raw data or strings.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/StreamPeerExtension.xml b/doc/classes/StreamPeerExtension.xml
new file mode 100644
index 0000000000..ceb9486a33
--- /dev/null
+++ b/doc/classes/StreamPeerExtension.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="StreamPeerExtension" inherits="StreamPeer" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_available_bytes" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="uint8_t*" />
+ <argument index="1" name="r_bytes" type="int" />
+ <argument index="2" name="r_received" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_partial_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="uint8_t*" />
+ <argument index="1" name="r_bytes" type="int" />
+ <argument index="2" name="r_received" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_data" type="const uint8_t*" />
+ <argument index="1" name="p_bytes" type="int" />
+ <argument index="2" name="r_sent" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_partial_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_data" type="const uint8_t*" />
+ <argument index="1" name="p_bytes" type="int" />
+ <argument index="2" name="r_sent" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/doc/classes/StreamPeerSSL.xml b/doc/classes/StreamPeerSSL.xml
index 034168c2a0..50389f912d 100644
--- a/doc/classes/StreamPeerSSL.xml
+++ b/doc/classes/StreamPeerSSL.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
SSL stream peer. This object can be used to connect to an SSL server or accept a single SSL client connection.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
<link title="SSL certificates">https://docs.godotengine.org/en/latest/tutorials/networking/ssl_certificates.html</link>
diff --git a/doc/classes/StreamPeerTCP.xml b/doc/classes/StreamPeerTCP.xml
index bba48e7275..6b700593a2 100644
--- a/doc/classes/StreamPeerTCP.xml
+++ b/doc/classes/StreamPeerTCP.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
TCP stream peer. This object can be used to connect to TCP servers, or also is returned by a TCP server.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/TCPServer.xml b/doc/classes/TCPServer.xml
index 8676e33bb4..4fbaf9412f 100644
--- a/doc/classes/TCPServer.xml
+++ b/doc/classes/TCPServer.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
A TCP server. Listens to connections on a port and returns a [StreamPeerTCP] when it gets an incoming connection.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml
index 77bd7b1a0a..4c50aa4e1f 100644
--- a/doc/classes/TabContainer.xml
+++ b/doc/classes/TabContainer.xml
@@ -6,8 +6,6 @@
<description>
Sets the active tab's [code]visible[/code] property to the value [code]true[/code]. Sets all other children's to [code]false[/code].
Ignores non-[Control] children.
- Individual tabs are always visible unless you use [method set_tab_disabled] and [method set_tab_title] to hide it.
- To hide only a tab's content, nest the content inside a child [Control], so it receives the [TabContainer]'s visibility setting instead.
</description>
<tutorials>
</tutorials>
@@ -50,6 +48,13 @@
Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is disabled.
</description>
</method>
+ <method name="get_tab_hidden" qualifiers="const">
+ <return type="bool" />
+ <argument index="0" name="tab_idx" type="int" />
+ <description>
+ Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is hidden.
+ </description>
+ </method>
<method name="get_tab_icon" qualifiers="const">
<return type="Texture2D" />
<argument index="0" name="tab_idx" type="int" />
@@ -89,8 +94,15 @@
<argument index="0" name="tab_idx" type="int" />
<argument index="1" name="disabled" type="bool" />
<description>
- If [code]disabled[/code] is [code]false[/code], hides the tab at index [code]tab_idx[/code].
- [b]Note:[/b] Its title text will remain, unless also removed with [method set_tab_title].
+ If [code]disabled[/code] is [code]true[/code], disables the tab at index [code]tab_idx[/code], making it non-interactable.
+ </description>
+ </method>
+ <method name="set_tab_hidden">
+ <return type="void" />
+ <argument index="0" name="tab_idx" type="int" />
+ <argument index="1" name="hidden" type="bool" />
+ <description>
+ If [code]hidden[/code] is [code]true[/code], hides the tab at index [code]tab_idx[/code], making it disappear from the tab area.
</description>
</method>
<method name="set_tab_icon">
@@ -106,14 +118,14 @@
<argument index="0" name="tab_idx" type="int" />
<argument index="1" name="title" type="String" />
<description>
- Sets a title for the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title].
+ Sets a title for the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node.
</description>
</method>
<method name="set_tabs_rearrange_group">
<return type="void" />
<argument index="0" name="group_id" type="int" />
<description>
- Defines rearrange group id, choose for each [TabContainer] the same value to enable tab drag between [TabContainer]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code].
+ Defines rearrange group id, choose for each [TabContainer] the same value to enable tab drag between [TabContainer]. Enable drag with [member drag_to_rearrange_enabled].
</description>
</method>
</methods>
diff --git a/doc/classes/Tabs.xml b/doc/classes/Tabs.xml
index f4c89a8b16..3ee3feb365 100644
--- a/doc/classes/Tabs.xml
+++ b/doc/classes/Tabs.xml
@@ -108,7 +108,7 @@
<return type="String" />
<argument index="0" name="tab_idx" type="int" />
<description>
- Returns the title of the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title].
+ Returns the title of the tab at index [code]tab_idx[/code].
</description>
</method>
<method name="get_tabs_rearrange_group" qualifiers="const">
@@ -144,8 +144,7 @@
<argument index="0" name="tab_idx" type="int" />
<argument index="1" name="disabled" type="bool" />
<description>
- If [code]disabled[/code] is [code]false[/code], hides the tab at index [code]tab_idx[/code].
- [b]Note:[/b] Its title text will remain unless it is also removed with [method set_tab_title].
+ If [code]disabled[/code] is [code]true[/code], disables the tab at index [code]tab_idx[/code], making it non-interactable.
</description>
</method>
<method name="set_tab_icon">
@@ -193,7 +192,7 @@
<return type="void" />
<argument index="0" name="group_id" type="int" />
<description>
- Defines the rearrange group ID. Choose for each [Tabs] the same value to dragging tabs between [Tabs]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code].
+ Defines the rearrange group ID. Choose for each [Tabs] the same value to dragging tabs between [Tabs]. Enable drag with [member drag_to_rearrange_enabled].
</description>
</method>
</methods>
diff --git a/doc/classes/Thread.xml b/doc/classes/Thread.xml
index 9c9119c664..ae5c0761b1 100644
--- a/doc/classes/Thread.xml
+++ b/doc/classes/Thread.xml
@@ -27,12 +27,11 @@
</method>
<method name="start">
<return type="int" enum="Error" />
- <argument index="0" name="instance" type="Object" />
- <argument index="1" name="method" type="StringName" />
- <argument index="2" name="userdata" type="Variant" default="null" />
- <argument index="3" name="priority" type="int" enum="Thread.Priority" default="1" />
+ <argument index="0" name="callable" type="Callable" />
+ <argument index="1" name="userdata" type="Variant" default="null" />
+ <argument index="2" name="priority" type="int" enum="Thread.Priority" default="1" />
<description>
- Starts a new [Thread] that runs [code]method[/code] on object [code]instance[/code] with [code]userdata[/code] passed as an argument. Even if no userdata is passed, [code]method[/code] must accept one argument and it will be null. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum.
+ Starts a new [Thread] that calls [code]callable[/code] with [code]userdata[/code] passed as an argument. Even if no userdata is passed, [code]method[/code] must accept one argument and it will be null. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum.
Returns [constant OK] on success, or [constant ERR_CANT_CREATE] on failure.
</description>
</method>
diff --git a/doc/classes/TileData.xml b/doc/classes/TileData.xml
index 0d3282c6d3..81c5743ccc 100644
--- a/doc/classes/TileData.xml
+++ b/doc/classes/TileData.xml
@@ -37,6 +37,20 @@
Returns how many polygons the tile has for TileSet physics layer with index [code]layer_id[/code].
</description>
</method>
+ <method name="get_constant_angular_velocity" qualifiers="const">
+ <return type="float" />
+ <argument index="0" name="layer_id" type="int" />
+ <description>
+ Returns the constant angular velocity applied to objects colliding with this tile.
+ </description>
+ </method>
+ <method name="get_constant_linear_velocity" qualifiers="const">
+ <return type="Vector2" />
+ <argument index="0" name="layer_id" type="int" />
+ <description>
+ Returns the constant linear velocity applied to objects colliding with this tile.
+ </description>
+ </method>
<method name="get_custom_data" qualifiers="const">
<return type="Variant" />
<argument index="0" name="layer_name" type="String" />
@@ -123,6 +137,22 @@
Sets the polygons count for TileSet physics layer with index [code]layer_id[/code].
</description>
</method>
+ <method name="set_constant_angular_velocity">
+ <return type="void" />
+ <argument index="0" name="layer_id" type="int" />
+ <argument index="1" name="velocity" type="float" />
+ <description>
+ Sets the constant angular velocity. This does not rotate the tile. This angular velocity is applied to objects colliding with this tile.
+ </description>
+ </method>
+ <method name="set_constant_linear_velocity">
+ <return type="void" />
+ <argument index="0" name="layer_id" type="int" />
+ <argument index="1" name="velocity" type="Vector2" />
+ <description>
+ Sets the constant linear velocity. This does not move the tile. This linear velocity is applied to objects colliding with this tile. This is useful to create conveyor belts.
+ </description>
+ </method>
<method name="set_custom_data">
<return type="void" />
<argument index="0" name="layer_name" type="String" />
diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml
index 4621d138ac..e5fe823be6 100644
--- a/doc/classes/TileMap.xml
+++ b/doc/classes/TileMap.xml
@@ -29,6 +29,13 @@
Clears all cells.
</description>
</method>
+ <method name="clear_layer">
+ <return type="void" />
+ <argument index="0" name="layer" type="int" />
+ <description>
+ Clears all cells on the given layer.
+ </description>
+ </method>
<method name="fix_invalid_tiles">
<return type="void" />
<description>
@@ -62,6 +69,13 @@
Returns the tile source ID of the cell on layer [code]layer[/code] at coordinates [code]coords[/code]. If [code]use_proxies[/code] is [code]false[/code], ignores the [TileSet]'s tile proxies, returning the raw alternative identifier. See [method TileSet.map_tile_proxy].
</description>
</method>
+ <method name="get_coords_for_body_rid">
+ <return type="Vector2i" />
+ <argument index="0" name="body" type="RID" />
+ <description>
+ Returns the coodinates of the tile for given physics body RID. Such RID can be retrieved from [member KinematicCollision2D.collider_rid], when colliding with a tile.
+ </description>
+ </method>
<method name="get_layer_name" qualifiers="const">
<return type="String" />
<argument index="0" name="layer" type="int" />
@@ -220,6 +234,10 @@
<member name="cell_quadrant_size" type="int" setter="set_quadrant_size" getter="get_quadrant_size" default="16">
The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
</member>
+ <member name="collision_animatable" type="bool" setter="set_collision_animatable" getter="is_collision_animatable" default="false">
+ If enabled, the TileMap will see its collisions synced to the physics tick and change its collision type from static to kinematic. This is required to create TileMap-based moving platform.
+ [b]Note:[/b] Enabling [code]collision_animatable[/code] may have a small performance impact, only do it if the TileMap is moving and has colliding tiles.
+ </member>
<member name="collision_visibility_mode" type="int" setter="set_collision_visibility_mode" getter="get_collision_visibility_mode" enum="TileMap.VisibilityMode" default="0">
Show or hide the TileMap's collision shapes. If set to [code]VISIBILITY_MODE_DEFAULT[/code], this depends on the show collision debug settings.
</member>
diff --git a/doc/classes/Translation.xml b/doc/classes/Translation.xml
index c27d6f5667..2a0695d42e 100644
--- a/doc/classes/Translation.xml
+++ b/doc/classes/Translation.xml
@@ -11,6 +11,24 @@
<link title="Locales">https://docs.godotengine.org/en/latest/tutorials/i18n/locales.html</link>
</tutorials>
<methods>
+ <method name="_get_message" qualifiers="virtual const">
+ <return type="StringName" />
+ <argument index="0" name="src_message" type="StringName" />
+ <argument index="1" name="context" type="StringName" />
+ <description>
+ Virtual method to override [method get_message].
+ </description>
+ </method>
+ <method name="_get_plural_message" qualifiers="virtual const">
+ <return type="StringName" />
+ <argument index="0" name="src_message" type="StringName" />
+ <argument index="1" name="src_plural_message" type="StringName" />
+ <argument index="2" name="n" type="int" />
+ <argument index="3" name="context" type="StringName" />
+ <description>
+ Virtual method to override [method get_plural_message].
+ </description>
+ </method>
<method name="add_message">
<return type="void" />
<argument index="0" name="src_message" type="StringName" />
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml
index ede6e2fdd5..f94018c96b 100644
--- a/doc/classes/Tween.xml
+++ b/doc/classes/Tween.xml
@@ -86,6 +86,7 @@
[code]initial_value[/code] is the starting value of the interpolation.
[code]delta_value[/code] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code].
[code]duration[/code] is the total time of the interpolation.
+ [b]Note:[/b] If [code]duration[/code] is equal to [code]0[/code], the method will always return the final value, regardless of [code]elapsed_time[/code] provided.
</description>
</method>
<method name="is_running">
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index f8fc949220..086d3b4284 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -47,7 +47,7 @@
RenderingDeviceVulkan::Buffer *RenderingDeviceVulkan::_get_buffer_from_owner(RID p_buffer, VkPipelineStageFlags &r_stage_mask, VkAccessFlags &r_access_mask, uint32_t p_post_barrier) {
Buffer *buffer = nullptr;
if (vertex_buffer_owner.owns(p_buffer)) {
- buffer = vertex_buffer_owner.getornull(p_buffer);
+ buffer = vertex_buffer_owner.get_or_null(p_buffer);
r_stage_mask |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
r_access_mask |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
@@ -64,7 +64,7 @@ RenderingDeviceVulkan::Buffer *RenderingDeviceVulkan::_get_buffer_from_owner(RID
} else if (index_buffer_owner.owns(p_buffer)) {
r_stage_mask |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
r_access_mask |= VK_ACCESS_INDEX_READ_BIT;
- buffer = index_buffer_owner.getornull(p_buffer);
+ buffer = index_buffer_owner.get_or_null(p_buffer);
} else if (uniform_buffer_owner.owns(p_buffer)) {
if (p_post_barrier & BARRIER_MASK_RASTER) {
r_stage_mask |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
@@ -73,7 +73,7 @@ RenderingDeviceVulkan::Buffer *RenderingDeviceVulkan::_get_buffer_from_owner(RID
r_stage_mask |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
}
r_access_mask |= VK_ACCESS_UNIFORM_READ_BIT;
- buffer = uniform_buffer_owner.getornull(p_buffer);
+ buffer = uniform_buffer_owner.get_or_null(p_buffer);
} else if (texture_buffer_owner.owns(p_buffer)) {
if (p_post_barrier & BARRIER_MASK_RASTER) {
r_stage_mask |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
@@ -84,9 +84,9 @@ RenderingDeviceVulkan::Buffer *RenderingDeviceVulkan::_get_buffer_from_owner(RID
r_access_mask |= VK_ACCESS_SHADER_READ_BIT;
}
- buffer = &texture_buffer_owner.getornull(p_buffer)->buffer;
+ buffer = &texture_buffer_owner.get_or_null(p_buffer)->buffer;
} else if (storage_buffer_owner.owns(p_buffer)) {
- buffer = storage_buffer_owner.getornull(p_buffer);
+ buffer = storage_buffer_owner.get_or_null(p_buffer);
if (p_post_barrier & BARRIER_MASK_RASTER) {
r_stage_mask |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
r_access_mask |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
@@ -2048,12 +2048,12 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID p_with_texture) {
_THREAD_SAFE_METHOD_
- Texture *src_texture = texture_owner.getornull(p_with_texture);
+ Texture *src_texture = texture_owner.get_or_null(p_with_texture);
ERR_FAIL_COND_V(!src_texture, RID());
if (src_texture->owner.is_valid()) { //ahh this is a share
p_with_texture = src_texture->owner;
- src_texture = texture_owner.getornull(src_texture->owner);
+ src_texture = texture_owner.get_or_null(src_texture->owner);
ERR_FAIL_COND_V(!src_texture, RID()); //this is a bug
}
@@ -2173,12 +2173,12 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID
RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type) {
_THREAD_SAFE_METHOD_
- Texture *src_texture = texture_owner.getornull(p_with_texture);
+ Texture *src_texture = texture_owner.get_or_null(p_with_texture);
ERR_FAIL_COND_V(!src_texture, RID());
if (src_texture->owner.is_valid()) { //ahh this is a share
p_with_texture = src_texture->owner;
- src_texture = texture_owner.getornull(src_texture->owner);
+ src_texture = texture_owner.get_or_null(src_texture->owner);
ERR_FAIL_COND_V(!src_texture, RID()); //this is a bug
}
@@ -2299,12 +2299,12 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co
ERR_FAIL_COND_V_MSG((draw_list || compute_list) && !p_use_setup_queue, ERR_INVALID_PARAMETER,
"Updating textures is forbidden during creation of a draw or compute list");
- Texture *texture = texture_owner.getornull(p_texture);
+ Texture *texture = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!texture, ERR_INVALID_PARAMETER);
if (texture->owner != RID()) {
p_texture = texture->owner;
- texture = texture_owner.getornull(texture->owner);
+ texture = texture_owner.get_or_null(texture->owner);
ERR_FAIL_COND_V(!texture, ERR_BUG); //this is a bug
}
@@ -2601,7 +2601,7 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex
Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) {
_THREAD_SAFE_METHOD_
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Vector<uint8_t>());
ERR_FAIL_COND_V_MSG(tex->bound, Vector<uint8_t>(),
@@ -2731,7 +2731,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
bool RenderingDeviceVulkan::texture_is_shared(RID p_texture) {
_THREAD_SAFE_METHOD_
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, false);
return tex->owner.is_valid();
}
@@ -2743,7 +2743,7 @@ bool RenderingDeviceVulkan::texture_is_valid(RID p_texture) {
Size2i RenderingDeviceVulkan::texture_size(RID p_texture) {
_THREAD_SAFE_METHOD_
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Size2i());
return Size2i(tex->width, tex->height);
}
@@ -2751,7 +2751,7 @@ Size2i RenderingDeviceVulkan::texture_size(RID p_texture) {
Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, uint32_t p_post_barrier) {
_THREAD_SAFE_METHOD_
- Texture *src_tex = texture_owner.getornull(p_from_texture);
+ Texture *src_tex = texture_owner.get_or_null(p_from_texture);
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(src_tex->bound, ERR_INVALID_PARAMETER,
@@ -2772,7 +2772,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
ERR_FAIL_COND_V(p_src_mipmap >= src_tex->mipmaps, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_src_layer >= src_layer_count, ERR_INVALID_PARAMETER);
- Texture *dst_tex = texture_owner.getornull(p_to_texture);
+ Texture *dst_tex = texture_owner.get_or_null(p_to_texture);
ERR_FAIL_COND_V(!dst_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(dst_tex->bound, ERR_INVALID_PARAMETER,
@@ -2939,7 +2939,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID p_to_texture, uint32_t p_post_barrier) {
_THREAD_SAFE_METHOD_
- Texture *src_tex = texture_owner.getornull(p_from_texture);
+ Texture *src_tex = texture_owner.get_or_null(p_from_texture);
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(src_tex->bound, ERR_INVALID_PARAMETER,
@@ -2950,7 +2950,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
ERR_FAIL_COND_V_MSG(src_tex->type != TEXTURE_TYPE_2D, ERR_INVALID_PARAMETER, "Source texture must be 2D (or a slice of a 3D/Cube texture)");
ERR_FAIL_COND_V_MSG(src_tex->samples == TEXTURE_SAMPLES_1, ERR_INVALID_PARAMETER, "Source texture must be multisampled.");
- Texture *dst_tex = texture_owner.getornull(p_to_texture);
+ Texture *dst_tex = texture_owner.get_or_null(p_to_texture);
ERR_FAIL_COND_V(!dst_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(dst_tex->bound, ERR_INVALID_PARAMETER,
@@ -3110,7 +3110,7 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, uint32_t p_post_barrier) {
_THREAD_SAFE_METHOD_
- Texture *src_tex = texture_owner.getornull(p_texture);
+ Texture *src_tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(src_tex->bound, ERR_INVALID_PARAMETER,
@@ -3880,7 +3880,7 @@ RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attac
FramebufferPass pass;
for (int i = 0; i < p_texture_attachments.size(); i++) {
- Texture *texture = texture_owner.getornull(p_texture_attachments[i]);
+ Texture *texture = texture_owner.get_or_null(p_texture_attachments[i]);
ERR_FAIL_COND_V_MSG(!texture, RID(), "Texture index supplied for framebuffer (" + itos(i) + ") is not a valid texture.");
ERR_FAIL_COND_V_MSG(texture->layers != p_view_count, RID(), "Layers of our texture doesn't match view count for this framebuffer");
@@ -3905,7 +3905,7 @@ RID RenderingDeviceVulkan::framebuffer_create_multipass(const Vector<RID> &p_tex
Size2i size;
for (int i = 0; i < p_texture_attachments.size(); i++) {
- Texture *texture = texture_owner.getornull(p_texture_attachments[i]);
+ Texture *texture = texture_owner.get_or_null(p_texture_attachments[i]);
ERR_FAIL_COND_V_MSG(!texture, RID(), "Texture index supplied for framebuffer (" + itos(i) + ") is not a valid texture.");
ERR_FAIL_COND_V_MSG(texture->layers != p_view_count, RID(), "Layers of our texture doesn't match view count for this framebuffer");
@@ -3951,7 +3951,7 @@ RID RenderingDeviceVulkan::framebuffer_create_multipass(const Vector<RID> &p_tex
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_get_format(RID p_framebuffer) {
_THREAD_SAFE_METHOD_
- Framebuffer *framebuffer = framebuffer_owner.getornull(p_framebuffer);
+ Framebuffer *framebuffer = framebuffer_owner.get_or_null(p_framebuffer);
ERR_FAIL_COND_V(!framebuffer, INVALID_ID);
return framebuffer->format_id;
@@ -4101,7 +4101,7 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo
vertex_array.description = p_vertex_format;
vertex_array.max_instances_allowed = 0xFFFFFFFF; //by default as many as you want
for (int i = 0; i < p_src_buffers.size(); i++) {
- Buffer *buffer = vertex_buffer_owner.getornull(p_src_buffers[i]);
+ Buffer *buffer = vertex_buffer_owner.get_or_null(p_src_buffers[i]);
//validate with buffer
{
@@ -4197,7 +4197,7 @@ RID RenderingDeviceVulkan::index_array_create(RID p_index_buffer, uint32_t p_ind
ERR_FAIL_COND_V(!index_buffer_owner.owns(p_index_buffer), RID());
- IndexBuffer *index_buffer = index_buffer_owner.getornull(p_index_buffer);
+ IndexBuffer *index_buffer = index_buffer_owner.get_or_null(p_index_buffer);
ERR_FAIL_COND_V(p_index_count == 0, RID());
ERR_FAIL_COND_V(p_index_offset + p_index_count > index_buffer->index_count, RID());
@@ -4241,7 +4241,7 @@ static VkShaderStageFlagBits shader_stage_masks[RenderingDevice::SHADER_STAGE_MA
String RenderingDeviceVulkan::_shader_uniform_debug(RID p_shader, int p_set) {
String ret;
- const Shader *shader = shader_owner.getornull(p_shader);
+ const Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, String());
for (int i = 0; i < shader->sets.size(); i++) {
if (p_set >= 0 && i != p_set) {
@@ -5272,7 +5272,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_
uint32_t RenderingDeviceVulkan::shader_get_vertex_input_attribute_mask(RID p_shader) {
_THREAD_SAFE_METHOD_
- const Shader *shader = shader_owner.getornull(p_shader);
+ const Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, 0);
return shader->vertex_input_mask;
}
@@ -5494,7 +5494,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
ERR_FAIL_COND_V(p_uniforms.size() == 0, RID());
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RID());
ERR_FAIL_COND_V_MSG(p_shader_set >= (uint32_t)shader->sets.size() || shader->sets[p_shader_set].uniform_info.size() == 0, RID(),
@@ -5563,7 +5563,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkDescriptorImageInfo> image_info;
for (int j = 0; j < uniform.ids.size(); j++) {
- VkSampler *sampler = sampler_owner.getornull(uniform.ids[j]);
+ VkSampler *sampler = sampler_owner.get_or_null(uniform.ids[j]);
ERR_FAIL_COND_V_MSG(!sampler, RID(), "Sampler (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid sampler.");
VkDescriptorImageInfo img_info;
@@ -5596,10 +5596,10 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkDescriptorImageInfo> image_info;
for (int j = 0; j < uniform.ids.size(); j += 2) {
- VkSampler *sampler = sampler_owner.getornull(uniform.ids[j + 0]);
+ VkSampler *sampler = sampler_owner.get_or_null(uniform.ids[j + 0]);
ERR_FAIL_COND_V_MSG(!sampler, RID(), "SamplerBuffer (binding: " + itos(uniform.binding) + ", index " + itos(j + 1) + ") is not a valid sampler.");
- Texture *texture = texture_owner.getornull(uniform.ids[j + 1]);
+ Texture *texture = texture_owner.get_or_null(uniform.ids[j + 1]);
ERR_FAIL_COND_V_MSG(!texture, RID(), "Texture (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid texture.");
ERR_FAIL_COND_V_MSG(!(texture->usage_flags & TEXTURE_USAGE_SAMPLING_BIT), RID(),
@@ -5621,7 +5621,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
mutable_sampled_textures.push_back(texture);
}
if (texture->owner.is_valid()) {
- texture = texture_owner.getornull(texture->owner);
+ texture = texture_owner.get_or_null(texture->owner);
ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen
}
@@ -5652,7 +5652,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkDescriptorImageInfo> image_info;
for (int j = 0; j < uniform.ids.size(); j++) {
- Texture *texture = texture_owner.getornull(uniform.ids[j]);
+ Texture *texture = texture_owner.get_or_null(uniform.ids[j]);
ERR_FAIL_COND_V_MSG(!texture, RID(), "Texture (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid texture.");
ERR_FAIL_COND_V_MSG(!(texture->usage_flags & TEXTURE_USAGE_SAMPLING_BIT), RID(),
@@ -5675,7 +5675,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
}
if (texture->owner.is_valid()) {
- texture = texture_owner.getornull(texture->owner);
+ texture = texture_owner.get_or_null(texture->owner);
ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen
}
@@ -5705,7 +5705,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkDescriptorImageInfo> image_info;
for (int j = 0; j < uniform.ids.size(); j++) {
- Texture *texture = texture_owner.getornull(uniform.ids[j]);
+ Texture *texture = texture_owner.get_or_null(uniform.ids[j]);
ERR_FAIL_COND_V_MSG(!texture, RID(),
"Image (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid texture.");
@@ -5723,7 +5723,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
}
if (texture->owner.is_valid()) {
- texture = texture_owner.getornull(texture->owner);
+ texture = texture_owner.get_or_null(texture->owner);
ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen
}
@@ -5755,7 +5755,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkBufferView> buffer_view;
for (int j = 0; j < uniform.ids.size(); j++) {
- TextureBuffer *buffer = texture_buffer_owner.getornull(uniform.ids[j]);
+ TextureBuffer *buffer = texture_buffer_owner.get_or_null(uniform.ids[j]);
ERR_FAIL_COND_V_MSG(!buffer, RID(), "Texture Buffer (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid texture buffer.");
buffer_info.push_back(buffer->buffer.buffer_info);
@@ -5786,10 +5786,10 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkBufferView> buffer_view;
for (int j = 0; j < uniform.ids.size(); j += 2) {
- VkSampler *sampler = sampler_owner.getornull(uniform.ids[j + 0]);
+ VkSampler *sampler = sampler_owner.get_or_null(uniform.ids[j + 0]);
ERR_FAIL_COND_V_MSG(!sampler, RID(), "SamplerBuffer (binding: " + itos(uniform.binding) + ", index " + itos(j + 1) + ") is not a valid sampler.");
- TextureBuffer *buffer = texture_buffer_owner.getornull(uniform.ids[j + 1]);
+ TextureBuffer *buffer = texture_buffer_owner.get_or_null(uniform.ids[j + 1]);
VkDescriptorImageInfo img_info;
img_info.sampler = *sampler;
@@ -5821,7 +5821,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
ERR_FAIL_COND_V_MSG(uniform.ids.size() != 1, RID(),
"Uniform buffer supplied (binding: " + itos(uniform.binding) + ") must provide one ID (" + itos(uniform.ids.size()) + " provided).");
- Buffer *buffer = uniform_buffer_owner.getornull(uniform.ids[0]);
+ Buffer *buffer = uniform_buffer_owner.get_or_null(uniform.ids[0]);
ERR_FAIL_COND_V_MSG(!buffer, RID(), "Uniform buffer supplied (binding: " + itos(uniform.binding) + ") is invalid.");
ERR_FAIL_COND_V_MSG(buffer->size != (uint32_t)set_uniform.length, RID(),
@@ -5842,9 +5842,9 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Buffer *buffer = nullptr;
if (storage_buffer_owner.owns(uniform.ids[0])) {
- buffer = storage_buffer_owner.getornull(uniform.ids[0]);
+ buffer = storage_buffer_owner.get_or_null(uniform.ids[0]);
} else if (vertex_buffer_owner.owns(uniform.ids[0])) {
- buffer = vertex_buffer_owner.getornull(uniform.ids[0]);
+ buffer = vertex_buffer_owner.get_or_null(uniform.ids[0]);
ERR_FAIL_COND_V_MSG(!(buffer->usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT), RID(), "Vertex buffer supplied (binding: " + itos(uniform.binding) + ") was not created with storage flag.");
}
@@ -5875,7 +5875,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
Vector<VkDescriptorImageInfo> image_info;
for (int j = 0; j < uniform.ids.size(); j++) {
- Texture *texture = texture_owner.getornull(uniform.ids[j]);
+ Texture *texture = texture_owner.get_or_null(uniform.ids[j]);
ERR_FAIL_COND_V_MSG(!texture, RID(),
"InputAttachment (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") is not a valid texture.");
@@ -5888,7 +5888,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
img_info.imageView = texture->view;
if (texture->owner.is_valid()) {
- texture = texture_owner.getornull(texture->owner);
+ texture = texture_owner.get_or_null(texture->owner);
ERR_FAIL_COND_V(!texture, RID()); //bug, should never happen
}
@@ -5977,7 +5977,7 @@ bool RenderingDeviceVulkan::uniform_set_is_valid(RID p_uniform_set) {
}
void RenderingDeviceVulkan::uniform_set_set_invalidation_callback(RID p_uniform_set, UniformSetInvalidatedCallback p_callback, void *p_userdata) {
- UniformSet *us = uniform_set_owner.getornull(p_uniform_set);
+ UniformSet *us = uniform_set_owner.get_or_null(p_uniform_set);
ERR_FAIL_COND(!us);
us->invalidated_callback = p_callback;
us->invalidated_callback_userdata = p_userdata;
@@ -6126,7 +6126,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
_THREAD_SAFE_METHOD_
//needs a shader
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RID());
ERR_FAIL_COND_V_MSG(shader->is_compute, RID(),
@@ -6568,7 +6568,7 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader, const Vector<Pi
_THREAD_SAFE_METHOD_
//needs a shader
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RID());
ERR_FAIL_COND_V_MSG(!shader->is_compute, RID(),
@@ -6779,7 +6779,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu
framebuffer_create_info.renderPass = version.render_pass;
Vector<VkImageView> attachments;
for (int i = 0; i < p_framebuffer->texture_ids.size(); i++) {
- Texture *texture = texture_owner.getornull(p_framebuffer->texture_ids[i]);
+ Texture *texture = texture_owner.get_or_null(p_framebuffer->texture_ids[i]);
ERR_FAIL_COND_V(!texture, ERR_BUG);
attachments.push_back(texture->view);
ERR_FAIL_COND_V(texture->width != p_framebuffer->size.width, ERR_BUG);
@@ -6831,7 +6831,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff
{
int color_index = 0;
for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
- Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
+ Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]);
VkClearValue clear_value;
if (color_index < p_clear_colors.size() && texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
@@ -6859,7 +6859,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff
render_pass_begin.pClearValues = clear_values.ptr();
for (int i = 0; i < p_storage_textures.size(); i++) {
- Texture *texture = texture_owner.getornull(p_storage_textures[i]);
+ Texture *texture = texture_owner.get_or_null(p_storage_textures[i]);
ERR_CONTINUE_MSG(!(texture->usage_flags & TEXTURE_USAGE_STORAGE_BIT), "Supplied storage texture " + itos(i) + " for draw list is not set to be used for storage.");
if (texture->usage_flags & TEXTURE_USAGE_SAMPLING_BIT) {
@@ -6897,7 +6897,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff
draw_list_unbind_depth_textures = p_final_depth_action != FINAL_ACTION_CONTINUE;
for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
- Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
+ Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]);
texture->bound = true;
draw_list_bound_textures.push_back(framebuffer->texture_ids[i]);
}
@@ -6909,7 +6909,7 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list,
Vector<VkClearAttachment> clear_attachments;
int color_index = 0;
for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
- Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
+ Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]);
VkClearAttachment clear_at = {};
if (p_clear_color && texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
@@ -6952,7 +6952,7 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time.");
ERR_FAIL_COND_V_MSG(compute_list != nullptr && !compute_list->state.allow_draw_overlap, INVALID_ID, "Only one draw/compute list can be active at the same time.");
- Framebuffer *framebuffer = framebuffer_owner.getornull(p_framebuffer);
+ Framebuffer *framebuffer = framebuffer_owner.get_or_null(p_framebuffer);
ERR_FAIL_COND_V(!framebuffer, INVALID_ID);
Point2i viewport_offset;
@@ -6993,7 +6993,7 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
int color_count = 0;
for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
- Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
+ Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]);
if (texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
color_count++;
@@ -7056,7 +7056,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
ERR_FAIL_COND_V(p_splits < 1, ERR_INVALID_DECLARATION);
- Framebuffer *framebuffer = framebuffer_owner.getornull(p_framebuffer);
+ Framebuffer *framebuffer = framebuffer_owner.get_or_null(p_framebuffer);
ERR_FAIL_COND_V(!framebuffer, ERR_INVALID_DECLARATION);
Point2i viewport_offset;
@@ -7091,7 +7091,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
int color_count = 0;
for (int i = 0; i < framebuffer->texture_ids.size(); i++) {
- Texture *texture = texture_owner.getornull(framebuffer->texture_ids[i]);
+ Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]);
if (texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
color_count++;
@@ -7192,7 +7192,7 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI
ERR_FAIL_COND_MSG(!dl->validation.active, "Submitted Draw Lists can no longer be modified.");
#endif
- const RenderPipeline *pipeline = render_pipeline_owner.getornull(p_render_pipeline);
+ const RenderPipeline *pipeline = render_pipeline_owner.get_or_null(p_render_pipeline);
ERR_FAIL_COND(!pipeline);
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(pipeline->validation.framebuffer_format != draw_list_framebuffer_format && pipeline->validation.render_pass != draw_list_current_subpass);
@@ -7267,7 +7267,7 @@ void RenderingDeviceVulkan::draw_list_bind_uniform_set(DrawListID p_list, RID p_
ERR_FAIL_COND_MSG(!dl->validation.active, "Submitted Draw Lists can no longer be modified.");
#endif
- const UniformSet *uniform_set = uniform_set_owner.getornull(p_uniform_set);
+ const UniformSet *uniform_set = uniform_set_owner.get_or_null(p_uniform_set);
ERR_FAIL_COND(!uniform_set);
if (p_index > dl->state.set_count) {
@@ -7315,7 +7315,7 @@ void RenderingDeviceVulkan::draw_list_bind_vertex_array(DrawListID p_list, RID p
ERR_FAIL_COND_MSG(!dl->validation.active, "Submitted Draw Lists can no longer be modified.");
#endif
- const VertexArray *vertex_array = vertex_array_owner.getornull(p_vertex_array);
+ const VertexArray *vertex_array = vertex_array_owner.get_or_null(p_vertex_array);
ERR_FAIL_COND(!vertex_array);
if (dl->state.vertex_array == p_vertex_array) {
@@ -7339,7 +7339,7 @@ void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_
ERR_FAIL_COND_MSG(!dl->validation.active, "Submitted Draw Lists can no longer be modified.");
#endif
- const IndexArray *index_array = index_array_owner.getornull(p_index_array);
+ const IndexArray *index_array = index_array_owner.get_or_null(p_index_array);
ERR_FAIL_COND(!index_array);
if (dl->state.index_array == p_index_array) {
@@ -7425,7 +7425,7 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
if (dl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(dl->state.sets[i].uniform_set)) {
- UniformSet *us = uniform_set_owner.getornull(dl->state.sets[i].uniform_set);
+ UniformSet *us = uniform_set_owner.get_or_null(dl->state.sets[i].uniform_set);
ERR_FAIL_MSG("Uniforms supplied for set (" + itos(i) + "):\n" + _shader_uniform_debug(us->shader_id, us->shader_set) + "\nare not the same format as required by the pipeline shader. Pipeline shader requires the following bindings:\n" + _shader_uniform_debug(dl->state.pipeline_shader));
} else {
ERR_FAIL_MSG("Uniforms supplied for set (" + itos(i) + ", which was was just freed) are not the same format as required by the pipeline shader. Pipeline shader requires the following bindings:\n" + _shader_uniform_debug(dl->state.pipeline_shader));
@@ -7696,7 +7696,7 @@ void RenderingDeviceVulkan::draw_list_end(uint32_t p_post_barrier) {
vkCmdEndRenderPass(frames[frame].draw_command_buffer);
for (int i = 0; i < draw_list_bound_textures.size(); i++) {
- Texture *texture = texture_owner.getornull(draw_list_bound_textures[i]);
+ Texture *texture = texture_owner.get_or_null(draw_list_bound_textures[i]);
ERR_CONTINUE(!texture); //wtf
if (draw_list_unbind_color_textures && (texture->usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT)) {
texture->bound = false;
@@ -7744,7 +7744,7 @@ void RenderingDeviceVulkan::draw_list_end(uint32_t p_post_barrier) {
}
for (uint32_t i = 0; i < image_barrier_count; i++) {
- Texture *texture = texture_owner.getornull(draw_list_storage_textures[i]);
+ Texture *texture = texture_owner.get_or_null(draw_list_storage_textures[i]);
VkImageMemoryBarrier &image_memory_barrier = image_barriers[i];
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
@@ -7810,7 +7810,7 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l
ComputeList *cl = compute_list;
- const ComputePipeline *pipeline = compute_pipeline_owner.getornull(p_compute_pipeline);
+ const ComputePipeline *pipeline = compute_pipeline_owner.get_or_null(p_compute_pipeline);
ERR_FAIL_COND(!pipeline);
if (p_compute_pipeline == cl->state.pipeline) {
@@ -7883,7 +7883,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list,
ERR_FAIL_COND_MSG(!cl->validation.active, "Submitted Compute Lists can no longer be modified.");
#endif
- UniformSet *uniform_set = uniform_set_owner.getornull(p_uniform_set);
+ UniformSet *uniform_set = uniform_set_owner.get_or_null(p_uniform_set);
ERR_FAIL_COND(!uniform_set);
if (p_index > cl->state.set_count) {
@@ -8082,7 +8082,7 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t
if (cl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(cl->state.sets[i].uniform_set)) {
- UniformSet *us = uniform_set_owner.getornull(cl->state.sets[i].uniform_set);
+ UniformSet *us = uniform_set_owner.get_or_null(cl->state.sets[i].uniform_set);
ERR_FAIL_MSG("Uniforms supplied for set (" + itos(i) + "):\n" + _shader_uniform_debug(us->shader_id, us->shader_set) + "\nare not the same format as required by the pipeline shader. Pipeline shader requires the following bindings:\n" + _shader_uniform_debug(cl->state.pipeline_shader));
} else {
ERR_FAIL_MSG("Uniforms supplied for set (" + itos(i) + ", which was was just freed) are not the same format as required by the pipeline shader. Pipeline shader requires the following bindings:\n" + _shader_uniform_debug(cl->state.pipeline_shader));
@@ -8125,7 +8125,7 @@ void RenderingDeviceVulkan::compute_list_dispatch_indirect(ComputeListID p_list,
ERR_FAIL_COND(!compute_list);
ComputeList *cl = compute_list;
- Buffer *buffer = storage_buffer_owner.getornull(p_buffer);
+ Buffer *buffer = storage_buffer_owner.get_or_null(p_buffer);
ERR_FAIL_COND(!buffer);
ERR_FAIL_COND_MSG(!(buffer->usage & STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT), "Buffer provided was not created to do indirect dispatch.");
@@ -8159,7 +8159,7 @@ void RenderingDeviceVulkan::compute_list_dispatch_indirect(ComputeListID p_list,
if (cl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(cl->state.sets[i].uniform_set)) {
- UniformSet *us = uniform_set_owner.getornull(cl->state.sets[i].uniform_set);
+ UniformSet *us = uniform_set_owner.get_or_null(cl->state.sets[i].uniform_set);
ERR_FAIL_MSG("Uniforms supplied for set (" + itos(i) + "):\n" + _shader_uniform_debug(us->shader_id, us->shader_set) + "\nare not the same format as required by the pipeline shader. Pipeline shader requires the following bindings:\n" + _shader_uniform_debug(cl->state.pipeline_shader));
} else {
ERR_FAIL_MSG("Uniforms supplied for set (" + itos(i) + ", which was was just freed) are not the same format as required by the pipeline shader. Pipeline shader requires the following bindings:\n" + _shader_uniform_debug(cl->state.pipeline_shader));
@@ -8371,25 +8371,25 @@ void RenderingDeviceVulkan::draw_list_render_secondary_to_framebuffer(ID p_frame
void RenderingDeviceVulkan::_free_internal(RID p_id) {
//push everything so it's disposed of next time this frame index is processed (means, it's safe to do it)
if (texture_owner.owns(p_id)) {
- Texture *texture = texture_owner.getornull(p_id);
+ Texture *texture = texture_owner.get_or_null(p_id);
frames[frame].textures_to_dispose_of.push_back(*texture);
texture_owner.free(p_id);
} else if (framebuffer_owner.owns(p_id)) {
- Framebuffer *framebuffer = framebuffer_owner.getornull(p_id);
+ Framebuffer *framebuffer = framebuffer_owner.get_or_null(p_id);
frames[frame].framebuffers_to_dispose_of.push_back(*framebuffer);
framebuffer_owner.free(p_id);
} else if (sampler_owner.owns(p_id)) {
- VkSampler *sampler = sampler_owner.getornull(p_id);
+ VkSampler *sampler = sampler_owner.get_or_null(p_id);
frames[frame].samplers_to_dispose_of.push_back(*sampler);
sampler_owner.free(p_id);
} else if (vertex_buffer_owner.owns(p_id)) {
- Buffer *vertex_buffer = vertex_buffer_owner.getornull(p_id);
+ Buffer *vertex_buffer = vertex_buffer_owner.get_or_null(p_id);
frames[frame].buffers_to_dispose_of.push_back(*vertex_buffer);
vertex_buffer_owner.free(p_id);
} else if (vertex_array_owner.owns(p_id)) {
vertex_array_owner.free(p_id);
} else if (index_buffer_owner.owns(p_id)) {
- IndexBuffer *index_buffer = index_buffer_owner.getornull(p_id);
+ IndexBuffer *index_buffer = index_buffer_owner.get_or_null(p_id);
Buffer b;
b.allocation = index_buffer->allocation;
b.buffer = index_buffer->buffer;
@@ -8400,24 +8400,24 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) {
} else if (index_array_owner.owns(p_id)) {
index_array_owner.free(p_id);
} else if (shader_owner.owns(p_id)) {
- Shader *shader = shader_owner.getornull(p_id);
+ Shader *shader = shader_owner.get_or_null(p_id);
frames[frame].shaders_to_dispose_of.push_back(*shader);
shader_owner.free(p_id);
} else if (uniform_buffer_owner.owns(p_id)) {
- Buffer *uniform_buffer = uniform_buffer_owner.getornull(p_id);
+ Buffer *uniform_buffer = uniform_buffer_owner.get_or_null(p_id);
frames[frame].buffers_to_dispose_of.push_back(*uniform_buffer);
uniform_buffer_owner.free(p_id);
} else if (texture_buffer_owner.owns(p_id)) {
- TextureBuffer *texture_buffer = texture_buffer_owner.getornull(p_id);
+ TextureBuffer *texture_buffer = texture_buffer_owner.get_or_null(p_id);
frames[frame].buffers_to_dispose_of.push_back(texture_buffer->buffer);
frames[frame].buffer_views_to_dispose_of.push_back(texture_buffer->view);
texture_buffer_owner.free(p_id);
} else if (storage_buffer_owner.owns(p_id)) {
- Buffer *storage_buffer = storage_buffer_owner.getornull(p_id);
+ Buffer *storage_buffer = storage_buffer_owner.get_or_null(p_id);
frames[frame].buffers_to_dispose_of.push_back(*storage_buffer);
storage_buffer_owner.free(p_id);
} else if (uniform_set_owner.owns(p_id)) {
- UniformSet *uniform_set = uniform_set_owner.getornull(p_id);
+ UniformSet *uniform_set = uniform_set_owner.get_or_null(p_id);
frames[frame].uniform_sets_to_dispose_of.push_back(*uniform_set);
if (uniform_set->invalidated_callback != nullptr) {
uniform_set->invalidated_callback(p_id, uniform_set->invalidated_callback_userdata);
@@ -8425,11 +8425,11 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) {
uniform_set_owner.free(p_id);
} else if (render_pipeline_owner.owns(p_id)) {
- RenderPipeline *pipeline = render_pipeline_owner.getornull(p_id);
+ RenderPipeline *pipeline = render_pipeline_owner.get_or_null(p_id);
frames[frame].render_pipelines_to_dispose_of.push_back(*pipeline);
render_pipeline_owner.free(p_id);
} else if (compute_pipeline_owner.owns(p_id)) {
- ComputePipeline *pipeline = compute_pipeline_owner.getornull(p_id);
+ ComputePipeline *pipeline = compute_pipeline_owner.get_or_null(p_id);
frames[frame].compute_pipelines_to_dispose_of.push_back(*pipeline);
compute_pipeline_owner.free(p_id);
} else {
@@ -8448,49 +8448,49 @@ void RenderingDeviceVulkan::free(RID p_id) {
// We just expose the resources that are owned and can be accessed easily.
void RenderingDeviceVulkan::set_resource_name(RID p_id, const String p_name) {
if (texture_owner.owns(p_id)) {
- Texture *texture = texture_owner.getornull(p_id);
+ Texture *texture = texture_owner.get_or_null(p_id);
if (texture->owner.is_null()) {
// Don't set the source texture's name when calling on a texture view
context->set_object_name(VK_OBJECT_TYPE_IMAGE, uint64_t(texture->image), p_name);
}
context->set_object_name(VK_OBJECT_TYPE_IMAGE_VIEW, uint64_t(texture->view), p_name + " View");
} else if (framebuffer_owner.owns(p_id)) {
- //Framebuffer *framebuffer = framebuffer_owner.getornull(p_id);
+ //Framebuffer *framebuffer = framebuffer_owner.get_or_null(p_id);
// Not implemented for now as the relationship between Framebuffer and RenderPass is very complex
} else if (sampler_owner.owns(p_id)) {
- VkSampler *sampler = sampler_owner.getornull(p_id);
+ VkSampler *sampler = sampler_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_SAMPLER, uint64_t(*sampler), p_name);
} else if (vertex_buffer_owner.owns(p_id)) {
- Buffer *vertex_buffer = vertex_buffer_owner.getornull(p_id);
+ Buffer *vertex_buffer = vertex_buffer_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_BUFFER, uint64_t(vertex_buffer->buffer), p_name);
} else if (index_buffer_owner.owns(p_id)) {
- IndexBuffer *index_buffer = index_buffer_owner.getornull(p_id);
+ IndexBuffer *index_buffer = index_buffer_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_BUFFER, uint64_t(index_buffer->buffer), p_name);
} else if (shader_owner.owns(p_id)) {
- Shader *shader = shader_owner.getornull(p_id);
+ Shader *shader = shader_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_PIPELINE_LAYOUT, uint64_t(shader->pipeline_layout), p_name + " Pipeline Layout");
for (int i = 0; i < shader->sets.size(); i++) {
context->set_object_name(VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, uint64_t(shader->sets[i].descriptor_set_layout), p_name);
}
} else if (uniform_buffer_owner.owns(p_id)) {
- Buffer *uniform_buffer = uniform_buffer_owner.getornull(p_id);
+ Buffer *uniform_buffer = uniform_buffer_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_BUFFER, uint64_t(uniform_buffer->buffer), p_name);
} else if (texture_buffer_owner.owns(p_id)) {
- TextureBuffer *texture_buffer = texture_buffer_owner.getornull(p_id);
+ TextureBuffer *texture_buffer = texture_buffer_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_BUFFER, uint64_t(texture_buffer->buffer.buffer), p_name);
context->set_object_name(VK_OBJECT_TYPE_BUFFER_VIEW, uint64_t(texture_buffer->view), p_name + " View");
} else if (storage_buffer_owner.owns(p_id)) {
- Buffer *storage_buffer = storage_buffer_owner.getornull(p_id);
+ Buffer *storage_buffer = storage_buffer_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_BUFFER, uint64_t(storage_buffer->buffer), p_name);
} else if (uniform_set_owner.owns(p_id)) {
- UniformSet *uniform_set = uniform_set_owner.getornull(p_id);
+ UniformSet *uniform_set = uniform_set_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_DESCRIPTOR_SET, uint64_t(uniform_set->descriptor_set), p_name);
} else if (render_pipeline_owner.owns(p_id)) {
- RenderPipeline *pipeline = render_pipeline_owner.getornull(p_id);
+ RenderPipeline *pipeline = render_pipeline_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_PIPELINE, uint64_t(pipeline->pipeline), p_name);
context->set_object_name(VK_OBJECT_TYPE_PIPELINE_LAYOUT, uint64_t(pipeline->pipeline_layout), p_name + " Layout");
} else if (compute_pipeline_owner.owns(p_id)) {
- ComputePipeline *pipeline = compute_pipeline_owner.getornull(p_id);
+ ComputePipeline *pipeline = compute_pipeline_owner.get_or_null(p_id);
context->set_object_name(VK_OBJECT_TYPE_PIPELINE, uint64_t(pipeline->pipeline), p_name);
context->set_object_name(VK_OBJECT_TYPE_PIPELINE_LAYOUT, uint64_t(pipeline->pipeline_layout), p_name + " Layout");
} else {
@@ -9037,31 +9037,31 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R
return context->get_graphics_queue_family_index();
}; break;
case DRIVER_RESOURCE_VULKAN_IMAGE: {
- Texture *tex = texture_owner.getornull(p_rid);
+ Texture *tex = texture_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(tex, 0);
return (uint64_t)tex->image;
}; break;
case DRIVER_RESOURCE_VULKAN_IMAGE_VIEW: {
- Texture *tex = texture_owner.getornull(p_rid);
+ Texture *tex = texture_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(tex, 0);
return (uint64_t)tex->view;
}; break;
case DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT: {
- Texture *tex = texture_owner.getornull(p_rid);
+ Texture *tex = texture_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(tex, 0);
return vulkan_formats[tex->format];
}; break;
case DRIVER_RESOURCE_VULKAN_SAMPLER: {
- VkSampler *sampler = sampler_owner.getornull(p_rid);
+ VkSampler *sampler = sampler_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(sampler, 0);
return uint64_t(*sampler);
}; break;
case DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET: {
- UniformSet *uniform_set = uniform_set_owner.getornull(p_rid);
+ UniformSet *uniform_set = uniform_set_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(uniform_set, 0);
return uint64_t(uniform_set->descriptor_set);
@@ -9069,15 +9069,15 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R
case DRIVER_RESOURCE_VULKAN_BUFFER: {
Buffer *buffer = nullptr;
if (vertex_buffer_owner.owns(p_rid)) {
- buffer = vertex_buffer_owner.getornull(p_rid);
+ buffer = vertex_buffer_owner.get_or_null(p_rid);
} else if (index_buffer_owner.owns(p_rid)) {
- buffer = index_buffer_owner.getornull(p_rid);
+ buffer = index_buffer_owner.get_or_null(p_rid);
} else if (uniform_buffer_owner.owns(p_rid)) {
- buffer = uniform_buffer_owner.getornull(p_rid);
+ buffer = uniform_buffer_owner.get_or_null(p_rid);
} else if (texture_buffer_owner.owns(p_rid)) {
- buffer = &texture_buffer_owner.getornull(p_rid)->buffer;
+ buffer = &texture_buffer_owner.get_or_null(p_rid)->buffer;
} else if (storage_buffer_owner.owns(p_rid)) {
- buffer = storage_buffer_owner.getornull(p_rid);
+ buffer = storage_buffer_owner.get_or_null(p_rid);
}
ERR_FAIL_NULL_V(buffer, 0);
@@ -9085,13 +9085,13 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R
return uint64_t(buffer->buffer);
}; break;
case DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE: {
- ComputePipeline *compute_pipeline = compute_pipeline_owner.getornull(p_rid);
+ ComputePipeline *compute_pipeline = compute_pipeline_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(compute_pipeline, 0);
return uint64_t(compute_pipeline->pipeline);
}; break;
case DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE: {
- RenderPipeline *render_pipeline = render_pipeline_owner.getornull(p_rid);
+ RenderPipeline *render_pipeline = render_pipeline_owner.get_or_null(p_rid);
ERR_FAIL_NULL_V(render_pipeline, 0);
return uint64_t(render_pipeline->pipeline);
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index bb0123e536..1c7e83af21 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -2084,12 +2084,12 @@ RID VulkanContext::local_device_create() {
}
VkDevice VulkanContext::local_device_get_vk_device(RID p_local_device) {
- LocalDevice *ld = local_device_owner.getornull(p_local_device);
+ LocalDevice *ld = local_device_owner.get_or_null(p_local_device);
return ld->device;
}
void VulkanContext::local_device_push_command_buffers(RID p_local_device, const VkCommandBuffer *p_buffers, int p_count) {
- LocalDevice *ld = local_device_owner.getornull(p_local_device);
+ LocalDevice *ld = local_device_owner.get_or_null(p_local_device);
ERR_FAIL_COND(ld->waiting);
VkSubmitInfo submit_info;
@@ -2119,7 +2119,7 @@ void VulkanContext::local_device_push_command_buffers(RID p_local_device, const
}
void VulkanContext::local_device_sync(RID p_local_device) {
- LocalDevice *ld = local_device_owner.getornull(p_local_device);
+ LocalDevice *ld = local_device_owner.get_or_null(p_local_device);
ERR_FAIL_COND(!ld->waiting);
vkDeviceWaitIdle(ld->device);
@@ -2127,7 +2127,7 @@ void VulkanContext::local_device_sync(RID p_local_device) {
}
void VulkanContext::local_device_free(RID p_local_device) {
- LocalDevice *ld = local_device_owner.getornull(p_local_device);
+ LocalDevice *ld = local_device_owner.get_or_null(p_local_device);
vkDestroyDevice(ld->device, nullptr);
local_device_owner.free(p_local_device);
}
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 5fda1c76ef..a312c161a8 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -147,7 +147,7 @@ void ScriptEditorDebugger::update_tabs() {
}
void ScriptEditorDebugger::clear_style() {
- tabs->add_theme_style_override("panel", nullptr);
+ tabs->remove_theme_style_override("panel");
}
void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) {
@@ -501,6 +501,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
error->set_text(0, time);
error->set_text_align(0, TreeItem::ALIGN_LEFT);
+ const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), SNAME("Editor"));
+ error->set_custom_color(0, color);
+ error->set_custom_color(1, color);
+
String error_title;
if (oe.callstack.size() > 0) {
// If available, use the script's stack in the error title.
@@ -1234,7 +1238,7 @@ void ScriptEditorDebugger::update_live_edit_root() {
Array msg;
msg.push_back(np);
if (editor->get_edited_scene()) {
- msg.push_back(editor->get_edited_scene()->get_filename());
+ msg.push_back(editor->get_edited_scene()->get_scene_file_path());
} else {
msg.push_back("");
}
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 5e50835ef2..225526da5b 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -554,7 +554,7 @@ void EditorData::remove_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, edited_scene.size());
if (edited_scene[p_idx].root) {
for (int i = 0; i < editor_plugins.size(); i++) {
- editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename());
+ editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_scene_file_path());
}
memdelete(edited_scene[p_idx].root);
@@ -583,7 +583,7 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String>
if (p_node == p_root) {
ss = p_node->get_scene_inherited_state();
- } else if (p_node->get_filename() != String()) {
+ } else if (p_node->get_scene_file_path() != String()) {
ss = p_node->get_scene_instance_state();
}
@@ -643,12 +643,12 @@ bool EditorData::check_and_update_scene(int p_idx) {
}
}
- new_scene->set_filename(edited_scene[p_idx].root->get_filename());
+ new_scene->set_scene_file_path(edited_scene[p_idx].root->get_scene_file_path());
memdelete(edited_scene[p_idx].root);
edited_scene.write[p_idx].root = new_scene;
- if (new_scene->get_filename() != "") {
- edited_scene.write[p_idx].path = new_scene->get_filename();
+ if (new_scene->get_scene_file_path() != "") {
+ edited_scene.write[p_idx].path = new_scene->get_scene_file_path();
}
edited_scene.write[p_idx].selection = new_selection;
@@ -682,10 +682,10 @@ void EditorData::set_edited_scene_root(Node *p_root) {
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
edited_scene.write[current_edited_scene].root = p_root;
if (p_root) {
- if (p_root->get_filename() != "") {
- edited_scene.write[current_edited_scene].path = p_root->get_filename();
+ if (p_root->get_scene_file_path() != "") {
+ edited_scene.write[current_edited_scene].path = p_root->get_scene_file_path();
} else {
- p_root->set_filename(edited_scene[current_edited_scene].path);
+ p_root->set_scene_file_path(edited_scene[current_edited_scene].path);
}
}
@@ -764,7 +764,7 @@ Ref<Script> EditorData::get_scene_root_script(int p_idx) const {
Ref<Script> s = edited_scene[p_idx].root->get_script();
if (!s.is_valid() && edited_scene[p_idx].root->get_child_count()) {
Node *n = edited_scene[p_idx].root->get_child(0);
- while (!s.is_valid() && n && n->get_filename() == String()) {
+ while (!s.is_valid() && n && n->get_scene_file_path() == String()) {
s = n->get_script();
n = n->get_parent();
}
@@ -777,11 +777,11 @@ String EditorData::get_scene_title(int p_idx, bool p_always_strip_extension) con
if (!edited_scene[p_idx].root) {
return TTR("[empty]");
}
- if (edited_scene[p_idx].root->get_filename() == "") {
+ if (edited_scene[p_idx].root->get_scene_file_path() == "") {
return TTR("[unsaved]");
}
- const String filename = edited_scene[p_idx].root->get_filename().get_file();
+ const String filename = edited_scene[p_idx].root->get_scene_file_path().get_file();
const String basename = filename.get_basename();
if (p_always_strip_extension) {
@@ -795,7 +795,7 @@ String EditorData::get_scene_title(int p_idx, bool p_always_strip_extension) con
continue;
}
- if (edited_scene[i].root && basename == edited_scene[i].root->get_filename().get_file().get_basename()) {
+ if (edited_scene[i].root && basename == edited_scene[i].root->get_scene_file_path().get_file().get_basename()) {
return filename;
}
}
@@ -811,17 +811,17 @@ void EditorData::set_scene_path(int p_idx, const String &p_path) {
if (!edited_scene[p_idx].root) {
return;
}
- edited_scene[p_idx].root->set_filename(p_path);
+ edited_scene[p_idx].root->set_scene_file_path(p_path);
}
String EditorData::get_scene_path(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
if (edited_scene[p_idx].root) {
- if (edited_scene[p_idx].root->get_filename() == "") {
- edited_scene[p_idx].root->set_filename(edited_scene[p_idx].path);
+ if (edited_scene[p_idx].root->get_scene_file_path() == "") {
+ edited_scene[p_idx].root->set_scene_file_path(edited_scene[p_idx].path);
} else {
- return edited_scene[p_idx].root->get_filename();
+ return edited_scene[p_idx].root->get_scene_file_path();
}
}
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index 5df392b91e..f91dedf25d 100644
--- a/editor/editor_dir_dialog.cpp
+++ b/editor/editor_dir_dialog.cpp
@@ -44,6 +44,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p
p_item->set_metadata(0, p_dir->get_path());
p_item->set_icon(0, tree->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ p_item->set_icon_modulate(0, tree->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")));
if (!p_item->get_parent()) {
p_item->set_text(0, "res://");
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index e719797e03..1aaa5432f4 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -394,7 +394,7 @@ void EditorNode::_version_control_menu_option(int p_idx) {
void EditorNode::_update_title() {
const String appname = ProjectSettings::get_singleton()->get("application/config/name");
String title = (appname.is_empty() ? "Unnamed Project" : appname) + String(" - ") + VERSION_NAME;
- const String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String();
+ const String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_scene_file_path() : String();
if (!edited.is_empty()) {
// Display the edited scene name before the program name so that it can be seen in the OS task bar.
title = vformat("%s - %s", edited.get_file(), title);
@@ -1175,7 +1175,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
int srpos = path.find("::");
if (srpos != -1) {
String base = path.substr(0, srpos);
- if (!get_edited_scene() || get_edited_scene()->get_filename() != base) {
+ if (!get_edited_scene() || get_edited_scene()->get_scene_file_path() != base) {
show_warning(TTR("This resource can't be saved because it does not belong to the edited scene. Make it unique first."));
return;
}
@@ -1549,7 +1549,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_node) {
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *child = p_node->get_child(i);
- if (child->get_filename() == p_filename) {
+ if (child->get_scene_file_path() == p_filename) {
return true;
}
@@ -1645,7 +1645,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
return;
}
- if (scene->get_filename() != String() && _validate_scene_recursive(scene->get_filename(), scene)) {
+ if (scene->get_scene_file_path() != String() && _validate_scene_recursive(scene->get_scene_file_path(), scene)) {
show_accept(TTR("This scene can't be saved because there is a cyclic instancing inclusion.\nPlease resolve it and then attempt to save again."), TTR("OK"));
return;
}
@@ -1699,7 +1699,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
if (err == OK) {
- scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file));
+ scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(p_file));
if (idx < 0 || idx == editor_data.get_edited_scene()) {
set_current_version(editor_data.get_undo_redo().get_version());
} else {
@@ -1727,8 +1727,8 @@ void EditorNode::save_scene_list(Vector<String> p_scene_filenames) {
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
- if (scene && (p_scene_filenames.find(scene->get_filename()) >= 0)) {
- _save_scene(scene->get_filename(), i);
+ if (scene && (p_scene_filenames.find(scene->get_scene_file_path()) >= 0)) {
+ _save_scene(scene->get_scene_file_path(), i);
}
}
}
@@ -1738,7 +1738,7 @@ void EditorNode::restart_editor() {
String to_reopen;
if (get_tree()->get_edited_scene_root()) {
- to_reopen = get_tree()->get_edited_scene_root()->get_filename();
+ to_reopen = get_tree()->get_edited_scene_root()->get_scene_file_path();
}
_exit_editor();
@@ -1757,13 +1757,15 @@ void EditorNode::restart_editor() {
void EditorNode::_save_all_scenes() {
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
- if (scene && scene->get_filename() != "") {
+ if (scene && scene->get_scene_file_path() != "" && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
if (i != editor_data.get_edited_scene()) {
- _save_scene(scene->get_filename(), i);
+ _save_scene(scene->get_scene_file_path(), i);
} else {
- _save_scene_with_preview(scene->get_filename());
+ _save_scene_with_preview(scene->get_scene_file_path());
}
- } // else: ignore new scenes
+ } else {
+ show_warning(TTR("Could not save one or more scenes!"), TTR("Save All Scenes"));
+ }
}
_save_default_environment();
@@ -1776,7 +1778,7 @@ void EditorNode::_mark_unsaved_scenes() {
continue;
}
- String path = node->get_filename();
+ String path = node->get_scene_file_path();
if (!(path == String() || FileAccess::exists(path))) {
if (i == editor_data.get_edited_scene()) {
set_current_version(-1);
@@ -2128,7 +2130,7 @@ void EditorNode::_edit_current() {
if (FileAccess::exists(base_path + ".import")) {
editable_warning = TTR("This resource belongs to a scene that was imported, so it's not editable.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
} else {
- if ((!get_edited_scene() || get_edited_scene()->get_filename() != base_path) && ResourceLoader::get_resource_type(base_path) == "PackedScene") {
+ if ((!get_edited_scene() || get_edited_scene()->get_scene_file_path() != base_path) && ResourceLoader::get_resource_type(base_path) == "PackedScene") {
editable_warning = TTR("This resource belongs to a scene that was instantiated or inherited.\nChanges to it won't be kept when saving the current scene.");
}
}
@@ -2152,8 +2154,8 @@ void EditorNode::_edit_current() {
inspector_dock->update(nullptr);
}
- if (get_edited_scene() && get_edited_scene()->get_filename() != String()) {
- String source_scene = get_edited_scene()->get_filename();
+ if (get_edited_scene() && get_edited_scene()->get_scene_file_path() != String()) {
+ String source_scene = get_edited_scene()->get_scene_file_path();
if (FileAccess::exists(source_scene + ".import")) {
editable_warning = TTR("This scene was imported, so changes to it won't be kept.\nInstancing it or inheriting will allow making changes to it.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
}
@@ -2276,7 +2278,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
String args;
bool skip_breakpoints;
- if (p_current || (editor_data.get_edited_scene_root() && p_custom != String() && p_custom == editor_data.get_edited_scene_root()->get_filename())) {
+ if (p_current || (editor_data.get_edited_scene_root() && p_custom != String() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -2284,7 +2286,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
return;
}
- if (scene->get_filename() == "") {
+ if (scene->get_scene_file_path() == "") {
current_option = -1;
_menu_option(FILE_SAVE_AS_SCENE);
// Set the option to save and run so when the dialog is accepted, the scene runs.
@@ -2293,7 +2295,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
return;
}
- run_filename = scene->get_filename();
+ run_filename = scene->get_scene_file_path();
} else if (p_custom != "") {
run_filename = p_custom;
}
@@ -2309,8 +2311,8 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (unsaved_cache) {
Node *scene = editor_data.get_edited_scene_root();
- if (scene && scene->get_filename() != "") { // Only autosave if there is a scene and if it has a path.
- _save_scene_with_preview(scene->get_filename());
+ if (scene && scene->get_scene_file_path() != "") { // Only autosave if there is a scene and if it has a path.
+ _save_scene_with_preview(scene->get_scene_file_path());
}
}
_menu_option(FILE_SAVE_ALL_SCENES);
@@ -2403,7 +2405,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
Node *scene = editor_data.get_edited_scene_root();
if (scene) {
- file->set_current_path(scene->get_filename());
+ file->set_current_path(scene->get_scene_file_path());
};
file->set_title(p_option == FILE_OPEN_SCENE ? TTR("Open Scene") : TTR("Open Base Scene"));
file->popup_file_dialog();
@@ -2465,7 +2467,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) {
Node *scene_root = editor_data.get_edited_scene_root(tab_closing);
if (scene_root) {
- String scene_filename = scene_root->get_filename();
+ String scene_filename = scene_root->get_scene_file_path();
save_confirmation->get_ok_button()->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();
@@ -2484,20 +2486,22 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case SCENE_TAB_CLOSE:
case FILE_SAVE_SCENE: {
int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing;
-
Node *scene = editor_data.get_edited_scene_root(scene_idx);
- if (scene && scene->get_filename() != "") {
- if (scene_idx != editor_data.get_edited_scene()) {
- _save_scene_with_preview(scene->get_filename(), scene_idx);
- } else {
- _save_scene_with_preview(scene->get_filename());
- }
+ if (scene && scene->get_scene_file_path() != "") {
+ if (DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
+ if (scene_idx != editor_data.get_edited_scene()) {
+ _save_scene_with_preview(scene->get_scene_file_path(), scene_idx);
+ } else {
+ _save_scene_with_preview(scene->get_scene_file_path());
+ }
- if (scene_idx != -1) {
- _discard_changes();
+ if (scene_idx != -1) {
+ _discard_changes();
+ }
+ save_layout();
+ } else {
+ show_save_accept(vformat(TTR("%s no longer exists! Please specify a new save location."), scene->get_scene_file_path().get_base_dir()), TTR("OK"));
}
- save_layout();
-
break;
}
[[fallthrough]];
@@ -2539,8 +2543,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
- if (scene->get_filename() != "") {
- String path = scene->get_filename();
+ if (scene->get_scene_file_path() != "") {
+ String path = scene->get_scene_file_path();
file->set_current_path(path);
if (extensions.size()) {
String ext = path.get_extension().to_lower();
@@ -2638,7 +2642,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
break;
}
- String filename = scene->get_filename();
+ String filename = scene->get_scene_file_path();
if (filename == String()) {
show_warning(TTR("Can't reload a scene that was never saved."));
@@ -2760,7 +2764,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
String unsaved_scenes;
int i = _next_unsaved_scene(true, 0);
while (i != -1) {
- unsaved_scenes += "\n " + editor_data.get_edited_scene_root(i)->get_filename();
+ unsaved_scenes += "\n " + editor_data.get_edited_scene_root(i)->get_scene_file_path();
i = _next_unsaved_scene(true, ++i);
}
@@ -2835,7 +2839,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
Node *scene = editor_data.get_edited_scene_root();
if (scene) {
- file->set_current_path(scene->get_filename());
+ file->set_current_path(scene->get_scene_file_path());
};
file->set_title(TTR("Pick a Main Scene"));
file->popup_file_dialog();
@@ -2937,7 +2941,7 @@ int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) {
int current = editor_data.get_edited_scene();
bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
if (unsaved) {
- String scene_filename = editor_data.get_edited_scene_root(i)->get_filename();
+ String scene_filename = editor_data.get_edited_scene_root(i)->get_scene_file_path();
if (p_valid_filename && scene_filename.length() == 0) {
continue;
}
@@ -2969,7 +2973,7 @@ void EditorNode::_discard_changes(const String &p_str) {
case SCENE_TAB_CLOSE: {
Node *scene = editor_data.get_edited_scene_root(tab_closing);
if (scene != nullptr) {
- String scene_filename = scene->get_filename();
+ String scene_filename = scene->get_scene_file_path();
if (scene_filename != "") {
previous_scenes.push_back(scene_filename);
}
@@ -3598,7 +3602,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
Ref<SceneState> state = sdata->get_state();
state->set_path(lpath);
new_scene->set_scene_inherited_state(state);
- new_scene->set_filename(String());
+ new_scene->set_scene_file_path(String());
}
new_scene->set_scene_instance_state(Ref<SceneState>());
@@ -3771,7 +3775,7 @@ void EditorNode::_load_error_notify(void *p_ud, const String &p_text) {
}
bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const {
- if (p_node->get_filename() == p_path) {
+ if (p_node->get_scene_file_path() == p_path) {
return true;
}
@@ -3949,7 +3953,7 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na
pick_main_scene->hide();
current_option = SETTINGS_PICK_MAIN_SCENE;
- _dialog_action(scene->get_filename());
+ _dialog_action(scene->get_scene_file_path());
}
}
@@ -4150,6 +4154,13 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) {
accept->popup_centered();
}
+void EditorNode::show_save_accept(const String &p_text, const String &p_title) {
+ current_option = -1;
+ save_accept->get_ok_button()->set_text(p_title);
+ save_accept->set_text(p_text);
+ save_accept->popup_centered();
+}
+
void EditorNode::show_warning(const String &p_text, const String &p_title) {
if (warning->is_inside_tree()) {
warning->set_text(p_text);
@@ -4932,7 +4943,7 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) {
editor_data.get_scene_version(p_tab) != 0;
if (unsaved) {
save_confirmation->get_ok_button()->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->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_scene_file_path() != "" ? scene->get_scene_file_path() : "unsaved scene"));
save_confirmation->popup_centered();
} else {
_discard_changes();
@@ -6263,6 +6274,10 @@ EditorNode::EditorNode() {
gui_base->add_child(accept);
accept->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
+ save_accept = memnew(AcceptDialog);
+ gui_base->add_child(save_accept);
+ save_accept->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), make_binds((int)MenuOptions::FILE_SAVE_AS_SCENE));
+
project_export = memnew(ProjectExportDialog);
gui_base->add_child(project_export);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 2e8b850c7b..d1f4cf8452 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -308,6 +308,7 @@ private:
ConfirmationDialog *pick_main_scene;
Button *select_current_scene_button;
AcceptDialog *accept;
+ AcceptDialog *save_accept;
EditorAbout *about;
AcceptDialog *warning;
@@ -814,6 +815,7 @@ public:
Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
void show_accept(const String &p_text, const String &p_title);
+ void show_save_accept(const String &p_text, const String &p_title);
void show_warning(const String &p_text, const String &p_title = TTR("Warning!"));
void _copy_warning(const String &p_str);
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 99b917107e..7afc8d4c83 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -219,7 +219,7 @@ Array EditorInterface::get_open_scenes() const {
if (scenes[idx_scn].root == nullptr) {
continue;
}
- ret.push_back(scenes[idx_scn].root->get_filename());
+ ret.push_back(scenes[idx_scn].root->get_scene_file_path());
}
return ret;
}
@@ -291,11 +291,11 @@ Error EditorInterface::save_scene() {
if (!get_edited_scene_root()) {
return ERR_CANT_CREATE;
}
- if (get_edited_scene_root()->get_filename() == String()) {
+ if (get_edited_scene_root()->get_scene_file_path() == String()) {
return ERR_CANT_CREATE;
}
- save_scene_as(get_edited_scene_root()->get_filename());
+ save_scene_as(get_edited_scene_root()->get_scene_file_path());
return OK;
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 1820804cfe..70f43e01cf 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -411,6 +411,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/automatically_open_screenshots", true);
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/single_window_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
_initial_set("interface/editor/hide_console_window", false);
+ _initial_set("interface/editor/mouse_extra_buttons_navigate_history", true);
_initial_set("interface/editor/save_each_scene_on_quit", true); // Regression
// Inspector
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index afeba4f6fb..1890814da9 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -191,6 +191,59 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
}
}
+void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) {
+ Ref<InputEventKey> k = p_event;
+ if (k.is_valid() && k->is_pressed()) {
+ double step = get_step();
+ double real_step = step;
+ if (step < 1) {
+ double divisor = 1.0 / get_step();
+
+ if (trunc(divisor) == divisor) {
+ step = 1.0;
+ }
+ }
+
+ if (k->is_ctrl_pressed()) {
+ step *= 100.0;
+ } else if (k->is_shift_pressed()) {
+ step *= 10.0;
+ } else if (k->is_alt_pressed()) {
+ step *= 0.1;
+ }
+
+ uint32_t code = k->get_keycode();
+ switch (code) {
+ case KEY_UP: {
+ _evaluate_input_text();
+
+ double last_value = get_value();
+ set_value(last_value + step);
+ double new_value = get_value();
+
+ if (new_value < CLAMP(last_value + step, get_min(), get_max())) {
+ set_value(last_value + real_step);
+ }
+
+ value_input->set_text(get_text_value());
+ } break;
+ case KEY_DOWN: {
+ _evaluate_input_text();
+
+ double last_value = get_value();
+ set_value(last_value - step);
+ double new_value = get_value();
+
+ if (new_value > CLAMP(last_value - step, get_min(), get_max())) {
+ set_value(last_value - real_step);
+ }
+
+ value_input->set_text(get_text_value());
+ } break;
+ }
+ }
+}
+
void EditorSpinSlider::_update_value_input_stylebox() {
if (!value_input) {
return;
@@ -585,11 +638,13 @@ void EditorSpinSlider::_ensure_input_popup() {
value_input_popup->connect("popup_hide", callable_mp(this, &EditorSpinSlider::_value_input_closed));
value_input->connect("text_submitted", callable_mp(this, &EditorSpinSlider::_value_input_submitted));
value_input->connect("focus_exited", callable_mp(this, &EditorSpinSlider::_value_focus_exited));
+ value_input->connect("gui_input", callable_mp(this, &EditorSpinSlider::_value_input_gui_input));
if (is_inside_tree()) {
_update_value_input_stylebox();
}
}
+
EditorSpinSlider::EditorSpinSlider() {
flat = false;
grabbing_spinner_attempt = false;
diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h
index 1bf8e8eef9..7e10764491 100644
--- a/editor/editor_spin_slider.h
+++ b/editor/editor_spin_slider.h
@@ -71,6 +71,7 @@ class EditorSpinSlider : public Range {
void _value_input_closed();
void _value_input_submitted(const String &);
void _value_focus_exited();
+ void _value_input_gui_input(const Ref<InputEvent> &p_event);
bool hide_slider;
bool flat;
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 6e5b94dc07..de1d7b5706 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1084,6 +1084,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("folded", "CodeEdit", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
theme->set_icon("can_fold", "CodeEdit", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
theme->set_icon("executing_line", "CodeEdit", theme->get_icon("MainPlay", "EditorIcons"));
+ theme->set_icon("breakpoint", "CodeEdit", theme->get_icon("Breakpoint", "EditorIcons"));
theme->set_constant("line_spacing", "CodeEdit", EDITOR_DEF("text_editor/appearance/whitespace/line_spacing", 6));
// H/VSplitContainer
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index b646b3361d..cb88e9d75e 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -743,7 +743,7 @@ void ExportTemplateManager::_notification(int p_what) {
current_missing_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
current_installed_label->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
- mirror_options_button->set_icon(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons")));
+ mirror_options_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 5dd5c050e0..28bbfc2eff 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1175,7 +1175,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
EditorData *ed = &editor->get_editor_data();
for (int j = 0; j < ed->get_edited_scene_count(); j++) {
if (ed->get_scene_path(j) == file_changed_paths[i]) {
- ed->get_edited_scene_root(j)->set_filename(new_item_path);
+ ed->get_edited_scene_root(j)->set_scene_file_path(new_item_path);
editor->save_layout();
break;
}
@@ -1260,7 +1260,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String>
continue;
}
- path = get_tree()->get_edited_scene_root()->get_filename();
+ path = get_tree()->get_edited_scene_root()->get_scene_file_path();
} else {
path = EditorNode::get_editor_data().get_scene_path(i);
}
@@ -1270,7 +1270,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String>
}
if (i == EditorNode::get_editor_data().get_edited_scene()) {
- get_tree()->get_edited_scene_root()->set_filename(path);
+ get_tree()->get_edited_scene_root()->set_scene_file_path(path);
} else {
EditorNode::get_editor_data().set_scene_path(i, path);
}
diff --git a/editor/icons/Breakpoint.svg b/editor/icons/Breakpoint.svg
new file mode 100644
index 0000000000..b95c2b511e
--- /dev/null
+++ b/editor/icons/Breakpoint.svg
@@ -0,0 +1 @@
+<svg enable-background="new 0 0 16 16" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m15 8c0 3.866-3.134 7-7 7s-7-3.134-7-7 3.134-7 7-7 7 3.134 7 7" fill="#e1e1e1"/><pathd="m12 8c0 2.209-1.791 4-4 4s-4-1.791-4-4 1.791-4 4-4 4 1.791 4 4" fill="#f6f6f6"/></svg>
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index c48d9bb117..2c9bc7dadf 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -980,6 +980,8 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/shadow_meshes", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lightmap_uv", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lods", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_split_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 25.0f));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_merge_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 60.0f));
} break;
case INTERNAL_IMPORT_CATEGORY_MATERIAL: {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "use_external/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
@@ -1259,6 +1261,8 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
//do mesh processing
bool generate_lods = p_generate_lods;
+ float split_angle = 25.0f;
+ float merge_angle = 60.0f;
bool create_shadow_meshes = p_create_shadow_meshes;
bool bake_lightmaps = p_light_bake_mode == LIGHT_BAKE_STATIC_LIGHTMAPS;
String save_to_file;
@@ -1301,6 +1305,14 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
}
}
+ if (mesh_settings.has("lods/normal_split_angle")) {
+ split_angle = mesh_settings["lods/normal_split_angle"];
+ }
+
+ if (mesh_settings.has("lods/normal_merge_angle")) {
+ merge_angle = mesh_settings["lods/normal_merge_angle"];
+ }
+
if (mesh_settings.has("save_to_file/enabled") && bool(mesh_settings["save_to_file/enabled"]) && mesh_settings.has("save_to_file/path")) {
save_to_file = mesh_settings["save_to_file/path"];
if (!save_to_file.is_resource_file()) {
@@ -1310,8 +1322,9 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
}
if (generate_lods) {
- src_mesh_node->get_mesh()->generate_lods();
+ src_mesh_node->get_mesh()->generate_lods(merge_angle, split_angle);
}
+
if (create_shadow_meshes) {
src_mesh_node->get_mesh()->create_shadow_mesh();
}
diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp
index 5e6dd08e79..f83a7d046a 100644
--- a/editor/import/scene_importer_mesh.cpp
+++ b/editor/import/scene_importer_mesh.cpp
@@ -30,11 +30,99 @@
#include "scene_importer_mesh.h"
-#include "core/math/math_defs.h"
+#include "core/math/random_pcg.h"
+#include "core/math/static_raycaster.h"
#include "scene/resources/surface_tool.h"
#include <cstdint>
+void EditorSceneImporterMesh::Surface::split_normals(const LocalVector<int> &p_indices, const LocalVector<Vector3> &p_normals) {
+ ERR_FAIL_COND(arrays.size() != RS::ARRAY_MAX);
+
+ const PackedVector3Array &vertices = arrays[RS::ARRAY_VERTEX];
+ int current_vertex_count = vertices.size();
+ int new_vertex_count = p_indices.size();
+ int final_vertex_count = current_vertex_count + new_vertex_count;
+ const int *indices_ptr = p_indices.ptr();
+
+ for (int i = 0; i < arrays.size(); i++) {
+ if (i == RS::ARRAY_INDEX) {
+ continue;
+ }
+
+ if (arrays[i].get_type() == Variant::NIL) {
+ continue;
+ }
+
+ switch (arrays[i].get_type()) {
+ case Variant::PACKED_VECTOR3_ARRAY: {
+ PackedVector3Array data = arrays[i];
+ data.resize(final_vertex_count);
+ Vector3 *data_ptr = data.ptrw();
+ if (i == RS::ARRAY_NORMAL) {
+ const Vector3 *normals_ptr = p_normals.ptr();
+ memcpy(&data_ptr[current_vertex_count], normals_ptr, sizeof(Vector3) * new_vertex_count);
+ } else {
+ for (int j = 0; j < new_vertex_count; j++) {
+ data_ptr[current_vertex_count + j] = data_ptr[indices_ptr[j]];
+ }
+ }
+ arrays[i] = data;
+ } break;
+ case Variant::PACKED_VECTOR2_ARRAY: {
+ PackedVector2Array data = arrays[i];
+ data.resize(final_vertex_count);
+ Vector2 *data_ptr = data.ptrw();
+ for (int j = 0; j < new_vertex_count; j++) {
+ data_ptr[current_vertex_count + j] = data_ptr[indices_ptr[j]];
+ }
+ arrays[i] = data;
+ } break;
+ case Variant::PACKED_FLOAT32_ARRAY: {
+ PackedFloat32Array data = arrays[i];
+ int elements = data.size() / current_vertex_count;
+ data.resize(final_vertex_count * elements);
+ float *data_ptr = data.ptrw();
+ for (int j = 0; j < new_vertex_count; j++) {
+ memcpy(&data_ptr[(current_vertex_count + j) * elements], &data_ptr[indices_ptr[j] * elements], sizeof(float) * elements);
+ }
+ arrays[i] = data;
+ } break;
+ case Variant::PACKED_INT32_ARRAY: {
+ PackedInt32Array data = arrays[i];
+ int elements = data.size() / current_vertex_count;
+ data.resize(final_vertex_count * elements);
+ int32_t *data_ptr = data.ptrw();
+ for (int j = 0; j < new_vertex_count; j++) {
+ memcpy(&data_ptr[(current_vertex_count + j) * elements], &data_ptr[indices_ptr[j] * elements], sizeof(int32_t) * elements);
+ }
+ arrays[i] = data;
+ } break;
+ case Variant::PACKED_BYTE_ARRAY: {
+ PackedByteArray data = arrays[i];
+ int elements = data.size() / current_vertex_count;
+ data.resize(final_vertex_count * elements);
+ uint8_t *data_ptr = data.ptrw();
+ for (int j = 0; j < new_vertex_count; j++) {
+ memcpy(&data_ptr[(current_vertex_count + j) * elements], &data_ptr[indices_ptr[j] * elements], sizeof(uint8_t) * elements);
+ }
+ arrays[i] = data;
+ } break;
+ case Variant::PACKED_COLOR_ARRAY: {
+ PackedColorArray data = arrays[i];
+ data.resize(final_vertex_count);
+ Color *data_ptr = data.ptrw();
+ for (int j = 0; j < new_vertex_count; j++) {
+ data_ptr[current_vertex_count + j] = data_ptr[indices_ptr[j]];
+ }
+ } break;
+ default: {
+ ERR_FAIL_MSG("Uhandled array type.");
+ } break;
+ }
+ }
+}
+
void EditorSceneImporterMesh::add_blend_shape(const String &p_name) {
ERR_FAIL_COND(surfaces.size() > 0);
blend_shapes.push_back(p_name);
@@ -157,29 +245,14 @@ void EditorSceneImporterMesh::set_surface_material(int p_surface, const Ref<Mate
mesh.unref();
}
-Basis EditorSceneImporterMesh::compute_rotation_matrix_from_ortho_6d(Vector3 p_x_raw, Vector3 p_y_raw) {
- Vector3 x = p_x_raw.normalized();
- Vector3 z = x.cross(p_y_raw);
- z = z.normalized();
- Vector3 y = z.cross(x);
- Basis basis;
- basis.set_axis(Vector3::AXIS_X, x);
- basis.set_axis(Vector3::AXIS_Y, y);
- basis.set_axis(Vector3::AXIS_Z, z);
- return basis;
-}
-
-void EditorSceneImporterMesh::generate_lods() {
- if (!SurfaceTool::simplify_func) {
- return;
- }
+void EditorSceneImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_split_angle) {
if (!SurfaceTool::simplify_scale_func) {
return;
}
- if (!SurfaceTool::simplify_sloppy_func) {
+ if (!SurfaceTool::simplify_with_attrib_func) {
return;
}
- if (!SurfaceTool::simplify_with_attrib_func) {
+ if (!SurfaceTool::optimize_vertex_cache_func) {
return;
}
@@ -190,67 +263,343 @@ void EditorSceneImporterMesh::generate_lods() {
surfaces.write[i].lods.clear();
Vector<Vector3> vertices = surfaces[i].arrays[RS::ARRAY_VERTEX];
- Vector<int> indices = surfaces[i].arrays[RS::ARRAY_INDEX];
- if (indices.size() == 0) {
+ PackedInt32Array indices = surfaces[i].arrays[RS::ARRAY_INDEX];
+ Vector<Vector3> normals = surfaces[i].arrays[RS::ARRAY_NORMAL];
+ Vector<Vector2> uvs = surfaces[i].arrays[RS::ARRAY_TEX_UV];
+
+ unsigned int index_count = indices.size();
+ unsigned int vertex_count = vertices.size();
+
+ if (index_count == 0) {
continue; //no lods if no indices
}
- Vector<Vector3> normals = surfaces[i].arrays[RS::ARRAY_NORMAL];
- uint32_t vertex_count = vertices.size();
+
const Vector3 *vertices_ptr = vertices.ptr();
- Vector<float> attributes;
- Vector<float> normal_weights;
- int32_t attribute_count = 6;
- if (normals.size()) {
- attributes.resize(normals.size() * attribute_count);
- for (int32_t normal_i = 0; normal_i < normals.size(); normal_i++) {
- Basis basis;
- basis.set_euler(normals[normal_i]);
- Vector3 basis_x = basis.get_axis(0);
- Vector3 basis_y = basis.get_axis(1);
- basis = compute_rotation_matrix_from_ortho_6d(basis_x, basis_y);
- basis_x = basis.get_axis(0);
- basis_y = basis.get_axis(1);
- attributes.write[normal_i * attribute_count + 0] = basis_x.x;
- attributes.write[normal_i * attribute_count + 1] = basis_x.y;
- attributes.write[normal_i * attribute_count + 2] = basis_x.z;
- attributes.write[normal_i * attribute_count + 3] = basis_y.x;
- attributes.write[normal_i * attribute_count + 4] = basis_y.y;
- attributes.write[normal_i * attribute_count + 5] = basis_y.z;
- }
- normal_weights.resize(vertex_count);
- for (int32_t weight_i = 0; weight_i < normal_weights.size(); weight_i++) {
- normal_weights.write[weight_i] = 1.0;
+ const int *indices_ptr = indices.ptr();
+
+ if (normals.is_empty()) {
+ normals.resize(vertices.size());
+ Vector3 *n_ptr = normals.ptrw();
+ for (unsigned int j = 0; j < index_count; j += 3) {
+ const Vector3 &v0 = vertices_ptr[indices_ptr[j + 0]];
+ const Vector3 &v1 = vertices_ptr[indices_ptr[j + 1]];
+ const Vector3 &v2 = vertices_ptr[indices_ptr[j + 2]];
+ Vector3 n = vec3_cross(v0 - v2, v0 - v1).normalized();
+ n_ptr[j + 0] = n;
+ n_ptr[j + 1] = n;
+ n_ptr[j + 2] = n;
}
- } else {
- attribute_count = 0;
}
- const int min_indices = 10;
- const float error_tolerance = 1.44224'95703; // Cube root of 3
- const float threshold = 1.0 / error_tolerance;
- int index_target = indices.size() * threshold;
- float max_mesh_error_percentage = 1e0f;
+
+ float normal_merge_threshold = Math::cos(Math::deg2rad(p_normal_merge_angle));
+ float normal_pre_split_threshold = Math::cos(Math::deg2rad(MIN(180.0f, p_normal_split_angle * 2.0f)));
+ float normal_split_threshold = Math::cos(Math::deg2rad(p_normal_split_angle));
+ const Vector3 *normals_ptr = normals.ptr();
+
+ Map<Vector3, LocalVector<Pair<int, int>>> unique_vertices;
+
+ LocalVector<int> vertex_remap;
+ LocalVector<int> vertex_inverse_remap;
+ LocalVector<Vector3> merged_vertices;
+ LocalVector<Vector3> merged_normals;
+ LocalVector<int> merged_normals_counts;
+ const Vector2 *uvs_ptr = uvs.ptr();
+
+ for (unsigned int j = 0; j < vertex_count; j++) {
+ const Vector3 &v = vertices_ptr[j];
+ const Vector3 &n = normals_ptr[j];
+
+ Map<Vector3, LocalVector<Pair<int, int>>>::Element *E = unique_vertices.find(v);
+
+ if (E) {
+ const LocalVector<Pair<int, int>> &close_verts = E->get();
+
+ bool found = false;
+ for (unsigned int k = 0; k < close_verts.size(); k++) {
+ const Pair<int, int> &idx = close_verts[k];
+
+ // TODO check more attributes?
+ if ((!uvs_ptr || uvs_ptr[j].distance_squared_to(uvs_ptr[idx.second]) < CMP_EPSILON2) && normals[idx.second].dot(n) > normal_merge_threshold) {
+ vertex_remap.push_back(idx.first);
+ merged_normals[idx.first] += normals[idx.second];
+ merged_normals_counts[idx.first]++;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ int vcount = merged_vertices.size();
+ unique_vertices[v].push_back(Pair<int, int>(vcount, j));
+ vertex_inverse_remap.push_back(j);
+ merged_vertices.push_back(v);
+ vertex_remap.push_back(vcount);
+ merged_normals.push_back(normals_ptr[j]);
+ merged_normals_counts.push_back(1);
+ }
+ } else {
+ int vcount = merged_vertices.size();
+ unique_vertices[v] = LocalVector<Pair<int, int>>();
+ unique_vertices[v].push_back(Pair<int, int>(vcount, j));
+ vertex_inverse_remap.push_back(j);
+ merged_vertices.push_back(v);
+ vertex_remap.push_back(vcount);
+ merged_normals.push_back(normals_ptr[j]);
+ merged_normals_counts.push_back(1);
+ }
+ }
+
+ LocalVector<int> merged_indices;
+ merged_indices.resize(index_count);
+ for (unsigned int j = 0; j < index_count; j++) {
+ merged_indices[j] = vertex_remap[indices[j]];
+ }
+
+ unsigned int merged_vertex_count = merged_vertices.size();
+ const Vector3 *merged_vertices_ptr = merged_vertices.ptr();
+ const int32_t *merged_indices_ptr = merged_indices.ptr();
+
+ {
+ const int *counts_ptr = merged_normals_counts.ptr();
+ Vector3 *merged_normals_ptrw = merged_normals.ptr();
+ for (unsigned int j = 0; j < merged_vertex_count; j++) {
+ merged_normals_ptrw[j] /= counts_ptr[j];
+ }
+ }
+
+ LocalVector<float> normal_weights;
+ normal_weights.resize(merged_vertex_count);
+ for (unsigned int j = 0; j < merged_vertex_count; j++) {
+ normal_weights[j] = 2.0; // Give some weight to normal preservation, may be worth exposing as an import setting
+ }
+
+ const float max_mesh_error = FLT_MAX; // We don't want to limit by error, just by index target
+ float scale = SurfaceTool::simplify_scale_func((const float *)merged_vertices_ptr, merged_vertex_count, sizeof(Vector3));
float mesh_error = 0.0f;
- float scale = SurfaceTool::simplify_scale_func((const float *)vertices_ptr, vertex_count, sizeof(Vector3));
- while (index_target > min_indices) {
- Vector<int> new_indices;
- new_indices.resize(indices.size());
- size_t new_len = SurfaceTool::simplify_with_attrib_func((unsigned int *)new_indices.ptrw(), (const unsigned int *)indices.ptr(), indices.size(), (const float *)vertices_ptr, vertex_count, sizeof(Vector3), index_target, max_mesh_error_percentage, &mesh_error, (float *)attributes.ptrw(), normal_weights.ptrw(), attribute_count);
- if ((int)new_len > (index_target * error_tolerance)) {
- break;
+
+ unsigned int index_target = 12; // Start with the smallest target, 4 triangles
+ unsigned int last_index_count = 0;
+
+ int split_vertex_count = vertex_count;
+ LocalVector<Vector3> split_vertex_normals;
+ LocalVector<int> split_vertex_indices;
+ split_vertex_normals.reserve(index_count / 3);
+ split_vertex_indices.reserve(index_count / 3);
+
+ RandomPCG pcg;
+ pcg.seed(123456789); // Keep seed constant across imports
+
+ Ref<StaticRaycaster> raycaster = StaticRaycaster::create();
+ if (raycaster.is_valid()) {
+ raycaster->add_mesh(vertices, indices, 0);
+ raycaster->commit();
+ }
+
+ while (index_target < index_count) {
+ PackedInt32Array new_indices;
+ new_indices.resize(index_count);
+
+ size_t new_index_count = SurfaceTool::simplify_with_attrib_func((unsigned int *)new_indices.ptrw(), (const uint32_t *)merged_indices_ptr, index_count, (const float *)merged_vertices_ptr, merged_vertex_count, sizeof(Vector3), index_target, max_mesh_error, &mesh_error, (float *)merged_normals.ptr(), normal_weights.ptr(), 3);
+
+ if (new_index_count < last_index_count * 1.5f) {
+ index_target = index_target * 1.5f;
+ continue;
}
- Surface::LOD lod;
- lod.distance = mesh_error * scale;
- if (Math::is_zero_approx(mesh_error)) {
+
+ if (new_index_count <= 0 || (new_index_count >= (index_count * 0.75f))) {
break;
}
- if (new_len <= 0) {
- break;
+
+ new_indices.resize(new_index_count);
+
+ LocalVector<LocalVector<int>> vertex_corners;
+ vertex_corners.resize(vertex_count);
+ {
+ int *ptrw = new_indices.ptrw();
+ for (unsigned int j = 0; j < new_index_count; j++) {
+ const int &remapped = vertex_inverse_remap[ptrw[j]];
+ vertex_corners[remapped].push_back(j);
+ ptrw[j] = remapped;
+ }
}
- new_indices.resize(new_len);
+
+ if (raycaster.is_valid()) {
+ float error_factor = 1.0f / (scale * MAX(mesh_error, 0.15));
+ const float ray_bias = 0.05;
+ float ray_length = ray_bias + mesh_error * scale * 3.0f;
+
+ Vector<StaticRaycaster::Ray> rays;
+ LocalVector<Vector2> ray_uvs;
+
+ int32_t *new_indices_ptr = new_indices.ptrw();
+
+ int current_ray_count = 0;
+ for (unsigned int j = 0; j < new_index_count; j += 3) {
+ const Vector3 &v0 = vertices_ptr[new_indices_ptr[j + 0]];
+ const Vector3 &v1 = vertices_ptr[new_indices_ptr[j + 1]];
+ const Vector3 &v2 = vertices_ptr[new_indices_ptr[j + 2]];
+ Vector3 face_normal = vec3_cross(v0 - v2, v0 - v1);
+ float face_area = face_normal.length(); // Actually twice the face area, since it's the same error_factor on all faces, we don't care
+
+ Vector3 dir = face_normal / face_area;
+ int ray_count = CLAMP(5.0 * face_area * error_factor, 16, 64);
+
+ rays.resize(current_ray_count + ray_count);
+ StaticRaycaster::Ray *rays_ptr = rays.ptrw();
+
+ ray_uvs.resize(current_ray_count + ray_count);
+ Vector2 *ray_uvs_ptr = ray_uvs.ptr();
+
+ for (int k = 0; k < ray_count; k++) {
+ float u = pcg.randf();
+ float v = pcg.randf();
+
+ if (u + v >= 1.0f) {
+ u = 1.0f - u;
+ v = 1.0f - v;
+ }
+
+ u = 0.9f * u + 0.05f / 3.0f; // Give barycentric coordinates some padding, we don't want to sample right on the edge
+ v = 0.9f * v + 0.05f / 3.0f; // v = (v - one_third) * 0.95f + one_third;
+ float w = 1.0f - u - v;
+
+ Vector3 org = v0 * w + v1 * u + v2 * v;
+ org -= dir * ray_bias;
+ rays_ptr[current_ray_count + k] = StaticRaycaster::Ray(org, dir, 0.0f, ray_length);
+ rays_ptr[current_ray_count + k].id = j / 3;
+ ray_uvs_ptr[current_ray_count + k] = Vector2(u, v);
+ }
+
+ current_ray_count += ray_count;
+ }
+
+ raycaster->intersect(rays);
+
+ LocalVector<Vector3> ray_normals;
+ LocalVector<float> ray_normal_weights;
+
+ ray_normals.resize(new_index_count);
+ ray_normal_weights.resize(new_index_count);
+
+ for (unsigned int j = 0; j < new_index_count; j++) {
+ ray_normal_weights[j] = 0.0f;
+ }
+
+ const StaticRaycaster::Ray *rp = rays.ptr();
+ for (int j = 0; j < rays.size(); j++) {
+ if (rp[j].geomID != 0) { // Ray missed
+ continue;
+ }
+
+ if (rp[j].normal.normalized().dot(rp[j].dir) > 0.0f) { // Hit a back face.
+ continue;
+ }
+
+ const float &u = rp[j].u;
+ const float &v = rp[j].v;
+ const float w = 1.0f - u - v;
+
+ const unsigned int &hit_tri_id = rp[j].primID;
+ const unsigned int &orig_tri_id = rp[j].id;
+
+ const Vector3 &n0 = normals_ptr[indices_ptr[hit_tri_id * 3 + 0]];
+ const Vector3 &n1 = normals_ptr[indices_ptr[hit_tri_id * 3 + 1]];
+ const Vector3 &n2 = normals_ptr[indices_ptr[hit_tri_id * 3 + 2]];
+ Vector3 normal = n0 * w + n1 * u + n2 * v;
+
+ Vector2 orig_uv = ray_uvs[j];
+ float orig_bary[3] = { 1.0f - orig_uv.x - orig_uv.y, orig_uv.x, orig_uv.y };
+ for (int k = 0; k < 3; k++) {
+ int idx = orig_tri_id * 3 + k;
+ float weight = orig_bary[k];
+ ray_normals[idx] += normal * weight;
+ ray_normal_weights[idx] += weight;
+ }
+ }
+
+ for (unsigned int j = 0; j < new_index_count; j++) {
+ if (ray_normal_weights[j] < 1.0f) { // Not enough data, the new normal would be just a bad guess
+ ray_normals[j] = Vector3();
+ } else {
+ ray_normals[j] /= ray_normal_weights[j];
+ }
+ }
+
+ LocalVector<LocalVector<int>> normal_group_indices;
+ LocalVector<Vector3> normal_group_averages;
+ normal_group_indices.reserve(24);
+ normal_group_averages.reserve(24);
+
+ for (unsigned int j = 0; j < vertex_count; j++) {
+ const LocalVector<int> &corners = vertex_corners[j];
+ const Vector3 &vertex_normal = normals_ptr[j];
+
+ for (unsigned int k = 0; k < corners.size(); k++) {
+ const int &corner_idx = corners[k];
+ const Vector3 &ray_normal = ray_normals[corner_idx];
+
+ if (ray_normal.length_squared() < CMP_EPSILON2) {
+ continue;
+ }
+
+ bool found = false;
+ for (unsigned int l = 0; l < normal_group_indices.size(); l++) {
+ LocalVector<int> &group_indices = normal_group_indices[l];
+ Vector3 n = normal_group_averages[l] / group_indices.size();
+ if (n.dot(ray_normal) > normal_pre_split_threshold) {
+ found = true;
+ group_indices.push_back(corner_idx);
+ normal_group_averages[l] += ray_normal;
+ break;
+ }
+ }
+
+ if (!found) {
+ LocalVector<int> new_group;
+ new_group.push_back(corner_idx);
+ normal_group_indices.push_back(new_group);
+ normal_group_averages.push_back(ray_normal);
+ }
+ }
+
+ for (unsigned int k = 0; k < normal_group_indices.size(); k++) {
+ LocalVector<int> &group_indices = normal_group_indices[k];
+ Vector3 n = normal_group_averages[k] / group_indices.size();
+
+ if (vertex_normal.dot(n) < normal_split_threshold) {
+ split_vertex_indices.push_back(j);
+ split_vertex_normals.push_back(n);
+ int new_idx = split_vertex_count++;
+ for (unsigned int l = 0; l < group_indices.size(); l++) {
+ new_indices_ptr[group_indices[l]] = new_idx;
+ }
+ }
+ }
+
+ normal_group_indices.clear();
+ normal_group_averages.clear();
+ }
+ }
+
+ Surface::LOD lod;
+ lod.distance = MAX(mesh_error * scale, CMP_EPSILON2);
lod.indices = new_indices;
- print_line("Lod " + itos(surfaces.write[i].lods.size()) + " begin with " + itos(indices.size() / 3) + " triangles and shoot for " + itos(index_target / 3) + " triangles. Got " + itos(new_len / 3) + " triangles. Lod screen ratio " + rtos(lod.distance));
surfaces.write[i].lods.push_back(lod);
- index_target *= threshold;
+ index_target = MAX(new_index_count, index_target) * 2;
+ last_index_count = new_index_count;
+
+ if (mesh_error == 0.0f) {
+ break;
+ }
+ }
+
+ surfaces.write[i].split_normals(split_vertex_indices, split_vertex_normals);
+ surfaces.write[i].lods.sort_custom<Surface::LODComparator>();
+
+ for (int j = 0; j < surfaces.write[i].lods.size(); j++) {
+ Surface::LOD &lod = surfaces.write[i].lods.write[j];
+ unsigned int *lod_indices_ptr = (unsigned int *)lod.indices.ptrw();
+ SurfaceTool::optimize_vertex_cache_func(lod_indices_ptr, lod_indices_ptr, lod.indices.size(), split_vertex_count);
}
}
}
@@ -347,7 +696,7 @@ void EditorSceneImporterMesh::create_shadow_mesh() {
Map<Vector3, int> unique_vertices;
const Vector3 *vptr = vertices.ptr();
for (int j = 0; j < vertex_count; j++) {
- Vector3 v = vptr[j];
+ const Vector3 &v = vptr[j];
Map<Vector3, int>::Element *E = unique_vertices.find(v);
@@ -397,9 +746,9 @@ void EditorSceneImporterMesh::create_shadow_mesh() {
index_wptr = new_indices.ptrw();
for (int k = 0; k < index_count; k++) {
- int index = index_rptr[j];
+ int index = index_rptr[k];
ERR_FAIL_INDEX(index, vertex_count);
- index_wptr[j] = vertex_remap[index];
+ index_wptr[k] = vertex_remap[index];
}
lods[surfaces[i].lods[j].distance] = new_indices;
@@ -436,9 +785,9 @@ void EditorSceneImporterMesh::_set_data(const Dictionary &p_data) {
if (s.has("lods")) {
lods = s["lods"];
}
- Array blend_shapes;
- if (s.has("blend_shapes")) {
- blend_shapes = s["blend_shapes"];
+ Array b_shapes;
+ if (s.has("b_shapes")) {
+ b_shapes = s["b_shapes"];
}
Ref<Material> material;
if (s.has("material")) {
@@ -448,7 +797,7 @@ void EditorSceneImporterMesh::_set_data(const Dictionary &p_data) {
if (s.has("flags")) {
flags = s["flags"];
}
- add_surface(prim, arr, blend_shapes, lods, material, name, flags);
+ add_surface(prim, arr, b_shapes, lods, material, name, flags);
}
}
}
diff --git a/editor/import/scene_importer_mesh.h b/editor/import/scene_importer_mesh.h
index d32b1fdf74..111b191cae 100644
--- a/editor/import/scene_importer_mesh.h
+++ b/editor/import/scene_importer_mesh.h
@@ -32,6 +32,7 @@
#define EDITOR_SCENE_IMPORTER_MESH_H
#include "core/io/resource.h"
+#include "core/templates/local_vector.h"
#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_3d.h"
#include "scene/resources/mesh.h"
@@ -55,12 +56,20 @@ class EditorSceneImporterMesh : public Resource {
Vector<BlendShape> blend_shape_data;
struct LOD {
Vector<int> indices;
- float distance;
+ float distance = 0.0f;
};
Vector<LOD> lods;
Ref<Material> material;
String name;
uint32_t flags = 0;
+
+ struct LODComparator {
+ _FORCE_INLINE_ bool operator()(const LOD &l, const LOD &r) const {
+ return l.distance < r.distance;
+ }
+ };
+
+ void split_normals(const LocalVector<int> &p_indices, const LocalVector<Vector3> &p_normals);
};
Vector<Surface> surfaces;
Vector<String> blend_shapes;
@@ -71,7 +80,6 @@ class EditorSceneImporterMesh : public Resource {
Ref<EditorSceneImporterMesh> shadow_mesh;
Size2i lightmap_size_hint;
- Basis compute_rotation_matrix_from_ortho_6d(Vector3 p_x_raw, Vector3 y_raw);
protected:
void _set_data(const Dictionary &p_data);
@@ -103,7 +111,7 @@ public:
void set_surface_material(int p_surface, const Ref<Material> &p_material);
- void generate_lods();
+ void generate_lods(float p_normal_merge_angle, float p_normal_split_angle);
void create_shadow_mesh();
Ref<EditorSceneImporterMesh> get_shadow_mesh() const;
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 49fcac512b..686a35e442 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -129,8 +129,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
add_point_pos += blend_space->get_min_space();
if (snap->is_pressed()) {
- add_point_pos.x = Math::snapped(add_point_pos.x, blend_space->get_snap().x);
- add_point_pos.y = Math::snapped(add_point_pos.y, blend_space->get_snap().y);
+ add_point_pos = add_point_pos.snapped(blend_space->get_snap());
}
}
@@ -215,8 +214,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
Vector2 point = blend_space->get_blend_point_position(selected_point);
point += drag_ofs;
if (snap->is_pressed()) {
- point.x = Math::snapped(point.x, blend_space->get_snap().x);
- point.y = Math::snapped(point.y, blend_space->get_snap().y);
+ point = point.snapped(blend_space->get_snap());
}
updating = true;
@@ -467,8 +465,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (dragging_selected && selected_point == point_idx) {
point += drag_ofs;
if (snap->is_pressed()) {
- point.x = Math::snapped(point.x, blend_space->get_snap().x);
- point.y = Math::snapped(point.y, blend_space->get_snap().y);
+ point = point.snapped(blend_space->get_snap());
}
}
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
@@ -503,8 +500,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (dragging_selected && selected_point == i) {
point += drag_ofs;
if (snap->is_pressed()) {
- point.x = Math::snapped(point.x, blend_space->get_snap().x);
- point.y = Math::snapped(point.y, blend_space->get_snap().y);
+ point = point.snapped(blend_space->get_snap());
}
}
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
@@ -702,8 +698,7 @@ void AnimationNodeBlendSpace2DEditor::_update_edited_point_pos() {
if (dragging_selected) {
pos += drag_ofs;
if (snap->is_pressed()) {
- pos.x = Math::snapped(pos.x, blend_space->get_snap().x);
- pos.y = Math::snapped(pos.y, blend_space->get_snap().y);
+ pos = pos.snapped(blend_space->get_snap());
}
}
updating = true;
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 1758ba7048..a42bdfea34 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1460,8 +1460,8 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
- if (canvas_item->get_filename() != "" && canvas_item != editor->get_edited_scene()) {
- editor->open_request(canvas_item->get_filename());
+ if (canvas_item->get_scene_file_path() != "" && canvas_item != editor->get_edited_scene()) {
+ editor->open_request(canvas_item->get_scene_file_path());
return true;
}
}
@@ -2927,7 +2927,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_string(font, text_pos, TS->format_number(vformat("%.1f px", length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color);
if (draw_secondary_lines) {
- const real_t horizontal_angle_rad = atan2(length_vector.y, length_vector.x);
+ const real_t horizontal_angle_rad = length_vector.angle();
const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad;
const int horizontal_angle = round(180 * horizontal_angle_rad / Math_PI);
const int vertical_angle = round(180 * vertical_angle_rad / Math_PI);
@@ -4898,8 +4898,7 @@ void CanvasItemEditor::_focus_selection(int p_op) {
if (p_op == VIEW_CENTER_TO_SELECTION) {
center = rect.get_center();
Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center);
- view_offset.x -= Math::round(offset.x / zoom);
- view_offset.y -= Math::round(offset.y / zoom);
+ view_offset -= (offset / zoom).round();
update_viewport();
} else { // VIEW_FRAME_TO_SELECTION
@@ -5801,7 +5800,7 @@ void CanvasItemEditorViewport::_remove_preview() {
}
bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
- if (p_desired_node->get_filename() == p_target_scene_path) {
+ if (p_desired_node->get_scene_file_path() == p_target_scene_path) {
return true;
}
@@ -5898,14 +5897,14 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons
return false;
}
- if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
- if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instantiated_scene)) {
+ if (editor->get_edited_scene()->get_scene_file_path() != "") { // cyclical instancing
+ if (_cyclical_dependency_exists(editor->get_edited_scene()->get_scene_file_path(), instantiated_scene)) {
memdelete(instantiated_scene);
return false;
}
}
- instantiated_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
+ instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(path));
editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene);
editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_owner", editor->get_edited_scene());
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index 903a3689b0..5ac58795d1 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -362,6 +362,7 @@ void GPUParticles3DEditor::_generate_emission_points() {
Ref<ImageTexture> tex;
tex.instantiate();
+ tex->create_from_image(image);
Ref<ParticlesMaterial> material = node->get_process_material();
ERR_FAIL_COND(material.is_null());
@@ -390,6 +391,7 @@ void GPUParticles3DEditor::_generate_emission_points() {
Ref<ImageTexture> tex2;
tex2.instantiate();
+ tex2->create_from_image(image2);
material->set_emission_normal_texture(tex2);
} else {
diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
index a4436525fb..6df2e34ceb 100644
--- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
@@ -33,7 +33,7 @@
void GPUParticlesCollisionSDFEditorPlugin::_bake() {
if (col_sdf) {
if (col_sdf->get_texture().is_null() || !col_sdf->get_texture()->get_path().is_resource_file()) {
- String path = get_tree()->get_edited_scene_root()->get_filename();
+ String path = get_tree()->get_edited_scene_root()->get_scene_file_path();
if (path == String()) {
path = "res://" + col_sdf->get_name() + "_data.exr";
} else {
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index 3207a989bd..16cafda899 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -244,6 +244,7 @@ void ItemListEditor::_node_removed(Node *p_node) {
void ItemListEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) {
add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ clear_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
del_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
} else if (p_notification == NOTIFICATION_READY) {
get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed));
@@ -258,6 +259,12 @@ void ItemListEditor::_add_pressed() {
item_plugins[selected_idx]->add_item();
}
+void ItemListEditor::_clear_pressed() {
+ for (int i = item_plugins[selected_idx]->get_item_count() - 1; i >= 0; i--) {
+ item_plugins[selected_idx]->erase(i);
+ }
+}
+
void ItemListEditor::_delete_pressed() {
if (selected_idx == -1) {
return;
@@ -350,6 +357,11 @@ ItemListEditor::ItemListEditor() {
hbc->add_spacer();
+ clear_button = memnew(Button);
+ clear_button->set_text(TTR("Delete All"));
+ hbc->add_child(clear_button);
+ clear_button->connect("pressed", callable_mp(this, &ItemListEditor::_clear_pressed));
+
del_button = memnew(Button);
del_button->set_text(TTR("Delete"));
hbc->add_child(del_button);
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 8c77f3d952..8f61aef083 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -204,6 +204,7 @@ class ItemListEditor : public HBoxContainer {
Tree *tree;
Button *add_button;
Button *del_button;
+ Button *clear_button;
int selected_idx;
@@ -213,6 +214,7 @@ class ItemListEditor : public HBoxContainer {
void _add_pressed();
void _delete_pressed();
+ void _clear_pressed();
void _node_removed(Node *p_node);
diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp
index b4a70cd31d..123087446c 100644
--- a/editor/plugins/lightmap_gi_editor_plugin.cpp
+++ b/editor/plugins/lightmap_gi_editor_plugin.cpp
@@ -43,9 +43,9 @@ void LightmapGIEditorPlugin::_bake_select_file(const String &p_file) {
switch (err) {
case LightmapGI::BAKE_ERROR_NO_SAVE_PATH: {
- String scene_path = lightmap->get_filename();
+ String scene_path = lightmap->get_scene_file_path();
if (scene_path == String()) {
- scene_path = lightmap->get_owner()->get_filename();
+ scene_path = lightmap->get_owner()->get_scene_file_path();
}
if (scene_path == String()) {
EditorNode::get_singleton()->show_warning(TTR("Can't determine a save path for lightmap images.\nSave your scene and try again."));
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index d52a633fed..857190bc92 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2601,6 +2601,9 @@ void Node3DEditorViewport::_project_settings_changed() {
const bool use_occlusion_culling = GLOBAL_GET("rendering/occlusion_culling/use_occlusion_culling");
viewport->set_use_occlusion_culling(use_occlusion_culling);
+
+ const float lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels");
+ viewport->set_lod_threshold(lod_threshold);
}
void Node3DEditorViewport::_notification(int p_what) {
@@ -3917,7 +3920,7 @@ void Node3DEditorViewport::_remove_preview() {
}
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) {
+ if (p_desired_node->get_scene_file_path() == p_target_scene_path) {
return true;
}
@@ -3959,15 +3962,15 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
return false;
}
- if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
- if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instantiated_scene)) {
+ if (editor->get_edited_scene()->get_scene_file_path() != "") { // cyclical instancing
+ if (_cyclical_dependency_exists(editor->get_edited_scene()->get_scene_file_path(), instantiated_scene)) {
memdelete(instantiated_scene);
return false;
}
}
if (scene != nullptr) {
- instantiated_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
+ instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(path));
}
editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene);
@@ -6280,7 +6283,7 @@ void Node3DEditor::update_grid() {
// Gets a orthogonal or perspective position correctly (for the grid comparison)
const Vector3 camera_position = get_editor_viewport(0)->camera->get_position();
- if (!grid_init_draw || (camera_position - grid_camera_last_update_position).length() >= 10.0f) {
+ if (!grid_init_draw || grid_camera_last_update_position.distance_squared_to(camera_position) >= 100.0f) {
_finish_grid();
_init_grid();
grid_init_draw = true;
diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp
index ab88b9f00d..0328b1bea6 100644
--- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp
@@ -41,9 +41,9 @@ void OccluderInstance3DEditorPlugin::_bake_select_file(const String &p_file) {
switch (err) {
case OccluderInstance3D::BAKE_ERROR_NO_SAVE_PATH: {
- String scene_path = occluder_instance->get_filename();
+ String scene_path = occluder_instance->get_scene_file_path();
if (scene_path == String()) {
- scene_path = occluder_instance->get_owner()->get_filename();
+ scene_path = occluder_instance->get_owner()->get_scene_file_path();
}
if (scene_path == String()) {
EditorNode::get_singleton()->show_warning(TTR("Can't determine a save path for the occluder.\nSave your scene and try again."));
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index 13f7908170..bb0c270baa 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -510,7 +510,14 @@ void Path3DEditorPlugin::_close_curve() {
if (c->get_point_count() < 2) {
return;
}
- c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0));
+ if (c->get_point_position(0) == c->get_point_position(c->get_point_count() - 1)) {
+ return;
+ }
+ UndoRedo *ur = editor->get_undo_redo();
+ ur->create_action(TTR("Close Curve"));
+ ur->add_do_method(c.ptr(), "add_point", c->get_point_position(0), c->get_point_in(0), c->get_point_out(0), -1);
+ ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
+ ur->commit_action();
}
void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index ac18ff9f1c..5afe9ed60c 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -779,7 +779,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
if ((mm->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
- Vector2 drag(mm->get_relative().x, mm->get_relative().y);
+ Vector2 drag = mm->get_relative();
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
uv_vscroll->set_value(uv_vscroll->get_value() - drag.y);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 07e4d4ebf0..6922a48a50 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -2750,6 +2750,29 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
}
+void ScriptEditor::input(const Ref<InputEvent> &p_event) {
+ // This is implemented in `input()` rather than `unhandled_input()` to allow
+ // the shortcut to be used regardless of the click location.
+ // This feature can be disabled to avoid interfering with other uses of the additional
+ // mouse buttons, such as push-to-talk in a VoIP program.
+ if (EDITOR_GET("interface/editor/mouse_extra_buttons_navigate_history")) {
+ const Ref<InputEventMouseButton> mb = p_event;
+
+ // Navigate the script history using additional mouse buttons present on some mice.
+ // This must be hardcoded as the editor shortcuts dialog doesn't allow assigning
+ // more than one shortcut per action.
+ if (mb.is_valid() && mb->is_pressed() && is_visible_in_tree()) {
+ if (mb->get_button_index() == MOUSE_BUTTON_XBUTTON1) {
+ _history_back();
+ }
+
+ if (mb->get_button_index() == MOUSE_BUTTON_XBUTTON2) {
+ _history_forward();
+ }
+ }
+ }
+}
+
void ScriptEditor::unhandled_key_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
@@ -3294,7 +3317,6 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections);
ClassDB::bind_method("_help_class_open", &ScriptEditor::_help_class_open);
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
-
ClassDB::bind_method("_update_members_overview", &ScriptEditor::_update_members_overview);
ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts);
@@ -3427,9 +3449,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
ED_SHORTCUT("script_editor/window_sort", TTR("Sort"));
ED_SHORTCUT("script_editor/window_move_up", TTR("Move Up"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_UP);
ED_SHORTCUT("script_editor/window_move_down", TTR("Move Down"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_DOWN);
- ED_SHORTCUT("script_editor/next_script", TTR("Next Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work
+ // FIXME: These should be `KEY_GREATER` and `KEY_LESS` but those don't work.
+ ED_SHORTCUT("script_editor/next_script", TTR("Next Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD);
ED_SHORTCUT("script_editor/prev_script", TTR("Previous Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COMMA);
- set_process_unhandled_key_input(true);
+ set_process_input(true);
+ set_process_unhandled_input(true);
file_menu = memnew(MenuButton);
file_menu->set_text(TTR("File"));
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 7620605570..6d9b27e0be 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -418,6 +418,7 @@ class ScriptEditor : public PanelContainer {
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+ virtual void input(const Ref<InputEvent> &p_event) override;
virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override;
void _script_list_gui_input(const Ref<InputEvent> &ev);
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 44db06bcfd..b9ec6bf5ab 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -58,6 +58,21 @@ void TexturePreview::_notification(int p_what) {
}
}
+void TexturePreview::_update_metadata_label_text() {
+ Ref<Texture2D> texture = texture_display->get_texture();
+
+ String format;
+ if (Object::cast_to<ImageTexture>(*texture)) {
+ format = Image::get_format_name(Object::cast_to<ImageTexture>(*texture)->get_format());
+ } else if (Object::cast_to<StreamTexture2D>(*texture)) {
+ format = Image::get_format_name(Object::cast_to<StreamTexture2D>(*texture)->get_format());
+ } else {
+ format = texture->get_class();
+ }
+
+ metadata_label->set_text(itos(texture->get_width()) + "x" + itos(texture->get_height()) + " " + format);
+}
+
TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) {
checkerboard = memnew(TextureRect);
checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE);
@@ -75,16 +90,8 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) {
if (p_show_metadata) {
metadata_label = memnew(Label);
- String format;
- if (Object::cast_to<ImageTexture>(*p_texture)) {
- format = Image::get_format_name(Object::cast_to<ImageTexture>(*p_texture)->get_format());
- } else if (Object::cast_to<StreamTexture2D>(*p_texture)) {
- format = Image::get_format_name(Object::cast_to<StreamTexture2D>(*p_texture)->get_format());
- } else {
- format = p_texture->get_class();
- }
-
- metadata_label->set_text(itos(p_texture->get_width()) + "x" + itos(p_texture->get_height()) + " " + format);
+ _update_metadata_label_text();
+ p_texture->connect("changed", callable_mp(this, &TexturePreview::_update_metadata_label_text));
// It's okay that these colors are static since the grid color is static too.
metadata_label->add_theme_color_override("font_color", Color::named("white"));
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index 36a5513ea6..60349febd7 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -44,6 +44,8 @@ private:
TextureRect *checkerboard = nullptr;
Label *metadata_label = nullptr;
+ void _update_metadata_label_text();
+
protected:
void _notification(int p_what);
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index cfb2d63bc7..ce90d61616 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -50,7 +50,7 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5),
Math::round(2 * EDSCALE));
- while ((to - from).length_squared() > 200) {
+ while (from.distance_squared_to(to) > 200) {
edit_draw->draw_line(
from,
from + line,
@@ -674,8 +674,7 @@ void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
draw_zoom = p_zoom;
Point2 ofs = p_position;
ofs = ofs / prev_zoom - ofs / draw_zoom;
- draw_ofs.x = Math::round(draw_ofs.x + ofs.x);
- draw_ofs.y = Math::round(draw_ofs.y + ofs.y);
+ draw_ofs = (draw_ofs + ofs).round();
edit_draw->update();
}
diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp
index 801ee0eac2..d26d0ec39d 100644
--- a/editor/plugins/theme_editor_preview.cpp
+++ b/editor/plugins/theme_editor_preview.cpp
@@ -126,8 +126,8 @@ void ThemeEditorPreview::_draw_picker_overlay() {
highlight_label_rect.size.x += margin_left + margin_right;
highlight_label_rect.size.y += margin_top + margin_bottom;
- highlight_label_rect.position.x = CLAMP(highlight_label_rect.position.x, 0.0, picker_overlay->get_size().width);
- highlight_label_rect.position.y = CLAMP(highlight_label_rect.position.y, 0.0, picker_overlay->get_size().height);
+ highlight_label_rect.position = highlight_label_rect.position.clamp(Vector2(), picker_overlay->get_size());
+
picker_overlay->draw_style_box(theme_cache.preview_picker_label, highlight_label_rect);
Point2 label_pos = highlight_label_rect.position;
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index ea7ca787c8..5f72cfe313 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -231,10 +231,14 @@ void GenericTilePolygonEditor::_zoom_changed() {
void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
switch (p_item_pressed) {
- case RESET_TO_DEFAULT_TILE:
+ case RESET_TO_DEFAULT_TILE: {
undo_redo->create_action(TTR("Edit Polygons"));
undo_redo->add_do_method(this, "clear_polygons");
- undo_redo->add_do_method(this, "add_polygon", tile_set->get_tile_shape_polygon());
+ Vector<Vector2> polygon = tile_set->get_tile_shape_polygon();
+ for (int i = 0; i < polygon.size(); i++) {
+ polygon.write[i] = polygon[i] * tile_set->get_tile_size();
+ }
+ undo_redo->add_do_method(this, "add_polygon", polygon);
undo_redo->add_do_method(base_control, "update");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
undo_redo->add_undo_method(this, "clear_polygons");
@@ -244,8 +248,8 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
undo_redo->add_undo_method(base_control, "update");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
undo_redo->commit_action(true);
- break;
- case CLEAR_TILE:
+ } break;
+ case CLEAR_TILE: {
undo_redo->create_action(TTR("Edit Polygons"));
undo_redo->add_do_method(this, "clear_polygons");
undo_redo->add_do_method(base_control, "update");
@@ -257,7 +261,7 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
undo_redo->add_undo_method(base_control, "update");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
undo_redo->commit_action(true);
- break;
+ } break;
default:
break;
}
@@ -308,6 +312,9 @@ void GenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_cur
ERR_FAIL_COND(!tile_set.is_valid());
Vector<Point2> polygon = tile_set->get_tile_shape_polygon();
+ for (int i = 0; i < polygon.size(); i++) {
+ polygon.write[i] = polygon[i] * tile_set->get_tile_size();
+ }
Point2 snapped_point = r_point;
// Snap to polygon vertices.
@@ -539,7 +546,11 @@ void GenericTilePolygonEditor::set_tile_set(Ref<TileSet> p_tile_set) {
// Set the default tile shape
clear_polygons();
if (p_tile_set.is_valid()) {
- add_polygon(p_tile_set->get_tile_shape_polygon());
+ Vector<Vector2> polygon = p_tile_set->get_tile_shape_polygon();
+ for (int i = 0; i < polygon.size(); i++) {
+ polygon.write[i] = polygon[i] * p_tile_set->get_tile_size();
+ }
+ add_polygon(polygon);
}
}
tile_set = p_tile_set;
@@ -622,7 +633,7 @@ void GenericTilePolygonEditor::_notification(int p_what) {
button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons")));
button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons")));
button_pixel_snap->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Snap"), SNAME("EditorIcons")));
- button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons")));
+ button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
break;
}
}
@@ -1265,17 +1276,21 @@ void TileDataCollisionEditor::_polygons_changed() {
}
Variant TileDataCollisionEditor::_get_painted_value() {
+ Dictionary dict;
+ dict["linear_velocity"] = dummy_object->get("linear_velocity");
+ dict["angular_velocity"] = dummy_object->get("angular_velocity");
Array array;
for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
ERR_FAIL_COND_V(polygon_editor->get_polygon(i).size() < 3, Variant());
- Dictionary dict;
- dict["points"] = polygon_editor->get_polygon(i);
- dict["one_way"] = dummy_object->get(vformat("polygon_%d_one_way", i));
- dict["one_way_margin"] = dummy_object->get(vformat("polygon_%d_one_way_margin", i));
- array.push_back(dict);
+ Dictionary polygon_dict;
+ polygon_dict["points"] = polygon_editor->get_polygon(i);
+ polygon_dict["one_way"] = dummy_object->get(vformat("polygon_%d_one_way", i));
+ polygon_dict["one_way_margin"] = dummy_object->get(vformat("polygon_%d_one_way_margin", i));
+ array.push_back(polygon_dict);
}
+ dict["polygons"] = array;
- return array;
+ return dict;
}
void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) {
@@ -1291,6 +1306,8 @@ void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_
}
_polygons_changed();
+ dummy_object->set("linear_velocity", tile_data->get_constant_linear_velocity(physics_layer));
+ dummy_object->set("angular_velocity", tile_data->get_constant_angular_velocity(physics_layer));
for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) {
dummy_object->set(vformat("polygon_%d_one_way", i), tile_data->is_collision_polygon_one_way(physics_layer, i));
dummy_object->set(vformat("polygon_%d_one_way_margin", i), tile_data->get_collision_polygon_one_way_margin(physics_layer, i));
@@ -1306,13 +1323,16 @@ void TileDataCollisionEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_so
TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
ERR_FAIL_COND(!tile_data);
- Array array = p_value;
+ Dictionary dict = p_value;
+ tile_data->set_constant_linear_velocity(physics_layer, dict["linear_velocity"]);
+ tile_data->set_constant_angular_velocity(physics_layer, dict["angular_velocity"]);
+ Array array = dict["polygons"];
tile_data->set_collision_polygons_count(physics_layer, array.size());
for (int i = 0; i < array.size(); i++) {
- Dictionary dict = array[i];
- tile_data->set_collision_polygon_points(physics_layer, i, dict["points"]);
- tile_data->set_collision_polygon_one_way(physics_layer, i, dict["one_way"]);
- tile_data->set_collision_polygon_one_way_margin(physics_layer, i, dict["one_way_margin"]);
+ Dictionary polygon_dict = array[i];
+ tile_data->set_collision_polygon_points(physics_layer, i, polygon_dict["points"]);
+ tile_data->set_collision_polygon_one_way(physics_layer, i, polygon_dict["one_way"]);
+ tile_data->set_collision_polygon_one_way_margin(physics_layer, i, polygon_dict["one_way_margin"]);
}
polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
@@ -1322,15 +1342,19 @@ Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas
TileData *tile_data = Object::cast_to<TileData>(p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile));
ERR_FAIL_COND_V(!tile_data, Variant());
+ Dictionary dict;
+ dict["linear_velocity"] = tile_data->get_constant_linear_velocity(physics_layer);
+ dict["angular_velocity"] = tile_data->get_constant_angular_velocity(physics_layer);
Array array;
for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) {
- Dictionary dict;
- dict["points"] = tile_data->get_collision_polygon_points(physics_layer, i);
- dict["one_way"] = tile_data->is_collision_polygon_one_way(physics_layer, i);
- dict["one_way_margin"] = tile_data->get_collision_polygon_one_way_margin(physics_layer, i);
- array.push_back(dict);
+ Dictionary polygon_dict;
+ polygon_dict["points"] = tile_data->get_collision_polygon_points(physics_layer, i);
+ polygon_dict["one_way"] = tile_data->is_collision_polygon_one_way(physics_layer, i);
+ polygon_dict["one_way_margin"] = tile_data->get_collision_polygon_one_way_margin(physics_layer, i);
+ array.push_back(polygon_dict);
}
- return array;
+ dict["polygons"] = array;
+ return dict;
}
void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) {
@@ -1378,6 +1402,27 @@ TileDataCollisionEditor::TileDataCollisionEditor() {
polygon_editor->connect("polygons_changed", callable_mp(this, &TileDataCollisionEditor::_polygons_changed));
add_child(polygon_editor);
+ dummy_object->add_dummy_property("linear_velocity");
+ dummy_object->set("linear_velocity", Vector2());
+ dummy_object->add_dummy_property("angular_velocity");
+ dummy_object->set("angular_velocity", 0.0);
+
+ EditorProperty *linear_velocity_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::VECTOR2, "linear_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ linear_velocity_editor->set_object_and_property(dummy_object, "linear_velocity");
+ linear_velocity_editor->set_label("linear_velocity");
+ linear_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
+ linear_velocity_editor->update_property();
+ add_child(linear_velocity_editor);
+ property_editors["linear_velocity"] = linear_velocity_editor;
+
+ EditorProperty *angular_velocity_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::FLOAT, "angular_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ angular_velocity_editor->set_object_and_property(dummy_object, "angular_velocity");
+ angular_velocity_editor->set_label("angular_velocity");
+ angular_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
+ angular_velocity_editor->update_property();
+ add_child(angular_velocity_editor);
+ property_editors["angular_velocity"] = linear_velocity_editor;
+
_polygons_changed();
}
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 8b5b576369..a248f23517 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -1041,7 +1041,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i
TypedArray<Vector2i> to_check;
if (source.source_id == TileSet::INVALID_SOURCE) {
Rect2i rect = tile_map->get_used_rect();
- if (rect.size.x <= 0 || rect.size.y <= 0) {
+ if (rect.has_no_area()) {
rect = Rect2i(p_coords, Vector2i(1, 1));
}
for (int x = boundaries.position.x; x < boundaries.get_end().x; x++) {
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 54185d1d2a..1f1408016b 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -87,7 +87,7 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list
p_list->push_back(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, ""));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "separation", PROPERTY_HINT_NONE, ""));
- p_list->push_back(PropertyInfo(Variant::VECTOR2I, "tile_size", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2I, "texture_region_size", PROPERTY_HINT_NONE, ""));
}
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() {
@@ -926,11 +926,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven
can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
}
for (int i = 0; i < 4; i++) {
- Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
+ Vector2 pos = rect.position + rect.size * coords[i];
if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) {
cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE;
}
- Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
+ Vector2 next_pos = rect.position + rect.size * coords[(i + 1) % 4];
if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) {
cursor_shape = (i % 2) ? CURSOR_HSIZE : CURSOR_VSIZE;
}
@@ -1136,7 +1136,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven
can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
}
for (int i = 0; i < 4; i++) {
- Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
+ Vector2 pos = rect.position + rect.size * coords[i];
if (can_grow[i] && can_grow[(i + 3) % 4] && Rect2(pos, zoomed_size).has_point(mouse_local_pos)) {
drag_type = (DragType)((int)DRAG_TYPE_RESIZE_TOP_LEFT + i * 2);
drag_start_mouse_pos = mouse_local_pos;
@@ -1145,7 +1145,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven
drag_start_tile_shape = Rect2i(selected.tile, tile_set_atlas_source->get_tile_size_in_atlas(selected.tile));
cursor_shape = (i % 2) ? CURSOR_BDIAGSIZE : CURSOR_FDIAGSIZE;
}
- Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
+ Vector2 next_pos = rect.position + rect.size * coords[(i + 1) % 4];
if (can_grow[i] && Rect2((pos + next_pos) / 2.0, zoomed_size).has_point(mouse_local_pos)) {
drag_type = (DragType)((int)DRAG_TYPE_RESIZE_TOP + i * 2);
drag_start_mouse_pos = mouse_local_pos;
@@ -1614,13 +1614,13 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() {
can_grow[i] |= (i % 2 == 0) ? size_in_atlas.y > 1 : size_in_atlas.x > 1;
}
for (int i = 0; i < 4; i++) {
- Vector2 pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[i];
+ Vector2 pos = rect.position + rect.size * coords[i];
if (can_grow[i] && can_grow[(i + 3) % 4]) {
tile_atlas_control->draw_texture_rect(resize_handle, Rect2(pos, zoomed_size), false);
} else {
tile_atlas_control->draw_texture_rect(resize_handle_disabled, Rect2(pos, zoomed_size), false);
}
- Vector2 next_pos = rect.position + Vector2(rect.size.x, rect.size.y) * coords[(i + 1) % 4];
+ Vector2 next_pos = rect.position + rect.size * coords[(i + 1) % 4];
if (can_grow[i]) {
tile_atlas_control->draw_texture_rect(resize_handle, Rect2((pos + next_pos) / 2.0, zoomed_size), false);
} else {
@@ -1946,6 +1946,11 @@ void TileSetAtlasSourceEditor::_tile_set_atlas_source_changed() {
tile_set_atlas_source_changed_needs_update = true;
}
+void TileSetAtlasSourceEditor::_tile_proxy_object_changed(String p_what) {
+ tile_set_atlas_source_changed_needs_update = false; // Avoid updating too many things.
+ _update_atlas_view();
+}
+
void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) {
if (p_what == "texture" && !atlas_source_proxy_object->get("texture").is_null()) {
confirm_auto_create_tiles->popup_centered();
@@ -2206,7 +2211,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
middle_vbox_container->add_child(tile_inspector_label);
tile_proxy_object = memnew(AtlasTileProxyObject(this));
- tile_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view).unbind(1));
+ tile_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_proxy_object_changed));
tile_inspector = memnew(EditorInspector);
tile_inspector->set_undo_redo(undo_redo);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h
index 501416c340..6448b55feb 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.h
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h
@@ -264,6 +264,7 @@ private:
AcceptDialog *confirm_auto_create_tiles;
void _tile_set_atlas_source_changed();
+ void _tile_proxy_object_changed(String p_what);
void _atlas_source_proxy_object_changed(String p_what);
void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value);
diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp
index 5bbc0c9dd5..9a44d40dcb 100644
--- a/editor/plugins/voxel_gi_editor_plugin.cpp
+++ b/editor/plugins/voxel_gi_editor_plugin.cpp
@@ -33,7 +33,7 @@
void VoxelGIEditorPlugin::_bake() {
if (voxel_gi) {
if (voxel_gi->get_probe_data().is_null()) {
- String path = get_tree()->get_edited_scene_root()->get_filename();
+ String path = get_tree()->get_edited_scene_root()->get_scene_file_path();
if (path == String()) {
path = "res://" + voxel_gi->get_name() + "_data.res";
} else {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 4bc0905163..d2e8880bf9 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -187,8 +187,8 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N
break;
}
- if (edited_scene->get_filename() != "") {
- if (_cyclical_dependency_exists(edited_scene->get_filename(), instantiated_scene)) {
+ if (edited_scene->get_scene_file_path() != "") {
+ if (_cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_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();
error = true;
@@ -196,7 +196,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N
}
}
- instantiated_scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_files[i]));
+ instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(p_files[i]));
instances.push_back(instantiated_scene);
}
@@ -307,7 +307,7 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
bool result = false;
Vector<Node *> instances;
while (true) {
- if (p->get_filename() == p_target_scene_path) {
+ if (p->get_scene_file_path() == p_target_scene_path) {
result = true;
break;
}
@@ -442,7 +442,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!node_clipboard.is_empty()) {
_clear_clipboard();
}
- clipboard_source_scene = editor->get_edited_scene()->get_filename();
+ clipboard_source_scene = editor->get_edited_scene()->get_scene_file_path();
selection.sort_custom<Node::Comparator>();
@@ -465,9 +465,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
bool has_cycle = false;
- if (edited_scene->get_filename() != String()) {
+ if (edited_scene->get_scene_file_path() != String()) {
for (Node *E : node_clipboard) {
- if (edited_scene->get_filename() == E->get_filename()) {
+ if (edited_scene->get_scene_file_path() == E->get_scene_file_path()) {
has_cycle = true;
break;
}
@@ -496,7 +496,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
Map<RES, RES> resource_remap;
- String target_scene = editor->get_edited_scene()->get_filename();
+ String target_scene = editor->get_edited_scene()->get_scene_file_path();
if (target_scene != clipboard_source_scene) {
if (!clipboard_resource_remap.has(target_scene)) {
Map<RES, RES> remap;
@@ -808,7 +808,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
return;
}
- if (node->get_filename() != String()) {
+ if (node->get_scene_file_path() != String()) {
accept->set_text(TTR("Instantiated scenes can't become root"));
accept->popup_centered();
return;
@@ -818,14 +818,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", node);
editor_data->get_undo_redo().add_do_method(node, "add_child", root);
- editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename());
- editor_data->get_undo_redo().add_do_method(root, "set_filename", String());
+ editor_data->get_undo_redo().add_do_method(node, "set_scene_file_path", root->get_scene_file_path());
+ editor_data->get_undo_redo().add_do_method(root, "set_scene_file_path", String());
editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)nullptr);
editor_data->get_undo_redo().add_do_method(root, "set_owner", node);
_node_replace_owner(root, root, node, MODE_DO);
- editor_data->get_undo_redo().add_undo_method(root, "set_filename", root->get_filename());
- editor_data->get_undo_redo().add_undo_method(node, "set_filename", String());
+ editor_data->get_undo_redo().add_undo_method(root, "set_scene_file_path", root->get_scene_file_path());
+ editor_data->get_undo_redo().add_undo_method(node, "set_scene_file_path", String());
editor_data->get_undo_redo().add_undo_method(node, "remove_child", root);
editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root);
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
@@ -848,7 +848,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
Ref<MultiNodeEdit> mne = memnew(MultiNodeEdit);
- for (const Map<Node *, Object *>::Element *E = EditorNode::get_singleton()->get_editor_selection()->get_selection().front(); E; E = E->next()) {
+ for (const Map<Node *, Object *>::Element *E = editor_selection->get_selection().front(); E; E = E->next()) {
mne->add_node(root->get_path_to(E->key()));
}
@@ -887,7 +887,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *node = remove_list[0];
if (node == editor_data->get_edited_scene_root()) {
msg = vformat(TTR("Delete the root node \"%s\"?"), node->get_name());
- } else if (node->get_filename() == "" && node->get_child_count() > 0) {
+ } else if (node->get_scene_file_path() == "" && node->get_child_count() > 0) {
// Display this message only for non-instantiated scenes
msg = vformat(TTR("Delete node \"%s\" and its children?"), node->get_name());
} else {
@@ -934,7 +934,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
- if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_filename() != "") {
+ if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_scene_file_path() != "") {
accept->set_text(TTR("Can't save the branch of an already instantiated scene.\nTo create a variation of a scene, you can make an inherited scene based on the instantiated scene using Scene > New Inherited Scene... instead."));
accept->popup_centered();
break;
@@ -1047,10 +1047,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
- ERR_FAIL_COND(node->get_filename() == String());
+ ERR_FAIL_COND(node->get_scene_file_path() == String());
undo_redo->create_action(TTR("Make Local"));
- undo_redo->add_do_method(node, "set_filename", "");
- undo_redo->add_undo_method(node, "set_filename", node->get_filename());
+ undo_redo->add_do_method(node, "set_scene_file_path", "");
+ undo_redo->add_undo_method(node, "set_scene_file_path", node->get_scene_file_path());
_node_replace_owner(node, node, root);
undo_redo->add_do_method(scene_tree, "update_tree");
undo_redo->add_undo_method(scene_tree, "update_tree");
@@ -1064,7 +1064,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (e) {
Node *node = e->get();
if (node) {
- scene_tree->emit_signal(SNAME("open"), node->get_filename());
+ scene_tree->emit_signal(SNAME("open"), node->get_scene_file_path());
}
}
} break;
@@ -1694,7 +1694,7 @@ bool SceneTreeDock::_validate_no_instance() {
List<Node *> selection = editor_selection->get_selected_node_list();
for (Node *E : selection) {
- if (E != edited_scene && E->get_filename() != "") {
+ if (E != edited_scene && E->get_scene_file_path() != "") {
accept->set_text(TTR("This operation can't be done on instantiated scenes."));
accept->popup_centered();
return false;
@@ -2101,11 +2101,11 @@ void SceneTreeDock::_update_script_button() {
if (!profile_allow_script_editing) {
button_create_script->hide();
button_detach_script->hide();
- } else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 0) {
+ } else if (editor_selection->get_selection().size() == 0) {
button_create_script->hide();
button_detach_script->hide();
- } else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
- Node *n = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0];
+ } else if (editor_selection->get_selection().size() == 1) {
+ Node *n = editor_selection->get_selected_node_list()[0];
if (n->get_script().is_null()) {
button_create_script->show();
button_detach_script->hide();
@@ -2128,10 +2128,12 @@ void SceneTreeDock::_update_script_button() {
}
void SceneTreeDock::_selection_changed() {
- int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
+ int selection_size = editor_selection->get_selection().size();
if (selection_size > 1) {
//automatically turn on multi-edit
_tool_selected(TOOL_MULTI_EDIT);
+ } else if (selection_size == 1) {
+ editor->push_item(editor_selection->get_selection().front()->key());
} else if (selection_size == 0) {
editor->push_item(nullptr);
}
@@ -2751,7 +2753,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
bool can_replace = true;
for (Node *E : selection) {
- if (E != edited_scene && (E->get_owner() != edited_scene || E->get_filename() != "")) {
+ if (E != edited_scene && (E->get_owner() != edited_scene || E->get_scene_file_path() != "")) {
can_replace = false;
break;
}
@@ -2783,7 +2785,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
}
- bool is_external = (selection[0]->get_filename() != "");
+ bool is_external = (selection[0]->get_scene_file_path() != "");
if (is_external) {
bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr;
bool is_top_level = selection[0]->get_owner() == nullptr;
@@ -2883,9 +2885,9 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) {
Ref<Script> existing = selected->get_script();
- String path = selected->get_filename();
+ String path = selected->get_scene_file_path();
if (path == "") {
- String root_path = editor_data->get_edited_scene_root()->get_filename();
+ String root_path = editor_data->get_edited_scene_root()->get_scene_file_path();
if (root_path == "") {
path = String("res://").plus_file(selected->get_name());
} else {
@@ -2937,7 +2939,7 @@ void SceneTreeDock::attach_shader_to_selected() {
if (path == "") {
String root_path;
if (editor_data->get_edited_scene_root()) {
- root_path = editor_data->get_edited_scene_root()->get_filename();
+ root_path = editor_data->get_edited_scene_root()->get_scene_file_path();
}
String shader_name;
if (selected_shader_material->get_name().is_empty()) {
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 3de87d9df7..ccca01ed8b 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -66,7 +66,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
emit_signal(SNAME("open"), n->get_scene_inherited_state()->get_path());
}
} else {
- emit_signal(SNAME("open"), n->get_filename());
+ emit_signal(SNAME("open"), n->get_scene_file_path());
}
} else if (p_id == BUTTON_SCRIPT) {
Ref<Script> script_typed = n->get_script();
@@ -302,10 +302,10 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
}
item->set_tooltip(0, tooltip);
- } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) {
+ } else if (p_node != get_scene_node() && p_node->get_scene_file_path() != "" && can_open_instance) {
item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
- String tooltip = String(p_node->get_name()) + "\n" + TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class();
+ String tooltip = String(p_node->get_name()) + "\n" + TTR("Instance:") + " " + p_node->get_scene_file_path() + "\n" + TTR("Type:") + " " + p_node->get_class();
if (p_node->get_editor_description() != String()) {
tooltip += "\n\n" + p_node->get_editor_description();
}
@@ -954,7 +954,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
Node *n = get_node(np);
if (n) {
// Only allow selection if not part of an instantiated scene.
- if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_filename() == String()) {
+ if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path() == String()) {
selected.push_back(n);
icons.push_back(next->get_icon(0));
}
diff --git a/main/main.cpp b/main/main.cpp
index fc24010e7b..7d7c9d7374 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1721,8 +1721,10 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
}
#ifdef TOOLS_ENABLED
- Ref<Image> icon = memnew(Image(app_icon_png));
- DisplayServer::get_singleton()->set_icon(icon);
+ if (OS::get_singleton()->get_bundle_icon_path().is_empty()) {
+ Ref<Image> icon = memnew(Image(app_icon_png));
+ DisplayServer::get_singleton()->set_icon(icon);
+ }
#endif
}
@@ -2440,7 +2442,7 @@ bool Main::start() {
#endif
}
- if (!hasicon) {
+ if (!hasicon && OS::get_singleton()->get_bundle_icon_path().is_empty()) {
Ref<Image> icon = memnew(Image(app_icon_png));
DisplayServer::get_singleton()->set_icon(icon);
}
@@ -2689,8 +2691,9 @@ void Main::cleanup(bool p_force) {
rendering_server->global_variables_clear();
if (xr_server) {
- // cleanup now before we pull the rug from underneath...
- memdelete(xr_server);
+ // Now that we're unregistering properly in plugins we need to keep access to xr_server for a little longer
+ // We do however unset our primary interface
+ xr_server->set_primary_interface(Ref<XRInterface>());
}
unregister_driver_types();
@@ -2706,6 +2709,10 @@ void Main::cleanup(bool p_force) {
unregister_scene_types();
unregister_server_types();
+ if (xr_server) {
+ memdelete(xr_server);
+ }
+
if (audio_server) {
audio_server->finish();
memdelete(audio_server);
diff --git a/methods.py b/methods.py
index 50b413a0e6..0e71adb40d 100644
--- a/methods.py
+++ b/methods.py
@@ -56,6 +56,17 @@ def disable_warnings(self):
self.Append(CXXFLAGS=["-w"])
+def force_optimization_on_debug(self):
+ # 'self' is the environment
+ if self["target"] != "debug":
+ return
+
+ if self.msvc:
+ self.Append(CCFLAGS=["/O2"])
+ else:
+ self.Append(CCFLAGS=["-O3"])
+
+
def add_module_version_string(self, s):
self.module_version_string += "." + s
diff --git a/misc/dist/osx_tools.app/Contents/Resources/Godot.icns b/misc/dist/osx_tools.app/Contents/Resources/Godot.icns
index be9254630c..61697976c6 100644
--- a/misc/dist/osx_tools.app/Contents/Resources/Godot.icns
+++ b/misc/dist/osx_tools.app/Contents/Resources/Godot.icns
Binary files differ
diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub
index ba57de303e..09509abc44 100644
--- a/modules/bullet/SCsub
+++ b/modules/bullet/SCsub
@@ -10,7 +10,7 @@ env_bullet = env_modules.Clone()
thirdparty_obj = []
if env["builtin_bullet"]:
- # Build only version 2 for now (as of 2.89)
+ # Build only "Bullet2" API (not "Bullet3" folders).
# Sync file list with relevant upstream CMakeLists.txt for each folder.
if env["float"] == "64":
env.Append(CPPDEFINES=["BT_USE_DOUBLE_PRECISION=1"])
@@ -189,6 +189,7 @@ if env["builtin_bullet"]:
"LinearMath/btGeometryUtil.cpp",
"LinearMath/btPolarDecomposition.cpp",
"LinearMath/btQuickprof.cpp",
+ "LinearMath/btReducedVector.cpp",
"LinearMath/btSerializer.cpp",
"LinearMath/btSerializer64.cpp",
"LinearMath/btThreads.cpp",
@@ -200,15 +201,11 @@ if env["builtin_bullet"]:
thirdparty_sources = [thirdparty_dir + file for file in bullet2_src]
- # Treat Bullet headers as system headers to avoid raising warnings. Not supported on MSVC.
- if not env.msvc:
- env_bullet.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
- else:
- env_bullet.Prepend(CPPPATH=[thirdparty_dir])
+ env_bullet.Prepend(CPPPATH=[thirdparty_dir])
if env["target"] == "debug" or env["target"] == "release_debug":
env_bullet.Append(CPPDEFINES=["DEBUG"])
- env_bullet.Append(CPPDEFINES=["BT_USE_OLD_DAMPING_METHOD"])
+ env_bullet.Append(CPPDEFINES=["BT_USE_OLD_DAMPING_METHOD", "BT_THREADSAFE"])
env_thirdparty = env_bullet.Clone()
env_thirdparty.disable_warnings()
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index ed05e51e53..3054debaec 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -124,7 +124,7 @@ RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) {
}
void BulletPhysicsServer3D::shape_set_data(RID p_shape, const Variant &p_data) {
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
}
@@ -134,25 +134,25 @@ void BulletPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_b
}
PhysicsServer3D::ShapeType BulletPhysicsServer3D::shape_get_type(RID p_shape) const {
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, PhysicsServer3D::SHAPE_CUSTOM);
return shape->get_type();
}
Variant BulletPhysicsServer3D::shape_get_data(RID p_shape) const {
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
return shape->get_data();
}
void BulletPhysicsServer3D::shape_set_margin(RID p_shape, real_t p_margin) {
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_margin(p_margin);
}
real_t BulletPhysicsServer3D::shape_get_margin(RID p_shape) const {
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0.0);
return shape->get_margin();
}
@@ -168,7 +168,7 @@ RID BulletPhysicsServer3D::space_create() {
}
void BulletPhysicsServer3D::space_set_active(RID p_space, bool p_active) {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
if (space_is_active(p_space) == p_active) {
@@ -185,47 +185,47 @@ void BulletPhysicsServer3D::space_set_active(RID p_space, bool p_active) {
}
bool BulletPhysicsServer3D::space_is_active(RID p_space) const {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, false);
return -1 != active_spaces.find(space);
}
void BulletPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
real_t BulletPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
PhysicsDirectSpaceState3D *BulletPhysicsServer3D::space_get_direct_state(RID p_space) {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, nullptr);
return space->get_direct_state();
}
void BulletPhysicsServer3D::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector3> BulletPhysicsServer3D::space_get_contacts(RID p_space) const {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector3>());
return space->get_debug_contacts();
}
int BulletPhysicsServer3D::space_get_contact_count(RID p_space) const {
- SpaceBullet *space = space_owner.getornull(p_space);
+ SpaceBullet *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
@@ -239,91 +239,91 @@ RID BulletPhysicsServer3D::area_create() {
}
void BulletPhysicsServer3D::area_set_space(RID p_area, RID p_space) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
SpaceBullet *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
area->set_space(space);
}
RID BulletPhysicsServer3D::area_get_space(RID p_area) const {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
return area->get_space()->get_self();
}
void BulletPhysicsServer3D::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_spOv_mode(p_mode);
}
PhysicsServer3D::AreaSpaceOverrideMode BulletPhysicsServer3D::area_get_space_override_mode(RID p_area) const {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED);
return area->get_spOv_mode();
}
void BulletPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform, bool p_disabled) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
area->add_shape(shape, p_transform, p_disabled);
}
void BulletPhysicsServer3D::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
area->set_shape(p_shape_idx, shape);
}
void BulletPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
int BulletPhysicsServer3D::area_get_shape_count(RID p_area) const {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, 0);
return area->get_shape_count();
}
RID BulletPhysicsServer3D::area_get_shape(RID p_area, int p_shape_idx) const {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
return area->get_shape(p_shape_idx)->get_self();
}
Transform3D BulletPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform3D());
return area->get_shape_transform(p_shape_idx);
}
void BulletPhysicsServer3D::area_remove_shape(RID p_area, int p_shape_idx) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
return area->remove_shape_full(p_shape_idx);
}
void BulletPhysicsServer3D::area_clear_shapes(RID p_area) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
for (int i = area->get_shape_count(); 0 < i; --i) {
@@ -332,7 +332,7 @@ void BulletPhysicsServer3D::area_clear_shapes(RID p_area) {
}
void BulletPhysicsServer3D::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_shape_disabled(p_shape_idx, p_disabled);
@@ -342,7 +342,7 @@ void BulletPhysicsServer3D::area_attach_object_instance_id(RID p_area, ObjectID
if (space_owner.owns(p_area)) {
return;
}
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
@@ -351,19 +351,19 @@ ObjectID BulletPhysicsServer3D::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
return ObjectID();
}
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_instance_id();
}
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);
+ SpaceBullet *space = space_owner.get_or_null(p_area);
if (space) {
space->set_param(p_param, p_value);
}
} else {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
@@ -372,10 +372,10 @@ void BulletPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, co
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);
+ SpaceBullet *space = space_owner.get_or_null(p_area);
return space->get_param(p_param);
} else {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
@@ -383,52 +383,52 @@ Variant BulletPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param)
}
void BulletPhysicsServer3D::area_set_transform(RID p_area, const Transform3D &p_transform) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
}
Transform3D BulletPhysicsServer3D::area_get_transform(RID p_area) const {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform3D());
return area->get_transform();
}
void BulletPhysicsServer3D::area_set_collision_mask(RID p_area, uint32_t p_mask) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
void BulletPhysicsServer3D::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
void BulletPhysicsServer3D::area_set_monitorable(RID p_area, bool p_monitorable) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_monitorable(p_monitorable);
}
void BulletPhysicsServer3D::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(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 BulletPhysicsServer3D::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
void BulletPhysicsServer3D::area_set_ray_pickable(RID p_area, bool p_enable) {
- AreaBullet *area = area_owner.getornull(p_area);
+ AreaBullet *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_ray_pickable(p_enable);
}
@@ -445,12 +445,12 @@ RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) {
}
void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
SpaceBullet *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -462,7 +462,7 @@ void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) {
}
RID BulletPhysicsServer3D::body_get_space(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
SpaceBullet *space = body->get_space();
@@ -473,52 +473,52 @@ RID BulletPhysicsServer3D::body_get_space(RID p_body) const {
}
void BulletPhysicsServer3D::body_set_mode(RID p_body, PhysicsServer3D::BodyMode p_mode) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_mode(p_mode);
}
PhysicsServer3D::BodyMode BulletPhysicsServer3D::body_get_mode(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
}
void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform, bool p_disabled) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
body->add_shape(shape, p_transform, p_disabled);
}
void BulletPhysicsServer3D::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- ShapeBullet *shape = shape_owner.getornull(p_shape);
+ ShapeBullet *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
body->set_shape(p_shape_idx, shape);
}
void BulletPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform3D &p_transform) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
int BulletPhysicsServer3D::body_get_shape_count(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_shape_count();
}
RID BulletPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
ShapeBullet *shape = body->get_shape(p_shape_idx);
@@ -528,27 +528,27 @@ RID BulletPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const {
}
Transform3D BulletPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Transform3D());
return body->get_shape_transform(p_shape_idx);
}
void BulletPhysicsServer3D::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_shape_disabled(p_shape_idx, p_disabled);
}
void BulletPhysicsServer3D::body_remove_shape(RID p_body, int p_shape_idx) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_shape_full(p_shape_idx);
}
void BulletPhysicsServer3D::body_clear_shapes(RID p_body) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_all_shapes();
@@ -569,42 +569,42 @@ ObjectID BulletPhysicsServer3D::body_get_object_instance_id(RID p_body) const {
}
void BulletPhysicsServer3D::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection(p_enable);
}
bool BulletPhysicsServer3D::body_is_continuous_collision_detection_enabled(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_continuous_collision_detection_enabled();
}
void BulletPhysicsServer3D::body_set_collision_layer(RID p_body, uint32_t p_layer) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
uint32_t BulletPhysicsServer3D::body_get_collision_layer(RID p_body) const {
- const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ const RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
void BulletPhysicsServer3D::body_set_collision_mask(RID p_body, uint32_t p_mask) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
uint32_t BulletPhysicsServer3D::body_get_collision_mask(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
@@ -620,21 +620,21 @@ uint32_t BulletPhysicsServer3D::body_get_user_flags(RID p_body) const {
}
void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
}
real_t BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
}
void BulletPhysicsServer3D::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
if (body->get_kinematic_utilities()) {
@@ -643,7 +643,7 @@ void BulletPhysicsServer3D::body_set_kinematic_safe_margin(RID p_body, real_t p_
}
real_t BulletPhysicsServer3D::body_get_kinematic_safe_margin(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
if (body->get_kinematic_utilities()) {
@@ -654,90 +654,90 @@ real_t BulletPhysicsServer3D::body_get_kinematic_safe_margin(RID p_body) const {
}
void BulletPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
}
Variant BulletPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
}
void BulletPhysicsServer3D::body_set_applied_force(RID p_body, const Vector3 &p_force) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
}
Vector3 BulletPhysicsServer3D::body_get_applied_force(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_force();
}
void BulletPhysicsServer3D::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
}
Vector3 BulletPhysicsServer3D::body_get_applied_torque(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_torque();
}
void BulletPhysicsServer3D::body_add_central_force(RID p_body, const Vector3 &p_force) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_central_force(p_force);
}
void BulletPhysicsServer3D::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_force(p_force, p_position);
}
void BulletPhysicsServer3D::body_add_torque(RID p_body, const Vector3 &p_torque) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_torque(p_torque);
}
void BulletPhysicsServer3D::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
}
void BulletPhysicsServer3D::body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_impulse(p_impulse, p_position);
}
void BulletPhysicsServer3D::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_torque_impulse(p_impulse);
}
void BulletPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
Vector3 v = body->get_linear_velocity();
@@ -748,39 +748,39 @@ void BulletPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_
}
void BulletPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_axis, p_lock);
}
bool BulletPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
- const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ const RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->is_axis_locked(p_axis);
}
void BulletPhysicsServer3D::body_add_collision_exception(RID p_body, RID p_body_b) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- RigidBodyBullet *other_body = rigid_body_owner.getornull(p_body_b);
+ RigidBodyBullet *other_body = rigid_body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!other_body);
body->add_collision_exception(other_body);
}
void BulletPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_body_b) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- RigidBodyBullet *other_body = rigid_body_owner.getornull(p_body_b);
+ RigidBodyBullet *other_body = rigid_body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!other_body);
body->remove_collision_exception(other_body);
}
void BulletPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
p_exceptions->push_back(body->get_exceptions()[i]);
@@ -788,14 +788,14 @@ void BulletPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID>
}
void BulletPhysicsServer3D::body_set_max_contacts_reported(RID p_body, int p_contacts) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_max_collisions_detection(p_contacts);
}
int BulletPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_max_collisions_detection();
@@ -811,39 +811,39 @@ real_t BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_b
}
void BulletPhysicsServer3D::body_set_omit_force_integration(RID p_body, bool p_omit) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_omit_forces_integration(p_omit);
}
bool BulletPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_forces_integration();
}
void BulletPhysicsServer3D::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_callable, p_udata);
}
void BulletPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_body) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, nullptr);
return BulletPhysicsDirectBodyState3D::get_singleton(body);
}
bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform3D &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes, const Set<RID> &p_exclude) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -851,7 +851,7 @@ bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform3D &p_fr
}
int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform3D &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
ERR_FAIL_COND_V(!body->get_space(), 0);
@@ -869,19 +869,19 @@ RID BulletPhysicsServer3D::soft_body_create(bool p_init_sleeping) {
}
void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, RenderingServerHandler *p_rendering_server_handler) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->update_rendering_server(p_rendering_server_handler);
}
void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
SpaceBullet *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -893,7 +893,7 @@ void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) {
}
RID BulletPhysicsServer3D::soft_body_get_space(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
SpaceBullet *space = body->get_space();
@@ -904,7 +904,7 @@ RID BulletPhysicsServer3D::soft_body_get_space(RID p_body) const {
}
void BulletPhysicsServer3D::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_soft_mesh(p_mesh);
@@ -918,40 +918,40 @@ AABB BulletPhysicsServer::soft_body_get_bounds(RID p_body) const {
}
void BulletPhysicsServer3D::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
uint32_t BulletPhysicsServer3D::soft_body_get_collision_layer(RID p_body) const {
- const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ const SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
void BulletPhysicsServer3D::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
uint32_t BulletPhysicsServer3D::soft_body_get_collision_mask(RID p_body) const {
- const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ const SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
void BulletPhysicsServer3D::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- CollisionObjectBullet *other_body = rigid_body_owner.getornull(p_body_b);
+ CollisionObjectBullet *other_body = rigid_body_owner.get_or_null(p_body_b);
if (!other_body) {
- other_body = soft_body_owner.getornull(p_body_b);
+ other_body = soft_body_owner.get_or_null(p_body_b);
}
ERR_FAIL_COND(!other_body);
@@ -959,12 +959,12 @@ void BulletPhysicsServer3D::soft_body_add_collision_exception(RID p_body, RID p_
}
void BulletPhysicsServer3D::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- CollisionObjectBullet *other_body = rigid_body_owner.getornull(p_body_b);
+ CollisionObjectBullet *other_body = rigid_body_owner.get_or_null(p_body_b);
if (!other_body) {
- other_body = soft_body_owner.getornull(p_body_b);
+ other_body = soft_body_owner.get_or_null(p_body_b);
}
ERR_FAIL_COND(!other_body);
@@ -972,7 +972,7 @@ void BulletPhysicsServer3D::soft_body_remove_collision_exception(RID p_body, RID
}
void BulletPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
p_exceptions->push_back(body->get_exceptions()[i]);
@@ -991,98 +991,98 @@ Variant BulletPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state
}
void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform3D &p_transform) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_soft_transform(p_transform);
}
void BulletPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
void BulletPhysicsServer3D::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_simulation_precision(p_simulation_precision);
}
int BulletPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_simulation_precision();
}
void BulletPhysicsServer3D::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_total_mass(p_total_mass);
}
real_t BulletPhysicsServer3D::soft_body_get_total_mass(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_total_mass();
}
void BulletPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_linear_stiffness(p_stiffness);
}
real_t BulletPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_linear_stiffness();
}
void BulletPhysicsServer3D::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_pressure_coefficient(p_pressure_coefficient);
}
real_t BulletPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pressure_coefficient();
}
void BulletPhysicsServer3D::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_damping_coefficient(p_damping_coefficient);
}
real_t BulletPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_damping_coefficient();
}
void BulletPhysicsServer3D::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_drag_coefficient(p_drag_coefficient);
}
real_t BulletPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_drag_coefficient();
}
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);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_node_position(p_point_index, p_global_position);
}
Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.));
Vector3 pos;
body->get_node_position(p_point_index, pos);
@@ -1090,25 +1090,25 @@ Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, i
}
void BulletPhysicsServer3D::soft_body_remove_all_pinned_points(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->reset_all_node_mass();
}
void BulletPhysicsServer3D::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_node_mass(p_point_index, p_pin ? 0 : 1);
}
bool BulletPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) const {
- SoftBodyBullet *body = soft_body_owner.getornull(p_body);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_node_mass(p_point_index);
}
PhysicsServer3D::JointType BulletPhysicsServer3D::joint_get_type(RID p_joint) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
return joint->get_type();
}
@@ -1123,28 +1123,28 @@ int BulletPhysicsServer3D::joint_get_solver_priority(RID p_joint) const {
}
void BulletPhysicsServer3D::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
}
bool BulletPhysicsServer3D::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- JointBullet *joint(joint_owner.getornull(p_joint));
+ JointBullet *joint(joint_owner.get_or_null(p_joint));
ERR_FAIL_COND_V(!joint, false);
return joint->is_disabled_collisions_between_bodies();
}
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);
+ RigidBodyBullet *body_A = rigid_body_owner.get_or_null(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.getornull(p_body_B);
+ body_B = rigid_body_owner.get_or_null(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1158,7 +1158,7 @@ RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local
}
void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1166,7 +1166,7 @@ void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_par
}
real_t BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1174,7 +1174,7 @@ real_t BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_p
}
void BulletPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1182,7 +1182,7 @@ void BulletPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_
}
Vector3 BulletPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1190,7 +1190,7 @@ Vector3 BulletPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
}
void BulletPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1198,7 +1198,7 @@ void BulletPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_
}
Vector3 BulletPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1206,13 +1206,13 @@ Vector3 BulletPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
}
RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform3D &p_hinge_A, RID p_body_B, const Transform3D &p_hinge_B) {
- RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.get_or_null(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.getornull(p_body_B);
+ body_B = rigid_body_owner.get_or_null(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1226,13 +1226,13 @@ RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform3D &p
}
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);
+ RigidBodyBullet *body_A = rigid_body_owner.get_or_null(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.getornull(p_body_B);
+ body_B = rigid_body_owner.get_or_null(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1246,7 +1246,7 @@ RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3
}
void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1254,7 +1254,7 @@ void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p
}
real_t BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1262,7 +1262,7 @@ real_t BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam
}
void BulletPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1270,7 +1270,7 @@ void BulletPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_f
}
bool BulletPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1278,13 +1278,13 @@ bool BulletPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_f
}
RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.get_or_null(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.getornull(p_body_B);
+ body_B = rigid_body_owner.get_or_null(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1298,7 +1298,7 @@ RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform3D &
}
void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
SliderJointBullet *slider_joint = static_cast<SliderJointBullet *>(joint);
@@ -1306,7 +1306,7 @@ void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam
}
real_t BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0);
SliderJointBullet *slider_joint = static_cast<SliderJointBullet *>(joint);
@@ -1314,13 +1314,13 @@ real_t BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointPar
}
RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.get_or_null(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.getornull(p_body_B);
+ body_B = rigid_body_owner.get_or_null(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1332,7 +1332,7 @@ RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform
}
void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
ConeTwistJointBullet *coneTwist_joint = static_cast<ConeTwistJointBullet *>(joint);
@@ -1340,7 +1340,7 @@ void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJoi
}
real_t BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0.);
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.);
ConeTwistJointBullet *coneTwist_joint = static_cast<ConeTwistJointBullet *>(joint);
@@ -1348,13 +1348,13 @@ real_t BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJ
}
RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.get_or_null(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.getornull(p_body_B);
+ body_B = rigid_body_owner.get_or_null(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1368,7 +1368,7 @@ RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transfo
}
void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1376,7 +1376,7 @@ void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::A
}
real_t BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1384,7 +1384,7 @@ real_t BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3:
}
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);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1392,7 +1392,7 @@ void BulletPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Ax
}
bool BulletPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
- JointBullet *joint = joint_owner.getornull(p_joint);
+ JointBullet *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1401,7 +1401,7 @@ bool BulletPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Ax
void BulletPhysicsServer3D::free(RID p_rid) {
if (shape_owner.owns(p_rid)) {
- ShapeBullet *shape = shape_owner.getornull(p_rid);
+ ShapeBullet *shape = shape_owner.get_or_null(p_rid);
// Notify the shape is configured
for (Map<ShapeOwnerBullet *, int>::Element *element = shape->get_owners().front(); element; element = element->next()) {
@@ -1411,7 +1411,7 @@ void BulletPhysicsServer3D::free(RID p_rid) {
shape_owner.free(p_rid);
bulletdelete(shape);
} else if (rigid_body_owner.owns(p_rid)) {
- RigidBodyBullet *body = rigid_body_owner.getornull(p_rid);
+ RigidBodyBullet *body = rigid_body_owner.get_or_null(p_rid);
body->set_space(nullptr);
@@ -1421,7 +1421,7 @@ void BulletPhysicsServer3D::free(RID p_rid) {
bulletdelete(body);
} else if (soft_body_owner.owns(p_rid)) {
- SoftBodyBullet *body = soft_body_owner.getornull(p_rid);
+ SoftBodyBullet *body = soft_body_owner.get_or_null(p_rid);
body->set_space(nullptr);
@@ -1429,7 +1429,7 @@ void BulletPhysicsServer3D::free(RID p_rid) {
bulletdelete(body);
} else if (area_owner.owns(p_rid)) {
- AreaBullet *area = area_owner.getornull(p_rid);
+ AreaBullet *area = area_owner.get_or_null(p_rid);
area->set_space(nullptr);
@@ -1439,13 +1439,13 @@ void BulletPhysicsServer3D::free(RID p_rid) {
bulletdelete(area);
} else if (joint_owner.owns(p_rid)) {
- JointBullet *joint = joint_owner.getornull(p_rid);
+ JointBullet *joint = joint_owner.get_or_null(p_rid);
joint->destroy_internal_constraint();
joint_owner.free(p_rid);
bulletdelete(joint);
} else if (space_owner.owns(p_rid)) {
- SpaceBullet *space = space_owner.getornull(p_rid);
+ SpaceBullet *space = space_owner.get_or_null(p_rid);
space->remove_all_collision_objects();
@@ -1493,38 +1493,38 @@ int BulletPhysicsServer3D::get_process_info(ProcessInfo p_info) {
SpaceBullet *BulletPhysicsServer3D::get_space(RID p_rid) const {
ERR_FAIL_COND_V_MSG(space_owner.owns(p_rid) == false, nullptr, "The RID is not valid.");
- return space_owner.getornull(p_rid);
+ return space_owner.get_or_null(p_rid);
}
ShapeBullet *BulletPhysicsServer3D::get_shape(RID p_rid) const {
ERR_FAIL_COND_V_MSG(shape_owner.owns(p_rid) == false, nullptr, "The RID is not valid.");
- return shape_owner.getornull(p_rid);
+ return shape_owner.get_or_null(p_rid);
}
CollisionObjectBullet *BulletPhysicsServer3D::get_collision_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
- return rigid_body_owner.getornull(p_object);
+ return rigid_body_owner.get_or_null(p_object);
}
if (area_owner.owns(p_object)) {
- return area_owner.getornull(p_object);
+ return area_owner.get_or_null(p_object);
}
if (soft_body_owner.owns(p_object)) {
- return soft_body_owner.getornull(p_object);
+ return soft_body_owner.get_or_null(p_object);
}
ERR_FAIL_V_MSG(nullptr, "The RID is no valid.");
}
RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collision_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
- return rigid_body_owner.getornull(p_object);
+ return rigid_body_owner.get_or_null(p_object);
}
if (area_owner.owns(p_object)) {
- return area_owner.getornull(p_object);
+ return area_owner.get_or_null(p_object);
}
ERR_FAIL_V_MSG(nullptr, "The RID is no valid.");
}
JointBullet *BulletPhysicsServer3D::get_joint(RID p_rid) const {
ERR_FAIL_COND_V_MSG(joint_owner.owns(p_rid) == false, nullptr, "The RID is not valid.");
- return joint_owner.getornull(p_rid);
+ return joint_owner.get_or_null(p_rid);
}
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 0d2cd1f5a0..7b20fad28c 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -303,6 +303,7 @@ RigidBodyBullet::~RigidBodyBullet() {
void RigidBodyBullet::init_kinematic_utilities() {
kinematic_utilities = memnew(KinematicUtilities(this));
+ reload_kinematic_shapes();
}
void RigidBodyBullet::destroy_kinematic_utilities() {
@@ -529,26 +530,23 @@ void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) {
can_integrate_forces = false;
destroy_kinematic_utilities();
// The mode change is relevant to its mass
+ mode = p_mode;
switch (p_mode) {
case PhysicsServer3D::BODY_MODE_KINEMATIC:
- mode = PhysicsServer3D::BODY_MODE_KINEMATIC;
reload_axis_lock();
_internal_set_mass(0);
init_kinematic_utilities();
break;
case PhysicsServer3D::BODY_MODE_STATIC:
- mode = PhysicsServer3D::BODY_MODE_STATIC;
reload_axis_lock();
_internal_set_mass(0);
break;
case PhysicsServer3D::BODY_MODE_DYNAMIC:
- mode = PhysicsServer3D::BODY_MODE_DYNAMIC;
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
break;
- case PhysicsServer3D::MODE_DYNAMIC_LOCKED:
- mode = PhysicsServer3D::MODE_DYNAMIC_LOCKED;
+ case PhysicsServer3D::MODE_DYNAMIC_LINEAR:
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
@@ -721,7 +719,7 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
void RigidBodyBullet::reload_axis_lock() {
btBody->setLinearFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z))));
- if (PhysicsServer3D::MODE_DYNAMIC_LOCKED == mode) {
+ if (PhysicsServer3D::MODE_DYNAMIC_LINEAR == mode) {
/// When character angular is always locked
btBody->setAngularFactor(btVector3(0., 0., 0.));
} else {
@@ -1016,7 +1014,7 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
// Rigidbody is dynamic if and only if mass is non Zero, otherwise static
const bool isDynamic = p_mass != 0.f;
if (isDynamic) {
- if (PhysicsServer3D::BODY_MODE_DYNAMIC != mode && PhysicsServer3D::MODE_DYNAMIC_LOCKED != mode) {
+ if (PhysicsServer3D::BODY_MODE_DYNAMIC != mode && PhysicsServer3D::MODE_DYNAMIC_LINEAR != mode) {
return;
}
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index a9a811c445..66d7370bd7 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -122,7 +122,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
return 0;
}
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin);
@@ -158,7 +158,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
btVector3 bt_motion;
G_TO_B(p_motion, bt_motion);
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin);
@@ -219,7 +219,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform3D
return false;
}
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
@@ -251,7 +251,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform3D
}
bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform3D &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) {
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
@@ -947,7 +947,6 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform3D &p
if (!p_body->get_kinematic_utilities()) {
p_body->init_kinematic_utilities();
- p_body->reload_kinematic_shapes();
}
btVector3 initial_recover_motion(0, 0, 0);
@@ -1089,7 +1088,6 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform3D
if (!p_body->get_kinematic_utilities()) {
p_body->init_kinematic_utilities();
- p_body->reload_kinematic_shapes();
}
btVector3 recover_motion(0, 0, 0);
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index cbe41a1310..229e1e2724 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -37,16 +37,16 @@
// Static helper functions.
inline static bool is_snapable(const Vector3 &p_point1, const Vector3 &p_point2, real_t p_distance) {
- return (p_point1 - p_point2).length_squared() < p_distance * p_distance;
+ return p_point2.distance_squared_to(p_point1) < p_distance * p_distance;
}
-inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], const Vector2 p_uvs[2], const Vector2 &p_interpolation_point) {
- float segment_length = (p_segement_points[1] - p_segement_points[0]).length();
- if (p_segement_points[0].is_equal_approx(p_segement_points[1])) {
+inline static Vector2 interpolate_segment_uv(const Vector2 p_segment_points[2], const Vector2 p_uvs[2], const Vector2 &p_interpolation_point) {
+ if (p_segment_points[0].is_equal_approx(p_segment_points[1])) {
return p_uvs[0];
}
- float distance = (p_interpolation_point - p_segement_points[0]).length();
+ float segment_length = p_segment_points[0].distance_to(p_segment_points[1]);
+ float distance = p_segment_points[0].distance_to(p_interpolation_point);
float fraction = distance / segment_length;
return p_uvs[0].lerp(p_uvs[1], fraction);
@@ -162,7 +162,7 @@ inline static bool is_triangle_degenerate(const Vector2 p_vertices[3], real_t p_
return det < p_vertex_snap2;
}
-inline static bool are_segements_parallel(const Vector2 p_segment1_points[2], const Vector2 p_segment2_points[2], float p_vertex_snap2) {
+inline static bool are_segments_parallel(const Vector2 p_segment1_points[2], const Vector2 p_segment2_points[2], float p_vertex_snap2) {
Vector2 segment1 = p_segment1_points[1] - p_segment1_points[0];
Vector2 segment2 = p_segment2_points[1] - p_segment2_points[0];
real_t segment1_length2 = segment1.dot(segment1);
@@ -596,7 +596,7 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
_add_distance(intersectionsA, intersectionsB, current_face.from_b, 0);
}
} else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) {
- real_t distance = (intersection_point - face_center).length();
+ real_t distance = face_center.distance_to(intersection_point);
_add_distance(intersectionsA, intersectionsB, current_face.from_b, distance);
}
}
@@ -781,7 +781,7 @@ void CSGBrushOperation::MeshMerge::add_face(const Vector3 p_points[], const Vect
int CSGBrushOperation::Build2DFaces::_get_point_idx(const Vector2 &p_point) {
for (int vertex_idx = 0; vertex_idx < vertices.size(); ++vertex_idx) {
- if ((p_point - vertices[vertex_idx].point).length_squared() < vertex_snap2) {
+ if (vertices[vertex_idx].point.distance_squared_to(p_point) < vertex_snap2) {
return vertex_idx;
}
}
@@ -911,7 +911,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
vertices[outer_edge_idx[1]].point,
vertices[p_segment_indices[closest_idx]].point
};
- if (are_segements_parallel(edge1, edge2, vertex_snap2)) {
+ if (are_segments_parallel(edge1, edge2, vertex_snap2)) {
if (!degenerate_points.find(outer_edge_idx[0])) {
degenerate_points.push_back(outer_edge_idx[0]);
}
@@ -961,7 +961,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
// Check if point is existing face vertex.
bool existing = false;
for (int i = 0; i < 3; ++i) {
- if ((point_2D - face_vertices[i].point).length_squared() < vertex_snap2) {
+ if (face_vertices[i].point.distance_squared_to(point_2D) < vertex_snap2) {
existing = true;
break;
}
@@ -978,7 +978,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
};
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(point_2D, edge_points);
- if ((closest_point - point_2D).length_squared() < vertex_snap2) {
+ if (point_2D.distance_squared_to(closest_point) < vertex_snap2) {
int opposite_vertex_idx = face.vertex_idx[(face_edge_idx + 2) % 3];
// If new vertex snaps to degenerate vertex, just delete this face.
@@ -1041,7 +1041,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
bool on_edge = false;
for (int edge_point_idx = 0; edge_point_idx < 2; ++edge_point_idx) {
intersection_point = Geometry2D::get_closest_point_to_segment(p_segment_points[edge_point_idx], edge_points);
- if ((intersection_point - p_segment_points[edge_point_idx]).length_squared() < vertex_snap2) {
+ if (p_segment_points[edge_point_idx].distance_squared_to(intersection_point) < vertex_snap2) {
on_edge = true;
break;
}
@@ -1050,13 +1050,13 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
// Else check if the segment intersects the edge.
if (on_edge || Geometry2D::segment_intersects_segment(p_segment_points[0], p_segment_points[1], edge_points[0], edge_points[1], &intersection_point)) {
// Check if intersection point is an edge point.
- if ((intersection_point - edge_points[0]).length_squared() < vertex_snap2 ||
- (intersection_point - edge_points[1]).length_squared() < vertex_snap2) {
+ if ((edge_points[0].distance_squared_to(intersection_point) < vertex_snap2) ||
+ (edge_points[1].distance_squared_to(intersection_point) < vertex_snap2)) {
continue;
}
// Check if edge exists, by checking if the intersecting segment is parallel to the edge.
- if (are_segements_parallel(p_segment_points, edge_points, vertex_snap2)) {
+ if (are_segments_parallel(p_segment_points, edge_points, vertex_snap2)) {
continue;
}
@@ -1078,7 +1078,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
// If opposite point is on the segment, add its index to segment indices too.
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(vertices[opposite_vertex_idx].point, p_segment_points);
- if ((closest_point - vertices[opposite_vertex_idx].point).length_squared() < vertex_snap2) {
+ if (vertices[opposite_vertex_idx].point.distance_squared_to(closest_point) < vertex_snap2) {
_add_vertex_idx_sorted(r_segment_indices, opposite_vertex_idx);
}
@@ -1132,7 +1132,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
// Check if point is existing face vertex.
for (int i = 0; i < 3; ++i) {
- if ((p_point - face_vertices[i].point).length_squared() < vertex_snap2) {
+ if (face_vertices[i].point.distance_squared_to(p_point) < vertex_snap2) {
return face.vertex_idx[i];
}
}
@@ -1150,7 +1150,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
};
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, edge_points);
- if ((closest_point - p_point).length_squared() < vertex_snap2) {
+ if (p_point.distance_squared_to(closest_point) < vertex_snap2) {
on_edge = true;
// Add the point as a new vertex.
@@ -1172,8 +1172,8 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
Vector2 split_edge1[2] = { vertices[new_vertex_idx].point, edge_points[0] };
Vector2 split_edge2[2] = { vertices[new_vertex_idx].point, edge_points[1] };
Vector2 new_edge[2] = { vertices[new_vertex_idx].point, vertices[opposite_vertex_idx].point };
- if (are_segements_parallel(split_edge1, new_edge, vertex_snap2) &&
- are_segements_parallel(split_edge2, new_edge, vertex_snap2)) {
+ if (are_segments_parallel(split_edge1, new_edge, vertex_snap2) &&
+ are_segments_parallel(split_edge2, new_edge, vertex_snap2)) {
break;
}
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 452fb32d9d..e4297a593e 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -1732,6 +1732,7 @@ CSGBrush *CSGPolygon3D::_build_brush() {
int extrusion_face_count = shape_sides * 2;
int end_count = 0;
int shape_face_count = shape_faces.size() / 3;
+ real_t curve_length = 1.0;
switch (mode) {
case MODE_DEPTH:
extrusions = 1;
@@ -1744,7 +1745,12 @@ CSGBrush *CSGPolygon3D::_build_brush() {
}
break;
case MODE_PATH: {
- extrusions = Math::ceil(1.0 * curve->get_point_count() / path_interval);
+ curve_length = curve->get_baked_length();
+ if (path_interval_type == PATH_INTERVAL_DISTANCE) {
+ extrusions = MAX(1, Math::ceil(curve_length / path_interval)) + 1;
+ } else {
+ extrusions = Math::ceil(1.0 * curve->get_point_count() / path_interval);
+ }
if (!path_joined) {
end_count = 2;
extrusions -= 1;
@@ -1767,212 +1773,245 @@ CSGBrush *CSGPolygon3D::_build_brush() {
smooth.resize(face_count);
materials.resize(face_count);
invert.resize(face_count);
+ int faces_removed = 0;
- Vector3 *facesw = faces.ptrw();
- Vector2 *uvsw = uvs.ptrw();
- bool *smoothw = smooth.ptrw();
- Ref<Material> *materialsw = materials.ptrw();
- bool *invertw = invert.ptrw();
-
- int face = 0;
- Transform3D base_xform;
- Transform3D current_xform;
- Transform3D previous_xform;
- double u_step = 1.0 / extrusions;
- double v_step = 1.0 / shape_sides;
- double spin_step = Math::deg2rad(spin_degrees / spin_sides);
- double extrusion_step = 1.0 / extrusions;
- if (mode == MODE_PATH) {
- if (path_joined) {
- extrusion_step = 1.0 / (extrusions - 1);
- }
- extrusion_step *= curve->get_baked_length();
- }
+ {
+ Vector3 *facesw = faces.ptrw();
+ Vector2 *uvsw = uvs.ptrw();
+ bool *smoothw = smooth.ptrw();
+ Ref<Material> *materialsw = materials.ptrw();
+ bool *invertw = invert.ptrw();
- if (mode == MODE_PATH) {
- if (!path_local) {
- base_xform = path->get_global_transform();
+ int face = 0;
+ Transform3D base_xform;
+ Transform3D current_xform;
+ Transform3D previous_xform;
+ Transform3D previous_previous_xform;
+ double u_step = 1.0 / extrusions;
+ if (path_u_distance > 0.0) {
+ u_step *= curve_length / path_u_distance;
+ }
+ double v_step = 1.0 / shape_sides;
+ double spin_step = Math::deg2rad(spin_degrees / spin_sides);
+ double extrusion_step = 1.0 / extrusions;
+ if (mode == MODE_PATH) {
+ if (path_joined) {
+ extrusion_step = 1.0 / (extrusions - 1);
+ }
+ extrusion_step *= curve_length;
}
- Vector3 current_point = curve->interpolate_baked(0);
- Vector3 next_point = curve->interpolate_baked(extrusion_step);
- Vector3 current_up = Vector3(0, 1, 0);
- Vector3 direction = next_point - current_point;
+ if (mode == MODE_PATH) {
+ if (!path_local) {
+ base_xform = path->get_global_transform();
+ }
- if (path_joined) {
- Vector3 last_point = curve->interpolate_baked(curve->get_baked_length());
- direction = next_point - last_point;
- }
+ Vector3 current_point = curve->interpolate_baked(0);
+ Vector3 next_point = curve->interpolate_baked(extrusion_step);
+ Vector3 current_up = Vector3(0, 1, 0);
+ Vector3 direction = next_point - current_point;
- switch (path_rotation) {
- case PATH_ROTATION_POLYGON:
- direction = Vector3(0, 0, -1);
- break;
- case PATH_ROTATION_PATH:
- break;
- case PATH_ROTATION_PATH_FOLLOW:
- current_up = curve->interpolate_baked_up_vector(0);
- break;
+ if (path_joined) {
+ Vector3 last_point = curve->interpolate_baked(curve->get_baked_length());
+ direction = next_point - last_point;
+ }
+
+ switch (path_rotation) {
+ case PATH_ROTATION_POLYGON:
+ direction = Vector3(0, 0, -1);
+ break;
+ case PATH_ROTATION_PATH:
+ break;
+ case PATH_ROTATION_PATH_FOLLOW:
+ current_up = curve->interpolate_baked_up_vector(0);
+ break;
+ }
+
+ Transform3D facing = Transform3D().looking_at(direction, current_up);
+ current_xform = base_xform.translated(current_point) * facing;
}
- Transform3D facing = Transform3D().looking_at(direction, current_up);
- current_xform = base_xform.translated(current_point) * facing;
- }
+ // Create the mesh.
+ if (end_count > 0) {
+ // Add front end face.
+ for (int face_idx = 0; face_idx < shape_face_count; face_idx++) {
+ for (int face_vertex_idx = 0; face_vertex_idx < 3; face_vertex_idx++) {
+ // We need to reverse the rotation of the shape face vertices.
+ int index = shape_faces[face_idx * 3 + 2 - face_vertex_idx];
+ Point2 p = shape_polygon[index];
+ Point2 uv = (p - shape_rect.position) / shape_rect.size;
+
+ // Use the left side of the bottom half of the y-inverted texture.
+ uv.x = uv.x / 2;
+ uv.y = 1 - (uv.y / 2);
+
+ facesw[face * 3 + face_vertex_idx] = current_xform.xform(Vector3(p.x, p.y, 0));
+ uvsw[face * 3 + face_vertex_idx] = uv;
+ }
- // Create the mesh.
- if (end_count > 0) {
- // Add front end face.
- for (int face_idx = 0; face_idx < shape_face_count; face_idx++) {
- for (int face_vertex_idx = 0; face_vertex_idx < 3; face_vertex_idx++) {
- // We need to reverse the rotation of the shape face vertices.
- int index = shape_faces[face_idx * 3 + 2 - face_vertex_idx];
- Point2 p = shape_polygon[index];
- Point2 uv = (p - shape_rect.position) / shape_rect.size;
-
- // Use the left side of the bottom half of the y-inverted texture.
- uv.x = uv.x / 2;
- uv.y = 1 - (uv.y / 2);
-
- facesw[face * 3 + face_vertex_idx] = current_xform.xform(Vector3(p.x, p.y, 0));
- uvsw[face * 3 + face_vertex_idx] = uv;
+ smoothw[face] = false;
+ materialsw[face] = material;
+ invertw[face] = invert_faces;
+ face++;
}
-
- smoothw[face] = false;
- materialsw[face] = material;
- invertw[face] = invert_faces;
- face++;
}
- }
- // Add extrusion faces.
- for (int x0 = 0; x0 < extrusions; x0++) {
- previous_xform = current_xform;
-
- switch (mode) {
- case MODE_DEPTH: {
- current_xform.translate(Vector3(0, 0, -depth));
- } break;
- case MODE_SPIN: {
- current_xform.rotate(Vector3(0, 1, 0), spin_step);
- } break;
- case MODE_PATH: {
- double previous_offset = x0 * extrusion_step;
- double current_offset = (x0 + 1) * extrusion_step;
- double next_offset = (x0 + 2) * extrusion_step;
- if (x0 == extrusions - 1) {
- if (path_joined) {
- current_offset = 0;
- next_offset = extrusion_step;
+ real_t angle_simplify_dot = Math::cos(Math::deg2rad(path_simplify_angle));
+ Vector3 previous_simplify_dir = Vector3(0, 0, 0);
+ int faces_combined = 0;
+
+ // Add extrusion faces.
+ for (int x0 = 0; x0 < extrusions; x0++) {
+ previous_previous_xform = previous_xform;
+ previous_xform = current_xform;
+
+ switch (mode) {
+ case MODE_DEPTH: {
+ current_xform.translate(Vector3(0, 0, -depth));
+ } break;
+ case MODE_SPIN: {
+ current_xform.rotate(Vector3(0, 1, 0), spin_step);
+ } break;
+ case MODE_PATH: {
+ double previous_offset = x0 * extrusion_step;
+ double current_offset = (x0 + 1) * extrusion_step;
+ double next_offset = (x0 + 2) * extrusion_step;
+ if (x0 == extrusions - 1) {
+ if (path_joined) {
+ current_offset = 0;
+ next_offset = extrusion_step;
+ } else {
+ next_offset = current_offset;
+ }
+ }
+
+ Vector3 previous_point = curve->interpolate_baked(previous_offset);
+ Vector3 current_point = curve->interpolate_baked(current_offset);
+ Vector3 next_point = curve->interpolate_baked(next_offset);
+ Vector3 current_up = Vector3(0, 1, 0);
+ Vector3 direction = next_point - previous_point;
+ Vector3 current_dir = (current_point - previous_point).normalized();
+
+ // If the angles are similar, remove the previous face and replace it with this one.
+ if (path_simplify_angle > 0.0 && x0 > 0 && previous_simplify_dir.dot(current_dir) > angle_simplify_dot) {
+ faces_combined += 1;
+ previous_xform = previous_previous_xform;
+ face -= extrusion_face_count;
+ faces_removed += extrusion_face_count;
} else {
- next_offset = current_offset;
+ faces_combined = 0;
+ previous_simplify_dir = current_dir;
}
- }
- Vector3 previous_point = curve->interpolate_baked(previous_offset);
- Vector3 current_point = curve->interpolate_baked(current_offset);
- Vector3 next_point = curve->interpolate_baked(next_offset);
- Vector3 current_up = Vector3(0, 1, 0);
- Vector3 direction = next_point - previous_point;
+ switch (path_rotation) {
+ case PATH_ROTATION_POLYGON:
+ direction = Vector3(0, 0, -1);
+ break;
+ case PATH_ROTATION_PATH:
+ break;
+ case PATH_ROTATION_PATH_FOLLOW:
+ current_up = curve->interpolate_baked_up_vector(current_offset);
+ break;
+ }
- switch (path_rotation) {
- case PATH_ROTATION_POLYGON:
- direction = Vector3(0, 0, -1);
- break;
- case PATH_ROTATION_PATH:
- break;
- case PATH_ROTATION_PATH_FOLLOW:
- current_up = curve->interpolate_baked_up_vector(current_offset);
- break;
- }
+ Transform3D facing = Transform3D().looking_at(direction, current_up);
+ current_xform = base_xform.translated(current_point) * facing;
+ } break;
+ }
- Transform3D facing = Transform3D().looking_at(direction, current_up);
- current_xform = base_xform.translated(current_point) * facing;
- } break;
- }
+ double u0 = (x0 - faces_combined) * u_step;
+ double u1 = ((x0 + 1) * u_step);
+ if (mode == MODE_PATH && !path_continuous_u) {
+ u0 = 0.0;
+ u1 = 1.0;
+ }
- double u0 = x0 * u_step;
- double u1 = ((x0 + 1) * u_step);
- if (mode == MODE_PATH && !path_continuous_u) {
- u0 = 0.0;
- u1 = 1.0;
- }
+ for (int y0 = 0; y0 < shape_sides; y0++) {
+ int y1 = (y0 + 1) % shape_sides;
+ // Use the top half of the texture.
+ double v0 = (y0 * v_step) / 2;
+ double v1 = ((y0 + 1) * v_step) / 2;
- for (int y0 = 0; y0 < shape_sides; y0++) {
- int y1 = (y0 + 1) % shape_sides;
- // Use the top half of the texture.
- double v0 = (y0 * v_step) / 2;
- double v1 = ((y0 + 1) * v_step) / 2;
-
- Vector3 v[4] = {
- previous_xform.xform(Vector3(shape_polygon[y0].x, shape_polygon[y0].y, 0)),
- current_xform.xform(Vector3(shape_polygon[y0].x, shape_polygon[y0].y, 0)),
- current_xform.xform(Vector3(shape_polygon[y1].x, shape_polygon[y1].y, 0)),
- previous_xform.xform(Vector3(shape_polygon[y1].x, shape_polygon[y1].y, 0)),
- };
-
- Vector2 u[4] = {
- Vector2(u0, v0),
- Vector2(u1, v0),
- Vector2(u1, v1),
- Vector2(u0, v1),
- };
-
- // Face 1
- facesw[face * 3 + 0] = v[0];
- facesw[face * 3 + 1] = v[1];
- facesw[face * 3 + 2] = v[2];
-
- uvsw[face * 3 + 0] = u[0];
- uvsw[face * 3 + 1] = u[1];
- uvsw[face * 3 + 2] = u[2];
-
- smoothw[face] = smooth_faces;
- invertw[face] = invert_faces;
- materialsw[face] = material;
-
- face++;
-
- // Face 2
- facesw[face * 3 + 0] = v[2];
- facesw[face * 3 + 1] = v[3];
- facesw[face * 3 + 2] = v[0];
-
- uvsw[face * 3 + 0] = u[2];
- uvsw[face * 3 + 1] = u[3];
- uvsw[face * 3 + 2] = u[0];
-
- smoothw[face] = smooth_faces;
- invertw[face] = invert_faces;
- materialsw[face] = material;
-
- face++;
- }
- }
+ Vector3 v[4] = {
+ previous_xform.xform(Vector3(shape_polygon[y0].x, shape_polygon[y0].y, 0)),
+ current_xform.xform(Vector3(shape_polygon[y0].x, shape_polygon[y0].y, 0)),
+ current_xform.xform(Vector3(shape_polygon[y1].x, shape_polygon[y1].y, 0)),
+ previous_xform.xform(Vector3(shape_polygon[y1].x, shape_polygon[y1].y, 0)),
+ };
- if (end_count > 1) {
- // Add back end face.
- for (int face_idx = 0; face_idx < shape_face_count; face_idx++) {
- for (int face_vertex_idx = 0; face_vertex_idx < 3; face_vertex_idx++) {
- int index = shape_faces[face_idx * 3 + face_vertex_idx];
- Point2 p = shape_polygon[index];
- Point2 uv = (p - shape_rect.position) / shape_rect.size;
+ Vector2 u[4] = {
+ Vector2(u0, v0),
+ Vector2(u1, v0),
+ Vector2(u1, v1),
+ Vector2(u0, v1),
+ };
- // Use the x-inverted ride side of the bottom half of the y-inverted texture.
- uv.x = 1 - uv.x / 2;
- uv.y = 1 - (uv.y / 2);
+ // Face 1
+ facesw[face * 3 + 0] = v[0];
+ facesw[face * 3 + 1] = v[1];
+ facesw[face * 3 + 2] = v[2];
- facesw[face * 3 + face_vertex_idx] = current_xform.xform(Vector3(p.x, p.y, 0));
- uvsw[face * 3 + face_vertex_idx] = uv;
+ uvsw[face * 3 + 0] = u[0];
+ uvsw[face * 3 + 1] = u[1];
+ uvsw[face * 3 + 2] = u[2];
+
+ smoothw[face] = smooth_faces;
+ invertw[face] = invert_faces;
+ materialsw[face] = material;
+
+ face++;
+
+ // Face 2
+ facesw[face * 3 + 0] = v[2];
+ facesw[face * 3 + 1] = v[3];
+ facesw[face * 3 + 2] = v[0];
+
+ uvsw[face * 3 + 0] = u[2];
+ uvsw[face * 3 + 1] = u[3];
+ uvsw[face * 3 + 2] = u[0];
+
+ smoothw[face] = smooth_faces;
+ invertw[face] = invert_faces;
+ materialsw[face] = material;
+
+ face++;
}
+ }
+
+ if (end_count > 1) {
+ // Add back end face.
+ for (int face_idx = 0; face_idx < shape_face_count; face_idx++) {
+ for (int face_vertex_idx = 0; face_vertex_idx < 3; face_vertex_idx++) {
+ int index = shape_faces[face_idx * 3 + face_vertex_idx];
+ Point2 p = shape_polygon[index];
+ Point2 uv = (p - shape_rect.position) / shape_rect.size;
- smoothw[face] = false;
- materialsw[face] = material;
- invertw[face] = invert_faces;
- face++;
+ // Use the x-inverted ride side of the bottom half of the y-inverted texture.
+ uv.x = 1 - uv.x / 2;
+ uv.y = 1 - (uv.y / 2);
+
+ facesw[face * 3 + face_vertex_idx] = current_xform.xform(Vector3(p.x, p.y, 0));
+ uvsw[face * 3 + face_vertex_idx] = uv;
+ }
+
+ smoothw[face] = false;
+ materialsw[face] = material;
+ invertw[face] = invert_faces;
+ face++;
+ }
}
+
+ face_count -= faces_removed;
+ ERR_FAIL_COND_V_MSG(face != face_count, brush, "Bug: Failed to create the CSGPolygon mesh correctly.");
}
- ERR_FAIL_COND_V_MSG(face != face_count, brush, "Bug: Failed to create the CSGPolygon mesh correctly.");
+ if (faces_removed > 0) {
+ faces.resize(face_count * 3);
+ uvs.resize(face_count * 3);
+ smooth.resize(face_count);
+ materials.resize(face_count);
+ invert.resize(face_count);
+ }
brush->build_from_faces(faces, uvs, smooth, materials, invert);
@@ -2031,9 +2070,15 @@ void CSGPolygon3D::_bind_methods() {
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_type", "interval_type"), &CSGPolygon3D::set_path_interval_type);
+ ClassDB::bind_method(D_METHOD("get_path_interval_type"), &CSGPolygon3D::get_path_interval_type);
+
ClassDB::bind_method(D_METHOD("set_path_interval", "interval"), &CSGPolygon3D::set_path_interval);
ClassDB::bind_method(D_METHOD("get_path_interval"), &CSGPolygon3D::get_path_interval);
+ ClassDB::bind_method(D_METHOD("set_path_simplify_angle", "degrees"), &CSGPolygon3D::set_path_simplify_angle);
+ ClassDB::bind_method(D_METHOD("get_path_simplify_angle"), &CSGPolygon3D::get_path_simplify_angle);
+
ClassDB::bind_method(D_METHOD("set_path_rotation", "path_rotation"), &CSGPolygon3D::set_path_rotation);
ClassDB::bind_method(D_METHOD("get_path_rotation"), &CSGPolygon3D::get_path_rotation);
@@ -2043,6 +2088,9 @@ void CSGPolygon3D::_bind_methods() {
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_u_distance", "distance"), &CSGPolygon3D::set_path_u_distance);
+ ClassDB::bind_method(D_METHOD("get_path_u_distance"), &CSGPolygon3D::get_path_u_distance);
+
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);
@@ -2061,10 +2109,13 @@ void CSGPolygon3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "spin_degrees", PROPERTY_HINT_RANGE, "1,360,0.1"), "set_spin_degrees", "get_spin_degrees");
ADD_PROPERTY(PropertyInfo(Variant::INT, "spin_sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_spin_sides", "get_spin_sides");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "path_node", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Path3D"), "set_path_node", "get_path_node");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_interval", PROPERTY_HINT_RANGE, "0.1,1.0,0.05,exp"), "set_path_interval", "get_path_interval");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "path_interval_type", PROPERTY_HINT_ENUM, "Distance,Subdivide"), "set_path_interval_type", "get_path_interval_type");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_interval", PROPERTY_HINT_RANGE, "0.01,1.0,0.01,exp,or_greater"), "set_path_interval", "get_path_interval");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_simplify_angle", PROPERTY_HINT_RANGE, "0.0,180.0,0.1,exp"), "set_path_simplify_angle", "get_path_simplify_angle");
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_rotation", PROPERTY_HINT_ENUM, "Polygon,Path,PathFollow"), "set_path_rotation", "get_path_rotation");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_local"), "set_path_local", "is_path_local");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_continuous_u"), "set_path_continuous_u", "is_path_continuous_u");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_u_distance", PROPERTY_HINT_RANGE, "0.0,10.0,0.01,or_greater"), "set_path_u_distance", "get_path_u_distance");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_joined"), "set_path_joined", "is_path_joined");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial"), "set_material", "get_material");
@@ -2076,6 +2127,9 @@ void CSGPolygon3D::_bind_methods() {
BIND_ENUM_CONSTANT(PATH_ROTATION_POLYGON);
BIND_ENUM_CONSTANT(PATH_ROTATION_PATH);
BIND_ENUM_CONSTANT(PATH_ROTATION_PATH_FOLLOW);
+
+ BIND_ENUM_CONSTANT(PATH_INTERVAL_DISTANCE);
+ BIND_ENUM_CONSTANT(PATH_INTERVAL_SUBDIVIDE);
}
void CSGPolygon3D::set_polygon(const Vector<Vector2> &p_polygon) {
@@ -2119,6 +2173,16 @@ bool CSGPolygon3D::is_path_continuous_u() const {
return path_continuous_u;
}
+void CSGPolygon3D::set_path_u_distance(real_t p_path_u_distance) {
+ path_u_distance = p_path_u_distance;
+ _make_dirty();
+ update_gizmos();
+}
+
+real_t CSGPolygon3D::get_path_u_distance() const {
+ return path_u_distance;
+}
+
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;
@@ -2151,8 +2215,17 @@ NodePath CSGPolygon3D::get_path_node() const {
return path_node;
}
+void CSGPolygon3D::set_path_interval_type(PathIntervalType p_interval_type) {
+ path_interval_type = p_interval_type;
+ _make_dirty();
+ update_gizmos();
+}
+
+CSGPolygon3D::PathIntervalType CSGPolygon3D::get_path_interval_type() const {
+ return path_interval_type;
+}
+
void CSGPolygon3D::set_path_interval(float p_interval) {
- ERR_FAIL_COND_MSG(p_interval <= 0 || p_interval > 1, "Path interval must be greater than 0 and less than or equal to 1.0.");
path_interval = p_interval;
_make_dirty();
update_gizmos();
@@ -2162,6 +2235,16 @@ float CSGPolygon3D::get_path_interval() const {
return path_interval;
}
+void CSGPolygon3D::set_path_simplify_angle(float p_angle) {
+ path_simplify_angle = p_angle;
+ _make_dirty();
+ update_gizmos();
+}
+
+float CSGPolygon3D::get_path_simplify_angle() const {
+ return path_simplify_angle;
+}
+
void CSGPolygon3D::set_path_rotation(PathRotation p_rotation) {
path_rotation = p_rotation;
_make_dirty();
@@ -2229,10 +2312,13 @@ CSGPolygon3D::CSGPolygon3D() {
spin_degrees = 360;
spin_sides = 8;
smooth_faces = false;
+ path_interval_type = PATH_INTERVAL_DISTANCE;
path_interval = 1.0;
+ path_simplify_angle = 0.0;
path_rotation = PATH_ROTATION_PATH_FOLLOW;
path_local = false;
path_continuous_u = true;
+ path_u_distance = 1.0;
path_joined = false;
path = nullptr;
}
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index 5cf371665e..c85cce776b 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -336,6 +336,11 @@ public:
MODE_PATH
};
+ enum PathIntervalType {
+ PATH_INTERVAL_DISTANCE,
+ PATH_INTERVAL_SUBDIVIDE
+ };
+
enum PathRotation {
PATH_ROTATION_POLYGON,
PATH_ROTATION_PATH,
@@ -356,7 +361,9 @@ private:
int spin_sides;
NodePath path_node;
+ PathIntervalType path_interval_type;
float path_interval;
+ float path_simplify_angle;
PathRotation path_rotation;
bool path_local;
@@ -364,6 +371,7 @@ private:
bool smooth_faces;
bool path_continuous_u;
+ real_t path_u_distance;
bool path_joined;
bool _is_editable_3d_polygon() const;
@@ -396,9 +404,15 @@ public:
void set_path_node(const NodePath &p_path);
NodePath get_path_node() const;
+ void set_path_interval_type(PathIntervalType p_interval_type);
+ PathIntervalType get_path_interval_type() const;
+
void set_path_interval(float p_interval);
float get_path_interval() const;
+ void set_path_simplify_angle(float p_angle);
+ float get_path_simplify_angle() const;
+
void set_path_rotation(PathRotation p_rotation);
PathRotation get_path_rotation() const;
@@ -408,6 +422,9 @@ public:
void set_path_continuous_u(bool p_enable);
bool is_path_continuous_u() const;
+ void set_path_u_distance(real_t p_path_u_distance);
+ real_t get_path_u_distance() const;
+
void set_path_joined(bool p_enable);
bool is_path_joined() const;
@@ -422,5 +439,6 @@ public:
VARIANT_ENUM_CAST(CSGPolygon3D::Mode)
VARIANT_ENUM_CAST(CSGPolygon3D::PathRotation)
+VARIANT_ENUM_CAST(CSGPolygon3D::PathIntervalType)
#endif // CSG_SHAPE_H
diff --git a/modules/csg/doc_classes/CSGPolygon3D.xml b/modules/csg/doc_classes/CSGPolygon3D.xml
index 5d56e56de9..ecbb7962d1 100644
--- a/modules/csg/doc_classes/CSGPolygon3D.xml
+++ b/modules/csg/doc_classes/CSGPolygon3D.xml
@@ -24,6 +24,9 @@
<member name="path_interval" type="float" setter="set_path_interval" getter="get_path_interval">
When [member mode] is [constant MODE_PATH], the path interval or ratio of path points to extrusions.
</member>
+ <member name="path_interval_type" type="int" setter="set_path_interval_type" getter="get_path_interval_type" enum="CSGPolygon3D.PathIntervalType">
+ When [member mode] is [constant MODE_PATH], this will determine if the interval should be by distance ([constant PATH_INTERVAL_DISTANCE]) or subdivision fractions ([constant PATH_INTERVAL_SUBDIVIDE]).
+ </member>
<member name="path_joined" type="bool" setter="set_path_joined" getter="is_path_joined">
When [member mode] is [constant MODE_PATH], if [code]true[/code] the ends of the path are joined, by adding an extrusion between the last and first points of the path.
</member>
@@ -36,6 +39,12 @@
<member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon3D.PathRotation">
When [member mode] is [constant MODE_PATH], the [enum PathRotation] method used to rotate the [member polygon] as it is extruded.
</member>
+ <member name="path_simplify_angle" type="float" setter="set_path_simplify_angle" getter="get_path_simplify_angle">
+ When [member mode] is [constant MODE_PATH], extrusions that are less than this angle, will be merged together to reduce polygon count.
+ </member>
+ <member name="path_u_distance" type="float" setter="set_path_u_distance" getter="get_path_u_distance">
+ When [member mode] is [constant MODE_PATH], this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling.
+ </member>
<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0)">
The point array that defines the 2D polygon that is extruded.
</member>
@@ -70,5 +79,11 @@
<constant name="PATH_ROTATION_PATH_FOLLOW" value="2" enum="PathRotation">
The [member polygon] shape follows the path and its rotations around the path axis.
</constant>
+ <constant name="PATH_INTERVAL_DISTANCE" value="0" enum="PathIntervalType">
+ When [member mode] is set to [constant MODE_PATH], [member path_interval] will determine the distance, in meters, each interval of the path will extrude.
+ </constant>
+ <constant name="PATH_INTERVAL_SUBDIVIDE" value="1" enum="PathIntervalType">
+ When [member mode] is set to [constant MODE_PATH], [member path_interval] will subdivide the polygons along the path.
+ </constant>
</constants>
</class>
diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
index 456b390dbb..f9659c092a 100644
--- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml
+++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
@@ -77,10 +77,8 @@
<member name="host" type="ENetConnection" setter="" getter="get_host">
The underlying [ENetConnection] created after [method create_client] and [method create_server].
</member>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
<member name="server_relay" type="bool" setter="set_server_relay_enabled" getter="is_server_relay_enabled" default="true">
Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is [code]false[/code], clients won't be automatically notified of other peers and won't be able to send them packets through the server.
</member>
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
</members>
</class>
diff --git a/modules/enet/doc_classes/ENetPacketPeer.xml b/modules/enet/doc_classes/ENetPacketPeer.xml
index 8f0693fb01..4116ba17f2 100644
--- a/modules/enet/doc_classes/ENetPacketPeer.xml
+++ b/modules/enet/doc_classes/ENetPacketPeer.xml
@@ -6,6 +6,7 @@
<description>
A PacketPeer implementation representing a peer of an [ENetConnection].
This class cannot be instantiated directly but can be retrieved during [method ENetConnection.service] or via [method ENetConnection.get_peers].
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
<link title="API documentation on the ENet website">http://enet.bespin.org/usergroup0.html</link>
diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp
index afd31207f6..52eb46f070 100644
--- a/modules/enet/enet_multiplayer_peer.cpp
+++ b/modules/enet/enet_multiplayer_peer.cpp
@@ -33,22 +33,6 @@
#include "core/io/marshalls.h"
#include "core/os/os.h"
-void ENetMultiplayerPeer::set_transfer_channel(int p_channel) {
- transfer_channel = p_channel;
-}
-
-int ENetMultiplayerPeer::get_transfer_channel() const {
- return transfer_channel;
-}
-
-void ENetMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- transfer_mode = p_mode;
-}
-
-Multiplayer::TransferMode ENetMultiplayerPeer::get_transfer_mode() const {
- return transfer_mode;
-}
-
void ENetMultiplayerPeer::set_target_peer(int p_peer) {
target_peer = p_peer;
}
@@ -62,6 +46,7 @@ int ENetMultiplayerPeer::get_packet_peer() const {
Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) {
ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
+ set_refuse_new_connections(false);
Ref<ENetConnection> host;
host.instantiate();
Error err = host->create_host_bound(bind_ip, p_port, p_max_clients, 0, p_max_channels > 0 ? p_max_channels + SYSCH_MAX : 0, p_out_bandwidth);
@@ -70,7 +55,6 @@ Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_ma
}
active_mode = MODE_SERVER;
- refuse_connections = false;
unique_id = 1;
connection_status = CONNECTION_CONNECTED;
hosts[0] = host;
@@ -79,6 +63,7 @@ Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_ma
Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, int p_channel_count, int p_in_bandwidth, int p_out_bandwidth, int p_local_port) {
ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
+ set_refuse_new_connections(false);
Ref<ENetConnection> host;
host.instantiate();
Error err;
@@ -102,7 +87,6 @@ Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, in
// Need to wait for CONNECT event.
connection_status = CONNECTION_CONNECTING;
active_mode = MODE_CLIENT;
- refuse_connections = false;
peers[1] = peer;
hosts[0] = host;
@@ -113,7 +97,6 @@ Error ENetMultiplayerPeer::create_mesh(int p_id) {
ERR_FAIL_COND_V_MSG(p_id <= 0, ERR_INVALID_PARAMETER, "The unique ID must be greater then 0");
ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
active_mode = MODE_MESH;
- refuse_connections = false;
unique_id = p_id;
connection_status = CONNECTION_CONNECTED;
return OK;
@@ -145,7 +128,7 @@ bool ENetMultiplayerPeer::_poll_server() {
}
switch (ret) {
case ENetConnection::EVENT_CONNECT: {
- if (refuse_connections) {
+ if (is_refusing_new_connections()) {
event.peer->reset();
return false;
}
@@ -173,7 +156,7 @@ bool ENetMultiplayerPeer::_poll_server() {
emit_signal(SNAME("peer_disconnected"), id);
peers.erase(id);
- if (!server_relay) {
+ if (server_relay) {
_notify_peers(id, false);
}
return false;
@@ -423,6 +406,7 @@ void ENetMultiplayerPeer::close_connection(uint32_t wait_usec) {
hosts.clear();
unique_id = 0;
connection_status = CONNECTION_DISCONNECTED;
+ set_refuse_new_connections(false);
}
int ENetMultiplayerPeer::get_available_packet_count() const {
@@ -451,10 +435,11 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size
int packet_flags = 0;
int channel = SYSCH_RELIABLE;
+ int transfer_channel = get_transfer_channel();
if (transfer_channel > 0) {
channel = SYSCH_MAX + transfer_channel - 1;
} else {
- switch (transfer_mode) {
+ switch (get_transfer_mode()) {
case Multiplayer::TRANSFER_MODE_UNRELIABLE: {
packet_flags = ENET_PACKET_FLAG_UNSEQUENCED;
channel = SYSCH_UNRELIABLE;
@@ -545,19 +530,15 @@ int ENetMultiplayerPeer::get_unique_id() const {
return unique_id;
}
-void ENetMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
- refuse_connections = p_enable;
+void ENetMultiplayerPeer::set_refuse_new_connections(bool p_enabled) {
#ifdef GODOT_ENET
if (_is_active()) {
for (KeyValue<int, Ref<ENetConnection>> &E : hosts) {
- E.value->refuse_new_connections(p_enable);
+ E.value->refuse_new_connections(p_enabled);
}
}
#endif
-}
-
-bool ENetMultiplayerPeer::is_refusing_new_connections() const {
- return refuse_connections;
+ MultiplayerPeer::set_refuse_new_connections(p_enabled);
}
void ENetMultiplayerPeer::set_server_relay_enabled(bool p_enabled) {
diff --git a/modules/enet/enet_multiplayer_peer.h b/modules/enet/enet_multiplayer_peer.h
index b5316b8292..7a60e2359c 100644
--- a/modules/enet/enet_multiplayer_peer.h
+++ b/modules/enet/enet_multiplayer_peer.h
@@ -65,10 +65,7 @@ private:
uint32_t unique_id = 0;
int target_peer = 0;
- int transfer_channel = 0;
- Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
- bool refuse_connections = false;
bool server_relay = true;
ConnectionStatus connection_status = CONNECTION_DISCONNECTED;
@@ -101,40 +98,31 @@ protected:
static void _bind_methods();
public:
- virtual void set_transfer_channel(int p_channel) override;
- virtual int get_transfer_channel() const override;
-
- virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- virtual Multiplayer::TransferMode get_transfer_mode() const override;
virtual void set_target_peer(int p_peer) override;
-
virtual int get_packet_peer() const override;
- Error create_server(int p_port, int p_max_clients = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0);
- Error create_client(const String &p_address, int p_port, int p_channel_count = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_local_port = 0);
- Error create_mesh(int p_id);
- Error add_mesh_peer(int p_id, Ref<ENetConnection> p_host);
-
- void close_connection(uint32_t wait_usec = 100);
-
- void disconnect_peer(int p_peer, bool now = false);
-
virtual void poll() override;
-
virtual bool is_server() const override;
+ // Overriden so we can instrument the DTLSServer when needed.
+ virtual void set_refuse_new_connections(bool p_enabled) override;
- virtual int get_available_packet_count() const override;
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
+ virtual ConnectionStatus get_connection_status() const override;
+
+ virtual int get_unique_id() const override;
virtual int get_max_packet_size() const override;
+ virtual int get_available_packet_count() const override;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
- virtual ConnectionStatus get_connection_status() const override;
+ Error create_server(int p_port, int p_max_clients = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0);
+ Error create_client(const String &p_address, int p_port, int p_channel_count = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_local_port = 0);
+ Error create_mesh(int p_id);
+ Error add_mesh_peer(int p_id, Ref<ENetConnection> p_host);
- virtual void set_refuse_new_connections(bool p_enable) override;
- virtual bool is_refusing_new_connections() const override;
+ void close_connection(uint32_t wait_usec = 100);
- virtual int get_unique_id() const override;
+ void disconnect_peer(int p_peer, bool now = false);
void set_bind_ip(const IPAddress &p_ip);
void set_server_relay_enabled(bool p_enabled);
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 21ee39f3ed..94bda04d12 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -16,7 +16,6 @@ env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
Export("env_gdnative")
-SConscript("net/SCsub")
SConscript("pluginscript/SCsub")
SConscript("videodecoder/SCsub")
SConscript("text/SCsub")
diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py
index fa985501b5..026a84a70f 100644
--- a/modules/gdnative/config.py
+++ b/modules/gdnative/config.py
@@ -10,14 +10,9 @@ def get_doc_classes():
return [
"GDNative",
"GDNativeLibrary",
- "MultiplayerPeerGDNative",
"NativeScript",
- "PacketPeerGDNative",
"PluginScript",
- "StreamPeerGDNative",
"VideoStreamGDNative",
- "WebRTCPeerConnectionGDNative",
- "WebRTCDataChannelGDNative",
]
diff --git a/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml b/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml
deleted file mode 100644
index 40f3121525..0000000000
--- a/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="MultiplayerPeerGDNative" inherits="MultiplayerPeer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/PacketPeerGDNative.xml b/modules/gdnative/doc_classes/PacketPeerGDNative.xml
deleted file mode 100644
index 32863f8422..0000000000
--- a/modules/gdnative/doc_classes/PacketPeerGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="PacketPeerGDNative" inherits="PacketPeer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/StreamPeerGDNative.xml b/modules/gdnative/doc_classes/StreamPeerGDNative.xml
deleted file mode 100644
index a505de2106..0000000000
--- a/modules/gdnative/doc_classes/StreamPeerGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="StreamPeerGDNative" inherits="StreamPeer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml b/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml
deleted file mode 100644
index ddf354763c..0000000000
--- a/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebRTCDataChannelGDNative" inherits="WebRTCDataChannel" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml b/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml
deleted file mode 100644
index 821779a0ff..0000000000
--- a/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebRTCPeerConnectionGDNative" inherits="WebRTCPeerConnection" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 66d2dc267d..627883886c 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5105,97 +5105,6 @@
]
},
{
- "name": "net",
- "type": "NET",
- "version": {
- "major": 4,
- "minor": 0
- },
- "next": null,
- "api": [
- {
- "name": "godot_net_bind_stream_peer",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_stream_peer *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_bind_packet_peer",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_packet_peer *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_bind_multiplayer_peer",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_multiplayer_peer *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_set_webrtc_library",
- "return_type": "godot_error",
- "arguments": [
- [
- "const godot_net_webrtc_library *",
- "p_library"
- ]
- ]
- },
- {
- "name": "godot_net_bind_webrtc_peer_connection",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_webrtc_peer_connection *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_bind_webrtc_data_channel",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_webrtc_data_channel *",
- "p_interface"
- ]
- ]
- }
- ]
- },
- {
"name": "text",
"type": "TEXT",
"version": {
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 181fd71b82..4986b173cf 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -20,7 +20,6 @@ def _build_gdnative_api_struct_header(api):
"#include <gdnative/gdnative.h>",
"#include <android/godot_android.h>",
"#include <nativescript/godot_nativescript.h>",
- "#include <net/godot_net.h>",
"#include <pluginscript/godot_pluginscript.h>",
"#include <videodecoder/godot_videodecoder.h>",
"#include <text/godot_text.h>",
diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h
deleted file mode 100644
index 3fb7b9e1cc..0000000000
--- a/modules/gdnative/include/net/godot_net.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*************************************************************************/
-/* godot_net.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef GODOT_NATIVENET_H
-#define GODOT_NATIVENET_H
-
-#include <gdnative/gdnative.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// For future versions of the API we should only add new functions at the end of the structure and use the
-// version info to detect whether a call is available
-
-// Use these to populate version in your plugin
-#define GODOT_NET_API_MAJOR 3
-#define GODOT_NET_API_MINOR 1
-
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
- godot_object *data; /* User reference */
-
- /* This is StreamPeer */
- godot_error (*get_data)(void *user, uint8_t *p_buffer, int p_bytes);
- godot_error (*get_partial_data)(void *user, uint8_t *p_buffer, int p_bytes, int *r_received);
- godot_error (*put_data)(void *user, const uint8_t *p_data, int p_bytes);
- godot_error (*put_partial_data)(void *user, const uint8_t *p_data, int p_bytes, int *r_sent);
-
- int (*get_available_bytes)(const void *user);
-
- void *next; /* For extension? */
-} godot_net_stream_peer;
-
-/* Binds a StreamPeerGDNative to the provided interface */
-void godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface);
-
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is PacketPeer */
- godot_error (*get_packet)(void *, const uint8_t **, int *);
- godot_error (*put_packet)(void *, const uint8_t *, int);
- godot_int (*get_available_packet_count)(const void *);
- godot_int (*get_max_packet_size)(const void *);
-
- void *next; /* For extension? */
-} godot_net_packet_peer;
-
-/* Binds a PacketPeerGDNative to the provided interface */
-void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *);
-
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is PacketPeer */
- godot_error (*get_packet)(void *, const uint8_t **, int *);
- godot_error (*put_packet)(void *, const uint8_t *, int);
- godot_int (*get_available_packet_count)(const void *);
- godot_int (*get_max_packet_size)(const void *);
-
- /* This is MultiplayerPeer */
- void (*set_transfer_channel)(void *, godot_int);
- godot_int (*get_transfer_channel)(void *);
- void (*set_transfer_mode)(void *, godot_int);
- godot_int (*get_transfer_mode)(const void *);
- // 0 = broadcast, 1 = server, <0 = all but abs(value)
- void (*set_target_peer)(void *, godot_int);
- godot_int (*get_packet_peer)(const void *);
- godot_bool (*is_server)(const void *);
- void (*poll)(void *);
- // Must be > 0, 1 is for server
- int32_t (*get_unique_id)(const void *);
- void (*set_refuse_new_connections)(void *, godot_bool);
- godot_bool (*is_refusing_new_connections)(const void *);
- godot_int (*get_connection_status)(const void *);
-
- void *next; /* For extension? Or maybe not... */
-} godot_net_multiplayer_peer;
-
-/* Binds a MultiplayerPeerGDNative to the provided interface */
-void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *);
-
-#ifdef __cplusplus
-}
-#endif
-
-// WebRTC Bindings
-#include "net/godot_webrtc.h"
-
-#endif /* GODOT_NATIVENET_H */
diff --git a/modules/gdnative/include/net/godot_webrtc.h b/modules/gdnative/include/net/godot_webrtc.h
deleted file mode 100644
index 52006e56ec..0000000000
--- a/modules/gdnative/include/net/godot_webrtc.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*************************************************************************/
-/* godot_webrtc.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef GODOT_NATIVEWEBRTC_H
-#define GODOT_NATIVEWEBRTC_H
-
-#include <gdnative/gdnative.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define GODOT_NET_WEBRTC_API_MAJOR 4
-#define GODOT_NET_WEBRTC_API_MINOR 0
-
-/* Library Interface (used to set default GDNative WebRTC implementation */
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- /* Called when the library is unset as default interface via godot_net_set_webrtc_library */
- void (*unregistered)();
-
- /* Used by WebRTCPeerConnection create when GDNative is the default implementation. */
- /* Takes a pointer to WebRTCPeerConnectionGDNative, should bind and return OK, failure if binding was unsuccessful. */
- godot_error (*create_peer_connection)(godot_object *);
-
- void *next; /* For extension */
-} godot_net_webrtc_library;
-
-/* WebRTCPeerConnection interface */
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is WebRTCPeerConnection */
- godot_int (*get_connection_state)(const void *);
-
- godot_error (*initialize)(void *, const godot_dictionary *);
- godot_object *(*create_data_channel)(void *, const char *p_channel_name, const godot_dictionary *);
- godot_error (*create_offer)(void *);
- godot_error (*create_answer)(void *); /* unused for now, should be done automatically on set_local_description */
- godot_error (*set_remote_description)(void *, const char *, const char *);
- godot_error (*set_local_description)(void *, const char *, const char *);
- godot_error (*add_ice_candidate)(void *, const char *, int, const char *);
- godot_error (*poll)(void *);
- void (*close)(void *);
-
- void *next; /* For extension? */
-} godot_net_webrtc_peer_connection;
-
-/* WebRTCDataChannel interface */
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is PacketPeer */
- godot_error (*get_packet)(void *, const uint8_t **, int *);
- godot_error (*put_packet)(void *, const uint8_t *, int);
- godot_int (*get_available_packet_count)(const void *);
- godot_int (*get_max_packet_size)(const void *);
-
- /* This is WebRTCDataChannel */
- void (*set_write_mode)(void *, godot_int);
- godot_int (*get_write_mode)(const void *);
- bool (*was_string_packet)(const void *);
-
- godot_int (*get_ready_state)(const void *);
- const char *(*get_label)(const void *);
- bool (*is_ordered)(const void *);
- int (*get_id)(const void *);
- int (*get_max_packet_life_time)(const void *);
- int (*get_max_retransmits)(const void *);
- const char *(*get_protocol)(const void *);
- bool (*is_negotiated)(const void *);
- int (*get_buffered_amount)(const void *);
-
- godot_error (*poll)(void *);
- void (*close)(void *);
-
- void *next; /* For extension? */
-} godot_net_webrtc_data_channel;
-
-/* Set the default GDNative library */
-godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *);
-/* Binds a WebRTCPeerConnectionGDNative to the provided interface */
-void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *);
-/* Binds a WebRTCDataChannelGDNative to the provided interface */
-void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub
deleted file mode 100644
index b76500c003..0000000000
--- a/modules/gdnative/net/SCsub
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python
-
-Import("env")
-Import("env_gdnative")
-
-env_net = env_gdnative.Clone()
-
-has_webrtc = env_net["module_webrtc_enabled"]
-if has_webrtc:
- env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
-
-env_net.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
deleted file mode 100644
index 575d5f5060..0000000000
--- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*************************************************************************/
-/* multiplayer_peer_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 "multiplayer_peer_gdnative.h"
-
-MultiplayerPeerGDNative::MultiplayerPeerGDNative() {
- interface = nullptr;
-}
-
-MultiplayerPeerGDNative::~MultiplayerPeerGDNative() {
-}
-
-void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_interface) {
- interface = p_interface;
-}
-
-Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
-}
-
-Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
-}
-
-int MultiplayerPeerGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_max_packet_size(interface->data);
-}
-
-int MultiplayerPeerGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_packet_count(interface->data);
-}
-
-/* MultiplayerPeer */
-void MultiplayerPeerGDNative::set_transfer_channel(int p_channel) {
- ERR_FAIL_COND(interface == nullptr);
- return interface->set_transfer_channel(interface->data, p_channel);
-}
-
-int MultiplayerPeerGDNative::get_transfer_channel() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_transfer_channel(interface->data);
-}
-
-void MultiplayerPeerGDNative::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_transfer_mode(interface->data, (godot_int)p_mode);
-}
-
-Multiplayer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const {
- ERR_FAIL_COND_V(interface == nullptr, Multiplayer::TRANSFER_MODE_UNRELIABLE);
- return (Multiplayer::TransferMode)interface->get_transfer_mode(interface->data);
-}
-
-void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_target_peer(interface->data, p_peer_id);
-}
-
-int MultiplayerPeerGDNative::get_packet_peer() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_packet_peer(interface->data);
-}
-
-bool MultiplayerPeerGDNative::is_server() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->is_server(interface->data);
-}
-
-void MultiplayerPeerGDNative::poll() {
- ERR_FAIL_COND(interface == nullptr);
- interface->poll(interface->data);
-}
-
-int MultiplayerPeerGDNative::get_unique_id() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_unique_id(interface->data);
-}
-
-void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_refuse_new_connections(interface->data, p_enable);
-}
-
-bool MultiplayerPeerGDNative::is_refusing_new_connections() const {
- ERR_FAIL_COND_V(interface == nullptr, true);
- return interface->is_refusing_new_connections(interface->data);
-}
-
-MultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const {
- ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED);
- return (ConnectionStatus)interface->get_connection_status(interface->data);
-}
-
-void MultiplayerPeerGDNative::_bind_methods() {
- ADD_PROPERTY_DEFAULT("transfer_channel", 0);
- ADD_PROPERTY_DEFAULT("transfer_mode", Multiplayer::TRANSFER_MODE_UNRELIABLE);
- ADD_PROPERTY_DEFAULT("refuse_new_connections", true);
-}
-
-extern "C" {
-
-void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *p_impl) {
- ((MultiplayerPeerGDNative *)p_obj)->set_native_multiplayer_peer(p_impl);
-}
-}
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.h b/modules/gdnative/net/multiplayer_peer_gdnative.h
deleted file mode 100644
index 33e424d284..0000000000
--- a/modules/gdnative/net/multiplayer_peer_gdnative.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*************************************************************************/
-/* multiplayer_peer_gdnative.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 MULTIPLAYER_PEER_GDNATIVE_H
-#define MULTIPLAYER_PEER_GDNATIVE_H
-
-#include "core/multiplayer/multiplayer_peer.h"
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-class MultiplayerPeerGDNative : public MultiplayerPeer {
- GDCLASS(MultiplayerPeerGDNative, MultiplayerPeer);
-
-protected:
- static void _bind_methods();
- const godot_net_multiplayer_peer *interface;
-
-public:
- MultiplayerPeerGDNative();
- ~MultiplayerPeerGDNative();
-
- /* Sets the interface implementation from GDNative */
- void set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_impl);
-
- /* Specific to PacketPeer */
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
- virtual int get_max_packet_size() const override;
- virtual int get_available_packet_count() const override;
-
- /* Specific to MultiplayerPeer */
- virtual void set_transfer_channel(int p_channel) override;
- virtual int get_transfer_channel() const override;
- virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- virtual Multiplayer::TransferMode get_transfer_mode() const override;
- virtual void set_target_peer(int p_peer_id) override;
-
- virtual int get_packet_peer() const override;
-
- virtual bool is_server() const override;
-
- virtual void poll() override;
-
- virtual int get_unique_id() const override;
-
- virtual void set_refuse_new_connections(bool p_enable) override;
- virtual bool is_refusing_new_connections() const override;
-
- virtual ConnectionStatus get_connection_status() const override;
-};
-
-#endif // MULTIPLAYER_PEER_GDNATIVE_H
diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp
deleted file mode 100644
index 3bcdfed8ff..0000000000
--- a/modules/gdnative/net/packet_peer_gdnative.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************/
-/* packet_peer_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 "packet_peer_gdnative.h"
-
-PacketPeerGDNative::PacketPeerGDNative() {
- interface = nullptr;
-}
-
-PacketPeerGDNative::~PacketPeerGDNative() {
-}
-
-void PacketPeerGDNative::set_native_packet_peer(const godot_net_packet_peer *p_impl) {
- interface = p_impl;
-}
-
-void PacketPeerGDNative::_bind_methods() {
-}
-
-Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
-}
-
-Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
-}
-
-int PacketPeerGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_max_packet_size(interface->data);
-}
-
-int PacketPeerGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_packet_count(interface->data);
-}
-
-extern "C" {
-
-void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *p_impl) {
- ((PacketPeerGDNative *)p_obj)->set_native_packet_peer(p_impl);
-}
-}
diff --git a/modules/gdnative/net/packet_peer_gdnative.h b/modules/gdnative/net/packet_peer_gdnative.h
deleted file mode 100644
index 29013f9367..0000000000
--- a/modules/gdnative/net/packet_peer_gdnative.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*************************************************************************/
-/* packet_peer_gdnative.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 PACKET_PEER_GDNATIVE_H
-#define PACKET_PEER_GDNATIVE_H
-
-#include "core/io/packet_peer.h"
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-class PacketPeerGDNative : public PacketPeer {
- GDCLASS(PacketPeerGDNative, PacketPeer);
-
-protected:
- static void _bind_methods();
- const godot_net_packet_peer *interface;
-
-public:
- PacketPeerGDNative();
- ~PacketPeerGDNative();
-
- /* Sets the interface implementation from GDNative */
- void set_native_packet_peer(const godot_net_packet_peer *p_impl);
-
- /* Specific to PacketPeer */
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
- virtual int get_max_packet_size() const override;
- virtual int get_available_packet_count() const override;
-};
-
-#endif // PACKET_PEER_GDNATIVE_H
diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp
deleted file mode 100644
index 72ab72323d..0000000000
--- a/modules/gdnative/net/stream_peer_gdnative.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*************************************************************************/
-/* stream_peer_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 "stream_peer_gdnative.h"
-
-StreamPeerGDNative::StreamPeerGDNative() {
- interface = nullptr;
-}
-
-StreamPeerGDNative::~StreamPeerGDNative() {
-}
-
-void StreamPeerGDNative::set_native_stream_peer(const godot_net_stream_peer *p_interface) {
- interface = p_interface;
-}
-
-void StreamPeerGDNative::_bind_methods() {
-}
-
-Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->put_data(interface->data, p_data, p_bytes));
-}
-
-Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent));
-}
-
-Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->get_data(interface->data, p_buffer, p_bytes));
-}
-
-Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received));
-}
-
-int StreamPeerGDNative::get_available_bytes() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_bytes(interface->data);
-}
-
-extern "C" {
-
-void GDAPI godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface) {
- ((StreamPeerGDNative *)p_obj)->set_native_stream_peer(p_interface);
-}
-}
diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h
deleted file mode 100644
index dd5abceb83..0000000000
--- a/modules/gdnative/net/stream_peer_gdnative.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************/
-/* stream_peer_gdnative.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 STREAM_PEER_GDNATIVE_H
-#define STREAM_PEER_GDNATIVE_H
-
-#include "core/io/stream_peer.h"
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-class StreamPeerGDNative : public StreamPeer {
- GDCLASS(StreamPeerGDNative, StreamPeer);
-
-protected:
- static void _bind_methods();
- const godot_net_stream_peer *interface;
-
-public:
- StreamPeerGDNative();
- ~StreamPeerGDNative();
-
- /* Sets the interface implementation from GDNative */
- void set_native_stream_peer(const godot_net_stream_peer *p_interface);
-
- /* Specific to StreamPeer */
- Error put_data(const uint8_t *p_data, int p_bytes) override;
- Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) override;
- Error get_data(uint8_t *p_buffer, int p_bytes) override;
- Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) override;
- int get_available_bytes() const override;
-};
-
-#endif // STREAM_PEER_GDNATIVE_H
diff --git a/modules/gdnative/net/webrtc_gdnative.cpp b/modules/gdnative/net/webrtc_gdnative.cpp
deleted file mode 100644
index 76ccbad009..0000000000
--- a/modules/gdnative/net/webrtc_gdnative.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************/
-/* webrtc_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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 "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-#ifdef WEBRTC_GDNATIVE_ENABLED
-#include "modules/webrtc/webrtc_data_channel_gdnative.h"
-#include "modules/webrtc/webrtc_peer_connection_gdnative.h"
-#endif
-
-extern "C" {
-
-void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *p_impl) {
-#ifdef WEBRTC_GDNATIVE_ENABLED
- ((WebRTCPeerConnectionGDNative *)p_obj)->set_native_webrtc_peer_connection(p_impl);
-#endif
-}
-
-void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *p_impl) {
-#ifdef WEBRTC_GDNATIVE_ENABLED
- ((WebRTCDataChannelGDNative *)p_obj)->set_native_webrtc_data_channel(p_impl);
-#endif
-}
-
-godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *p_lib) {
-#ifdef WEBRTC_GDNATIVE_ENABLED
- return (godot_error)WebRTCPeerConnectionGDNative::set_default_library(p_lib);
-#else
- return (godot_error)ERR_UNAVAILABLE;
-#endif
-}
-}
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index e4c2b20224..a4ab5663ef 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -35,7 +35,6 @@
#include "gdnative.h"
#include "nativescript/register_types.h"
-#include "net/register_types.h"
#include "pluginscript/register_types.h"
#include "videodecoder/register_types.h"
@@ -265,7 +264,6 @@ void register_gdnative_types() {
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
- register_net_types();
register_nativescript_types();
register_pluginscript_types();
register_videodecoder_types();
@@ -329,7 +327,6 @@ void unregister_gdnative_types() {
unregister_videodecoder_types();
unregister_pluginscript_types();
unregister_nativescript_types();
- unregister_net_types();
memdelete(GDNativeCallRegistry::singleton);
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 23e88ae059..032e08f5a0 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -175,6 +175,11 @@ Error GDScriptAnalyzer::check_native_member_name_conflict(const StringName &p_me
return ERR_PARSE_ERROR;
}
+ if (GDScriptParser::get_builtin_type(p_member_name) != Variant::VARIANT_MAX) {
+ push_error(vformat(R"(The member "%s" cannot have the same name as a builtin type.)", p_member_name), p_member_node);
+ return ERR_PARSE_ERROR;
+ }
+
return OK;
}
@@ -2503,7 +2508,10 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
result.enum_type = name;
p_identifier->set_datatype(result);
} else {
- push_error(vformat(R"(Cannot find value "%s" in "%s".)", name, base.to_string()), p_identifier);
+ // Consider as a Dictionary
+ GDScriptParser::DataType dummy;
+ dummy.kind = GDScriptParser::DataType::VARIANT;
+ p_identifier->set_datatype(dummy);
}
} else {
push_error(R"(Cannot get property from enum value.)", p_identifier);
@@ -3676,6 +3684,11 @@ bool GDScriptAnalyzer::is_type_compatible(const GDScriptParser::DataType &p_targ
if (p_source.kind == GDScriptParser::DataType::BUILTIN && p_source.builtin_type == Variant::INT) {
return true;
}
+ if (p_source.kind == GDScriptParser::DataType::ENUM) {
+ if (p_source.native_type == p_target.native_type) {
+ return true;
+ }
+ }
if (p_source.kind == GDScriptParser::DataType::ENUM_VALUE) {
if (p_source.native_type == p_target.native_type && p_target.enum_values.has(p_source.enum_type)) {
return true;
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index a8aef84db3..947224e93e 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1071,19 +1071,25 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
}
}
- GDScriptCodeGenerator::Address assigned = _parse_expression(codegen, r_error, assignment->assigned_value);
- GDScriptCodeGenerator::Address op_result;
+ GDScriptCodeGenerator::Address assigned_value = _parse_expression(codegen, r_error, assignment->assigned_value);
if (r_error) {
return GDScriptCodeGenerator::Address();
}
- if (assignment->operation != GDScriptParser::AssignmentNode::OP_NONE) {
+ GDScriptCodeGenerator::Address to_assign;
+ bool has_operation = assignment->operation != GDScriptParser::AssignmentNode::OP_NONE;
+ if (has_operation) {
// Perform operation.
- op_result = codegen.add_temporary();
- gen->write_binary_operator(op_result, assignment->variant_op, target, assigned);
+ GDScriptCodeGenerator::Address op_result = codegen.add_temporary();
+ GDScriptCodeGenerator::Address og_value = _parse_expression(codegen, r_error, assignment->assignee);
+ gen->write_binary_operator(op_result, assignment->variant_op, og_value, assigned_value);
+ to_assign = op_result;
+
+ if (og_value.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
+ gen->pop_temporary();
+ }
} else {
- op_result = assigned;
- assigned = GDScriptCodeGenerator::Address();
+ to_assign = assigned_value;
}
GDScriptDataType assign_type = _gdtype_from_datatype(assignment->assignee->get_datatype());
@@ -1091,25 +1097,25 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
if (has_setter && !is_in_setter) {
// Call setter.
Vector<GDScriptCodeGenerator::Address> args;
- args.push_back(op_result);
+ args.push_back(to_assign);
gen->write_call(GDScriptCodeGenerator::Address(), GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::SELF), setter_function, args);
} else {
// Just assign.
if (assignment->use_conversion_assign) {
- gen->write_assign_with_conversion(target, op_result);
+ gen->write_assign_with_conversion(target, to_assign);
} else {
- gen->write_assign(target, op_result);
+ gen->write_assign(target, to_assign);
}
}
- if (op_result.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
- gen->pop_temporary();
+ if (to_assign.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
+ gen->pop_temporary(); // Pop assigned value or temp operation result.
}
- if (assigned.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
- gen->pop_temporary();
+ if (has_operation && assigned_value.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
+ gen->pop_temporary(); // Pop assigned value if not done before.
}
if (target.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
- gen->pop_temporary();
+ gen->pop_temporary(); // Pop the target to assignment.
}
}
return GDScriptCodeGenerator::Address(); // Assignment does not return a value.
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 2f8a054b2a..044ac4b661 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -637,7 +637,7 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
}
static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptCodeCompletionOption> &r_result) {
- if (p_annotation->name == "@export_range" || p_annotation->name == "@export_exp_range") {
+ if (p_annotation->name == "@export_range") {
if (p_argument == 3 || p_argument == 4) {
// Slider hint.
ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index bf21c8510a..6186d0edee 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -88,9 +88,9 @@ static String _get_var_type(const Variant *p_var) {
Object *bobj = p_var->get_validated_object_with_check(was_freed);
if (!bobj) {
if (was_freed) {
- basestr = "null instance";
- } else {
basestr = "previously freed";
+ } else {
+ basestr = "null instance";
}
} else {
basestr = bobj->get_class();
@@ -1233,7 +1233,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GD_ERR_BREAK(to_type < 0 || to_type >= Variant::VARIANT_MAX);
#ifdef DEBUG_ENABLED
- if (src->get_type() == Variant::OBJECT && !src->operator ObjectID().is_ref_counted() && ObjectDB::get_instance(src->operator ObjectID()) == nullptr) {
+ if (src->operator Object *() && !src->get_validated_object()) {
err_text = "Trying to cast a freed object.";
OPCODE_BREAK;
}
@@ -1263,7 +1263,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GD_ERR_BREAK(!nc);
#ifdef DEBUG_ENABLED
- if (src->get_type() == Variant::OBJECT && !src->operator ObjectID().is_ref_counted() && ObjectDB::get_instance(src->operator ObjectID()) == nullptr) {
+ if (src->operator Object *() && !src->get_validated_object()) {
err_text = "Trying to cast a freed object.";
OPCODE_BREAK;
}
@@ -1295,7 +1295,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GD_ERR_BREAK(!base_type);
#ifdef DEBUG_ENABLED
- if (src->get_type() == Variant::OBJECT && !src->operator ObjectID().is_ref_counted() && ObjectDB::get_instance(src->operator ObjectID()) == nullptr) {
+ if (src->operator Object *() && !src->get_validated_object()) {
err_text = "Trying to cast a freed object.";
OPCODE_BREAK;
}
@@ -2138,7 +2138,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
retvalue = gdfs;
- Error err = sig.connect(Callable(gdfs.ptr(), "_signal_callback"), varray(gdfs), Object::CONNECT_ONESHOT);
+ Error err = sig.connect(callable_bind(Callable(gdfs.ptr(), "_signal_callback"), retvalue), Object::CONNECT_ONESHOT);
if (err != OK) {
err_text = "Error connecting to signal: " + sig.get_name() + " during await.";
OPCODE_BREAK;
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index b6c48468f5..bd5a9f01b2 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -284,6 +284,23 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia
peer->res_queue.push_back(msg.utf8());
}
+void GDScriptLanguageProtocol::request_client(const String &p_method, const Variant &p_params, int p_client_id) {
+ if (p_client_id == -1) {
+ ERR_FAIL_COND_MSG(latest_client_id == -1,
+ "GDScript LSP: Can't notify client as none was connected.");
+ p_client_id = latest_client_id;
+ }
+ ERR_FAIL_COND(!clients.has(p_client_id));
+ Ref<LSPeer> peer = clients.get(p_client_id);
+ ERR_FAIL_COND(peer == nullptr);
+
+ Dictionary message = make_request(p_method, p_params, next_server_id);
+ next_server_id++;
+ String msg = Variant(message).to_json_string();
+ msg = format_output(msg);
+ peer->res_queue.push_back(msg.utf8());
+}
+
bool GDScriptLanguageProtocol::is_smart_resolve_enabled() const {
return bool(_EDITOR_GET("network/language_server/enable_smart_resolve"));
}
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h
index 5a2dd55c46..899446fb42 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.h
+++ b/modules/gdscript/language_server/gdscript_language_protocol.h
@@ -79,6 +79,8 @@ private:
int latest_client_id = 0;
int next_client_id = 0;
+ int next_server_id = 0;
+
Ref<GDScriptTextDocument> text_document;
Ref<GDScriptWorkspace> workspace;
@@ -107,6 +109,7 @@ public:
void stop();
void notify_client(const String &p_method, const Variant &p_params = Variant(), int p_client_id = -1);
+ void request_client(const String &p_method, const Variant &p_params = Variant(), int p_client_id = -1);
bool is_smart_resolve_enabled() const;
bool is_goto_native_symbols_enabled() const;
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index 1512b4bb89..f4b55cac02 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -42,6 +42,7 @@
#include "scene/resources/packed_scene.h"
void GDScriptWorkspace::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("apply_new_signal"), &GDScriptWorkspace::apply_new_signal);
ClassDB::bind_method(D_METHOD("didDeleteFiles"), &GDScriptWorkspace::did_delete_files);
ClassDB::bind_method(D_METHOD("symbol"), &GDScriptWorkspace::symbol);
ClassDB::bind_method(D_METHOD("parse_script", "path", "content"), &GDScriptWorkspace::parse_script);
@@ -52,6 +53,54 @@ void GDScriptWorkspace::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_script_api", "path"), &GDScriptWorkspace::generate_script_api);
}
+void GDScriptWorkspace::apply_new_signal(Object *obj, String function, PackedStringArray args) {
+ String function_signature = "func " + function;
+ Ref<Script> script = obj->get_script();
+
+ String source = script->get_source_code();
+
+ if (source.find(function_signature) != -1) {
+ return;
+ }
+
+ int first_class = source.find("\nclass ");
+ int start_line = 0;
+ if (first_class != -1) {
+ start_line = source.substr(0, first_class).split("\n").size();
+ } else {
+ start_line = source.split("\n").size();
+ }
+
+ String function_body = "\n\n" + function_signature + "(";
+ for (int i = 0; i < args.size(); ++i) {
+ function_body += args[i];
+ if (i < args.size() - 1) {
+ function_body += ", ";
+ }
+ }
+ function_body += ")";
+ if (EditorSettings::get_singleton()->get_setting("text_editor/completion/add_type_hints")) {
+ function_body += " -> void";
+ }
+ function_body += ":\n\tpass # Replace with function body.\n";
+
+ lsp::TextEdit text_edit;
+
+ if (first_class != -1) {
+ function_body += "\n\n";
+ }
+ text_edit.range.end.line = text_edit.range.start.line = start_line;
+
+ text_edit.newText = function_body;
+
+ String uri = get_file_uri(script->get_path());
+
+ lsp::ApplyWorkspaceEditParams params;
+ params.edit.add_edit(uri, text_edit);
+
+ GDScriptLanguageProtocol::get_singleton()->request_client("workspace/applyEdit", params.to_json());
+}
+
void GDScriptWorkspace::did_delete_files(const Dictionary &p_params) {
Array files = p_params["files"];
for (int i = 0; i < files.size(); ++i) {
@@ -360,6 +409,9 @@ Error GDScriptWorkspace::initialize() {
}
}
+ EditorNode *editor_node = EditorNode::get_singleton();
+ editor_node->connect("script_add_function_request", callable_mp(this, &GDScriptWorkspace::apply_new_signal));
+
return OK;
}
@@ -551,7 +603,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
}
}
-const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_requred) {
+const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_required) {
const lsp::DocumentSymbol *symbol = nullptr;
String path = get_file_path(p_doc_pos.textDocument.uri);
@@ -576,7 +628,10 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
} else {
ScriptLanguage::LookupResult ret;
- if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_requred), symbol_identifier, path, nullptr, ret)) {
+ if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").find("new(") > -1) {
+ symbol_identifier = "_init";
+ }
+ if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_required), symbol_identifier, path, nullptr, ret)) {
if (ret.type == ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION) {
String target_script_path = path;
if (!ret.script.is_null()) {
diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h
index 9496677449..6f5600b5cf 100644
--- a/modules/gdscript/language_server/gdscript_workspace.h
+++ b/modules/gdscript/language_server/gdscript_workspace.h
@@ -62,6 +62,8 @@ protected:
void list_script_files(const String &p_root_dir, List<String> &r_files);
+ void apply_new_signal(Object *obj, String function, PackedStringArray args);
+
public:
String root;
String root_uri;
@@ -85,7 +87,7 @@ public:
void publish_diagnostics(const String &p_path);
void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options);
- const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_requred = false);
+ const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false);
void resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list);
const lsp::DocumentSymbol *resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params);
void resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list);
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index 9ac6c6bd4e..662382d279 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -263,6 +263,16 @@ struct WorkspaceEdit {
*/
Map<String, Vector<TextEdit>> changes;
+ _FORCE_INLINE_ void add_edit(const String &uri, const TextEdit &edit) {
+ if (changes.has(uri)) {
+ changes[uri].push_back(edit);
+ } else {
+ Vector<TextEdit> edits;
+ edits.push_back(edit);
+ changes[uri] = edits;
+ }
+ }
+
_FORCE_INLINE_ Dictionary to_json() const {
Dictionary dict;
@@ -1322,6 +1332,18 @@ struct DocumentSymbol {
}
};
+struct ApplyWorkspaceEditParams {
+ WorkspaceEdit edit;
+
+ Dictionary to_json() {
+ Dictionary dict;
+
+ dict["edit"] = edit.to_json();
+
+ return dict;
+ }
+};
+
struct NativeSymbolInspectParams {
String native_class;
String symbol_name;
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd
new file mode 100644
index 0000000000..b84ccdce81
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd
@@ -0,0 +1,5 @@
+class Vector2:
+ pass
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out
new file mode 100644
index 0000000000..87863baf75
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The member "Vector2" cannot have the same name as a builtin type.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd
new file mode 100644
index 0000000000..a7c0a29a69
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd
@@ -0,0 +1,4 @@
+const Vector2 = 0
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out
new file mode 100644
index 0000000000..87863baf75
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The member "Vector2" cannot have the same name as a builtin type.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd
new file mode 100644
index 0000000000..930f91b389
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd
@@ -0,0 +1,4 @@
+enum Vector2 { A, B }
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out
new file mode 100644
index 0000000000..87863baf75
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The member "Vector2" cannot have the same name as a builtin type.
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd
new file mode 100644
index 0000000000..7cba29884c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd
@@ -0,0 +1,4 @@
+var Vector2
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out
new file mode 100644
index 0000000000..87863baf75
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+The member "Vector2" cannot have the same name as a builtin type.
diff --git a/modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.gd b/modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.gd
new file mode 100644
index 0000000000..3eb02816ed
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.gd
@@ -0,0 +1,11 @@
+#GDTEST_OK
+var prop : int = 0:
+ get:
+ return prop
+ set(value):
+ prop = value % 7
+
+func test():
+ for i in 7:
+ prop += 1
+ print(prop)
diff --git a/modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.out b/modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.out
new file mode 100644
index 0000000000..76157853f2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/property_with_operator_assignment.out
@@ -0,0 +1,8 @@
+GDTEST_OK
+1
+2
+3
+4
+5
+6
+0
diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml
index 91df7d8014..b4f03cd1ed 100644
--- a/modules/gltf/doc_classes/GLTFLight.xml
+++ b/modules/gltf/doc_classes/GLTFLight.xml
@@ -7,17 +7,25 @@
<tutorials>
</tutorials>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
+ The [Color] of the light. Defaults to white. A black color causes the light to have no effect.
</member>
<member name="inner_cone_angle" type="float" setter="set_inner_cone_angle" getter="get_inner_cone_angle" default="0.0">
+ The inner angle of the cone in a spotlight. Must be less than or equal to the outer cone angle.
+ Within this angle, the light is at full brightness. Between the inner and outer cone angles, there is a transition from full brightness to zero brightness. When creating a Godot [SpotLight3D], the ratio between the inner and outer cone angles is used to calculate the attenuation of the light.
</member>
- <member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="0.0">
+ <member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="1.0">
+ The intensity of the light. This is expressed in candelas (lumens per steradian) for point and spot lights, and lux (lumens per m²) for directional lights. When creating a Godot light, this value is converted to a unitless multiplier.
</member>
<member name="light_type" type="String" setter="set_light_type" getter="get_light_type" default="&quot;&quot;">
+ The type of the light. The values accepted by Godot are "point", "spot", and "directional", which correspond to Godot's [OmniLight3D], [SpotLight3D], and [DirectionalLight3D] respectively.
</member>
- <member name="outer_cone_angle" type="float" setter="set_outer_cone_angle" getter="get_outer_cone_angle" default="0.0">
+ <member name="outer_cone_angle" type="float" setter="set_outer_cone_angle" getter="get_outer_cone_angle" default="0.785398">
+ The outer angle of the cone in a spotlight. Must be greater than or equal to the inner angle.
+ At this angle, the light drops off to zero brightness. Between the inner and outer cone angles, there is a transition from full brightness to zero brightness. If this angle is a half turn, then the spotlight emits in all directions. When creating a Godot [SpotLight3D], the outer cone angle is used as the angle of the spotlight.
</member>
- <member name="range" type="float" setter="set_range" getter="get_range" default="0.0">
+ <member name="range" type="float" setter="set_range" getter="get_range" default="inf">
+ The range of the light, beyond which the light has no effect. GLTF lights with no range defined behave like physical lights (which have infinite range). When creating a Godot light, the range is clamped to 4096.
</member>
</members>
</class>
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
index fd9f758f10..3ce5ea23dc 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
@@ -86,7 +86,7 @@ void SceneExporterGLTFPlugin::convert_scene_to_gltf2() {
editor->show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
return;
}
- String filename = String(root->get_filename().get_file().get_basename());
+ String filename = String(root->get_scene_file_path().get_file().get_basename());
if (filename.is_empty()) {
filename = root->get_name();
}
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index df2856ec7c..5f2e8d4ba6 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -78,7 +78,10 @@
Error GLTFDocument::serialize(Ref<GLTFState> state, Node *p_root, const String &p_path) {
uint64_t begin_time = OS::get_singleton()->get_ticks_usec();
- _convert_scene_node(state, p_root, p_root, -1, -1);
+ state->skeleton3d_to_gltf_skeleton.clear();
+ state->skin_and_skeleton3d_to_gltf_skin.clear();
+
+ _convert_scene_node(state, p_root, -1, -1);
if (!state->buffers.size()) {
state->buffers.push_back(Vector<uint8_t>());
}
@@ -97,11 +100,7 @@ Error GLTFDocument::serialize(Ref<GLTFState> state, Node *p_root, const String &
if (err != OK) {
return Error::FAILED;
}
- /* STEP 4 CREATE BONE ATTACHMENTS */
- err = _serialize_bone_attachment(state);
- if (err != OK) {
- return Error::FAILED;
- }
+
/* STEP 5 SERIALIZE MESHES (we have enough info now) */
err = _serialize_meshes(state);
if (err != OK) {
@@ -249,30 +248,6 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref<GLTFState> state) {
return OK;
}
-Error GLTFDocument::_serialize_bone_attachment(Ref<GLTFState> state) {
- for (int skeleton_i = 0; skeleton_i < state->skeletons.size(); skeleton_i++) {
- for (int attachment_i = 0; attachment_i < state->skeletons[skeleton_i]->bone_attachments.size(); attachment_i++) {
- BoneAttachment3D *bone_attachment = state->skeletons[skeleton_i]->bone_attachments[attachment_i];
- String bone_name = bone_attachment->get_bone_name();
- bone_name = _sanitize_bone_name(bone_name);
- int32_t bone = state->skeletons[skeleton_i]->godot_skeleton->find_bone(bone_name);
- ERR_CONTINUE(bone == -1);
- for (int skin_i = 0; skin_i < state->skins.size(); skin_i++) {
- if (state->skins[skin_i]->skeleton != skeleton_i) {
- continue;
- }
-
- for (int node_i = 0; node_i < bone_attachment->get_child_count(); node_i++) {
- ERR_CONTINUE(bone >= state->skins[skin_i]->joints.size());
- _convert_scene_node(state, bone_attachment->get_child(node_i), bone_attachment->get_owner(), state->skins[skin_i]->joints[bone], 0);
- }
- break;
- }
- }
- }
- return OK;
-}
-
Error GLTFDocument::_parse_glb(const String &p_path, Ref<GLTFState> state) {
Error err;
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -2131,11 +2106,14 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
continue;
}
Array primitives;
- Array targets;
Dictionary gltf_mesh;
Array target_names;
Array weights;
+ for (int morph_i = 0; morph_i < import_mesh->get_blend_shape_count(); morph_i++) {
+ target_names.push_back(import_mesh->get_blend_shape_name(morph_i));
+ }
for (int surface_i = 0; surface_i < import_mesh->get_surface_count(); surface_i++) {
+ Array targets;
Dictionary primitive;
Mesh::PrimitiveType primitive_type = import_mesh->get_surface_primitive_type(surface_i);
switch (primitive_type) {
@@ -2337,10 +2315,10 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
const Array &a = array[Mesh::ARRAY_WEIGHTS];
const Vector<Vector3> &vertex_array = array[Mesh::ARRAY_VERTEX];
if ((a.size() / JOINT_GROUP_SIZE) == vertex_array.size()) {
- const int ret_size = a.size() / JOINT_GROUP_SIZE;
+ int32_t vertex_count = vertex_array.size();
Vector<Color> attribs;
- attribs.resize(ret_size);
- for (int i = 0; i < ret_size; i++) {
+ attribs.resize(vertex_count);
+ for (int i = 0; i < vertex_count; i++) {
attribs.write[i] = Color(a[(i * JOINT_GROUP_SIZE) + 0], a[(i * JOINT_GROUP_SIZE) + 1], a[(i * JOINT_GROUP_SIZE) + 2], a[(i * JOINT_GROUP_SIZE) + 3]);
}
attributes["WEIGHTS_0"] = _encode_accessor_as_weights(state, attribs, true);
@@ -2410,7 +2388,6 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
ArrayMesh::BlendShapeMode shape_mode = import_mesh->get_blend_shape_mode();
for (int morph_i = 0; morph_i < import_mesh->get_blend_shape_count(); morph_i++) {
Array array_morph = import_mesh->get_surface_blend_shape_arrays(surface_i, morph_i);
- target_names.push_back(import_mesh->get_blend_shape_name(morph_i));
Dictionary t;
Vector<Vector3> varr = array_morph[Mesh::ARRAY_VERTEX];
Array mesh_arrays = import_mesh->get_surface_arrays(surface_i);
@@ -2427,22 +2404,21 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
}
Vector<Vector3> narr = array_morph[Mesh::ARRAY_NORMAL];
- if (varr.size()) {
+ if (narr.size()) {
t["NORMAL"] = _encode_accessor_as_vec3(state, narr, true);
}
Vector<real_t> tarr = array_morph[Mesh::ARRAY_TANGENT];
if (tarr.size()) {
const int ret_size = tarr.size() / 4;
- Vector<Color> attribs;
+ Vector<Vector3> attribs;
attribs.resize(ret_size);
for (int i = 0; i < ret_size; i++) {
- Color tangent;
- tangent.r = tarr[(i * 4) + 0];
- tangent.g = tarr[(i * 4) + 1];
- tangent.b = tarr[(i * 4) + 2];
- tangent.a = tarr[(i * 4) + 3];
+ Vector3 vec3;
+ vec3.x = tarr[(i * 4) + 0];
+ vec3.y = tarr[(i * 4) + 1];
+ vec3.z = tarr[(i * 4) + 2];
}
- t["TANGENT"] = _encode_accessor_as_color(state, attribs, true);
+ t["TANGENT"] = _encode_accessor_as_vec3(state, attribs, true);
}
targets.push_back(t);
}
@@ -2471,12 +2447,13 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
Dictionary e;
e["targetNames"] = target_names;
- for (int j = 0; j < target_names.size(); j++) {
+ weights.resize(target_names.size());
+ for (int name_i = 0; name_i < target_names.size(); name_i++) {
real_t weight = 0.0;
- if (j < state->meshes.write[gltf_mesh_i]->get_blend_weights().size()) {
- weight = state->meshes.write[gltf_mesh_i]->get_blend_weights()[j];
+ if (name_i < state->meshes.write[gltf_mesh_i]->get_blend_weights().size()) {
+ weight = state->meshes.write[gltf_mesh_i]->get_blend_weights()[name_i];
}
- weights.push_back(weight);
+ weights[name_i] = weight;
}
if (weights.size()) {
gltf_mesh["weights"] = weights;
@@ -3757,10 +3734,7 @@ void GLTFDocument::spec_gloss_to_metal_base_color(const Color &p_specular_factor
r_base_color.g = Math::lerp(base_color_from_diffuse.g, base_color_from_specular.g, r_metallic * r_metallic);
r_base_color.b = Math::lerp(base_color_from_diffuse.b, base_color_from_specular.b, r_metallic * r_metallic);
r_base_color.a = p_diffuse.a;
- r_base_color.r = CLAMP(r_base_color.r, 0.0f, 1.0f);
- r_base_color.g = CLAMP(r_base_color.g, 0.0f, 1.0f);
- r_base_color.b = CLAMP(r_base_color.b, 0.0f, 1.0f);
- r_base_color.a = CLAMP(r_base_color.a, 0.0f, 1.0f);
+ r_base_color = r_base_color.clamp();
}
GLTFNodeIndex GLTFDocument::_find_highest_node(Ref<GLTFState> state, const Vector<GLTFNodeIndex> &subset) {
@@ -4288,6 +4262,7 @@ Error GLTFDocument::_create_skeletons(Ref<GLTFState> state) {
Skeleton3D *skeleton = memnew(Skeleton3D);
gltf_skeleton->godot_skeleton = skeleton;
+ state->skeleton3d_to_gltf_skeleton[skeleton->get_instance_id()] = skel_i;
// Make a unique name, no gltf node represents this skeleton
skeleton->set_name(_gen_unique_name(state, "Skeleton3D"));
@@ -4373,6 +4348,16 @@ Error GLTFDocument::_map_skin_joints_indices_to_skeleton_bone_indices(Ref<GLTFSt
Error GLTFDocument::_serialize_skins(Ref<GLTFState> state) {
_remove_duplicate_skins(state);
+ Array json_skins;
+ for (int skin_i = 0; skin_i < state->skins.size(); skin_i++) {
+ Ref<GLTFSkin> gltf_skin = state->skins[skin_i];
+ Dictionary json_skin;
+ json_skin["inverseBindMatrices"] = _encode_accessor_as_xform(state, gltf_skin->inverse_binds, false);
+ json_skin["joints"] = gltf_skin->get_joints();
+ json_skin["name"] = gltf_skin->get_name();
+ json_skins.push_back(json_skin);
+ }
+ state->json["skins"] = json_skins;
return OK;
}
@@ -4751,30 +4736,74 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) {
channels.push_back(t);
}
if (track.weight_tracks.size()) {
+ double length = 0.0f;
+
+ for (int32_t track_idx = 0; track_idx < track.weight_tracks.size(); track_idx++) {
+ int32_t last_time_index = track.weight_tracks[track_idx].times.size() - 1;
+ length = MAX(length, track.weight_tracks[track_idx].times[last_time_index]);
+ }
+
Dictionary t;
t["sampler"] = samplers.size();
Dictionary s;
-
Vector<real_t> times;
- Vector<real_t> values;
+ const double increment = 1.0 / BAKE_FPS;
+ {
+ double time = 0.0;
+ bool last = false;
+ while (true) {
+ times.push_back(time);
+ if (last) {
+ break;
+ }
+ time += increment;
+ if (time >= length) {
+ last = true;
+ time = length;
+ }
+ }
+ }
- for (int32_t times_i = 0; times_i < track.weight_tracks[0].times.size(); times_i++) {
- real_t time = track.weight_tracks[0].times[times_i];
- times.push_back(time);
+ for (int32_t track_idx = 0; track_idx < track.weight_tracks.size(); track_idx++) {
+ double time = 0.0;
+ bool last = false;
+ Vector<real_t> weight_track;
+ while (true) {
+ float weight = _interpolate_track<float>(track.weight_tracks[track_idx].times,
+ track.weight_tracks[track_idx].values,
+ time,
+ track.weight_tracks[track_idx].interpolation);
+ weight_track.push_back(weight);
+ if (last) {
+ break;
+ }
+ time += increment;
+ if (time >= length) {
+ last = true;
+ time = length;
+ }
+ }
+ track.weight_tracks.write[track_idx].times = times;
+ track.weight_tracks.write[track_idx].values = weight_track;
}
- values.resize(times.size() * track.weight_tracks.size());
- // TODO Sort by order in blend shapes
+ Vector<real_t> all_track_times = times;
+ Vector<real_t> all_track_values;
+ int32_t values_size = track.weight_tracks[0].values.size();
+ int32_t weight_tracks_size = track.weight_tracks.size();
+ all_track_values.resize(weight_tracks_size * values_size);
for (int k = 0; k < track.weight_tracks.size(); k++) {
Vector<float> wdata = track.weight_tracks[k].values;
for (int l = 0; l < wdata.size(); l++) {
- values.write[l * track.weight_tracks.size() + k] = wdata.write[l];
+ int32_t index = l * weight_tracks_size + k;
+ ERR_BREAK(index >= all_track_values.size());
+ all_track_values.write[index] = wdata.write[l];
}
}
s["interpolation"] = interpolation_to_string(track.weight_tracks[track.weight_tracks.size() - 1].interpolation);
- s["input"] = _encode_accessor_as_floats(state, times, false);
- s["output"] = _encode_accessor_as_floats(state, values, false);
+ s["input"] = _encode_accessor_as_floats(state, all_track_times, false);
+ s["output"] = _encode_accessor_as_floats(state, all_track_values, false);
samplers.push_back(s);
@@ -4908,7 +4937,7 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) {
track->weight_tracks.resize(wc);
const int expected_value_count = times.size() * output_count * wc;
- ERR_FAIL_COND_V_MSG(weights.size() != expected_value_count, ERR_PARSE_ERROR, "Invalid weight data, expected " + itos(expected_value_count) + " weight values, got " + itos(weights.size()) + " instead.");
+ ERR_CONTINUE_MSG(weights.size() != expected_value_count, "Invalid weight data, expected " + itos(expected_value_count) + " weight values, got " + itos(weights.size()) + " instead.");
const int wlen = weights.size() / wc;
for (int k = 0; k < wc; k++) { //separate tracks, having them together is not such a good idea
@@ -4973,7 +5002,7 @@ BoneAttachment3D *GLTFDocument::_generate_bone_attachment(Ref<GLTFState> state,
return bone_attachment;
}
-GLTFMeshIndex GLTFDocument::_convert_mesh_instance(Ref<GLTFState> state, MeshInstance3D *p_mesh_instance) {
+GLTFMeshIndex GLTFDocument::_convert_mesh_to_gltf(Ref<GLTFState> state, MeshInstance3D *p_mesh_instance) {
ERR_FAIL_NULL_V(p_mesh_instance, -1);
if (p_mesh_instance->get_mesh().is_null()) {
return -1;
@@ -5074,7 +5103,7 @@ Node3D *GLTFDocument::_generate_light(Ref<GLTFState> state, Node *scene_parent,
const float range = CLAMP(l->range, 0, 4096);
// Doubling the range will double the effective brightness, so we need double attenuation (half brightness).
// We want to have double intensity give double brightness, so we need half the attenuation.
- const float attenuation = range / intensity;
+ const float attenuation = range / (intensity * 2048);
if (l->light_type == "point") {
OmniLight3D *light = memnew(OmniLight3D);
light->set_param(OmniLight3D::PARAM_ATTENUATION, attenuation);
@@ -5150,13 +5179,13 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig
OmniLight3D *light = cast_to<OmniLight3D>(p_light);
l->range = light->get_param(OmniLight3D::PARAM_RANGE);
float attenuation = p_light->get_param(OmniLight3D::PARAM_ATTENUATION);
- l->intensity = l->range / attenuation;
+ l->intensity = l->range / (attenuation * 2048);
} else if (cast_to<SpotLight3D>(p_light)) {
l->light_type = "spot";
SpotLight3D *light = cast_to<SpotLight3D>(p_light);
l->range = light->get_param(SpotLight3D::PARAM_RANGE);
float attenuation = light->get_param(SpotLight3D::PARAM_ATTENUATION);
- l->intensity = l->range / attenuation;
+ l->intensity = l->range / (attenuation * 2048);
l->outer_cone_angle = Math::deg2rad(light->get_param(SpotLight3D::PARAM_SPOT_ANGLE));
// This equation is the inverse of the import equation (which has a desmos link).
@@ -5170,17 +5199,6 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig
return light_index;
}
-GLTFSkeletonIndex GLTFDocument::_convert_skeleton(Ref<GLTFState> state, Skeleton3D *p_skeleton) {
- print_verbose("glTF: Converting skeleton: " + p_skeleton->get_name());
- Ref<GLTFSkeleton> gltf_skeleton;
- gltf_skeleton.instantiate();
- gltf_skeleton->set_name(_gen_unique_name(state, p_skeleton->get_name()));
- gltf_skeleton->godot_skeleton = p_skeleton;
- GLTFSkeletonIndex skeleton_i = state->skeletons.size();
- state->skeletons.push_back(gltf_skeleton);
- return skeleton_i;
-}
-
void GLTFDocument::_convert_spatial(Ref<GLTFState> state, Node3D *p_spatial, Ref<GLTFNode> p_node) {
Transform3D xform = p_spatial->get_transform();
p_node->scale = xform.basis.get_scale();
@@ -5196,7 +5214,7 @@ Node3D *GLTFDocument::_generate_spatial(Ref<GLTFState> state, Node *scene_parent
return spatial;
}
-void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, Node *p_root, const GLTFNodeIndex p_gltf_parent, const GLTFNodeIndex p_gltf_root) {
+void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, const GLTFNodeIndex p_gltf_parent, const GLTFNodeIndex p_gltf_root) {
bool retflag = true;
_check_visibility(p_current, retflag);
if (retflag) {
@@ -5210,37 +5228,41 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No
_convert_spatial(state, spatial, gltf_node);
}
if (cast_to<MeshInstance3D>(p_current)) {
- Node3D *spatial = cast_to<Node3D>(p_current);
- _convert_mesh_to_gltf(p_current, state, spatial, gltf_node);
+ MeshInstance3D *mi = cast_to<MeshInstance3D>(p_current);
+ _convert_mesh_instance_to_gltf(mi, state, gltf_node);
} else if (cast_to<BoneAttachment3D>(p_current)) {
- _convert_bone_attachment_to_gltf(p_current, state, gltf_node, retflag);
- // TODO 2020-12-21 iFire Handle the case of objects under the bone attachment.
+ BoneAttachment3D *bone = cast_to<BoneAttachment3D>(p_current);
+ _convert_bone_attachment_to_gltf(bone, state, p_gltf_parent, p_gltf_root, gltf_node);
return;
} else if (cast_to<Skeleton3D>(p_current)) {
- _convert_skeleton_to_gltf(p_current, state, p_gltf_parent, p_gltf_root, gltf_node, p_root);
+ Skeleton3D *skel = cast_to<Skeleton3D>(p_current);
+ _convert_skeleton_to_gltf(skel, state, p_gltf_parent, p_gltf_root, gltf_node);
// We ignore the Godot Engine node that is the skeleton.
return;
} else if (cast_to<MultiMeshInstance3D>(p_current)) {
- _convert_mult_mesh_instance_to_gltf(p_current, p_gltf_parent, p_gltf_root, gltf_node, state, p_root);
+ MultiMeshInstance3D *multi = cast_to<MultiMeshInstance3D>(p_current);
+ _convert_mult_mesh_instance_to_gltf(multi, p_gltf_parent, p_gltf_root, gltf_node, state);
#ifdef MODULE_CSG_ENABLED
} else if (cast_to<CSGShape3D>(p_current)) {
- if (p_current->get_parent() && cast_to<CSGShape3D>(p_current)->is_root_shape()) {
- _convert_csg_shape_to_gltf(p_current, p_gltf_parent, gltf_node, state);
+ CSGShape3D *shape = cast_to<CSGShape3D>(p_current);
+ if (shape->get_parent() && shape->is_root_shape()) {
+ _convert_csg_shape_to_gltf(shape, p_gltf_parent, gltf_node, state);
}
#endif // MODULE_CSG_ENABLED
#ifdef MODULE_GRIDMAP_ENABLED
} else if (cast_to<GridMap>(p_current)) {
- _convert_grid_map_to_gltf(p_current, p_gltf_parent, p_gltf_root, gltf_node, state, p_root);
+ GridMap *gridmap = Object::cast_to<GridMap>(p_current);
+ _convert_grid_map_to_gltf(gridmap, p_gltf_parent, p_gltf_root, gltf_node, state);
#endif // MODULE_GRIDMAP_ENABLED
} else if (cast_to<Camera3D>(p_current)) {
Camera3D *camera = Object::cast_to<Camera3D>(p_current);
- _convert_camera_to_gltf(camera, state, camera, gltf_node);
+ _convert_camera_to_gltf(camera, state, gltf_node);
} else if (cast_to<Light3D>(p_current)) {
Light3D *light = Object::cast_to<Light3D>(p_current);
- _convert_light_to_gltf(light, state, light, gltf_node);
+ _convert_light_to_gltf(light, state, gltf_node);
} else if (cast_to<AnimationPlayer>(p_current)) {
AnimationPlayer *animation_player = Object::cast_to<AnimationPlayer>(p_current);
- _convert_animation_player_to_gltf(animation_player, state, p_gltf_parent, p_gltf_root, gltf_node, p_current, p_root);
+ _convert_animation_player_to_gltf(animation_player, state, p_gltf_parent, p_gltf_root, gltf_node, p_current);
}
GLTFNodeIndex current_node_i = state->nodes.size();
GLTFNodeIndex gltf_root = p_gltf_root;
@@ -5252,13 +5274,13 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No
}
_create_gltf_node(state, p_current, current_node_i, p_gltf_parent, gltf_root, gltf_node);
for (int node_i = 0; node_i < p_current->get_child_count(); node_i++) {
- _convert_scene_node(state, p_current->get_child(node_i), p_root, current_node_i, gltf_root);
+ _convert_scene_node(state, p_current->get_child(node_i), current_node_i, gltf_root);
}
}
#ifdef MODULE_CSG_ENABLED
-void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state) {
- CSGShape3D *csg = Object::cast_to<CSGShape3D>(p_current);
+void GLTFDocument::_convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state) {
+ CSGShape3D *csg = p_current;
csg->call("_update_shape");
Array meshes = csg->get_meshes();
if (meshes.size() != 2) {
@@ -5289,16 +5311,15 @@ void GLTFDocument::_create_gltf_node(Ref<GLTFState> state, Node *p_scene_parent,
GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_gltf_node, Ref<GLTFNode> gltf_node) {
state->scene_nodes.insert(current_node_i, p_scene_parent);
state->nodes.push_back(gltf_node);
- if (current_node_i == p_parent_node_index) {
- return;
- }
+ ERR_FAIL_COND(current_node_i == p_parent_node_index);
+ state->nodes.write[current_node_i]->parent = p_parent_node_index;
if (p_parent_node_index == -1) {
return;
}
state->nodes.write[p_parent_node_index]->children.push_back(current_node_i);
}
-void GLTFDocument::_convert_animation_player_to_gltf(AnimationPlayer *animation_player, Ref<GLTFState> state, const GLTFNodeIndex &p_gltf_current, const GLTFNodeIndex &p_gltf_root_index, Ref<GLTFNode> p_gltf_node, Node *p_scene_parent, Node *p_root) {
+void GLTFDocument::_convert_animation_player_to_gltf(AnimationPlayer *animation_player, Ref<GLTFState> state, GLTFNodeIndex p_gltf_current, GLTFNodeIndex p_gltf_root_index, Ref<GLTFNode> p_gltf_node, Node *p_scene_parent) {
ERR_FAIL_COND(!animation_player);
state->animation_players.push_back(animation_player);
print_verbose(String("glTF: Converting animation player: ") + animation_player->get_name());
@@ -5317,7 +5338,7 @@ void GLTFDocument::_check_visibility(Node *p_node, bool &retflag) {
retflag = false;
}
-void GLTFDocument::_convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> state, Node3D *spatial, Ref<GLTFNode> gltf_node) {
+void GLTFDocument::_convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> state, Ref<GLTFNode> gltf_node) {
ERR_FAIL_COND(!camera);
GLTFCameraIndex camera_index = _convert_camera(state, camera);
if (camera_index != -1) {
@@ -5325,7 +5346,7 @@ void GLTFDocument::_convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> stat
}
}
-void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, Node3D *spatial, Ref<GLTFNode> gltf_node) {
+void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, Ref<GLTFNode> gltf_node) {
ERR_FAIL_COND(!light);
GLTFLightIndex light_index = _convert_light(state, light);
if (light_index != -1) {
@@ -5334,43 +5355,39 @@ void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> state,
}
#ifdef MODULE_GRIDMAP_ENABLED
-void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node) {
- GridMap *grid_map = Object::cast_to<GridMap>(p_scene_parent);
- ERR_FAIL_COND(!grid_map);
- Array cells = grid_map->get_used_cells();
+void GLTFDocument::_convert_grid_map_to_gltf(GridMap *p_grid_map, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state) {
+ Array cells = p_grid_map->get_used_cells();
for (int32_t k = 0; k < cells.size(); k++) {
GLTFNode *new_gltf_node = memnew(GLTFNode);
gltf_node->children.push_back(state->nodes.size());
state->nodes.push_back(new_gltf_node);
Vector3 cell_location = cells[k];
- int32_t cell = grid_map->get_cell_item(
+ int32_t cell = p_grid_map->get_cell_item(
Vector3(cell_location.x, cell_location.y, cell_location.z));
EditorSceneImporterMeshNode3D *import_mesh_node = memnew(EditorSceneImporterMeshNode3D);
- import_mesh_node->set_mesh(grid_map->get_mesh_library()->get_item_mesh(cell));
+ import_mesh_node->set_mesh(p_grid_map->get_mesh_library()->get_item_mesh(cell));
Transform3D cell_xform;
cell_xform.basis.set_orthogonal_index(
- grid_map->get_cell_item_orientation(
+ p_grid_map->get_cell_item_orientation(
Vector3(cell_location.x, cell_location.y, cell_location.z)));
- cell_xform.basis.scale(Vector3(grid_map->get_cell_scale(),
- grid_map->get_cell_scale(),
- grid_map->get_cell_scale()));
- cell_xform.set_origin(grid_map->map_to_world(
+ cell_xform.basis.scale(Vector3(p_grid_map->get_cell_scale(),
+ p_grid_map->get_cell_scale(),
+ p_grid_map->get_cell_scale()));
+ cell_xform.set_origin(p_grid_map->map_to_world(
Vector3(cell_location.x, cell_location.y, cell_location.z)));
Ref<GLTFMesh> gltf_mesh;
gltf_mesh.instantiate();
gltf_mesh = import_mesh_node;
new_gltf_node->mesh = state->meshes.size();
state->meshes.push_back(gltf_mesh);
- new_gltf_node->xform = cell_xform * grid_map->get_transform();
- new_gltf_node->set_name(_gen_unique_name(state, grid_map->get_mesh_library()->get_item_name(cell)));
+ new_gltf_node->xform = cell_xform * p_grid_map->get_transform();
+ new_gltf_node->set_name(_gen_unique_name(state, p_grid_map->get_mesh_library()->get_item_name(cell)));
}
}
#endif // MODULE_GRIDMAP_ENABLED
-void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node) {
- MultiMeshInstance3D *multi_mesh_instance = Object::cast_to<MultiMeshInstance3D>(p_scene_parent);
- ERR_FAIL_COND(!multi_mesh_instance);
- Ref<MultiMesh> multi_mesh = multi_mesh_instance->get_multimesh();
+void GLTFDocument::_convert_mult_mesh_instance_to_gltf(MultiMeshInstance3D *p_multi_mesh_instance, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state) {
+ Ref<MultiMesh> multi_mesh = p_multi_mesh_instance->get_multimesh();
if (multi_mesh.is_valid()) {
for (int32_t instance_i = 0; instance_i < multi_mesh->get_instance_count();
instance_i++) {
@@ -5386,9 +5403,9 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, con
transform.basis.set_quaternion_scale(quaternion,
Vector3(scale.x, 0, scale.y));
transform =
- multi_mesh_instance->get_transform() * transform;
+ p_multi_mesh_instance->get_transform() * transform;
} else if (multi_mesh->get_transform_format() == MultiMesh::TRANSFORM_3D) {
- transform = multi_mesh_instance->get_transform() *
+ transform = p_multi_mesh_instance->get_transform() *
multi_mesh->get_instance_transform(instance_i);
}
Ref<ArrayMesh> mm = multi_mesh->get_mesh();
@@ -5408,56 +5425,102 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, con
state->meshes.push_back(gltf_mesh);
}
new_gltf_node->xform = transform;
- new_gltf_node->set_name(_gen_unique_name(state, multi_mesh_instance->get_name()));
+ new_gltf_node->set_name(_gen_unique_name(state, p_multi_mesh_instance->get_name()));
gltf_node->children.push_back(state->nodes.size());
state->nodes.push_back(new_gltf_node);
}
}
}
-void GLTFDocument::_convert_skeleton_to_gltf(Node *p_scene_parent, Ref<GLTFState> state, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Node *p_root_node) {
- Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_scene_parent);
- if (skeleton) {
- // Remove placeholder skeleton3d node by not creating the gltf node
- // Skins are per mesh
- for (int node_i = 0; node_i < skeleton->get_child_count(); node_i++) {
- _convert_scene_node(state, skeleton->get_child(node_i), p_root_node, p_parent_node_index, p_root_node_index);
+void GLTFDocument::_convert_skeleton_to_gltf(Skeleton3D *p_skeleton3d, Ref<GLTFState> state, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_node_index, Ref<GLTFNode> gltf_node) {
+ Skeleton3D *skeleton = p_skeleton3d;
+ Ref<GLTFSkeleton> gltf_skeleton;
+ gltf_skeleton.instantiate();
+ // GLTFSkeleton is only used to hold internal state data. It will not be written to the document.
+ //
+ gltf_skeleton->godot_skeleton = skeleton;
+ GLTFSkeletonIndex skeleton_i = state->skeletons.size();
+ state->skeleton3d_to_gltf_skeleton[skeleton->get_instance_id()] = skeleton_i;
+ state->skeletons.push_back(gltf_skeleton);
+
+ BoneId bone_count = skeleton->get_bone_count();
+ for (BoneId bone_i = 0; bone_i < bone_count; bone_i++) {
+ Ref<GLTFNode> joint_node;
+ joint_node.instantiate();
+ // Note that we cannot use _gen_unique_bone_name here, because glTF spec requires all node
+ // names to be unique regardless of whether or not they are used as joints.
+ joint_node->set_name(_gen_unique_name(state, skeleton->get_bone_name(bone_i)));
+ Transform3D xform = skeleton->get_bone_rest(bone_i) * skeleton->get_bone_pose(bone_i);
+ joint_node->scale = xform.basis.get_scale();
+ joint_node->rotation = xform.basis.get_rotation_quaternion();
+ joint_node->position = xform.origin;
+ joint_node->joint = true;
+ GLTFNodeIndex current_node_i = state->nodes.size();
+ state->scene_nodes.insert(current_node_i, skeleton);
+ state->nodes.push_back(joint_node);
+
+ gltf_skeleton->joints.push_back(current_node_i);
+ if (skeleton->get_bone_parent(bone_i) == -1) {
+ gltf_skeleton->roots.push_back(current_node_i);
+ }
+ gltf_skeleton->godot_bone_node.insert(bone_i, current_node_i);
+ }
+ for (BoneId bone_i = 0; bone_i < bone_count; bone_i++) {
+ GLTFNodeIndex current_node_i = gltf_skeleton->godot_bone_node[bone_i];
+ BoneId parent_bone_id = skeleton->get_bone_parent(bone_i);
+ if (parent_bone_id == -1) {
+ if (p_parent_node_index != -1) {
+ state->nodes.write[current_node_i]->parent = p_parent_node_index;
+ state->nodes.write[p_parent_node_index]->children.push_back(current_node_i);
+ }
+ } else {
+ GLTFNodeIndex parent_node_i = gltf_skeleton->godot_bone_node[parent_bone_id];
+ state->nodes.write[current_node_i]->parent = parent_node_i;
+ state->nodes.write[parent_node_i]->children.push_back(current_node_i);
}
}
+ // Remove placeholder skeleton3d node by not creating the gltf node
+ // Skins are per mesh
+ for (int node_i = 0; node_i < skeleton->get_child_count(); node_i++) {
+ _convert_scene_node(state, skeleton->get_child(node_i), p_parent_node_index, p_root_node_index);
+ }
}
-void GLTFDocument::_convert_bone_attachment_to_gltf(Node *p_scene_parent, Ref<GLTFState> state, Ref<GLTFNode> gltf_node, bool &retflag) {
- retflag = true;
- BoneAttachment3D *bone_attachment = Object::cast_to<BoneAttachment3D>(p_scene_parent);
- if (bone_attachment) {
- Node *node = bone_attachment->get_parent();
- while (node) {
- Skeleton3D *bone_attachment_skeleton = Object::cast_to<Skeleton3D>(node);
- if (bone_attachment_skeleton) {
- for (GLTFSkeletonIndex skeleton_i = 0; skeleton_i < state->skeletons.size(); skeleton_i++) {
- if (state->skeletons[skeleton_i]->godot_skeleton != bone_attachment_skeleton) {
- continue;
- }
- state->skeletons.write[skeleton_i]->bone_attachments.push_back(bone_attachment);
- break;
- }
- break;
- }
- node = node->get_parent();
+void GLTFDocument::_convert_bone_attachment_to_gltf(BoneAttachment3D *p_bone_attachment, Ref<GLTFState> state, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_node_index, Ref<GLTFNode> gltf_node) {
+ Skeleton3D *skeleton;
+ // Note that relative transforms to external skeletons and pose overrides are not supported.
+ if (p_bone_attachment->get_use_external_skeleton()) {
+ skeleton = cast_to<Skeleton3D>(p_bone_attachment->get_node_or_null(p_bone_attachment->get_external_skeleton()));
+ } else {
+ skeleton = cast_to<Skeleton3D>(p_bone_attachment->get_parent());
+ }
+ GLTFSkeletonIndex skel_gltf_i = -1;
+ if (skeleton != nullptr && state->skeleton3d_to_gltf_skeleton.has(skeleton->get_instance_id())) {
+ skel_gltf_i = state->skeleton3d_to_gltf_skeleton[skeleton->get_instance_id()];
+ }
+ int bone_idx = -1;
+ if (skeleton != nullptr) {
+ bone_idx = p_bone_attachment->get_bone_idx();
+ if (bone_idx == -1) {
+ bone_idx = skeleton->find_bone(p_bone_attachment->get_bone_name());
}
- gltf_node.unref();
- return;
}
- retflag = false;
+ GLTFNodeIndex par_node_index = p_parent_node_index;
+ if (skeleton != nullptr && bone_idx != -1 && skel_gltf_i != -1) {
+ Ref<GLTFSkeleton> gltf_skeleton = state->skeletons.write[skel_gltf_i];
+ gltf_skeleton->bone_attachments.push_back(p_bone_attachment);
+ par_node_index = gltf_skeleton->joints[bone_idx];
+ }
+
+ for (int node_i = 0; node_i < p_bone_attachment->get_child_count(); node_i++) {
+ _convert_scene_node(state, p_bone_attachment->get_child(node_i), par_node_index, p_root_node_index);
+ }
}
-void GLTFDocument::_convert_mesh_to_gltf(Node *p_scene_parent, Ref<GLTFState> state, Node3D *spatial, Ref<GLTFNode> gltf_node) {
- MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_scene_parent);
- if (mi) {
- GLTFMeshIndex gltf_mesh_index = _convert_mesh_instance(state, mi);
- if (gltf_mesh_index != -1) {
- gltf_node->mesh = gltf_mesh_index;
- }
+void GLTFDocument::_convert_mesh_instance_to_gltf(MeshInstance3D *p_scene_parent, Ref<GLTFState> state, Ref<GLTFNode> gltf_node) {
+ GLTFMeshIndex gltf_mesh_index = _convert_mesh_to_gltf(state, p_scene_parent);
+ if (gltf_mesh_index != -1) {
+ gltf_node->mesh = gltf_mesh_index;
}
}
@@ -5911,10 +5974,6 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
if (node->mesh < 0) {
continue;
}
- Array json_skins;
- if (state->json.has("skins")) {
- json_skins = state->json["skins"];
- }
Map<GLTFNodeIndex, Node *>::Element *mi_element = state->scene_nodes.find(mi_node_i);
if (!mi_element) {
continue;
@@ -5926,7 +5985,6 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
node->rotation = mi_xform.basis.get_rotation_quaternion();
node->position = mi_xform.origin;
- Dictionary json_skin;
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(mi->get_node(mi->get_skeleton_path()));
if (!skeleton) {
continue;
@@ -5935,121 +5993,75 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
continue;
}
Ref<Skin> skin = mi->get_skin();
- if (skin.is_null()) {
- skin = skeleton->register_skin(nullptr)->get_skin();
- }
Ref<GLTFSkin> gltf_skin;
gltf_skin.instantiate();
Array json_joints;
- GLTFSkeletonIndex skeleton_gltf_i = -1;
NodePath skeleton_path = mi->get_skeleton_path();
- bool is_unique = true;
- for (int32_t skin_i = 0; skin_i < state->skins.size(); skin_i++) {
- Ref<GLTFSkin> prev_gltf_skin = state->skins.write[skin_i];
- if (gltf_skin.is_null()) {
- continue;
- }
- GLTFSkeletonIndex prev_skeleton = prev_gltf_skin->get_skeleton();
- if (prev_skeleton == -1 || prev_skeleton >= state->skeletons.size()) {
- continue;
- }
- if (prev_gltf_skin->get_godot_skin() == skin && state->skeletons[prev_skeleton]->godot_skeleton == skeleton) {
- node->skin = skin_i;
- node->skeleton = prev_skeleton;
- is_unique = false;
- break;
- }
- }
- if (!is_unique) {
- continue;
- }
- GLTFSkeletonIndex skeleton_i = _convert_skeleton(state, skeleton);
- skeleton_gltf_i = skeleton_i;
- ERR_CONTINUE(skeleton_gltf_i == -1);
- gltf_skin->skeleton = skeleton_gltf_i;
- Ref<GLTFSkeleton> gltf_skeleton = state->skeletons.write[skeleton_gltf_i];
- for (int32_t bind_i = 0; bind_i < skin->get_bind_count(); bind_i++) {
- String godot_bone_name = skin->get_bind_name(bind_i);
- if (godot_bone_name.is_empty()) {
- int32_t bone = skin->get_bind_bone(bind_i);
- godot_bone_name = skeleton->get_bone_name(bone);
- }
- if (skeleton->find_bone(godot_bone_name) == -1) {
- godot_bone_name = skeleton->get_bone_name(0);
- }
- BoneId bone_index = skeleton->find_bone(godot_bone_name);
- ERR_CONTINUE(bone_index == -1);
- Ref<GLTFNode> joint_node;
- joint_node.instantiate();
- String gltf_bone_name = _gen_unique_bone_name(state, skeleton_gltf_i, godot_bone_name);
- joint_node->set_name(gltf_bone_name);
-
- Transform3D bone_rest_xform = skeleton->get_bone_rest(bone_index);
- joint_node->scale = bone_rest_xform.basis.get_scale();
- joint_node->rotation = bone_rest_xform.basis.get_rotation_quaternion();
- joint_node->position = bone_rest_xform.origin;
- joint_node->joint = true;
-
- int32_t joint_node_i = state->nodes.size();
- state->nodes.push_back(joint_node);
- gltf_skeleton->godot_bone_node.insert(bone_index, joint_node_i);
- int32_t joint_index = gltf_skin->joints.size();
- gltf_skin->joint_i_to_bone_i.insert(joint_index, bone_index);
- gltf_skin->joints.push_back(joint_node_i);
- gltf_skin->joints_original.push_back(joint_node_i);
- gltf_skin->inverse_binds.push_back(skin->get_bind_pose(bind_i));
- json_joints.push_back(joint_node_i);
- for (Map<GLTFNodeIndex, Node *>::Element *skin_scene_node_i = state->scene_nodes.front(); skin_scene_node_i; skin_scene_node_i = skin_scene_node_i->next()) {
- if (skin_scene_node_i->get() == skeleton) {
- gltf_skin->skin_root = skin_scene_node_i->key();
- json_skin["skeleton"] = skin_scene_node_i->key();
- }
- }
- gltf_skin->godot_skin = skin;
- gltf_skin->set_name(_gen_unique_name(state, skin->get_name()));
- }
- for (int32_t bind_i = 0; bind_i < skin->get_bind_count(); bind_i++) {
- String bone_name = skeleton->get_bone_name(bind_i);
- String godot_bone_name = skin->get_bind_name(bind_i);
- int32_t bone = -1;
- if (skin->get_bind_bone(bind_i) != -1) {
- bone = skin->get_bind_bone(bind_i);
- godot_bone_name = skeleton->get_bone_name(bone);
- }
- bone = skeleton->find_bone(godot_bone_name);
- if (bone == -1) {
- continue;
- }
- BoneId bone_parent = skeleton->get_bone_parent(bone);
- GLTFNodeIndex joint_node_i = gltf_skeleton->godot_bone_node[bone];
- ERR_CONTINUE(joint_node_i >= state->nodes.size());
- if (bone_parent != -1) {
- GLTFNodeIndex parent_joint_gltf_node = gltf_skin->joints[bone_parent];
- Ref<GLTFNode> parent_joint_node = state->nodes.write[parent_joint_gltf_node];
- parent_joint_node->children.push_back(joint_node_i);
+ Node *skel_node = mi->get_node_or_null(skeleton_path);
+ Skeleton3D *godot_skeleton = nullptr;
+ if (skel_node != nullptr) {
+ godot_skeleton = cast_to<Skeleton3D>(skel_node);
+ }
+ if (godot_skeleton != nullptr && state->skeleton3d_to_gltf_skeleton.has(godot_skeleton->get_instance_id())) {
+ // This is a skinned mesh. If the mesh has no ARRAY_WEIGHTS or ARRAY_BONES, it will be invisible.
+ const GLTFSkeletonIndex skeleton_gltf_i = state->skeleton3d_to_gltf_skeleton[godot_skeleton->get_instance_id()];
+ Ref<GLTFSkeleton> gltf_skeleton = state->skeletons[skeleton_gltf_i];
+ int bone_cnt = skeleton->get_bone_count();
+ ERR_FAIL_COND(bone_cnt != gltf_skeleton->joints.size());
+
+ ObjectID gltf_skin_key = skin->get_instance_id();
+ ObjectID gltf_skel_key = godot_skeleton->get_instance_id();
+ GLTFSkinIndex skin_gltf_i = -1;
+ GLTFNodeIndex root_gltf_i = -1;
+ if (!gltf_skeleton->roots.is_empty()) {
+ root_gltf_i = gltf_skeleton->roots[0];
+ }
+ if (state->skin_and_skeleton3d_to_gltf_skin.has(gltf_skin_key) && state->skin_and_skeleton3d_to_gltf_skin[gltf_skin_key].has(gltf_skel_key)) {
+ skin_gltf_i = state->skin_and_skeleton3d_to_gltf_skin[gltf_skin_key][gltf_skel_key];
} else {
- Node *node_parent = skeleton->get_parent();
- ERR_CONTINUE(!node_parent);
- for (Map<GLTFNodeIndex, Node *>::Element *E = state->scene_nodes.front(); E; E = E->next()) {
- if (E->get() == node_parent) {
- GLTFNodeIndex gltf_node_i = E->key();
- Ref<GLTFNode> gltf_node = state->nodes.write[gltf_node_i];
- gltf_node->children.push_back(joint_node_i);
- break;
+ if (skin.is_null()) {
+ // Note that gltf_skin_key should remain null, so these can share a reference.
+ skin = skeleton->register_skin(nullptr)->get_skin();
+ }
+ gltf_skin.instantiate();
+ gltf_skin->godot_skin = skin;
+ gltf_skin->set_name(skin->get_name());
+ gltf_skin->skeleton = skeleton_gltf_i;
+ gltf_skin->skin_root = root_gltf_i;
+ //gltf_state->godot_to_gltf_node[skel_node]
+ HashMap<StringName, int> bone_name_to_idx;
+ for (int bone_i = 0; bone_i < bone_cnt; bone_i++) {
+ bone_name_to_idx[skeleton->get_bone_name(bone_i)] = bone_i;
+ }
+ for (int bind_i = 0, cnt = skin->get_bind_count(); bind_i < cnt; bind_i++) {
+ int bone_i = skin->get_bind_bone(bind_i);
+ Transform3D bind_pose = skin->get_bind_pose(bind_i);
+ StringName bind_name = skin->get_bind_name(bind_i);
+ if (bind_name != StringName()) {
+ bone_i = bone_name_to_idx[bind_name];
}
+ ERR_CONTINUE(bone_i < 0 || bone_i >= bone_cnt);
+ if (bind_name == StringName()) {
+ bind_name = skeleton->get_bone_name(bone_i);
+ }
+ GLTFNodeIndex skeleton_bone_i = gltf_skeleton->joints[bone_i];
+ gltf_skin->joints_original.push_back(skeleton_bone_i);
+ gltf_skin->joints.push_back(skeleton_bone_i);
+ gltf_skin->inverse_binds.push_back(bind_pose);
+ if (skeleton->get_bone_parent(bone_i) == -1) {
+ gltf_skin->roots.push_back(skeleton_bone_i);
+ }
+ gltf_skin->joint_i_to_bone_i[bind_i] = bone_i;
+ gltf_skin->joint_i_to_name[bind_i] = bind_name;
}
+ skin_gltf_i = state->skins.size();
+ state->skins.push_back(gltf_skin);
+ state->skin_and_skeleton3d_to_gltf_skin[gltf_skin_key][gltf_skel_key] = skin_gltf_i;
}
+ node->skin = skin_gltf_i;
+ node->skeleton = skeleton_gltf_i;
}
- _expand_skin(state, gltf_skin);
- node->skin = state->skins.size();
- state->skins.push_back(gltf_skin);
-
- json_skin["inverseBindMatrices"] = _encode_accessor_as_xform(state, gltf_skin->inverse_binds, false);
- json_skin["joints"] = json_joints;
- json_skin["name"] = gltf_skin->get_name();
- json_skins.push_back(json_skin);
- state->json["skins"] = json_skins;
}
}
@@ -6132,7 +6144,6 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
for (int32_t key_i = 0; key_i < key_count; key_i++) {
times.write[key_i] = p_animation->track_get_key_time(p_track_i, key_i);
}
- const float BAKE_FPS = 30.0f;
if (track_type == Animation::TYPE_TRANSFORM3D) {
p_track.position_track.times = times;
p_track.position_track.interpolation = gltf_interpolation;
@@ -6370,69 +6381,58 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
const Vector<String> node_suffix = String(orig_track_path).split(":blend_shapes/");
const NodePath path = node_suffix[0];
const String suffix = node_suffix[1];
- const Node *node = ap->get_parent()->get_node_or_null(path);
- for (Map<GLTFNodeIndex, Node *>::Element *transform_track_i = state->scene_nodes.front(); transform_track_i; transform_track_i = transform_track_i->next()) {
- if (transform_track_i->get() == node) {
- const MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node);
- if (!mi) {
- continue;
- }
- Ref<ArrayMesh> array_mesh = mi->get_mesh();
- if (array_mesh.is_null()) {
+ Node *node = ap->get_parent()->get_node_or_null(path);
+ MeshInstance3D *mi = cast_to<MeshInstance3D>(node);
+ Ref<Mesh> mesh = mi->get_mesh();
+ ERR_CONTINUE(mesh.is_null());
+ int32_t mesh_index = -1;
+ for (Map<GLTFNodeIndex, Node *>::Element *mesh_track_i = state->scene_nodes.front(); mesh_track_i; mesh_track_i = mesh_track_i->next()) {
+ if (mesh_track_i->get() == node) {
+ mesh_index = mesh_track_i->key();
+ }
+ }
+ ERR_CONTINUE(mesh_index == -1);
+ Map<int, GLTFAnimation::Track> &tracks = gltf_animation->get_tracks();
+ GLTFAnimation::Track track = gltf_animation->get_tracks().has(mesh_index) ? gltf_animation->get_tracks()[mesh_index] : GLTFAnimation::Track();
+ if (!tracks.has(mesh_index)) {
+ for (int32_t shape_i = 0; shape_i < mesh->get_blend_shape_count(); shape_i++) {
+ String shape_name = mesh->get_blend_shape_name(shape_i);
+ NodePath shape_path = String(path) + ":blend_shapes/" + shape_name;
+ int32_t shape_track_i = animation->find_track(shape_path);
+ if (shape_track_i == -1) {
+ GLTFAnimation::Channel<float> weight;
+ weight.interpolation = GLTFAnimation::INTERP_LINEAR;
+ weight.times.push_back(0.0f);
+ weight.times.push_back(0.0f);
+ weight.values.push_back(0.0f);
+ weight.values.push_back(0.0f);
+ track.weight_tracks.push_back(weight);
continue;
}
- if (node_suffix.size() != 2) {
- continue;
+ Animation::InterpolationType interpolation = animation->track_get_interpolation_type(track_i);
+ GLTFAnimation::Interpolation gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
+ if (interpolation == Animation::InterpolationType::INTERPOLATION_LINEAR) {
+ gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
+ } else if (interpolation == Animation::InterpolationType::INTERPOLATION_NEAREST) {
+ gltf_interpolation = GLTFAnimation::INTERP_STEP;
+ } else if (interpolation == Animation::InterpolationType::INTERPOLATION_CUBIC) {
+ gltf_interpolation = GLTFAnimation::INTERP_CUBIC_SPLINE;
}
- GLTFNodeIndex mesh_index = -1;
- for (GLTFNodeIndex node_i = 0; node_i < state->scene_nodes.size(); node_i++) {
- if (state->scene_nodes[node_i] == node) {
- mesh_index = node_i;
- break;
- }
+ int32_t key_count = animation->track_get_key_count(shape_track_i);
+ GLTFAnimation::Channel<float> weight;
+ weight.interpolation = gltf_interpolation;
+ weight.times.resize(key_count);
+ for (int32_t time_i = 0; time_i < key_count; time_i++) {
+ weight.times.write[time_i] = animation->track_get_key_time(shape_track_i, time_i);
}
- ERR_CONTINUE(mesh_index == -1);
- Ref<Mesh> mesh = mi->get_mesh();
- ERR_CONTINUE(mesh.is_null());
- for (int32_t shape_i = 0; shape_i < mesh->get_blend_shape_count(); shape_i++) {
- if (mesh->get_blend_shape_name(shape_i) != suffix) {
- continue;
- }
- GLTFAnimation::Track track;
- Map<int, GLTFAnimation::Track>::Element *blend_shape_track_i = gltf_animation->get_tracks().find(mesh_index);
- if (blend_shape_track_i) {
- track = blend_shape_track_i->get();
- }
- Animation::InterpolationType interpolation = animation->track_get_interpolation_type(track_i);
-
- GLTFAnimation::Interpolation gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
- if (interpolation == Animation::InterpolationType::INTERPOLATION_LINEAR) {
- gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
- } else if (interpolation == Animation::InterpolationType::INTERPOLATION_NEAREST) {
- gltf_interpolation = GLTFAnimation::INTERP_STEP;
- } else if (interpolation == Animation::InterpolationType::INTERPOLATION_CUBIC) {
- gltf_interpolation = GLTFAnimation::INTERP_CUBIC_SPLINE;
- }
- Animation::TrackType track_type = animation->track_get_type(track_i);
- if (track_type == Animation::TYPE_VALUE) {
- int32_t key_count = animation->track_get_key_count(track_i);
- GLTFAnimation::Channel<float> weight;
- weight.interpolation = gltf_interpolation;
- weight.times.resize(key_count);
- for (int32_t time_i = 0; time_i < key_count; time_i++) {
- weight.times.write[time_i] = animation->track_get_key_time(track_i, time_i);
- }
- weight.values.resize(key_count);
- for (int32_t value_i = 0; value_i < key_count; value_i++) {
- weight.values.write[value_i] = animation->track_get_key_value(track_i, value_i);
- }
- track.weight_tracks.push_back(weight);
- }
- gltf_animation->get_tracks()[mesh_index] = track;
+ weight.values.resize(key_count);
+ for (int32_t value_i = 0; value_i < key_count; value_i++) {
+ weight.values.write[value_i] = animation->track_get_key_value(shape_track_i, value_i);
}
+ track.weight_tracks.push_back(weight);
}
+ tracks[mesh_index] = track;
}
-
} else if (String(orig_track_path).find(":") != -1) {
//Process skeleton
const Vector<String> node_suffix = String(orig_track_path).split(":");
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index fb798a055a..18aeb81bc0 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -51,6 +51,9 @@ class GLTFSkin;
class GLTFNode;
class GLTFSpecGloss;
class GLTFSkeleton;
+class CSGShape3D;
+class GridMap;
+class MultiMeshInstance3D;
using GLTFAccessorIndex = int;
using GLTFAnimationIndex = int;
@@ -72,6 +75,9 @@ class GLTFDocument : public Resource {
friend class GLTFSkin;
friend class GLTFSkeleton;
+private:
+ const float BAKE_FPS = 30.0f;
+
public:
const int32_t JOINT_GROUP_SIZE = 4;
enum GLTFType {
@@ -350,7 +356,6 @@ private:
GLTFNodeIndex p_node_i);
Error _encode_buffer_bins(Ref<GLTFState> state, const String &p_path);
Error _encode_buffer_glb(Ref<GLTFState> state, const String &p_path);
- Error _serialize_bone_attachment(Ref<GLTFState> state);
Dictionary _serialize_texture_transform_uv1(Ref<BaseMaterial3D> p_material);
Dictionary _serialize_texture_transform_uv2(Ref<BaseMaterial3D> p_material);
Error _serialize_version(Ref<GLTFState> state);
@@ -381,20 +386,17 @@ public:
void _generate_skeleton_bone_node(Ref<GLTFState> state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index);
void _import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
const GLTFAnimationIndex index, const int bake_fps);
- GLTFMeshIndex _convert_mesh_instance(Ref<GLTFState> state,
- MeshInstance3D *p_mesh_instance);
void _convert_mesh_instances(Ref<GLTFState> state);
GLTFCameraIndex _convert_camera(Ref<GLTFState> state, Camera3D *p_camera);
- void _convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, Node3D *spatial, Ref<GLTFNode> gltf_node);
+ void _convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, Ref<GLTFNode> gltf_node);
GLTFLightIndex _convert_light(Ref<GLTFState> state, Light3D *p_light);
- GLTFSkeletonIndex _convert_skeleton(Ref<GLTFState> state, Skeleton3D *p_skeleton);
void _convert_spatial(Ref<GLTFState> state, Node3D *p_spatial, Ref<GLTFNode> p_node);
- void _convert_scene_node(Ref<GLTFState> state, Node *p_current, Node *p_root,
+ void _convert_scene_node(Ref<GLTFState> state, Node *p_current,
const GLTFNodeIndex p_gltf_current,
const GLTFNodeIndex p_gltf_root);
#ifdef MODULE_CSG_ENABLED
- void _convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
+ void _convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
#endif // MODULE_CSG_ENABLED
void _create_gltf_node(Ref<GLTFState> state,
@@ -405,40 +407,39 @@ public:
Ref<GLTFNode> gltf_node);
void _convert_animation_player_to_gltf(
AnimationPlayer *animation_player, Ref<GLTFState> state,
- const GLTFNodeIndex &p_gltf_current,
- const GLTFNodeIndex &p_gltf_root_index,
- Ref<GLTFNode> p_gltf_node, Node *p_scene_parent,
- Node *p_root);
+ GLTFNodeIndex p_gltf_current,
+ GLTFNodeIndex p_gltf_root_index,
+ Ref<GLTFNode> p_gltf_node, Node *p_scene_parent);
void _check_visibility(Node *p_node, bool &retflag);
void _convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> state,
- Node3D *spatial,
Ref<GLTFNode> gltf_node);
#ifdef MODULE_GRIDMAP_ENABLED
void _convert_grid_map_to_gltf(
- Node *p_scene_parent,
- const GLTFNodeIndex &p_parent_node_index,
- const GLTFNodeIndex &p_root_node_index,
- Ref<GLTFNode> gltf_node, Ref<GLTFState> state,
- Node *p_root_node);
+ GridMap *p_grid_map,
+ GLTFNodeIndex p_parent_node_index,
+ GLTFNodeIndex p_root_node_index,
+ Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
#endif // MODULE_GRIDMAP_ENABLED
void _convert_mult_mesh_instance_to_gltf(
- Node *p_scene_parent,
- const GLTFNodeIndex &p_parent_node_index,
- const GLTFNodeIndex &p_root_node_index,
- Ref<GLTFNode> gltf_node, Ref<GLTFState> state,
- Node *p_root_node);
+ MultiMeshInstance3D *p_scene_parent,
+ GLTFNodeIndex p_parent_node_index,
+ GLTFNodeIndex p_root_node_index,
+ Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
void _convert_skeleton_to_gltf(
- Node *p_scene_parent, Ref<GLTFState> state,
- const GLTFNodeIndex &p_parent_node_index,
- const GLTFNodeIndex &p_root_node_index,
- Ref<GLTFNode> gltf_node, Node *p_root_node);
- void _convert_bone_attachment_to_gltf(Node *p_scene_parent,
+ Skeleton3D *p_scene_parent, Ref<GLTFState> state,
+ GLTFNodeIndex p_parent_node_index,
+ GLTFNodeIndex p_root_node_index,
+ Ref<GLTFNode> gltf_node);
+ void _convert_bone_attachment_to_gltf(BoneAttachment3D *p_bone_attachment,
+ Ref<GLTFState> state,
+ GLTFNodeIndex p_parent_node_index,
+ GLTFNodeIndex p_root_node_index,
+ Ref<GLTFNode> gltf_node);
+ void _convert_mesh_instance_to_gltf(MeshInstance3D *p_mesh_instance,
Ref<GLTFState> state,
- Ref<GLTFNode> gltf_node,
- bool &retflag);
- void _convert_mesh_to_gltf(Node *p_scene_parent,
- Ref<GLTFState> state, Node3D *spatial,
Ref<GLTFNode> gltf_node);
+ GLTFMeshIndex _convert_mesh_to_gltf(Ref<GLTFState> state,
+ MeshInstance3D *p_mesh_instance);
void _convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
String p_animation_track_name);
Error serialize(Ref<GLTFState> state, Node *p_root, const String &p_path);
diff --git a/modules/gltf/gltf_light.h b/modules/gltf/gltf_light.h
index 079fb18151..62a20d2f16 100644
--- a/modules/gltf/gltf_light.h
+++ b/modules/gltf/gltf_light.h
@@ -42,12 +42,12 @@ protected:
static void _bind_methods();
private:
- Color color;
- float intensity = 0.0f;
+ Color color = Color(1.0f, 1.0f, 1.0f);
+ float intensity = 1.0f;
String light_type;
- float range = 0.0f;
+ float range = INFINITY;
float inner_cone_angle = 0.0f;
- float outer_cone_angle = 0.0f;
+ float outer_cone_angle = Math_TAU / 8.0f;
public:
Color get_color();
diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h
index 896ea5fc56..d6614da804 100644
--- a/modules/gltf/gltf_state.h
+++ b/modules/gltf/gltf_state.h
@@ -44,6 +44,8 @@
#include "gltf_texture.h"
#include "core/io/resource.h"
+#include "core/templates/map.h"
+#include "core/templates/pair.h"
#include "core/templates/vector.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/texture.h"
@@ -87,6 +89,9 @@ class GLTFState : public Resource {
Vector<Ref<GLTFAnimation>> animations;
Map<GLTFNodeIndex, Node *> scene_nodes;
+ Map<ObjectID, GLTFSkeletonIndex> skeleton3d_to_gltf_skeleton;
+ Map<ObjectID, Map<ObjectID, GLTFSkinIndex>> skin_and_skeleton3d_to_gltf_skin;
+
protected:
static void _bind_methods();
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 487e6deac0..116c0e00f9 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -377,10 +377,7 @@ int GridMap::get_cell_item_orientation(const Vector3i &p_position) const {
}
Vector3i GridMap::world_to_map(const Vector3 &p_world_position) const {
- Vector3 map_position = p_world_position / cell_size;
- map_position.x = floor(map_position.x);
- map_position.y = floor(map_position.y);
- map_position.z = floor(map_position.z);
+ Vector3 map_position = (p_world_position / cell_size).floor();
return Vector3i(map_position);
}
diff --git a/modules/mobile_vr/register_types.cpp b/modules/mobile_vr/register_types.cpp
index 47d1fe482c..233c16531a 100644
--- a/modules/mobile_vr/register_types.cpp
+++ b/modules/mobile_vr/register_types.cpp
@@ -32,15 +32,30 @@
#include "mobile_vr_interface.h"
+Ref<MobileVRInterface> mobile_vr;
+
void register_mobile_vr_types() {
GDREGISTER_CLASS(MobileVRInterface);
if (XRServer::get_singleton()) {
- Ref<MobileVRInterface> mobile_vr;
mobile_vr.instantiate();
XRServer::get_singleton()->add_interface(mobile_vr);
}
}
void unregister_mobile_vr_types() {
+ if (mobile_vr.is_valid()) {
+ // uninitialise our interface if it is initialised
+ if (mobile_vr->is_initialized()) {
+ mobile_vr->uninitialize();
+ }
+
+ // unregister our interface from the XR server
+ if (XRServer::get_singleton()) {
+ XRServer::get_singleton()->remove_interface(mobile_vr);
+ }
+
+ // and release
+ mobile_vr.unref();
+ }
}
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 6cc7ddb424..af7c54dd5b 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -3511,10 +3511,10 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
}
Multiplayer::RPCMode CSharpScript::_member_get_rpc_mode(IMonoClassMember *p_member) const {
- if (p_member->has_attribute(CACHED_CLASS(RemoteAttribute))) {
+ if (p_member->has_attribute(CACHED_CLASS(AnyAttribute))) {
return Multiplayer::RPC_MODE_ANY;
}
- if (p_member->has_attribute(CACHED_CLASS(PuppetAttribute))) {
+ if (p_member->has_attribute(CACHED_CLASS(AuthorityAttribute))) {
return Multiplayer::RPC_MODE_AUTHORITY;
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
index 2dedba2be3..1da91ea867 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
@@ -3,8 +3,8 @@ using System;
namespace Godot
{
[AttributeUsage(AttributeTargets.Method)]
- public class RemoteAttribute : Attribute { }
+ public class AnyAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method)]
- public class PuppetAttribute : Attribute { }
+ public class AuthorityAttribute : Attribute { }
}
diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp
index 8b215a66c2..34e845a589 100644
--- a/modules/mono/mono_gd/gd_mono_cache.cpp
+++ b/modules/mono/mono_gd/gd_mono_cache.cpp
@@ -140,8 +140,8 @@ void CachedData::clear_godot_api_cache() {
field_ExportAttribute_hintString = nullptr;
class_SignalAttribute = nullptr;
class_ToolAttribute = nullptr;
- class_RemoteAttribute = nullptr;
- class_PuppetAttribute = nullptr;
+ class_AnyAttribute = nullptr;
+ class_AuthorityAttribute = nullptr;
class_GodotMethodAttribute = nullptr;
field_GodotMethodAttribute_methodName = nullptr;
class_ScriptPathAttribute = nullptr;
@@ -265,8 +265,8 @@ void update_godot_api_cache() {
CACHE_FIELD_AND_CHECK(ExportAttribute, hintString, CACHED_CLASS(ExportAttribute)->get_field("hintString"));
CACHE_CLASS_AND_CHECK(SignalAttribute, GODOT_API_CLASS(SignalAttribute));
CACHE_CLASS_AND_CHECK(ToolAttribute, GODOT_API_CLASS(ToolAttribute));
- CACHE_CLASS_AND_CHECK(RemoteAttribute, GODOT_API_CLASS(RemoteAttribute));
- CACHE_CLASS_AND_CHECK(PuppetAttribute, GODOT_API_CLASS(PuppetAttribute));
+ CACHE_CLASS_AND_CHECK(AnyAttribute, GODOT_API_CLASS(AnyAttribute));
+ CACHE_CLASS_AND_CHECK(AuthorityAttribute, GODOT_API_CLASS(AuthorityAttribute));
CACHE_CLASS_AND_CHECK(GodotMethodAttribute, GODOT_API_CLASS(GodotMethodAttribute));
CACHE_FIELD_AND_CHECK(GodotMethodAttribute, methodName, CACHED_CLASS(GodotMethodAttribute)->get_field("methodName"));
CACHE_CLASS_AND_CHECK(ScriptPathAttribute, GODOT_API_CLASS(ScriptPathAttribute));
diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h
index fd28bbda14..e60a4d5279 100644
--- a/modules/mono/mono_gd/gd_mono_cache.h
+++ b/modules/mono/mono_gd/gd_mono_cache.h
@@ -111,8 +111,8 @@ struct CachedData {
GDMonoField *field_ExportAttribute_hintString;
GDMonoClass *class_SignalAttribute;
GDMonoClass *class_ToolAttribute;
- GDMonoClass *class_RemoteAttribute;
- GDMonoClass *class_PuppetAttribute;
+ GDMonoClass *class_AnyAttribute;
+ GDMonoClass *class_AuthorityAttribute;
GDMonoClass *class_GodotMethodAttribute;
GDMonoField *field_GodotMethodAttribute_methodName;
GDMonoClass *class_ScriptPathAttribute;
diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp
index fd965674d6..f600f07c87 100644
--- a/modules/navigation/godot_navigation_server.cpp
+++ b/modules/navigation/godot_navigation_server.cpp
@@ -133,13 +133,13 @@ RID GodotNavigationServer::map_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
RID rid = map_owner.make_rid();
- NavMap *space = map_owner.getornull(rid);
+ NavMap *space = map_owner.get_or_null(rid);
space->set_self(rid);
return rid;
}
COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND(map == nullptr);
if (p_active) {
@@ -156,84 +156,84 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
}
bool GodotNavigationServer::map_is_active(RID p_map) const {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, false);
return active_maps.find(map) >= 0;
}
COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND(map == nullptr);
map->set_up(p_up);
}
Vector3 GodotNavigationServer::map_get_up(RID p_map) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_up();
}
COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND(map == nullptr);
map->set_cell_size(p_cell_size);
}
real_t GodotNavigationServer::map_get_cell_size(RID p_map) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, 0);
return map->get_cell_size();
}
COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND(map == nullptr);
map->set_edge_connection_margin(p_connection_margin);
}
real_t GodotNavigationServer::map_get_edge_connection_margin(RID p_map) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, 0);
return map->get_edge_connection_margin();
}
Vector<Vector3> GodotNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_layers) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>());
return map->get_path(p_origin, p_destination, p_optimize, p_layers);
}
Vector3 GodotNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point_to_segment(p_from, p_to, p_use_collision);
}
Vector3 GodotNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point(p_point);
}
Vector3 GodotNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point_normal(p_point);
}
RID GodotNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const {
- const NavMap *map = map_owner.getornull(p_map);
+ const NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND_V(map == nullptr, RID());
return map->get_closest_point_owner(p_point);
@@ -243,13 +243,13 @@ RID GodotNavigationServer::region_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
RID rid = region_owner.make_rid();
- NavRegion *reg = region_owner.getornull(rid);
+ NavRegion *reg = region_owner.get_or_null(rid);
reg->set_self(rid);
return rid;
}
COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND(region == nullptr);
if (region->get_map() != nullptr) {
@@ -262,7 +262,7 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
}
if (p_map.is_valid()) {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND(map == nullptr);
map->add_region(region);
@@ -271,28 +271,28 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
}
COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform) {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND(region == nullptr);
region->set_transform(p_transform);
}
COMMAND_2(region_set_layers, RID, p_region, uint32_t, p_layers) {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND(region == nullptr);
region->set_layers(p_layers);
}
uint32_t GodotNavigationServer::region_get_layers(RID p_region) const {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND_V(region == nullptr, 0);
return region->get_layers();
}
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND(region == nullptr);
region->set_mesh(p_nav_mesh);
@@ -309,21 +309,21 @@ void GodotNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node
}
int GodotNavigationServer::region_get_connections_count(RID p_region) const {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND_V(!region, 0);
return region->get_connections_count();
}
Vector3 GodotNavigationServer::region_get_connection_pathway_start(RID p_region, int p_connection_id) const {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND_V(!region, Vector3());
return region->get_connection_pathway_start(p_connection_id);
}
Vector3 GodotNavigationServer::region_get_connection_pathway_end(RID p_region, int p_connection_id) const {
- NavRegion *region = region_owner.getornull(p_region);
+ NavRegion *region = region_owner.get_or_null(p_region);
ERR_FAIL_COND_V(!region, Vector3());
return region->get_connection_pathway_end(p_connection_id);
@@ -333,13 +333,13 @@ RID GodotNavigationServer::agent_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
RID rid = agent_owner.make_rid();
- RvoAgent *agent = agent_owner.getornull(rid);
+ RvoAgent *agent = agent_owner.get_or_null(rid);
agent->set_self(rid);
return rid;
}
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
if (agent->get_map()) {
@@ -353,7 +353,7 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
agent->set_map(nullptr);
if (p_map.is_valid()) {
- NavMap *map = map_owner.getornull(p_map);
+ NavMap *map = map_owner.get_or_null(p_map);
ERR_FAIL_COND(map == nullptr);
agent->set_map(map);
@@ -366,77 +366,77 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
}
COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->neighborDist_ = p_dist;
}
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxNeighbors_ = p_count;
}
COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->timeHorizon_ = p_time;
}
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->radius_ = p_radius;
}
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxSpeed_ = p_max_speed;
}
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
}
COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->ignore_y_ = p_ignore;
}
bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND_V(agent == nullptr, false);
return agent->is_map_changed();
}
COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) {
- RvoAgent *agent = agent_owner.getornull(p_agent);
+ RvoAgent *agent = agent_owner.get_or_null(p_agent);
ERR_FAIL_COND(agent == nullptr);
agent->set_callback(p_receiver == nullptr ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata);
@@ -452,7 +452,7 @@ COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_
COMMAND_1(free, RID, p_object) {
if (map_owner.owns(p_object)) {
- NavMap *map = map_owner.getornull(p_object);
+ NavMap *map = map_owner.get_or_null(p_object);
// Removes any assigned region
std::vector<NavRegion *> regions = map->get_regions();
@@ -474,7 +474,7 @@ COMMAND_1(free, RID, p_object) {
map_owner.free(p_object);
} else if (region_owner.owns(p_object)) {
- NavRegion *region = region_owner.getornull(p_object);
+ NavRegion *region = region_owner.get_or_null(p_object);
// Removes this region from the map if assigned
if (region->get_map() != nullptr) {
@@ -485,7 +485,7 @@ COMMAND_1(free, RID, p_object) {
region_owner.free(p_object);
} else if (agent_owner.owns(p_object)) {
- RvoAgent *agent = agent_owner.getornull(p_object);
+ RvoAgent *agent = agent_owner.get_or_null(p_object);
// Removes this agent from the map if assigned
if (agent->get_map() != nullptr) {
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index 3150ca0bc8..962bf79150 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -664,7 +664,7 @@ void NavMap::sync() {
} else {
other1 = other_edge_p1.lerp(other_edge_p2, (1.0 - projected_p1_ratio) / (projected_p2_ratio - projected_p1_ratio));
}
- if ((self1 - other1).length() > edge_connection_margin) {
+ if (other1.distance_to(self1) > edge_connection_margin) {
continue;
}
@@ -675,7 +675,7 @@ void NavMap::sync() {
} else {
other2 = other_edge_p1.lerp(other_edge_p2, (0.0 - projected_p1_ratio) / (projected_p2_ratio - projected_p1_ratio));
}
- if ((self2 - other2).length() > edge_connection_margin) {
+ if (other2.distance_to(self2) > edge_connection_margin) {
continue;
}
diff --git a/modules/raycast/SCsub b/modules/raycast/SCsub
index 2efd75b625..ef4c598194 100644
--- a/modules/raycast/SCsub
+++ b/modules/raycast/SCsub
@@ -79,6 +79,7 @@ if env["builtin_embree"]:
env.Append(LIBS=["psapi"])
env_thirdparty = env_raycast.Clone()
+ env_thirdparty.force_optimization_on_debug()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
diff --git a/modules/raycast/lightmap_raycaster.cpp b/modules/raycast/lightmap_raycaster.cpp
index 0583acc119..fdcf509da8 100644
--- a/modules/raycast/lightmap_raycaster.cpp
+++ b/modules/raycast/lightmap_raycaster.cpp
@@ -168,7 +168,7 @@ void LightmapRaycasterEmbree::clear_mesh_filter() {
filter_meshes.clear();
}
-void embree_error_handler(void *p_user_data, RTCError p_code, const char *p_str) {
+void embree_lm_error_handler(void *p_user_data, RTCError p_code, const char *p_str) {
print_error("Embree error: " + String(p_str));
}
@@ -179,16 +179,11 @@ LightmapRaycasterEmbree::LightmapRaycasterEmbree() {
#endif
embree_device = rtcNewDevice(nullptr);
- rtcSetDeviceErrorFunction(embree_device, &embree_error_handler, nullptr);
+ rtcSetDeviceErrorFunction(embree_device, &embree_lm_error_handler, nullptr);
embree_scene = rtcNewScene(embree_device);
}
LightmapRaycasterEmbree::~LightmapRaycasterEmbree() {
-#ifdef __SSE2__
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF);
- _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF);
-#endif
-
if (embree_scene != nullptr) {
rtcReleaseScene(embree_scene);
}
diff --git a/modules/raycast/lightmap_raycaster.h b/modules/raycast/lightmap_raycaster.h
index 4c3de27837..290b0a1cf3 100644
--- a/modules/raycast/lightmap_raycaster.h
+++ b/modules/raycast/lightmap_raycaster.h
@@ -30,9 +30,9 @@
#ifdef TOOLS_ENABLED
+#include "core/io/image.h"
#include "core/object/object.h"
#include "scene/3d/lightmapper.h"
-#include "scene/resources/mesh.h"
#include <embree3/rtcore.h>
diff --git a/modules/raycast/raycast_occlusion_cull.cpp b/modules/raycast/raycast_occlusion_cull.cpp
index 7de3318fa9..75491c98e5 100644
--- a/modules/raycast/raycast_occlusion_cull.cpp
+++ b/modules/raycast/raycast_occlusion_cull.cpp
@@ -217,7 +217,7 @@ void RaycastOcclusionCull::occluder_initialize(RID p_occluder) {
}
void RaycastOcclusionCull::occluder_set_mesh(RID p_occluder, const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices) {
- Occluder *occluder = occluder_owner.getornull(p_occluder);
+ Occluder *occluder = occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->vertices = p_vertices;
@@ -238,7 +238,7 @@ void RaycastOcclusionCull::occluder_set_mesh(RID p_occluder, const PackedVector3
}
void RaycastOcclusionCull::free_occluder(RID p_occluder) {
- Occluder *occluder = occluder_owner.getornull(p_occluder);
+ Occluder *occluder = occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
memdelete(occluder);
occluder_owner.free(p_occluder);
@@ -278,7 +278,7 @@ void RaycastOcclusionCull::scenario_set_instance(RID p_scenario, RID p_instance,
bool changed = false;
if (instance.occluder != p_occluder) {
- Occluder *old_occluder = occluder_owner.getornull(instance.occluder);
+ Occluder *old_occluder = occluder_owner.get_or_null(instance.occluder);
if (old_occluder) {
old_occluder->users.erase(InstanceID(p_scenario, p_instance));
}
@@ -286,7 +286,7 @@ void RaycastOcclusionCull::scenario_set_instance(RID p_scenario, RID p_instance,
instance.occluder = p_occluder;
if (p_occluder.is_valid()) {
- Occluder *occluder = occluder_owner.getornull(p_occluder);
+ Occluder *occluder = occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->users.insert(InstanceID(p_scenario, p_instance));
}
@@ -318,7 +318,7 @@ void RaycastOcclusionCull::scenario_remove_instance(RID p_scenario, RID p_instan
OccluderInstance &instance = scenario.instances[p_instance];
if (!instance.removed) {
- Occluder *occluder = occluder_owner.getornull(instance.occluder);
+ Occluder *occluder = occluder_owner.get_or_null(instance.occluder);
if (occluder) {
occluder->users.erase(InstanceID(p_scenario, p_instance));
}
@@ -340,7 +340,7 @@ void RaycastOcclusionCull::Scenario::_update_dirty_instance(int p_idx, RID *p_in
return;
}
- Occluder *occ = raycast_singleton->occluder_owner.getornull(occ_inst->occluder);
+ Occluder *occ = raycast_singleton->occluder_owner.get_or_null(occ_inst->occluder);
if (!occ) {
return;
@@ -456,7 +456,7 @@ bool RaycastOcclusionCull::Scenario::update(ThreadWorkPool &p_thread_pool) {
const RID *inst_rid = nullptr;
while ((inst_rid = instances.next(inst_rid))) {
OccluderInstance *occ_inst = instances.getptr(*inst_rid);
- Occluder *occ = raycast_singleton->occluder_owner.getornull(occ_inst->occluder);
+ Occluder *occ = raycast_singleton->occluder_owner.get_or_null(occ_inst->occluder);
if (!occ || !occ_inst->enabled) {
continue;
diff --git a/modules/raycast/register_types.cpp b/modules/raycast/register_types.cpp
index 78ca91309f..ed99e635e1 100644
--- a/modules/raycast/register_types.cpp
+++ b/modules/raycast/register_types.cpp
@@ -32,12 +32,14 @@
#include "lightmap_raycaster.h"
#include "raycast_occlusion_cull.h"
+#include "static_raycaster.h"
RaycastOcclusionCull *raycast_occlusion_cull = nullptr;
void register_raycast_types() {
#ifdef TOOLS_ENABLED
LightmapRaycasterEmbree::make_default_raycaster();
+ StaticRaycasterEmbree::make_default_raycaster();
#endif
raycast_occlusion_cull = memnew(RaycastOcclusionCull);
}
@@ -46,4 +48,7 @@ void unregister_raycast_types() {
if (raycast_occlusion_cull) {
memdelete(raycast_occlusion_cull);
}
+#ifdef TOOLS_ENABLED
+ StaticRaycasterEmbree::free();
+#endif
}
diff --git a/modules/raycast/static_raycaster.cpp b/modules/raycast/static_raycaster.cpp
new file mode 100644
index 0000000000..2ba65eebf8
--- /dev/null
+++ b/modules/raycast/static_raycaster.cpp
@@ -0,0 +1,137 @@
+/*************************************************************************/
+/* static_raycaster.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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. */
+/*************************************************************************/
+
+#ifdef TOOLS_ENABLED
+
+#include "static_raycaster.h"
+
+#ifdef __SSE2__
+#include <pmmintrin.h>
+#endif
+
+RTCDevice StaticRaycasterEmbree::embree_device;
+
+StaticRaycaster *StaticRaycasterEmbree::create_embree_raycaster() {
+ return memnew(StaticRaycasterEmbree);
+}
+
+void StaticRaycasterEmbree::make_default_raycaster() {
+ create_function = create_embree_raycaster;
+}
+
+void StaticRaycasterEmbree::free() {
+ if (embree_device) {
+ rtcReleaseDevice(embree_device);
+ }
+}
+
+bool StaticRaycasterEmbree::intersect(Ray &r_ray) {
+ RTCIntersectContext context;
+ rtcInitIntersectContext(&context);
+ rtcIntersect1(embree_scene, &context, (RTCRayHit *)&r_ray);
+ return r_ray.geomID != RTC_INVALID_GEOMETRY_ID;
+}
+
+void StaticRaycasterEmbree::intersect(Vector<Ray> &r_rays) {
+ Ray *rays = r_rays.ptrw();
+ for (int i = 0; i < r_rays.size(); ++i) {
+ intersect(rays[i]);
+ }
+}
+
+void StaticRaycasterEmbree::add_mesh(const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices, unsigned int p_id) {
+ RTCGeometry embree_mesh = rtcNewGeometry(embree_device, RTC_GEOMETRY_TYPE_TRIANGLE);
+
+ int vertex_count = p_vertices.size();
+
+ Vector3 *embree_vertices = (Vector3 *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vector3), vertex_count);
+ memcpy(embree_vertices, p_vertices.ptr(), sizeof(Vector3) * vertex_count);
+
+ if (p_indices.is_empty()) {
+ ERR_FAIL_COND(vertex_count % 3 != 0);
+ uint32_t *embree_triangles = (uint32_t *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, sizeof(uint32_t) * 3, vertex_count / 3);
+ for (int i = 0; i < vertex_count; i++) {
+ embree_triangles[i] = i;
+ }
+ } else {
+ uint32_t *embree_triangles = (uint32_t *)rtcSetNewGeometryBuffer(embree_mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, sizeof(uint32_t) * 3, p_indices.size() / 3);
+ memcpy(embree_triangles, p_indices.ptr(), sizeof(uint32_t) * p_indices.size());
+ }
+
+ rtcCommitGeometry(embree_mesh);
+ rtcAttachGeometryByID(embree_scene, embree_mesh, p_id);
+ rtcReleaseGeometry(embree_mesh);
+}
+
+void StaticRaycasterEmbree::commit() {
+ rtcCommitScene(embree_scene);
+}
+
+void StaticRaycasterEmbree::set_mesh_filter(const Set<int> &p_mesh_ids) {
+ for (Set<int>::Element *E = p_mesh_ids.front(); E; E = E->next()) {
+ rtcDisableGeometry(rtcGetGeometry(embree_scene, E->get()));
+ }
+ rtcCommitScene(embree_scene);
+ filter_meshes = p_mesh_ids;
+}
+
+void StaticRaycasterEmbree::clear_mesh_filter() {
+ for (Set<int>::Element *E = filter_meshes.front(); E; E = E->next()) {
+ rtcEnableGeometry(rtcGetGeometry(embree_scene, E->get()));
+ }
+ rtcCommitScene(embree_scene);
+ filter_meshes.clear();
+}
+
+void embree_error_handler(void *p_user_data, RTCError p_code, const char *p_str) {
+ print_error("Embree error: " + String(p_str));
+}
+
+StaticRaycasterEmbree::StaticRaycasterEmbree() {
+#ifdef __SSE2__
+ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+ _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
+#endif
+
+ if (!embree_device) {
+ embree_device = rtcNewDevice(nullptr);
+ rtcSetDeviceErrorFunction(embree_device, &embree_error_handler, nullptr);
+ }
+
+ embree_scene = rtcNewScene(embree_device);
+}
+
+StaticRaycasterEmbree::~StaticRaycasterEmbree() {
+ if (embree_scene != nullptr) {
+ rtcReleaseScene(embree_scene);
+ }
+}
+
+#endif
diff --git a/modules/gdnative/net/register_types.cpp b/modules/raycast/static_raycaster.h
index 46c383e5ae..6b13ecf690 100644
--- a/modules/gdnative/net/register_types.cpp
+++ b/modules/raycast/static_raycaster.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* register_types.cpp */
+/* static_raycaster.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,16 +28,37 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "register_types.h"
-#include "multiplayer_peer_gdnative.h"
-#include "packet_peer_gdnative.h"
-#include "stream_peer_gdnative.h"
+#ifdef TOOLS_ENABLED
-void register_net_types() {
- GDREGISTER_CLASS(MultiplayerPeerGDNative);
- GDREGISTER_CLASS(PacketPeerGDNative);
- GDREGISTER_CLASS(StreamPeerGDNative);
-}
+#include "core/math/static_raycaster.h"
-void unregister_net_types() {
-}
+#include <embree3/rtcore.h>
+
+class StaticRaycasterEmbree : public StaticRaycaster {
+ GDCLASS(StaticRaycasterEmbree, StaticRaycaster);
+
+private:
+ static RTCDevice embree_device;
+ RTCScene embree_scene;
+
+ Set<int> filter_meshes;
+
+public:
+ virtual bool intersect(Ray &p_ray) override;
+ virtual void intersect(Vector<Ray> &r_rays) override;
+
+ virtual void add_mesh(const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices, unsigned int p_id) override;
+ virtual void commit() override;
+
+ virtual void set_mesh_filter(const Set<int> &p_mesh_ids) override;
+ virtual void clear_mesh_filter() override;
+
+ static StaticRaycaster *create_embree_raycaster();
+ static void make_default_raycaster();
+ static void free();
+
+ StaticRaycasterEmbree();
+ ~StaticRaycasterEmbree();
+};
+
+#endif
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index 2336153c0d..acc447018d 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -131,20 +131,6 @@ hb_position_t TextServerAdvanced::hb_bmp_get_glyph_h_kerning(hb_font_t *p_font,
return bm_font->face->kerning_map[Vector2i(p_left_glyph, p_right_glyph)].x * 64;
}
-hb_position_t TextServerAdvanced::hb_bmp_get_glyph_v_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data) {
- const hb_bmp_font_t *bm_font = reinterpret_cast<const hb_bmp_font_t *>(p_font_data);
-
- if (!bm_font->face) {
- return 0;
- }
-
- if (!bm_font->face->kerning_map.has(Vector2i(p_left_glyph, p_right_glyph))) {
- return 0;
- }
-
- return bm_font->face->kerning_map[Vector2i(p_left_glyph, p_right_glyph)].y * 64;
-}
-
hb_bool_t TextServerAdvanced::hb_bmp_get_glyph_v_origin(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_position_t *r_x, hb_position_t *r_y, void *p_user_data) {
const hb_bmp_font_t *bm_font = reinterpret_cast<const hb_bmp_font_t *>(p_font_data);
@@ -205,7 +191,6 @@ void TextServerAdvanced::hb_bmp_create_font_funcs() {
hb_font_funcs_set_glyph_v_advance_func(funcs, hb_bmp_get_glyph_v_advance, nullptr, nullptr);
hb_font_funcs_set_glyph_v_origin_func(funcs, hb_bmp_get_glyph_v_origin, nullptr, nullptr);
hb_font_funcs_set_glyph_h_kerning_func(funcs, hb_bmp_get_glyph_h_kerning, nullptr, nullptr);
- hb_font_funcs_set_glyph_v_kerning_func(funcs, hb_bmp_get_glyph_v_kerning, nullptr, nullptr);
hb_font_funcs_set_glyph_extents_func(funcs, hb_bmp_get_glyph_extents, nullptr, nullptr);
hb_font_funcs_make_immutable(funcs);
@@ -348,11 +333,11 @@ String TextServerAdvanced::get_name() const {
void TextServerAdvanced::free(RID p_rid) {
_THREAD_SAFE_METHOD_
if (font_owner.owns(p_rid)) {
- FontDataAdvanced *fd = font_owner.getornull(p_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_rid);
font_owner.free(p_rid);
memdelete(fd);
} else if (shaped_owner.owns(p_rid)) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_rid);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_rid);
shaped_owner.free(p_rid);
memdelete(sd);
}
@@ -1611,7 +1596,7 @@ _FORCE_INLINE_ void TextServerAdvanced::_font_clear_cache(FontDataAdvanced *p_fo
}
hb_font_t *TextServerAdvanced::_font_get_hb_handle(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, nullptr);
MutexLock lock(fd->mutex);
@@ -1629,7 +1614,7 @@ RID TextServerAdvanced::create_font() {
}
void TextServerAdvanced::font_set_data(RID p_font_rid, const PackedByteArray &p_data) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1640,7 +1625,7 @@ void TextServerAdvanced::font_set_data(RID p_font_rid, const PackedByteArray &p_
}
void TextServerAdvanced::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1651,7 +1636,7 @@ void TextServerAdvanced::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data
}
void TextServerAdvanced::font_set_antialiased(RID p_font_rid, bool p_antialiased) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1662,7 +1647,7 @@ void TextServerAdvanced::font_set_antialiased(RID p_font_rid, bool p_antialiased
}
bool TextServerAdvanced::font_is_antialiased(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1670,7 +1655,7 @@ bool TextServerAdvanced::font_is_antialiased(RID p_font_rid) const {
}
void TextServerAdvanced::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1681,7 +1666,7 @@ void TextServerAdvanced::font_set_multichannel_signed_distance_field(RID p_font_
}
bool TextServerAdvanced::font_is_multichannel_signed_distance_field(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1689,7 +1674,7 @@ bool TextServerAdvanced::font_is_multichannel_signed_distance_field(RID p_font_r
}
void TextServerAdvanced::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1700,7 +1685,7 @@ void TextServerAdvanced::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pi
}
int TextServerAdvanced::font_get_msdf_pixel_range(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1708,7 +1693,7 @@ int TextServerAdvanced::font_get_msdf_pixel_range(RID p_font_rid) const {
}
void TextServerAdvanced::font_set_msdf_size(RID p_font_rid, int p_msdf_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1719,7 +1704,7 @@ void TextServerAdvanced::font_set_msdf_size(RID p_font_rid, int p_msdf_size) {
}
int TextServerAdvanced::font_get_msdf_size(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1727,7 +1712,7 @@ int TextServerAdvanced::font_get_msdf_size(RID p_font_rid) const {
}
void TextServerAdvanced::font_set_fixed_size(RID p_font_rid, int p_fixed_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1737,7 +1722,7 @@ void TextServerAdvanced::font_set_fixed_size(RID p_font_rid, int p_fixed_size) {
}
int TextServerAdvanced::font_get_fixed_size(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1745,7 +1730,7 @@ int TextServerAdvanced::font_get_fixed_size(RID p_font_rid) const {
}
void TextServerAdvanced::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1756,7 +1741,7 @@ void TextServerAdvanced::font_set_force_autohinter(RID p_font_rid, bool p_force_
}
bool TextServerAdvanced::font_is_force_autohinter(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1764,7 +1749,7 @@ bool TextServerAdvanced::font_is_force_autohinter(RID p_font_rid) const {
}
void TextServerAdvanced::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1775,7 +1760,7 @@ void TextServerAdvanced::font_set_hinting(RID p_font_rid, TextServer::Hinting p_
}
TextServer::Hinting TextServerAdvanced::font_get_hinting(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, HINTING_NONE);
MutexLock lock(fd->mutex);
@@ -1783,7 +1768,7 @@ TextServer::Hinting TextServerAdvanced::font_get_hinting(RID p_font_rid) const {
}
void TextServerAdvanced::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1794,7 +1779,7 @@ void TextServerAdvanced::font_set_variation_coordinates(RID p_font_rid, const Di
}
Dictionary TextServerAdvanced::font_get_variation_coordinates(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Dictionary());
MutexLock lock(fd->mutex);
@@ -1802,7 +1787,7 @@ Dictionary TextServerAdvanced::font_get_variation_coordinates(RID p_font_rid) co
}
void TextServerAdvanced::font_set_oversampling(RID p_font_rid, real_t p_oversampling) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1813,7 +1798,7 @@ void TextServerAdvanced::font_set_oversampling(RID p_font_rid, real_t p_oversamp
}
real_t TextServerAdvanced::font_get_oversampling(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1821,7 +1806,7 @@ real_t TextServerAdvanced::font_get_oversampling(RID p_font_rid) const {
}
Array TextServerAdvanced::font_get_size_cache_list(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Array());
MutexLock lock(fd->mutex);
@@ -1833,7 +1818,7 @@ Array TextServerAdvanced::font_get_size_cache_list(RID p_font_rid) const {
}
void TextServerAdvanced::font_clear_size_cache(RID p_font_rid) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1844,7 +1829,7 @@ void TextServerAdvanced::font_clear_size_cache(RID p_font_rid) {
}
void TextServerAdvanced::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1855,7 +1840,7 @@ void TextServerAdvanced::font_remove_size_cache(RID p_font_rid, const Vector2i &
}
void TextServerAdvanced::font_set_ascent(RID p_font_rid, int p_size, real_t p_ascent) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1866,7 +1851,7 @@ void TextServerAdvanced::font_set_ascent(RID p_font_rid, int p_size, real_t p_as
}
real_t TextServerAdvanced::font_get_ascent(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1882,7 +1867,7 @@ real_t TextServerAdvanced::font_get_ascent(RID p_font_rid, int p_size) const {
}
void TextServerAdvanced::font_set_descent(RID p_font_rid, int p_size, real_t p_descent) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
Vector2i size = _get_size(fd, p_size);
@@ -1892,7 +1877,7 @@ void TextServerAdvanced::font_set_descent(RID p_font_rid, int p_size, real_t p_d
}
real_t TextServerAdvanced::font_get_descent(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1908,7 +1893,7 @@ real_t TextServerAdvanced::font_get_descent(RID p_font_rid, int p_size) const {
}
void TextServerAdvanced::font_set_underline_position(RID p_font_rid, int p_size, real_t p_underline_position) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1919,7 +1904,7 @@ void TextServerAdvanced::font_set_underline_position(RID p_font_rid, int p_size,
}
real_t TextServerAdvanced::font_get_underline_position(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1935,7 +1920,7 @@ real_t TextServerAdvanced::font_get_underline_position(RID p_font_rid, int p_siz
}
void TextServerAdvanced::font_set_underline_thickness(RID p_font_rid, int p_size, real_t p_underline_thickness) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1946,7 +1931,7 @@ void TextServerAdvanced::font_set_underline_thickness(RID p_font_rid, int p_size
}
real_t TextServerAdvanced::font_get_underline_thickness(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1962,7 +1947,7 @@ real_t TextServerAdvanced::font_get_underline_thickness(RID p_font_rid, int p_si
}
void TextServerAdvanced::font_set_scale(RID p_font_rid, int p_size, real_t p_scale) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1973,7 +1958,7 @@ void TextServerAdvanced::font_set_scale(RID p_font_rid, int p_size, real_t p_sca
}
real_t TextServerAdvanced::font_get_scale(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1989,7 +1974,7 @@ real_t TextServerAdvanced::font_get_scale(RID p_font_rid, int p_size) const {
}
void TextServerAdvanced::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2010,7 +1995,7 @@ void TextServerAdvanced::font_set_spacing(RID p_font_rid, int p_size, TextServer
}
int TextServerAdvanced::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0);
MutexLock lock(fd->mutex);
@@ -2041,7 +2026,7 @@ int TextServerAdvanced::font_get_spacing(RID p_font_rid, int p_size, TextServer:
}
int TextServerAdvanced::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0);
MutexLock lock(fd->mutex);
@@ -2053,7 +2038,7 @@ int TextServerAdvanced::font_get_texture_count(RID p_font_rid, const Vector2i &p
}
void TextServerAdvanced::font_clear_textures(RID p_font_rid, const Vector2i &p_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
Vector2i size = _get_size_outline(fd, p_size);
@@ -2063,7 +2048,7 @@ void TextServerAdvanced::font_clear_textures(RID p_font_rid, const Vector2i &p_s
}
void TextServerAdvanced::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2075,7 +2060,7 @@ void TextServerAdvanced::font_remove_texture(RID p_font_rid, const Vector2i &p_s
}
void TextServerAdvanced::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
ERR_FAIL_COND(p_image.is_null());
@@ -2101,7 +2086,7 @@ void TextServerAdvanced::font_set_texture_image(RID p_font_rid, const Vector2i &
}
Ref<Image> TextServerAdvanced::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Ref<Image>());
MutexLock lock(fd->mutex);
@@ -2116,7 +2101,7 @@ Ref<Image> TextServerAdvanced::font_get_texture_image(RID p_font_rid, const Vect
}
void TextServerAdvanced::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2131,7 +2116,7 @@ void TextServerAdvanced::font_set_texture_offsets(RID p_font_rid, const Vector2i
}
PackedInt32Array TextServerAdvanced::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, PackedInt32Array());
MutexLock lock(fd->mutex);
@@ -2144,7 +2129,7 @@ PackedInt32Array TextServerAdvanced::font_get_texture_offsets(RID p_font_rid, co
}
Array TextServerAdvanced::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Array());
MutexLock lock(fd->mutex);
@@ -2161,7 +2146,7 @@ Array TextServerAdvanced::font_get_glyph_list(RID p_font_rid, const Vector2i &p_
}
void TextServerAdvanced::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2172,7 +2157,7 @@ void TextServerAdvanced::font_clear_glyphs(RID p_font_rid, const Vector2i &p_siz
}
void TextServerAdvanced::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2183,7 +2168,7 @@ void TextServerAdvanced::font_remove_glyph(RID p_font_rid, const Vector2i &p_siz
}
Vector2 TextServerAdvanced::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -2204,7 +2189,7 @@ Vector2 TextServerAdvanced::font_get_glyph_advance(RID p_font_rid, int p_size, i
}
void TextServerAdvanced::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2219,7 +2204,7 @@ void TextServerAdvanced::font_set_glyph_advance(RID p_font_rid, int p_size, int3
}
Vector2 TextServerAdvanced::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -2240,7 +2225,7 @@ Vector2 TextServerAdvanced::font_get_glyph_offset(RID p_font_rid, const Vector2i
}
void TextServerAdvanced::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2255,7 +2240,7 @@ void TextServerAdvanced::font_set_glyph_offset(RID p_font_rid, const Vector2i &p
}
Vector2 TextServerAdvanced::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -2276,7 +2261,7 @@ Vector2 TextServerAdvanced::font_get_glyph_size(RID p_font_rid, const Vector2i &
}
void TextServerAdvanced::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2291,7 +2276,7 @@ void TextServerAdvanced::font_set_glyph_size(RID p_font_rid, const Vector2i &p_s
}
Rect2 TextServerAdvanced::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Rect2());
MutexLock lock(fd->mutex);
@@ -2307,7 +2292,7 @@ Rect2 TextServerAdvanced::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i
}
void TextServerAdvanced::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2322,7 +2307,7 @@ void TextServerAdvanced::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &
}
int TextServerAdvanced::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, -1);
MutexLock lock(fd->mutex);
@@ -2338,7 +2323,7 @@ int TextServerAdvanced::font_get_glyph_texture_idx(RID p_font_rid, const Vector2
}
void TextServerAdvanced::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2353,7 +2338,7 @@ void TextServerAdvanced::font_set_glyph_texture_idx(RID p_font_rid, const Vector
}
bool TextServerAdvanced::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index, Vector<Vector3> &r_points, Vector<int32_t> &r_contours, bool &r_orientation) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -2387,7 +2372,7 @@ bool TextServerAdvanced::font_get_glyph_contours(RID p_font_rid, int p_size, int
}
Array TextServerAdvanced::font_get_kerning_list(RID p_font_rid, int p_size) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Array());
MutexLock lock(fd->mutex);
@@ -2403,7 +2388,7 @@ Array TextServerAdvanced::font_get_kerning_list(RID p_font_rid, int p_size) cons
}
void TextServerAdvanced::font_clear_kerning_map(RID p_font_rid, int p_size) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2414,7 +2399,7 @@ void TextServerAdvanced::font_clear_kerning_map(RID p_font_rid, int p_size) {
}
void TextServerAdvanced::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2425,7 +2410,7 @@ void TextServerAdvanced::font_remove_kerning(RID p_font_rid, int p_size, const V
}
void TextServerAdvanced::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2436,7 +2421,7 @@ void TextServerAdvanced::font_set_kerning(RID p_font_rid, int p_size, const Vect
}
Vector2 TextServerAdvanced::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -2469,7 +2454,7 @@ Vector2 TextServerAdvanced::font_get_kerning(RID p_font_rid, int p_size, const V
}
int32_t TextServerAdvanced::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0);
MutexLock lock(fd->mutex);
@@ -2492,7 +2477,7 @@ int32_t TextServerAdvanced::font_get_glyph_index(RID p_font_rid, int p_size, cha
}
bool TextServerAdvanced::font_has_char(RID p_font_rid, char32_t p_char) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -2510,7 +2495,7 @@ bool TextServerAdvanced::font_has_char(RID p_font_rid, char32_t p_char) const {
}
String TextServerAdvanced::font_get_supported_chars(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, String());
MutexLock lock(fd->mutex);
@@ -2544,7 +2529,7 @@ String TextServerAdvanced::font_get_supported_chars(RID p_font_rid) const {
}
void TextServerAdvanced::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2562,7 +2547,7 @@ void TextServerAdvanced::font_render_range(RID p_font_rid, const Vector2i &p_siz
}
void TextServerAdvanced::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2572,7 +2557,7 @@ void TextServerAdvanced::font_render_glyph(RID p_font_rid, const Vector2i &p_siz
}
void TextServerAdvanced::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2612,7 +2597,7 @@ void TextServerAdvanced::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz
}
void TextServerAdvanced::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2652,7 +2637,7 @@ void TextServerAdvanced::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i
}
bool TextServerAdvanced::font_is_language_supported(RID p_font_rid, const String &p_language) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -2664,7 +2649,7 @@ bool TextServerAdvanced::font_is_language_supported(RID p_font_rid, const String
}
void TextServerAdvanced::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2672,7 +2657,7 @@ void TextServerAdvanced::font_set_language_support_override(RID p_font_rid, cons
}
bool TextServerAdvanced::font_get_language_support_override(RID p_font_rid, const String &p_language) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -2680,7 +2665,7 @@ bool TextServerAdvanced::font_get_language_support_override(RID p_font_rid, cons
}
void TextServerAdvanced::font_remove_language_support_override(RID p_font_rid, const String &p_language) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2688,7 +2673,7 @@ void TextServerAdvanced::font_remove_language_support_override(RID p_font_rid, c
}
Vector<String> TextServerAdvanced::font_get_language_support_overrides(RID p_font_rid) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector<String>());
MutexLock lock(fd->mutex);
@@ -2700,7 +2685,7 @@ Vector<String> TextServerAdvanced::font_get_language_support_overrides(RID p_fon
}
bool TextServerAdvanced::font_is_script_supported(RID p_font_rid, const String &p_script) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -2714,7 +2699,7 @@ bool TextServerAdvanced::font_is_script_supported(RID p_font_rid, const String &
}
void TextServerAdvanced::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2722,7 +2707,7 @@ void TextServerAdvanced::font_set_script_support_override(RID p_font_rid, const
}
bool TextServerAdvanced::font_get_script_support_override(RID p_font_rid, const String &p_script) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -2730,7 +2715,7 @@ bool TextServerAdvanced::font_get_script_support_override(RID p_font_rid, const
}
void TextServerAdvanced::font_remove_script_support_override(RID p_font_rid, const String &p_script) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -2738,7 +2723,7 @@ void TextServerAdvanced::font_remove_script_support_override(RID p_font_rid, con
}
Vector<String> TextServerAdvanced::font_get_script_support_overrides(RID p_font_rid) {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector<String>());
MutexLock lock(fd->mutex);
@@ -2750,7 +2735,7 @@ Vector<String> TextServerAdvanced::font_get_script_support_overrides(RID p_font_
}
Dictionary TextServerAdvanced::font_supported_feature_list(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Dictionary());
MutexLock lock(fd->mutex);
@@ -2760,7 +2745,7 @@ Dictionary TextServerAdvanced::font_supported_feature_list(RID p_font_rid) const
}
Dictionary TextServerAdvanced::font_supported_variation_list(RID p_font_rid) const {
- FontDataAdvanced *fd = font_owner.getornull(p_font_rid);
+ FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Dictionary());
MutexLock lock(fd->mutex);
@@ -2791,7 +2776,7 @@ void TextServerAdvanced::font_set_global_oversampling(real_t p_oversampling) {
List<RID> text_bufs;
shaped_owner.get_owned_list(&text_bufs);
for (const RID &E : text_bufs) {
- invalidate(shaped_owner.getornull(E));
+ invalidate(shaped_owner.get_or_null(E));
}
}
}
@@ -2852,7 +2837,7 @@ void TextServerAdvanced::invalidate(TextServerAdvanced::ShapedTextDataAdvanced *
}
void TextServerAdvanced::full_copy(ShapedTextDataAdvanced *p_shaped) {
- ShapedTextDataAdvanced *parent = shaped_owner.getornull(p_shaped->parent);
+ ShapedTextDataAdvanced *parent = shaped_owner.get_or_null(p_shaped->parent);
for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = parent->objects.front(); E; E = E->next()) {
if (E->get().pos >= p_shaped->start && E->get().pos < p_shaped->end) {
@@ -2883,7 +2868,7 @@ RID TextServerAdvanced::create_shaped_text(TextServer::Direction p_direction, Te
}
void TextServerAdvanced::shaped_text_clear(RID p_shaped) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2898,7 +2883,7 @@ void TextServerAdvanced::shaped_text_clear(RID p_shaped) {
}
void TextServerAdvanced::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2912,7 +2897,7 @@ void TextServerAdvanced::shaped_text_set_direction(RID p_shaped, TextServer::Dir
}
TextServer::Direction TextServerAdvanced::shaped_text_get_direction(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, TextServer::DIRECTION_LTR);
MutexLock lock(sd->mutex);
@@ -2920,7 +2905,7 @@ TextServer::Direction TextServerAdvanced::shaped_text_get_direction(RID p_shaped
}
void TextServerAdvanced::shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2932,7 +2917,7 @@ void TextServerAdvanced::shaped_text_set_bidi_override(RID p_shaped, const Vecto
}
void TextServerAdvanced::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2946,7 +2931,7 @@ void TextServerAdvanced::shaped_text_set_orientation(RID p_shaped, TextServer::O
}
void TextServerAdvanced::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2958,7 +2943,7 @@ void TextServerAdvanced::shaped_text_set_preserve_invalid(RID p_shaped, bool p_e
}
bool TextServerAdvanced::shaped_text_get_preserve_invalid(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2966,7 +2951,7 @@ bool TextServerAdvanced::shaped_text_get_preserve_invalid(RID p_shaped) const {
}
void TextServerAdvanced::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2980,7 +2965,7 @@ void TextServerAdvanced::shaped_text_set_preserve_control(RID p_shaped, bool p_e
}
bool TextServerAdvanced::shaped_text_get_preserve_control(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2988,7 +2973,7 @@ bool TextServerAdvanced::shaped_text_get_preserve_control(RID p_shaped) const {
}
TextServer::Orientation TextServerAdvanced::shaped_text_get_orientation(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, TextServer::ORIENTATION_HORIZONTAL);
MutexLock lock(sd->mutex);
@@ -2996,13 +2981,13 @@ TextServer::Orientation TextServerAdvanced::shaped_text_get_orientation(RID p_sh
}
bool TextServerAdvanced::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
ERR_FAIL_COND_V(p_size <= 0, false);
MutexLock lock(sd->mutex);
for (int i = 0; i < p_fonts.size(); i++) {
- ERR_FAIL_COND_V(!font_owner.getornull(p_fonts[i]), false);
+ ERR_FAIL_COND_V(!font_owner.get_or_null(p_fonts[i]), false);
}
if (p_text.is_empty()) {
@@ -3031,7 +3016,7 @@ bool TextServerAdvanced::shaped_text_add_string(RID p_shaped, const String &p_te
bool TextServerAdvanced::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) {
_THREAD_SAFE_METHOD_
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
ERR_FAIL_COND_V(p_key == Variant(), false);
ERR_FAIL_COND_V(sd->objects.has(p_key), false);
@@ -3060,7 +3045,7 @@ bool TextServerAdvanced::shaped_text_add_object(RID p_shaped, Variant p_key, con
}
bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -3193,7 +3178,7 @@ bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key,
}
RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_length) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, RID());
MutexLock lock(sd->mutex);
@@ -3386,7 +3371,7 @@ RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_leng
}
RID TextServerAdvanced::shaped_text_get_parent(RID p_shaped) const {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, RID());
MutexLock lock(sd->mutex);
@@ -3394,7 +3379,7 @@ RID TextServerAdvanced::shaped_text_get_parent(RID p_shaped) const {
}
real_t TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, real_t p_width, uint8_t /*JustificationFlag*/ p_jst_flags) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -3530,7 +3515,7 @@ real_t TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, real_t p_width
}
real_t TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const Vector<real_t> &p_tab_stops) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -3580,7 +3565,7 @@ real_t TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const Vector<real
}
void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, real_t p_width, uint8_t p_trim_flags) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped_line);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped_line);
ERR_FAIL_COND_MSG(!sd, "ShapedTextDataAdvanced invalid.");
MutexLock lock(sd->mutex);
@@ -3588,6 +3573,7 @@ void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, re
shaped_text_shape(p_shaped_line);
}
+ sd->text_trimmed = false;
sd->overrun_trim_data.ellipsis_glyph_buf.clear();
bool add_ellipsis = (p_trim_flags & OVERRUN_ADD_ELLIPSIS) == OVERRUN_ADD_ELLIPSIS;
@@ -3706,7 +3692,7 @@ void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, re
}
TextServer::TrimData TextServerAdvanced::shaped_text_get_trim_data(RID p_shaped) const {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V_MSG(!sd, TrimData(), "ShapedTextDataAdvanced invalid.");
MutexLock lock(sd->mutex);
@@ -3714,7 +3700,7 @@ TextServer::TrimData TextServerAdvanced::shaped_text_get_trim_data(RID p_shaped)
}
bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -3906,7 +3892,7 @@ _FORCE_INLINE_ int _generate_kashida_justification_opportunies(const String &p_d
}
bool TextServerAdvanced::shaped_text_update_justification_ops(RID p_shaped) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -4263,7 +4249,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star
}
bool TextServerAdvanced::shaped_text_shape(RID p_shaped) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -4493,7 +4479,7 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) {
}
bool TextServerAdvanced::shaped_text_is_ready(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -4501,7 +4487,7 @@ bool TextServerAdvanced::shaped_text_is_ready(RID p_shaped) const {
}
Vector<TextServer::Glyph> TextServerAdvanced::shaped_text_get_glyphs(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Vector<TextServer::Glyph>());
MutexLock lock(sd->mutex);
@@ -4512,7 +4498,7 @@ Vector<TextServer::Glyph> TextServerAdvanced::shaped_text_get_glyphs(RID p_shape
}
Vector2i TextServerAdvanced::shaped_text_get_range(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Vector2i());
MutexLock lock(sd->mutex);
@@ -4520,7 +4506,7 @@ Vector2i TextServerAdvanced::shaped_text_get_range(RID p_shaped) const {
}
Vector<TextServer::Glyph> TextServerAdvanced::shaped_text_sort_logical(RID p_shaped) {
- ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Vector<TextServer::Glyph>());
MutexLock lock(sd->mutex);
@@ -4539,7 +4525,7 @@ Vector<TextServer::Glyph> TextServerAdvanced::shaped_text_sort_logical(RID p_sha
Array TextServerAdvanced::shaped_text_get_objects(RID p_shaped) const {
Array ret;
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, ret);
MutexLock lock(sd->mutex);
@@ -4551,7 +4537,7 @@ Array TextServerAdvanced::shaped_text_get_objects(RID p_shaped) const {
}
Rect2 TextServerAdvanced::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Rect2());
MutexLock lock(sd->mutex);
@@ -4563,7 +4549,7 @@ Rect2 TextServerAdvanced::shaped_text_get_object_rect(RID p_shaped, Variant p_ke
}
Size2 TextServerAdvanced::shaped_text_get_size(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Size2());
MutexLock lock(sd->mutex);
@@ -4578,7 +4564,7 @@ Size2 TextServerAdvanced::shaped_text_get_size(RID p_shaped) const {
}
real_t TextServerAdvanced::shaped_text_get_ascent(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -4589,7 +4575,7 @@ real_t TextServerAdvanced::shaped_text_get_ascent(RID p_shaped) const {
}
real_t TextServerAdvanced::shaped_text_get_descent(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -4600,7 +4586,7 @@ real_t TextServerAdvanced::shaped_text_get_descent(RID p_shaped) const {
}
real_t TextServerAdvanced::shaped_text_get_width(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -4611,7 +4597,7 @@ real_t TextServerAdvanced::shaped_text_get_width(RID p_shaped) const {
}
real_t TextServerAdvanced::shaped_text_get_underline_position(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -4623,7 +4609,7 @@ real_t TextServerAdvanced::shaped_text_get_underline_position(RID p_shaped) cons
}
real_t TextServerAdvanced::shaped_text_get_underline_thickness(RID p_shaped) const {
- const ShapedTextDataAdvanced *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h
index 5989035800..fc0e7a09a7 100644
--- a/modules/text_server_adv/text_server_adv.h
+++ b/modules/text_server_adv/text_server_adv.h
@@ -269,7 +269,6 @@ class TextServerAdvanced : public TextServer {
static hb_position_t hb_bmp_get_glyph_h_advance(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, void *p_user_data);
static hb_position_t hb_bmp_get_glyph_v_advance(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, void *p_user_data);
static hb_position_t hb_bmp_get_glyph_h_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data);
- static hb_position_t hb_bmp_get_glyph_v_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data);
static hb_bool_t hb_bmp_get_glyph_v_origin(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_position_t *r_x, hb_position_t *r_y, void *p_user_data);
static hb_bool_t hb_bmp_get_glyph_extents(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_glyph_extents_t *r_extents, void *p_user_data);
static hb_bool_t hb_bmp_get_font_h_extents(hb_font_t *p_font, void *p_font_data, hb_font_extents_t *r_metrics, void *p_user_data);
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 8a1bd93c65..b1ce85d505 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -80,11 +80,11 @@ String TextServerFallback::get_name() const {
void TextServerFallback::free(RID p_rid) {
_THREAD_SAFE_METHOD_
if (font_owner.owns(p_rid)) {
- FontDataFallback *fd = font_owner.getornull(p_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_rid);
font_owner.free(p_rid);
memdelete(fd);
} else if (shaped_owner.owns(p_rid)) {
- ShapedTextData *sd = shaped_owner.getornull(p_rid);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_rid);
shaped_owner.free(p_rid);
memdelete(sd);
}
@@ -611,11 +611,13 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontDataFallback *p_font_d
flags |= FT_LOAD_COLOR;
}
+ int32_t glyph_index = FT_Get_Char_Index(fd->face, p_glyph);
+
FT_Fixed v, h;
- FT_Get_Advance(fd->face, p_glyph, flags, &h);
- FT_Get_Advance(fd->face, p_glyph, flags | FT_LOAD_VERTICAL_LAYOUT, &v);
+ FT_Get_Advance(fd->face, glyph_index, flags, &h);
+ FT_Get_Advance(fd->face, glyph_index, flags | FT_LOAD_VERTICAL_LAYOUT, &v);
- int error = FT_Load_Glyph(fd->face, p_glyph, flags);
+ int error = FT_Load_Glyph(fd->face, glyph_index, flags);
if (error) {
fd->glyph_map[p_glyph] = FontGlyph();
ERR_FAIL_V_MSG(false, "FreeType: Failed to load glyph.");
@@ -809,7 +811,7 @@ RID TextServerFallback::create_font() {
}
void TextServerFallback::font_set_data(RID p_font_rid, const PackedByteArray &p_data) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -820,7 +822,7 @@ void TextServerFallback::font_set_data(RID p_font_rid, const PackedByteArray &p_
}
void TextServerFallback::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -831,7 +833,7 @@ void TextServerFallback::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data
}
void TextServerFallback::font_set_antialiased(RID p_font_rid, bool p_antialiased) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -842,7 +844,7 @@ void TextServerFallback::font_set_antialiased(RID p_font_rid, bool p_antialiased
}
bool TextServerFallback::font_is_antialiased(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -850,7 +852,7 @@ bool TextServerFallback::font_is_antialiased(RID p_font_rid) const {
}
void TextServerFallback::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -861,7 +863,7 @@ void TextServerFallback::font_set_multichannel_signed_distance_field(RID p_font_
}
bool TextServerFallback::font_is_multichannel_signed_distance_field(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -869,7 +871,7 @@ bool TextServerFallback::font_is_multichannel_signed_distance_field(RID p_font_r
}
void TextServerFallback::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -880,7 +882,7 @@ void TextServerFallback::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pi
}
int TextServerFallback::font_get_msdf_pixel_range(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -888,7 +890,7 @@ int TextServerFallback::font_get_msdf_pixel_range(RID p_font_rid) const {
}
void TextServerFallback::font_set_msdf_size(RID p_font_rid, int p_msdf_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -899,7 +901,7 @@ void TextServerFallback::font_set_msdf_size(RID p_font_rid, int p_msdf_size) {
}
int TextServerFallback::font_get_msdf_size(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -907,7 +909,7 @@ int TextServerFallback::font_get_msdf_size(RID p_font_rid) const {
}
void TextServerFallback::font_set_fixed_size(RID p_font_rid, int p_fixed_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -917,7 +919,7 @@ void TextServerFallback::font_set_fixed_size(RID p_font_rid, int p_fixed_size) {
}
int TextServerFallback::font_get_fixed_size(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -925,7 +927,7 @@ int TextServerFallback::font_get_fixed_size(RID p_font_rid) const {
}
void TextServerFallback::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -936,7 +938,7 @@ void TextServerFallback::font_set_force_autohinter(RID p_font_rid, bool p_force_
}
bool TextServerFallback::font_is_force_autohinter(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -944,7 +946,7 @@ bool TextServerFallback::font_is_force_autohinter(RID p_font_rid) const {
}
void TextServerFallback::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -955,7 +957,7 @@ void TextServerFallback::font_set_hinting(RID p_font_rid, TextServer::Hinting p_
}
TextServer::Hinting TextServerFallback::font_get_hinting(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, HINTING_NONE);
MutexLock lock(fd->mutex);
@@ -963,7 +965,7 @@ TextServer::Hinting TextServerFallback::font_get_hinting(RID p_font_rid) const {
}
void TextServerFallback::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -974,7 +976,7 @@ void TextServerFallback::font_set_variation_coordinates(RID p_font_rid, const Di
}
Dictionary TextServerFallback::font_get_variation_coordinates(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Dictionary());
MutexLock lock(fd->mutex);
@@ -982,7 +984,7 @@ Dictionary TextServerFallback::font_get_variation_coordinates(RID p_font_rid) co
}
void TextServerFallback::font_set_oversampling(RID p_font_rid, real_t p_oversampling) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -993,7 +995,7 @@ void TextServerFallback::font_set_oversampling(RID p_font_rid, real_t p_oversamp
}
real_t TextServerFallback::font_get_oversampling(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1001,7 +1003,7 @@ real_t TextServerFallback::font_get_oversampling(RID p_font_rid) const {
}
Array TextServerFallback::font_get_size_cache_list(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Array());
MutexLock lock(fd->mutex);
@@ -1013,7 +1015,7 @@ Array TextServerFallback::font_get_size_cache_list(RID p_font_rid) const {
}
void TextServerFallback::font_clear_size_cache(RID p_font_rid) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1024,7 +1026,7 @@ void TextServerFallback::font_clear_size_cache(RID p_font_rid) {
}
void TextServerFallback::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1035,7 +1037,7 @@ void TextServerFallback::font_remove_size_cache(RID p_font_rid, const Vector2i &
}
void TextServerFallback::font_set_ascent(RID p_font_rid, int p_size, real_t p_ascent) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1046,7 +1048,7 @@ void TextServerFallback::font_set_ascent(RID p_font_rid, int p_size, real_t p_as
}
real_t TextServerFallback::font_get_ascent(RID p_font_rid, int p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1062,7 +1064,7 @@ real_t TextServerFallback::font_get_ascent(RID p_font_rid, int p_size) const {
}
void TextServerFallback::font_set_descent(RID p_font_rid, int p_size, real_t p_descent) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
Vector2i size = _get_size(fd, p_size);
@@ -1072,7 +1074,7 @@ void TextServerFallback::font_set_descent(RID p_font_rid, int p_size, real_t p_d
}
real_t TextServerFallback::font_get_descent(RID p_font_rid, int p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1088,7 +1090,7 @@ real_t TextServerFallback::font_get_descent(RID p_font_rid, int p_size) const {
}
void TextServerFallback::font_set_underline_position(RID p_font_rid, int p_size, real_t p_underline_position) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1099,7 +1101,7 @@ void TextServerFallback::font_set_underline_position(RID p_font_rid, int p_size,
}
real_t TextServerFallback::font_get_underline_position(RID p_font_rid, int p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1115,7 +1117,7 @@ real_t TextServerFallback::font_get_underline_position(RID p_font_rid, int p_siz
}
void TextServerFallback::font_set_underline_thickness(RID p_font_rid, int p_size, real_t p_underline_thickness) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1126,7 +1128,7 @@ void TextServerFallback::font_set_underline_thickness(RID p_font_rid, int p_size
}
real_t TextServerFallback::font_get_underline_thickness(RID p_font_rid, int p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1142,7 +1144,7 @@ real_t TextServerFallback::font_get_underline_thickness(RID p_font_rid, int p_si
}
void TextServerFallback::font_set_scale(RID p_font_rid, int p_size, real_t p_scale) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1153,7 +1155,7 @@ void TextServerFallback::font_set_scale(RID p_font_rid, int p_size, real_t p_sca
}
real_t TextServerFallback::font_get_scale(RID p_font_rid, int p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0.f);
MutexLock lock(fd->mutex);
@@ -1169,7 +1171,7 @@ real_t TextServerFallback::font_get_scale(RID p_font_rid, int p_size) const {
}
void TextServerFallback::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1190,7 +1192,7 @@ void TextServerFallback::font_set_spacing(RID p_font_rid, int p_size, TextServer
}
int TextServerFallback::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0);
MutexLock lock(fd->mutex);
@@ -1221,7 +1223,7 @@ int TextServerFallback::font_get_spacing(RID p_font_rid, int p_size, TextServer:
}
int TextServerFallback::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, 0);
MutexLock lock(fd->mutex);
@@ -1233,7 +1235,7 @@ int TextServerFallback::font_get_texture_count(RID p_font_rid, const Vector2i &p
}
void TextServerFallback::font_clear_textures(RID p_font_rid, const Vector2i &p_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
Vector2i size = _get_size_outline(fd, p_size);
@@ -1243,7 +1245,7 @@ void TextServerFallback::font_clear_textures(RID p_font_rid, const Vector2i &p_s
}
void TextServerFallback::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1255,7 +1257,7 @@ void TextServerFallback::font_remove_texture(RID p_font_rid, const Vector2i &p_s
}
void TextServerFallback::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
ERR_FAIL_COND(p_image.is_null());
@@ -1281,7 +1283,7 @@ void TextServerFallback::font_set_texture_image(RID p_font_rid, const Vector2i &
}
Ref<Image> TextServerFallback::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Ref<Image>());
MutexLock lock(fd->mutex);
@@ -1296,7 +1298,7 @@ Ref<Image> TextServerFallback::font_get_texture_image(RID p_font_rid, const Vect
}
void TextServerFallback::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1311,7 +1313,7 @@ void TextServerFallback::font_set_texture_offsets(RID p_font_rid, const Vector2i
}
PackedInt32Array TextServerFallback::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, PackedInt32Array());
MutexLock lock(fd->mutex);
@@ -1324,7 +1326,7 @@ PackedInt32Array TextServerFallback::font_get_texture_offsets(RID p_font_rid, co
}
Array TextServerFallback::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Array());
MutexLock lock(fd->mutex);
@@ -1341,7 +1343,7 @@ Array TextServerFallback::font_get_glyph_list(RID p_font_rid, const Vector2i &p_
}
void TextServerFallback::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1352,7 +1354,7 @@ void TextServerFallback::font_clear_glyphs(RID p_font_rid, const Vector2i &p_siz
}
void TextServerFallback::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1363,7 +1365,7 @@ void TextServerFallback::font_remove_glyph(RID p_font_rid, const Vector2i &p_siz
}
Vector2 TextServerFallback::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -1384,7 +1386,7 @@ Vector2 TextServerFallback::font_get_glyph_advance(RID p_font_rid, int p_size, i
}
void TextServerFallback::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1399,7 +1401,7 @@ void TextServerFallback::font_set_glyph_advance(RID p_font_rid, int p_size, int3
}
Vector2 TextServerFallback::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -1420,7 +1422,7 @@ Vector2 TextServerFallback::font_get_glyph_offset(RID p_font_rid, const Vector2i
}
void TextServerFallback::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1435,7 +1437,7 @@ void TextServerFallback::font_set_glyph_offset(RID p_font_rid, const Vector2i &p
}
Vector2 TextServerFallback::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -1456,7 +1458,7 @@ Vector2 TextServerFallback::font_get_glyph_size(RID p_font_rid, const Vector2i &
}
void TextServerFallback::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1471,7 +1473,7 @@ void TextServerFallback::font_set_glyph_size(RID p_font_rid, const Vector2i &p_s
}
Rect2 TextServerFallback::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Rect2());
MutexLock lock(fd->mutex);
@@ -1487,7 +1489,7 @@ Rect2 TextServerFallback::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i
}
void TextServerFallback::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1502,7 +1504,7 @@ void TextServerFallback::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &
}
int TextServerFallback::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, -1);
MutexLock lock(fd->mutex);
@@ -1518,7 +1520,7 @@ int TextServerFallback::font_get_glyph_texture_idx(RID p_font_rid, const Vector2
}
void TextServerFallback::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1533,7 +1535,7 @@ void TextServerFallback::font_set_glyph_texture_idx(RID p_font_rid, const Vector
}
bool TextServerFallback::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index, Vector<Vector3> &r_points, Vector<int32_t> &r_contours, bool &r_orientation) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1542,7 +1544,7 @@ bool TextServerFallback::font_get_glyph_contours(RID p_font_rid, int p_size, int
ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), false);
#ifdef MODULE_FREETYPE_ENABLED
- int error = FT_Load_Glyph(fd->cache[size]->face, p_index, FT_LOAD_NO_BITMAP | (fd->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0));
+ int error = FT_Load_Glyph(fd->cache[size]->face, FT_Get_Char_Index(fd->cache[size]->face, p_index), FT_LOAD_NO_BITMAP | (fd->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0));
ERR_FAIL_COND_V(error, false);
r_points.clear();
@@ -1567,7 +1569,7 @@ bool TextServerFallback::font_get_glyph_contours(RID p_font_rid, int p_size, int
}
Array TextServerFallback::font_get_kerning_list(RID p_font_rid, int p_size) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Array());
MutexLock lock(fd->mutex);
@@ -1583,7 +1585,7 @@ Array TextServerFallback::font_get_kerning_list(RID p_font_rid, int p_size) cons
}
void TextServerFallback::font_clear_kerning_map(RID p_font_rid, int p_size) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1594,7 +1596,7 @@ void TextServerFallback::font_clear_kerning_map(RID p_font_rid, int p_size) {
}
void TextServerFallback::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1605,7 +1607,7 @@ void TextServerFallback::font_remove_kerning(RID p_font_rid, int p_size, const V
}
void TextServerFallback::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1616,7 +1618,7 @@ void TextServerFallback::font_set_kerning(RID p_font_rid, int p_size, const Vect
}
Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector2());
MutexLock lock(fd->mutex);
@@ -1636,7 +1638,9 @@ Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const V
#ifdef MODULE_FREETYPE_ENABLED
if (fd->cache[size]->face) {
FT_Vector delta;
- FT_Get_Kerning(fd->cache[size]->face, p_glyph_pair.x, p_glyph_pair.y, FT_KERNING_DEFAULT, &delta);
+ int32_t glyph_a = FT_Get_Char_Index(fd->cache[size]->face, p_glyph_pair.x);
+ int32_t glyph_b = FT_Get_Char_Index(fd->cache[size]->face, p_glyph_pair.y);
+ FT_Get_Kerning(fd->cache[size]->face, glyph_a, glyph_b, FT_KERNING_DEFAULT, &delta);
if (fd->msdf) {
return Vector2(delta.x, delta.y) * (real_t)p_size / (real_t)fd->msdf_source_size;
} else {
@@ -1649,30 +1653,11 @@ Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const V
}
int32_t TextServerFallback::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
- ERR_FAIL_COND_V(!fd, 0);
-
- MutexLock lock(fd->mutex);
- Vector2i size = _get_size(fd, p_size);
- ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0);
-
-#ifdef MODULE_FREETYPE_ENABLED
- if (fd->cache[size]->face) {
- if (p_variation_selector) {
- return FT_Face_GetCharVariantIndex(fd->cache[size]->face, p_char, p_variation_selector);
- } else {
- return FT_Get_Char_Index(fd->cache[size]->face, p_char);
- }
- } else {
- return 0;
- }
-#else
return (int32_t)p_char;
-#endif
}
bool TextServerFallback::font_has_char(RID p_font_rid, char32_t p_char) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1690,7 +1675,7 @@ bool TextServerFallback::font_has_char(RID p_font_rid, char32_t p_char) const {
}
String TextServerFallback::font_get_supported_chars(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, String());
MutexLock lock(fd->mutex);
@@ -1724,25 +1709,19 @@ String TextServerFallback::font_get_supported_chars(RID p_font_rid) const {
}
void TextServerFallback::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
Vector2i size = _get_size_outline(fd, p_size);
ERR_FAIL_COND(!_ensure_cache_for_size(fd, size));
for (char32_t i = p_start; i <= p_end; i++) {
-#ifdef MODULE_FREETYPE_ENABLED
- if (fd->cache[size]->face) {
- _ensure_glyph(fd, size, FT_Get_Char_Index(fd->cache[size]->face, i));
- continue;
- }
-#endif
_ensure_glyph(fd, size, (int32_t)i);
}
}
void TextServerFallback::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1752,7 +1731,7 @@ void TextServerFallback::font_render_glyph(RID p_font_rid, const Vector2i &p_siz
}
void TextServerFallback::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1792,7 +1771,7 @@ void TextServerFallback::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz
}
void TextServerFallback::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1832,7 +1811,7 @@ void TextServerFallback::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i
}
bool TextServerFallback::font_is_language_supported(RID p_font_rid, const String &p_language) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1844,7 +1823,7 @@ bool TextServerFallback::font_is_language_supported(RID p_font_rid, const String
}
void TextServerFallback::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1852,7 +1831,7 @@ void TextServerFallback::font_set_language_support_override(RID p_font_rid, cons
}
bool TextServerFallback::font_get_language_support_override(RID p_font_rid, const String &p_language) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1860,7 +1839,7 @@ bool TextServerFallback::font_get_language_support_override(RID p_font_rid, cons
}
void TextServerFallback::font_remove_language_support_override(RID p_font_rid, const String &p_language) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1868,7 +1847,7 @@ void TextServerFallback::font_remove_language_support_override(RID p_font_rid, c
}
Vector<String> TextServerFallback::font_get_language_support_overrides(RID p_font_rid) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector<String>());
MutexLock lock(fd->mutex);
@@ -1880,7 +1859,7 @@ Vector<String> TextServerFallback::font_get_language_support_overrides(RID p_fon
}
bool TextServerFallback::font_is_script_supported(RID p_font_rid, const String &p_script) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1892,7 +1871,7 @@ bool TextServerFallback::font_is_script_supported(RID p_font_rid, const String &
}
void TextServerFallback::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1900,7 +1879,7 @@ void TextServerFallback::font_set_script_support_override(RID p_font_rid, const
}
bool TextServerFallback::font_get_script_support_override(RID p_font_rid, const String &p_script) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, false);
MutexLock lock(fd->mutex);
@@ -1908,7 +1887,7 @@ bool TextServerFallback::font_get_script_support_override(RID p_font_rid, const
}
void TextServerFallback::font_remove_script_support_override(RID p_font_rid, const String &p_script) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND(!fd);
MutexLock lock(fd->mutex);
@@ -1918,7 +1897,7 @@ void TextServerFallback::font_remove_script_support_override(RID p_font_rid, con
}
Vector<String> TextServerFallback::font_get_script_support_overrides(RID p_font_rid) {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Vector<String>());
MutexLock lock(fd->mutex);
@@ -1934,7 +1913,7 @@ Dictionary TextServerFallback::font_supported_feature_list(RID p_font_rid) const
}
Dictionary TextServerFallback::font_supported_variation_list(RID p_font_rid) const {
- FontDataFallback *fd = font_owner.getornull(p_font_rid);
+ FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
ERR_FAIL_COND_V(!fd, Dictionary());
MutexLock lock(fd->mutex);
@@ -1965,7 +1944,7 @@ void TextServerFallback::font_set_global_oversampling(real_t p_oversampling) {
List<RID> text_bufs;
shaped_owner.get_owned_list(&text_bufs);
for (const RID &E : text_bufs) {
- invalidate(shaped_owner.getornull(E));
+ invalidate(shaped_owner.get_or_null(E));
}
}
}
@@ -1990,7 +1969,7 @@ void TextServerFallback::invalidate(ShapedTextData *p_shaped) {
}
void TextServerFallback::full_copy(ShapedTextData *p_shaped) {
- ShapedTextData *parent = shaped_owner.getornull(p_shaped->parent);
+ ShapedTextData *parent = shaped_owner.get_or_null(p_shaped->parent);
for (Map<Variant, ShapedTextData::EmbeddedObject>::Element *E = parent->objects.front(); E; E = E->next()) {
if (E->get().pos >= p_shaped->start && E->get().pos < p_shaped->end) {
@@ -2021,7 +2000,7 @@ RID TextServerFallback::create_shaped_text(TextServer::Direction p_direction, Te
}
void TextServerFallback::shaped_text_clear(RID p_shaped) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2045,7 +2024,7 @@ TextServer::Direction TextServerFallback::shaped_text_get_direction(RID p_shaped
}
void TextServerFallback::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2063,7 +2042,7 @@ void TextServerFallback::shaped_text_set_bidi_override(RID p_shaped, const Vecto
}
TextServer::Orientation TextServerFallback::shaped_text_get_orientation(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, TextServer::ORIENTATION_HORIZONTAL);
MutexLock lock(sd->mutex);
@@ -2071,7 +2050,7 @@ TextServer::Orientation TextServerFallback::shaped_text_get_orientation(RID p_sh
}
void TextServerFallback::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
MutexLock lock(sd->mutex);
ERR_FAIL_COND(!sd);
@@ -2085,7 +2064,7 @@ void TextServerFallback::shaped_text_set_preserve_invalid(RID p_shaped, bool p_e
}
bool TextServerFallback::shaped_text_get_preserve_invalid(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2093,7 +2072,7 @@ bool TextServerFallback::shaped_text_get_preserve_invalid(RID p_shaped) const {
}
void TextServerFallback::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND(!sd);
MutexLock lock(sd->mutex);
@@ -2107,7 +2086,7 @@ void TextServerFallback::shaped_text_set_preserve_control(RID p_shaped, bool p_e
}
bool TextServerFallback::shaped_text_get_preserve_control(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2115,14 +2094,14 @@ bool TextServerFallback::shaped_text_get_preserve_control(RID p_shaped) const {
}
bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
ERR_FAIL_COND_V(p_size <= 0, false);
for (int i = 0; i < p_fonts.size(); i++) {
- ERR_FAIL_COND_V(!font_owner.getornull(p_fonts[i]), false);
+ ERR_FAIL_COND_V(!font_owner.get_or_null(p_fonts[i]), false);
}
if (p_text.is_empty()) {
@@ -2162,7 +2141,7 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te
}
bool TextServerFallback::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2193,7 +2172,7 @@ bool TextServerFallback::shaped_text_add_object(RID p_shaped, Variant p_key, con
}
bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2326,7 +2305,7 @@ bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key,
}
RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_length) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, RID());
MutexLock lock(sd->mutex);
@@ -2480,7 +2459,7 @@ RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_leng
}
RID TextServerFallback::shaped_text_get_parent(RID p_shaped) const {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, RID());
MutexLock lock(sd->mutex);
@@ -2488,7 +2467,7 @@ RID TextServerFallback::shaped_text_get_parent(RID p_shaped) const {
}
real_t TextServerFallback::shaped_text_fit_to_width(RID p_shaped, real_t p_width, uint8_t /*JustificationFlag*/ p_jst_flags) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -2568,7 +2547,7 @@ real_t TextServerFallback::shaped_text_fit_to_width(RID p_shaped, real_t p_width
}
real_t TextServerFallback::shaped_text_tab_align(RID p_shaped, const Vector<real_t> &p_tab_stops) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -2618,7 +2597,7 @@ real_t TextServerFallback::shaped_text_tab_align(RID p_shaped, const Vector<real
}
bool TextServerFallback::shaped_text_update_breaks(RID p_shaped) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2659,7 +2638,7 @@ bool TextServerFallback::shaped_text_update_breaks(RID p_shaped) {
}
bool TextServerFallback::shaped_text_update_justification_ops(RID p_shaped) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2675,7 +2654,7 @@ bool TextServerFallback::shaped_text_update_justification_ops(RID p_shaped) {
}
void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, real_t p_width, uint8_t p_trim_flags) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped_line);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped_line);
ERR_FAIL_COND_MSG(!sd, "ShapedTextDataFallback invalid.");
MutexLock lock(sd->mutex);
@@ -2683,6 +2662,7 @@ void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, re
shaped_text_shape(p_shaped_line);
}
+ sd->text_trimmed = false;
sd->overrun_trim_data.ellipsis_glyph_buf.clear();
bool add_ellipsis = (p_trim_flags & OVERRUN_ADD_ELLIPSIS) == OVERRUN_ADD_ELLIPSIS;
@@ -2791,7 +2771,7 @@ void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, re
}
TextServer::TrimData TextServerFallback::shaped_text_get_trim_data(RID p_shaped) const {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V_MSG(!sd, TrimData(), "ShapedTextDataFallback invalid.");
MutexLock lock(sd->mutex);
@@ -2799,7 +2779,7 @@ TextServer::TrimData TextServerFallback::shaped_text_get_trim_data(RID p_shaped)
}
bool TextServerFallback::shaped_text_shape(RID p_shaped) {
- ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -2993,7 +2973,7 @@ bool TextServerFallback::shaped_text_shape(RID p_shaped) {
}
bool TextServerFallback::shaped_text_is_ready(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, false);
MutexLock lock(sd->mutex);
@@ -3001,7 +2981,7 @@ bool TextServerFallback::shaped_text_is_ready(RID p_shaped) const {
}
Vector<TextServer::Glyph> TextServerFallback::shaped_text_get_glyphs(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Vector<TextServer::Glyph>());
MutexLock lock(sd->mutex);
@@ -3012,7 +2992,7 @@ Vector<TextServer::Glyph> TextServerFallback::shaped_text_get_glyphs(RID p_shape
}
Vector2i TextServerFallback::shaped_text_get_range(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Vector2i());
MutexLock lock(sd->mutex);
@@ -3020,7 +3000,7 @@ Vector2i TextServerFallback::shaped_text_get_range(RID p_shaped) const {
}
Vector<TextServer::Glyph> TextServerFallback::shaped_text_sort_logical(RID p_shaped) {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Vector<TextServer::Glyph>());
MutexLock lock(sd->mutex);
@@ -3033,7 +3013,7 @@ Vector<TextServer::Glyph> TextServerFallback::shaped_text_sort_logical(RID p_sha
Array TextServerFallback::shaped_text_get_objects(RID p_shaped) const {
Array ret;
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, ret);
MutexLock lock(sd->mutex);
@@ -3045,7 +3025,7 @@ Array TextServerFallback::shaped_text_get_objects(RID p_shaped) const {
}
Rect2 TextServerFallback::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Rect2());
MutexLock lock(sd->mutex);
@@ -3057,7 +3037,7 @@ Rect2 TextServerFallback::shaped_text_get_object_rect(RID p_shaped, Variant p_ke
}
Size2 TextServerFallback::shaped_text_get_size(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, Size2());
MutexLock lock(sd->mutex);
@@ -3072,7 +3052,7 @@ Size2 TextServerFallback::shaped_text_get_size(RID p_shaped) const {
}
real_t TextServerFallback::shaped_text_get_ascent(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -3083,7 +3063,7 @@ real_t TextServerFallback::shaped_text_get_ascent(RID p_shaped) const {
}
real_t TextServerFallback::shaped_text_get_descent(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -3094,7 +3074,7 @@ real_t TextServerFallback::shaped_text_get_descent(RID p_shaped) const {
}
real_t TextServerFallback::shaped_text_get_width(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -3105,7 +3085,7 @@ real_t TextServerFallback::shaped_text_get_width(RID p_shaped) const {
}
real_t TextServerFallback::shaped_text_get_underline_position(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
@@ -3117,7 +3097,7 @@ real_t TextServerFallback::shaped_text_get_underline_position(RID p_shaped) cons
}
real_t TextServerFallback::shaped_text_get_underline_thickness(RID p_shaped) const {
- const ShapedTextData *sd = shaped_owner.getornull(p_shaped);
+ const ShapedTextData *sd = shaped_owner.get_or_null(p_shaped);
ERR_FAIL_COND_V(!sd, 0.f);
MutexLock lock(sd->mutex);
diff --git a/modules/webrtc/SCsub b/modules/webrtc/SCsub
index 31b8a73bf2..e6b9959840 100644
--- a/modules/webrtc/SCsub
+++ b/modules/webrtc/SCsub
@@ -4,11 +4,6 @@ Import("env")
Import("env_modules")
env_webrtc = env_modules.Clone()
-use_gdnative = env_webrtc["module_gdnative_enabled"]
-
-if use_gdnative: # GDNative is retained in Javascript for export compatibility
- env_webrtc.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
- env_webrtc.Prepend(CPPPATH=["#modules/gdnative/include/"])
if env["platform"] == "javascript":
# Our JavaScript/C++ interface.
diff --git a/modules/webrtc/config.py b/modules/webrtc/config.py
index 3281415f38..4ad918833a 100644
--- a/modules/webrtc/config.py
+++ b/modules/webrtc/config.py
@@ -11,6 +11,8 @@ def get_doc_classes():
"WebRTCPeerConnection",
"WebRTCDataChannel",
"WebRTCMultiplayerPeer",
+ "WebRTCPeerConnectionExtension",
+ "WebRTCDataChannelExtension",
]
diff --git a/modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml b/modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml
new file mode 100644
index 0000000000..746fabd6e5
--- /dev/null
+++ b/modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="WebRTCDataChannelExtension" inherits="WebRTCDataChannel" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_close" qualifiers="virtual">
+ <return type="void" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_available_packet_count" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_buffered_amount" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_id" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_label" qualifiers="virtual const">
+ <return type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_life_time" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_size" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_retransmits" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="const uint8_t **" />
+ <argument index="1" name="r_buffer_size" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_protocol" qualifiers="virtual const">
+ <return type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_ready_state" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_write_mode" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_negotiated" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_ordered" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_poll" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_buffer" type="const uint8_t*" />
+ <argument index="1" name="p_buffer_size" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_write_mode" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_write_mode" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_was_string_packet" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
index 9040d510c0..a8360a4d45 100644
--- a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
+++ b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
@@ -7,6 +7,7 @@
This class constructs a full mesh of [WebRTCPeerConnection] (one connection for each peer) that can be used as a [member MultiplayerAPI.multiplayer_peer].
You can add each [WebRTCPeerConnection] via [method add_peer] or remove them via [method remove_peer]. Peers must be added in [constant WebRTCPeerConnection.STATE_NEW] state to allow it to create the appropriate channels. This class will not create offers nor set descriptions, it will only poll them, and notify connections and disconnections.
[signal MultiplayerPeer.connection_succeeded] and [signal MultiplayerPeer.server_disconnected] will not be emitted unless [code]server_compatibility[/code] is [code]true[/code] in [method initialize]. Beside that data transfer works like in a [MultiplayerPeer].
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
@@ -67,8 +68,4 @@
</description>
</method>
</methods>
- <members>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
- </members>
</class>
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml b/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
new file mode 100644
index 0000000000..d296fcd6e7
--- /dev/null
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="WebRTCPeerConnectionExtension" inherits="WebRTCPeerConnection" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_add_ice_candidate" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_sdp_mid_name" type="String" />
+ <argument index="1" name="p_sdp_mline_index" type="int" />
+ <argument index="2" name="p_sdp_name" type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_close" qualifiers="virtual">
+ <return type="void" />
+ <description>
+ </description>
+ </method>
+ <method name="_create_data_channel" qualifiers="virtual">
+ <return type="Object" />
+ <argument index="0" name="p_label" type="String" />
+ <argument index="1" name="p_config" type="Dictionary" />
+ <description>
+ </description>
+ </method>
+ <method name="_create_offer" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_connection_state" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_initialize" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_config" type="Dictionary" />
+ <description>
+ </description>
+ </method>
+ <method name="_poll" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_local_description" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_type" type="String" />
+ <argument index="1" name="p_sdp" type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_remote_description" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_type" type="String" />
+ <argument index="1" name="p_sdp" type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="make_default">
+ <return type="void" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/modules/webrtc/register_types.cpp b/modules/webrtc/register_types.cpp
index 63ecc03a4c..8110e4a048 100644
--- a/modules/webrtc/register_types.cpp
+++ b/modules/webrtc/register_types.cpp
@@ -31,17 +31,11 @@
#include "register_types.h"
#include "core/config/project_settings.h"
#include "webrtc_data_channel.h"
+#include "webrtc_multiplayer_peer.h"
#include "webrtc_peer_connection.h"
-#ifdef JAVASCRIPT_ENABLED
-#include "emscripten.h"
-#include "webrtc_peer_connection_js.h"
-#endif
-#ifdef WEBRTC_GDNATIVE_ENABLED
-#include "webrtc_data_channel_gdnative.h"
-#include "webrtc_peer_connection_gdnative.h"
-#endif
-#include "webrtc_multiplayer_peer.h"
+#include "webrtc_data_channel_extension.h"
+#include "webrtc_peer_connection_extension.h"
void register_webrtc_types() {
#define _SET_HINT(NAME, _VAL_, _MAX_) \
@@ -50,18 +44,12 @@ void register_webrtc_types() {
_SET_HINT(WRTC_IN_BUF, 64, 4096);
-#ifdef JAVASCRIPT_ENABLED
- WebRTCPeerConnectionJS::make_default();
-#elif defined(WEBRTC_GDNATIVE_ENABLED)
- WebRTCPeerConnectionGDNative::make_default();
-#endif
-
ClassDB::register_custom_instance_class<WebRTCPeerConnection>();
-#ifdef WEBRTC_GDNATIVE_ENABLED
- GDREGISTER_CLASS(WebRTCPeerConnectionGDNative);
- GDREGISTER_CLASS(WebRTCDataChannelGDNative);
-#endif
+ GDREGISTER_CLASS(WebRTCPeerConnectionExtension);
+
GDREGISTER_VIRTUAL_CLASS(WebRTCDataChannel);
+ GDREGISTER_CLASS(WebRTCDataChannelExtension);
+
GDREGISTER_CLASS(WebRTCMultiplayerPeer);
}
diff --git a/modules/webrtc/webrtc_data_channel_extension.cpp b/modules/webrtc/webrtc_data_channel_extension.cpp
new file mode 100644
index 0000000000..ae346f6d8e
--- /dev/null
+++ b/modules/webrtc/webrtc_data_channel_extension.cpp
@@ -0,0 +1,215 @@
+/*************************************************************************/
+/* webrtc_data_channel_extension.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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 "webrtc_data_channel_extension.h"
+
+void WebRTCDataChannelExtension::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
+
+ GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
+ GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
+ GDVIRTUAL_BIND(_get_available_packet_count);
+ GDVIRTUAL_BIND(_get_max_packet_size);
+
+ GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_close);
+
+ GDVIRTUAL_BIND(_set_write_mode, "p_write_mode");
+ GDVIRTUAL_BIND(_get_write_mode);
+
+ GDVIRTUAL_BIND(_was_string_packet);
+ GDVIRTUAL_BIND(_get_ready_state);
+ GDVIRTUAL_BIND(_get_label);
+ GDVIRTUAL_BIND(_is_ordered);
+ GDVIRTUAL_BIND(_get_id);
+ GDVIRTUAL_BIND(_get_max_packet_life_time);
+ GDVIRTUAL_BIND(_get_max_retransmits);
+ GDVIRTUAL_BIND(_get_protocol);
+ GDVIRTUAL_BIND(_is_negotiated);
+ GDVIRTUAL_BIND(_get_buffered_amount);
+}
+
+int WebRTCDataChannelExtension::get_available_packet_count() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_packet_count, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_available_packet_count is unimplemented!");
+ return -1;
+}
+
+Error WebRTCDataChannelExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_packet_native is unimplemented!");
+ return FAILED;
+}
+
+Error WebRTCDataChannelExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_put_packet_native is unimplemented!");
+ return FAILED;
+}
+
+int WebRTCDataChannelExtension::get_max_packet_size() const {
+ int size;
+ if (GDVIRTUAL_CALL(_get_max_packet_size, size)) {
+ return size;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_max_packet_size is unimplemented!");
+ return 0;
+}
+
+Error WebRTCDataChannelExtension::poll() {
+ int err;
+ if (GDVIRTUAL_CALL(_poll, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_poll is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+void WebRTCDataChannelExtension::close() {
+ if (GDVIRTUAL_CALL(_close)) {
+ return;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_close is unimplemented!");
+}
+
+void WebRTCDataChannelExtension::set_write_mode(WriteMode p_mode) {
+ if (GDVIRTUAL_CALL(_set_write_mode, p_mode)) {
+ return;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_set_write_mode is unimplemented!");
+}
+
+WebRTCDataChannel::WriteMode WebRTCDataChannelExtension::get_write_mode() const {
+ int mode;
+ if (GDVIRTUAL_CALL(_get_write_mode, mode)) {
+ return (WriteMode)mode;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_write_mode is unimplemented!");
+ return WRITE_MODE_BINARY;
+}
+
+bool WebRTCDataChannelExtension::was_string_packet() const {
+ bool was_string;
+ if (GDVIRTUAL_CALL(_was_string_packet, was_string)) {
+ return was_string;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_was_string_packet is unimplemented!");
+ return false;
+}
+
+WebRTCDataChannel::ChannelState WebRTCDataChannelExtension::get_ready_state() const {
+ int state;
+ if (GDVIRTUAL_CALL(_get_ready_state, state)) {
+ return (ChannelState)state;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_ready_state is unimplemented!");
+ return STATE_CLOSED;
+}
+
+String WebRTCDataChannelExtension::get_label() const {
+ String label;
+ if (GDVIRTUAL_CALL(_get_label, label)) {
+ return label;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_label is unimplemented!");
+ return label;
+}
+
+bool WebRTCDataChannelExtension::is_ordered() const {
+ bool ordered;
+ if (GDVIRTUAL_CALL(_is_ordered, ordered)) {
+ return ordered;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_is_ordered is unimplemented!");
+ return false;
+}
+
+int WebRTCDataChannelExtension::get_id() const {
+ int id;
+ if (GDVIRTUAL_CALL(_get_id, id)) {
+ return id;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_id is unimplemented!");
+ return -1;
+}
+
+int WebRTCDataChannelExtension::get_max_packet_life_time() const {
+ int lifetime;
+ if (GDVIRTUAL_CALL(_get_max_packet_life_time, lifetime)) {
+ return lifetime;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_max_packet_life_time is unimplemented!");
+ return -1;
+}
+
+int WebRTCDataChannelExtension::get_max_retransmits() const {
+ int retransmits;
+ if (GDVIRTUAL_CALL(_get_max_retransmits, retransmits)) {
+ return retransmits;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_max_retransmits is unimplemented!");
+ return -1;
+}
+
+String WebRTCDataChannelExtension::get_protocol() const {
+ String protocol;
+ if (GDVIRTUAL_CALL(_get_protocol, protocol)) {
+ return protocol;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_protocol is unimplemented!");
+ return protocol;
+}
+
+bool WebRTCDataChannelExtension::is_negotiated() const {
+ bool negotiated;
+ if (GDVIRTUAL_CALL(_is_negotiated, negotiated)) {
+ return negotiated;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_is_negotiated is unimplemented!");
+ return false;
+}
+
+int WebRTCDataChannelExtension::get_buffered_amount() const {
+ int amount;
+ if (GDVIRTUAL_CALL(_get_buffered_amount, amount)) {
+ return amount;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_buffered_amount is unimplemented!");
+ return -1;
+}
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.h b/modules/webrtc/webrtc_data_channel_extension.h
index 5c80edd48c..eec96b4c62 100644
--- a/modules/webrtc/webrtc_data_channel_gdnative.h
+++ b/modules/webrtc/webrtc_data_channel_extension.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* webrtc_data_channel_gdnative.h */
+/* webrtc_data_channel_extension.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,26 +28,22 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef WEBRTC_DATA_CHANNEL_GDNATIVE_H
-#define WEBRTC_DATA_CHANNEL_GDNATIVE_H
+#ifndef WEBRTC_DATA_CHANNEL_EXTENSION_H
+#define WEBRTC_DATA_CHANNEL_EXTENSION_H
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "modules/gdnative/include/net/godot_net.h"
#include "webrtc_data_channel.h"
-class WebRTCDataChannelGDNative : public WebRTCDataChannel {
- GDCLASS(WebRTCDataChannelGDNative, WebRTCDataChannel);
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
+class WebRTCDataChannelExtension : public WebRTCDataChannel {
+ GDCLASS(WebRTCDataChannelExtension, WebRTCDataChannel);
protected:
static void _bind_methods();
-private:
- const godot_net_webrtc_data_channel *interface;
-
public:
- void set_native_webrtc_data_channel(const godot_net_webrtc_data_channel *p_impl);
-
virtual void set_write_mode(WriteMode mode) override;
virtual WriteMode get_write_mode() const override;
virtual bool was_string_packet() const override;
@@ -72,10 +68,31 @@ public:
virtual int get_max_packet_size() const override;
- WebRTCDataChannelGDNative();
- ~WebRTCDataChannelGDNative();
-};
+ /** GDExtension **/
+ GDVIRTUAL0RC(int, _get_available_packet_count);
+ GDVIRTUAL2R(int, _get_packet, GDNativeConstPtr<const uint8_t *>, GDNativePtr<int>);
+ GDVIRTUAL2R(int, _put_packet, GDNativeConstPtr<const uint8_t>, int);
+ GDVIRTUAL0RC(int, _get_max_packet_size);
-#endif // WEBRTC_GDNATIVE_ENABLED
+ GDVIRTUAL0R(int, _poll);
+ GDVIRTUAL0(_close);
+
+ GDVIRTUAL1(_set_write_mode, int);
+ GDVIRTUAL0RC(int, _get_write_mode);
+
+ GDVIRTUAL0RC(bool, _was_string_packet);
+
+ GDVIRTUAL0RC(int, _get_ready_state);
+ GDVIRTUAL0RC(String, _get_label);
+ GDVIRTUAL0RC(bool, _is_ordered);
+ GDVIRTUAL0RC(int, _get_id);
+ GDVIRTUAL0RC(int, _get_max_packet_life_time);
+ GDVIRTUAL0RC(int, _get_max_retransmits);
+ GDVIRTUAL0RC(String, _get_protocol);
+ GDVIRTUAL0RC(bool, _is_negotiated);
+ GDVIRTUAL0RC(int, _get_buffered_amount);
+
+ WebRTCDataChannelExtension() {}
+};
-#endif // WEBRTC_DATA_CHANNEL_GDNATIVE_H
+#endif // WEBRTC_DATA_CHANNEL_EXTENSION_H
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp
deleted file mode 100644
index 10a3367557..0000000000
--- a/modules/webrtc/webrtc_data_channel_gdnative.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*************************************************************************/
-/* webrtc_data_channel_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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. */
-/*************************************************************************/
-
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "webrtc_data_channel_gdnative.h"
-
-#include "core/io/resource_loader.h"
-#include "modules/gdnative/nativescript/nativescript.h"
-
-void WebRTCDataChannelGDNative::_bind_methods() {
- ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
-}
-
-WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() {
- interface = nullptr;
-}
-
-WebRTCDataChannelGDNative::~WebRTCDataChannelGDNative() {
-}
-
-Error WebRTCDataChannelGDNative::poll() {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->poll(interface->data);
-}
-
-void WebRTCDataChannelGDNative::close() {
- ERR_FAIL_COND(interface == nullptr);
- interface->close(interface->data);
-}
-
-void WebRTCDataChannelGDNative::set_write_mode(WriteMode p_mode) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_write_mode(interface->data, p_mode);
-}
-
-WebRTCDataChannel::WriteMode WebRTCDataChannelGDNative::get_write_mode() const {
- ERR_FAIL_COND_V(interface == nullptr, WRITE_MODE_BINARY);
- return (WriteMode)interface->get_write_mode(interface->data);
-}
-
-bool WebRTCDataChannelGDNative::was_string_packet() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->was_string_packet(interface->data);
-}
-
-WebRTCDataChannel::ChannelState WebRTCDataChannelGDNative::get_ready_state() const {
- ERR_FAIL_COND_V(interface == nullptr, STATE_CLOSED);
- return (ChannelState)interface->get_ready_state(interface->data);
-}
-
-String WebRTCDataChannelGDNative::get_label() const {
- ERR_FAIL_COND_V(interface == nullptr, "");
- return String(interface->get_label(interface->data));
-}
-
-bool WebRTCDataChannelGDNative::is_ordered() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->is_ordered(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_id() const {
- ERR_FAIL_COND_V(interface == nullptr, -1);
- return interface->get_id(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_max_packet_life_time() const {
- ERR_FAIL_COND_V(interface == nullptr, -1);
- return interface->get_max_packet_life_time(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_max_retransmits() const {
- ERR_FAIL_COND_V(interface == nullptr, -1);
- return interface->get_max_retransmits(interface->data);
-}
-
-String WebRTCDataChannelGDNative::get_protocol() const {
- ERR_FAIL_COND_V(interface == nullptr, "");
- return String(interface->get_protocol(interface->data));
-}
-
-bool WebRTCDataChannelGDNative::is_negotiated() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->is_negotiated(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_buffered_amount() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
- return interface->get_buffered_amount(interface->data);
-}
-
-Error WebRTCDataChannelGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
-}
-
-Error WebRTCDataChannelGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
-}
-
-int WebRTCDataChannelGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_max_packet_size(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_packet_count(interface->data);
-}
-
-void WebRTCDataChannelGDNative::set_native_webrtc_data_channel(const godot_net_webrtc_data_channel *p_impl) {
- interface = p_impl;
-}
-
-#endif // WEBRTC_GDNATIVE_ENABLED
diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp
index d60d694df1..48117f05f2 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.cpp
+++ b/modules/webrtc/webrtc_multiplayer_peer.cpp
@@ -43,22 +43,6 @@ void WebRTCMultiplayerPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("close"), &WebRTCMultiplayerPeer::close);
}
-void WebRTCMultiplayerPeer::set_transfer_channel(int p_channel) {
- transfer_channel = p_channel;
-}
-
-int WebRTCMultiplayerPeer::get_transfer_channel() const {
- return transfer_channel;
-}
-
-void WebRTCMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- transfer_mode = p_mode;
-}
-
-Multiplayer::TransferMode WebRTCMultiplayerPeer::get_transfer_mode() const {
- return transfer_mode;
-}
-
void WebRTCMultiplayerPeer::set_target_peer(int p_peer_id) {
target_peer = p_peer_id;
}
@@ -188,14 +172,6 @@ void WebRTCMultiplayerPeer::_find_next_peer() {
next_packet_peer = 0;
}
-void WebRTCMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
- refuse_connections = p_enable;
-}
-
-bool WebRTCMultiplayerPeer::is_refusing_new_connections() const {
- return refuse_connections;
-}
-
MultiplayerPeer::ConnectionStatus WebRTCMultiplayerPeer::get_connection_status() const {
return connection_status;
}
@@ -279,7 +255,7 @@ Dictionary WebRTCMultiplayerPeer::get_peers() {
Error WebRTCMultiplayerPeer::add_peer(Ref<WebRTCPeerConnection> p_peer, int p_peer_id, int p_unreliable_lifetime) {
ERR_FAIL_COND_V(p_peer_id < 0 || p_peer_id > ~(1 << 31), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_unreliable_lifetime < 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(refuse_connections, ERR_UNAUTHORIZED);
+ ERR_FAIL_COND_V(is_refusing_new_connections(), ERR_UNAUTHORIZED);
// Peer must be valid, and in new state (to create data channels)
ERR_FAIL_COND_V(!p_peer.is_valid(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_peer->get_connection_state() != WebRTCPeerConnection::STATE_NEW, ERR_INVALID_PARAMETER);
@@ -352,9 +328,9 @@ Error WebRTCMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_
Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
ERR_FAIL_COND_V(connection_status == CONNECTION_DISCONNECTED, ERR_UNCONFIGURED);
- int ch = transfer_channel;
+ int ch = get_transfer_channel();
if (ch == 0) {
- switch (transfer_mode) {
+ switch (get_transfer_mode()) {
case Multiplayer::TRANSFER_MODE_RELIABLE:
ch = CH_RELIABLE;
break;
diff --git a/modules/webrtc/webrtc_multiplayer_peer.h b/modules/webrtc/webrtc_multiplayer_peer.h
index 80a6491492..4a7e9ad7c8 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.h
+++ b/modules/webrtc/webrtc_multiplayer_peer.h
@@ -65,10 +65,7 @@ private:
uint32_t unique_id = 0;
int target_peer = 0;
int client_count = 0;
- bool refuse_connections = false;
ConnectionStatus connection_status = CONNECTION_DISCONNECTED;
- int transfer_channel = 0;
- Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
int next_packet_peer = 0;
bool server_compat = false;
@@ -97,10 +94,6 @@ public:
int get_max_packet_size() const override;
// MultiplayerPeer
- void set_transfer_channel(int p_channel) override;
- int get_transfer_channel() const override;
- void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- Multiplayer::TransferMode get_transfer_mode() const override;
void set_target_peer(int p_peer_id) override;
int get_unique_id() const override;
@@ -110,9 +103,6 @@ public:
void poll() override;
- void set_refuse_new_connections(bool p_enable) override;
- bool is_refusing_new_connections() const override;
-
ConnectionStatus get_connection_status() const override;
};
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp
index 3e2938bf7d..ad28aa76c7 100644
--- a/modules/webrtc/webrtc_peer_connection.cpp
+++ b/modules/webrtc/webrtc_peer_connection.cpp
@@ -30,17 +30,29 @@
#include "webrtc_peer_connection.h"
-WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = nullptr;
+#ifdef JAVASCRIPT_ENABLED
+#include "webrtc_peer_connection_js.h"
+#else
+#include "webrtc_peer_connection_extension.h"
+#endif
-Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() {
- return create();
+StringName WebRTCPeerConnection::default_extension;
+
+void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) {
+ default_extension = p_extension;
}
WebRTCPeerConnection *WebRTCPeerConnection::create() {
- if (!_create) {
- return nullptr;
+#ifdef JAVASCRIPT_ENABLED
+ return memnew(WebRTCPeerConnectionJS);
+#else
+ if (default_extension == String()) {
+ WARN_PRINT_ONCE("No default WebRTC extension configured.");
+ return memnew(WebRTCPeerConnectionExtension);
}
- return _create();
+ Object *obj = ClassDB::instantiate(default_extension);
+ return Object::cast_to<WebRTCPeerConnectionExtension>(obj);
+#endif
}
void WebRTCPeerConnection::_bind_methods() {
diff --git a/modules/webrtc/webrtc_peer_connection.h b/modules/webrtc/webrtc_peer_connection.h
index fcfb9ae9ae..e2ef3e55ad 100644
--- a/modules/webrtc/webrtc_peer_connection.h
+++ b/modules/webrtc/webrtc_peer_connection.h
@@ -47,11 +47,15 @@ public:
STATE_CLOSED
};
+private:
+ static StringName default_extension;
+
protected:
static void _bind_methods();
- static WebRTCPeerConnection *(*_create)();
public:
+ static void set_default_extension(const StringName &p_name);
+
virtual ConnectionState get_connection_state() const = 0;
virtual Error initialize(Dictionary p_config = Dictionary()) = 0;
@@ -63,7 +67,6 @@ public:
virtual Error poll() = 0;
virtual void close() = 0;
- static Ref<WebRTCPeerConnection> create_ref();
static WebRTCPeerConnection *create();
WebRTCPeerConnection();
diff --git a/modules/webrtc/webrtc_peer_connection_extension.cpp b/modules/webrtc/webrtc_peer_connection_extension.cpp
new file mode 100644
index 0000000000..33288e66d6
--- /dev/null
+++ b/modules/webrtc/webrtc_peer_connection_extension.cpp
@@ -0,0 +1,131 @@
+/*************************************************************************/
+/* webrtc_peer_connection_extension.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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 "webrtc_peer_connection_extension.h"
+
+void WebRTCPeerConnectionExtension::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("make_default"), &WebRTCPeerConnectionExtension::make_default);
+
+ GDVIRTUAL_BIND(_get_connection_state);
+ GDVIRTUAL_BIND(_initialize, "p_config");
+ GDVIRTUAL_BIND(_create_data_channel, "p_label", "p_config");
+ GDVIRTUAL_BIND(_create_offer);
+ GDVIRTUAL_BIND(_set_remote_description, "p_type", "p_sdp");
+ GDVIRTUAL_BIND(_set_local_description, "p_type", "p_sdp");
+ GDVIRTUAL_BIND(_add_ice_candidate, "p_sdp_mid_name", "p_sdp_mline_index", "p_sdp_name");
+ GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_close);
+}
+
+void WebRTCPeerConnectionExtension::make_default() {
+ ERR_FAIL_COND_MSG(!_get_extension(), vformat("Can't make %s the default without extending it.", get_class()));
+ WebRTCPeerConnection::set_default_extension(get_class());
+}
+
+WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionExtension::get_connection_state() const {
+ int state;
+ if (GDVIRTUAL_CALL(_get_connection_state, state)) {
+ return (ConnectionState)state;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_get_connection_state is unimplemented!");
+ return STATE_DISCONNECTED;
+}
+
+Error WebRTCPeerConnectionExtension::initialize(Dictionary p_config) {
+ int err;
+ if (GDVIRTUAL_CALL(_initialize, p_config, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_initialize is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Ref<WebRTCDataChannel> WebRTCPeerConnectionExtension::create_data_channel(String p_label, Dictionary p_options) {
+ Object *ret = nullptr;
+ if (GDVIRTUAL_CALL(_create_data_channel, p_label, p_options, ret)) {
+ WebRTCDataChannel *ch = Object::cast_to<WebRTCDataChannel>(ret);
+ ERR_FAIL_COND_V_MSG(ret && !ch, nullptr, "Returned object must be an instance of WebRTCDataChannel.");
+ return ch;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_create_data_channel is unimplemented!");
+ return nullptr;
+}
+
+Error WebRTCPeerConnectionExtension::create_offer() {
+ int err;
+ if (GDVIRTUAL_CALL(_create_offer, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_create_offer is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::set_local_description(String p_type, String p_sdp) {
+ int err;
+ if (GDVIRTUAL_CALL(_set_local_description, p_type, p_sdp, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_set_local_description is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::set_remote_description(String p_type, String p_sdp) {
+ int err;
+ if (GDVIRTUAL_CALL(_set_remote_description, p_type, p_sdp, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_set_remote_description is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::add_ice_candidate(String p_sdp_mid_name, int p_sdp_mline_index, String p_sdp_name) {
+ int err;
+ if (GDVIRTUAL_CALL(_add_ice_candidate, p_sdp_mid_name, p_sdp_mline_index, p_sdp_name, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_add_ice_candidate is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::poll() {
+ int err;
+ if (GDVIRTUAL_CALL(_poll, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_poll is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+void WebRTCPeerConnectionExtension::close() {
+ if (GDVIRTUAL_CALL(_close)) {
+ return;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_close is unimplemented!");
+}
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.h b/modules/webrtc/webrtc_peer_connection_extension.h
index 578af0202f..b3c2039fc1 100644
--- a/modules/webrtc/webrtc_peer_connection_gdnative.h
+++ b/modules/webrtc/webrtc_peer_connection_extension.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* webrtc_peer_connection_gdnative.h */
+/* webrtc_peer_connection_extension.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,30 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef WEBRTC_PEER_CONNECTION_GDNATIVE_H
-#define WEBRTC_PEER_CONNECTION_GDNATIVE_H
+#ifndef WEBRTC_PEER_CONNECTION_EXTENSION_H
+#define WEBRTC_PEER_CONNECTION_EXTENSION_H
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "modules/gdnative/include/net/godot_net.h"
#include "webrtc_peer_connection.h"
-class WebRTCPeerConnectionGDNative : public WebRTCPeerConnection {
- GDCLASS(WebRTCPeerConnectionGDNative, WebRTCPeerConnection);
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
+class WebRTCPeerConnectionExtension : public WebRTCPeerConnection {
+ GDCLASS(WebRTCPeerConnectionExtension, WebRTCPeerConnection);
protected:
static void _bind_methods();
- static WebRTCPeerConnection *_create();
-
-private:
- static const godot_net_webrtc_library *default_library;
- const godot_net_webrtc_peer_connection *interface;
public:
- static Error set_default_library(const godot_net_webrtc_library *p_library);
- static void make_default() { WebRTCPeerConnection::_create = WebRTCPeerConnectionGDNative::_create; }
-
- void set_native_webrtc_peer_connection(const godot_net_webrtc_peer_connection *p_impl);
+ void make_default();
virtual ConnectionState get_connection_state() const override;
@@ -60,14 +53,22 @@ public:
virtual Error create_offer() override;
virtual Error set_remote_description(String type, String sdp) override;
virtual Error set_local_description(String type, String sdp) override;
- virtual Error add_ice_candidate(String sdpMidName, int sdpMlineIndexName, String sdpName) override;
+ virtual Error add_ice_candidate(String p_sdp_mid_name, int p_sdp_mline_index, String p_sdp_name) override;
virtual Error poll() override;
virtual void close() override;
- WebRTCPeerConnectionGDNative();
- ~WebRTCPeerConnectionGDNative();
-};
+ /** GDExtension **/
+ GDVIRTUAL0RC(int, _get_connection_state);
+ GDVIRTUAL1R(int, _initialize, Dictionary);
+ GDVIRTUAL2R(Object *, _create_data_channel, String, Dictionary);
+ GDVIRTUAL0R(int, _create_offer);
+ GDVIRTUAL2R(int, _set_remote_description, String, String);
+ GDVIRTUAL2R(int, _set_local_description, String, String);
+ GDVIRTUAL3R(int, _add_ice_candidate, String, int, String);
+ GDVIRTUAL0R(int, _poll);
+ GDVIRTUAL0(_close);
-#endif // WEBRTC_GDNATIVE_ENABLED
+ WebRTCPeerConnectionExtension() {}
+};
-#endif // WEBRTC_PEER_CONNECTION_GDNATIVE_H
+#endif // WEBRTC_PEER_CONNECTION_EXTENSION_H
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
deleted file mode 100644
index dcf78dfb73..0000000000
--- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************************************/
-/* webrtc_peer_connection_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 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. */
-/*************************************************************************/
-
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "webrtc_peer_connection_gdnative.h"
-
-#include "core/io/resource_loader.h"
-#include "modules/gdnative/nativescript/nativescript.h"
-#include "webrtc_data_channel_gdnative.h"
-
-const godot_net_webrtc_library *WebRTCPeerConnectionGDNative::default_library = nullptr;
-
-Error WebRTCPeerConnectionGDNative::set_default_library(const godot_net_webrtc_library *p_lib) {
- if (default_library) {
- const godot_net_webrtc_library *old = default_library;
- default_library = nullptr;
- old->unregistered();
- }
- default_library = p_lib;
- return OK; // Maybe add version check and fail accordingly
-}
-
-WebRTCPeerConnection *WebRTCPeerConnectionGDNative::_create() {
- WebRTCPeerConnectionGDNative *obj = memnew(WebRTCPeerConnectionGDNative);
- ERR_FAIL_COND_V_MSG(!default_library, obj, "Default GDNative WebRTC implementation not defined.");
-
- // Call GDNative constructor
- Error err = (Error)default_library->create_peer_connection(obj);
- ERR_FAIL_COND_V_MSG(err != OK, obj, "GDNative default library constructor returned an error.");
-
- return obj;
-}
-
-void WebRTCPeerConnectionGDNative::_bind_methods() {
-}
-
-WebRTCPeerConnectionGDNative::WebRTCPeerConnectionGDNative() {
- interface = nullptr;
-}
-
-WebRTCPeerConnectionGDNative::~WebRTCPeerConnectionGDNative() {
-}
-
-Error WebRTCPeerConnectionGDNative::initialize(Dictionary p_config) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->initialize(interface->data, (const godot_dictionary *)&p_config);
-}
-
-Ref<WebRTCDataChannel> WebRTCPeerConnectionGDNative::create_data_channel(String p_label, Dictionary p_options) {
- ERR_FAIL_COND_V(interface == nullptr, nullptr);
- return (WebRTCDataChannel *)interface->create_data_channel(interface->data, p_label.utf8().get_data(), (const godot_dictionary *)&p_options);
-}
-
-Error WebRTCPeerConnectionGDNative::create_offer() {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->create_offer(interface->data);
-}
-
-Error WebRTCPeerConnectionGDNative::set_local_description(String p_type, String p_sdp) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->set_local_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data());
-}
-
-Error WebRTCPeerConnectionGDNative::set_remote_description(String p_type, String p_sdp) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->set_remote_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data());
-}
-
-Error WebRTCPeerConnectionGDNative::add_ice_candidate(String sdpMidName, int sdpMlineIndexName, String sdpName) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->add_ice_candidate(interface->data, sdpMidName.utf8().get_data(), sdpMlineIndexName, sdpName.utf8().get_data());
-}
-
-Error WebRTCPeerConnectionGDNative::poll() {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->poll(interface->data);
-}
-
-void WebRTCPeerConnectionGDNative::close() {
- ERR_FAIL_COND(interface == nullptr);
- interface->close(interface->data);
-}
-
-WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionGDNative::get_connection_state() const {
- ERR_FAIL_COND_V(interface == nullptr, STATE_DISCONNECTED);
- return (ConnectionState)interface->get_connection_state(interface->data);
-}
-
-void WebRTCPeerConnectionGDNative::set_native_webrtc_peer_connection(const godot_net_webrtc_peer_connection *p_impl) {
- interface = p_impl;
-}
-
-#endif // WEBRTC_GDNATIVE_ENABLED
diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h
index 0272e67f6f..d2beccaf03 100644
--- a/modules/webrtc/webrtc_peer_connection_js.h
+++ b/modules/webrtc/webrtc_peer_connection_js.h
@@ -63,9 +63,6 @@ private:
static void _on_error(void *p_obj);
public:
- static WebRTCPeerConnection *_create() { return memnew(WebRTCPeerConnectionJS); }
- static void make_default() { WebRTCPeerConnection::_create = WebRTCPeerConnectionJS::_create; }
-
virtual ConnectionState get_connection_state() const;
virtual Error initialize(Dictionary configuration = Dictionary());
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index ed8f3ba867..4b515c12a1 100644
--- a/modules/websocket/doc_classes/WebSocketClient.xml
+++ b/modules/websocket/doc_classes/WebSocketClient.xml
@@ -8,6 +8,7 @@
This client can be optionally used as a multiplayer peer for the [MultiplayerAPI].
After starting the client ([method connect_to_url]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]).
You will receive appropriate signals when connecting, disconnecting, or when new data is available.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
index bf35acbd11..8d8ab220e2 100644
--- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
Base class for WebSocket server and client, allowing them to be used as multiplayer peer for the [MultiplayerAPI].
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
@@ -30,10 +31,6 @@
</description>
</method>
</methods>
- <members>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
- </members>
<signals>
<signal name="peer_packet">
<argument index="0" name="peer_source" type="int" />
diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml
index 2bb705b384..f901b089ea 100644
--- a/modules/websocket/doc_classes/WebSocketServer.xml
+++ b/modules/websocket/doc_classes/WebSocketServer.xml
@@ -7,6 +7,7 @@
This class implements a WebSocket server that can also support the high-level multiplayer API.
After starting the server ([method listen]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal.
[b]Note:[/b] Not available in HTML5 exports.
+ [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description>
<tutorials>
</tutorials>
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 7464cf2bf5..3a27855a5e 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -105,23 +105,6 @@ Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer
//
// MultiplayerPeer
//
-void WebSocketMultiplayerPeer::set_transfer_channel(int p_channel) {
- // Websocket does not have channels.
-}
-
-int WebSocketMultiplayerPeer::get_transfer_channel() const {
- return 0;
-}
-
-void WebSocketMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- // Websocket uses TCP, reliable
-}
-
-Multiplayer::TransferMode WebSocketMultiplayerPeer::get_transfer_mode() const {
- // Websocket uses TCP, reliable
- return Multiplayer::TRANSFER_MODE_RELIABLE;
-}
-
void WebSocketMultiplayerPeer::set_target_peer(int p_target_peer) {
_target_peer = p_target_peer;
}
@@ -137,14 +120,6 @@ int WebSocketMultiplayerPeer::get_unique_id() const {
return _peer_id;
}
-void WebSocketMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
- _refusing = p_enable;
-}
-
-bool WebSocketMultiplayerPeer::is_refusing_new_connections() const {
- return _refusing;
-}
-
void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_type, int32_t p_peer_id) {
ERR_FAIL_COND(!p_peer.is_valid());
ERR_FAIL_COND(!p_peer->is_connected_to_host());
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index d97a599fe9..380edf67ed 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/modules/websocket/websocket_multiplayer_peer.h
@@ -68,7 +68,6 @@ protected:
bool _is_multiplayer = false;
int _target_peer = 0;
int _peer_id = 0;
- int _refusing = false;
static void _bind_methods();
@@ -78,15 +77,9 @@ protected:
public:
/* MultiplayerPeer */
- void set_transfer_channel(int p_channel) override;
- int get_transfer_channel() const override;
- void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- Multiplayer::TransferMode get_transfer_mode() const override;
void set_target_peer(int p_target_peer) override;
int get_packet_peer() const override;
int get_unique_id() const override;
- void set_refuse_new_connections(bool p_enable) override;
- bool is_refusing_new_connections() const override;
/* PacketPeer */
virtual int get_available_packet_count() const override;
diff --git a/modules/webxr/register_types.cpp b/modules/webxr/register_types.cpp
index 078a6547cf..16b483c39e 100644
--- a/modules/webxr/register_types.cpp
+++ b/modules/webxr/register_types.cpp
@@ -33,15 +33,34 @@
#include "webxr_interface.h"
#include "webxr_interface_js.h"
+#ifdef JAVASCRIPT_ENABLED
+Ref<WebXRInterfaceJS> webxr;
+#endif
+
void register_webxr_types() {
GDREGISTER_VIRTUAL_CLASS(WebXRInterface);
#ifdef JAVASCRIPT_ENABLED
- Ref<WebXRInterfaceJS> webxr;
webxr.instantiate();
XRServer::get_singleton()->add_interface(webxr);
#endif
}
void unregister_webxr_types() {
+#ifdef JAVASCRIPT_ENABLED
+ if (webxr.is_valid()) {
+ // uninitialise our interface if it is initialised
+ if (webxr->is_initialized()) {
+ webxr->uninitialize();
+ }
+
+ // unregister our interface from the XR server
+ if (XRServer::get_singleton()) {
+ XRServer::get_singleton()->remove_interface(webxr);
+ }
+
+ // and release
+ webxr.unref();
+ }
+#endif
}
diff --git a/platform/javascript/.eslintrc.js b/platform/javascript/.eslintrc.js
index 0ff9d67d26..2c81f1f02d 100644
--- a/platform/javascript/.eslintrc.js
+++ b/platform/javascript/.eslintrc.js
@@ -39,5 +39,13 @@ module.exports = {
// Closure compiler (exported properties)
"quote-props": ["error", "consistent"],
"dot-notation": "off",
+ // No comma dangle for functions (it's madness, and ES2017)
+ "comma-dangle": ["error", {
+ "arrays": "always-multiline",
+ "objects": "always-multiline",
+ "imports": "always-multiline",
+ "exports": "always-multiline",
+ "functions": "never"
+ }],
}
};
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index be4d2cba20..124b4ee1c8 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -595,6 +595,12 @@ void DisplayServerJavaScript::virtual_keyboard_hide() {
godot_js_display_vk_hide();
}
+// Window blur callback
+EM_BOOL DisplayServerJavaScript::blur_callback(int p_event_type, const EmscriptenFocusEvent *p_event, void *p_user_data) {
+ Input::get_singleton()->release_pressed_events();
+ return false;
+}
+
// Gamepad
void DisplayServerJavaScript::gamepad_callback(int p_index, int p_connected, const char *p_id, const char *p_guid) {
Input *input = Input::get_singleton();
@@ -797,6 +803,7 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
SET_EM_CALLBACK(canvas_id, mousedown, mouse_button_callback)
SET_EM_WINDOW_CALLBACK(mousemove, mousemove_callback)
SET_EM_WINDOW_CALLBACK(mouseup, mouse_button_callback)
+ SET_EM_WINDOW_CALLBACK(blur, blur_callback)
SET_EM_CALLBACK(canvas_id, wheel, wheel_callback)
SET_EM_CALLBACK(canvas_id, touchstart, touch_press_callback)
SET_EM_CALLBACK(canvas_id, touchmove, touchmove_callback)
diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h
index bf5e229c9a..1863ddefeb 100644
--- a/platform/javascript/display_server_javascript.h
+++ b/platform/javascript/display_server_javascript.h
@@ -85,6 +85,8 @@ private:
static EM_BOOL touch_press_callback(int p_event_type, const EmscriptenTouchEvent *p_event, void *p_user_data);
static EM_BOOL touchmove_callback(int p_event_type, const EmscriptenTouchEvent *p_event, void *p_user_data);
+ static EM_BOOL blur_callback(int p_event_type, const EmscriptenFocusEvent *p_event, void *p_user_data);
+
static void gamepad_callback(int p_index, int p_connected, const char *p_id, const char *p_guid);
void process_joypads();
diff --git a/platform/javascript/js/libs/library_godot_audio.js b/platform/javascript/js/libs/library_godot_audio.js
index f6010fd12a..6cbb0567f4 100644
--- a/platform/javascript/js/libs/library_godot_audio.js
+++ b/platform/javascript/js/libs/library_godot_audio.js
@@ -229,7 +229,7 @@ const GodotAudioWorklet = {
'godot-processor',
{
'outputChannelCount': [channels],
- },
+ }
);
return Promise.resolve();
});
diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp
index 54a3104482..2404c20153 100644
--- a/platform/osx/export/export_plugin.cpp
+++ b/platform/osx/export/export_plugin.cpp
@@ -95,6 +95,7 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_pictures", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_music", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/entitlements/app_sandbox/files_movies", PROPERTY_HINT_ENUM, "No,Read-only,Read-write"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::ARRAY, "codesign/entitlements/app_sandbox/helper_executables", PROPERTY_HINT_ARRAY_TYPE, itos(Variant::STRING) + "/" + itos(PROPERTY_HINT_GLOBAL_FILE) + ":"), Array()));
r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));
@@ -535,6 +536,8 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
err = ERR_CANT_CREATE;
}
+ Array helpers = p_preset->get("codesign/entitlements/app_sandbox/helper_executables");
+
// Create our folder structure.
if (err == OK) {
print_line("Creating " + tmp_app_path_name + "/Contents/MacOS");
@@ -546,6 +549,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
}
+ if ((err == OK) && helpers.size() > 0) {
+ print_line("Creating " + tmp_app_path_name + "/Contents/Helpers");
+ err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Helpers");
+ }
+
if (err == OK) {
print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
err = tmp_app_dir->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
@@ -688,6 +696,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
bool sign_enabled = p_preset->get("codesign/enable");
String ent_path = p_preset->get("codesign/entitlements/custom_file");
+ String hlp_ent_path = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name + "_helper.entitlements");
if (sign_enabled && (ent_path == "")) {
ent_path = EditorPaths::get_singleton()->get_cache_dir().plus_file(pkg_name + ".entitlements");
@@ -819,10 +828,43 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
} else {
err = ERR_CANT_CREATE;
}
+
+ if ((err == OK) && helpers.size() > 0) {
+ ent_f = FileAccess::open(hlp_ent_path, FileAccess::WRITE);
+ if (ent_f) {
+ ent_f->store_line("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ ent_f->store_line("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
+ ent_f->store_line("<plist version=\"1.0\">");
+ ent_f->store_line("<dict>");
+ ent_f->store_line("<key>com.apple.security.app-sandbox</key>");
+ ent_f->store_line("<true/>");
+ ent_f->store_line("<key>com.apple.security.inherit</key>");
+ ent_f->store_line("<true/>");
+ ent_f->store_line("</dict>");
+ ent_f->store_line("</plist>");
+
+ ent_f->close();
+ memdelete(ent_f);
+ } else {
+ err = ERR_CANT_CREATE;
+ }
+ }
+ }
+
+ if ((err == OK) && helpers.size() > 0) {
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ for (int i = 0; i < helpers.size(); i++) {
+ String hlp_path = helpers[i];
+ err = da->copy(hlp_path, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file());
+ if (err == OK && sign_enabled) {
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), hlp_ent_path);
+ }
+ FileAccess::set_unix_permissions(tmp_app_path_name + "/Contents/Helpers/" + hlp_path.get_file(), 0755);
+ }
}
if (err == OK) {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
for (int i = 0; i < shared_objects.size(); i++) {
String src_path = ProjectSettings::get_singleton()->globalize_path(shared_objects[i].path);
if (da->dir_exists(src_path)) {
@@ -842,7 +884,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + src_path.get_file(), ent_path);
}
}
- memdelete(da);
}
if (sign_enabled) {
@@ -903,6 +944,9 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
err = _notarize(p_preset, p_path);
}
+ // Clean up temporary entitlements files.
+ DirAccess::remove_file_or_error(hlp_ent_path);
+
// Clean up temporary .app dir.
tmp_app_dir->change_dir(tmp_app_path_name);
tmp_app_dir->erase_contents_recursive();
@@ -916,7 +960,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) {
String dir = p_root_path.plus_file(p_folder);
- DirAccess *da = DirAccess::open(dir);
+ DirAccessRef da = DirAccess::open(dir);
da->list_dir_begin();
String f;
while ((f = da->get_next()) != "") {
@@ -967,7 +1011,7 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String
} else if (da->current_is_dir()) {
_zip_folder_recursive(p_zip, p_root_path, p_folder.plus_file(f), p_pkg_name);
} else {
- bool is_executable = (p_folder.ends_with("MacOS") && (f == p_pkg_name));
+ bool is_executable = (p_folder.ends_with("MacOS") && (f == p_pkg_name)) || p_folder.ends_with("Helpers");
OS::Time time = OS::get_singleton()->get_time();
OS::Date date = OS::get_singleton()->get_date();
@@ -1012,7 +1056,6 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String
}
}
da->list_dir_end();
- memdelete(da);
}
bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index df41ccd892..a52436a70a 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -82,6 +82,7 @@ public:
virtual String get_data_path() const override;
virtual String get_cache_path() const override;
virtual String get_bundle_resource_dir() const override;
+ virtual String get_bundle_icon_path() const override;
virtual String get_godot_dir_name() const override;
virtual String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const override;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index c6e35fee83..6ef1bdbd11 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -379,14 +379,26 @@ String OS_OSX::get_cache_path() const {
}
String OS_OSX::get_bundle_resource_dir() const {
+ String ret;
+
NSBundle *main = [NSBundle mainBundle];
- NSString *resourcePath = [main resourcePath];
+ if (main) {
+ NSString *resourcePath = [main resourcePath];
+ ret.parse_utf8([resourcePath UTF8String]);
+ }
+ return ret;
+}
- char *utfs = strdup([resourcePath UTF8String]);
+String OS_OSX::get_bundle_icon_path() const {
String ret;
- ret.parse_utf8(utfs);
- free(utfs);
+ NSBundle *main = [NSBundle mainBundle];
+ if (main) {
+ NSString *iconPath = [[main infoDictionary] objectForKey:@"CFBundleIconFile"];
+ if (iconPath) {
+ ret.parse_utf8([iconPath UTF8String]);
+ }
+ }
return ret;
}
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index cf2632f380..bf26ec1f20 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -727,7 +727,7 @@ void CPUParticles2D::_particles_process(double p_delta) {
p.hue_rot_rand = Math::randf();
p.anim_offset_rand = Math::randf();
- real_t angle1_rad = Math::atan2(direction.y, direction.x) + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread);
+ real_t angle1_rad = direction.angle() + Math::deg2rad((Math::randf() * 2.0 - 1.0) * spread);
Vector2 rot = Vector2(Math::cos(angle1_rad), Math::sin(angle1_rad));
p.velocity = rot * Math::lerp(parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], parameters_min[PARAM_INITIAL_LINEAR_VELOCITY], Math::randf());
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index 72ea6541e3..cbf0d50c4e 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -464,7 +464,7 @@ void NavigationRegion2D::_notification(int p_what) {
draw_line(a, b, doors_color);
// Draw a circle to illustrate the margins.
- real_t angle = (b - a).angle();
+ real_t angle = b.angle_to_point(a);
draw_arc(a, radius, angle + Math_PI / 2.0, angle - Math_PI / 2.0 + Math_TAU, 10, doors_color);
draw_arc(b, radius, angle - Math_PI / 2.0, angle + Math_PI / 2.0, 10, doors_color);
}
diff --git a/scene/2d/physical_bone_2d.cpp b/scene/2d/physical_bone_2d.cpp
index c4b2608812..48817679bc 100644
--- a/scene/2d/physical_bone_2d.cpp
+++ b/scene/2d/physical_bone_2d.cpp
@@ -150,27 +150,15 @@ void PhysicalBone2D::_start_physics_simulation() {
return;
}
- // Reset to Bone2D position
+ // Reset to Bone2D position.
_position_at_bone2d();
- // Apply the layers and masks
+ // Apply the layers and masks.
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
- // Apply the correct mode
- RigidDynamicBody2D::Mode rigid_mode = get_mode();
- if (rigid_mode == RigidDynamicBody2D::MODE_STATIC) {
- set_body_mode(PhysicsServer2D::BODY_MODE_STATIC);
- } else if (rigid_mode == RigidDynamicBody2D::MODE_DYNAMIC) {
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC);
- } else if (rigid_mode == RigidDynamicBody2D::MODE_KINEMATIC) {
- set_body_mode(PhysicsServer2D::BODY_MODE_KINEMATIC);
- } else if (rigid_mode == RigidDynamicBody2D::MODE_DYNAMIC_LOCKED) {
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED);
- } else {
- // Default to Dynamic.
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC);
- }
+ // Apply the correct mode.
+ _apply_body_mode();
_internal_simulate_physics = true;
set_physics_process_internal(true);
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index c3dc9ab92b..09bcbdbf0f 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -34,8 +34,8 @@
#include "scene/scene_string_names.h"
void PhysicsBody2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "test_only", "safe_margin"), &PhysicsBody2D::_move, DEFVAL(false), DEFVAL(0.08));
- ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "collision", "safe_margin"), &PhysicsBody2D::test_move, DEFVAL(Variant()), DEFVAL(0.08));
+ ClassDB::bind_method(D_METHOD("move_and_collide", "linear_velocity", "test_only", "safe_margin"), &PhysicsBody2D::_move, DEFVAL(false), DEFVAL(0.08));
+ ClassDB::bind_method(D_METHOD("test_move", "from", "linear_velocity", "collision", "safe_margin"), &PhysicsBody2D::test_move, DEFVAL(Variant()), DEFVAL(0.08));
ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &PhysicsBody2D::get_collision_exceptions);
ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody2D::add_collision_exception_with);
@@ -57,7 +57,10 @@ PhysicsBody2D::~PhysicsBody2D() {
Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_motion, bool p_test_only, real_t p_margin) {
PhysicsServer2D::MotionResult result;
- if (move_and_collide(p_motion, result, p_margin, p_test_only)) {
+ // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky.
+ double delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time();
+
+ if (move_and_collide(p_motion * delta, result, p_margin, p_test_only)) {
// Create a new instance when the cached reference is invalid or still in use in script.
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
motion_cache.instantiate();
@@ -133,7 +136,10 @@ bool PhysicsBody2D::test_move(const Transform2D &p_from, const Vector2 &p_motion
r = const_cast<PhysicsServer2D::MotionResult *>(&r_collision->result);
}
- return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_margin, r);
+ // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky.
+ double delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time();
+
+ return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion * delta, p_margin, r);
}
TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() {
@@ -282,6 +288,12 @@ void AnimatableBody2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
last_valid_transform = get_global_transform();
+ _update_kinematic_motion();
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ set_only_update_transform_changes(false);
+ set_notify_local_transform(false);
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
@@ -307,7 +319,6 @@ void AnimatableBody2D::_bind_methods() {
AnimatableBody2D::AnimatableBody2D() :
StaticBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
- _update_kinematic_motion();
}
void RigidDynamicBody2D::_body_enter_tree(ObjectID p_id) {
@@ -430,7 +441,7 @@ void RigidDynamicBody2D::_body_state_changed_callback(void *p_instance, PhysicsD
void RigidDynamicBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) {
set_block_transform_notify(true); // don't want notify (would feedback loop)
- if (mode != MODE_KINEMATIC) {
+ if (!freeze || freeze_mode != FREEZE_MODE_KINEMATIC) {
set_global_transform(p_state->get_transform());
}
@@ -524,29 +535,60 @@ void RigidDynamicBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state)
}
}
-void RigidDynamicBody2D::set_mode(Mode p_mode) {
- mode = p_mode;
- switch (p_mode) {
- case MODE_DYNAMIC: {
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC);
- } break;
- case MODE_STATIC: {
- set_body_mode(PhysicsServer2D::BODY_MODE_STATIC);
+void RigidDynamicBody2D::_apply_body_mode() {
+ if (freeze) {
+ switch (freeze_mode) {
+ case FREEZE_MODE_STATIC: {
+ set_body_mode(PhysicsServer2D::BODY_MODE_STATIC);
+ } break;
+ case FREEZE_MODE_KINEMATIC: {
+ set_body_mode(PhysicsServer2D::BODY_MODE_KINEMATIC);
+ } break;
+ }
+ } else if (lock_rotation) {
+ set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR);
+ } else {
+ set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC);
+ }
+}
- } break;
- case MODE_KINEMATIC: {
- set_body_mode(PhysicsServer2D::BODY_MODE_KINEMATIC);
+void RigidDynamicBody2D::set_lock_rotation_enabled(bool p_lock_rotation) {
+ if (p_lock_rotation == lock_rotation) {
+ return;
+ }
- } break;
- case MODE_DYNAMIC_LOCKED: {
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED);
+ lock_rotation = p_lock_rotation;
+ _apply_body_mode();
+}
- } break;
+bool RigidDynamicBody2D::is_lock_rotation_enabled() const {
+ return lock_rotation;
+}
+
+void RigidDynamicBody2D::set_freeze_enabled(bool p_freeze) {
+ if (p_freeze == freeze) {
+ return;
+ }
+
+ freeze = p_freeze;
+ _apply_body_mode();
+}
+
+bool RigidDynamicBody2D::is_freeze_enabled() const {
+ return freeze;
+}
+
+void RigidDynamicBody2D::set_freeze_mode(FreezeMode p_freeze_mode) {
+ if (p_freeze_mode == freeze_mode) {
+ return;
}
+
+ freeze_mode = p_freeze_mode;
+ _apply_body_mode();
}
-RigidDynamicBody2D::Mode RigidDynamicBody2D::get_mode() const {
- return mode;
+RigidDynamicBody2D::FreezeMode RigidDynamicBody2D::get_freeze_mode() const {
+ return freeze_mode;
}
void RigidDynamicBody2D::set_mass(real_t p_mass) {
@@ -844,17 +886,14 @@ TypedArray<String> RigidDynamicBody2D::get_configuration_warnings() const {
TypedArray<String> warnings = CollisionObject2D::get_configuration_warnings();
- if ((get_mode() == MODE_DYNAMIC || get_mode() == MODE_DYNAMIC_LOCKED) && (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05)) {
- warnings.push_back(TTR("Size changes to RigidDynamicBody2D (in dynamic modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
+ if (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05) {
+ warnings.push_back(TTR("Size changes to RigidDynamicBody2D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
}
return warnings;
}
void RigidDynamicBody2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidDynamicBody2D::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &RigidDynamicBody2D::get_mode);
-
ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidDynamicBody2D::set_mass);
ClassDB::bind_method(D_METHOD("get_mass"), &RigidDynamicBody2D::get_mass);
@@ -918,11 +957,19 @@ void RigidDynamicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidDynamicBody2D::set_can_sleep);
ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidDynamicBody2D::is_able_to_sleep);
+ ClassDB::bind_method(D_METHOD("set_lock_rotation_enabled", "lock_rotation"), &RigidDynamicBody2D::set_lock_rotation_enabled);
+ ClassDB::bind_method(D_METHOD("is_lock_rotation_enabled"), &RigidDynamicBody2D::is_lock_rotation_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_freeze_enabled", "freeze_mode"), &RigidDynamicBody2D::set_freeze_enabled);
+ ClassDB::bind_method(D_METHOD("is_freeze_enabled"), &RigidDynamicBody2D::is_freeze_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_freeze_mode", "freeze_mode"), &RigidDynamicBody2D::set_freeze_mode);
+ ClassDB::bind_method(D_METHOD("get_freeze_mode"), &RigidDynamicBody2D::get_freeze_mode);
+
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidDynamicBody2D::get_colliding_bodies);
GDVIRTUAL_BIND(_integrate_forces, "state");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Dynamic,Static,DynamicLocked,Kinematic"), "set_mode", "get_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_RANGE, "0.01,1000,0.01,or_greater,exp"), "set_mass", "get_mass");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inertia", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater,exp"), "set_inertia", "get_inertia");
ADD_PROPERTY(PropertyInfo(Variant::INT, "center_of_mass_mode", PROPERTY_HINT_ENUM, "Auto,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_center_of_mass_mode", "get_center_of_mass_mode");
@@ -936,6 +983,9 @@ void RigidDynamicBody2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "contact_monitor"), "set_contact_monitor", "is_contact_monitor_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleeping", "is_sleeping");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), "set_can_sleep", "is_able_to_sleep");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "lock_rotation"), "set_lock_rotation_enabled", "is_lock_rotation_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "freeze"), "set_freeze_enabled", "is_freeze_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "freeze_mode", PROPERTY_HINT_ENUM, "Static,Kinematic"), "set_freeze_mode", "get_freeze_mode");
ADD_GROUP("Linear", "linear_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "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");
@@ -952,10 +1002,8 @@ void RigidDynamicBody2D::_bind_methods() {
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_ENUM_CONSTANT(MODE_DYNAMIC);
- BIND_ENUM_CONSTANT(MODE_STATIC);
- BIND_ENUM_CONSTANT(MODE_DYNAMIC_LOCKED);
- BIND_ENUM_CONSTANT(MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(FREEZE_MODE_STATIC);
+ BIND_ENUM_CONSTANT(FREEZE_MODE_KINEMATIC);
BIND_ENUM_CONSTANT(CENTER_OF_MASS_MODE_AUTO);
BIND_ENUM_CONSTANT(CENTER_OF_MASS_MODE_CUSTOM);
@@ -1004,6 +1052,8 @@ bool CharacterBody2D::move_and_slide() {
double delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time();
Vector2 current_platform_velocity = platform_velocity;
+ Transform2D gt = get_global_transform();
+ previous_position = gt.elements[2];
if ((on_floor || on_wall) && platform_rid.is_valid()) {
bool excluded = false;
@@ -1016,7 +1066,6 @@ bool CharacterBody2D::move_and_slide() {
//this approach makes sure there is less delay between the actual body velocity and the one we saved
PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(platform_rid);
if (bs) {
- Transform2D gt = get_global_transform();
Vector2 local_position = gt.elements[2] - bs->get_transform().elements[2];
current_platform_velocity = bs->get_velocity_at_local_position(local_position);
}
@@ -1026,6 +1075,7 @@ bool CharacterBody2D::move_and_slide() {
}
motion_results.clear();
+ last_motion = Vector2();
bool was_on_floor = on_floor;
on_floor = false;
@@ -1048,16 +1098,24 @@ bool CharacterBody2D::move_and_slide() {
_move_and_slide_free(delta);
}
- if (!on_floor && !on_wall) {
+ // Compute real velocity.
+ real_velocity = get_position_delta() / delta;
+
+ if (moving_platform_apply_velocity_on_leave != PLATFORM_VEL_ON_LEAVE_NEVER) {
// Add last platform velocity when just left a moving platform.
- linear_velocity += current_platform_velocity;
+ if (!on_floor && !on_wall) {
+ if (moving_platform_apply_velocity_on_leave == PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY && current_platform_velocity.dot(up_direction) < 0) {
+ current_platform_velocity = current_platform_velocity.slide(up_direction);
+ }
+ motion_velocity += current_platform_velocity;
+ }
}
return motion_results.size() > 0;
}
void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_floor, const Vector2 &p_prev_platform_velocity) {
- Vector2 motion = linear_velocity * p_delta;
+ Vector2 motion = motion_velocity * p_delta;
Vector2 motion_slide_up = motion.slide(up_direction);
Vector2 prev_floor_normal = floor_normal;
@@ -1074,7 +1132,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Constant speed can be applied only the first time sliding is enabled.
bool can_apply_constant_speed = sliding_enabled;
bool first_slide = true;
- bool vel_dir_facing_up = linear_velocity.dot(up_direction) > 0;
+ bool vel_dir_facing_up = motion_velocity.dot(up_direction) > 0;
Vector2 last_travel;
for (int iteration = 0; iteration < max_slides; ++iteration) {
@@ -1083,20 +1141,20 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
Vector2 prev_position = get_global_transform().elements[2];
bool collided = move_and_collide(motion, result, margin, false, !sliding_enabled);
+ last_motion = result.travel;
if (collided) {
motion_results.push_back(result);
_set_collision_direction(result);
- if (on_floor && floor_stop_on_slope && (linear_velocity.normalized() + up_direction).length() < 0.01) {
+ if (on_floor && floor_stop_on_slope && (motion_velocity.normalized() + up_direction).length() < 0.01) {
Transform2D gt = get_global_transform();
- if (result.travel.length() > margin) {
- gt.elements[2] -= result.travel.slide(up_direction);
- } else {
+ if (result.travel.length() <= margin + CMP_EPSILON) {
gt.elements[2] -= result.travel;
}
set_global_transform(gt);
- linear_velocity = Vector2();
+ motion_velocity = Vector2();
+ last_motion = Vector2();
motion = Vector2();
break;
}
@@ -1111,7 +1169,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Avoid to move forward on a wall if floor_block_on_wall is true.
if (p_was_on_floor && !on_floor && !vel_dir_facing_up) {
// If the movement is large the body can be prevented from reaching the walls.
- if (result.travel.length() <= margin) {
+ if (result.travel.length() <= margin + CMP_EPSILON) {
// Cancels the motion.
Transform2D gt = get_global_transform();
gt.elements[2] -= result.travel;
@@ -1122,7 +1180,8 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
platform_layer = prev_platform_layer;
platform_velocity = p_prev_platform_velocity;
floor_normal = prev_floor_normal;
- linear_velocity = Vector2();
+ motion_velocity = Vector2();
+ last_motion = Vector2();
motion = Vector2();
break;
}
@@ -1143,7 +1202,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Regular sliding, the last part of the test handle the case when you don't want to slide on the ceiling.
else if ((sliding_enabled || !on_floor) && (!on_ceiling || slide_on_ceiling || !vel_dir_facing_up)) {
Vector2 slide_motion = result.remainder.slide(result.collision_normal);
- if (slide_motion.dot(linear_velocity) > 0.0) {
+ if (slide_motion.dot(motion_velocity) > 0.0) {
motion = slide_motion;
} else {
motion = Vector2();
@@ -1151,10 +1210,10 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
if (slide_on_ceiling && on_ceiling) {
// Apply slide only in the direction of the input motion, otherwise just stop to avoid jittering when moving against a wall.
if (vel_dir_facing_up) {
- linear_velocity = linear_velocity.slide(result.collision_normal);
+ motion_velocity = motion_velocity.slide(result.collision_normal);
} else {
// Avoid acceleration in slope when falling.
- linear_velocity = up_direction * up_direction.dot(linear_velocity);
+ motion_velocity = up_direction * up_direction.dot(motion_velocity);
}
}
}
@@ -1162,7 +1221,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
else {
motion = result.remainder;
if (on_ceiling && !slide_on_ceiling && vel_dir_facing_up) {
- linear_velocity = linear_velocity.slide(up_direction);
+ motion_velocity = motion_velocity.slide(up_direction);
motion = motion.slide(up_direction);
}
}
@@ -1196,12 +1255,12 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Reset the gravity accumulation when touching the ground.
if (on_floor && !vel_dir_facing_up) {
- linear_velocity = linear_velocity.slide(up_direction);
+ motion_velocity = motion_velocity.slide(up_direction);
}
}
void CharacterBody2D::_move_and_slide_free(double p_delta) {
- Vector2 motion = linear_velocity * p_delta;
+ Vector2 motion = motion_velocity * p_delta;
platform_rid = RID();
floor_normal = Vector2();
@@ -1212,12 +1271,18 @@ void CharacterBody2D::_move_and_slide_free(double p_delta) {
PhysicsServer2D::MotionResult result;
bool collided = move_and_collide(motion, result, margin, false, false);
+ last_motion = result.travel;
if (collided) {
motion_results.push_back(result);
_set_collision_direction(result);
- if (free_mode_min_slide_angle != 0 && result.get_angle(-linear_velocity.normalized()) < free_mode_min_slide_angle + FLOOR_ANGLE_THRESHOLD) {
+ if (result.remainder.is_equal_approx(Vector2())) {
+ motion = Vector2();
+ break;
+ }
+
+ if (free_mode_min_slide_angle != 0 && result.get_angle(-motion_velocity.normalized()) < free_mode_min_slide_angle + FLOOR_ANGLE_THRESHOLD) {
motion = Vector2();
} else if (first_slide) {
Vector2 motion_slide_norm = result.remainder.slide(result.collision_normal).normalized();
@@ -1226,27 +1291,30 @@ void CharacterBody2D::_move_and_slide_free(double p_delta) {
motion = result.remainder.slide(result.collision_normal);
}
- if (motion.dot(linear_velocity) <= 0.0) {
+ if (motion.dot(motion_velocity) <= 0.0) {
motion = Vector2();
}
}
- first_slide = false;
-
if (!collided || motion.is_equal_approx(Vector2())) {
break;
}
+
+ first_slide = false;
}
}
void CharacterBody2D::_snap_on_floor(bool was_on_floor, bool vel_dir_facing_up) {
- if (Math::is_equal_approx(floor_snap_length, 0) || on_floor || !was_on_floor || vel_dir_facing_up) {
+ if (on_floor || !was_on_floor || vel_dir_facing_up) {
return;
}
+ // Snap by at least collision margin to keep floor state consistent.
+ real_t length = MAX(floor_snap_length, margin);
+
Transform2D gt = get_global_transform();
PhysicsServer2D::MotionResult result;
- if (move_and_collide(up_direction * -floor_snap_length, result, margin, true, false, true)) {
+ if (move_and_collide(-up_direction * length, result, margin, true, false, true)) {
bool apply = true;
if (result.get_angle(up_direction) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) {
on_floor = true;
@@ -1274,12 +1342,15 @@ void CharacterBody2D::_snap_on_floor(bool was_on_floor, bool vel_dir_facing_up)
}
bool CharacterBody2D::_on_floor_if_snapped(bool was_on_floor, bool vel_dir_facing_up) {
- if (Math::is_equal_approx(floor_snap_length, 0) || up_direction == Vector2() || on_floor || !was_on_floor || vel_dir_facing_up) {
+ if (up_direction == Vector2() || on_floor || !was_on_floor || vel_dir_facing_up) {
return false;
}
+ // Snap by at least collision margin to keep floor state consistent.
+ real_t length = MAX(floor_snap_length, margin);
+
PhysicsServer2D::MotionResult result;
- if (move_and_collide(up_direction * -floor_snap_length, result, margin, true, false, true)) {
+ if (move_and_collide(-up_direction * length, result, margin, true, false, true)) {
if (result.get_angle(up_direction) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) {
return true;
}
@@ -1297,6 +1368,7 @@ void CharacterBody2D::_set_collision_direction(const PhysicsServer2D::MotionResu
on_ceiling = true;
} else {
on_wall = true;
+ wall_normal = p_result.collision_normal;
// Don't apply wall velocity when the collider is a CharacterBody2D.
if (Object::cast_to<CharacterBody2D>(ObjectDB::get_instance(p_result.collider_id)) == nullptr) {
_set_platform_data(p_result);
@@ -1310,12 +1382,12 @@ void CharacterBody2D::_set_platform_data(const PhysicsServer2D::MotionResult &p_
platform_layer = PhysicsServer2D::get_singleton()->body_get_collision_layer(platform_rid);
}
-const Vector2 &CharacterBody2D::get_linear_velocity() const {
- return linear_velocity;
+const Vector2 &CharacterBody2D::get_motion_velocity() const {
+ return motion_velocity;
}
-void CharacterBody2D::set_linear_velocity(const Vector2 &p_velocity) {
- linear_velocity = p_velocity;
+void CharacterBody2D::set_motion_velocity(const Vector2 &p_velocity) {
+ motion_velocity = p_velocity;
}
bool CharacterBody2D::is_on_floor() const {
@@ -1342,16 +1414,32 @@ bool CharacterBody2D::is_on_ceiling_only() const {
return on_ceiling && !on_floor && !on_wall;
}
-Vector2 CharacterBody2D::get_floor_normal() const {
+const Vector2 &CharacterBody2D::get_floor_normal() const {
return floor_normal;
}
+const Vector2 &CharacterBody2D::get_wall_normal() const {
+ return wall_normal;
+}
+
+const Vector2 &CharacterBody2D::get_last_motion() const {
+ return last_motion;
+}
+
+Vector2 CharacterBody2D::get_position_delta() const {
+ return get_global_transform().elements[2] - previous_position;
+}
+
+const Vector2 &CharacterBody2D::get_real_velocity() const {
+ return real_velocity;
+}
+
real_t CharacterBody2D::get_floor_angle(const Vector2 &p_up_direction) const {
ERR_FAIL_COND_V(p_up_direction == Vector2(), 0);
return Math::acos(floor_normal.dot(p_up_direction));
}
-Vector2 CharacterBody2D::get_platform_velocity() const {
+const Vector2 &CharacterBody2D::get_platform_velocity() const {
return platform_velocity;
}
@@ -1451,6 +1539,14 @@ CharacterBody2D::MotionMode CharacterBody2D::get_motion_mode() const {
return motion_mode;
}
+void CharacterBody2D::set_moving_platform_apply_velocity_on_leave(MovingPlatformApplyVelocityOnLeave p_on_leave_apply_velocity) {
+ moving_platform_apply_velocity_on_leave = p_on_leave_apply_velocity;
+}
+
+CharacterBody2D::MovingPlatformApplyVelocityOnLeave CharacterBody2D::get_moving_platform_apply_velocity_on_leave() const {
+ return moving_platform_apply_velocity_on_leave;
+}
+
int CharacterBody2D::get_max_slides() const {
return max_slides;
}
@@ -1511,8 +1607,8 @@ void CharacterBody2D::_notification(int p_what) {
void CharacterBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_slide"), &CharacterBody2D::move_and_slide);
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &CharacterBody2D::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &CharacterBody2D::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_motion_velocity", "motion_velocity"), &CharacterBody2D::set_motion_velocity);
+ ClassDB::bind_method(D_METHOD("get_motion_velocity"), &CharacterBody2D::get_motion_velocity);
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &CharacterBody2D::set_safe_margin);
ClassDB::bind_method(D_METHOD("get_safe_margin"), &CharacterBody2D::get_safe_margin);
@@ -1542,6 +1638,8 @@ void CharacterBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_up_direction", "up_direction"), &CharacterBody2D::set_up_direction);
ClassDB::bind_method(D_METHOD("set_motion_mode", "mode"), &CharacterBody2D::set_motion_mode);
ClassDB::bind_method(D_METHOD("get_motion_mode"), &CharacterBody2D::get_motion_mode);
+ ClassDB::bind_method(D_METHOD("set_moving_platform_apply_velocity_on_leave", "on_leave_apply_velocity"), &CharacterBody2D::set_moving_platform_apply_velocity_on_leave);
+ ClassDB::bind_method(D_METHOD("get_moving_platform_apply_velocity_on_leave"), &CharacterBody2D::get_moving_platform_apply_velocity_on_leave);
ClassDB::bind_method(D_METHOD("is_on_floor"), &CharacterBody2D::is_on_floor);
ClassDB::bind_method(D_METHOD("is_on_floor_only"), &CharacterBody2D::is_on_floor_only);
@@ -1550,6 +1648,10 @@ void CharacterBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_on_wall"), &CharacterBody2D::is_on_wall);
ClassDB::bind_method(D_METHOD("is_on_wall_only"), &CharacterBody2D::is_on_wall_only);
ClassDB::bind_method(D_METHOD("get_floor_normal"), &CharacterBody2D::get_floor_normal);
+ ClassDB::bind_method(D_METHOD("get_wall_normal"), &CharacterBody2D::get_wall_normal);
+ ClassDB::bind_method(D_METHOD("get_last_motion"), &CharacterBody2D::get_last_motion);
+ ClassDB::bind_method(D_METHOD("get_position_delta"), &CharacterBody2D::get_position_delta);
+ ClassDB::bind_method(D_METHOD("get_real_velocity"), &CharacterBody2D::get_real_velocity);
ClassDB::bind_method(D_METHOD("get_floor_angle", "up_direction"), &CharacterBody2D::get_floor_angle, DEFVAL(Vector2(0.0, -1.0)));
ClassDB::bind_method(D_METHOD("get_platform_velocity"), &CharacterBody2D::get_platform_velocity);
ClassDB::bind_method(D_METHOD("get_slide_collision_count"), &CharacterBody2D::get_slide_collision_count);
@@ -1557,10 +1659,11 @@ void CharacterBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_last_slide_collision"), &CharacterBody2D::_get_last_slide_collision);
ADD_PROPERTY(PropertyInfo(Variant::INT, "motion_mode", PROPERTY_HINT_ENUM, "Grounded,Free", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_motion_mode", "get_motion_mode");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "up_direction"), "set_up_direction", "get_up_direction");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_motion_velocity", "get_motion_velocity");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_ceiling"), "set_slide_on_ceiling_enabled", "is_slide_on_ceiling_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_slides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_max_slides", "get_max_slides");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "up_direction"), "set_up_direction", "get_up_direction");
+
ADD_GROUP("Free Mode", "free_mode_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "free_mode_min_slide_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians", PROPERTY_USAGE_DEFAULT), "set_free_mode_min_slide_angle", "get_free_mode_min_slide_angle");
ADD_GROUP("Floor", "floor_");
@@ -1568,14 +1671,19 @@ void CharacterBody2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_constant_speed"), "set_floor_constant_speed_enabled", "is_floor_constant_speed_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "floor_block_on_wall"), "set_floor_block_on_wall_enabled", "is_floor_block_on_wall_enabled");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_max_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians"), "set_floor_max_angle", "get_floor_max_angle");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_snap_length", PROPERTY_HINT_RANGE, "0,1000,0.1"), "set_floor_snap_length", "get_floor_snap_length");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "floor_snap_length", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_floor_snap_length", "get_floor_snap_length");
ADD_GROUP("Moving platform", "moving_platform");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "moving_platform_apply_velocity_on_leave", PROPERTY_HINT_ENUM, "Always,Upward Only,Never", PROPERTY_USAGE_DEFAULT), "set_moving_platform_apply_velocity_on_leave", "get_moving_platform_apply_velocity_on_leave");
ADD_PROPERTY(PropertyInfo(Variant::INT, "moving_platform_floor_layers", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_moving_platform_floor_layers", "get_moving_platform_floor_layers");
ADD_PROPERTY(PropertyInfo(Variant::INT, "moving_platform_wall_layers", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_moving_platform_wall_layers", "get_moving_platform_wall_layers");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
BIND_ENUM_CONSTANT(MOTION_MODE_GROUNDED);
BIND_ENUM_CONSTANT(MOTION_MODE_FREE);
+
+ BIND_ENUM_CONSTANT(PLATFORM_VEL_ON_LEAVE_ALWAYS);
+ BIND_ENUM_CONSTANT(PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY);
+ BIND_ENUM_CONSTANT(PLATFORM_VEL_ON_LEAVE_NEVER);
}
void CharacterBody2D::_validate_property(PropertyInfo &property) const {
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 5d0d98a2df..92b7fd1648 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -92,7 +92,7 @@ class AnimatableBody2D : public StaticBody2D {
GDCLASS(AnimatableBody2D, StaticBody2D);
private:
- bool sync_to_physics = false;
+ bool sync_to_physics = true;
Transform2D last_valid_transform;
@@ -117,11 +117,9 @@ class RigidDynamicBody2D : public PhysicsBody2D {
GDCLASS(RigidDynamicBody2D, PhysicsBody2D);
public:
- enum Mode {
- MODE_DYNAMIC,
- MODE_STATIC,
- MODE_DYNAMIC_LOCKED,
- MODE_KINEMATIC,
+ enum FreezeMode {
+ FREEZE_MODE_STATIC,
+ FREEZE_MODE_KINEMATIC,
};
enum CenterOfMassMode {
@@ -137,7 +135,9 @@ public:
private:
bool can_sleep = true;
- Mode mode = MODE_DYNAMIC;
+ bool lock_rotation = false;
+ bool freeze = false;
+ FreezeMode freeze_mode = FREEZE_MODE_STATIC;
real_t mass = 1.0;
real_t inertia = 0.0;
@@ -211,9 +211,17 @@ protected:
GDVIRTUAL1(_integrate_forces, PhysicsDirectBodyState2D *)
+ void _apply_body_mode();
+
public:
- void set_mode(Mode p_mode);
- Mode get_mode() const;
+ void set_lock_rotation_enabled(bool p_lock_rotation);
+ bool is_lock_rotation_enabled() const;
+
+ void set_freeze_enabled(bool p_freeze);
+ bool is_freeze_enabled() const;
+
+ void set_freeze_mode(FreezeMode p_freeze_mode);
+ FreezeMode get_freeze_mode() const;
void set_mass(real_t p_mass);
real_t get_mass() const;
@@ -290,7 +298,7 @@ private:
void _reload_physics_characteristics();
};
-VARIANT_ENUM_CAST(RigidDynamicBody2D::Mode);
+VARIANT_ENUM_CAST(RigidDynamicBody2D::FreezeMode);
VARIANT_ENUM_CAST(RigidDynamicBody2D::CenterOfMassMode);
VARIANT_ENUM_CAST(RigidDynamicBody2D::CCDMode);
@@ -302,10 +310,15 @@ public:
MOTION_MODE_GROUNDED,
MOTION_MODE_FREE,
};
+ enum MovingPlatformApplyVelocityOnLeave {
+ PLATFORM_VEL_ON_LEAVE_ALWAYS,
+ PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY,
+ PLATFORM_VEL_ON_LEAVE_NEVER,
+ };
bool move_and_slide();
- const Vector2 &get_linear_velocity() const;
- void set_linear_velocity(const Vector2 &p_velocity);
+ const Vector2 &get_motion_velocity() const;
+ void set_motion_velocity(const Vector2 &p_velocity);
bool is_on_floor() const;
bool is_on_floor_only() const;
@@ -313,9 +326,14 @@ public:
bool is_on_wall_only() const;
bool is_on_ceiling() const;
bool is_on_ceiling_only() const;
- Vector2 get_floor_normal() const;
+ const Vector2 &get_last_motion() const;
+ Vector2 get_position_delta() const;
+ const Vector2 &get_floor_normal() const;
+ const Vector2 &get_wall_normal() const;
+ const Vector2 &get_real_velocity() const;
+
real_t get_floor_angle(const Vector2 &p_up_direction = Vector2(0.0, -1.0)) const;
- Vector2 get_platform_velocity() const;
+ const Vector2 &get_platform_velocity() const;
int get_slide_collision_count() const;
PhysicsServer2D::MotionResult get_slide_collision(int p_bounce) const;
@@ -326,23 +344,29 @@ public:
private:
real_t margin = 0.08;
MotionMode motion_mode = MOTION_MODE_GROUNDED;
+ MovingPlatformApplyVelocityOnLeave moving_platform_apply_velocity_on_leave = PLATFORM_VEL_ON_LEAVE_ALWAYS;
- bool floor_stop_on_slope = false;
bool floor_constant_speed = false;
+ bool floor_stop_on_slope = true;
bool floor_block_on_wall = true;
bool slide_on_ceiling = true;
int max_slides = 4;
- int platform_layer;
+ int platform_layer = 0;
real_t floor_max_angle = Math::deg2rad((real_t)45.0);
- real_t floor_snap_length = 0;
+ real_t floor_snap_length = 1;
real_t free_mode_min_slide_angle = Math::deg2rad((real_t)15.0);
Vector2 up_direction = Vector2(0.0, -1.0);
uint32_t moving_platform_floor_layers = UINT32_MAX;
uint32_t moving_platform_wall_layers = 0;
- Vector2 linear_velocity;
+ Vector2 motion_velocity;
Vector2 floor_normal;
Vector2 platform_velocity;
+ Vector2 wall_normal;
+ Vector2 last_motion;
+ Vector2 previous_position;
+ Vector2 real_velocity;
+
RID platform_rid;
bool on_floor = false;
bool on_ceiling = false;
@@ -387,6 +411,9 @@ private:
void set_motion_mode(MotionMode p_mode);
MotionMode get_motion_mode() const;
+ void set_moving_platform_apply_velocity_on_leave(MovingPlatformApplyVelocityOnLeave p_on_leave_velocity);
+ MovingPlatformApplyVelocityOnLeave get_moving_platform_apply_velocity_on_leave() const;
+
void _move_and_slide_free(double p_delta);
void _move_and_slide_grounded(double p_delta, bool p_was_on_floor, const Vector2 &p_prev_platform_velocity);
@@ -406,6 +433,7 @@ protected:
};
VARIANT_ENUM_CAST(CharacterBody2D::MotionMode);
+VARIANT_ENUM_CAST(CharacterBody2D::MovingPlatformApplyVelocityOnLeave);
class KinematicCollision2D : public RefCounted {
GDCLASS(KinematicCollision2D, RefCounted);
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp
index 4bbbc3575d..63a0fb9b89 100644
--- a/scene/2d/skeleton_2d.cpp
+++ b/scene/2d/skeleton_2d.cpp
@@ -456,7 +456,7 @@ void Bone2D::calculate_length_and_rotation() {
if (child) {
Vector2 child_local_pos = to_local(child->get_global_position());
length = child_local_pos.length();
- bone_angle = Math::atan2(child_local_pos.normalized().y, child_local_pos.normalized().x);
+ bone_angle = child_local_pos.normalized().angle();
calculated = true;
break;
}
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 03db9c0d32..78d018ac53 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -452,6 +452,19 @@ int TileMap::get_layer_z_index(int p_layer) const {
return layers[p_layer].z_index;
}
+void TileMap::set_collision_animatable(bool p_enabled) {
+ collision_animatable = p_enabled;
+ _clear_internals();
+ set_notify_local_transform(p_enabled);
+ set_physics_process_internal(p_enabled);
+ _recreate_internals();
+ emit_signal(SNAME("changed"));
+}
+
+bool TileMap::is_collision_animatable() const {
+ return collision_animatable;
+}
+
void TileMap::set_collision_visibility_mode(TileMap::VisibilityMode p_show_collision) {
collision_visibility_mode = p_show_collision;
_clear_internals();
@@ -508,7 +521,6 @@ Map<Vector2i, TileMapQuadrant>::Element *TileMap::_create_quadrant(int p_layer,
// Call the create_quadrant method on plugins
if (tile_set.is_valid()) {
_rendering_create_quadrant(&q);
- _physics_create_quadrant(&q);
}
return layers[p_layer].quadrant_map.insert(p_qk, q);
@@ -1092,24 +1104,67 @@ void TileMap::draw_tile(RID p_canvas_item, Vector2i p_position, const Ref<TileSe
void TileMap::_physics_notification(int p_what) {
switch (p_what) {
+ case CanvasItem::NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
+ bool in_editor = false;
+#ifdef TOOLS_ENABLED
+ in_editor = Engine::get_singleton()->is_editor_hint();
+#endif
+ if (is_inside_tree() && collision_animatable && !in_editor) {
+ // Update tranform on the physics tick when in animatable mode.
+ last_valid_transform = new_transform;
+ set_notify_local_transform(false);
+ set_global_transform(new_transform);
+ set_notify_local_transform(true);
+ }
+ } break;
case CanvasItem::NOTIFICATION_TRANSFORM_CHANGED: {
- // Update the bodies transforms.
- if (is_inside_tree()) {
+ bool in_editor = false;
+#ifdef TOOLS_ENABLED
+ in_editor = Engine::get_singleton()->is_editor_hint();
+#endif
+ if (is_inside_tree() && (!collision_animatable || in_editor)) {
+ // Update the new transform directly if we are not in animatable mode.
+ Transform2D global_transform = get_global_transform();
for (int layer = 0; layer < (int)layers.size(); layer++) {
- Transform2D global_transform = get_global_transform();
+ for (Map<Vector2i, TileMapQuadrant>::Element *E = layers[layer].quadrant_map.front(); E; E = E->next()) {
+ TileMapQuadrant &q = E->get();
+ for (RID body : q.bodies) {
+ Transform2D xform;
+ xform.set_origin(map_to_world(bodies_coords[body]));
+ xform = global_transform * xform;
+ PhysicsServer2D::get_singleton()->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
+ }
+ }
+ }
+ }
+ } break;
+ case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
+ bool in_editor = false;
+#ifdef TOOLS_ENABLED
+ in_editor = Engine::get_singleton()->is_editor_hint();
+#endif
+ if (is_inside_tree() && !in_editor && collision_animatable) {
+ // Only active when animatable. Send the new transform to the physics...
+ new_transform = get_global_transform();
+ for (int layer = 0; layer < (int)layers.size(); layer++) {
for (Map<Vector2i, TileMapQuadrant>::Element *E = layers[layer].quadrant_map.front(); E; E = E->next()) {
TileMapQuadrant &q = E->get();
- Transform2D xform;
- xform.set_origin(map_to_world(E->key() * get_effective_quadrant_size(layer)));
- xform = global_transform * xform;
+ for (RID body : q.bodies) {
+ Transform2D xform;
+ xform.set_origin(map_to_world(bodies_coords[body]));
+ xform = new_transform * xform;
- for (int body_index = 0; body_index < q.bodies.size(); body_index++) {
- PhysicsServer2D::get_singleton()->body_set_state(q.bodies[body_index], PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
+ PhysicsServer2D::get_singleton()->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
}
}
}
+
+ // ... but then revert changes.
+ set_notify_local_transform(false);
+ set_global_transform(last_valid_transform);
+ set_notify_local_transform(true);
}
} break;
}
@@ -1120,29 +1175,23 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
ERR_FAIL_COND(!tile_set.is_valid());
Transform2D global_transform = get_global_transform();
+ last_valid_transform = global_transform;
+ new_transform = global_transform;
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
+ RID space = get_world_2d()->get_space();
SelfList<TileMapQuadrant> *q_list_element = r_dirty_quadrant_list.first();
while (q_list_element) {
TileMapQuadrant &q = *q_list_element->self();
- Vector2 quadrant_pos = map_to_world(q.coords * get_effective_quadrant_size(q.layer));
-
- LocalVector<int> body_shape_count;
- body_shape_count.resize(q.bodies.size());
-
- // Clear shapes.
- for (int body_index = 0; body_index < q.bodies.size(); body_index++) {
- ps->body_clear_shapes(q.bodies[body_index]);
- body_shape_count[body_index] = 0;
-
- // Position the bodies.
- Transform2D xform;
- xform.set_origin(quadrant_pos);
- xform = global_transform * xform;
- ps->body_set_state(q.bodies[body_index], PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
+ // Clear bodies.
+ for (RID body : q.bodies) {
+ bodies_coords.erase(body);
+ ps->free(body);
}
+ q.bodies.clear();
+ // Recreate bodies and shapes.
for (Set<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) {
TileMapCell c = get_cell(q.layer, E_cell->get(), true);
@@ -1158,26 +1207,53 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
if (atlas_source) {
TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile));
- for (int body_index = 0; body_index < q.bodies.size(); body_index++) {
- int &body_shape_index = body_shape_count[body_index];
+ for (int tile_set_physics_layer = 0; tile_set_physics_layer < tile_set->get_physics_layers_count(); tile_set_physics_layer++) {
+ Ref<PhysicsMaterial> physics_material = tile_set->get_physics_layer_physics_material(tile_set_physics_layer);
+ uint32_t physics_layer = tile_set->get_physics_layer_collision_layer(tile_set_physics_layer);
+ uint32_t physics_mask = tile_set->get_physics_layer_collision_mask(tile_set_physics_layer);
- // Add the shapes again.
- for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(body_index); polygon_index++) {
- bool one_way_collision = tile_data->is_collision_polygon_one_way(body_index, polygon_index);
- float one_way_collision_margin = tile_data->get_collision_polygon_one_way_margin(body_index, polygon_index);
+ // Create the body.
+ RID body = ps->body_create();
+ bodies_coords[body] = E_cell->get();
+ ps->body_set_mode(body, collision_animatable ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC);
+ ps->body_set_space(body, space);
- int shapes_count = tile_data->get_collision_polygon_shapes_count(body_index, polygon_index);
- for (int shape_index = 0; shape_index < shapes_count; shape_index++) {
- Transform2D xform = Transform2D();
- xform.set_origin(map_to_world(E_cell->get()) - quadrant_pos);
+ Transform2D xform;
+ xform.set_origin(map_to_world(E_cell->get()));
+ xform = global_transform * xform;
+ ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
+
+ ps->body_attach_object_instance_id(body, get_instance_id());
+ ps->body_set_collision_layer(body, physics_layer);
+ ps->body_set_collision_mask(body, physics_mask);
+ ps->body_set_pickable(body, false);
+ ps->body_set_state(body, PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, tile_data->get_constant_linear_velocity(tile_set_physics_layer));
+ ps->body_set_state(body, PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, tile_data->get_constant_angular_velocity(tile_set_physics_layer));
+
+ if (!physics_material.is_valid()) {
+ ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
+ ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_FRICTION, 1);
+ } else {
+ ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material->computed_bounce());
+ ps->body_set_param(body, PhysicsServer2D::BODY_PARAM_FRICTION, physics_material->computed_friction());
+ }
+
+ q.bodies.push_back(body);
+ // Add the shapes to the body.
+ int body_shape_index = 0;
+ for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(tile_set_physics_layer); polygon_index++) {
+ // Iterate over the polygons.
+ bool one_way_collision = tile_data->is_collision_polygon_one_way(tile_set_physics_layer, polygon_index);
+ float one_way_collision_margin = tile_data->get_collision_polygon_one_way_margin(tile_set_physics_layer, polygon_index);
+ int shapes_count = tile_data->get_collision_polygon_shapes_count(tile_set_physics_layer, polygon_index);
+ for (int shape_index = 0; shape_index < shapes_count; shape_index++) {
// Add decomposed convex shapes.
- Ref<ConvexPolygonShape2D> shape = tile_data->get_collision_polygon_shape(body_index, polygon_index, shape_index);
- ps->body_add_shape(q.bodies[body_index], shape->get_rid(), xform);
- ps->body_set_shape_metadata(q.bodies[body_index], body_shape_index, E_cell->get());
- ps->body_set_shape_as_one_way_collision(q.bodies[body_index], body_shape_index, one_way_collision, one_way_collision_margin);
+ Ref<ConvexPolygonShape2D> shape = tile_data->get_collision_polygon_shape(tile_set_physics_layer, polygon_index, shape_index);
+ ps->body_add_shape(body, shape->get_rid());
+ ps->body_set_shape_as_one_way_collision(body, body_shape_index, one_way_collision, one_way_collision_margin);
- ++body_shape_index;
+ body_shape_index++;
}
}
}
@@ -1189,54 +1265,11 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r
}
}
-void TileMap::_physics_create_quadrant(TileMapQuadrant *p_quadrant) {
- ERR_FAIL_COND(!tile_set.is_valid());
-
- //Get the TileMap's gobla transform.
- Transform2D global_transform;
- if (is_inside_tree()) {
- global_transform = get_global_transform();
- }
-
- // Clear all bodies.
- p_quadrant->bodies.clear();
-
- // Create the body and set its parameters.
- for (int layer = 0; layer < tile_set->get_physics_layers_count(); layer++) {
- RID body = PhysicsServer2D::get_singleton()->body_create();
- PhysicsServer2D::get_singleton()->body_set_mode(body, PhysicsServer2D::BODY_MODE_STATIC);
-
- PhysicsServer2D::get_singleton()->body_attach_object_instance_id(body, get_instance_id());
- PhysicsServer2D::get_singleton()->body_set_collision_layer(body, tile_set->get_physics_layer_collision_layer(layer));
- PhysicsServer2D::get_singleton()->body_set_collision_mask(body, tile_set->get_physics_layer_collision_mask(layer));
-
- Ref<PhysicsMaterial> physics_material = tile_set->get_physics_layer_physics_material(layer);
- if (!physics_material.is_valid()) {
- PhysicsServer2D::get_singleton()->body_set_param(body, PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
- PhysicsServer2D::get_singleton()->body_set_param(body, PhysicsServer2D::BODY_PARAM_FRICTION, 1);
- } else {
- PhysicsServer2D::get_singleton()->body_set_param(body, PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material->computed_bounce());
- PhysicsServer2D::get_singleton()->body_set_param(body, PhysicsServer2D::BODY_PARAM_FRICTION, physics_material->computed_friction());
- }
-
- if (is_inside_tree()) {
- RID space = get_world_2d()->get_space();
- PhysicsServer2D::get_singleton()->body_set_space(body, space);
-
- Transform2D xform;
- xform.set_origin(map_to_world(p_quadrant->coords * get_effective_quadrant_size(p_quadrant->layer)));
- xform = global_transform * xform;
- PhysicsServer2D::get_singleton()->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform);
- }
-
- p_quadrant->bodies.push_back(body);
- }
-}
-
void TileMap::_physics_cleanup_quadrant(TileMapQuadrant *p_quadrant) {
// Remove a quadrant.
- for (int body_index = 0; body_index < p_quadrant->bodies.size(); body_index++) {
- PhysicsServer2D::get_singleton()->free(p_quadrant->bodies[body_index]);
+ for (RID body : p_quadrant->bodies) {
+ bodies_coords.erase(body);
+ PhysicsServer2D::get_singleton()->free(body);
}
p_quadrant->bodies.clear();
}
@@ -1252,7 +1285,7 @@ void TileMap::_physics_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
bool show_collision = false;
switch (collision_visibility_mode) {
case TileMap::VISIBILITY_MODE_DEFAULT:
- show_collision = !Engine::get_singleton()->is_editor_hint() && (get_tree() && get_tree()->is_debugging_navigation_hint());
+ show_collision = !Engine::get_singleton()->is_editor_hint() && (get_tree() && get_tree()->is_debugging_collisions_hint());
break;
case TileMap::VISIBILITY_MODE_FORCE_HIDE:
show_collision = false;
@@ -1266,39 +1299,28 @@ void TileMap::_physics_draw_quadrant_debug(TileMapQuadrant *p_quadrant) {
}
RenderingServer *rs = RenderingServer::get_singleton();
-
- Vector2 quadrant_pos = map_to_world(p_quadrant->coords * get_effective_quadrant_size(p_quadrant->layer));
+ PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
Color debug_collision_color = get_tree()->get_debug_collisions_color();
- for (Set<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) {
- TileMapCell c = get_cell(p_quadrant->layer, E_cell->get(), true);
-
- Transform2D xform;
- xform.set_origin(map_to_world(E_cell->get()) - quadrant_pos);
- rs->canvas_item_add_set_transform(p_quadrant->debug_canvas_item, xform);
-
- if (tile_set->has_source(c.source_id)) {
- TileSetSource *source = *tile_set->get_source(c.source_id);
-
- if (!source->has_tile(c.get_atlas_coords()) || !source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
- continue;
- }
+ Vector<Color> color;
+ color.push_back(debug_collision_color);
- TileSetAtlasSource *atlas_source = Object::cast_to<TileSetAtlasSource>(source);
- if (atlas_source) {
- TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile));
+ Vector2 quadrant_pos = map_to_world(p_quadrant->coords * get_effective_quadrant_size(p_quadrant->layer));
+ Transform2D qudrant_xform;
+ qudrant_xform.set_origin(quadrant_pos);
+ Transform2D global_transform_inv = (get_global_transform() * qudrant_xform).affine_inverse();
- for (int body_index = 0; body_index < p_quadrant->bodies.size(); body_index++) {
- for (int polygon_index = 0; polygon_index < tile_data->get_collision_polygons_count(body_index); polygon_index++) {
- // Draw the debug polygon.
- Vector<Vector2> polygon = tile_data->get_collision_polygon_points(body_index, polygon_index);
- if (polygon.size() >= 3) {
- Vector<Color> color;
- color.push_back(debug_collision_color);
- rs->canvas_item_add_polygon(p_quadrant->debug_canvas_item, polygon, color);
- }
- }
- }
+ for (RID body : p_quadrant->bodies) {
+ Transform2D xform = Transform2D(ps->body_get_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM)) * global_transform_inv;
+ rs->canvas_item_add_set_transform(p_quadrant->debug_canvas_item, xform);
+ for (int shape_index = 0; shape_index < ps->body_get_shape_count(body); shape_index++) {
+ const RID &shape = ps->body_get_shape(body, shape_index);
+ PhysicsServer2D::ShapeType type = ps->shape_get_type(shape);
+ if (type == PhysicsServer2D::SHAPE_CONVEX_POLYGON) {
+ Vector<Vector2> polygon = ps->shape_get_data(shape);
+ rs->canvas_item_add_polygon(p_quadrant->debug_canvas_item, polygon, color);
+ } else {
+ WARN_PRINT("Wrong shape type for a tile, should be SHAPE_CONVEX_POLYGON.");
}
}
rs->canvas_item_add_set_transform(p_quadrant->debug_canvas_item, Transform2D());
@@ -1858,6 +1880,11 @@ Map<Vector2i, TileMapQuadrant> *TileMap::get_quadrant_map(int p_layer) {
return &layers[p_layer].quadrant_map;
}
+Vector2i TileMap::get_coords_for_body_rid(RID p_physics_body) {
+ ERR_FAIL_COND_V_MSG(!bodies_coords.has(p_physics_body), Vector2i(), vformat("No tiles for the given body RID %d.", p_physics_body));
+ return bodies_coords[p_physics_body];
+}
+
void TileMap::fix_invalid_tiles() {
ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot fix invalid tiles if Tileset is not open.");
@@ -2034,10 +2061,22 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
return false;
} else if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_int()) {
int index = components[0].trim_prefix("layer_").to_int();
- if (index < 0 || index >= (int)layers.size()) {
+ if (index < 0) {
return false;
}
+ if (index >= (int)layers.size()) {
+ _clear_internals();
+ while (index >= (int)layers.size()) {
+ layers.push_back(TileMapLayer());
+ }
+ _recreate_internals();
+
+ notify_property_list_changed();
+ emit_signal(SNAME("changed"));
+ update_configuration_warnings();
+ }
+
if (components[1] == "name") {
set_layer_name(index, p_value);
return true;
@@ -2995,6 +3034,8 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &TileMap::set_layer_z_index);
ClassDB::bind_method(D_METHOD("get_layer_z_index", "layer"), &TileMap::get_layer_z_index);
+ ClassDB::bind_method(D_METHOD("set_collision_animatable", "enabled"), &TileMap::set_collision_animatable);
+ ClassDB::bind_method(D_METHOD("is_collision_animatable"), &TileMap::is_collision_animatable);
ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &TileMap::set_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMap::get_collision_visibility_mode);
@@ -3006,10 +3047,14 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "layer", "coords", "use_proxies"), &TileMap::get_cell_atlas_coords);
ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "layer", "coords", "use_proxies"), &TileMap::get_cell_alternative_tile);
+ ClassDB::bind_method(D_METHOD("get_coords_for_body_rid", "body"), &TileMap::get_coords_for_body_rid);
+
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles);
- ClassDB::bind_method(D_METHOD("get_surrounding_tiles", "coords"), &TileMap::get_surrounding_tiles);
+ ClassDB::bind_method(D_METHOD("clear_layer", "layer"), &TileMap::clear_layer);
ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear);
+ ClassDB::bind_method(D_METHOD("get_surrounding_tiles", "coords"), &TileMap::get_surrounding_tiles);
+
ClassDB::bind_method(D_METHOD("get_used_cells", "layer"), &TileMap::get_used_cells);
ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect);
@@ -3025,6 +3070,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_set", PROPERTY_HINT_RESOURCE_TYPE, "TileSet"), "set_tileset", "get_tileset");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_quadrant_size", PROPERTY_HINT_RANGE, "1,128,1"), "set_quadrant_size", "get_quadrant_size");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_animatable"), "set_collision_animatable", "is_collision_animatable");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_visibility_mode", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_collision_visibility_mode", "get_collision_visibility_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_visibility_mode", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_navigation_visibility_mode", "get_navigation_visibility_mode");
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index ca38baa550..2faede2445 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -202,6 +202,7 @@ private:
// Properties.
Ref<TileSet> tile_set;
int quadrant_size = 16;
+ bool collision_animatable = false;
VisibilityMode collision_visibility_mode = VISIBILITY_MODE_DEFAULT;
VisibilityMode navigation_visibility_mode = VISIBILITY_MODE_DEFAULT;
@@ -229,6 +230,9 @@ private:
LocalVector<TileMapLayer> layers;
int selected_layer = -1;
+ // Mapping for RID to coords.
+ Map<RID, Vector2i> bodies_coords;
+
// Quadrants and internals management.
Vector2i _coords_to_quadrant_coords(int p_layer, const Vector2i &p_coords) const;
@@ -259,9 +263,10 @@ private:
void _rendering_cleanup_quadrant(TileMapQuadrant *p_quadrant);
void _rendering_draw_quadrant_debug(TileMapQuadrant *p_quadrant);
+ Transform2D last_valid_transform;
+ Transform2D new_transform;
void _physics_notification(int p_what);
void _physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r_dirty_quadrant_list);
- void _physics_create_quadrant(TileMapQuadrant *p_quadrant);
void _physics_cleanup_quadrant(TileMapQuadrant *p_quadrant);
void _physics_draw_quadrant_debug(TileMapQuadrant *p_quadrant);
@@ -325,6 +330,9 @@ public:
void set_selected_layer(int p_layer_id); // For editor use.
int get_selected_layer() const;
+ void set_collision_animatable(bool p_enabled);
+ bool is_collision_animatable() const;
+
void set_collision_visibility_mode(VisibilityMode p_show_collision);
VisibilityMode get_collision_visibility_mode();
@@ -364,6 +372,9 @@ public:
virtual void set_texture_filter(CanvasItem::TextureFilter p_texture_filter) override;
virtual void set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) override;
+ // For finding tiles from collision.
+ Vector2i get_coords_for_body_rid(RID p_physics_body);
+
// Fixing a nclearing methods.
void fix_invalid_tiles();
diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp
index c34c150145..afd11482e3 100644
--- a/scene/3d/bone_attachment_3d.cpp
+++ b/scene/3d/bone_attachment_3d.cpp
@@ -110,7 +110,7 @@ TypedArray<String> BoneAttachment3D::get_configuration_warnings() const {
} else {
Skeleton3D *parent = Object::cast_to<Skeleton3D>(get_parent());
if (!parent) {
- warnings.append(TTR("Parent node is not a Skeleton3D node! Please use an extenral Skeleton3D if you intend to use the BoneAttachment3D without it being a child of a Skeleton3D node."));
+ warnings.append(TTR("Parent node is not a Skeleton3D node! Please use an external Skeleton3D if you intend to use the BoneAttachment3D without it being a child of a Skeleton3D node."));
}
}
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index c79f956642..4e496fba47 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -124,8 +124,7 @@ TypedArray<String> CollisionShape3D::get_configuration_warnings() const {
if (shape.is_valid() &&
Object::cast_to<RigidDynamicBody3D>(get_parent()) &&
- Object::cast_to<ConcavePolygonShape3D>(*shape) &&
- Object::cast_to<RigidDynamicBody3D>(get_parent())->get_mode() != RigidDynamicBody3D::MODE_STATIC) {
+ Object::cast_to<ConcavePolygonShape3D>(*shape)) {
warnings.push_back(TTR("ConcavePolygonShape3D doesn't support RigidDynamicBody3D in another mode than static."));
}
diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp
index baf28ae102..32a62d8c7e 100644
--- a/scene/3d/gpu_particles_3d.cpp
+++ b/scene/3d/gpu_particles_3d.cpp
@@ -469,7 +469,7 @@ void GPUParticles3D::_skinning_changed() {
if (draw_pass.is_valid() && draw_pass->get_builtin_bind_pose_count() > 0) {
xforms.resize(draw_pass->get_builtin_bind_pose_count());
for (int j = 0; j < draw_pass->get_builtin_bind_pose_count(); j++) {
- xforms.write[i] = draw_pass->get_builtin_bind_pose(j);
+ xforms.write[j] = draw_pass->get_builtin_bind_pose(j);
}
break;
}
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 48da186860..9e2358ed39 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -38,8 +38,8 @@
#endif
void PhysicsBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "test_only", "safe_margin", "max_collisions"), &PhysicsBody3D::_move, DEFVAL(false), DEFVAL(0.001), DEFVAL(1));
- ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "collision", "safe_margin", "max_collisions"), &PhysicsBody3D::test_move, DEFVAL(Variant()), DEFVAL(0.001), DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("move_and_collide", "linear_velocity", "test_only", "safe_margin", "max_collisions"), &PhysicsBody3D::_move, DEFVAL(false), DEFVAL(0.001), DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("test_move", "from", "linear_velocity", "collision", "safe_margin", "max_collisions"), &PhysicsBody3D::test_move, DEFVAL(Variant()), DEFVAL(0.001), DEFVAL(1));
ClassDB::bind_method(D_METHOD("set_axis_lock", "axis", "lock"), &PhysicsBody3D::set_axis_lock);
ClassDB::bind_method(D_METHOD("get_axis_lock", "axis"), &PhysicsBody3D::get_axis_lock);
@@ -97,7 +97,10 @@ void PhysicsBody3D::remove_collision_exception_with(Node *p_node) {
Ref<KinematicCollision3D> PhysicsBody3D::_move(const Vector3 &p_motion, bool p_test_only, real_t p_margin, int p_max_collisions) {
PhysicsServer3D::MotionResult result;
- if (move_and_collide(p_motion, result, p_margin, p_test_only, p_max_collisions)) {
+ // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky
+ double delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time();
+
+ if (move_and_collide(p_motion * delta, result, p_margin, p_test_only, p_max_collisions)) {
// Create a new instance when the cached reference is invalid or still in use in script.
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
motion_cache.instantiate();
@@ -177,7 +180,10 @@ bool PhysicsBody3D::test_move(const Transform3D &p_from, const Vector3 &p_motion
r = const_cast<PhysicsServer3D::MotionResult *>(&r_collision->result);
}
- return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_margin, r, p_max_collisions);
+ // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky
+ double delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time();
+
+ return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion * delta, p_margin, r, p_max_collisions);
}
void PhysicsBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) {
@@ -334,6 +340,12 @@ void AnimatableBody3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
last_valid_transform = get_global_transform();
+ _update_kinematic_motion();
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ set_only_update_transform_changes(false);
+ set_notify_local_transform(false);
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
@@ -361,8 +373,6 @@ void AnimatableBody3D::_bind_methods() {
AnimatableBody3D::AnimatableBody3D() :
StaticBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) {
PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback);
-
- _update_kinematic_motion();
}
void RigidDynamicBody3D::_body_enter_tree(ObjectID p_id) {
@@ -599,27 +609,60 @@ void RigidDynamicBody3D::_notification(int p_what) {
#endif
}
-void RigidDynamicBody3D::set_mode(Mode p_mode) {
- mode = p_mode;
- switch (p_mode) {
- case MODE_DYNAMIC: {
- set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC);
- } break;
- case MODE_STATIC: {
- set_body_mode(PhysicsServer3D::BODY_MODE_STATIC);
- } break;
- case MODE_DYNAMIC_LOCKED: {
- set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC_LOCKED);
- } break;
- case MODE_KINEMATIC: {
- set_body_mode(PhysicsServer3D::BODY_MODE_KINEMATIC);
- } break;
+void RigidDynamicBody3D::_apply_body_mode() {
+ if (freeze) {
+ switch (freeze_mode) {
+ case FREEZE_MODE_STATIC: {
+ set_body_mode(PhysicsServer3D::BODY_MODE_STATIC);
+ } break;
+ case FREEZE_MODE_KINEMATIC: {
+ set_body_mode(PhysicsServer3D::BODY_MODE_KINEMATIC);
+ } break;
+ }
+ } else if (lock_rotation) {
+ set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR);
+ } else {
+ set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC);
}
- update_configuration_warnings();
}
-RigidDynamicBody3D::Mode RigidDynamicBody3D::get_mode() const {
- return mode;
+void RigidDynamicBody3D::set_lock_rotation_enabled(bool p_lock_rotation) {
+ if (p_lock_rotation == lock_rotation) {
+ return;
+ }
+
+ lock_rotation = p_lock_rotation;
+ _apply_body_mode();
+}
+
+bool RigidDynamicBody3D::is_lock_rotation_enabled() const {
+ return lock_rotation;
+}
+
+void RigidDynamicBody3D::set_freeze_enabled(bool p_freeze) {
+ if (p_freeze == freeze) {
+ return;
+ }
+
+ freeze = p_freeze;
+ _apply_body_mode();
+}
+
+bool RigidDynamicBody3D::is_freeze_enabled() const {
+ return freeze;
+}
+
+void RigidDynamicBody3D::set_freeze_mode(FreezeMode p_freeze_mode) {
+ if (p_freeze_mode == freeze_mode) {
+ return;
+ }
+
+ freeze_mode = p_freeze_mode;
+ _apply_body_mode();
+}
+
+RigidDynamicBody3D::FreezeMode RigidDynamicBody3D::get_freeze_mode() const {
+ return freeze_mode;
}
void RigidDynamicBody3D::set_mass(real_t p_mass) {
@@ -892,17 +935,14 @@ TypedArray<String> RigidDynamicBody3D::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings();
- if ((get_mode() == MODE_DYNAMIC || get_mode() == MODE_DYNAMIC_LOCKED) && (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)) {
- warnings.push_back(TTR("Size changes to RigidDynamicBody (in dynamic modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
+ if (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) {
+ warnings.push_back(TTR("Size changes to RigidDynamicBody will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
}
return warnings;
}
void RigidDynamicBody3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidDynamicBody3D::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &RigidDynamicBody3D::get_mode);
-
ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidDynamicBody3D::set_mass);
ClassDB::bind_method(D_METHOD("get_mass"), &RigidDynamicBody3D::get_mass);
@@ -963,11 +1003,19 @@ void RigidDynamicBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidDynamicBody3D::set_can_sleep);
ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidDynamicBody3D::is_able_to_sleep);
+ ClassDB::bind_method(D_METHOD("set_lock_rotation_enabled", "lock_rotation"), &RigidDynamicBody3D::set_lock_rotation_enabled);
+ ClassDB::bind_method(D_METHOD("is_lock_rotation_enabled"), &RigidDynamicBody3D::is_lock_rotation_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_freeze_enabled", "freeze_mode"), &RigidDynamicBody3D::set_freeze_enabled);
+ ClassDB::bind_method(D_METHOD("is_freeze_enabled"), &RigidDynamicBody3D::is_freeze_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_freeze_mode", "freeze_mode"), &RigidDynamicBody3D::set_freeze_mode);
+ ClassDB::bind_method(D_METHOD("get_freeze_mode"), &RigidDynamicBody3D::get_freeze_mode);
+
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidDynamicBody3D::get_colliding_bodies);
GDVIRTUAL_BIND(_integrate_forces, "state");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Dynamic,Static,DynamicLocked,Kinematic"), "set_mode", "get_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_RANGE, "0.01,1000,0.01,or_greater,exp"), "set_mass", "get_mass");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "inertia", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater,exp"), "set_inertia", "get_inertia");
ADD_PROPERTY(PropertyInfo(Variant::INT, "center_of_mass_mode", PROPERTY_HINT_ENUM, "Auto,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_center_of_mass_mode", "get_center_of_mass_mode");
@@ -981,6 +1029,9 @@ void RigidDynamicBody3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "contact_monitor"), "set_contact_monitor", "is_contact_monitor_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleeping", "is_sleeping");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), "set_can_sleep", "is_able_to_sleep");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "lock_rotation"), "set_lock_rotation_enabled", "is_lock_rotation_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "freeze"), "set_freeze_enabled", "is_freeze_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "freeze_mode", PROPERTY_HINT_ENUM, "Static,Kinematic"), "set_freeze_mode", "get_freeze_mode");
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");
@@ -994,10 +1045,8 @@ void RigidDynamicBody3D::_bind_methods() {
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_ENUM_CONSTANT(MODE_DYNAMIC);
- BIND_ENUM_CONSTANT(MODE_STATIC);
- BIND_ENUM_CONSTANT(MODE_DYNAMIC_LOCKED);
- BIND_ENUM_CONSTANT(MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(FREEZE_MODE_STATIC);
+ BIND_ENUM_CONSTANT(FREEZE_MODE_KINEMATIC);
BIND_ENUM_CONSTANT(CENTER_OF_MASS_MODE_AUTO);
BIND_ENUM_CONSTANT(CENTER_OF_MASS_MODE_CUSTOM);
@@ -1040,13 +1089,16 @@ void RigidDynamicBody3D::_reload_physics_characteristics() {
bool CharacterBody3D::move_and_slide() {
// Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky
double delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time();
- previous_position = get_global_transform().origin;
+
for (int i = 0; i < 3; i++) {
if (locked_axis & (1 << i)) {
- linear_velocity[i] = 0.0;
+ motion_velocity[i] = 0.0;
}
}
+ Transform3D gt = get_global_transform();
+ previous_position = gt.origin;
+
Vector3 current_platform_velocity = platform_velocity;
if ((collision_state.floor || collision_state.wall) && platform_rid.is_valid()) {
@@ -1060,7 +1112,6 @@ bool CharacterBody3D::move_and_slide() {
//this approach makes sure there is less delay between the actual body velocity and the one we saved
PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(platform_rid);
if (bs) {
- Transform3D gt = get_global_transform();
Vector3 local_position = gt.origin - bs->get_transform().origin;
current_platform_velocity = bs->get_velocity_at_local_position(local_position);
}
@@ -1074,6 +1125,8 @@ bool CharacterBody3D::move_and_slide() {
bool was_on_floor = collision_state.floor;
collision_state.state = 0;
+ last_motion = Vector3();
+
if (!current_platform_velocity.is_equal_approx(Vector3())) {
PhysicsServer3D::MotionResult floor_result;
Set<RID> exclude;
@@ -1101,20 +1154,15 @@ bool CharacterBody3D::move_and_slide() {
if (moving_platform_apply_velocity_on_leave == PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY && current_platform_velocity.dot(up_direction) < 0) {
current_platform_velocity = current_platform_velocity.slide(up_direction);
}
- linear_velocity += current_platform_velocity;
+ motion_velocity += current_platform_velocity;
}
}
- // Reset the gravity accumulation when touching the ground.
- if (collision_state.floor && linear_velocity.dot(up_direction) <= 0) {
- linear_velocity = linear_velocity.slide(up_direction);
- }
-
return motion_results.size() > 0;
}
void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_floor) {
- Vector3 motion = linear_velocity * p_delta;
+ Vector3 motion = motion_velocity * p_delta;
Vector3 motion_slide_up = motion.slide(up_direction);
Vector3 prev_floor_normal = floor_normal;
@@ -1129,12 +1177,13 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Constant speed can be applied only the first time sliding is enabled.
bool can_apply_constant_speed = sliding_enabled;
bool first_slide = true;
- bool vel_dir_facing_up = linear_velocity.dot(up_direction) > 0;
+ bool vel_dir_facing_up = motion_velocity.dot(up_direction) > 0;
Vector3 total_travel;
for (int iteration = 0; iteration < max_slides; ++iteration) {
PhysicsServer3D::MotionResult result;
bool collided = move_and_collide(motion, result, margin, false, 4, !sliding_enabled);
+ last_motion = result.travel;
if (collided) {
motion_results.push_back(result);
@@ -1144,21 +1193,20 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
CollisionState result_state;
_set_collision_direction(result, result_state);
- if (collision_state.floor && floor_stop_on_slope && (linear_velocity.normalized() + up_direction).length() < 0.01) {
+ if (collision_state.floor && floor_stop_on_slope && (motion_velocity.normalized() + up_direction).length() < 0.01) {
Transform3D gt = get_global_transform();
- real_t travel_total = result.travel.length();
- if (travel_total <= margin + CMP_EPSILON) {
+ if (result.travel.length() <= margin + CMP_EPSILON) {
gt.origin -= result.travel;
}
set_global_transform(gt);
- linear_velocity = Vector3();
+ motion_velocity = Vector3();
motion = Vector3();
+ last_motion = Vector3();
break;
}
if (result.remainder.is_equal_approx(Vector3())) {
motion = Vector3();
- last_motion = result.travel;
break;
}
@@ -1186,7 +1234,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
Transform3D gt = get_global_transform();
real_t travel_total = result.travel.length();
real_t cancel_dist_max = MIN(0.1, margin * 20);
- if (travel_total < margin + CMP_EPSILON) {
+ if (travel_total <= margin + CMP_EPSILON) {
gt.origin -= result.travel;
} else if (travel_total < cancel_dist_max) { // If the movement is large the body can be prevented from reaching the walls.
gt.origin -= result.travel.slide(up_direction);
@@ -1207,7 +1255,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
Vector3 forward = wall_normal.slide(up_direction).normalized();
motion = motion.slide(forward);
// Avoid accelerating when you jump on the wall and smooth falling.
- linear_velocity = linear_velocity.slide(forward);
+ motion_velocity = motion_velocity.slide(forward);
// Allow only lateral motion along previous floor when already on floor.
// Fixes slowing down when moving in diagonal against an inclined wall.
@@ -1236,7 +1284,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
if (stop_all_motion) {
motion = Vector3();
- linear_velocity = Vector3();
+ motion_velocity = Vector3();
}
}
}
@@ -1247,7 +1295,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
real_t motion_angle = Math::abs(Math::acos(-horizontal_normal.dot(motion_slide_up.normalized())));
if (motion_angle < wall_min_slide_angle) {
motion = up_direction * motion.dot(up_direction);
- linear_velocity = up_direction * linear_velocity.dot(up_direction);
+ motion_velocity = up_direction * motion_velocity.dot(up_direction);
apply_default_sliding = false;
}
@@ -1258,19 +1306,33 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Regular sliding, the last part of the test handle the case when you don't want to slide on the ceiling.
if ((sliding_enabled || !collision_state.floor) && (!collision_state.ceiling || slide_on_ceiling || !vel_dir_facing_up)) {
const PhysicsServer3D::MotionCollision &collision = result.collisions[0];
+
Vector3 slide_motion = result.remainder.slide(collision.normal);
- if (slide_motion.dot(linear_velocity) > 0.0) {
+ if (collision_state.floor && !collision_state.wall) {
+ // Slide using the intersection between the motion plane and the floor plane,
+ // in order to keep the direction intact.
+ real_t motion_length = slide_motion.length();
+ slide_motion = up_direction.cross(result.remainder).cross(floor_normal);
+
+ // Keep the length from default slide to change speed in slopes by default,
+ // when constant speed is not enabled.
+ slide_motion.normalize();
+ slide_motion *= motion_length;
+ }
+
+ if (slide_motion.dot(motion_velocity) > 0.0) {
motion = slide_motion;
} else {
motion = Vector3();
}
+
if (slide_on_ceiling && result_state.ceiling) {
// Apply slide only in the direction of the input motion, otherwise just stop to avoid jittering when moving against a wall.
if (vel_dir_facing_up) {
- linear_velocity = linear_velocity.slide(collision.normal);
+ motion_velocity = motion_velocity.slide(collision.normal);
} else {
// Avoid acceleration in slope when falling.
- linear_velocity = up_direction * up_direction.dot(linear_velocity);
+ motion_velocity = up_direction * up_direction.dot(motion_velocity);
}
}
}
@@ -1278,18 +1340,19 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
else {
motion = result.remainder;
if (result_state.ceiling && !slide_on_ceiling && vel_dir_facing_up) {
- linear_velocity = linear_velocity.slide(up_direction);
+ motion_velocity = motion_velocity.slide(up_direction);
motion = motion.slide(up_direction);
}
}
}
+ total_travel += result.travel;
+
// Apply Constant Speed.
- if (p_was_on_floor && floor_constant_speed && collision_state.floor && !motion.is_equal_approx(Vector3())) {
- motion = motion.normalized() * MAX(0, (motion_slide_up.length() - result.travel.slide(up_direction).length() - total_travel.slide(up_direction).length()));
+ if (p_was_on_floor && floor_constant_speed && can_apply_constant_speed && collision_state.floor && !motion.is_equal_approx(Vector3())) {
+ Vector3 travel_slide_up = total_travel.slide(up_direction);
+ motion = motion.normalized() * MAX(0, (motion_slide_up.length() - travel_slide_up.length()));
}
-
- total_travel += result.travel;
}
// When you move forward in a downward slope you don’t collide because you will be in the air.
// This test ensures that constant speed is applied, only if the player is still on the ground after the snap is applied.
@@ -1300,34 +1363,34 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
gt.origin = gt.origin - result.travel;
set_global_transform(gt);
- Vector3 motion_slide_norm = motion.slide(prev_floor_normal).normalized();
+ // Slide using the intersection between the motion plane and the floor plane,
+ // in order to keep the direction intact.
+ Vector3 motion_slide_norm = up_direction.cross(motion).cross(prev_floor_normal);
+ motion_slide_norm.normalize();
+
motion = motion_slide_norm * (motion_slide_up.length());
collided = true;
}
- can_apply_constant_speed = !can_apply_constant_speed && !sliding_enabled;
- sliding_enabled = true;
- first_slide = false;
-
- if (!motion.is_equal_approx(Vector3())) {
- last_motion = motion;
- }
-
if (!collided || motion.is_equal_approx(Vector3())) {
break;
}
+
+ can_apply_constant_speed = !can_apply_constant_speed && !sliding_enabled;
+ sliding_enabled = true;
+ first_slide = false;
}
_snap_on_floor(p_was_on_floor, vel_dir_facing_up);
// Reset the gravity accumulation when touching the ground.
if (collision_state.floor && !vel_dir_facing_up) {
- linear_velocity = linear_velocity.slide(up_direction);
+ motion_velocity = motion_velocity.slide(up_direction);
}
}
void CharacterBody3D::_move_and_slide_free(double p_delta) {
- Vector3 motion = linear_velocity * p_delta;
+ Vector3 motion = motion_velocity * p_delta;
platform_rid = RID();
floor_normal = Vector3();
@@ -1338,6 +1401,7 @@ void CharacterBody3D::_move_and_slide_free(double p_delta) {
PhysicsServer3D::MotionResult result;
bool collided = move_and_collide(motion, result, margin, false, 1, false);
+ last_motion = result.travel;
if (collided) {
motion_results.push_back(result);
@@ -1345,7 +1409,12 @@ void CharacterBody3D::_move_and_slide_free(double p_delta) {
CollisionState result_state;
_set_collision_direction(result, result_state);
- if (wall_min_slide_angle != 0 && Math::acos(wall_normal.dot(-linear_velocity.normalized())) < wall_min_slide_angle + FLOOR_ANGLE_THRESHOLD) {
+ if (result.remainder.is_equal_approx(Vector3())) {
+ motion = Vector3();
+ break;
+ }
+
+ if (wall_min_slide_angle != 0 && Math::acos(wall_normal.dot(-motion_velocity.normalized())) < wall_min_slide_angle + FLOOR_ANGLE_THRESHOLD) {
motion = Vector3();
if (result.travel.length() < margin + CMP_EPSILON) {
Transform3D gt = get_global_transform();
@@ -1359,16 +1428,16 @@ void CharacterBody3D::_move_and_slide_free(double p_delta) {
motion = result.remainder.slide(wall_normal);
}
- if (motion.dot(linear_velocity) <= 0.0) {
+ if (motion.dot(motion_velocity) <= 0.0) {
motion = Vector3();
}
}
- first_slide = false;
-
if (!collided || motion.is_equal_approx(Vector3())) {
break;
}
+
+ first_slide = false;
}
}
@@ -1377,7 +1446,9 @@ void CharacterBody3D::_snap_on_floor(bool was_on_floor, bool vel_dir_facing_up)
return;
}
+ // Snap by at least collision margin to keep floor state consistent.
real_t length = MAX(floor_snap_length, margin);
+
Transform3D gt = get_global_transform();
PhysicsServer3D::MotionResult result;
if (move_and_collide(-up_direction * length, result, margin, true, 4, false, true)) {
@@ -1403,12 +1474,15 @@ void CharacterBody3D::_snap_on_floor(bool was_on_floor, bool vel_dir_facing_up)
}
bool CharacterBody3D::_on_floor_if_snapped(bool was_on_floor, bool vel_dir_facing_up) {
- if (Math::is_zero_approx(floor_snap_length) || up_direction == Vector3() || collision_state.floor || !was_on_floor || vel_dir_facing_up) {
+ if (up_direction == Vector3() || collision_state.floor || !was_on_floor || vel_dir_facing_up) {
return false;
}
+ // Snap by at least collision margin to keep floor state consistent.
+ real_t length = MAX(floor_snap_length, margin);
+
PhysicsServer3D::MotionResult result;
- if (move_and_collide(-up_direction * floor_snap_length, result, margin, true, 4, false, true)) {
+ if (move_and_collide(-up_direction * length, result, margin, true, 4, false, true)) {
CollisionState result_state;
// Don't apply direction for any type.
_set_collision_direction(result, result_state, CollisionState());
@@ -1515,12 +1589,12 @@ real_t CharacterBody3D::get_safe_margin() const {
return margin;
}
-Vector3 CharacterBody3D::get_linear_velocity() const {
- return linear_velocity;
+const Vector3 &CharacterBody3D::get_motion_velocity() const {
+ return motion_velocity;
}
-void CharacterBody3D::set_linear_velocity(const Vector3 &p_velocity) {
- linear_velocity = p_velocity;
+void CharacterBody3D::set_motion_velocity(const Vector3 &p_velocity) {
+ motion_velocity = p_velocity;
}
bool CharacterBody3D::is_on_floor() const {
@@ -1547,15 +1621,15 @@ bool CharacterBody3D::is_on_ceiling_only() const {
return collision_state.ceiling && !collision_state.floor && !collision_state.wall;
}
-Vector3 CharacterBody3D::get_floor_normal() const {
+const Vector3 &CharacterBody3D::get_floor_normal() const {
return floor_normal;
}
-Vector3 CharacterBody3D::get_wall_normal() const {
+const Vector3 &CharacterBody3D::get_wall_normal() const {
return wall_normal;
}
-Vector3 CharacterBody3D::get_last_motion() const {
+const Vector3 &CharacterBody3D::get_last_motion() const {
return last_motion;
}
@@ -1563,19 +1637,23 @@ Vector3 CharacterBody3D::get_position_delta() const {
return get_transform().origin - previous_position;
}
-Vector3 CharacterBody3D::get_real_velocity() const {
+const Vector3 &CharacterBody3D::get_real_velocity() const {
return real_velocity;
-};
+}
real_t CharacterBody3D::get_floor_angle(const Vector3 &p_up_direction) const {
ERR_FAIL_COND_V(p_up_direction == Vector3(), 0);
return Math::acos(floor_normal.dot(p_up_direction));
}
-Vector3 CharacterBody3D::get_platform_velocity() const {
+const Vector3 &CharacterBody3D::get_platform_velocity() const {
return platform_velocity;
}
+Vector3 CharacterBody3D::get_linear_velocity() const {
+ return get_real_velocity();
+}
+
int CharacterBody3D::get_slide_collision_count() const {
return motion_results.size();
}
@@ -1730,8 +1808,8 @@ void CharacterBody3D::_notification(int p_what) {
void CharacterBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_slide"), &CharacterBody3D::move_and_slide);
- ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &CharacterBody3D::set_linear_velocity);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &CharacterBody3D::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_motion_velocity", "motion_velocity"), &CharacterBody3D::set_motion_velocity);
+ ClassDB::bind_method(D_METHOD("get_motion_velocity"), &CharacterBody3D::get_motion_velocity);
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &CharacterBody3D::set_safe_margin);
ClassDB::bind_method(D_METHOD("get_safe_margin"), &CharacterBody3D::get_safe_margin);
@@ -1784,7 +1862,7 @@ void CharacterBody3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "motion_mode", PROPERTY_HINT_ENUM, "Grounded,Free", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_motion_mode", "get_motion_mode");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "up_direction"), "set_up_direction", "get_up_direction");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slide_on_ceiling"), "set_slide_on_ceiling_enabled", "is_slide_on_ceiling_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_linear_velocity", "get_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "motion_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_motion_velocity", "get_motion_velocity");
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_slides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_max_slides", "get_max_slides");
ADD_GROUP("Free Mode", "free_mode_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wall_min_slide_angle", PROPERTY_HINT_RANGE, "0,180,0.1,radians", PROPERTY_USAGE_DEFAULT), "set_wall_min_slide_angle", "get_wall_min_slide_angle");
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index 96f3d7d747..0f25d2469f 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -105,7 +105,7 @@ private:
Vector3 linear_velocity;
Vector3 angular_velocity;
- bool sync_to_physics = false;
+ bool sync_to_physics = true;
Transform3D last_valid_transform;
@@ -133,11 +133,9 @@ class RigidDynamicBody3D : public PhysicsBody3D {
GDCLASS(RigidDynamicBody3D, PhysicsBody3D);
public:
- enum Mode {
- MODE_DYNAMIC,
- MODE_STATIC,
- MODE_DYNAMIC_LOCKED,
- MODE_KINEMATIC,
+ enum FreezeMode {
+ FREEZE_MODE_STATIC,
+ FREEZE_MODE_KINEMATIC,
};
enum CenterOfMassMode {
@@ -145,11 +143,11 @@ public:
CENTER_OF_MASS_MODE_CUSTOM,
};
- GDVIRTUAL1(_integrate_forces, PhysicsDirectBodyState3D *)
-
-protected:
+private:
bool can_sleep = true;
- Mode mode = MODE_DYNAMIC;
+ bool lock_rotation = false;
+ bool freeze = false;
+ FreezeMode freeze_mode = FREEZE_MODE_STATIC;
real_t mass = 1.0;
Vector3 inertia;
@@ -214,16 +212,28 @@ protected:
void _body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape);
static void _body_state_changed_callback(void *p_instance, PhysicsDirectBodyState3D *p_state);
- virtual void _body_state_changed(PhysicsDirectBodyState3D *p_state);
+protected:
void _notification(int p_what);
static void _bind_methods();
virtual void _validate_property(PropertyInfo &property) const override;
+ GDVIRTUAL1(_integrate_forces, PhysicsDirectBodyState3D *)
+
+ virtual void _body_state_changed(PhysicsDirectBodyState3D *p_state);
+
+ void _apply_body_mode();
+
public:
- void set_mode(Mode p_mode);
- Mode get_mode() const;
+ void set_lock_rotation_enabled(bool p_lock_rotation);
+ bool is_lock_rotation_enabled() const;
+
+ void set_freeze_enabled(bool p_freeze);
+ bool is_freeze_enabled() const;
+
+ void set_freeze_mode(FreezeMode p_freeze_mode);
+ FreezeMode get_freeze_mode() const;
void set_mass(real_t p_mass);
real_t get_mass() const;
@@ -298,7 +308,7 @@ private:
void _reload_physics_characteristics();
};
-VARIANT_ENUM_CAST(RigidDynamicBody3D::Mode);
+VARIANT_ENUM_CAST(RigidDynamicBody3D::FreezeMode);
VARIANT_ENUM_CAST(RigidDynamicBody3D::CenterOfMassMode);
class KinematicCollision3D;
@@ -318,8 +328,8 @@ public:
};
bool move_and_slide();
- virtual Vector3 get_linear_velocity() const override;
- void set_linear_velocity(const Vector3 &p_velocity);
+ const Vector3 &get_motion_velocity() const;
+ void set_motion_velocity(const Vector3 &p_velocity);
bool is_on_floor() const;
bool is_on_floor_only() const;
@@ -327,13 +337,15 @@ public:
bool is_on_wall_only() const;
bool is_on_ceiling() const;
bool is_on_ceiling_only() const;
- Vector3 get_last_motion() const;
+ const Vector3 &get_last_motion() const;
Vector3 get_position_delta() const;
- Vector3 get_floor_normal() const;
- Vector3 get_wall_normal() const;
- Vector3 get_real_velocity() const;
+ const Vector3 &get_floor_normal() const;
+ const Vector3 &get_wall_normal() const;
+ const Vector3 &get_real_velocity() const;
real_t get_floor_angle(const Vector3 &p_up_direction = Vector3(0.0, 1.0, 0.0)) const;
- Vector3 get_platform_velocity() const;
+ const Vector3 &get_platform_velocity() const;
+
+ virtual Vector3 get_linear_velocity() const override;
int get_slide_collision_count() const;
PhysicsServer3D::MotionResult get_slide_collision(int p_bounce) const;
@@ -364,12 +376,12 @@ private:
};
CollisionState collision_state;
- bool floor_stop_on_slope = false;
bool floor_constant_speed = false;
+ bool floor_stop_on_slope = true;
bool floor_block_on_wall = true;
bool slide_on_ceiling = true;
int max_slides = 6;
- int platform_layer;
+ int platform_layer = 0;
RID platform_rid;
uint32_t moving_platform_floor_layers = UINT32_MAX;
uint32_t moving_platform_wall_layers = 0;
@@ -377,7 +389,7 @@ private:
real_t floor_max_angle = Math::deg2rad((real_t)45.0);
real_t wall_min_slide_angle = Math::deg2rad((real_t)15.0);
Vector3 up_direction = Vector3(0.0, 1.0, 0.0);
- Vector3 linear_velocity;
+ Vector3 motion_velocity;
Vector3 floor_normal;
Vector3 wall_normal;
Vector3 last_motion;
diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp
index 466f67afb8..8d90aabfac 100644
--- a/scene/3d/skeleton_ik_3d.cpp
+++ b/scene/3d/skeleton_ik_3d.cpp
@@ -99,7 +99,7 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
child_ci->current_pos = child_ci->initial_transform.origin;
if (child_ci->parent_item) {
- child_ci->length = (child_ci->current_pos - child_ci->parent_item->current_pos).length();
+ child_ci->length = child_ci->parent_item->current_pos.distance_to(child_ci->current_pos);
}
}
@@ -140,7 +140,7 @@ void FabrikInverseKinematic::solve_simple(Task *p_task, bool p_solve_magnet, Vec
solve_simple_backwards(p_task->chain, p_solve_magnet);
solve_simple_forwards(p_task->chain, p_solve_magnet, p_origin_pos);
- distance_to_goal = (p_task->chain.tips[0].chain_item->current_pos - p_task->chain.tips[0].end_effector->goal_transform.origin).length();
+ distance_to_goal = p_task->chain.tips[0].end_effector->goal_transform.origin.distance_to(p_task->chain.tips[0].chain_item->current_pos);
}
}
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp
index bc3bb81ed4..9a2aaa8be2 100644
--- a/scene/3d/vehicle_body_3d.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -470,7 +470,7 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
}
void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) {
- real_t chassisMass = mass;
+ real_t chassisMass = get_mass();
for (int w_it = 0; w_it < wheels.size(); w_it++) {
VehicleWheel3D &wheel_info = *wheels[w_it];
@@ -558,7 +558,7 @@ void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const
rel_pos2,
normal,
s->get_inverse_inertia_tensor().get_main_diagonal(),
- 1.0 / mass,
+ 1.0 / get_mass(),
b2invinertia,
b2invmass);
@@ -584,7 +584,7 @@ void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const
#define ONLY_USE_LINEAR_MASS
#ifdef ONLY_USE_LINEAR_MASS
- real_t massTerm = real_t(1.) / ((1.0 / mass) + b2invmass);
+ real_t massTerm = real_t(1.) / ((1.0 / get_mass()) + b2invmass);
impulse = -contactDamping * rel_vel * massTerm;
#else
real_t velocityImpulse = -contactDamping * rel_vel * jacDiagABInv;
diff --git a/scene/animation/SCsub b/scene/animation/SCsub
index cc33a5af84..d0aa0bc8aa 100644
--- a/scene/animation/SCsub
+++ b/scene/animation/SCsub
@@ -6,11 +6,8 @@ Import("env")
thirdparty_obj = []
-thirdparty_sources = "#thirdparty/misc/easing_equations.cpp"
-
env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
-env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
env.scene_sources += thirdparty_obj
# Godot source files
diff --git a/scene/animation/easing_equations.h b/scene/animation/easing_equations.h
new file mode 100644
index 0000000000..c38d083b7f
--- /dev/null
+++ b/scene/animation/easing_equations.h
@@ -0,0 +1,405 @@
+/*************************************************************************/
+/* easing_equations.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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. */
+/*************************************************************************/
+
+/*
+ * Derived from Robert Penner's easing equations: http://robertpenner.com/easing/
+ *
+ * Copyright (c) 2001 Robert Penner
+ *
+ * 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 EASING_EQUATIONS_H
+#define EASING_EQUATIONS_H
+
+namespace linear {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * t / d + b;
+}
+}; // namespace linear
+
+namespace sine {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return -c * cos(t / d * (Math_PI / 2)) + c + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return c * sin(t / d * (Math_PI / 2)) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ return -c / 2 * (cos(Math_PI * t / d) - 1) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace sine
+
+namespace quint {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * pow(t / d, 5) + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return c * (pow(t / d - 1, 5) + 1) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d * 2;
+
+ if (t < 1) {
+ return c / 2 * pow(t, 5) + b;
+ }
+ return c / 2 * (pow(t - 2, 5) + 2) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace quint
+
+namespace quart {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * pow(t / d, 4) + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return -c * (pow(t / d - 1, 4) - 1) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d * 2;
+
+ if (t < 1) {
+ return c / 2 * pow(t, 4) + b;
+ }
+ return -c / 2 * (pow(t - 2, 4) - 2) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace quart
+
+namespace quad {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * pow(t / d, 2) + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ t /= d;
+ return -c * t * (t - 2) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d * 2;
+
+ if (t < 1) {
+ return c / 2 * pow(t, 2) + b;
+ }
+ return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace quad
+
+namespace expo {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) {
+ return b;
+ }
+ return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == d) {
+ return b + c;
+ }
+ return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) {
+ return b;
+ }
+
+ if (t == d) {
+ return b + c;
+ }
+
+ t = t / d * 2;
+
+ if (t < 1) {
+ return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005;
+ }
+ return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace expo
+
+namespace elastic {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) {
+ return b;
+ }
+
+ t /= d;
+ if (t == 1) {
+ return b + c;
+ }
+
+ t -= 1;
+ float p = d * 0.3f;
+ float a = c * pow(2, 10 * t);
+ float s = p / 4;
+
+ return -(a * sin((t * d - s) * (2 * Math_PI) / p)) + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) {
+ return b;
+ }
+
+ t /= d;
+ if (t == 1) {
+ return b + c;
+ }
+
+ float p = d * 0.3f;
+ float s = p / 4;
+
+ return (c * pow(2, -10 * t) * sin((t * d - s) * (2 * Math_PI) / p) + c + b);
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) {
+ return b;
+ }
+
+ if ((t /= d / 2) == 2) {
+ return b + c;
+ }
+
+ float p = d * (0.3f * 1.5f);
+ float a = c;
+ float s = p / 4;
+
+ if (t < 1) {
+ t -= 1;
+ a *= pow(2, 10 * t);
+ return -0.5f * (a * sin((t * d - s) * (2 * Math_PI) / p)) + b;
+ }
+
+ t -= 1;
+ a *= pow(2, -10 * t);
+ return a * sin((t * d - s) * (2 * Math_PI) / p) * 0.5f + c + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace elastic
+
+namespace cubic {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ t /= d;
+ return c * t * t * t + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d - 1;
+ return c * (t * t * t + 1) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t /= d / 2;
+ if (t < 1) {
+ return c / 2 * t * t * t + b;
+ }
+
+ t -= 2;
+ return c / 2 * (t * t * t + 2) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace cubic
+
+namespace circ {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ t /= d;
+ return -c * (sqrt(1 - t * t) - 1) + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d - 1;
+ return c * sqrt(1 - t * t) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t /= d / 2;
+ if (t < 1) {
+ return -c / 2 * (sqrt(1 - t * t) - 1) + b;
+ }
+
+ t -= 2;
+ return c / 2 * (sqrt(1 - t * t) + 1) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace circ
+
+namespace bounce {
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ t /= d;
+
+ if (t < (1 / 2.75f)) {
+ return c * (7.5625f * t * t) + b;
+ }
+
+ if (t < (2 / 2.75f)) {
+ t -= 1.5f / 2.75f;
+ return c * (7.5625f * t * t + 0.75f) + b;
+ }
+
+ if (t < (2.5 / 2.75)) {
+ t -= 2.25f / 2.75f;
+ return c * (7.5625f * t * t + 0.9375f) + b;
+ }
+
+ t -= 2.625f / 2.75f;
+ return c * (7.5625f * t * t + 0.984375f) + b;
+}
+
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c - out(d - t, 0, c, d) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return in(t * 2, b, c / 2, d);
+ }
+ return out(t * 2 - d, b + c / 2, c / 2, d);
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace bounce
+
+namespace back {
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ float s = 1.70158f;
+ t /= d;
+
+ return c * t * t * ((s + 1) * t - s) + b;
+}
+
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ float s = 1.70158f;
+ t = t / d - 1;
+
+ return c * (t * t * ((s + 1) * t + s) + 1) + b;
+}
+
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ float s = 1.70158f * 1.525f;
+ t /= d / 2;
+
+ if (t < 1) {
+ return c / 2 * (t * t * ((s + 1) * t - s)) + b;
+ }
+
+ t -= 2;
+ return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b;
+}
+
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ if (t < d / 2) {
+ return out(t * 2, b, c / 2, d);
+ }
+ return in(t * 2 - d, b + c / 2, c / 2, d);
+}
+}; // namespace back
+
+#endif
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 2847031375..c43b83747b 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -30,8 +30,23 @@
#include "tween.h"
+#include "scene/animation/easing_equations.h"
#include "scene/main/node.h"
+Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = {
+ { &linear::in, &linear::in, &linear::in, &linear::in }, // Linear is the same for each easing.
+ { &sine::in, &sine::out, &sine::in_out, &sine::out_in },
+ { &quint::in, &quint::out, &quint::in_out, &quint::out_in },
+ { &quart::in, &quart::out, &quart::in_out, &quart::out_in },
+ { &quad::in, &quad::out, &quad::in_out, &quad::out_in },
+ { &expo::in, &expo::out, &expo::in_out, &expo::out_in },
+ { &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in },
+ { &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in },
+ { &circ::in, &circ::out, &circ::in_out, &circ::out_in },
+ { &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in },
+ { &back::in, &back::out, &back::in_out, &back::out_in },
+};
+
void Tweener::set_tween(Ref<Tween> p_tween) {
tween = p_tween;
}
@@ -317,6 +332,16 @@ bool Tween::should_pause() {
return pause_mode != TWEEN_PAUSE_PROCESS;
}
+real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t p_time, real_t p_initial, real_t p_delta, real_t p_duration) {
+ if (p_duration == 0) {
+ // Special case to avoid dividing by 0 in equations.
+ return p_initial + p_delta;
+ }
+
+ interpolater func = interpolaters[p_trans_type][p_ease_type];
+ return func(p_time, p_initial, p_delta, p_duration);
+}
+
Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, TransitionType p_trans, EaseType p_ease) {
ERR_FAIL_INDEX_V(p_trans, TransitionType::TRANS_MAX, Variant());
ERR_FAIL_INDEX_V(p_ease, EaseType::EASE_MAX, Variant());
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 5d1106bb41..0476a764a5 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -227,17 +227,17 @@ void CodeEdit::_notification(int p_what) {
end = font->get_string_size(line.substr(0, line.rfind(String::chr(0xFFFF))), font_size).x;
}
- Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent() + font_height * i + yofs);
+ Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent(font_size) + font_height * i + yofs);
round_ofs = round_ofs.round();
draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HALIGN_LEFT, -1, font_size, font_color);
if (end > 0) {
// Draw an underline for the currently edited function parameter.
- const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + line_spacing);
+ const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + yofs);
draw_line(b, b + Vector2(end - begin, 0), font_color, 2);
// Draw a translucent text highlight as well.
const Rect2 highlight_rect = Rect2(
- hint_ofs + sb->get_offset() + Vector2(begin, 0),
+ b - Vector2(0, font_height),
Vector2(end - begin, font_height));
draw_rect(highlight_rect, font_color * Color(1, 1, 1, 0.2));
}
@@ -1146,13 +1146,20 @@ bool CodeEdit::is_drawing_executing_lines_gutter() const {
}
void CodeEdit::_main_gutter_draw_callback(int p_line, int p_gutter, const Rect2 &p_region) {
- if (draw_breakpoints && is_line_breakpointed(p_line)) {
- int padding = p_region.size.x / 6;
+ if (draw_breakpoints) {
+ bool hovering = p_region.has_point(get_local_mouse_pos());
+ bool breakpointed = is_line_breakpointed(p_line);
- Rect2 breakpoint_region = p_region;
- breakpoint_region.position += Point2(padding, padding);
- breakpoint_region.size -= Point2(padding, padding) * 2;
- breakpoint_icon->draw_rect(get_canvas_item(), breakpoint_region, false, breakpoint_color);
+ if (breakpointed || (hovering && !is_dragging_cursor())) {
+ int padding = p_region.size.x / 6;
+ Rect2 icon_region = p_region;
+ icon_region.position += Point2(padding, padding);
+ icon_region.size -= Point2(padding, padding) * 2;
+
+ // Darken icon when hovering & not yet breakpointed.
+ Color use_color = hovering && !breakpointed ? breakpoint_color.darkened(0.4) : breakpoint_color;
+ breakpoint_icon->draw_rect(get_canvas_item(), icon_region, false, use_color);
+ }
}
if (draw_bookmarks && is_line_bookmarked(p_line)) {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 046715e17e..611035fff9 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -827,7 +827,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
real_t dist = center.distance_to(bev->get_position());
if (dist <= center.x) {
- real_t rad = Math::atan2(bev->get_position().y - center.y, bev->get_position().x - center.x);
+ real_t rad = bev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
s = CLAMP(dist / center.x, 0, 1);
} else {
@@ -844,7 +844,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
real_t dist = center.distance_to(bev->get_position());
if (dist >= center.x * 0.84 && dist <= center.x) {
- real_t rad = Math::atan2(bev->get_position().y - center.y, bev->get_position().x - center.x);
+ real_t rad = bev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
spinning = true;
} else {
@@ -889,12 +889,12 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
Vector2 center = c->get_size() / 2.0;
if (picker_type == SHAPE_VHS_CIRCLE) {
real_t dist = center.distance_to(mev->get_position());
- real_t rad = Math::atan2(mev->get_position().y - center.y, mev->get_position().x - center.x);
+ real_t rad = mev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
s = CLAMP(dist / center.x, 0, 1);
} else {
if (spinning) {
- real_t rad = Math::atan2(mev->get_position().y - center.y, mev->get_position().x - center.x);
+ real_t rad = mev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
} else {
real_t corner_x = (c == wheel_uv) ? center.x - Math_SQRT12 * c->get_size().width * 0.42 : 0;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index bca3b2059d..d9c08ec272 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -1071,10 +1071,7 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
if (mm.is_valid() && box_selecting) {
box_selecting_to = mm->get_position();
- box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
- MIN(box_selecting_from.y, box_selecting_to.y),
- ABS(box_selecting_from.x - box_selecting_to.x),
- ABS(box_selecting_from.y - box_selecting_to.y));
+ box_selecting_rect = Rect2(box_selecting_from.min(box_selecting_to), (box_selecting_from - box_selecting_to).abs());
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index cbdf2a498a..ecf735d7f5 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -31,6 +31,9 @@
#include "graph_node.h"
#include "core/string/translation.h"
+#ifdef TOOLS_ENABLED
+#include "graph_edit.h"
+#endif
struct _MinSizeCache {
int min_size;
@@ -458,6 +461,27 @@ void GraphNode::_shape() {
title_buf->add_string(title, font, font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale());
}
+#ifdef TOOLS_ENABLED
+void GraphNode::_edit_set_position(const Point2 &p_position) {
+ GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
+ if (graph) {
+ Point2 offset = (p_position + graph->get_scroll_ofs()) * graph->get_zoom();
+ set_position_offset(offset);
+ }
+ set_position(p_position);
+}
+
+void GraphNode::_validate_property(PropertyInfo &property) const {
+ Control::_validate_property(property);
+ GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
+ if (graph) {
+ if (property.name == "rect_position") {
+ property.usage |= PROPERTY_USAGE_READ_ONLY;
+ }
+ }
+}
+#endif
+
void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) {
ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set slot with p_idx (%d) lesser than zero.", p_idx));
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index c7c7006bfc..2238cfdb56 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -98,6 +98,11 @@ private:
Overlay overlay = OVERLAY_DISABLED;
+#ifdef TOOLS_ENABLED
+ void _edit_set_position(const Point2 &p_position) override;
+ void _validate_property(PropertyInfo &property) const override;
+#endif
+
protected:
virtual void gui_input(const Ref<InputEvent> &p_ev) override;
void _notification(int p_what);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index d9acbeb828..89fd9bfc88 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -260,24 +260,29 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
} else {
if (selecting_enabled) {
- if (!b->is_double_click() && (OS::get_singleton()->get_ticks_msec() - selection.last_dblclk) < 600) {
+ const int triple_click_timeout = 600;
+ const int triple_click_tolerance = 5;
+ const bool is_triple_click = !b->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < triple_click_timeout && b->get_position().distance_to(last_dblclk_pos) < triple_click_tolerance;
+
+ if (is_triple_click && text.length()) {
// Triple-click select all.
selection.enabled = true;
selection.begin = 0;
selection.end = text.length();
selection.double_click = true;
- selection.last_dblclk = 0;
+ last_dblclk = 0;
caret_column = selection.begin;
} else if (b->is_double_click()) {
// Double-click select word.
+ last_dblclk = OS::get_singleton()->get_ticks_msec();
+ last_dblclk_pos = b->get_position();
Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text_rid);
for (int i = 0; i < words.size(); i++) {
- if (words[i].x < caret_column && words[i].y > caret_column) {
+ if ((words[i].x < caret_column && words[i].y > caret_column) || (i == words.size() - 1 && caret_column == words[i].y)) {
selection.enabled = true;
selection.begin = words[i].x;
selection.end = words[i].y;
selection.double_click = true;
- selection.last_dblclk = OS::get_singleton()->get_ticks_msec();
caret_column = selection.end;
break;
}
@@ -1555,6 +1560,20 @@ void LineEdit::deselect() {
update();
}
+bool LineEdit::has_selection() const {
+ return selection.enabled;
+}
+
+int LineEdit::get_selection_from_column() const {
+ ERR_FAIL_COND_V(!selection.enabled, -1);
+ return selection.begin;
+}
+
+int LineEdit::get_selection_to_column() const {
+ ERR_FAIL_COND_V(!selection.enabled, -1);
+ return selection.end;
+}
+
void LineEdit::selection_delete() {
if (selection.enabled) {
delete_text(selection.begin, selection.end);
@@ -2089,6 +2108,9 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("select", "from", "to"), &LineEdit::select, DEFVAL(0), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("select_all"), &LineEdit::select_all);
ClassDB::bind_method(D_METHOD("deselect"), &LineEdit::deselect);
+ ClassDB::bind_method(D_METHOD("has_selection"), &LineEdit::has_selection);
+ ClassDB::bind_method(D_METHOD("get_selection_from_column"), &LineEdit::get_selection_from_column);
+ ClassDB::bind_method(D_METHOD("get_selection_to_column"), &LineEdit::get_selection_to_column);
ClassDB::bind_method(D_METHOD("set_text", "text"), &LineEdit::set_text);
ClassDB::bind_method(D_METHOD("get_text"), &LineEdit::get_text);
ClassDB::bind_method(D_METHOD("get_draw_control_chars"), &LineEdit::get_draw_control_chars);
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index e364a79c83..923024dd56 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -136,7 +136,6 @@ private:
bool creating = false;
bool double_click = false;
bool drag_attempt = false;
- uint64_t last_dblclk = 0;
} selection;
struct TextOperation {
@@ -153,6 +152,9 @@ private:
bool pressing_inside = false;
} clear_button_status;
+ uint64_t last_dblclk = 0;
+ Vector2 last_dblclk_pos;
+
bool caret_blink_enabled = false;
bool caret_force_displayed = false;
bool draw_caret = true;
@@ -229,6 +231,9 @@ public:
void select_all();
void selection_delete();
void deselect();
+ bool has_selection() const;
+ int get_selection_from_column() const;
+ int get_selection_to_column() const;
void delete_char();
void delete_text(int p_from_column, int p_to_column);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 3eaae5181d..277026cc28 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -2378,8 +2378,7 @@ void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width,
item->size.width = p_image->get_width() * p_height / p_image->get_height();
} else {
// keep original width and height
- item->size.height = p_image->get_height();
- item->size.width = p_image->get_width();
+ item->size = p_image->get_size();
}
}
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index a423dc0173..c8a0501d8a 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -79,7 +79,7 @@ void TabContainer::gui_input(const Ref<InputEvent> &p_event) {
Popup *popup = get_popup();
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
- Point2 pos(mb->get_position().x, mb->get_position().y);
+ Point2 pos = mb->get_position();
Size2 size = get_size();
// Click must be on tabs in the tab header area.
@@ -190,7 +190,7 @@ void TabContainer::gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
- Point2 pos(mm->get_position().x, mm->get_position().y);
+ Point2 pos = mm->get_position();
Size2 size = get_size();
// Mouse must be on tabs in the tab header area.
@@ -1210,6 +1210,8 @@ void TabContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tab_icon", "tab_idx"), &TabContainer::get_tab_icon);
ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &TabContainer::set_tab_disabled);
ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &TabContainer::get_tab_disabled);
+ ClassDB::bind_method(D_METHOD("set_tab_hidden", "tab_idx", "hidden"), &TabContainer::set_tab_hidden);
+ ClassDB::bind_method(D_METHOD("get_tab_hidden", "tab_idx"), &TabContainer::get_tab_hidden);
ClassDB::bind_method(D_METHOD("get_tab_idx_at_point", "point"), &TabContainer::get_tab_idx_at_point);
ClassDB::bind_method(D_METHOD("set_popup", "popup"), &TabContainer::set_popup);
ClassDB::bind_method(D_METHOD("get_popup"), &TabContainer::get_popup);
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 3ca2d1c1e9..ef34bec347 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -98,29 +98,45 @@ void Tabs::gui_input(const Ref<InputEvent> &p_event) {
if (mm.is_valid()) {
Point2 pos = mm->get_position();
- highlight_arrow = -1;
if (buttons_visible) {
Ref<Texture2D> incr = get_theme_icon(SNAME("increment"));
Ref<Texture2D> decr = get_theme_icon(SNAME("decrement"));
if (is_layout_rtl()) {
if (pos.x < decr->get_width()) {
- highlight_arrow = 1;
+ if (highlight_arrow != 1) {
+ highlight_arrow = 1;
+ update();
+ }
} else if (pos.x < incr->get_width() + decr->get_width()) {
- highlight_arrow = 0;
+ if (highlight_arrow != 0) {
+ highlight_arrow = 0;
+ update();
+ }
+ } else if (highlight_arrow != -1) {
+ highlight_arrow = -1;
+ update();
}
} else {
int limit_minus_buttons = get_size().width - incr->get_width() - decr->get_width();
if (pos.x > limit_minus_buttons + decr->get_width()) {
- highlight_arrow = 1;
+ if (highlight_arrow != 1) {
+ highlight_arrow = 1;
+ update();
+ }
} else if (pos.x > limit_minus_buttons) {
- highlight_arrow = 0;
+ if (highlight_arrow != 0) {
+ highlight_arrow = 0;
+ update();
+ }
+ } else if (highlight_arrow != -1) {
+ highlight_arrow = -1;
+ update();
}
}
}
_update_hover();
- update();
return;
}
@@ -167,7 +183,7 @@ void Tabs::gui_input(const Ref<InputEvent> &p_event) {
if (mb->is_pressed() && (mb->get_button_index() == MOUSE_BUTTON_LEFT || (select_with_rmb && mb->get_button_index() == MOUSE_BUTTON_RIGHT))) {
// clicks
- Point2 pos(mb->get_position().x, mb->get_position().y);
+ Point2 pos = mb->get_position();
if (buttons_visible) {
Ref<Texture2D> incr = get_theme_icon(SNAME("increment"));
@@ -241,6 +257,7 @@ void Tabs::_shape(int p_tab) {
tabs.write[p_tab].xl_text = atr(tabs[p_tab].text);
tabs.write[p_tab].text_buf->clear();
+ tabs.write[p_tab].text_buf->set_width(-1);
if (tabs[p_tab].text_direction == Control::TEXT_DIRECTION_INHERITED) {
tabs.write[p_tab].text_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
} else {
@@ -529,7 +546,6 @@ bool Tabs::get_offset_buttons_visible() const {
void Tabs::set_tab_title(int p_tab, const String &p_title) {
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].text = p_title;
- tabs.write[p_tab].xl_text = atr(p_title);
_shape(p_tab);
update();
minimum_size_changed();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 09899413f2..5e165be15e 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1636,6 +1636,32 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
}
+
+ // Check if user is hovering a different gutter, and update if yes.
+ Vector2i current_hovered_gutter = Vector2i(-1, -1);
+
+ int left_margin = style_normal->get_margin(SIDE_LEFT);
+ if (mpos.x <= left_margin + gutters_width + gutter_padding) {
+ int hovered_row = get_line_column_at_pos(mpos).y;
+ for (int i = 0; i < gutters.size(); i++) {
+ if (!gutters[i].draw || gutters[i].width <= 0) {
+ continue;
+ }
+
+ if (mpos.x > left_margin && mpos.x <= (left_margin + gutters[i].width) - 3) {
+ // We are in this gutter i's horizontal area.
+ current_hovered_gutter = Vector2i(i, hovered_row);
+ break;
+ }
+
+ left_margin += gutters[i].width;
+ }
+ }
+
+ if (current_hovered_gutter != hovered_gutter) {
+ hovered_gutter = current_hovered_gutter;
+ update();
+ }
}
if (draw_minimap && !dragging_selection) {
@@ -2731,7 +2757,10 @@ void TextEdit::insert_line_at(int p_at, const String &p_text) {
}
void TextEdit::insert_text_at_caret(const String &p_text) {
- begin_complex_operation();
+ bool had_selection = has_selection();
+ if (had_selection) {
+ begin_complex_operation();
+ }
delete_selection();
@@ -2743,7 +2772,9 @@ void TextEdit::insert_text_at_caret(const String &p_text) {
set_caret_column(new_column);
update();
- end_complex_operation();
+ if (had_selection) {
+ end_complex_operation();
+ }
}
void TextEdit::remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
@@ -3689,7 +3720,7 @@ void TextEdit::select_word_under_caret() {
int end = 0;
const Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text.get_line_data(caret.line)->get_rid());
for (int i = 0; i < words.size(); i++) {
- if (words[i].x <= caret.column && words[i].y >= caret.column) {
+ if ((words[i].x < caret.column && words[i].y > caret.column) || (i == words.size() - 1 && caret.column == words[i].y)) {
begin = words[i].x;
end = words[i].y;
break;
@@ -5411,7 +5442,7 @@ void TextEdit::_update_selection_mode_word() {
int end = beg;
Vector<Vector2i> words = TS->shaped_text_get_word_breaks(text.get_line_data(line)->get_rid());
for (int i = 0; i < words.size(); i++) {
- if (words[i].x < caret_pos && words[i].y > caret_pos) {
+ if ((words[i].x < caret_pos && words[i].y > caret_pos) || (i == words.size() - 1 && caret_pos == words[i].y)) {
beg = words[i].x;
end = words[i].y;
break;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index b1226f2aff..db16d09c58 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -477,6 +477,7 @@ private:
Vector<GutterInfo> gutters;
int gutters_width = 0;
int gutter_padding = 0;
+ Vector2i hovered_gutter = Vector2i(-1, -1); // X = gutter index, Y = row.
void _update_gutter_width();
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp
index 286f01ee33..35a098c6fd 100644
--- a/scene/gui/texture_progress_bar.cpp
+++ b/scene/gui/texture_progress_bar.cpp
@@ -471,7 +471,7 @@ void TextureProgressBar::_notification(int p_what) {
Vector<Point2> uvs;
Vector<Point2> points;
uvs.push_back(get_relative_center());
- points.push_back(progress_offset + Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
+ points.push_back(progress_offset + s * get_relative_center());
for (int i = 0; i < pts.size(); i++) {
Point2 uv = unit_val_to_uv(pts[i]);
if (uvs.find(uv) >= 0) {
@@ -493,8 +493,7 @@ void TextureProgressBar::_notification(int p_what) {
p = progress->get_size();
}
- p.x *= get_relative_center().x;
- p.y *= get_relative_center().y;
+ p *= get_relative_center();
p = p.floor();
draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f62c09925d..7d7596635c 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -144,6 +144,7 @@ void TreeItem::_change_tree(Tree *p_tree) {
/* cell mode */
void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) {
ERR_FAIL_INDEX(p_column, cells.size());
+
Cell &c = cells.write[p_column];
c.mode = p_mode;
c.min = 0;
@@ -155,8 +156,9 @@ void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) {
c.text = "";
c.dirty = true;
c.icon_max_w = 0;
+ c.cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const {
@@ -167,22 +169,27 @@ TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const {
/* check mode */
void TreeItem::set_checked(int p_column, bool p_checked) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].checked = p_checked;
cells.write[p_column].indeterminate = false;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
void TreeItem::set_indeterminate(int p_column, bool p_indeterminate) {
ERR_FAIL_INDEX(p_column, cells.size());
+
// Prevent uncheck if indeterminate set to false twice
if (p_indeterminate == cells[p_column].indeterminate) {
return;
}
+
cells.write[p_column].indeterminate = p_indeterminate;
cells.write[p_column].checked = false;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
bool TreeItem::is_checked(int p_column) const {
@@ -214,8 +221,10 @@ void TreeItem::set_text(int p_column, String p_text) {
}
cells.write[p_column].step = 0;
}
+
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
String TreeItem::get_text(int p_column) const {
@@ -231,7 +240,7 @@ void TreeItem::set_text_direction(int p_column, Control::TextDirection p_text_di
cells.write[p_column].dirty = true;
_changed_notify(p_column);
}
- cached_minimum_size_dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
}
Control::TextDirection TreeItem::get_text_direction(int p_column) const {
@@ -241,10 +250,12 @@ Control::TextDirection TreeItem::get_text_direction(int p_column) const {
void TreeItem::clear_opentype_features(int p_column) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].opentype_features.clear();
cells.write[p_column].dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
void TreeItem::set_opentype_feature(int p_column, const String &p_name, int p_value) {
@@ -253,8 +264,9 @@ void TreeItem::set_opentype_feature(int p_column, const String &p_name, int p_va
if (!cells[p_column].opentype_features.has(tag) || (int)cells[p_column].opentype_features[tag] != p_value) {
cells.write[p_column].opentype_features[tag] = p_value;
cells.write[p_column].dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
}
@@ -269,11 +281,13 @@ int TreeItem::get_opentype_feature(int p_column, const String &p_name) const {
void TreeItem::set_structured_text_bidi_override(int p_column, Control::StructuredTextParser p_parser) {
ERR_FAIL_INDEX(p_column, cells.size());
+
if (cells[p_column].st_parser != p_parser) {
cells.write[p_column].st_parser = p_parser;
cells.write[p_column].dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
}
@@ -284,10 +298,12 @@ Control::StructuredTextParser TreeItem::get_structured_text_bidi_override(int p_
void TreeItem::set_structured_text_bidi_override_options(int p_column, Array p_args) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].st_args = p_args;
cells.write[p_column].dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
Array TreeItem::get_structured_text_bidi_override_options(int p_column) const {
@@ -297,11 +313,13 @@ Array TreeItem::get_structured_text_bidi_override_options(int p_column) const {
void TreeItem::set_language(int p_column, const String &p_language) {
ERR_FAIL_INDEX(p_column, cells.size());
+
if (cells[p_column].language != p_language) {
cells.write[p_column].language = p_language;
cells.write[p_column].dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
}
@@ -312,10 +330,11 @@ String TreeItem::get_language(int p_column) const {
void TreeItem::set_suffix(int p_column, String p_suffix) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].suffix = p_suffix;
+ cells.write[p_column].cached_minimum_size_dirty = true;
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
String TreeItem::get_suffix(int p_column) const {
@@ -325,9 +344,11 @@ String TreeItem::get_suffix(int p_column) const {
void TreeItem::set_icon(int p_column, const Ref<Texture2D> &p_icon) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].icon = p_icon;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
Ref<Texture2D> TreeItem::get_icon(int p_column) const {
@@ -337,9 +358,11 @@ Ref<Texture2D> TreeItem::get_icon(int p_column) const {
void TreeItem::set_icon_region(int p_column, const Rect2 &p_icon_region) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].icon_region = p_icon_region;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
Rect2 TreeItem::get_icon_region(int p_column) const {
@@ -360,9 +383,11 @@ Color TreeItem::get_icon_modulate(int p_column) const {
void TreeItem::set_icon_max_width(int p_column, int p_max) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].icon_max_w = p_max;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
int TreeItem::get_icon_max_width(int p_column) const {
@@ -474,8 +499,11 @@ void TreeItem::uncollapse_tree() {
void TreeItem::set_custom_minimum_height(int p_height) {
custom_min_height = p_height;
+
+ for (Cell &c : cells)
+ c.cached_minimum_size_dirty = true;
+
_changed_notify();
- cached_minimum_size_dirty = true;
}
int TreeItem::get_custom_minimum_height() const {
@@ -799,8 +827,9 @@ void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id
button.disabled = p_disabled;
button.tooltip = p_tooltip;
cells.write[p_column].buttons.push_back(button);
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
int TreeItem::get_button_count(int p_column) const {
@@ -843,8 +872,9 @@ void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture2D> &p_butto
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
cells.write[p_column].buttons.write[p_idx].texture = p_button;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) {
@@ -859,8 +889,9 @@ void TreeItem::set_button_disabled(int p_column, int p_idx, bool p_disabled) {
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
cells.write[p_column].buttons.write[p_idx].disabled = p_disabled;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
@@ -872,9 +903,11 @@ bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
void TreeItem::set_editable(int p_column, bool p_editable) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].editable = p_editable;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
bool TreeItem::is_editable(int p_column) {
@@ -906,8 +939,9 @@ void TreeItem::clear_custom_color(int p_column) {
void TreeItem::set_custom_font(int p_column, const Ref<Font> &p_font) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].custom_font = p_font;
- cached_minimum_size_dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
}
Ref<Font> TreeItem::get_custom_font(int p_column) const {
@@ -917,8 +951,9 @@ Ref<Font> TreeItem::get_custom_font(int p_column) const {
void TreeItem::set_custom_font_size(int p_column, int p_font_size) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].custom_font_size = p_font_size;
- cached_minimum_size_dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
}
int TreeItem::get_custom_font_size(int p_column) const {
@@ -961,8 +996,9 @@ Color TreeItem::get_custom_bg_color(int p_column) const {
void TreeItem::set_custom_as_button(int p_column, bool p_button) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].custom_button = p_button;
- cached_minimum_size_dirty = true;
+ cells.write[p_column].cached_minimum_size_dirty = true;
}
bool TreeItem::is_custom_set_as_button(int p_column) const {
@@ -972,9 +1008,11 @@ bool TreeItem::is_custom_set_as_button(int p_column) const {
void TreeItem::set_text_align(int p_column, TextAlign p_align) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].text_align = p_align;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
TreeItem::TextAlign TreeItem::get_text_align(int p_column) const {
@@ -984,9 +1022,11 @@ TreeItem::TextAlign TreeItem::get_text_align(int p_column) const {
void TreeItem::set_expand_right(int p_column, bool p_enable) {
ERR_FAIL_INDEX(p_column, cells.size());
+
cells.write[p_column].expand_right = p_enable;
+ cells.write[p_column].cached_minimum_size_dirty = true;
+
_changed_notify(p_column);
- cached_minimum_size_dirty = true;
}
bool TreeItem::get_expand_right(int p_column) const {
@@ -996,8 +1036,11 @@ bool TreeItem::get_expand_right(int p_column) const {
void TreeItem::set_disable_folding(bool p_disable) {
disable_folding = p_disable;
+
+ for (Cell &c : cells)
+ c.cached_minimum_size_dirty = true;
+
_changed_notify(0);
- cached_minimum_size_dirty = true;
}
bool TreeItem::is_folding_disabled() const {
@@ -1009,14 +1052,12 @@ Size2 TreeItem::get_minimum_size(int p_column) {
Tree *tree = get_tree();
ERR_FAIL_COND_V(!tree, Size2());
- if (cached_minimum_size_dirty) {
- Size2 size;
+ const TreeItem::Cell &cell = cells[p_column];
- // Default offset?
- //size.width += (disable_folding || tree->hide_folding) ? tree->cache.hseparation : tree->cache.item_margin;
+ if (cell.cached_minimum_size_dirty) {
+ Size2 size;
// Text.
- const TreeItem::Cell &cell = cells[p_column];
if (!cell.text.is_empty()) {
if (cell.dirty) {
tree->update_item_cell(this, p_column);
@@ -1052,11 +1093,11 @@ Size2 TreeItem::get_minimum_size(int p_column) {
size.width += (cell.buttons.size() - 1) * tree->cache.button_margin;
}
- cached_minimum_size = size;
- cached_minimum_size_dirty = false;
+ cells.write[p_column].cached_minimum_size = size;
+ cells.write[p_column].cached_minimum_size_dirty = false;
}
- return cached_minimum_size;
+ return cell.cached_minimum_size;
}
Variant TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
@@ -1337,10 +1378,6 @@ void Tree::update_cache() {
cache.title_button_color = get_theme_color(SNAME("title_button_color"));
v_scroll->set_custom_step(cache.font->get_height(cache.font_size));
-
- for (TreeItem *item = get_root(); item; item = item->get_next()) {
- item->cached_minimum_size_dirty = true;
- }
}
int Tree::compute_item_height(TreeItem *p_item) const {
@@ -1712,7 +1749,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if ((select_mode == SELECT_ROW && selected_item == p_item) || p_item->cells[i].selected || !p_item->has_meta("__focus_rect")) {
- Rect2i r(cell_rect.position, cell_rect.size);
+ Rect2i r = cell_rect;
p_item->set_meta("__focus_rect", Rect2(r.position, r.size));
@@ -1968,7 +2005,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
arrow = cache.arrow;
}
- Point2 apos = p_pos + p_draw_ofs + Point2i(0, (label_h - arrow->get_height()) / 2) - cache.offset;
+ Point2 apos = p_pos + Point2i(0, (label_h - arrow->get_height()) / 2) - cache.offset + p_draw_ofs;
+ apos.x += cache.item_margin - arrow->get_width();
if (rtl) {
apos.x = get_size().width - apos.x - arrow->get_width();
@@ -4000,10 +4038,12 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) {
int Tree::get_column_minimum_width(int p_column) const {
ERR_FAIL_INDEX_V(p_column, columns.size(), -1);
+ // Use the custom minimum width.
int min_width = columns[p_column].custom_min_width;
+ // Check if the visible title of the column is wider.
if (show_column_titles) {
- min_width = MAX(cache.font->get_string_size(columns[p_column].title).width, min_width);
+ min_width = MAX(cache.font->get_string_size(columns[p_column].title).width + cache.bg->get_margin(SIDE_LEFT) + cache.bg->get_margin(SIDE_RIGHT), min_width);
}
if (!columns[p_column].clip_content) {
@@ -4028,7 +4068,11 @@ int Tree::get_column_minimum_width(int p_column) const {
Size2 item_size = item->get_minimum_size(p_column);
if (p_column == 0) {
item_size.width += cache.item_margin * depth;
+ } else {
+ item_size.width += cache.hseparation;
}
+
+ // Check if the item is wider.
min_width = MAX(min_width, item_size.width);
}
}
@@ -4068,9 +4112,6 @@ int Tree::get_column_width(int p_column) const {
}
}
- if (p_column < columns.size() - 1) {
- column_width += cache.hseparation;
- }
return column_width;
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 85fed941dc..c4a6b6b058 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -95,6 +95,9 @@ private:
bool expand_right = false;
Color icon_color = Color(1, 1, 1);
+ Size2i cached_minimum_size;
+ bool cached_minimum_size_dirty = true;
+
TextAlign text_align = ALIGN_LEFT;
Variant meta;
@@ -130,9 +133,6 @@ private:
bool disable_folding = false;
int custom_min_height = 0;
- Size2i cached_minimum_size;
- bool cached_minimum_size_dirty = true;
-
TreeItem *parent = nullptr; // parent item
TreeItem *prev = nullptr; // previous in list
TreeItem *next = nullptr; // next in list
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index f24d880045..14fd14dd18 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -104,9 +104,11 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
CharString charstr = p_request_data.utf8();
size_t len = charstr.length();
- raw_data.resize(len);
- uint8_t *w = raw_data.ptrw();
- memcpy(w, charstr.ptr(), len);
+ if (len > 0) {
+ raw_data.resize(len);
+ uint8_t *w = raw_data.ptrw();
+ memcpy(w, charstr.ptr(), len);
+ }
return request_raw(p_url, p_custom_headers, p_ssl_validate_domain, p_method, raw_data);
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index f5d2d2f2a2..db5f714b99 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -114,8 +114,8 @@ void Node::_notification(int p_notification) {
memdelete(data.path_cache);
data.path_cache = nullptr;
}
- if (data.filename.length()) {
- get_multiplayer()->scene_enter_exit_notify(data.filename, this, false);
+ if (data.scene_file_path.length()) {
+ get_multiplayer()->scene_enter_exit_notify(data.scene_file_path, this, false);
}
} break;
case NOTIFICATION_PATH_CHANGED: {
@@ -146,9 +146,9 @@ void Node::_notification(int p_notification) {
GDVIRTUAL_CALL(_ready);
- if (data.filename.length()) {
+ if (data.scene_file_path.length()) {
ERR_FAIL_COND(!is_inside_tree());
- get_multiplayer()->scene_enter_exit_notify(data.filename, this, true);
+ get_multiplayer()->scene_enter_exit_notify(data.scene_file_path, this, true);
}
} break;
@@ -235,7 +235,7 @@ void Node::_propagate_enter_tree() {
data.blocked--;
#ifdef DEBUG_ENABLED
- SceneDebugger::add_to_cache(data.filename, this);
+ SceneDebugger::add_to_cache(data.scene_file_path, this);
#endif
// enter groups
}
@@ -253,7 +253,7 @@ void Node::_propagate_exit_tree() {
//block while removing children
#ifdef DEBUG_ENABLED
- SceneDebugger::remove_from_cache(data.filename, this);
+ SceneDebugger::remove_from_cache(data.scene_file_path, this);
#endif
data.blocked++;
@@ -1846,12 +1846,12 @@ void Node::remove_and_skip() {
data.parent->remove_child(this);
}
-void Node::set_filename(const String &p_filename) {
- data.filename = p_filename;
+void Node::set_scene_file_path(const String &p_scene_file_path) {
+ data.scene_file_path = p_scene_file_path;
}
-String Node::get_filename() const {
- return data.filename;
+String Node::get_scene_file_path() const {
+ return data.scene_file_path;
}
void Node::set_editor_description(const String &p_editor_description) {
@@ -1948,8 +1948,8 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
nip->set_instance_path(ip->get_instance_path());
node = nip;
- } else if ((p_flags & DUPLICATE_USE_INSTANCING) && get_filename() != String()) {
- Ref<PackedScene> res = ResourceLoader::load(get_filename());
+ } else if ((p_flags & DUPLICATE_USE_INSTANCING) && get_scene_file_path() != String()) {
+ Ref<PackedScene> res = ResourceLoader::load(get_scene_file_path());
ERR_FAIL_COND_V(res.is_null(), nullptr);
PackedScene::GenEditState ges = PackedScene::GEN_EDIT_STATE_DISABLED;
#ifdef TOOLS_ENABLED
@@ -1972,8 +1972,8 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
ERR_FAIL_COND_V(!node, nullptr);
}
- if (get_filename() != "") { //an instance
- node->set_filename(get_filename());
+ if (get_scene_file_path() != "") { //an instance
+ node->set_scene_file_path(get_scene_file_path());
node->data.editable_instance = data.editable_instance;
}
@@ -2004,7 +2004,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
node_tree.push_back(descendant);
- if (descendant->get_filename() != "" && instance_roots.has(descendant->get_owner())) {
+ if (descendant->get_scene_file_path() != "" && instance_roots.has(descendant->get_owner())) {
instance_roots.push_back(descendant);
}
}
@@ -2313,7 +2313,7 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) {
owned_by_owner[i]->set_owner(owner);
}
- p_node->set_filename(get_filename());
+ p_node->set_scene_file_path(get_scene_file_path());
}
void Node::_replace_connections_target(Node *p_new_target) {
@@ -2693,8 +2693,8 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_index", "include_internal"), &Node::get_index, DEFVAL(false));
ClassDB::bind_method(D_METHOD("print_tree"), &Node::print_tree);
ClassDB::bind_method(D_METHOD("print_tree_pretty"), &Node::print_tree_pretty);
- ClassDB::bind_method(D_METHOD("set_filename", "filename"), &Node::set_filename);
- ClassDB::bind_method(D_METHOD("get_filename"), &Node::get_filename);
+ ClassDB::bind_method(D_METHOD("set_scene_file_path", "scene_file_path"), &Node::set_scene_file_path);
+ ClassDB::bind_method(D_METHOD("get_scene_file_path"), &Node::get_scene_file_path);
ClassDB::bind_method(D_METHOD("propagate_notification", "what"), &Node::propagate_notification);
ClassDB::bind_method(D_METHOD("propagate_call", "method", "args", "parent_first"), &Node::propagate_call, DEFVAL(Array()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_physics_process", "enable"), &Node::set_physics_process);
@@ -2839,7 +2839,7 @@ void Node::_bind_methods() {
ADD_SIGNAL(MethodInfo("tree_exited"));
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_name", "get_name");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_filename", "get_filename");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "scene_file_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_scene_file_path", "get_scene_file_path");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_owner", "get_owner");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "", "get_multiplayer");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "set_custom_multiplayer", "get_custom_multiplayer");
diff --git a/scene/main/node.h b/scene/main/node.h
index 198501eeac..7d4c79cfba 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -96,7 +96,7 @@ private:
};
struct Data {
- String filename;
+ String scene_file_path;
Ref<SceneState> instance_state;
Ref<SceneState> inherited_state;
@@ -353,8 +353,8 @@ public:
void print_tree();
void print_tree_pretty();
- void set_filename(const String &p_filename);
- String get_filename() const;
+ void set_scene_file_path(const String &p_scene_file_path);
+ String get_scene_file_path() const;
void set_editor_description(const String &p_editor_description);
String get_editor_description() const;
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 6e78193717..3d07e4473d 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1105,7 +1105,7 @@ Error SceneTree::change_scene_to(const Ref<PackedScene> &p_scene) {
Error SceneTree::reload_current_scene() {
ERR_FAIL_COND_V(!current_scene, ERR_UNCONFIGURED);
- String fname = current_scene->get_filename();
+ String fname = current_scene->get_scene_file_path();
return change_scene(fname);
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 59faa50114..9722570060 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -384,7 +384,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// save the child instantiated scenes that are chosen as editable, so they can be restored
// upon load back
- if (p_node != p_owner && p_node->get_filename() != String() && p_owner->is_editable_instance(p_node)) {
+ if (p_node != p_owner && p_node->get_scene_file_path() != String() && p_owner->is_editable_instance(p_node)) {
editable_instances.push_back(p_owner->get_path_to(p_node));
// Node is the root of an editable instance.
is_editable_instance = true;
@@ -437,14 +437,14 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
}
- if (p_node->get_filename() != String() && p_node->get_owner() == p_owner && instantiated_by_owner) {
+ if (p_node->get_scene_file_path() != String() && p_node->get_owner() == p_owner && instantiated_by_owner) {
if (p_node->get_scene_instance_load_placeholder()) {
//it's a placeholder, use the placeholder path
- nd.instance = _vm_get_variant(p_node->get_filename(), variant_map);
+ nd.instance = _vm_get_variant(p_node->get_scene_file_path(), variant_map);
nd.instance |= FLAG_INSTANCE_IS_PLACEHOLDER;
} else {
//must instance ourselves
- Ref<PackedScene> instance = ResourceLoader::load(p_node->get_filename());
+ Ref<PackedScene> instance = ResourceLoader::load(p_node->get_scene_file_path());
if (!instance.is_valid()) {
return ERR_CANT_OPEN;
}
@@ -454,7 +454,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
n = nullptr;
} else {
- if (n->get_filename() != String()) {
+ if (n->get_scene_file_path() != String()) {
//is an instance
Ref<SceneState> state = n->get_scene_instance_state();
if (state.is_valid()) {
@@ -714,7 +714,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
ERR_CONTINUE(!common_parent);
- if (common_parent != p_owner && common_parent->get_filename() == String()) {
+ if (common_parent != p_owner && common_parent->get_scene_file_path() == String()) {
common_parent = common_parent->get_owner();
}
@@ -774,7 +774,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
nl = nullptr;
} else {
- if (nl->get_filename() != String()) {
+ if (nl->get_scene_file_path() != String()) {
//is an instance
Ref<SceneState> state = nl->get_scene_instance_state();
if (state.is_valid()) {
@@ -1652,7 +1652,7 @@ Node *PackedScene::instantiate(GenEditState p_edit_state) const {
}
if (get_path() != "" && get_path().find("::") == -1) {
- s->set_filename(get_path());
+ s->set_scene_file_path(get_path());
}
s->notification(Node::NOTIFICATION_INSTANCED);
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index e7da41db9d..f8be00f5fb 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -1390,6 +1390,12 @@ void QuadMesh::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_offset"), "set_center_offset", "get_center_offset");
}
+uint32_t QuadMesh::surface_get_format(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, 1, 0);
+
+ return RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_TANGENT | RS::ARRAY_FORMAT_TEX_UV;
+}
+
QuadMesh::QuadMesh() {
primitive_type = PRIMITIVE_TRIANGLES;
}
@@ -1460,7 +1466,7 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
} else {
Vector3 p = Vector3(x * radius * w, y, z * radius * w);
points.push_back(p);
- Vector3 normal = Vector3(x * radius * w * scale, y / scale, z * radius * w * scale);
+ Vector3 normal = Vector3(x * w * scale, radius * (y / scale), z * w * scale);
normals.push_back(normal.normalized());
};
ADD_TANGENT(z, 0.0, -x, 1.0)
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 7915cb0028..d447dad97a 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -285,6 +285,8 @@ protected:
virtual void _create_mesh_array(Array &p_arr) const override;
public:
+ virtual uint32_t surface_get_format(int p_idx) const override;
+
QuadMesh();
void set_size(const Size2 &p_size);
diff --git a/scene/resources/skeleton_modification_2d.cpp b/scene/resources/skeleton_modification_2d.cpp
index e533fb054a..7ac40b497d 100644
--- a/scene/resources/skeleton_modification_2d.cpp
+++ b/scene/resources/skeleton_modification_2d.cpp
@@ -96,37 +96,25 @@ float SkeletonModification2D::clamp_angle(float p_angle, float p_min_bound, floa
p_max_bound = Math_TAU + p_max_bound;
}
if (p_min_bound > p_max_bound) {
- float tmp = p_min_bound;
- p_min_bound = p_max_bound;
- p_max_bound = tmp;
+ SWAP(p_min_bound, p_max_bound);
}
+ bool is_beyond_bounds = (p_angle < p_min_bound || p_angle > p_max_bound);
+ bool is_within_bounds = (p_angle > p_min_bound && p_angle < p_max_bound);
+
// Note: May not be the most optimal way to clamp, but it always constraints to the nearest angle.
- if (p_invert == false) {
- if (p_angle < p_min_bound || p_angle > p_max_bound) {
- Vector2 min_bound_vec = Vector2(Math::cos(p_min_bound), Math::sin(p_min_bound));
- Vector2 max_bound_vec = Vector2(Math::cos(p_max_bound), Math::sin(p_max_bound));
- Vector2 angle_vec = Vector2(Math::cos(p_angle), Math::sin(p_angle));
-
- if (angle_vec.distance_squared_to(min_bound_vec) <= angle_vec.distance_squared_to(max_bound_vec)) {
- p_angle = p_min_bound;
- } else {
- p_angle = p_max_bound;
- }
- }
- } else {
- if (p_angle > p_min_bound && p_angle < p_max_bound) {
- Vector2 min_bound_vec = Vector2(Math::cos(p_min_bound), Math::sin(p_min_bound));
- Vector2 max_bound_vec = Vector2(Math::cos(p_max_bound), Math::sin(p_max_bound));
- Vector2 angle_vec = Vector2(Math::cos(p_angle), Math::sin(p_angle));
+ if ((!p_invert && is_beyond_bounds) || (p_invert && is_within_bounds)) {
+ Vector2 min_bound_vec = Vector2(Math::cos(p_min_bound), Math::sin(p_min_bound));
+ Vector2 max_bound_vec = Vector2(Math::cos(p_max_bound), Math::sin(p_max_bound));
+ Vector2 angle_vec = Vector2(Math::cos(p_angle), Math::sin(p_angle));
- if (angle_vec.distance_squared_to(min_bound_vec) <= angle_vec.distance_squared_to(max_bound_vec)) {
- p_angle = p_min_bound;
- } else {
- p_angle = p_max_bound;
- }
+ if (angle_vec.distance_squared_to(min_bound_vec) <= angle_vec.distance_squared_to(max_bound_vec)) {
+ p_angle = p_min_bound;
+ } else {
+ p_angle = p_max_bound;
}
}
+
return p_angle;
}
@@ -152,9 +140,7 @@ void SkeletonModification2D::editor_draw_angle_constraints(Bone2D *p_operation_b
arc_angle_max = (Math_PI * 2) + arc_angle_max;
}
if (arc_angle_min > arc_angle_max) {
- float tmp = arc_angle_min;
- arc_angle_min = arc_angle_max;
- arc_angle_max = tmp;
+ SWAP(arc_angle_min, arc_angle_max);
}
arc_angle_min += p_operation_bone->get_bone_angle();
arc_angle_max += p_operation_bone->get_bone_angle();
diff --git a/scene/resources/skeleton_modification_2d_fabrik.cpp b/scene/resources/skeleton_modification_2d_fabrik.cpp
index 6e9429034f..3b5c555f89 100644
--- a/scene/resources/skeleton_modification_2d_fabrik.cpp
+++ b/scene/resources/skeleton_modification_2d_fabrik.cpp
@@ -247,7 +247,7 @@ void SkeletonModification2DFABRIK::chain_backwards() {
}
float current_bone2d_node_length = current_bone2d_node->get_length() * MIN(current_bone2d_node->get_global_scale().x, current_bone2d_node->get_global_scale().y);
- float length = current_bone2d_node_length / (previous_pose.get_origin() - current_pose.get_origin()).length();
+ float length = current_bone2d_node_length / (current_pose.get_origin().distance_to(previous_pose.get_origin()));
Vector2 finish_position = previous_pose.get_origin().lerp(current_pose.get_origin(), length);
current_pose.set_origin(finish_position);
@@ -268,7 +268,7 @@ void SkeletonModification2DFABRIK::chain_forwards() {
Transform2D next_pose = fabrik_transform_chain[i + 1];
float current_bone2d_node_length = current_bone2d_node->get_length() * MIN(current_bone2d_node->get_global_scale().x, current_bone2d_node->get_global_scale().y);
- float length = current_bone2d_node_length / (current_pose.get_origin() - next_pose.get_origin()).length();
+ float length = current_bone2d_node_length / (next_pose.get_origin().distance_to(current_pose.get_origin()));
Vector2 finish_position = current_pose.get_origin().lerp(next_pose.get_origin(), length);
current_pose.set_origin(finish_position);
diff --git a/scene/resources/skeleton_modification_2d_twoboneik.cpp b/scene/resources/skeleton_modification_2d_twoboneik.cpp
index 88d80a501f..4f752896a9 100644
--- a/scene/resources/skeleton_modification_2d_twoboneik.cpp
+++ b/scene/resources/skeleton_modification_2d_twoboneik.cpp
@@ -144,7 +144,7 @@ void SkeletonModification2DTwoBoneIK::_execute(float p_delta) {
// With modifications by TwistedTwigleg
Vector2 target_difference = target->get_global_position() - joint_one_bone->get_global_position();
float joint_one_to_target = target_difference.length();
- float angle_atan = Math::atan2(target_difference.y, target_difference.x);
+ float angle_atan = target_difference.angle();
float bone_one_length = joint_one_bone->get_length() * MIN(joint_one_bone->get_global_scale().x, joint_one_bone->get_global_scale().y);
float bone_two_length = joint_two_bone->get_length() * MIN(joint_two_bone->get_global_scale().x, joint_two_bone->get_global_scale().y);
diff --git a/scene/resources/skeleton_modification_3d.cpp b/scene/resources/skeleton_modification_3d.cpp
index ee02ede2d5..b476952d86 100644
--- a/scene/resources/skeleton_modification_3d.cpp
+++ b/scene/resources/skeleton_modification_3d.cpp
@@ -72,37 +72,25 @@ real_t SkeletonModification3D::clamp_angle(real_t p_angle, real_t p_min_bound, r
p_max_bound = Math_TAU + p_max_bound;
}
if (p_min_bound > p_max_bound) {
- real_t tmp = p_min_bound;
- p_min_bound = p_max_bound;
- p_max_bound = tmp;
+ SWAP(p_min_bound, p_max_bound);
}
+ bool is_beyond_bounds = (p_angle < p_min_bound || p_angle > p_max_bound);
+ bool is_within_bounds = (p_angle > p_min_bound && p_angle < p_max_bound);
+
// Note: May not be the most optimal way to clamp, but it always constraints to the nearest angle.
- if (p_invert == false) {
- if (p_angle < p_min_bound || p_angle > p_max_bound) {
- Vector2 min_bound_vec = Vector2(Math::cos(p_min_bound), Math::sin(p_min_bound));
- Vector2 max_bound_vec = Vector2(Math::cos(p_max_bound), Math::sin(p_max_bound));
- Vector2 angle_vec = Vector2(Math::cos(p_angle), Math::sin(p_angle));
-
- if (angle_vec.distance_squared_to(min_bound_vec) <= angle_vec.distance_squared_to(max_bound_vec)) {
- p_angle = p_min_bound;
- } else {
- p_angle = p_max_bound;
- }
- }
- } else {
- if (p_angle > p_min_bound && p_angle < p_max_bound) {
- Vector2 min_bound_vec = Vector2(Math::cos(p_min_bound), Math::sin(p_min_bound));
- Vector2 max_bound_vec = Vector2(Math::cos(p_max_bound), Math::sin(p_max_bound));
- Vector2 angle_vec = Vector2(Math::cos(p_angle), Math::sin(p_angle));
-
- if (angle_vec.distance_squared_to(min_bound_vec) <= angle_vec.distance_squared_to(max_bound_vec)) {
- p_angle = p_min_bound;
- } else {
- p_angle = p_max_bound;
- }
+ if ((!p_invert && is_beyond_bounds) || (p_invert && is_within_bounds)) {
+ Vector2 min_bound_vec = Vector2(Math::cos(p_min_bound), Math::sin(p_min_bound));
+ Vector2 max_bound_vec = Vector2(Math::cos(p_max_bound), Math::sin(p_max_bound));
+ Vector2 angle_vec = Vector2(Math::cos(p_angle), Math::sin(p_angle));
+
+ if (angle_vec.distance_squared_to(min_bound_vec) <= angle_vec.distance_squared_to(max_bound_vec)) {
+ p_angle = p_min_bound;
+ } else {
+ p_angle = p_max_bound;
}
}
+
return p_angle;
}
diff --git a/scene/resources/skeleton_modification_3d_fabrik.cpp b/scene/resources/skeleton_modification_3d_fabrik.cpp
index 69f75eb7b5..e615615924 100644
--- a/scene/resources/skeleton_modification_3d_fabrik.cpp
+++ b/scene/resources/skeleton_modification_3d_fabrik.cpp
@@ -232,7 +232,7 @@ void SkeletonModification3DFABRIK::chain_backwards() {
int current_bone_idx = fabrik_data_chain[i].bone_idx;
Transform3D current_trans = stack->skeleton->local_pose_to_global_pose(current_bone_idx, stack->skeleton->get_bone_local_pose_override(current_bone_idx));
- real_t length = fabrik_data_chain[i].length / (next_bone_trans.origin - current_trans.origin).length();
+ real_t length = fabrik_data_chain[i].length / (current_trans.origin.distance_to(next_bone_trans.origin));
current_trans.origin = next_bone_trans.origin.lerp(current_trans.origin, length);
// Apply it back to the skeleton
@@ -253,7 +253,7 @@ void SkeletonModification3DFABRIK::chain_forwards() {
int next_bone_idx = fabrik_data_chain[i + 1].bone_idx;
Transform3D next_bone_trans = stack->skeleton->local_pose_to_global_pose(next_bone_idx, stack->skeleton->get_bone_local_pose_override(next_bone_idx));
- real_t length = fabrik_data_chain[i].length / (current_trans.origin - next_bone_trans.origin).length();
+ real_t length = fabrik_data_chain[i].length / (next_bone_trans.origin.distance_to(current_trans.origin));
next_bone_trans.origin = current_trans.origin.lerp(next_bone_trans.origin, length);
// Apply it back to the skeleton
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index d5e370568d..a8cd872408 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -1176,6 +1176,7 @@ Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun
ERR_FAIL_COND_V(simplify_func == nullptr, lod);
ERR_FAIL_COND_V(vertex_array.size() == 0, lod);
ERR_FAIL_COND_V(index_array.size() == 0, lod);
+ ERR_FAIL_COND_V(index_array.size() % 3 != 0, lod);
lod.resize(index_array.size());
LocalVector<float> vertices; //uses floats
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 3dc32632cc..1b3a7a5f2a 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1248,6 +1248,14 @@ bool AtlasTexture::is_pixel_opaque(int p_x, int p_y) const {
return atlas->is_pixel_opaque(x, y);
}
+Ref<Image> AtlasTexture::get_image() const {
+ if (!atlas.is_valid() || !atlas->get_image().is_valid()) {
+ return Ref<Image>();
+ }
+
+ return atlas->get_image()->get_rect(region);
+}
+
AtlasTexture::AtlasTexture() {}
/////////////////////////////////////////
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 93f4e2de5a..862b9a47a6 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -250,6 +250,8 @@ public:
bool is_pixel_opaque(int p_x, int p_y) const override;
+ virtual Ref<Image> get_image() const override;
+
AtlasTexture();
};
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 67cbd0e094..15e622c9d6 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -1019,20 +1019,25 @@ Vector<Vector2> TileSet::get_tile_shape_polygon() {
void TileSet::draw_tile_shape(CanvasItem *p_canvas_item, Transform2D p_transform, Color p_color, bool p_filled, Ref<Texture2D> p_texture) {
if (tile_meshes_dirty) {
- Vector<Vector2> uvs = get_tile_shape_polygon();
+ Vector<Vector2> shape = get_tile_shape_polygon();
+ Vector<Vector2> uvs;
+ uvs.resize(shape.size());
+ for (int i = 0; i < shape.size(); i++) {
+ uvs.write[i] = shape[i] + Vector2(0.5, 0.5);
+ }
Vector<Color> colors;
- colors.resize(uvs.size());
+ colors.resize(shape.size());
colors.fill(Color(1.0, 1.0, 1.0, 1.0));
// Filled mesh.
tile_filled_mesh->clear_surfaces();
Array a;
a.resize(Mesh::ARRAY_MAX);
- a[Mesh::ARRAY_VERTEX] = uvs;
+ a[Mesh::ARRAY_VERTEX] = shape;
a[Mesh::ARRAY_TEX_UV] = uvs;
a[Mesh::ARRAY_COLOR] = colors;
- a[Mesh::ARRAY_INDEX] = Geometry2D::triangulate_polygon(uvs);
+ a[Mesh::ARRAY_INDEX] = Geometry2D::triangulate_polygon(shape);
tile_filled_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
// Lines mesh.
@@ -1040,9 +1045,9 @@ void TileSet::draw_tile_shape(CanvasItem *p_canvas_item, Transform2D p_transform
a.clear();
a.resize(Mesh::ARRAY_MAX);
// Add the first point again when drawing lines.
- uvs.push_back(uvs[0]);
+ shape.push_back(shape[0]);
colors.push_back(colors[0]);
- a[Mesh::ARRAY_VERTEX] = uvs;
+ a[Mesh::ARRAY_VERTEX] = shape;
a[Mesh::ARRAY_COLOR] = colors;
tile_lines_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINE_STRIP, a, Array(), Dictionary(), Mesh::ARRAY_FLAG_USE_2D_VERTICES);
@@ -3119,7 +3124,7 @@ Vector2i TileSetAtlasSource::get_atlas_grid_size() const {
}
bool TileSetAtlasSource::_set(const StringName &p_name, const Variant &p_value) {
- Vector<String> components = String(p_name).split("/", true, 3);
+ Vector<String> components = String(p_name).split("/", true, 2);
// Compute the vector2i if we have coordinates.
Vector<String> coords_split = components[0].split(":");
@@ -3520,6 +3525,13 @@ Vector2i TileSetAtlasSource::get_tile_id(int p_index) const {
}
bool TileSetAtlasSource::has_room_for_tile(Vector2i p_atlas_coords, Vector2i p_size, int p_animation_columns, Vector2i p_animation_separation, int p_frames_count, Vector2i p_ignored_tile) const {
+ if (p_atlas_coords.x < 0 || p_atlas_coords.y < 0) {
+ return false;
+ }
+ if (p_size.x <= 0 || p_size.y <= 0) {
+ return false;
+ }
+ Size2i atlas_grid_size = get_atlas_grid_size();
for (int frame = 0; frame < p_frames_count; frame++) {
Vector2i frame_coords = p_atlas_coords + (p_size + p_animation_separation) * ((p_animation_columns > 0) ? Vector2i(frame % p_animation_columns, frame / p_animation_columns) : Vector2i(frame, 0));
for (int x = 0; x < p_size.x; x++) {
@@ -3528,6 +3540,11 @@ bool TileSetAtlasSource::has_room_for_tile(Vector2i p_atlas_coords, Vector2i p_s
if (_coords_mapping_cache.has(coords) && _coords_mapping_cache[coords] != p_ignored_tile) {
return false;
}
+ if (coords.x >= atlas_grid_size.x || coords.y >= atlas_grid_size.y) {
+ if (!(_coords_mapping_cache.has(coords) && _coords_mapping_cache[coords] == p_ignored_tile)) {
+ return false; // Only accept tiles outside the atlas if they are part of the ignored tile.
+ }
+ }
}
}
}
@@ -3558,8 +3575,7 @@ Vector2i TileSetAtlasSource::get_tile_effective_texture_offset(Vector2i p_atlas_
margin = Vector2i(MAX(0, margin.x), MAX(0, margin.y));
Vector2i effective_texture_offset = Object::cast_to<TileData>(get_tile_data(p_atlas_coords, p_alternative_tile))->get_texture_offset();
if (ABS(effective_texture_offset.x) > margin.x || ABS(effective_texture_offset.y) > margin.y) {
- effective_texture_offset.x = CLAMP(effective_texture_offset.x, -margin.x, margin.x);
- effective_texture_offset.y = CLAMP(effective_texture_offset.y, -margin.y, margin.y);
+ effective_texture_offset = effective_texture_offset.clamp(-margin, margin);
}
return effective_texture_offset;
@@ -4300,9 +4316,26 @@ Ref<OccluderPolygon2D> TileData::get_occluder(int p_layer_id) const {
}
// Physics
-int TileData::get_collision_polygons_count(int p_layer_id) const {
- ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0);
- return physics[p_layer_id].polygons.size();
+void TileData::set_constant_linear_velocity(int p_layer_id, const Vector2 &p_velocity) {
+ ERR_FAIL_INDEX(p_layer_id, physics.size());
+ physics.write[p_layer_id].linear_velocity = p_velocity;
+ emit_signal(SNAME("changed"));
+}
+
+Vector2 TileData::get_constant_linear_velocity(int p_layer_id) const {
+ ERR_FAIL_INDEX_V(p_layer_id, physics.size(), Vector2());
+ return physics[p_layer_id].linear_velocity;
+}
+
+void TileData::set_constant_angular_velocity(int p_layer_id, real_t p_velocity) {
+ ERR_FAIL_INDEX(p_layer_id, physics.size());
+ physics.write[p_layer_id].angular_velocity = p_velocity;
+ emit_signal(SNAME("changed"));
+}
+
+real_t TileData::get_constant_angular_velocity(int p_layer_id) const {
+ ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0.0);
+ return physics[p_layer_id].angular_velocity;
}
void TileData::set_collision_polygons_count(int p_layer_id, int p_polygons_count) {
@@ -4313,6 +4346,11 @@ void TileData::set_collision_polygons_count(int p_layer_id, int p_polygons_count
emit_signal(SNAME("changed"));
}
+int TileData::get_collision_polygons_count(int p_layer_id) const {
+ ERR_FAIL_INDEX_V(p_layer_id, physics.size(), 0);
+ return physics[p_layer_id].polygons.size();
+}
+
void TileData::add_collision_polygon(int p_layer_id) {
ERR_FAIL_INDEX(p_layer_id, physics.size());
physics.write[p_layer_id].polygons.push_back(PhysicsLayerTileData::PolygonShapeTileData());
@@ -4514,11 +4552,7 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
// Physics layers.
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
- if (components.size() == 2 && components[1] == "polygons_count") {
- if (p_value.get_type() != Variant::INT) {
- return false;
- }
-
+ if (components.size() == 2) {
if (layer_index >= physics.size()) {
if (tile_set) {
return false;
@@ -4526,8 +4560,19 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
physics.resize(layer_index + 1);
}
}
- set_collision_polygons_count(layer_index, p_value);
- return true;
+ if (components[1] == "linear_velocity") {
+ set_constant_linear_velocity(layer_index, p_value);
+ return true;
+ } else if (components[1] == "angular_velocity") {
+ set_constant_angular_velocity(layer_index, p_value);
+ return true;
+ } else if (components[1] == "polygons_count") {
+ if (p_value.get_type() != Variant::INT) {
+ return false;
+ }
+ set_collision_polygons_count(layer_index, p_value);
+ return true;
+ }
} else if (components.size() == 3 && components[1].begins_with("polygon_") && components[1].trim_prefix("polygon_").is_valid_int()) {
int polygon_index = components[1].trim_prefix("polygon_").to_int();
ERR_FAIL_COND_V(polygon_index < 0, false);
@@ -4629,9 +4674,18 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
if (layer_index >= physics.size()) {
return false;
}
- if (components.size() == 2 && components[1] == "polygons_count") {
- r_ret = get_collision_polygons_count(layer_index);
- return true;
+
+ if (components.size() == 2) {
+ if (components[1] == "linear_velocity") {
+ r_ret = get_constant_linear_velocity(layer_index);
+ return true;
+ } else if (components[1] == "angular_velocity") {
+ r_ret = get_constant_angular_velocity(layer_index);
+ return true;
+ } else if (components[1] == "polygons_count") {
+ r_ret = get_collision_polygons_count(layer_index);
+ return true;
+ }
} else if (components.size() == 3 && components[1].begins_with("polygon_") && components[1].trim_prefix("polygon_").is_valid_int()) {
int polygon_index = components[1].trim_prefix("polygon_").to_int();
ERR_FAIL_COND_V(polygon_index < 0, false);
@@ -4702,6 +4756,8 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
// Physics layers.
p_list->push_back(PropertyInfo(Variant::NIL, "Physics", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
for (int i = 0; i < physics.size(); i++) {
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, vformat("physics_layer_%d/linear_velocity", i), PROPERTY_HINT_NONE));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("physics_layer_%d/angular_velocity", i), PROPERTY_HINT_NONE));
p_list->push_back(PropertyInfo(Variant::INT, vformat("physics_layer_%d/polygons_count", i), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
for (int j = 0; j < physics[i].polygons.size(); j++) {
@@ -4791,8 +4847,12 @@ void TileData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_occluder", "layer_id"), &TileData::get_occluder);
// Physics.
- ClassDB::bind_method(D_METHOD("get_collision_polygons_count", "layer_id"), &TileData::get_collision_polygons_count);
+ ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "layer_id", "velocity"), &TileData::set_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_linear_velocity", "layer_id"), &TileData::get_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "layer_id", "velocity"), &TileData::set_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_angular_velocity", "layer_id"), &TileData::get_constant_angular_velocity);
ClassDB::bind_method(D_METHOD("set_collision_polygons_count", "layer_id", "polygons_count"), &TileData::set_collision_polygons_count);
+ ClassDB::bind_method(D_METHOD("get_collision_polygons_count", "layer_id"), &TileData::get_collision_polygons_count);
ClassDB::bind_method(D_METHOD("add_collision_polygon", "layer_id"), &TileData::add_collision_polygon);
ClassDB::bind_method(D_METHOD("remove_collision_polygon", "layer_id", "polygon_index"), &TileData::remove_collision_polygon);
ClassDB::bind_method(D_METHOD("set_collision_polygon_points", "layer_id", "polygon_index", "polygon"), &TileData::set_collision_polygon_points);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 46cb1fb36d..42b82957fb 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -645,6 +645,8 @@ private:
float one_way_margin = 1.0;
};
+ Vector2 linear_velocity;
+ float angular_velocity;
Vector<PolygonShapeTileData> polygons;
};
Vector<PhysicsLayerTileData> physics;
@@ -718,8 +720,12 @@ public:
Ref<OccluderPolygon2D> get_occluder(int p_layer_id) const;
// Physics
- int get_collision_polygons_count(int p_layer_id) const;
+ void set_constant_linear_velocity(int p_layer_id, const Vector2 &p_velocity);
+ Vector2 get_constant_linear_velocity(int p_layer_id) const;
+ void set_constant_angular_velocity(int p_layer_id, real_t p_velocity);
+ real_t get_constant_angular_velocity(int p_layer_id) const;
void set_collision_polygons_count(int p_layer_id, int p_shapes_count);
+ int get_collision_polygons_count(int p_layer_id) const;
void add_collision_polygon(int p_layer_id);
void remove_collision_polygon(int p_layer_id, int p_polygon_index);
void set_collision_polygon_points(int p_layer_id, int p_polygon_index, Vector<Vector2> p_polygon);
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index edd769aa9a..38b98b7bca 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -113,7 +113,7 @@ void Body2DSW::update_mass_properties() {
_inv_inertia = 0;
_inv_mass = 0;
} break;
- case PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED: {
+ case PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR: {
_inv_inertia = 0;
_inv_mass = 1.0 / mass;
@@ -257,7 +257,7 @@ void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
set_active(true);
} break;
- case PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED: {
+ case PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = 0;
angular_velocity = 0;
diff --git a/servers/physics_2d/body_direct_state_2d_sw.cpp b/servers/physics_2d/body_direct_state_2d_sw.cpp
index 58250c3077..22a5fc2b36 100644
--- a/servers/physics_2d/body_direct_state_2d_sw.cpp
+++ b/servers/physics_2d/body_direct_state_2d_sw.cpp
@@ -59,6 +59,7 @@ real_t PhysicsDirectBodyState2DSW::get_inverse_inertia() const {
}
void PhysicsDirectBodyState2DSW::set_linear_velocity(const Vector2 &p_velocity) {
+ body->set_active(true);
body->set_linear_velocity(p_velocity);
}
@@ -67,6 +68,7 @@ Vector2 PhysicsDirectBodyState2DSW::get_linear_velocity() const {
}
void PhysicsDirectBodyState2DSW::set_angular_velocity(real_t p_velocity) {
+ body->set_active(true);
body->set_angular_velocity(p_velocity);
}
@@ -87,26 +89,32 @@ Vector2 PhysicsDirectBodyState2DSW::get_velocity_at_local_position(const Vector2
}
void PhysicsDirectBodyState2DSW::add_central_force(const Vector2 &p_force) {
+ body->set_active(true);
body->add_central_force(p_force);
}
void PhysicsDirectBodyState2DSW::add_force(const Vector2 &p_force, const Vector2 &p_position) {
+ body->set_active(true);
body->add_force(p_force, p_position);
}
void PhysicsDirectBodyState2DSW::add_torque(real_t p_torque) {
+ body->set_active(true);
body->add_torque(p_torque);
}
void PhysicsDirectBodyState2DSW::apply_central_impulse(const Vector2 &p_impulse) {
+ body->set_active(true);
body->apply_central_impulse(p_impulse);
}
void PhysicsDirectBodyState2DSW::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) {
+ body->set_active(true);
body->apply_impulse(p_impulse, p_position);
}
void PhysicsDirectBodyState2DSW::apply_torque_impulse(real_t p_torque) {
+ body->set_active(true);
body->apply_torque_impulse(p_torque);
}
@@ -167,7 +175,7 @@ Variant PhysicsDirectBodyState2DSW::get_contact_collider_shape_metadata(int p_co
if (!PhysicsServer2DSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) {
return Variant();
}
- Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider);
+ Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.get_or_null(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/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index e052258a92..b4338217df 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -112,32 +112,32 @@ RID PhysicsServer2DSW::concave_polygon_shape_create() {
}
void PhysicsServer2DSW::shape_set_data(RID p_shape, const Variant &p_data) {
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
void PhysicsServer2DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
PhysicsServer2D::ShapeType PhysicsServer2DSW::shape_get_type(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.getornull(p_shape);
+ const Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.getornull(p_shape);
+ const Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
return shape->get_data();
};
real_t PhysicsServer2DSW::shape_get_custom_solver_bias(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.getornull(p_shape);
+ const Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
@@ -193,9 +193,9 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
}
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);
+ Shape2DSW *shape_A = shape_owner.get_or_null(p_shape_A);
ERR_FAIL_COND_V(!shape_A, false);
- Shape2DSW *shape_B = shape_owner.getornull(p_shape_B);
+ Shape2DSW *shape_B = shape_owner.get_or_null(p_shape_B);
ERR_FAIL_COND_V(!shape_B, false);
if (p_result_max == 0) {
@@ -218,7 +218,7 @@ RID PhysicsServer2DSW::space_create() {
RID id = space_owner.make_rid(space);
space->set_self(id);
RID area_id = area_create();
- Area2DSW *area = area_owner.getornull(area_id);
+ Area2DSW *area = area_owner.get_or_null(area_id);
ERR_FAIL_COND_V(!area, RID());
space->set_default_area(area);
area->set_space(space);
@@ -228,7 +228,7 @@ RID PhysicsServer2DSW::space_create() {
};
void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
if (p_active) {
active_spaces.insert(space);
@@ -238,45 +238,45 @@ void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) {
}
bool PhysicsServer2DSW::space_is_active(RID p_space) const {
- const Space2DSW *space = space_owner.getornull(p_space);
+ const Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, false);
return active_spaces.has(space);
}
void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
real_t PhysicsServer2DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
- const Space2DSW *space = space_owner.getornull(p_space);
+ const Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
void PhysicsServer2DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector2> PhysicsServer2DSW::space_get_contacts(RID p_space) const {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector2>());
return space->get_debug_contacts();
}
int PhysicsServer2DSW::space_get_contact_count(RID p_space) const {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space) {
- Space2DSW *space = space_owner.getornull(p_space);
+ Space2DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, nullptr);
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -291,12 +291,12 @@ RID PhysicsServer2DSW::area_create() {
};
void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
Space2DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -309,7 +309,7 @@ void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
};
RID PhysicsServer2DSW::area_get_space(RID p_area) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Space2DSW *space = area->get_space();
@@ -320,34 +320,34 @@ RID PhysicsServer2DSW::area_get_space(RID p_area) const {
};
void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_space_override_mode(p_mode);
}
PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_override_mode(RID p_area) const {
- const Area2DSW *area = area_owner.getornull(p_area);
+ const Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
return area->get_space_override_mode();
}
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);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
area->add_shape(shape, p_transform, p_disabled);
}
void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -355,14 +355,14 @@ void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
}
void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape, area->get_shape_count());
FLUSH_QUERY_CHECK(area);
@@ -371,14 +371,14 @@ void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_
}
int PhysicsServer2DSW::area_get_shape_count(RID p_area) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Shape2DSW *shape = area->get_shape(p_shape_idx);
@@ -388,21 +388,21 @@ RID PhysicsServer2DSW::area_get_shape(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);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
return area->get_shape_transform(p_shape_idx);
}
void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->remove_shape(p_shape_idx);
}
void PhysicsServer2DSW::area_clear_shapes(RID p_area) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
while (area->get_shape_count()) {
@@ -412,86 +412,86 @@ void PhysicsServer2DSW::area_clear_shapes(RID p_area) {
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);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_instance_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);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_canvas_instance_id(p_id);
}
ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.getornull(p_area);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_canvas_instance_id();
}
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);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
};
void PhysicsServer2DSW::area_set_transform(RID p_area, const Transform2D &p_transform) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
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);
+ Space2DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
};
Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
return area->get_transform();
};
void PhysicsServer2DSW::area_set_pickable(RID p_area, bool p_pickable) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_pickable(p_pickable);
}
void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -499,28 +499,28 @@ void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
}
void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area2DSW *area = area_owner.getornull(p_area);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), 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);
+ Area2DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
@@ -536,11 +536,11 @@ RID PhysicsServer2DSW::body_create() {
}
void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
Space2DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -553,7 +553,7 @@ void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
};
RID PhysicsServer2DSW::body_get_space(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Space2DSW *space = body->get_space();
@@ -564,7 +564,7 @@ RID PhysicsServer2DSW::body_get_space(RID p_body) const {
};
void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
FLUSH_QUERY_CHECK(body);
@@ -572,27 +572,27 @@ void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
};
PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
};
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);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
body->add_shape(shape, p_transform, p_disabled);
}
void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape2DSW *shape = shape_owner.getornull(p_shape);
+ Shape2DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -600,33 +600,33 @@ void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
}
void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
void PhysicsServer2DSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_shape_metadata(p_shape_idx, p_metadata);
}
Variant PhysicsServer2DSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_shape_metadata(p_shape_idx);
}
int PhysicsServer2DSW::body_get_shape_count(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Shape2DSW *shape = body->get_shape(p_shape_idx);
@@ -636,21 +636,21 @@ RID PhysicsServer2DSW::body_get_shape(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);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Transform2D());
return body->get_shape_transform(p_shape_idx);
}
void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_shape(p_shape_idx);
}
void PhysicsServer2DSW::body_clear_shapes(RID p_body) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
while (body->get_shape_count()) {
@@ -659,7 +659,7 @@ void PhysicsServer2DSW::body_clear_shapes(RID p_body) {
}
void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -668,7 +668,7 @@ void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
}
void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, real_t p_margin) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -677,109 +677,109 @@ void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh
}
void PhysicsServer2DSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection_mode(p_mode);
}
PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_detection_mode(RID p_body) const {
- const Body2DSW *body = body_owner.getornull(p_body);
+ const Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED);
return body->get_continuous_collision_detection_mode();
}
void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
};
ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
};
void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_canvas_instance_id(p_id);
};
ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_canvas_instance_id();
};
void PhysicsServer2DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
};
uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
};
void PhysicsServer2DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
};
uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
};
void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
};
Variant PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
};
void PhysicsServer2DSW::body_reset_mass_properties(RID p_body) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
return body->reset_mass_properties();
}
void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
};
Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
};
void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_force) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
@@ -787,13 +787,13 @@ void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_forc
};
Vector2 PhysicsServer2DSW::body_get_applied_force(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Vector2());
return body->get_applied_force();
};
void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
@@ -801,14 +801,14 @@ void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
};
real_t PhysicsServer2DSW::body_get_applied_torque(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_applied_torque();
};
void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
@@ -816,7 +816,7 @@ void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_
}
void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -826,7 +826,7 @@ void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
}
void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -836,7 +836,7 @@ void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_impulse,
};
void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_force) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_central_force(p_force);
@@ -844,7 +844,7 @@ void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_forc
};
void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_force(p_force, p_position);
@@ -852,7 +852,7 @@ void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_force, const
};
void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_torque(p_torque);
@@ -860,7 +860,7 @@ void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) {
};
void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -874,7 +874,7 @@ void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
};
void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
@@ -882,7 +882,7 @@ void PhysicsServer2DSW::body_add_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);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
@@ -890,7 +890,7 @@ void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b
};
void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -899,55 +899,55 @@ void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
void PhysicsServer2DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
};
real_t PhysicsServer2DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_omit_force_integration(p_omit);
};
bool PhysicsServer2DSW::body_is_omitting_force_integration(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
void PhysicsServer2DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
int PhysicsServer2DSW::body_get_max_contacts_reported(RID p_body) const {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void PhysicsServer2DSW::body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state_sync_callback(p_instance, p_callback);
}
void PhysicsServer2DSW::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_callable, p_udata);
}
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);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_INDEX_V(p_body_shape, body->get_shape_count(), false);
@@ -955,13 +955,13 @@ bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s
}
void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_pickable(p_pickable);
}
bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin, MotionResult *r_result, bool p_collide_separation_ray, const Set<RID> &p_exclude) {
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(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);
@@ -974,7 +974,7 @@ bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from,
PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
- Body2DSW *body = body_owner.getornull(p_body);
+ Body2DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, nullptr);
ERR_FAIL_COND_V(!body->get_space(), nullptr);
@@ -993,7 +993,7 @@ RID PhysicsServer2DSW::joint_create() {
}
void PhysicsServer2DSW::joint_clear(RID p_joint) {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
if (joint->get_type() != JOINT_TYPE_MAX) {
Joint2DSW *empty_joint = memnew(Joint2DSW);
empty_joint->copy_settings_from(joint);
@@ -1004,7 +1004,7 @@ void PhysicsServer2DSW::joint_clear(RID p_joint) {
}
void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
switch (p_param) {
@@ -1021,7 +1021,7 @@ void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t
}
real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const {
- const Joint2DSW *joint = joint_owner.getornull(p_joint);
+ const Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, -1);
switch (p_param) {
@@ -1040,7 +1040,7 @@ real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const
}
void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
@@ -1060,22 +1060,22 @@ void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, con
}
bool PhysicsServer2DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- const Joint2DSW *joint = joint_owner.getornull(p_joint);
+ const Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, true);
return joint->is_disabled_collisions_between_bodies();
}
void PhysicsServer2DSW::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
- Body2DSW *A = body_owner.getornull(p_body_a);
+ Body2DSW *A = body_owner.get_or_null(p_body_a);
ERR_FAIL_COND(!A);
Body2DSW *B = nullptr;
if (body_owner.owns(p_body_b)) {
- B = body_owner.getornull(p_body_b);
+ B = body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!B);
}
- Joint2DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint2DSW *joint = memnew(PinJoint2DSW(p_pos, A, B));
@@ -1086,13 +1086,13 @@ void PhysicsServer2DSW::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_
}
void PhysicsServer2DSW::joint_make_groove(RID p_joint, 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);
+ Body2DSW *A = body_owner.get_or_null(p_body_a);
ERR_FAIL_COND(!A);
- Body2DSW *B = body_owner.getornull(p_body_b);
+ Body2DSW *B = body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!B);
- Joint2DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint2DSW *joint = memnew(GrooveJoint2DSW(p_a_groove1, p_a_groove2, p_b_anchor, A, B));
@@ -1103,13 +1103,13 @@ void PhysicsServer2DSW::joint_make_groove(RID p_joint, const Vector2 &p_a_groove
}
void PhysicsServer2DSW::joint_make_damped_spring(RID p_joint, 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);
+ Body2DSW *A = body_owner.get_or_null(p_body_a);
ERR_FAIL_COND(!A);
- Body2DSW *B = body_owner.getornull(p_body_b);
+ Body2DSW *B = body_owner.get_or_null(p_body_b);
ERR_FAIL_COND(!B);
- Joint2DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint2DSW *joint = memnew(DampedSpringJoint2DSW(p_anchor_a, p_anchor_b, A, B));
@@ -1120,7 +1120,7 @@ void PhysicsServer2DSW::joint_make_damped_spring(RID p_joint, const Vector2 &p_a
}
void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_TYPE_PIN);
@@ -1129,7 +1129,7 @@ void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
}
real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_TYPE_PIN, 0);
@@ -1138,7 +1138,7 @@ real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
}
void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_TYPE_DAMPED_SPRING);
@@ -1147,7 +1147,7 @@ void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringP
}
real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const {
- Joint2DSW *j = joint_owner.getornull(p_joint);
+ Joint2DSW *j = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_TYPE_DAMPED_SPRING, 0);
@@ -1156,7 +1156,7 @@ real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSprin
}
PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const {
- Joint2DSW *joint = joint_owner.getornull(p_joint);
+ Joint2DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_TYPE_PIN);
return joint->get_type();
@@ -1166,7 +1166,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
_update_shapes(); // just in case
if (shape_owner.owns(p_rid)) {
- Shape2DSW *shape = shape_owner.getornull(p_rid);
+ Shape2DSW *shape = shape_owner.get_or_null(p_rid);
while (shape->get_owners().size()) {
ShapeOwner2DSW *so = shape->get_owners().front()->key();
@@ -1176,7 +1176,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
shape_owner.free(p_rid);
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
- Body2DSW *body = body_owner.getornull(p_rid);
+ Body2DSW *body = body_owner.get_or_null(p_rid);
/*
if (body->get_state_query())
@@ -1196,7 +1196,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
memdelete(body);
} else if (area_owner.owns(p_rid)) {
- Area2DSW *area = area_owner.getornull(p_rid);
+ Area2DSW *area = area_owner.get_or_null(p_rid);
/*
if (area->get_monitor_query())
@@ -1212,7 +1212,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
area_owner.free(p_rid);
memdelete(area);
} else if (space_owner.owns(p_rid)) {
- Space2DSW *space = space_owner.getornull(p_rid);
+ Space2DSW *space = space_owner.get_or_null(p_rid);
while (space->get_objects().size()) {
CollisionObject2DSW *co = (CollisionObject2DSW *)space->get_objects().front()->get();
@@ -1224,7 +1224,7 @@ void PhysicsServer2DSW::free(RID p_rid) {
space_owner.free(p_rid);
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
- Joint2DSW *joint = joint_owner.getornull(p_rid);
+ Joint2DSW *joint = joint_owner.get_or_null(p_rid);
joint_owner.free(p_rid);
memdelete(joint);
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index b9b26eb21d..df37b11c1b 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -34,6 +34,9 @@
#include "core/os/os.h"
#include "core/templates/pair.h"
#include "physics_server_2d_sw.h"
+
+#define TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR 0.05
+
_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)) {
return false;
@@ -203,7 +206,7 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
return 0;
}
- Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -248,7 +251,7 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
}
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 = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -335,7 +338,7 @@ bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &
return false;
}
- Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
@@ -432,9 +435,11 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
}
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 = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
+ real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR;
+
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
aabb = aabb.merge(Rect2(aabb.position + p_motion, aabb.size)); //motion
aabb = aabb.grow(p_margin);
@@ -445,7 +450,7 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
rcd.best_len = 0;
rcd.best_object = nullptr;
rcd.best_shape = 0;
- rcd.min_allowed_depth = space->test_motion_min_contact_depth;
+ rcd.min_allowed_depth = min_contact_depth;
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)) {
@@ -569,6 +574,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
ExcludedShapeSW excluded_shape_pairs[max_excluded_shape_pairs];
int excluded_shape_pair_count = 0;
+ real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR;
+
real_t motion_length = p_motion.length();
Vector2 motion_normal = p_motion / motion_length;
@@ -671,6 +678,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
break;
}
+ recovered = true;
+
Vector2 recover_motion;
for (int i = 0; i < cbk.amount; i++) {
Vector2 a = sr[i * 2 + 0];
@@ -682,9 +691,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
// Compute depth on recovered motion.
real_t depth = n.dot(a + recover_motion) - d;
- if (depth > 0.0) {
+ if (depth > min_contact_depth + CMP_EPSILON) {
// Only recover if there is penetration.
- recover_motion -= n * depth * 0.4;
+ recover_motion -= n * (depth - min_contact_depth) * 0.4;
}
}
@@ -693,8 +702,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
break;
}
- recovered = true;
-
body_transform.elements[2] += recover_motion;
body_aabb.position += recover_motion;
@@ -870,7 +877,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
rcd.best_shape = 0;
// Allowed depth can't be lower than motion length, in order to handle contacts at low speed.
- rcd.min_allowed_depth = MIN(motion_length, test_motion_min_contact_depth);
+ rcd.min_allowed_depth = MIN(motion_length, min_contact_depth);
int from_shape = best_shape != -1 ? best_shape : 0;
int to_shape = best_shape != -1 ? best_shape + 1 : p_body->get_shape_count();
@@ -1141,9 +1148,6 @@ void Space2DSW::set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_valu
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;
}
}
@@ -1163,8 +1167,6 @@ real_t Space2DSW::get_param(PhysicsServer2D::SpaceParameter p_param) const {
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;
}
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index 30c6b4cf55..a1a8a77ee4 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -102,7 +102,6 @@ private:
real_t contact_max_separation = 1.5;
real_t contact_max_allowed_penetration = 0.3;
real_t constraint_bias = 0.2;
- real_t test_motion_min_contact_depth = 0.005;
enum {
INTERSECTION_QUERY_MAX = 2048
diff --git a/servers/physics_3d/body_3d_sw.cpp b/servers/physics_3d/body_3d_sw.cpp
index 5924e249a5..91fe80a3dc 100644
--- a/servers/physics_3d/body_3d_sw.cpp
+++ b/servers/physics_3d/body_3d_sw.cpp
@@ -154,7 +154,7 @@ void Body3DSW::update_mass_properties() {
_inv_inertia = Vector3();
_inv_mass = 0;
} break;
- case PhysicsServer3D::BODY_MODE_DYNAMIC_LOCKED: {
+ case PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR: {
_inv_inertia_tensor.set_zero();
_inv_mass = 1.0 / mass;
@@ -310,7 +310,7 @@ void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
set_active(true);
} break;
- case PhysicsServer3D::BODY_MODE_DYNAMIC_LOCKED: {
+ case PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = Vector3();
angular_velocity = Vector3();
diff --git a/servers/physics_3d/body_direct_state_3d_sw.cpp b/servers/physics_3d/body_direct_state_3d_sw.cpp
index d197dd288d..e74baefc3a 100644
--- a/servers/physics_3d/body_direct_state_3d_sw.cpp
+++ b/servers/physics_3d/body_direct_state_3d_sw.cpp
@@ -66,6 +66,7 @@ Basis PhysicsDirectBodyState3DSW::get_inverse_inertia_tensor() const {
}
void PhysicsDirectBodyState3DSW::set_linear_velocity(const Vector3 &p_velocity) {
+ body->set_active(true);
body->set_linear_velocity(p_velocity);
}
@@ -74,6 +75,7 @@ Vector3 PhysicsDirectBodyState3DSW::get_linear_velocity() const {
}
void PhysicsDirectBodyState3DSW::set_angular_velocity(const Vector3 &p_velocity) {
+ body->set_active(true);
body->set_angular_velocity(p_velocity);
}
@@ -94,26 +96,32 @@ Vector3 PhysicsDirectBodyState3DSW::get_velocity_at_local_position(const Vector3
}
void PhysicsDirectBodyState3DSW::add_central_force(const Vector3 &p_force) {
+ body->set_active(true);
body->add_central_force(p_force);
}
void PhysicsDirectBodyState3DSW::add_force(const Vector3 &p_force, const Vector3 &p_position) {
+ body->set_active(true);
body->add_force(p_force, p_position);
}
void PhysicsDirectBodyState3DSW::add_torque(const Vector3 &p_torque) {
+ body->set_active(true);
body->add_torque(p_torque);
}
void PhysicsDirectBodyState3DSW::apply_central_impulse(const Vector3 &p_impulse) {
+ body->set_active(true);
body->apply_central_impulse(p_impulse);
}
void PhysicsDirectBodyState3DSW::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) {
+ body->set_active(true);
body->apply_impulse(p_impulse, p_position);
}
void PhysicsDirectBodyState3DSW::apply_torque_impulse(const Vector3 &p_impulse) {
+ body->set_active(true);
body->apply_torque_impulse(p_impulse);
}
diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp
index 8fbb0ba477..ece1fe46e7 100644
--- a/servers/physics_3d/physics_server_3d_sw.cpp
+++ b/servers/physics_3d/physics_server_3d_sw.cpp
@@ -102,25 +102,25 @@ RID PhysicsServer3DSW::custom_shape_create() {
}
void PhysicsServer3DSW::shape_set_data(RID p_shape, const Variant &p_data) {
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(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);
+ Shape3DSW *shape = shape_owner.get_or_null(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);
+ const Shape3DSW *shape = shape_owner.get_or_null(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);
+ const Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
return shape->get_data();
@@ -134,7 +134,7 @@ real_t PhysicsServer3DSW::shape_get_margin(RID p_shape) const {
}
real_t PhysicsServer3DSW::shape_get_custom_solver_bias(RID p_shape) const {
- const Shape3DSW *shape = shape_owner.getornull(p_shape);
+ const Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
@@ -144,7 +144,7 @@ RID PhysicsServer3DSW::space_create() {
RID id = space_owner.make_rid(space);
space->set_self(id);
RID area_id = area_create();
- Area3DSW *area = area_owner.getornull(area_id);
+ Area3DSW *area = area_owner.get_or_null(area_id);
ERR_FAIL_COND_V(!area, RID());
space->set_default_area(area);
area->set_space(space);
@@ -158,7 +158,7 @@ RID PhysicsServer3DSW::space_create() {
};
void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
if (p_active) {
active_spaces.insert(space);
@@ -168,27 +168,27 @@ void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) {
}
bool PhysicsServer3DSW::space_is_active(RID p_space) const {
- const Space3DSW *space = space_owner.getornull(p_space);
+ const Space3DSW *space = space_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(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);
+ const Space3DSW *space = space_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, nullptr);
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -196,19 +196,19 @@ PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space
}
void PhysicsServer3DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- Space3DSW *space = space_owner.getornull(p_space);
+ Space3DSW *space = space_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
@@ -221,12 +221,12 @@ RID PhysicsServer3DSW::area_create() {
};
void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
Space3DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -239,7 +239,7 @@ void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
};
RID PhysicsServer3DSW::area_get_space(RID p_area) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Space3DSW *space = area->get_space();
@@ -250,34 +250,34 @@ RID PhysicsServer3DSW::area_get_space(RID p_area) const {
};
void PhysicsServer3DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(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);
+ const Area3DSW *area = area_owner.get_or_null(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 Transform3D &p_transform, bool p_disabled) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -285,21 +285,21 @@ void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
}
void PhysicsServer3DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, RID());
Shape3DSW *shape = area->get_shape(p_shape_idx);
@@ -309,21 +309,21 @@ RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
}
Transform3D PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform3D());
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);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
while (area->get_shape_count()) {
@@ -332,7 +332,7 @@ void PhysicsServer3DSW::area_clear_shapes(RID p_area) {
}
void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count());
FLUSH_QUERY_CHECK(area);
@@ -341,74 +341,74 @@ void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, boo
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);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
};
void PhysicsServer3DSW::area_set_transform(RID p_area, const Transform3D &p_transform) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Space3DSW *space = space_owner.get_or_null(p_area);
p_area = space->get_default_area()->get_self();
}
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
};
Transform3D PhysicsServer3DSW::area_get_transform(RID p_area) const {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, Transform3D());
return area->get_transform();
};
void PhysicsServer3DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -416,21 +416,21 @@ void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool 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);
+ Area3DSW *area = area_owner.get_or_null(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);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_ray_pickable(p_enable);
}
void PhysicsServer3DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area3DSW *area = area_owner.getornull(p_area);
+ Area3DSW *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
@@ -446,12 +446,12 @@ RID PhysicsServer3DSW::body_create() {
};
void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
Space3DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -464,7 +464,7 @@ void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
};
RID PhysicsServer3DSW::body_get_space(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Space3DSW *space = body->get_space();
@@ -475,55 +475,55 @@ RID PhysicsServer3DSW::body_get_space(RID p_body) const {
};
void PhysicsServer3DSW::body_set_mode(RID p_body, BodyMode p_mode) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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 Transform3D &p_transform, bool p_disabled) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
- Shape3DSW *shape = shape_owner.getornull(p_shape);
+ Shape3DSW *shape = shape_owner.get_or_null(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 Transform3D &p_transform) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, RID());
Shape3DSW *shape = body->get_shape(p_shape_idx);
@@ -533,7 +533,7 @@ RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
}
void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -542,21 +542,21 @@ void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
}
Transform3D PhysicsServer3DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, Transform3D());
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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
while (body->get_shape_count()) {
@@ -565,21 +565,21 @@ void PhysicsServer3DSW::body_clear_shapes(RID p_body) {
}
void PhysicsServer3DSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
@@ -587,14 +587,14 @@ void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
}
uint32_t PhysicsServer3DSW::body_get_collision_layer(RID p_body) const {
- const Body3DSW *body = body_owner.getornull(p_body);
+ const Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
@@ -602,20 +602,20 @@ void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
}
uint32_t PhysicsServer3DSW::body_get_collision_mask(RID p_body) const {
- const Body3DSW *body = body_owner.getornull(p_body);
+ const Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
if (body) {
body->set_instance_id(p_id);
return;
}
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
if (soft_body) {
soft_body->set_instance_id(p_id);
return;
@@ -625,61 +625,61 @@ void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id
};
ObjectID PhysicsServer3DSW::body_get_object_instance_id(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
};
uint32_t PhysicsServer3DSW::body_get_user_flags(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer3DSW::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
};
Variant PhysicsServer3DSW::body_get_param(RID p_body, BodyParameter p_param) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
};
void PhysicsServer3DSW::body_reset_mass_properties(RID p_body) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
return body->reset_mass_properties();
}
void PhysicsServer3DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
@@ -687,13 +687,13 @@ void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_forc
};
Vector3 PhysicsServer3DSW::body_get_applied_force(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
@@ -701,14 +701,14 @@ void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_tor
};
Vector3 PhysicsServer3DSW::body_get_applied_torque(RID p_body) const {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_central_force(p_force);
@@ -716,7 +716,7 @@ void PhysicsServer3DSW::body_add_central_force(RID p_body, const Vector3 &p_forc
}
void PhysicsServer3DSW::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_force(p_force, p_position);
@@ -724,7 +724,7 @@ void PhysicsServer3DSW::body_add_force(RID p_body, const Vector3 &p_force, const
};
void PhysicsServer3DSW::body_add_torque(RID p_body, const Vector3 &p_torque) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_torque(p_torque);
@@ -732,7 +732,7 @@ void PhysicsServer3DSW::body_add_torque(RID p_body, const Vector3 &p_torque) {
};
void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -742,7 +742,7 @@ void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_
}
void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -752,7 +752,7 @@ void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_impulse,
};
void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -762,7 +762,7 @@ void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_i
};
void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -776,7 +776,7 @@ void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis
};
void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_axis, p_lock);
@@ -784,13 +784,13 @@ void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_l
}
bool PhysicsServer3DSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
- const Body3DSW *body = body_owner.getornull(p_body);
+ const Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
@@ -798,7 +798,7 @@ void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
};
void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
@@ -806,7 +806,7 @@ void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b
};
void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -815,61 +815,61 @@ void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
void PhysicsServer3DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(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);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void PhysicsServer3DSW::body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_state_sync_callback(p_instance, p_callback);
}
void PhysicsServer3DSW::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_callable, p_udata);
}
void PhysicsServer3DSW::body_set_ray_pickable(RID p_body, bool p_enable) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform3D &p_from, const Vector3 &p_motion, real_t p_margin, MotionResult *r_result, int p_max_collisions, bool p_collide_separation_ray, const Set<RID> &p_exclude) {
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(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);
@@ -882,7 +882,7 @@ bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform3D &p_from,
PhysicsDirectBodyState3D *PhysicsServer3DSW::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
- Body3DSW *body = body_owner.getornull(p_body);
+ Body3DSW *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, nullptr);
ERR_FAIL_NULL_V(body->get_space(), nullptr);
@@ -901,19 +901,19 @@ RID PhysicsServer3DSW::soft_body_create() {
}
void PhysicsServer3DSW::soft_body_update_rendering_server(RID p_body, RenderingServerHandler *p_rendering_server_handler) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->update_rendering_server(p_rendering_server_handler);
}
void PhysicsServer3DSW::soft_body_set_space(RID p_body, RID p_space) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
Space3DSW *space = nullptr;
if (p_space.is_valid()) {
- space = space_owner.getornull(p_space);
+ space = space_owner.get_or_null(p_space);
ERR_FAIL_COND(!space);
}
@@ -925,7 +925,7 @@ void PhysicsServer3DSW::soft_body_set_space(RID p_body, RID p_space) {
}
RID PhysicsServer3DSW::soft_body_get_space(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, RID());
Space3DSW *space = soft_body->get_space();
@@ -936,49 +936,49 @@ RID PhysicsServer3DSW::soft_body_get_space(RID p_body) const {
}
void PhysicsServer3DSW::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_collision_layer(p_layer);
}
uint32_t PhysicsServer3DSW::soft_body_get_collision_layer(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0);
return soft_body->get_collision_layer();
}
void PhysicsServer3DSW::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_collision_mask(p_mask);
}
uint32_t PhysicsServer3DSW::soft_body_get_collision_mask(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0);
return soft_body->get_collision_mask();
}
void PhysicsServer3DSW::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->add_exception(p_body_b);
}
void PhysicsServer3DSW::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->remove_exception(p_body_b);
}
void PhysicsServer3DSW::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
for (int i = 0; i < soft_body->get_exceptions().size(); i++) {
@@ -987,154 +987,154 @@ void PhysicsServer3DSW::soft_body_get_collision_exceptions(RID p_body, List<RID>
}
void PhysicsServer3DSW::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_state(p_state, p_variant);
}
Variant PhysicsServer3DSW::soft_body_get_state(RID p_body, BodyState p_state) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, Variant());
return soft_body->get_state(p_state);
}
void PhysicsServer3DSW::soft_body_set_transform(RID p_body, const Transform3D &p_transform) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_state(BODY_STATE_TRANSFORM, p_transform);
}
void PhysicsServer3DSW::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_ray_pickable(p_enable);
}
void PhysicsServer3DSW::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_iteration_count(p_simulation_precision);
}
int PhysicsServer3DSW::soft_body_get_simulation_precision(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_iteration_count();
}
void PhysicsServer3DSW::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_total_mass(p_total_mass);
}
real_t PhysicsServer3DSW::soft_body_get_total_mass(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_total_mass();
}
void PhysicsServer3DSW::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_linear_stiffness(p_stiffness);
}
real_t PhysicsServer3DSW::soft_body_get_linear_stiffness(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_linear_stiffness();
}
void PhysicsServer3DSW::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_pressure_coefficient(p_pressure_coefficient);
}
real_t PhysicsServer3DSW::soft_body_get_pressure_coefficient(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_pressure_coefficient();
}
void PhysicsServer3DSW::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_damping_coefficient(p_damping_coefficient);
}
real_t PhysicsServer3DSW::soft_body_get_damping_coefficient(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_damping_coefficient();
}
void PhysicsServer3DSW::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_drag_coefficient(p_drag_coefficient);
}
real_t PhysicsServer3DSW::soft_body_get_drag_coefficient(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, 0.f);
return soft_body->get_drag_coefficient();
}
void PhysicsServer3DSW::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_mesh(p_mesh);
}
AABB PhysicsServer3DSW::soft_body_get_bounds(RID p_body) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, AABB());
return soft_body->get_bounds();
}
void PhysicsServer3DSW::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->set_vertex_position(p_point_index, p_global_position);
}
Vector3 PhysicsServer3DSW::soft_body_get_point_global_position(RID p_body, int p_point_index) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, Vector3());
return soft_body->get_vertex_position(p_point_index);
}
void PhysicsServer3DSW::soft_body_remove_all_pinned_points(RID p_body) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
soft_body->unpin_all_vertices();
}
void PhysicsServer3DSW::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND(!soft_body);
if (p_pin) {
@@ -1145,7 +1145,7 @@ void PhysicsServer3DSW::soft_body_pin_point(RID p_body, int p_point_index, bool
}
bool PhysicsServer3DSW::soft_body_is_point_pinned(RID p_body, int p_point_index) const {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_body);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!soft_body, false);
return soft_body->is_vertex_pinned(p_point_index);
@@ -1161,7 +1161,7 @@ RID PhysicsServer3DSW::joint_create() {
}
void PhysicsServer3DSW::joint_clear(RID p_joint) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
if (joint->get_type() != JOINT_TYPE_MAX) {
Joint3DSW *empty_joint = memnew(Joint3DSW);
empty_joint->copy_settings_from(joint);
@@ -1172,7 +1172,7 @@ void PhysicsServer3DSW::joint_clear(RID p_joint) {
}
void PhysicsServer3DSW::joint_make_pin(RID p_joint, 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);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1180,12 +1180,12 @@ void PhysicsServer3DSW::joint_make_pin(RID p_joint, RID p_body_A, const Vector3
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(PinJoint3DSW(body_A, p_local_A, body_B, p_local_B));
@@ -1196,7 +1196,7 @@ void PhysicsServer3DSW::joint_make_pin(RID p_joint, RID p_body_A, const Vector3
}
void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1204,7 +1204,7 @@ void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
}
real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1212,7 +1212,7 @@ real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
}
void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1220,7 +1220,7 @@ void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
}
Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1228,7 +1228,7 @@ Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
}
void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1236,7 +1236,7 @@ void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
}
Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, Vector3());
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
@@ -1244,7 +1244,7 @@ Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
}
void PhysicsServer3DSW::joint_make_hinge(RID p_joint, RID p_body_A, const Transform3D &p_frame_A, RID p_body_B, const Transform3D &p_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1252,12 +1252,12 @@ void PhysicsServer3DSW::joint_make_hinge(RID p_joint, RID p_body_A, const Transf
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_frame_A, p_frame_B));
@@ -1268,7 +1268,7 @@ void PhysicsServer3DSW::joint_make_hinge(RID p_joint, RID p_body_A, const Transf
}
void PhysicsServer3DSW::joint_make_hinge_simple(RID p_joint, 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);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1276,12 +1276,12 @@ void PhysicsServer3DSW::joint_make_hinge_simple(RID p_joint, RID p_body_A, const
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B));
@@ -1292,7 +1292,7 @@ void PhysicsServer3DSW::joint_make_hinge_simple(RID p_joint, RID p_body_A, const
}
void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1300,7 +1300,7 @@ void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_par
}
real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, 0);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1308,7 +1308,7 @@ real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_p
}
void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_HINGE);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1316,7 +1316,7 @@ void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag,
}
bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_HINGE, false);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
@@ -1324,19 +1324,19 @@ bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag)
}
void PhysicsServer3DSW::joint_set_solver_priority(RID p_joint, int p_priority) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(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);
+ Joint3DSW *joint = joint_owner.get_or_null(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);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
@@ -1356,20 +1356,20 @@ void PhysicsServer3DSW::joint_disable_collisions_between_bodies(RID p_joint, con
}
bool PhysicsServer3DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(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);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_TYPE_PIN);
return joint->get_type();
}
void PhysicsServer3DSW::joint_make_slider(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1377,12 +1377,12 @@ void PhysicsServer3DSW::joint_make_slider(RID p_joint, RID p_body_A, const Trans
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(SliderJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
@@ -1393,7 +1393,7 @@ void PhysicsServer3DSW::joint_make_slider(RID p_joint, RID p_body_A, const Trans
}
void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_SLIDER);
SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
@@ -1401,7 +1401,7 @@ void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_p
}
real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0);
SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
@@ -1409,7 +1409,7 @@ real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p
}
void PhysicsServer3DSW::joint_make_cone_twist(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1417,12 +1417,12 @@ void PhysicsServer3DSW::joint_make_cone_twist(RID p_joint, RID p_body_A, const T
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(ConeTwistJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B));
@@ -1433,7 +1433,7 @@ void PhysicsServer3DSW::joint_make_cone_twist(RID p_joint, RID p_body_A, const T
}
void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_CONE_TWIST);
ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
@@ -1441,7 +1441,7 @@ void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointPa
}
real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_CONE_TWIST, 0);
ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
@@ -1449,7 +1449,7 @@ real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJoint
}
void PhysicsServer3DSW::joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) {
- Body3DSW *body_A = body_owner.getornull(p_body_A);
+ Body3DSW *body_A = body_owner.get_or_null(p_body_A);
ERR_FAIL_COND(!body_A);
if (!p_body_B.is_valid()) {
@@ -1457,12 +1457,12 @@ void PhysicsServer3DSW::joint_make_generic_6dof(RID p_joint, RID p_body_A, const
p_body_B = body_A->get_space()->get_static_global_body();
}
- Body3DSW *body_B = body_owner.getornull(p_body_B);
+ Body3DSW *body_B = body_owner.get_or_null(p_body_B);
ERR_FAIL_COND(!body_B);
ERR_FAIL_COND(body_A == body_B);
- Joint3DSW *prev_joint = joint_owner.getornull(p_joint);
+ Joint3DSW *prev_joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(prev_joint == nullptr);
Joint3DSW *joint = memnew(Generic6DOFJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B, true));
@@ -1473,7 +1473,7 @@ void PhysicsServer3DSW::joint_make_generic_6dof(RID p_joint, RID p_body_A, const
}
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);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1481,7 +1481,7 @@ void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis
}
real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1489,7 +1489,7 @@ real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axi
}
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);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1497,7 +1497,7 @@ void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p
}
bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) const {
- Joint3DSW *joint = joint_owner.getornull(p_joint);
+ Joint3DSW *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
@@ -1508,7 +1508,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
_update_shapes(); //just in case
if (shape_owner.owns(p_rid)) {
- Shape3DSW *shape = shape_owner.getornull(p_rid);
+ Shape3DSW *shape = shape_owner.get_or_null(p_rid);
while (shape->get_owners().size()) {
ShapeOwner3DSW *so = shape->get_owners().front()->key();
@@ -1518,7 +1518,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
shape_owner.free(p_rid);
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
- Body3DSW *body = body_owner.getornull(p_rid);
+ Body3DSW *body = body_owner.get_or_null(p_rid);
/*
if (body->get_state_query())
@@ -1537,14 +1537,14 @@ void PhysicsServer3DSW::free(RID p_rid) {
body_owner.free(p_rid);
memdelete(body);
} else if (soft_body_owner.owns(p_rid)) {
- SoftBody3DSW *soft_body = soft_body_owner.getornull(p_rid);
+ SoftBody3DSW *soft_body = soft_body_owner.get_or_null(p_rid);
soft_body->set_space(nullptr);
soft_body_owner.free(p_rid);
memdelete(soft_body);
} else if (area_owner.owns(p_rid)) {
- Area3DSW *area = area_owner.getornull(p_rid);
+ Area3DSW *area = area_owner.get_or_null(p_rid);
/*
if (area->get_monitor_query())
@@ -1560,7 +1560,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
area_owner.free(p_rid);
memdelete(area);
} else if (space_owner.owns(p_rid)) {
- Space3DSW *space = space_owner.getornull(p_rid);
+ Space3DSW *space = space_owner.get_or_null(p_rid);
while (space->get_objects().size()) {
CollisionObject3DSW *co = (CollisionObject3DSW *)space->get_objects().front()->get();
@@ -1574,7 +1574,7 @@ void PhysicsServer3DSW::free(RID p_rid) {
space_owner.free(p_rid);
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
- Joint3DSW *joint = joint_owner.getornull(p_rid);
+ Joint3DSW *joint = joint_owner.get_or_null(p_rid);
joint_owner.free(p_rid);
memdelete(joint);
diff --git a/servers/physics_3d/soft_body_3d_sw.cpp b/servers/physics_3d/soft_body_3d_sw.cpp
index 5f6e202c73..752d5f3a91 100644
--- a/servers/physics_3d/soft_body_3d_sw.cpp
+++ b/servers/physics_3d/soft_body_3d_sw.cpp
@@ -249,8 +249,10 @@ void SoftBody3DSW::update_area() {
// Node area.
LocalVector<int> counts;
- counts.resize(nodes.size());
- memset(counts.ptr(), 0, counts.size() * sizeof(int));
+ if (nodes.size() > 0) {
+ counts.resize(nodes.size());
+ memset(counts.ptr(), 0, counts.size() * sizeof(int));
+ }
for (i = 0, ni = nodes.size(); i < ni; ++i) {
nodes[i].area = 0.0;
diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index cc4eab1f0b..3718babbd6 100644
--- a/servers/physics_3d/space_3d_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -34,6 +34,8 @@
#include "core/config/project_settings.h"
#include "physics_server_3d_sw.h"
+#define TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR 0.05
+
_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;
@@ -185,7 +187,7 @@ int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Trans
return 0;
}
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_xform.xform(shape->get_aabb());
@@ -236,7 +238,7 @@ int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Trans
}
bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transform3D &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) {
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, false);
AABB aabb = p_xform.xform(shape->get_aabb());
@@ -359,7 +361,7 @@ bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform3D &
return false;
}
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
AABB aabb = p_shape_xform.xform(shape->get_aabb());
@@ -485,16 +487,18 @@ static void _rest_cbk_result(const Vector3 &p_point_A, int p_index_A, const Vect
}
bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform3D &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) {
- Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.getornull(p_shape);
+ Shape3DSW *shape = PhysicsServer3DSW::singletonsw->shape_owner.get_or_null(p_shape);
ERR_FAIL_COND_V(!shape, 0);
+ real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR;
+
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, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
_RestCallbackData rcd;
- rcd.min_allowed_depth = space->test_motion_min_contact_depth;
+ rcd.min_allowed_depth = min_contact_depth;
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)) {
@@ -539,9 +543,9 @@ bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform3D &p_sh
}
Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
- CollisionObject3DSW *obj = PhysicsServer3DSW::singletonsw->area_owner.getornull(p_object);
+ CollisionObject3DSW *obj = PhysicsServer3DSW::singletonsw->area_owner.get_or_null(p_object);
if (!obj) {
- obj = PhysicsServer3DSW::singletonsw->body_owner.getornull(p_object);
+ obj = PhysicsServer3DSW::singletonsw->body_owner.get_or_null(p_object);
}
ERR_FAIL_COND_V(!obj, Vector3());
@@ -658,6 +662,8 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
body_aabb = p_from.xform(p_body->get_inv_transform().xform(body_aabb));
body_aabb = body_aabb.grow(p_margin);
+ real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR;
+
real_t motion_length = p_motion.length();
Vector3 motion_normal = p_motion / motion_length;
@@ -711,8 +717,9 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
break;
}
- Vector3 recover_motion;
+ recovered = true;
+ Vector3 recover_motion;
for (int i = 0; i < cbk.amount; i++) {
Vector3 a = sr[i * 2 + 0];
Vector3 b = sr[i * 2 + 1];
@@ -723,9 +730,9 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
// Compute depth on recovered motion.
real_t depth = n.dot(a + recover_motion) - d;
- if (depth > 0.0) {
+ if (depth > min_contact_depth + CMP_EPSILON) {
// Only recover if there is penetration.
- recover_motion -= n * depth * 0.4;
+ recover_motion -= n * (depth - min_contact_depth) * 0.4;
}
}
@@ -734,8 +741,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
break;
}
- recovered = true;
-
body_transform.origin += recover_motion;
body_aabb.position += recover_motion;
@@ -889,7 +894,7 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co
}
// Allowed depth can't be lower than motion length, in order to handle contacts at low speed.
- rcd.min_allowed_depth = MIN(motion_length, test_motion_min_contact_depth);
+ rcd.min_allowed_depth = MIN(motion_length, min_contact_depth);
int from_shape = best_shape != -1 ? best_shape : 0;
int to_shape = best_shape != -1 ? best_shape + 1 : p_body->get_shape_count();
@@ -1158,9 +1163,6 @@ void Space3DSW::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_valu
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;
}
}
@@ -1182,8 +1184,6 @@ real_t Space3DSW::get_param(PhysicsServer3D::SpaceParameter p_param) const {
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;
}
diff --git a/servers/physics_3d/space_3d_sw.h b/servers/physics_3d/space_3d_sw.h
index fc2a7d304d..daa1244bf8 100644
--- a/servers/physics_3d/space_3d_sw.h
+++ b/servers/physics_3d/space_3d_sw.h
@@ -96,7 +96,6 @@ private:
real_t contact_max_separation = 0.05;
real_t contact_max_allowed_penetration = 0.01;
real_t constraint_bias = 0.01;
- real_t test_motion_min_contact_depth = 0.00001;
enum {
INTERSECTION_QUERY_MAX = 2048
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 8d5367e735..3fc94cd727 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -670,7 +670,6 @@ void PhysicsServer2D::_bind_methods() {
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD);
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH);
BIND_ENUM_CONSTANT(SHAPE_WORLD_BOUNDARY);
BIND_ENUM_CONSTANT(SHAPE_SEPARATION_RAY);
@@ -700,7 +699,7 @@ void PhysicsServer2D::_bind_methods() {
BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC);
- BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC_LOCKED);
+ BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC_LINEAR);
BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index 30d3c47051..4b85382fe5 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -262,7 +262,6 @@ public:
SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD,
SPACE_PARAM_BODY_TIME_TO_SLEEP,
SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
- SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH,
};
virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) = 0;
@@ -350,7 +349,7 @@ public:
BODY_MODE_STATIC,
BODY_MODE_KINEMATIC,
BODY_MODE_DYNAMIC,
- BODY_MODE_DYNAMIC_LOCKED,
+ BODY_MODE_DYNAMIC_LINEAR,
};
virtual RID body_create() = 0;
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp
index e868246636..9384cdc7b8 100644
--- a/servers/physics_server_3d.cpp
+++ b/servers/physics_server_3d.cpp
@@ -834,7 +834,7 @@ void PhysicsServer3D::_bind_methods() {
BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC);
- BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC_LOCKED);
+ BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC_LINEAR);
BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);
@@ -867,7 +867,6 @@ void PhysicsServer3D::_bind_methods() {
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP);
BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO);
BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
- BIND_ENUM_CONSTANT(SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH);
BIND_ENUM_CONSTANT(BODY_AXIS_LINEAR_X);
BIND_ENUM_CONSTANT(BODY_AXIS_LINEAR_Y);
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h
index 3e34da9561..14d395e714 100644
--- a/servers/physics_server_3d.h
+++ b/servers/physics_server_3d.h
@@ -271,7 +271,6 @@ public:
SPACE_PARAM_BODY_TIME_TO_SLEEP,
SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO,
SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,
- SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH
};
virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) = 0;
@@ -361,7 +360,7 @@ public:
BODY_MODE_STATIC,
BODY_MODE_KINEMATIC,
BODY_MODE_DYNAMIC,
- BODY_MODE_DYNAMIC_LOCKED,
+ BODY_MODE_DYNAMIC_LINEAR,
};
virtual RID body_create() = 0;
diff --git a/servers/rendering/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h
index 35bb7722e7..f95221c05b 100644
--- a/servers/rendering/rasterizer_dummy.h
+++ b/servers/rendering/rasterizer_dummy.h
@@ -224,7 +224,7 @@ public:
return texture_owner.make_rid(texture);
}
void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override {
- DummyTexture *t = texture_owner.getornull(p_texture);
+ DummyTexture *t = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!t);
t->image = p_image->duplicate();
}
@@ -241,7 +241,7 @@ public:
void texture_3d_placeholder_initialize(RID p_texture) override {}
Ref<Image> texture_2d_get(RID p_texture) const override {
- DummyTexture *t = texture_owner.getornull(p_texture);
+ DummyTexture *t = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!t, Ref<Image>());
return t->image;
}
@@ -661,7 +661,7 @@ public:
bool free(RID p_rid) override {
if (texture_owner.owns(p_rid)) {
// delete the texture
- DummyTexture *texture = texture_owner.getornull(p_rid);
+ DummyTexture *texture = texture_owner.get_or_null(p_rid);
texture_owner.free(p_rid);
memdelete(texture);
return true;
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp
index 456c736731..46683e8e68 100644
--- a/servers/rendering/renderer_canvas_cull.cpp
+++ b/servers/rendering/renderer_canvas_cull.cpp
@@ -100,7 +100,7 @@ void _collect_ysort_children(RendererCanvasCull::Item *p_canvas_item, Transform2
void _mark_ysort_dirty(RendererCanvasCull::Item *ysort_owner, RID_Owner<RendererCanvasCull::Item, true> &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) : nullptr;
+ ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.get_or_null(ysort_owner->parent) : nullptr;
} while (ysort_owner && ysort_owner->sort_y);
}
@@ -396,9 +396,9 @@ void RendererCanvasCull::canvas_initialize(RID p_rid) {
}
void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
- Canvas *canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
int idx = canvas->find_item(canvas_item);
@@ -407,7 +407,7 @@ void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, con
}
void RendererCanvasCull::canvas_set_modulate(RID p_canvas, const Color &p_color) {
- Canvas *canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->modulate = p_color;
}
@@ -417,7 +417,7 @@ void RendererCanvasCull::canvas_set_disable_scale(bool p_disable) {
}
void RendererCanvasCull::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
- Canvas *canvas = canvas_owner.getornull(p_canvas);
+ Canvas *canvas = canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->parent = p_parent;
@@ -432,15 +432,15 @@ void RendererCanvasCull::canvas_item_initialize(RID p_rid) {
}
void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (canvas_item->parent.is_valid()) {
if (canvas_owner.owns(canvas_item->parent)) {
- Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_item->parent);
canvas->erase_item(canvas_item);
} else if (canvas_item_owner.owns(canvas_item->parent)) {
- Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
+ Item *item_owner = canvas_item_owner.get_or_null(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
if (item_owner->sort_y) {
@@ -453,13 +453,13 @@ void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
if (p_parent.is_valid()) {
if (canvas_owner.owns(p_parent)) {
- Canvas *canvas = canvas_owner.getornull(p_parent);
+ Canvas *canvas = canvas_owner.get_or_null(p_parent);
Canvas::ChildItem ci;
ci.item = canvas_item;
canvas->child_items.push_back(ci);
canvas->children_order_dirty = true;
} else if (canvas_item_owner.owns(p_parent)) {
- Item *item_owner = canvas_item_owner.getornull(p_parent);
+ Item *item_owner = canvas_item_owner.get_or_null(p_parent);
item_owner->child_items.push_back(canvas_item);
item_owner->children_order_dirty = true;
@@ -476,7 +476,7 @@ void RendererCanvasCull::canvas_item_set_parent(RID p_item, RID p_parent) {
}
void RendererCanvasCull::canvas_item_set_visible(RID p_item, bool p_visible) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->visible = p_visible;
@@ -485,35 +485,35 @@ void RendererCanvasCull::canvas_item_set_visible(RID p_item, bool p_visible) {
}
void RendererCanvasCull::canvas_item_set_light_mask(RID p_item, int p_mask) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->light_mask = p_mask;
}
void RendererCanvasCull::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->xform = p_transform;
}
void RendererCanvasCull::canvas_item_set_clip(RID p_item, bool p_clip) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clip = p_clip;
}
void RendererCanvasCull::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->distance_field = p_enable;
}
void RendererCanvasCull::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);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->custom_rect = p_custom_rect;
@@ -521,35 +521,35 @@ void RendererCanvasCull::canvas_item_set_custom_rect(RID p_item, bool p_custom_r
}
void RendererCanvasCull::canvas_item_set_modulate(RID p_item, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->modulate = p_color;
}
void RendererCanvasCull::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->self_modulate = p_color;
}
void RendererCanvasCull::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->behind = p_enable;
}
void RendererCanvasCull::canvas_item_set_update_when_visible(RID p_item, bool p_update) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->update_when_visible = p_update;
}
void RendererCanvasCull::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);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPrimitive *line = canvas_item->alloc_command<Item::CommandPrimitive>();
@@ -573,7 +573,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width, bool p_antialiased) {
ERR_FAIL_COND(p_points.size() < 2);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Color color = Color(1, 1, 1, 1);
@@ -714,7 +714,7 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
void RendererCanvasCull::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);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>();
@@ -730,7 +730,7 @@ void RendererCanvasCull::canvas_item_add_multiline(RID p_item, const Vector<Poin
}
void RendererCanvasCull::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -740,7 +740,7 @@ void RendererCanvasCull::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, c
}
void RendererCanvasCull::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);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPolygon *circle = canvas_item->alloc_command<Item::CommandPolygon>();
@@ -776,7 +776,7 @@ void RendererCanvasCull::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
}
void RendererCanvasCull::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) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -807,7 +807,7 @@ void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
}
void RendererCanvasCull::canvas_item_add_msdf_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, int p_outline_size, float p_px_range) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -841,7 +841,7 @@ void RendererCanvasCull::canvas_item_add_msdf_texture_rect_region(RID p_item, co
}
void RendererCanvasCull::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, bool p_clip_uv) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandRect *rect = canvas_item->alloc_command<Item::CommandRect>();
@@ -882,7 +882,7 @@ void RendererCanvasCull::canvas_item_add_texture_rect_region(RID p_item, const R
}
void RendererCanvasCull::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) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandNinePatch *style = canvas_item->alloc_command<Item::CommandNinePatch>();
@@ -906,7 +906,7 @@ void RendererCanvasCull::canvas_item_add_primitive(RID p_item, const Vector<Poin
uint32_t pc = p_points.size();
ERR_FAIL_COND(pc == 0 || pc > 4);
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPrimitive *prim = canvas_item->alloc_command<Item::CommandPrimitive>();
@@ -932,7 +932,7 @@ void RendererCanvasCull::canvas_item_add_primitive(RID p_item, const Vector<Poin
}
void RendererCanvasCull::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) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
#ifdef DEBUG_ENABLED
int pointcount = p_points.size();
@@ -953,7 +953,7 @@ void RendererCanvasCull::canvas_item_add_polygon(RID p_item, const Vector<Point2
}
void RendererCanvasCull::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) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
int vertex_count = p_points.size();
@@ -976,7 +976,7 @@ void RendererCanvasCull::canvas_item_add_triangle_array(RID p_item, const Vector
}
void RendererCanvasCull::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandTransform *tr = canvas_item->alloc_command<Item::CommandTransform>();
@@ -985,7 +985,7 @@ void RendererCanvasCull::canvas_item_add_set_transform(RID p_item, const Transfo
}
void RendererCanvasCull::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
ERR_FAIL_COND(!p_mesh.is_valid());
@@ -1004,7 +1004,7 @@ void RendererCanvasCull::canvas_item_add_mesh(RID p_item, const RID &p_mesh, con
}
void RendererCanvasCull::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandParticles *part = canvas_item->alloc_command<Item::CommandParticles>();
@@ -1018,7 +1018,7 @@ void RendererCanvasCull::canvas_item_add_particles(RID p_item, RID p_particles,
}
void RendererCanvasCull::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandMultiMesh *mm = canvas_item->alloc_command<Item::CommandMultiMesh>();
@@ -1029,7 +1029,7 @@ void RendererCanvasCull::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p
}
void RendererCanvasCull::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandClipIgnore *ci = canvas_item->alloc_command<Item::CommandClipIgnore>();
@@ -1038,7 +1038,7 @@ void RendererCanvasCull::canvas_item_add_clip_ignore(RID p_item, bool p_ignore)
}
void RendererCanvasCull::canvas_item_add_animation_slice(RID p_item, double p_animation_length, double p_slice_begin, double p_slice_end, double p_offset) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandAnimationSlice *as = canvas_item->alloc_command<Item::CommandAnimationSlice>();
@@ -1050,7 +1050,7 @@ void RendererCanvasCull::canvas_item_add_animation_slice(RID p_item, double p_an
}
void RendererCanvasCull::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->sort_y = p_enable;
@@ -1061,21 +1061,21 @@ void RendererCanvasCull::canvas_item_set_sort_children_by_y(RID p_item, bool p_e
void RendererCanvasCull::canvas_item_set_z_index(RID p_item, int p_z) {
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);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->z_index = p_z;
}
void RendererCanvasCull::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->z_relative = p_enable;
}
void RendererCanvasCull::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (canvas_item->skeleton == p_skeleton) {
return;
@@ -1104,7 +1104,7 @@ void RendererCanvasCull::canvas_item_attach_skeleton(RID p_item, RID p_skeleton)
}
void RendererCanvasCull::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);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (p_enable && (canvas_item->copy_back_buffer == nullptr)) {
canvas_item->copy_back_buffer = memnew(RendererCanvasRender::Item::CopyBackBuffer);
@@ -1121,25 +1121,25 @@ void RendererCanvasCull::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_e
}
void RendererCanvasCull::canvas_item_clear(RID p_item) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clear();
}
void RendererCanvasCull::canvas_item_set_draw_index(RID p_item, int p_index) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->index = p_index;
if (canvas_item_owner.owns(canvas_item->parent)) {
- Item *canvas_item_parent = canvas_item_owner.getornull(canvas_item->parent);
+ Item *canvas_item_parent = canvas_item_owner.get_or_null(canvas_item->parent);
canvas_item_parent->children_order_dirty = true;
return;
}
- Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_item->parent);
if (canvas) {
canvas->children_order_dirty = true;
return;
@@ -1147,21 +1147,21 @@ void RendererCanvasCull::canvas_item_set_draw_index(RID p_item, int p_index) {
}
void RendererCanvasCull::canvas_item_set_material(RID p_item, RID p_material) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->material = p_material;
}
void RendererCanvasCull::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->use_parent_material = p_enable;
}
void RendererCanvasCull::canvas_item_set_visibility_notifier(RID p_item, bool p_enable, const Rect2 &p_area, const Callable &p_enter_callable, const Callable &p_exit_callable) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (p_enable) {
@@ -1181,7 +1181,7 @@ void RendererCanvasCull::canvas_item_set_visibility_notifier(RID p_item, bool p_
}
void RendererCanvasCull::canvas_item_set_canvas_group_mode(RID p_item, RS::CanvasGroupMode p_mode, float p_clear_margin, bool p_fit_empty, float p_fit_margin, bool p_blur_mipmaps) {
- Item *canvas_item = canvas_item_owner.getornull(p_item);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!canvas_item);
if (p_mode == RS::CANVAS_GROUP_MODE_DISABLED) {
@@ -1206,12 +1206,12 @@ RID RendererCanvasCull::canvas_light_allocate() {
}
void RendererCanvasCull::canvas_light_initialize(RID p_rid) {
canvas_light_owner.initialize_rid(p_rid);
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_rid);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_rid);
clight->light_internal = RSG::canvas_render->light_create();
}
void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->mode == p_mode) {
@@ -1232,11 +1232,11 @@ void RendererCanvasCull::canvas_light_set_mode(RID p_light, RS::CanvasLightMode
}
void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(clight->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(clight->canvas);
if (clight->mode == RS::CANVAS_LIGHT_MODE_POINT) {
canvas->lights.erase(clight);
} else {
@@ -1251,7 +1251,7 @@ void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
clight->canvas = p_canvas;
if (clight->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(clight->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(clight->canvas);
if (clight->mode == RS::CANVAS_LIGHT_MODE_POINT) {
canvas->lights.insert(clight);
} else {
@@ -1261,28 +1261,28 @@ void RendererCanvasCull::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
}
void RendererCanvasCull::canvas_light_set_enabled(RID p_light, bool p_enabled) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->enabled = p_enabled;
}
void RendererCanvasCull::canvas_light_set_texture_scale(RID p_light, float p_scale) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->scale = p_scale;
}
void RendererCanvasCull::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->xform = p_transform;
}
void RendererCanvasCull::canvas_light_set_texture(RID p_light, RID p_texture) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->texture == p_texture) {
@@ -1294,35 +1294,35 @@ void RendererCanvasCull::canvas_light_set_texture(RID p_light, RID p_texture) {
}
void RendererCanvasCull::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->texture_offset = p_offset;
}
void RendererCanvasCull::canvas_light_set_color(RID p_light, const Color &p_color) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->color = p_color;
}
void RendererCanvasCull::canvas_light_set_height(RID p_light, float p_height) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->height = p_height;
}
void RendererCanvasCull::canvas_light_set_energy(RID p_light, float p_energy) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->energy = p_energy;
}
void RendererCanvasCull::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->z_min = p_min_z;
@@ -1330,7 +1330,7 @@ void RendererCanvasCull::canvas_light_set_z_range(RID p_light, int p_min_z, int
}
void RendererCanvasCull::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->layer_max = p_max_layer;
@@ -1338,35 +1338,35 @@ void RendererCanvasCull::canvas_light_set_layer_range(RID p_light, int p_min_lay
}
void RendererCanvasCull::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->item_mask = p_mask;
}
void RendererCanvasCull::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->item_shadow_mask = p_mask;
}
void RendererCanvasCull::canvas_light_set_directional_distance(RID p_light, float p_distance) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->directional_distance = p_distance;
}
void RendererCanvasCull::canvas_light_set_blend_mode(RID p_light, RS::CanvasLightBlendMode p_mode) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->blend_mode = p_mode;
}
void RendererCanvasCull::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
if (clight->use_shadow == p_enabled) {
@@ -1378,21 +1378,21 @@ void RendererCanvasCull::canvas_light_set_shadow_enabled(RID p_light, bool p_ena
}
void RendererCanvasCull::canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_filter = p_filter;
}
void RendererCanvasCull::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_color = p_color;
}
void RendererCanvasCull::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
- RendererCanvasRender::Light *clight = canvas_light_owner.getornull(p_light);
+ RendererCanvasRender::Light *clight = canvas_light_owner.get_or_null(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_smooth = p_smooth;
}
@@ -1405,11 +1405,11 @@ void RendererCanvasCull::canvas_light_occluder_initialize(RID p_rid) {
}
void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
if (occluder->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(occluder->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
canvas->occluders.erase(occluder);
}
@@ -1420,24 +1420,24 @@ void RendererCanvasCull::canvas_light_occluder_attach_to_canvas(RID p_occluder,
occluder->canvas = p_canvas;
if (occluder->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(occluder->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
canvas->occluders.insert(occluder);
}
}
void RendererCanvasCull::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->enabled = p_enabled;
}
void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
if (occluder->polygon.is_valid()) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_polygon);
if (occluder_poly) {
occluder_poly->owners.erase(occluder);
}
@@ -1447,7 +1447,7 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p
occluder->occluder = RID();
if (occluder->polygon.is_valid()) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_polygon);
if (!occluder_poly) {
occluder->polygon = RID();
ERR_FAIL_COND(!occluder_poly);
@@ -1461,19 +1461,19 @@ void RendererCanvasCull::canvas_light_occluder_set_polygon(RID p_occluder, RID p
}
void RendererCanvasCull::canvas_light_occluder_set_as_sdf_collision(RID p_occluder, bool p_enable) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
}
void RendererCanvasCull::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->xform = p_xform;
}
void RendererCanvasCull::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->light_mask = p_mask;
@@ -1484,12 +1484,12 @@ RID RendererCanvasCull::canvas_occluder_polygon_allocate() {
}
void RendererCanvasCull::canvas_occluder_polygon_initialize(RID p_rid) {
canvas_light_occluder_polygon_owner.initialize_rid(p_rid);
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_rid);
occluder_poly->occluder = RSG::canvas_render->occluder_polygon_create();
}
void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
uint32_t pc = p_shape.size();
@@ -1513,7 +1513,7 @@ void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygo
}
void RendererCanvasCull::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);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
occluder_poly->cull_mode = p_mode;
RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode);
@@ -1550,12 +1550,12 @@ void RendererCanvasCull::canvas_texture_set_texture_repeat(RID p_canvas_texture,
}
void RendererCanvasCull::canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) {
- Item *ci = canvas_item_owner.getornull(p_item);
+ Item *ci = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!ci);
ci->texture_filter = p_filter;
}
void RendererCanvasCull::canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) {
- Item *ci = canvas_item_owner.getornull(p_item);
+ Item *ci = canvas_item_owner.get_or_null(p_item);
ERR_FAIL_COND(!ci);
ci->texture_repeat = p_repeat;
}
@@ -1600,11 +1600,11 @@ void RendererCanvasCull::update_visibility_notifiers() {
bool RendererCanvasCull::free(RID p_rid) {
if (canvas_owner.owns(p_rid)) {
- Canvas *canvas = canvas_owner.getornull(p_rid);
+ Canvas *canvas = canvas_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!canvas, false);
while (canvas->viewports.size()) {
- RendererViewport::Viewport *vp = RSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get());
+ RendererViewport::Viewport *vp = RSG::viewport->viewport_owner.get_or_null(canvas->viewports.front()->get());
ERR_FAIL_COND_V(!vp, true);
Map<RID, RendererViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
@@ -1629,15 +1629,15 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas_owner.free(p_rid);
} else if (canvas_item_owner.owns(p_rid)) {
- Item *canvas_item = canvas_item_owner.getornull(p_rid);
+ Item *canvas_item = canvas_item_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!canvas_item, true);
if (canvas_item->parent.is_valid()) {
if (canvas_owner.owns(canvas_item->parent)) {
- Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_item->parent);
canvas->erase_item(canvas_item);
} else if (canvas_item_owner.owns(canvas_item->parent)) {
- Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
+ Item *item_owner = canvas_item_owner.get_or_null(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
if (item_owner->sort_y) {
@@ -1663,11 +1663,11 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas_item_owner.free(p_rid);
} else if (canvas_light_owner.owns(p_rid)) {
- RendererCanvasRender::Light *canvas_light = canvas_light_owner.getornull(p_rid);
+ RendererCanvasRender::Light *canvas_light = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!canvas_light, true);
if (canvas_light->canvas.is_valid()) {
- Canvas *canvas = canvas_owner.getornull(canvas_light->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(canvas_light->canvas);
if (canvas) {
canvas->lights.erase(canvas_light);
}
@@ -1678,25 +1678,25 @@ bool RendererCanvasCull::free(RID p_rid) {
canvas_light_owner.free(p_rid);
} else if (canvas_light_occluder_owner.owns(p_rid)) {
- RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_rid);
+ RendererCanvasRender::LightOccluderInstance *occluder = canvas_light_occluder_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!occluder, true);
if (occluder->polygon.is_valid()) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(occluder->polygon);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(occluder->polygon);
if (occluder_poly) {
occluder_poly->owners.erase(occluder);
}
}
if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) {
- Canvas *canvas = canvas_owner.getornull(occluder->canvas);
+ Canvas *canvas = canvas_owner.get_or_null(occluder->canvas);
canvas->occluders.erase(occluder);
}
canvas_light_occluder_owner.free(p_rid);
} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
- LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
+ LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!occluder_poly, true);
RSG::canvas_render->free(occluder_poly->occluder);
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index fa3741c077..2377702738 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -2695,7 +2695,7 @@ void RenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geome
} break;
#if 0
case RS::INSTANCE_IMMEDIATE: {
- RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
+ RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index a5cc2db48f..75de2f6fbd 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -2440,7 +2440,7 @@ void RenderForwardMobile::_geometry_instance_update(GeometryInstance *p_geometry
} break;
#if 0
case RS::INSTANCE_IMMEDIATE: {
- RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
+ RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
ERR_CONTINUE(!immediate);
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index f507a83072..673df00c18 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -1144,7 +1144,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
continue;
}
- CanvasLight *clight = canvas_light_owner.getornull(l->light_internal);
+ CanvasLight *clight = canvas_light_owner.get_or_null(l->light_internal);
if (!clight) { //unused or invalid texture
l->render_index_cache = -1;
l = l->next_ptr;
@@ -1207,7 +1207,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
continue;
}
- CanvasLight *clight = canvas_light_owner.getornull(l->light_internal);
+ CanvasLight *clight = canvas_light_owner.get_or_null(l->light_internal);
if (!clight) { //unused or invalid texture
l->render_index_cache = -1;
l = l->next_ptr;
@@ -1394,6 +1394,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
update_skeletons = true;
}
}
+ c = c->next;
}
}
@@ -1480,7 +1481,7 @@ RID RendererCanvasRenderRD::light_create() {
}
void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl);
if (cl->texture == p_texture) {
return;
@@ -1496,7 +1497,7 @@ void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) {
}
void RendererCanvasRenderRD::light_set_use_shadow(RID p_rid, bool p_enable) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl);
cl->shadow.enabled = p_enable;
@@ -1536,7 +1537,7 @@ void RendererCanvasRenderRD::_update_shadow_atlas() {
}
}
void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl->shadow.enabled);
_update_shadow_atlas();
@@ -1590,7 +1591,7 @@ void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index,
LightOccluderInstance *instance = p_occluders;
while (instance) {
- OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
+ OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder);
if (!co || co->index_array.is_null() || !(p_light_mask & instance->light_mask)) {
instance = instance->next;
@@ -1614,7 +1615,7 @@ void RendererCanvasRenderRD::light_update_shadow(RID p_rid, int p_shadow_index,
}
void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND(!cl->shadow.enabled);
_update_shadow_atlas();
@@ -1665,7 +1666,7 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh
LightOccluderInstance *instance = p_occluders;
while (instance) {
- OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
+ OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder);
if (!co || co->index_array.is_null() || !(p_light_mask & instance->light_mask)) {
instance = instance->next;
@@ -1731,7 +1732,7 @@ void RendererCanvasRenderRD::render_sdf(RID p_render_target, LightOccluderInstan
LightOccluderInstance *instance = p_occluders;
while (instance) {
- OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
+ OccluderPolygon *co = occluder_polygon_owner.get_or_null(instance->occluder);
if (!co || co->sdf_index_array.is_null()) {
instance = instance->next;
@@ -1765,7 +1766,7 @@ RID RendererCanvasRenderRD::occluder_polygon_create() {
}
void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) {
- OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
+ OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!oc);
Vector<Vector2> lines;
@@ -1934,7 +1935,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve
}
void RendererCanvasRenderRD::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
- OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
+ OccluderPolygon *oc = occluder_polygon_owner.get_or_null(p_occluder);
ERR_FAIL_COND(!oc);
oc->cull_mode = p_mode;
}
@@ -2610,7 +2611,7 @@ void fragment() {
bool RendererCanvasRenderRD::free(RID p_rid) {
if (canvas_light_owner.owns(p_rid)) {
- CanvasLight *cl = canvas_light_owner.getornull(p_rid);
+ CanvasLight *cl = canvas_light_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!cl, false);
light_set_use_shadow(p_rid, false);
canvas_light_owner.free(p_rid);
diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
index c53c202bab..559e6d5ad7 100644
--- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp
@@ -197,7 +197,7 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color
}
} else {
screenrect = imgrect;
- screenrect.position += ((Size2(window_size.width, window_size.height) - screenrect.size) / 2.0).floor();
+ screenrect.position += ((window_size - screenrect.size) / 2.0).floor();
}
screenrect.position /= window_size;
diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
index fb308da38d..ecc560fc5d 100644
--- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp
@@ -1450,7 +1450,7 @@ void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform3D &p_transform, Re
break;
}
- RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_scene_render->render_state.sdfgi_update_data->directional_lights->get(j));
+ RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.get_or_null(p_scene_render->render_state.sdfgi_update_data->directional_lights->get(j));
ERR_CONTINUE(!li);
if (storage->light_directional_is_sky_only(li->light)) {
@@ -1484,7 +1484,7 @@ void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform3D &p_transform, Re
break;
}
- RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_scene_render->render_state.sdfgi_update_data->positional_light_instances[j]);
+ RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.get_or_null(p_scene_render->render_state.sdfgi_update_data->positional_light_instances[j]);
ERR_CONTINUE(!li);
uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light);
@@ -1534,7 +1534,7 @@ void RendererSceneGIRD::SDFGI::pre_process_gi(const Transform3D &p_transform, Re
void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region, const PagedArray<RendererSceneRender::GeometryInstance *> &p_instances, RendererSceneRenderRD *p_scene_render) {
//print_line("rendering region " + itos(p_region));
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb); // we wouldn't be here if this failed but...
AABB bounds;
Vector3i from;
@@ -1892,7 +1892,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region,
}
void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32_t p_cascade_count, const uint32_t *p_cascade_indices, const PagedArray<RID> *p_positional_light_cull_result, RendererSceneRenderRD *p_scene_render) {
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb); // we wouldn't be here if this failed but...
RD::get_singleton()->draw_command_begin_label("SDFGI Render Static Lighs");
@@ -1921,7 +1921,7 @@ void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32
break;
}
- RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.getornull(p_positional_light_cull_result[i][j]);
+ RendererSceneRenderRD::LightInstance *li = p_scene_render->light_instance_owner.get_or_null(p_positional_light_cull_result[i][j]);
ERR_CONTINUE(!li);
uint32_t max_sdfgi_cascade = storage->light_get_max_sdfgi_cascade(li->light);
@@ -3024,7 +3024,7 @@ void RendererSceneGIRD::setup_voxel_gi_instances(RID p_render_buffers, const Tra
r_voxel_gi_instances_used = 0;
// feels a little dirty to use our container this way but....
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(rb == nullptr);
RID voxel_gi_buffer = p_scene_render->render_buffers_get_voxel_gi_buffer(p_render_buffers);
@@ -3119,9 +3119,9 @@ void RendererSceneGIRD::setup_voxel_gi_instances(RID p_render_buffers, const Tra
void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_buffer, RID p_voxel_gi_buffer, RID p_environment, const CameraMatrix &p_projection, const Transform3D &p_transform, const PagedArray<RID> &p_voxel_gi_instances, RendererSceneRenderRD *p_scene_render) {
RD::get_singleton()->draw_command_begin_label("GI Render");
- RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneRenderRD::RenderBuffers *rb = p_scene_render->render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(rb == nullptr);
- RendererSceneEnvironmentRD *env = p_scene_render->environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = p_scene_render->environment_owner.get_or_null(p_environment);
if (rb->ambient_buffer.is_null() || rb->gi.using_half_size_gi != half_resolution) {
if (rb->ambient_buffer.is_valid()) {
@@ -3393,7 +3393,7 @@ void RendererSceneGIRD::voxel_gi_update(RID p_probe, bool p_update_light_instanc
}
void RendererSceneGIRD::debug_voxel_gi(RID p_voxel_gi, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform, bool p_lighting, bool p_emission, float p_alpha) {
- VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.getornull(p_voxel_gi);
+ VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->debug(p_draw_list, p_framebuffer, p_camera_with_transform, p_lighting, p_emission, p_alpha);
diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.h b/servers/rendering/renderer_rd/renderer_scene_gi_rd.h
index 0b4622646f..5bd41a104e 100644
--- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.h
@@ -383,7 +383,7 @@ public:
mutable RID_Owner<VoxelGIInstance> voxel_gi_instance_owner;
_FORCE_INLINE_ VoxelGIInstance *get_probe_instance(RID p_probe) const {
- return voxel_gi_instance_owner.getornull(p_probe);
+ return voxel_gi_instance_owner.get_or_null(p_probe);
};
_FORCE_INLINE_ RID voxel_gi_instance_get_texture(RID p_probe) {
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index 8e31ec1d8b..e7156accfa 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -48,8 +48,8 @@ void get_vogel_disk(float *r_kernel, int p_sample_count) {
}
void RendererSceneRenderRD::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
bool needs_sdfgi = env && env->sdfgi_enabled;
if (!needs_sdfgi) {
@@ -83,7 +83,7 @@ void RendererSceneRenderRD::sdfgi_update(RID p_render_buffers, RID p_environment
}
int RendererSceneRenderRD::sdfgi_get_pending_region_count(RID p_render_buffers) const {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(rb == nullptr, 0);
@@ -113,7 +113,7 @@ AABB RendererSceneRenderRD::sdfgi_get_pending_region_bounds(RID p_render_buffers
AABB bounds;
Vector3i from;
Vector3i size;
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(rb == nullptr, AABB());
ERR_FAIL_COND_V(rb->sdfgi == nullptr, AABB());
@@ -126,7 +126,7 @@ uint32_t RendererSceneRenderRD::sdfgi_get_pending_region_cascade(RID p_render_bu
AABB bounds;
Vector3i from;
Vector3i size;
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(rb == nullptr, -1);
ERR_FAIL_COND_V(rb->sdfgi == nullptr, -1);
@@ -164,139 +164,139 @@ void RendererSceneRenderRD::environment_initialize(RID p_rid) {
}
void RendererSceneRenderRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->background = p_bg;
}
void RendererSceneRenderRD::environment_set_sky(RID p_env, RID p_sky) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->sky = p_sky;
}
void RendererSceneRenderRD::environment_set_sky_custom_fov(RID p_env, float p_scale) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->sky_custom_fov = p_scale;
}
void RendererSceneRenderRD::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->sky_orientation = p_orientation;
}
void RendererSceneRenderRD::environment_set_bg_color(RID p_env, const Color &p_color) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->bg_color = p_color;
}
void RendererSceneRenderRD::environment_set_bg_energy(RID p_env, float p_energy) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->bg_energy = p_energy;
}
void RendererSceneRenderRD::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->canvas_max_layer = p_max_layer;
}
void RendererSceneRenderRD::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) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_ambient_light(p_color, p_ambient, p_energy, p_sky_contribution, p_reflection_source, p_ao_color);
}
RS::EnvironmentBG RendererSceneRenderRD::environment_get_background(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX);
return env->background;
}
RID RendererSceneRenderRD::environment_get_sky(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RID());
return env->sky;
}
float RendererSceneRenderRD::environment_get_sky_custom_fov(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->sky_custom_fov;
}
Basis RendererSceneRenderRD::environment_get_sky_orientation(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Basis());
return env->sky_orientation;
}
Color RendererSceneRenderRD::environment_get_bg_color(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->bg_color;
}
float RendererSceneRenderRD::environment_get_bg_energy(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->bg_energy;
}
int RendererSceneRenderRD::environment_get_canvas_max_layer(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->canvas_max_layer;
}
Color RendererSceneRenderRD::environment_get_ambient_light_color(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->ambient_light;
}
RS::EnvironmentAmbientSource RendererSceneRenderRD::environment_get_ambient_source(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG);
return env->ambient_source;
}
float RendererSceneRenderRD::environment_get_ambient_light_energy(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->ambient_light_energy;
}
float RendererSceneRenderRD::environment_get_ambient_sky_contribution(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->ambient_sky_contribution;
}
RS::EnvironmentReflectionSource RendererSceneRenderRD::environment_get_reflection_source(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED);
return env->reflection_source;
}
Color RendererSceneRenderRD::environment_get_ao_color(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->ao_color;
}
void RendererSceneRenderRD::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) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_tonemap(p_tone_mapper, p_exposure, p_white, p_auto_exposure, p_min_luminance, p_max_luminance, p_auto_exp_speed, p_auto_exp_scale);
}
void RendererSceneRenderRD::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, 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) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_glow(p_enable, p_levels, p_intensity, p_strength, p_mix, p_bloom_threshold, p_blend_mode, p_hdr_bleed_threshold, p_hdr_bleed_scale, p_hdr_luminance_cap);
}
@@ -310,7 +310,7 @@ void RendererSceneRenderRD::environment_glow_set_use_high_quality(bool p_enable)
}
void RendererSceneRenderRD::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
if (!is_dynamic_gi_supported()) {
@@ -321,58 +321,58 @@ void RendererSceneRenderRD::environment_set_sdfgi(RID p_env, bool p_enable, RS::
}
void RendererSceneRenderRD::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_fog(p_enable, p_light_color, p_light_energy, p_sun_scatter, p_density, p_height, p_height_density, p_fog_aerial_perspective);
}
bool RendererSceneRenderRD::environment_is_fog_enabled(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->fog_enabled;
}
Color RendererSceneRenderRD::environment_get_fog_light_color(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->fog_light_color;
}
float RendererSceneRenderRD::environment_get_fog_light_energy(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_light_energy;
}
float RendererSceneRenderRD::environment_get_fog_sun_scatter(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_sun_scatter;
}
float RendererSceneRenderRD::environment_get_fog_density(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_density;
}
float RendererSceneRenderRD::environment_get_fog_height(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_height;
}
float RendererSceneRenderRD::environment_get_fog_height_density(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_height_density;
}
float RendererSceneRenderRD::environment_get_fog_aerial_perspective(RID p_env) const {
- const RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ const RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->fog_aerial_perspective;
}
void RendererSceneRenderRD::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
if (!is_volumetric_supported()) {
@@ -403,7 +403,7 @@ void RendererSceneRenderRD::environment_set_sdfgi_frames_to_update_light(RS::Env
}
void RendererSceneRenderRD::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) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_ssr(p_enable, p_max_steps, p_fade_int, p_fade_out, p_depth_tolerance);
@@ -418,7 +418,7 @@ RS::EnvironmentSSRRoughnessQuality RendererSceneRenderRD::environment_get_ssr_ro
}
void RendererSceneRenderRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->set_ssao(p_enable, p_radius, p_intensity, p_power, p_detail, p_horizon, p_sharpness, p_light_affect, p_ao_channel_affect);
@@ -434,30 +434,30 @@ void RendererSceneRenderRD::environment_set_ssao_quality(RS::EnvironmentSSAOQual
}
bool RendererSceneRenderRD::environment_is_ssao_enabled(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->ssao_enabled;
}
float RendererSceneRenderRD::environment_get_ssao_ao_affect(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0.0);
return env->ssao_ao_channel_affect;
}
float RendererSceneRenderRD::environment_get_ssao_light_affect(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, 0.0);
return env->ssao_direct_light_affect;
}
bool RendererSceneRenderRD::environment_is_ssr_enabled(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->ssr_enabled;
}
bool RendererSceneRenderRD::environment_is_sdfgi_enabled(RID p_env) const {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, false);
return env->sdfgi_enabled;
}
@@ -467,7 +467,7 @@ bool RendererSceneRenderRD::is_environment(RID p_env) const {
}
Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND_V(!env, Ref<Image>());
if (env->background == RS::ENV_BG_CAMERA_FEED || env->background == RS::ENV_BG_CANVAS || env->background == RS::ENV_BG_KEEP) {
@@ -522,7 +522,7 @@ RID RendererSceneRenderRD::reflection_atlas_create() {
}
void RendererSceneRenderRD::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_ref_atlas);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_ref_atlas);
ERR_FAIL_COND(!ra);
if (ra->size == p_reflection_size && ra->count == p_reflection_count) {
@@ -557,7 +557,7 @@ void RendererSceneRenderRD::reflection_atlas_set_size(RID p_ref_atlas, int p_ref
}
int RendererSceneRenderRD::reflection_atlas_get_size(RID p_ref_atlas) const {
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_ref_atlas);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_ref_atlas);
ERR_FAIL_COND_V(!ra, 0);
return ra->size;
@@ -573,7 +573,7 @@ RID RendererSceneRenderRD::reflection_probe_instance_create(RID p_probe) {
}
void RendererSceneRenderRD::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!rpi);
rpi->transform = p_transform;
@@ -581,13 +581,13 @@ void RendererSceneRenderRD::reflection_probe_instance_set_transform(RID p_instan
}
void RendererSceneRenderRD::reflection_probe_release_atlas_index(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!rpi);
if (rpi->atlas.is_null()) {
return; //nothing to release
}
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND(!atlas);
ERR_FAIL_INDEX(rpi->atlas_index, atlas->reflections.size());
atlas->reflections.write[rpi->atlas_index].owner = RID();
@@ -596,7 +596,7 @@ void RendererSceneRenderRD::reflection_probe_release_atlas_index(RID p_instance)
}
bool RendererSceneRenderRD::reflection_probe_instance_needs_redraw(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
if (rpi->rendering) {
@@ -615,18 +615,18 @@ bool RendererSceneRenderRD::reflection_probe_instance_needs_redraw(RID p_instanc
}
bool RendererSceneRenderRD::reflection_probe_instance_has_reflection(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
return rpi->atlas.is_valid();
}
bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(p_reflection_atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_reflection_atlas);
ERR_FAIL_COND_V(!atlas, false);
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
RD::get_singleton()->draw_command_begin_label("Reflection probe render");
@@ -701,7 +701,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc
uint64_t pass_min = 0;
for (int i = 0; i < atlas->reflections.size(); i++) {
- ReflectionProbeInstance *rpi2 = reflection_probe_instance_owner.getornull(atlas->reflections[i].owner);
+ ReflectionProbeInstance *rpi2 = reflection_probe_instance_owner.get_or_null(atlas->reflections[i].owner);
if (rpi2->last_pass < pass_min) {
pass_min = rpi2->last_pass;
rpi->atlas_index = i;
@@ -733,12 +733,12 @@ RID RendererSceneRenderRD::reflection_probe_create_framebuffer(RID p_color, RID
}
bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, false);
ERR_FAIL_COND_V(!rpi->rendering, false);
ERR_FAIL_COND_V(rpi->atlas.is_null(), false);
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
if (!atlas || rpi->atlas_index == -1) {
//does not belong to an atlas anymore, cancel (was removed from atlas or atlas changed while rendering)
rpi->rendering = false;
@@ -779,30 +779,30 @@ bool RendererSceneRenderRD::reflection_probe_instance_postprocess_step(RID p_ins
}
uint32_t RendererSceneRenderRD::reflection_probe_instance_get_resolution(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, 0);
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND_V(!atlas, 0);
return atlas->size;
}
RID RendererSceneRenderRD::reflection_probe_instance_get_framebuffer(RID p_instance, int p_index) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, RID());
ERR_FAIL_INDEX_V(p_index, 6, RID());
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->reflections[rpi->atlas_index].fbs[p_index];
}
RID RendererSceneRenderRD::reflection_probe_instance_get_depth_framebuffer(RID p_instance, int p_index) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, RID());
ERR_FAIL_INDEX_V(p_index, 6, RID());
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(rpi->atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->depth_fb;
}
@@ -829,7 +829,7 @@ void RendererSceneRenderRD::_update_shadow_atlas(ShadowAtlas *shadow_atlas) {
}
void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(p_size < 0);
p_size = next_power_of_2(p_size);
@@ -851,7 +851,7 @@ void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool
//erase shadow atlas reference from lights
for (Map<RID, uint32_t>::Element *E = shadow_atlas->shadow_owners.front(); E; E = E->next()) {
- LightInstance *li = light_instance_owner.getornull(E->key());
+ LightInstance *li = light_instance_owner.get_or_null(E->key());
ERR_CONTINUE(!li);
li->shadow_atlases.erase(p_atlas);
}
@@ -864,7 +864,7 @@ void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool
}
void RendererSceneRenderRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_INDEX(p_quadrant, 4);
ERR_FAIL_INDEX(p_subdivision, 16384);
@@ -886,7 +886,7 @@ void RendererSceneRenderRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, i
for (int i = 0; i < shadow_atlas->quadrants[p_quadrant].shadows.size(); i++) {
if (shadow_atlas->quadrants[p_quadrant].shadows[i].owner.is_valid()) {
shadow_atlas->shadow_owners.erase(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
- LightInstance *li = light_instance_owner.getornull(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
+ LightInstance *li = light_instance_owner.get_or_null(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
ERR_CONTINUE(!li);
li->shadow_atlases.erase(p_atlas);
}
@@ -947,7 +947,7 @@ bool RendererSceneRenderRD::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
break;
}
- LightInstance *sli = light_instance_owner.getornull(sarr[j].owner);
+ LightInstance *sli = light_instance_owner.get_or_null(sarr[j].owner);
ERR_CONTINUE(!sli);
if (sli->last_scene_pass != scene_pass) {
@@ -999,7 +999,7 @@ bool RendererSceneRenderRD::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_
uint64_t pass = 0;
if (sarr[j].owner.is_valid()) {
- LightInstance *sli = light_instance_owner.getornull(sarr[j].owner);
+ LightInstance *sli = light_instance_owner.get_or_null(sarr[j].owner);
ERR_CONTINUE(!sli);
if (sli->last_scene_pass == scene_pass) {
@@ -1014,7 +1014,7 @@ bool RendererSceneRenderRD::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_
}
if (sarr[j + 1].owner.is_valid()) {
- LightInstance *sli = light_instance_owner.getornull(sarr[j + 1].owner);
+ LightInstance *sli = light_instance_owner.get_or_null(sarr[j + 1].owner);
ERR_CONTINUE(!sli);
if (sli->last_scene_pass == scene_pass) {
@@ -1053,10 +1053,10 @@ bool RendererSceneRenderRD::_shadow_atlas_find_omni_shadows(ShadowAtlas *shadow_
}
bool RendererSceneRenderRD::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!shadow_atlas, false);
- LightInstance *li = light_instance_owner.getornull(p_light_intance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_intance);
ERR_FAIL_COND_V(!li, false);
if (shadow_atlas->size == 0 || shadow_atlas->smallest_subdiv == 0) {
@@ -1179,7 +1179,7 @@ bool RendererSceneRenderRD::shadow_atlas_update_light(RID p_atlas, RID p_light_i
void RendererSceneRenderRD::_shadow_atlas_invalidate_shadow(RendererSceneRenderRD::ShadowAtlas::Quadrant::Shadow *p_shadow, RID p_atlas, RendererSceneRenderRD::ShadowAtlas *p_shadow_atlas, uint32_t p_quadrant, uint32_t p_shadow_idx) {
if (p_shadow->owner.is_valid()) {
- LightInstance *sli = light_instance_owner.getornull(p_shadow->owner);
+ LightInstance *sli = light_instance_owner.get_or_null(p_shadow->owner);
uint32_t old_key = p_shadow_atlas->shadow_owners[p_shadow->owner];
if (old_key & ShadowAtlas::OMNI_LIGHT_FLAG) {
@@ -1260,7 +1260,7 @@ int RendererSceneRenderRD::get_directional_light_shadow_size(RID p_light_intance
Rect2i r = _get_directional_shadow_rect(directional_shadow.size, directional_shadow.light_count, 0);
- LightInstance *light_instance = light_instance_owner.getornull(p_light_intance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_intance);
ERR_FAIL_COND_V(!light_instance, 0);
switch (storage->light_directional_get_shadow_mode(light_instance->light)) {
@@ -1296,7 +1296,7 @@ void RendererSceneRenderRD::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokeh
}
void RendererSceneRenderRD::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) {
- CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_camera_effects);
ERR_FAIL_COND(!camfx);
camfx->dof_blur_far_enabled = p_far_enable;
@@ -1311,7 +1311,7 @@ void RendererSceneRenderRD::camera_effects_set_dof_blur(RID p_camera_effects, bo
}
void RendererSceneRenderRD::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {
- CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_camera_effects);
ERR_FAIL_COND(!camfx);
camfx->override_exposure_enabled = p_enable;
@@ -1321,7 +1321,7 @@ void RendererSceneRenderRD::camera_effects_set_custom_exposure(RID p_camera_effe
RID RendererSceneRenderRD::light_instance_create(RID p_light) {
RID li = light_instance_owner.make_rid(LightInstance());
- LightInstance *light_instance = light_instance_owner.getornull(li);
+ LightInstance *light_instance = light_instance_owner.get_or_null(li);
light_instance->self = li;
light_instance->light = p_light;
@@ -1334,21 +1334,21 @@ RID RendererSceneRenderRD::light_instance_create(RID p_light) {
}
void RendererSceneRenderRD::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
light_instance->transform = p_transform;
}
void RendererSceneRenderRD::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
light_instance->aabb = p_aabb;
}
void RendererSceneRenderRD::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
ERR_FAIL_INDEX(p_pass, 6);
@@ -1364,7 +1364,7 @@ void RendererSceneRenderRD::light_instance_set_shadow_transform(RID p_light_inst
}
void RendererSceneRenderRD::light_instance_mark_visible(RID p_light_instance) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND(!light_instance);
light_instance->last_scene_pass = scene_pass;
@@ -1407,7 +1407,7 @@ RID RendererSceneRenderRD::decal_instance_create(RID p_decal) {
}
void RendererSceneRenderRD::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) {
- DecalInstance *di = decal_instance_owner.getornull(p_decal);
+ DecalInstance *di = decal_instance_owner.get_or_null(p_decal);
ERR_FAIL_COND(!di);
di->transform = p_transform;
}
@@ -1420,7 +1420,7 @@ RID RendererSceneRenderRD::lightmap_instance_create(RID p_lightmap) {
return lightmap_instance_owner.make_rid(li);
}
void RendererSceneRenderRD::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
- LightmapInstance *li = lightmap_instance_owner.getornull(p_lightmap);
+ LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!li);
li->transform = p_transform;
}
@@ -1452,7 +1452,7 @@ void RendererSceneRenderRD::voxel_gi_update(RID p_probe, bool p_update_light_ins
}
void RendererSceneRenderRD::_debug_sdfgi_probes(RID p_render_buffers, RD::DrawListID p_draw_list, RID p_framebuffer, const CameraMatrix &p_camera_with_transform) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
if (!rb->sdfgi) {
@@ -1790,7 +1790,7 @@ void RendererSceneRenderRD::_free_render_buffer_data(RenderBuffers *rb) {
}
void RendererSceneRenderRD::_process_sss(RID p_render_buffers, const CameraMatrix &p_camera) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
@@ -1808,7 +1808,7 @@ void RendererSceneRenderRD::_process_sss(RID p_render_buffers, const CameraMatri
}
void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_buffer, RID p_specular_buffer, RID p_metallic, const Color &p_metallic_mask, RID p_environment, const CameraMatrix &p_projection, bool p_use_additive) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
@@ -1819,7 +1819,7 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb
return;
}
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
ERR_FAIL_COND(!env);
ERR_FAIL_COND(!env->ssr_enabled);
@@ -1860,10 +1860,10 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb
}
void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environment, RID p_normal_buffer, const CameraMatrix &p_projection) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
ERR_FAIL_COND(!env);
RENDER_TIMESTAMP("Process SSAO");
@@ -2005,7 +2005,7 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen
}
void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
RD::get_singleton()->draw_command_begin_label("Copy screen texture");
@@ -2034,7 +2034,7 @@ void RendererSceneRenderRD::_render_buffers_copy_screen_texture(const RenderData
}
void RendererSceneRenderRD::_render_buffers_copy_depth_texture(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
RD::get_singleton()->draw_command_begin_label("Copy depth texture");
@@ -2057,12 +2057,12 @@ void RendererSceneRenderRD::_render_buffers_copy_depth_texture(const RenderDataR
}
void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_render_data->environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_render_data->environment);
//glow (if enabled)
- CameraEffects *camfx = camera_effects_owner.getornull(p_render_data->camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_render_data->camera_effects);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
bool can_use_storage = _render_buffers_can_be_storage();
@@ -2251,10 +2251,10 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende
void RendererSceneRenderRD::_post_process_subpass(RID p_source_texture, RID p_framebuffer, const RenderDataRD *p_render_data) {
RD::get_singleton()->draw_command_begin_label("Post Process Subpass");
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_render_data->environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_render_data->environment);
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
@@ -2311,7 +2311,7 @@ void RendererSceneRenderRD::_post_process_subpass(RID p_source_texture, RID p_fr
}
void RendererSceneRenderRD::_disable_clear_request(const RenderDataRD *p_render_data) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(!rb);
storage->render_target_disable_clear_request(rb->render_target);
@@ -2320,7 +2320,7 @@ void RendererSceneRenderRD::_disable_clear_request(const RenderDataRD *p_render_
void RendererSceneRenderRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_shadow_atlas, RID p_occlusion_buffer) {
EffectsRD *effects = storage->get_effects();
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS) {
@@ -2386,7 +2386,7 @@ void RendererSceneRenderRD::_render_buffers_debug_draw(RID p_render_buffers, RID
}
void RendererSceneRenderRD::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) {
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_env);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_env);
ERR_FAIL_COND(!env);
env->adjustments_enabled = p_enable;
@@ -2398,7 +2398,7 @@ void RendererSceneRenderRD::environment_set_adjustment(RID p_env, bool p_enable,
}
RID RendererSceneRenderRD::render_buffers_get_back_buffer_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->blur[0].texture.is_valid()) {
return RID(); //not valid at the moment
@@ -2407,7 +2407,7 @@ RID RendererSceneRenderRD::render_buffers_get_back_buffer_texture(RID p_render_b
}
RID RendererSceneRenderRD::render_buffers_get_back_depth_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->depth_back_texture.is_valid()) {
return RID(); //not valid at the moment
@@ -2415,15 +2415,22 @@ RID RendererSceneRenderRD::render_buffers_get_back_depth_texture(RID p_render_bu
return rb->depth_back_texture;
}
+RID RendererSceneRenderRD::render_buffers_get_depth_texture(RID p_render_buffers) {
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
+ ERR_FAIL_COND_V(!rb, RID());
+
+ return rb->depth_texture;
+}
+
RID RendererSceneRenderRD::render_buffers_get_ao_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->ssao.ao_final;
}
RID RendererSceneRenderRD::render_buffers_get_voxel_gi_buffer(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (rb->gi.voxel_gi_buffer.is_null()) {
rb->gi.voxel_gi_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(RendererSceneGIRD::VoxelGIData) * RendererSceneGIRD::MAX_VOXEL_GI_INSTANCES);
@@ -2436,31 +2443,31 @@ RID RendererSceneRenderRD::render_buffers_get_default_voxel_gi_buffer() {
}
RID RendererSceneRenderRD::render_buffers_get_gi_ambient_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->ambient_buffer;
}
RID RendererSceneRenderRD::render_buffers_get_gi_reflection_texture(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
return rb->reflection_buffer;
}
uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_count(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
return rb->sdfgi->cascades.size();
}
bool RendererSceneRenderRD::render_buffers_is_sdfgi_enabled(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, false);
return rb->sdfgi != nullptr;
}
RID RendererSceneRenderRD::render_buffers_get_sdfgi_irradiance_probes(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
ERR_FAIL_COND_V(!rb->sdfgi, RID());
@@ -2468,7 +2475,7 @@ RID RendererSceneRenderRD::render_buffers_get_sdfgi_irradiance_probes(RID p_rend
}
Vector3 RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_offset(RID p_render_buffers, uint32_t p_cascade) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, Vector3());
ERR_FAIL_COND_V(!rb->sdfgi, Vector3());
ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), Vector3());
@@ -2477,7 +2484,7 @@ Vector3 RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_offset(RID p_ren
}
Vector3i RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_offset(RID p_render_buffers, uint32_t p_cascade) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, Vector3i());
ERR_FAIL_COND_V(!rb->sdfgi, Vector3i());
ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), Vector3i());
@@ -2487,14 +2494,14 @@ Vector3i RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_offset(RI
}
float RendererSceneRenderRD::render_buffers_get_sdfgi_normal_bias(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
return rb->sdfgi->normal_bias;
}
float RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_size(RID p_render_buffers, uint32_t p_cascade) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
ERR_FAIL_UNSIGNED_INDEX_V(p_cascade, rb->sdfgi->cascades.size(), 0);
@@ -2502,7 +2509,7 @@ float RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_size(RID p_r
return float(rb->sdfgi->cascade_size) * rb->sdfgi->cascades[p_cascade].cell_size / float(rb->sdfgi->probe_axis_count - 1);
}
uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_count(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
@@ -2510,7 +2517,7 @@ uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_probe_count(RID
}
uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_size(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0);
ERR_FAIL_COND_V(!rb->sdfgi, 0);
@@ -2518,7 +2525,7 @@ uint32_t RendererSceneRenderRD::render_buffers_get_sdfgi_cascade_size(RID p_rend
}
bool RendererSceneRenderRD::render_buffers_is_sdfgi_using_occlusion(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, false);
ERR_FAIL_COND_V(!rb->sdfgi, false);
@@ -2526,14 +2533,14 @@ bool RendererSceneRenderRD::render_buffers_is_sdfgi_using_occlusion(RID p_render
}
float RendererSceneRenderRD::render_buffers_get_sdfgi_energy(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, 0.0);
ERR_FAIL_COND_V(!rb->sdfgi, 0.0);
return rb->sdfgi->energy;
}
RID RendererSceneRenderRD::render_buffers_get_sdfgi_occlusion_texture(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
ERR_FAIL_COND_V(!rb->sdfgi, RID());
@@ -2541,20 +2548,20 @@ RID RendererSceneRenderRD::render_buffers_get_sdfgi_occlusion_texture(RID p_rend
}
bool RendererSceneRenderRD::render_buffers_has_volumetric_fog(RID p_render_buffers) const {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, false);
return rb->volumetric_fog != nullptr;
}
RID RendererSceneRenderRD::render_buffers_get_volumetric_fog_texture(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb || !rb->volumetric_fog, RID());
return rb->volumetric_fog->fog_map;
}
RID RendererSceneRenderRD::render_buffers_get_volumetric_fog_sky_uniform_set(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->volumetric_fog) {
@@ -2565,12 +2572,12 @@ RID RendererSceneRenderRD::render_buffers_get_volumetric_fog_sky_uniform_set(RID
}
float RendererSceneRenderRD::render_buffers_get_volumetric_fog_end(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb || !rb->volumetric_fog, 0);
return rb->volumetric_fog->length;
}
float RendererSceneRenderRD::render_buffers_get_volumetric_fog_detail_spread(RID p_render_buffers) {
- const RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ const RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb || !rb->volumetric_fog, 0);
return rb->volumetric_fog->spread;
}
@@ -2590,7 +2597,7 @@ bool RendererSceneRenderRD::_render_buffers_can_be_storage() {
void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) {
ERR_FAIL_COND_MSG(p_view_count == 0, "Must have at least 1 view");
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
// Should we add an overrule per viewport?
rb->width = p_width;
@@ -2794,7 +2801,7 @@ bool RendererSceneRenderRD::is_using_radiance_cubemap_array() const {
}
RendererSceneRenderRD::RenderBufferData *RendererSceneRenderRD::render_buffers_get_data(RID p_render_buffers) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND_V(!rb, nullptr);
return rb->data;
}
@@ -2807,7 +2814,7 @@ void RendererSceneRenderRD::_setup_reflections(const PagedArray<RID> &p_reflecti
break;
}
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_reflections[i]);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_reflections[i]);
if (!rpi) {
continue;
}
@@ -2893,7 +2900,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
r_directional_light_soft_shadows = false;
for (int i = 0; i < (int)p_lights.size(); i++) {
- LightInstance *li = light_instance_owner.getornull(p_lights[i]);
+ LightInstance *li = light_instance_owner.get_or_null(p_lights[i]);
if (!li) {
continue;
}
@@ -3122,7 +3129,7 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const
ShadowAtlas *shadow_atlas = nullptr;
if (p_shadow_atlas.is_valid() && p_using_shadows) {
- shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
}
bool using_forward_ids = _uses_forward_ids();
@@ -3305,7 +3312,7 @@ void RendererSceneRenderRD::_setup_decals(const PagedArray<RID> &p_decals, const
break;
}
- DecalInstance *di = decal_instance_owner.getornull(p_decals[i]);
+ DecalInstance *di = decal_instance_owner.get_or_null(p_decals[i]);
if (!di) {
continue;
}
@@ -3488,9 +3495,9 @@ void RendererSceneRenderRD::_volumetric_fog_erase(RenderBuffers *rb) {
void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_voxel_gi_count) {
ERR_FAIL_COND(!is_clustered_enabled()); // can't use volumetric fog without clustered
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_environment);
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_environment);
float ratio = float(rb->width) / float((rb->width + rb->height) / 2);
uint32_t target_width = uint32_t(float(volumetric_fog_size) * ratio);
@@ -3559,7 +3566,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 1;
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
if (shadow_atlas == nullptr || shadow_atlas->depth.is_null()) {
u.ids.push_back(storage->texture_rd_get_default(RendererStorageRD::DEFAULT_RD_TEXTURE_BLACK));
} else {
@@ -3881,7 +3888,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e
bool RendererSceneRenderRD::_needs_post_prepass_render(RenderDataRD *p_render_data, bool p_use_gi) {
if (p_render_data->render_buffers.is_valid()) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
if (rb->sdfgi != nullptr) {
return true;
}
@@ -3892,14 +3899,14 @@ bool RendererSceneRenderRD::_needs_post_prepass_render(RenderDataRD *p_render_da
void RendererSceneRenderRD::_post_prepass_render(RenderDataRD *p_render_data, bool p_use_gi) {
if (p_render_data->render_buffers.is_valid()) {
if (p_use_gi) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(rb == nullptr);
if (rb->sdfgi == nullptr) {
return;
}
- RendererSceneEnvironmentRD *env = environment_owner.getornull(p_render_data->environment);
- rb->sdfgi->update_probes(env, sky.sky_owner.getornull(env->sky));
+ RendererSceneEnvironmentRD *env = environment_owner.get_or_null(p_render_data->environment);
+ rb->sdfgi->update_probes(env, sky.sky_owner.get_or_null(env->sky));
}
}
}
@@ -3916,7 +3923,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool
// Render shadows while GI is rendering, due to how barriers are handled, this should happen at the same time
if (p_render_data->render_buffers.is_valid() && p_use_gi) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_render_data->render_buffers);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_data->render_buffers);
ERR_FAIL_COND(rb == nullptr);
if (rb->sdfgi != nullptr) {
rb->sdfgi->store_probes();
@@ -3931,7 +3938,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool
float lod_distance_multiplier = p_render_data->cam_projection.get_lod_multiplier();
{
for (int i = 0; i < render_state.render_shadow_count; i++) {
- LightInstance *li = light_instance_owner.getornull(render_state.render_shadows[i].light);
+ LightInstance *li = light_instance_owner.get_or_null(render_state.render_shadows[i].light);
if (storage->light_get_type(li->light) == RS::LIGHT_DIRECTIONAL) {
render_state.directional_shadows.push_back(i);
@@ -4051,7 +4058,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData
// getting this here now so we can direct call a bunch of things more easily
RenderBuffers *rb = nullptr;
if (p_render_buffers.is_valid()) {
- rb = render_buffers_owner.getornull(p_render_buffers);
+ rb = render_buffers_owner.get_or_null(p_render_buffers);
ERR_FAIL_COND(!rb);
}
@@ -4133,7 +4140,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData
//assign render indices to voxel_gi_instances
if (is_dynamic_gi_supported()) {
for (uint32_t i = 0; i < (uint32_t)p_voxel_gi_instances.size(); i++) {
- RendererSceneGIRD::VoxelGIInstance *voxel_gi_inst = gi.voxel_gi_instance_owner.getornull(p_voxel_gi_instances[i]);
+ RendererSceneGIRD::VoxelGIInstance *voxel_gi_inst = gi.voxel_gi_instance_owner.get_or_null(p_voxel_gi_instances[i]);
if (voxel_gi_inst) {
voxel_gi_inst->render_index = i;
}
@@ -4144,8 +4151,8 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData
// render_data.render_buffers == p_render_buffers so we can use our already retrieved rb
current_cluster_builder = rb->cluster_builder;
} else if (reflection_probe_instance_owner.owns(render_data.reflection_probe)) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(render_data.reflection_probe);
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(rpi->atlas);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(render_data.reflection_probe);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(rpi->atlas);
if (!ra) {
ERR_PRINT("reflection probe has no reflection atlas! Bug?");
current_cluster_builder = nullptr;
@@ -4223,7 +4230,7 @@ void RendererSceneRenderRD::_debug_draw_cluster(RID p_render_buffers) {
}
void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<GeometryInstance *> &p_instances, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_lod_threshold, bool p_open_pass, bool p_close_pass, bool p_clear_region, RendererScene::RenderInfo *p_render_info) {
- LightInstance *light_instance = light_instance_owner.getornull(p_light);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_light);
ERR_FAIL_COND(!light_instance);
Rect2i atlas_rect;
@@ -4258,10 +4265,7 @@ void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas,
light_projection = light_instance->shadow_transform[p_pass].camera;
light_transform = light_instance->shadow_transform[p_pass].transform;
- atlas_rect.position.x = light_instance->directional_rect.position.x;
- atlas_rect.position.y = light_instance->directional_rect.position.y;
- atlas_rect.size.width = light_instance->directional_rect.size.x;
- atlas_rect.size.height = light_instance->directional_rect.size.y;
+ atlas_rect = light_instance->directional_rect;
if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
atlas_rect.size.width /= 2;
@@ -4272,8 +4276,7 @@ void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas,
} else if (p_pass == 2) {
atlas_rect.position.y += atlas_rect.size.height;
} else if (p_pass == 3) {
- atlas_rect.position.x += atlas_rect.size.width;
- atlas_rect.position.y += atlas_rect.size.height;
+ atlas_rect.position += atlas_rect.size;
}
} else if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
atlas_rect.size.height /= 2;
@@ -4298,7 +4301,7 @@ void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas,
} else {
//set from shadow atlas
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(!shadow_atlas->shadow_owners.has(p_light));
@@ -4382,10 +4385,8 @@ void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas,
_render_shadow_end();
//reblit
Rect2 atlas_rect_norm = atlas_rect;
- atlas_rect_norm.position.x /= float(atlas_size);
- atlas_rect_norm.position.y /= float(atlas_size);
- atlas_rect_norm.size.x /= float(atlas_size);
- atlas_rect_norm.size.y /= float(atlas_size);
+ atlas_rect_norm.position /= float(atlas_size);
+ atlas_rect_norm.size /= float(atlas_size);
storage->get_effects()->copy_cubemap_to_dp(render_texture, atlas_fb, atlas_rect_norm, atlas_rect.size, light_projection.get_z_near(), light_projection.get_z_far(), false);
atlas_rect_norm.position += Vector2(dual_paraboloid_offset) * atlas_rect_norm.size;
storage->get_effects()->copy_cubemap_to_dp(render_texture, atlas_fb, atlas_rect_norm, atlas_rect.size, light_projection.get_z_near(), light_projection.get_z_far(), true);
@@ -4423,7 +4424,7 @@ void RendererSceneRenderRD::render_particle_collider_heightfield(RID p_collider,
bool RendererSceneRenderRD::free(RID p_rid) {
if (render_buffers_owner.owns(p_rid)) {
- RenderBuffers *rb = render_buffers_owner.getornull(p_rid);
+ RenderBuffers *rb = render_buffers_owner.get_or_null(p_rid);
_free_render_buffer_data(rb);
memdelete(rb->data);
if (rb->sdfgi) {
@@ -4446,24 +4447,24 @@ bool RendererSceneRenderRD::free(RID p_rid) {
camera_effects_owner.free(p_rid);
} else if (reflection_atlas_owner.owns(p_rid)) {
reflection_atlas_set_size(p_rid, 0, 0);
- ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_rid);
+ ReflectionAtlas *ra = reflection_atlas_owner.get_or_null(p_rid);
if (ra->cluster_builder) {
memdelete(ra->cluster_builder);
}
reflection_atlas_owner.free(p_rid);
} else if (reflection_probe_instance_owner.owns(p_rid)) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_rid);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_rid);
_free_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE, rpi->forward_id);
reflection_probe_release_atlas_index(p_rid);
reflection_probe_instance_owner.free(p_rid);
} else if (decal_instance_owner.owns(p_rid)) {
- DecalInstance *di = decal_instance_owner.getornull(p_rid);
+ DecalInstance *di = decal_instance_owner.get_or_null(p_rid);
_free_forward_id(FORWARD_ID_TYPE_DECAL, di->forward_id);
decal_instance_owner.free(p_rid);
} else if (lightmap_instance_owner.owns(p_rid)) {
lightmap_instance_owner.free(p_rid);
} else if (gi.voxel_gi_instance_owner.owns(p_rid)) {
- RendererSceneGIRD::VoxelGIInstance *voxel_gi = gi.voxel_gi_instance_owner.getornull(p_rid);
+ RendererSceneGIRD::VoxelGIInstance *voxel_gi = gi.voxel_gi_instance_owner.get_or_null(p_rid);
if (voxel_gi->texture.is_valid()) {
RD::get_singleton()->free(voxel_gi->texture);
RD::get_singleton()->free(voxel_gi->write_buffer);
@@ -4479,11 +4480,11 @@ bool RendererSceneRenderRD::free(RID p_rid) {
sky.update_dirty_skys();
sky.free_sky(p_rid);
} else if (light_instance_owner.owns(p_rid)) {
- LightInstance *light_instance = light_instance_owner.getornull(p_rid);
+ LightInstance *light_instance = light_instance_owner.get_or_null(p_rid);
//remove from shadow atlases..
for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(E->get());
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(E->get());
ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
uint32_t key = shadow_atlas->shadow_owners[p_rid];
uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
index eb61af517a..fa80b84cfe 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
@@ -149,7 +149,7 @@ protected:
RendererSceneEnvironmentRD *get_environment(RID p_environment) {
if (p_environment.is_valid()) {
- return environment_owner.getornull(p_environment);
+ return environment_owner.get_or_null(p_environment);
} else {
return nullptr;
}
@@ -814,19 +814,19 @@ public:
virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) override;
virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) override;
_FORCE_INLINE_ bool shadow_atlas_owns_light_instance(RID p_atlas, RID p_light_intance) {
- ShadowAtlas *atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!atlas, false);
return atlas->shadow_owners.has(p_light_intance);
}
_FORCE_INLINE_ RID shadow_atlas_get_texture(RID p_atlas) {
- ShadowAtlas *atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->depth;
}
_FORCE_INLINE_ Size2i shadow_atlas_get_size(RID p_atlas) {
- ShadowAtlas *atlas = shadow_atlas_owner.getornull(p_atlas);
+ ShadowAtlas *atlas = shadow_atlas_owner.get_or_null(p_atlas);
ERR_FAIL_COND_V(!atlas, Size2i());
return Size2(atlas->size, atlas->size);
}
@@ -942,7 +942,7 @@ public:
virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) override;
bool camera_effects_uses_dof(RID p_camera_effects) {
- CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
+ CameraEffects *camfx = camera_effects_owner.get_or_null(p_camera_effects);
return camfx && (camfx->dof_blur_near_enabled || camfx->dof_blur_far_enabled) && camfx->dof_blur_amount > 0.0;
}
@@ -954,18 +954,18 @@ public:
virtual void light_instance_mark_visible(RID p_light_instance) override;
_FORCE_INLINE_ RID light_instance_get_base_light(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->light;
}
_FORCE_INLINE_ Transform3D light_instance_get_base_transform(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->transform;
}
_FORCE_INLINE_ Rect2 light_instance_get_shadow_atlas_rect(RID p_light_instance, RID p_shadow_atlas, Vector2i &r_omni_offset) {
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
uint32_t key = shadow_atlas->shadow_owners[li->self];
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
@@ -1000,16 +1000,16 @@ public:
}
_FORCE_INLINE_ CameraMatrix light_instance_get_shadow_camera(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].camera;
}
_FORCE_INLINE_ float light_instance_get_shadow_texel_size(RID p_light_instance, RID p_shadow_atlas) {
#ifdef DEBUG_ENABLED
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
ERR_FAIL_COND_V(!li->shadow_atlases.has(p_shadow_atlas), 0);
#endif
- ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
+ ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(p_shadow_atlas);
ERR_FAIL_COND_V(!shadow_atlas, 0);
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V(!shadow_atlas->shadow_owners.has(p_light_instance), 0);
@@ -1027,59 +1027,59 @@ public:
_FORCE_INLINE_ Transform3D
light_instance_get_shadow_transform(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].transform;
}
_FORCE_INLINE_ float light_instance_get_shadow_bias_scale(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].bias_scale;
}
_FORCE_INLINE_ float light_instance_get_shadow_range(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].farplane;
}
_FORCE_INLINE_ float light_instance_get_shadow_range_begin(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].range_begin;
}
_FORCE_INLINE_ Vector2 light_instance_get_shadow_uv_scale(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].uv_scale;
}
_FORCE_INLINE_ Rect2 light_instance_get_directional_shadow_atlas_rect(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].atlas_rect;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_split(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].split;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_texel_size(RID p_light_instance, int p_index) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->shadow_transform[p_index].shadow_texel_size;
}
_FORCE_INLINE_ void light_instance_set_render_pass(RID p_light_instance, uint64_t p_pass) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
li->last_pass = p_pass;
}
_FORCE_INLINE_ uint64_t light_instance_get_render_pass(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->last_pass;
}
_FORCE_INLINE_ ForwardID light_instance_get_forward_id(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->forward_id;
}
_FORCE_INLINE_ RS::LightType light_instance_get_type(RID p_light_instance) {
- LightInstance *li = light_instance_owner.getornull(p_light_instance);
+ LightInstance *li = light_instance_owner.get_or_null(p_light_instance);
return li->light_type;
}
@@ -1088,7 +1088,7 @@ public:
virtual int reflection_atlas_get_size(RID p_ref_atlas) const override;
_FORCE_INLINE_ RID reflection_atlas_get_texture(RID p_ref_atlas) {
- ReflectionAtlas *atlas = reflection_atlas_owner.getornull(p_ref_atlas);
+ ReflectionAtlas *atlas = reflection_atlas_owner.get_or_null(p_ref_atlas);
ERR_FAIL_COND_V(!atlas, RID());
return atlas->reflection;
}
@@ -1107,41 +1107,41 @@ public:
RID reflection_probe_instance_get_depth_framebuffer(RID p_instance, int p_index);
_FORCE_INLINE_ RID reflection_probe_instance_get_probe(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, RID());
return rpi->probe;
}
_FORCE_INLINE_ ForwardID reflection_probe_instance_get_forward_id(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, 0);
return rpi->forward_id;
}
_FORCE_INLINE_ void reflection_probe_instance_set_render_pass(RID p_instance, uint32_t p_render_pass) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!rpi);
rpi->last_pass = p_render_pass;
}
_FORCE_INLINE_ uint32_t reflection_probe_instance_get_render_pass(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, 0);
return rpi->last_pass;
}
_FORCE_INLINE_ Transform3D reflection_probe_instance_get_transform(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, Transform3D());
return rpi->transform;
}
_FORCE_INLINE_ int reflection_probe_instance_get_atlas_index(RID p_instance) {
- ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
+ ReflectionProbeInstance *rpi = reflection_probe_instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!rpi, -1);
return rpi->atlas_index;
@@ -1151,32 +1151,32 @@ public:
virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override;
_FORCE_INLINE_ RID decal_instance_get_base(RID p_decal) const {
- DecalInstance *decal = decal_instance_owner.getornull(p_decal);
+ DecalInstance *decal = decal_instance_owner.get_or_null(p_decal);
return decal->decal;
}
_FORCE_INLINE_ ForwardID decal_instance_get_forward_id(RID p_decal) const {
- DecalInstance *decal = decal_instance_owner.getornull(p_decal);
+ DecalInstance *decal = decal_instance_owner.get_or_null(p_decal);
return decal->forward_id;
}
_FORCE_INLINE_ Transform3D decal_instance_get_transform(RID p_decal) const {
- DecalInstance *decal = decal_instance_owner.getornull(p_decal);
+ DecalInstance *decal = decal_instance_owner.get_or_null(p_decal);
return decal->transform;
}
virtual RID lightmap_instance_create(RID p_lightmap) override;
virtual void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override;
_FORCE_INLINE_ bool lightmap_instance_is_valid(RID p_lightmap_instance) {
- return lightmap_instance_owner.getornull(p_lightmap_instance) != nullptr;
+ return lightmap_instance_owner.get_or_null(p_lightmap_instance) != nullptr;
}
_FORCE_INLINE_ RID lightmap_instance_get_lightmap(RID p_lightmap_instance) {
- LightmapInstance *li = lightmap_instance_owner.getornull(p_lightmap_instance);
+ LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap_instance);
return li->lightmap;
}
_FORCE_INLINE_ Transform3D lightmap_instance_get_transform(RID p_lightmap_instance) {
- LightmapInstance *li = lightmap_instance_owner.getornull(p_lightmap_instance);
+ LightmapInstance *li = lightmap_instance_owner.get_or_null(p_lightmap_instance);
return li->transform;
}
@@ -1197,6 +1197,7 @@ public:
virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override;
virtual void gi_set_use_half_resolution(bool p_enable) override;
+ RID render_buffers_get_depth_texture(RID p_render_buffers);
RID render_buffers_get_ao_texture(RID p_render_buffers);
RID render_buffers_get_back_buffer_texture(RID p_render_buffers);
RID render_buffers_get_back_depth_texture(RID p_render_buffers);
diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
index c388da755c..14a4111038 100644
--- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp
@@ -1772,7 +1772,7 @@ void RendererSceneSkyRD::initialize_sky_rid(RID p_rid) {
}
RendererSceneSkyRD::Sky *RendererSceneSkyRD::get_sky(RID p_sky) const {
- return sky_owner.getornull(p_sky);
+ return sky_owner.get_or_null(p_sky);
}
void RendererSceneSkyRD::free_sky(RID p_sky) {
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index ec0d25376f..a0751d3689 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -842,7 +842,7 @@ void RendererStorageRD::texture_3d_initialize(RID p_texture, Image::Format p_for
}
void RendererStorageRD::texture_proxy_initialize(RID p_texture, RID p_base) {
- Texture *tex = texture_owner.getornull(p_base);
+ Texture *tex = texture_owner.get_or_null(p_base);
ERR_FAIL_COND(!tex);
Texture proxy_tex = *tex;
@@ -865,7 +865,7 @@ void RendererStorageRD::texture_proxy_initialize(RID p_texture, RID p_base) {
void RendererStorageRD::_texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate) {
ERR_FAIL_COND(p_image.is_null() || p_image->is_empty());
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->is_render_target);
ERR_FAIL_COND(p_image->get_width() != tex->width || p_image->get_height() != tex->height);
@@ -889,7 +889,7 @@ void RendererStorageRD::texture_2d_update(RID p_texture, const Ref<Image> &p_ima
}
void RendererStorageRD::texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->type != Texture::TYPE_3D);
Image::Image3DValidateError verr = Image::validate_3d_image(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps > 1, p_data);
@@ -926,10 +926,10 @@ void RendererStorageRD::texture_3d_update(RID p_texture, const Vector<Ref<Image>
}
void RendererStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(!tex->is_proxy);
- Texture *proxy_to = texture_owner.getornull(p_proxy_to);
+ Texture *proxy_to = texture_owner.get_or_null(p_proxy_to);
ERR_FAIL_COND(!proxy_to);
ERR_FAIL_COND(proxy_to->is_proxy);
@@ -943,7 +943,7 @@ void RendererStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
RD::get_singleton()->free(tex->rd_texture_srgb);
tex->rd_texture_srgb = RID();
}
- Texture *prev_tex = texture_owner.getornull(tex->proxy_to);
+ Texture *prev_tex = texture_owner.get_or_null(tex->proxy_to);
ERR_FAIL_COND(!prev_tex);
prev_tex->proxies.erase(p_texture);
}
@@ -1030,7 +1030,7 @@ void RendererStorageRD::texture_3d_placeholder_initialize(RID p_texture) {
}
Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Ref<Image>());
#ifdef TOOLS_ENABLED
@@ -1058,7 +1058,7 @@ Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
}
Ref<Image> RendererStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) const {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Ref<Image>());
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
@@ -1075,7 +1075,7 @@ Ref<Image> RendererStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) c
}
Vector<Ref<Image>> RendererStorageRD::texture_3d_get(RID p_texture) const {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND_V(!tex, Vector<Ref<Image>>());
ERR_FAIL_COND_V(tex->type != Texture::TYPE_3D, Vector<Ref<Image>>());
@@ -1106,10 +1106,10 @@ Vector<Ref<Image>> RendererStorageRD::texture_3d_get(RID p_texture) const {
}
void RendererStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->proxy_to.is_valid()); //can't replace proxy
- Texture *by_tex = texture_owner.getornull(p_by_texture);
+ Texture *by_tex = texture_owner.get_or_null(p_by_texture);
ERR_FAIL_COND(!by_tex);
ERR_FAIL_COND(by_tex->proxy_to.is_valid()); //can't replace proxy
@@ -1155,7 +1155,7 @@ void RendererStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
}
void RendererStorageRD::texture_set_size_override(RID p_texture, int p_width, int p_height) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->type != Texture::TYPE_2D);
tex->width_2d = p_width;
@@ -1163,7 +1163,7 @@ void RendererStorageRD::texture_set_size_override(RID p_texture, int p_width, in
}
void RendererStorageRD::texture_set_path(RID p_texture, const String &p_path) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->path = p_path;
}
@@ -1173,21 +1173,21 @@ String RendererStorageRD::texture_get_path(RID p_texture) const {
}
void RendererStorageRD::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_3d_callback_ud = p_userdata;
tex->detect_3d_callback = p_callback;
}
void RendererStorageRD::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_normal_callback_ud = p_userdata;
tex->detect_normal_callback = p_callback;
}
void RendererStorageRD::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_roughness_callback_ud = p_userdata;
tex->detect_roughness_callback = p_callback;
@@ -1235,7 +1235,7 @@ void RendererStorageRD::canvas_texture_initialize(RID p_rid) {
}
void RendererStorageRD::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
switch (p_channel) {
case RS::CANVAS_TEXTURE_CHANNEL_DIFFUSE: {
ct->diffuse = p_texture;
@@ -1252,7 +1252,7 @@ void RendererStorageRD::canvas_texture_set_channel(RID p_canvas_texture, RS::Can
}
void RendererStorageRD::canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_specular_color, float p_shininess) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ct->specular_color.r = p_specular_color.r;
ct->specular_color.g = p_specular_color.g;
ct->specular_color.b = p_specular_color.b;
@@ -1261,13 +1261,13 @@ void RendererStorageRD::canvas_texture_set_shading_parameters(RID p_canvas_textu
}
void RendererStorageRD::canvas_texture_set_texture_filter(RID p_canvas_texture, RS::CanvasItemTextureFilter p_filter) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ct->texture_filter = p_filter;
ct->clear_sets();
}
void RendererStorageRD::canvas_texture_set_texture_repeat(RID p_canvas_texture, RS::CanvasItemTextureRepeat p_repeat) {
- CanvasTexture *ct = canvas_texture_owner.getornull(p_canvas_texture);
+ CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
ct->texture_repeat = p_repeat;
ct->clear_sets();
}
@@ -1275,7 +1275,7 @@ void RendererStorageRD::canvas_texture_set_texture_repeat(RID p_canvas_texture,
bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, RID p_base_shader, int p_base_set, RID &r_uniform_set, Size2i &r_size, Color &r_specular_shininess, bool &r_use_normal, bool &r_use_specular) {
CanvasTexture *ct = nullptr;
- Texture *t = texture_owner.getornull(p_texture);
+ Texture *t = texture_owner.get_or_null(p_texture);
if (t) {
//regular texture
@@ -1286,7 +1286,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
ct = t->canvas_texture;
} else {
- ct = canvas_texture_owner.getornull(p_texture);
+ ct = canvas_texture_owner.get_or_null(p_texture);
}
if (!ct) {
@@ -1308,7 +1308,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 0;
- t = texture_owner.getornull(ct->diffuse);
+ t = texture_owner.get_or_null(ct->diffuse);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE));
ct->size_cache = Size2i(1, 1);
@@ -1323,7 +1323,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 1;
- t = texture_owner.getornull(ct->normal_map);
+ t = texture_owner.get_or_null(ct->normal_map);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_NORMAL));
ct->use_normal_cache = false;
@@ -1338,7 +1338,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 2;
- t = texture_owner.getornull(ct->specular);
+ t = texture_owner.get_or_null(ct->specular);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE));
ct->use_specular_cache = false;
@@ -1384,7 +1384,7 @@ void RendererStorageRD::shader_initialize(RID p_rid) {
}
void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
shader->code = p_code;
@@ -1456,13 +1456,13 @@ void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) {
}
String RendererStorageRD::shader_get_code(RID p_shader) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, String());
return shader->code;
}
void RendererStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
if (shader->data) {
return shader->data->get_param_list(p_param_list);
@@ -1470,7 +1470,7 @@ void RendererStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo> *
}
void RendererStorageRD::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
if (p_texture.is_valid() && texture_owner.owns(p_texture)) {
@@ -1488,7 +1488,7 @@ void RendererStorageRD::shader_set_default_texture_param(RID p_shader, const Str
}
RID RendererStorageRD::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RID());
if (shader->default_texture_parameter.has(p_name)) {
return shader->default_texture_parameter[p_name];
@@ -1498,7 +1498,7 @@ RID RendererStorageRD::shader_get_default_texture_param(RID p_shader, const Stri
}
Variant RendererStorageRD::shader_get_param_default(RID p_shader, const StringName &p_param) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, Variant());
if (shader->data) {
return shader->data->get_default_parameter(p_param);
@@ -1512,7 +1512,7 @@ void RendererStorageRD::shader_set_data_request_function(ShaderType p_shader_typ
}
RS::ShaderNativeSourceCode RendererStorageRD::shader_get_native_source_code(RID p_shader) const {
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND_V(!shader, RS::ShaderNativeSourceCode());
if (shader->data) {
return shader->data->get_native_source_code();
@@ -1527,7 +1527,7 @@ RID RendererStorageRD::material_allocate() {
}
void RendererStorageRD::material_initialize(RID p_rid) {
material_owner.initialize_rid(p_rid);
- Material *material = material_owner.getornull(p_rid);
+ Material *material = material_owner.get_or_null(p_rid);
material->self = p_rid;
}
@@ -1543,7 +1543,7 @@ void RendererStorageRD::_material_queue_update(Material *material, bool p_unifor
}
void RendererStorageRD::material_set_shader(RID p_material, RID p_shader) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (material->data) {
@@ -1563,7 +1563,7 @@ void RendererStorageRD::material_set_shader(RID p_material, RID p_shader) {
return;
}
- Shader *shader = shader_owner.getornull(p_shader);
+ Shader *shader = shader_owner.get_or_null(p_shader);
ERR_FAIL_COND(!shader);
material->shader = shader;
material->shader_type = shader->type;
@@ -1586,7 +1586,7 @@ void RendererStorageRD::material_set_shader(RID p_material, RID p_shader) {
}
void RendererStorageRD::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (p_value.get_type() == Variant::NIL) {
@@ -1605,7 +1605,7 @@ void RendererStorageRD::material_set_param(RID p_material, const StringName &p_p
}
Variant RendererStorageRD::material_get_param(RID p_material, const StringName &p_param) const {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND_V(!material, Variant());
if (material->params.has(p_param)) {
return material->params[p_param];
@@ -1615,7 +1615,7 @@ Variant RendererStorageRD::material_get_param(RID p_material, const StringName &
}
void RendererStorageRD::material_set_next_pass(RID p_material, RID p_next_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (material->next_pass == p_next_material) {
@@ -1631,7 +1631,7 @@ void RendererStorageRD::material_set_next_pass(RID p_material, RID p_next_materi
}
void RendererStorageRD::material_set_render_priority(RID p_material, int priority) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
material->priority = priority;
if (material->data) {
@@ -1640,7 +1640,7 @@ void RendererStorageRD::material_set_render_priority(RID p_material, int priorit
}
bool RendererStorageRD::material_is_animated(RID p_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND_V(!material, false);
if (material->shader && material->shader->data) {
if (material->shader->data->is_animated()) {
@@ -1653,7 +1653,7 @@ bool RendererStorageRD::material_is_animated(RID p_material) {
}
bool RendererStorageRD::material_casts_shadows(RID p_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND_V(!material, true);
if (material->shader && material->shader->data) {
if (material->shader->data->casts_shadows()) {
@@ -1666,7 +1666,7 @@ bool RendererStorageRD::material_casts_shadows(RID p_material) {
}
void RendererStorageRD::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
if (material->shader && material->shader->data) {
material->shader->data->get_instance_param_list(r_parameters);
@@ -1678,7 +1678,7 @@ void RendererStorageRD::material_get_instance_shader_parameters(RID p_material,
}
void RendererStorageRD::material_update_dependency(RID p_material, DependencyTracker *p_instance) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
ERR_FAIL_COND(!material);
p_instance->update_dependency(&material->dependency);
if (material->next_pass.is_valid()) {
@@ -2309,7 +2309,7 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari
} else {
bool srgb = p_use_linear_color && (p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO);
- Texture *tex = singleton->texture_owner.getornull(texture);
+ Texture *tex = singleton->texture_owner.get_or_null(texture);
if (tex) {
rd_texture = (srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
@@ -2470,14 +2470,14 @@ bool RendererStorageRD::MaterialData::update_parameters_uniform_set(const Map<St
void RendererStorageRD::_material_uniform_set_erased(const RID &p_set, void *p_material) {
RID rid = *(RID *)p_material;
- Material *material = base_singleton->material_owner.getornull(rid);
+ Material *material = base_singleton->material_owner.get_or_null(rid);
if (material) {
material->dependency.changed_notify(DEPENDENCY_CHANGED_MATERIAL);
}
}
void RendererStorageRD::material_force_update_textures(RID p_material, ShaderType p_shader_type) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
if (material->shader_type != p_shader_type) {
return;
}
@@ -2518,7 +2518,7 @@ void RendererStorageRD::mesh_initialize(RID p_rid) {
void RendererStorageRD::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) {
ERR_FAIL_COND(p_blend_shape_count < 0);
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_COND(mesh->surface_count > 0); //surfaces already exist
@@ -2528,7 +2528,7 @@ void RendererStorageRD::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape
/// Returns stride
void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_COND(mesh->surface_count == RS::MAX_MESH_SURFACES);
@@ -2732,13 +2732,13 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su
}
int RendererStorageRD::mesh_get_blend_shape_count(RID p_mesh) const {
- const Mesh *mesh = mesh_owner.getornull(p_mesh);
+ const Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, -1);
return mesh->blend_shape_count;
}
void RendererStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX((int)p_mode, 2);
@@ -2746,13 +2746,13 @@ void RendererStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode
}
RS::BlendShapeMode RendererStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
return mesh->blend_shape_mode;
}
void RendererStorageRD::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
@@ -2763,7 +2763,7 @@ void RendererStorageRD::mesh_surface_update_vertex_region(RID p_mesh, int p_surf
}
void RendererStorageRD::mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
@@ -2775,7 +2775,7 @@ void RendererStorageRD::mesh_surface_update_attribute_region(RID p_mesh, int p_s
}
void RendererStorageRD::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
ERR_FAIL_COND(p_data.size() == 0);
@@ -2787,7 +2787,7 @@ void RendererStorageRD::mesh_surface_update_skin_region(RID p_mesh, int p_surfac
}
void RendererStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count);
mesh->surfaces[p_surface]->material = p_material;
@@ -2797,7 +2797,7 @@ void RendererStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, RID
}
RID RendererStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RID());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RID());
@@ -2805,7 +2805,7 @@ RID RendererStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) cons
}
RS::SurfaceData RendererStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RS::SurfaceData());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData());
@@ -2845,32 +2845,32 @@ RS::SurfaceData RendererStorageRD::mesh_get_surface(RID p_mesh, int p_surface) c
}
int RendererStorageRD::mesh_get_surface_count(RID p_mesh) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, 0);
return mesh->surface_count;
}
void RendererStorageRD::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
mesh->custom_aabb = p_aabb;
}
AABB RendererStorageRD::mesh_get_custom_aabb(RID p_mesh) const {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, AABB());
return mesh->custom_aabb;
}
AABB RendererStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, AABB());
if (mesh->custom_aabb != AABB()) {
return mesh->custom_aabb;
}
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
if (!skeleton || skeleton->size == 0) {
return mesh->aabb;
@@ -2968,16 +2968,16 @@ AABB RendererStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
}
void RendererStorageRD::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
- Mesh *shadow_mesh = mesh_owner.getornull(mesh->shadow_mesh);
+ Mesh *shadow_mesh = mesh_owner.get_or_null(mesh->shadow_mesh);
if (shadow_mesh) {
shadow_mesh->shadow_owners.erase(mesh);
}
mesh->shadow_mesh = p_shadow_mesh;
- shadow_mesh = mesh_owner.getornull(mesh->shadow_mesh);
+ shadow_mesh = mesh_owner.get_or_null(mesh->shadow_mesh);
if (shadow_mesh) {
shadow_mesh->shadow_owners.insert(mesh);
@@ -2987,7 +2987,7 @@ void RendererStorageRD::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) {
}
void RendererStorageRD::mesh_clear(RID p_mesh) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND(!mesh);
for (uint32_t i = 0; i < mesh->surface_count; i++) {
Mesh::Surface &s = *mesh->surfaces[i];
@@ -3041,7 +3041,7 @@ void RendererStorageRD::mesh_clear(RID p_mesh) {
}
bool RendererStorageRD::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, false);
return mesh->blend_shape_count > 0 || (mesh->has_bone_weights && p_has_skeleton);
@@ -3050,11 +3050,11 @@ bool RendererStorageRD::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) {
/* MESH INSTANCE */
RID RendererStorageRD::mesh_instance_create(RID p_base) {
- Mesh *mesh = mesh_owner.getornull(p_base);
+ Mesh *mesh = mesh_owner.get_or_null(p_base);
ERR_FAIL_COND_V(!mesh, RID());
RID rid = mesh_instance_owner.make_rid();
- MeshInstance *mi = mesh_instance_owner.getornull(rid);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(rid);
mi->mesh = mesh;
@@ -3069,7 +3069,7 @@ RID RendererStorageRD::mesh_instance_create(RID p_base) {
return rid;
}
void RendererStorageRD::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_skeleton) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
if (mi->skeleton == p_skeleton) {
return;
}
@@ -3079,7 +3079,7 @@ void RendererStorageRD::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_sk
}
void RendererStorageRD::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int p_shape, float p_weight) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
ERR_FAIL_COND(!mi);
ERR_FAIL_INDEX(p_shape, (int)mi->blend_weights.size());
mi->blend_weights[p_shape] = p_weight;
@@ -3151,7 +3151,7 @@ void RendererStorageRD::_mesh_instance_add_surface(MeshInstance *mi, Mesh *mesh,
}
void RendererStorageRD::mesh_instance_check_for_update(RID p_mesh_instance) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
bool needs_update = mi->dirty;
@@ -3165,7 +3165,7 @@ void RendererStorageRD::mesh_instance_check_for_update(RID p_mesh_instance) {
}
if (!needs_update && mi->skeleton.is_valid()) {
- Skeleton *sk = skeleton_owner.getornull(mi->skeleton);
+ Skeleton *sk = skeleton_owner.get_or_null(mi->skeleton);
if (sk && sk->version != mi->skeleton_version) {
needs_update = true;
}
@@ -3196,7 +3196,7 @@ void RendererStorageRD::update_mesh_instances() {
while (dirty_mesh_instance_arrays.first()) {
MeshInstance *mi = dirty_mesh_instance_arrays.first()->self();
- Skeleton *sk = skeleton_owner.getornull(mi->skeleton);
+ Skeleton *sk = skeleton_owner.get_or_null(mi->skeleton);
for (uint32_t i = 0; i < mi->surfaces.size(); i++) {
if (mi->surfaces[i].uniform_set == RID() || mi->mesh->surfaces[i]->uniform_set == RID()) {
@@ -3443,7 +3443,7 @@ void RendererStorageRD::multimesh_initialize(RID p_rid) {
}
void RendererStorageRD::multimesh_allocate_data(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);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
if (multimesh->instances == p_instances && multimesh->xform_format == p_transform_format && multimesh->uses_colors == p_use_colors && multimesh->uses_custom_data == p_use_custom_data) {
@@ -3486,13 +3486,13 @@ void RendererStorageRD::multimesh_allocate_data(RID p_multimesh, int p_instances
}
int RendererStorageRD::multimesh_get_instance_count(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, 0);
return multimesh->instances;
}
void RendererStorageRD::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
if (multimesh->mesh == p_mesh) {
return;
@@ -3638,7 +3638,7 @@ void RendererStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const fl
}
void RendererStorageRD::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D);
@@ -3668,7 +3668,7 @@ void RendererStorageRD::multimesh_instance_set_transform(RID p_multimesh, int p_
}
void RendererStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D);
@@ -3694,7 +3694,7 @@ void RendererStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, int
}
void RendererStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(!multimesh->uses_colors);
@@ -3716,7 +3716,7 @@ void RendererStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_inde
}
void RendererStorageRD::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
ERR_FAIL_COND(!multimesh->uses_custom_data);
@@ -3738,14 +3738,14 @@ void RendererStorageRD::multimesh_instance_set_custom_data(RID p_multimesh, int
}
RID RendererStorageRD::multimesh_get_mesh(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, RID());
return multimesh->mesh;
}
Transform3D RendererStorageRD::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform3D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform3D());
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D, Transform3D());
@@ -3776,7 +3776,7 @@ Transform3D RendererStorageRD::multimesh_instance_get_transform(RID p_multimesh,
}
Transform2D RendererStorageRD::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform2D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D, Transform2D());
@@ -3801,7 +3801,7 @@ Transform2D RendererStorageRD::multimesh_instance_get_transform_2d(RID p_multime
}
Color RendererStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
ERR_FAIL_COND_V(!multimesh->uses_colors, Color());
@@ -3824,7 +3824,7 @@ Color RendererStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_ind
}
Color RendererStorageRD::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
ERR_FAIL_COND_V(!multimesh->uses_custom_data, Color());
@@ -3847,7 +3847,7 @@ Color RendererStorageRD::multimesh_instance_get_custom_data(RID p_multimesh, int
}
void RendererStorageRD::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
@@ -3880,7 +3880,7 @@ void RendererStorageRD::multimesh_set_buffer(RID p_multimesh, const Vector<float
}
Vector<float> RendererStorageRD::multimesh_get_buffer(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Vector<float>());
if (multimesh->buffer.is_null()) {
return Vector<float>();
@@ -3903,7 +3903,7 @@ Vector<float> RendererStorageRD::multimesh_get_buffer(RID p_multimesh) const {
}
void RendererStorageRD::multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(p_visible < -1 || p_visible > multimesh->instances);
if (multimesh->visible_instances == p_visible) {
@@ -3921,13 +3921,13 @@ void RendererStorageRD::multimesh_set_visible_instances(RID p_multimesh, int p_v
}
int RendererStorageRD::multimesh_get_visible_instances(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, 0);
return multimesh->visible_instances;
}
AABB RendererStorageRD::multimesh_get_aabb(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, AABB());
if (multimesh->aabb_dirty) {
const_cast<RendererStorageRD *>(this)->_update_dirty_multimeshes();
@@ -3998,7 +3998,7 @@ void RendererStorageRD::particles_initialize(RID p_rid) {
}
void RendererStorageRD::particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->mode == p_mode) {
return;
@@ -4010,7 +4010,7 @@ void RendererStorageRD::particles_set_mode(RID p_particles, RS::ParticlesMode p_
}
void RendererStorageRD::particles_set_emitting(RID p_particles, bool p_emitting) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->emitting = p_emitting;
@@ -4018,7 +4018,7 @@ void RendererStorageRD::particles_set_emitting(RID p_particles, bool p_emitting)
bool RendererStorageRD::particles_get_emitting(RID p_particles) {
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, false);
return particles->emitting;
@@ -4073,7 +4073,7 @@ void RendererStorageRD::_particles_free_data(Particles *particles) {
}
void RendererStorageRD::particles_set_amount(RID p_particles, int p_amount) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->amount == p_amount) {
@@ -4093,55 +4093,56 @@ void RendererStorageRD::particles_set_amount(RID p_particles, int p_amount) {
}
void RendererStorageRD::particles_set_lifetime(RID p_particles, double p_lifetime) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->lifetime = p_lifetime;
}
void RendererStorageRD::particles_set_one_shot(RID p_particles, bool p_one_shot) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->one_shot = p_one_shot;
}
void RendererStorageRD::particles_set_pre_process_time(RID p_particles, double p_time) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->pre_process_time = p_time;
}
void RendererStorageRD::particles_set_explosiveness_ratio(RID p_particles, real_t p_ratio) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->explosiveness = p_ratio;
}
void RendererStorageRD::particles_set_randomness_ratio(RID p_particles, real_t p_ratio) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->randomness = p_ratio;
}
void RendererStorageRD::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->custom_aabb = p_aabb;
particles->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::particles_set_speed_scale(RID p_particles, double p_scale) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->speed_scale = p_scale;
}
void RendererStorageRD::particles_set_use_local_coordinates(RID p_particles, bool p_enable) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->use_local_coords = p_enable;
+ particles->dependency.changed_notify(DEPENDENCY_CHANGED_PARTICLES);
}
void RendererStorageRD::particles_set_fixed_fps(RID p_particles, int p_fps) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->fixed_fps = p_fps;
@@ -4157,21 +4158,21 @@ void RendererStorageRD::particles_set_fixed_fps(RID p_particles, int p_fps) {
}
void RendererStorageRD::particles_set_interpolate(RID p_particles, bool p_enable) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->interpolate = p_enable;
}
void RendererStorageRD::particles_set_fractional_delta(RID p_particles, bool p_enable) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->fractional_delta = p_enable;
}
void RendererStorageRD::particles_set_trails(RID p_particles, bool p_enable, double p_length) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_COND(p_length < 0.1);
p_length = MIN(10.0, p_length);
@@ -4190,7 +4191,7 @@ void RendererStorageRD::particles_set_trails(RID p_particles, bool p_enable, dou
}
void RendererStorageRD::particles_set_trail_bind_poses(RID p_particles, const Vector<Transform3D> &p_bind_poses) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->trail_bind_pose_buffer.is_valid() && particles->trail_bind_poses.size() != p_bind_poses.size()) {
_particles_free_data(particles);
@@ -4207,49 +4208,49 @@ void RendererStorageRD::particles_set_trail_bind_poses(RID p_particles, const Ve
}
void RendererStorageRD::particles_set_collision_base_size(RID p_particles, real_t p_size) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->collision_base_size = p_size;
}
void RendererStorageRD::particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->transform_align = p_transform_align;
}
void RendererStorageRD::particles_set_process_material(RID p_particles, RID p_material) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->process_material = p_material;
}
void RendererStorageRD::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->draw_order = p_order;
}
void RendererStorageRD::particles_set_draw_passes(RID p_particles, int p_passes) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->draw_passes.resize(p_passes);
}
void RendererStorageRD::particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_INDEX(p_pass, particles->draw_passes.size());
particles->draw_passes.write[p_pass] = p_mesh;
}
void RendererStorageRD::particles_restart(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->restart_request = true;
@@ -4273,7 +4274,7 @@ void RendererStorageRD::_particles_allocate_emission_buffer(Particles *particles
}
void RendererStorageRD::particles_set_subemitter(RID p_particles, RID p_subemitter_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_COND(p_particles == p_subemitter_particles);
@@ -4286,7 +4287,7 @@ void RendererStorageRD::particles_set_subemitter(RID p_particles, RID p_subemitt
}
void RendererStorageRD::particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
ERR_FAIL_COND(particles->amount == 0);
@@ -4329,7 +4330,7 @@ void RendererStorageRD::particles_emit(RID p_particles, const Transform3D &p_tra
}
void RendererStorageRD::particles_request_process(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (!particles->dirty) {
@@ -4344,7 +4345,7 @@ AABB RendererStorageRD::particles_get_current_aabb(RID p_particles) {
WARN_PRINT_ONCE("Calling this function with threaded rendering enabled stalls the renderer, use with care.");
}
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, AABB());
int total_amount = particles->amount;
@@ -4352,10 +4353,8 @@ AABB RendererStorageRD::particles_get_current_aabb(RID p_particles) {
total_amount *= particles->trail_bind_poses.size();
}
- Vector<ParticleData> data;
- data.resize(total_amount);
-
Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(particles->particle_buffer);
+ ERR_FAIL_COND_V(buffer.size() != (int)(total_amount * sizeof(ParticleData)), AABB());
Transform3D inv = particles->emission_transform.affine_inverse();
@@ -4363,7 +4362,7 @@ AABB RendererStorageRD::particles_get_current_aabb(RID p_particles) {
if (buffer.size()) {
bool first = true;
- const ParticleData *particle_data = (const ParticleData *)data.ptr();
+ const ParticleData *particle_data = reinterpret_cast<const ParticleData *>(buffer.ptr());
for (int i = 0; i < total_amount; i++) {
if (particle_data[i].active) {
Vector3 pos = Vector3(particle_data[i].xform[12], particle_data[i].xform[13], particle_data[i].xform[14]);
@@ -4394,28 +4393,28 @@ AABB RendererStorageRD::particles_get_current_aabb(RID p_particles) {
}
AABB RendererStorageRD::particles_get_aabb(RID p_particles) const {
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, AABB());
return particles->custom_aabb;
}
void RendererStorageRD::particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->emission_transform = p_transform;
}
int RendererStorageRD::particles_get_draw_passes(RID p_particles) const {
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, 0);
return particles->draw_passes.size();
}
RID RendererStorageRD::particles_get_draw_pass_mesh(RID p_particles, int p_pass) const {
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, RID());
ERR_FAIL_INDEX_V(p_pass, particles->draw_passes.size(), RID());
@@ -4423,19 +4422,19 @@ RID RendererStorageRD::particles_get_draw_pass_mesh(RID p_particles, int p_pass)
}
void RendererStorageRD::particles_add_collision(RID p_particles, RID p_particles_collision_instance) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->collisions.insert(p_particles_collision_instance);
}
void RendererStorageRD::particles_remove_collision(RID p_particles, RID p_particles_collision_instance) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->collisions.erase(p_particles_collision_instance);
}
void RendererStorageRD::particles_set_canvas_sdf_collision(RID p_particles, bool p_enable, const Transform2D &p_xform, const Rect2 &p_to_screen, RID p_texture) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
particles->has_sdf_collision = p_enable;
particles->sdf_collision_transform = p_xform;
@@ -4477,7 +4476,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
RD::Uniform u;
u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 3;
- Particles *sub_emitter = particles_owner.getornull(p_particles->sub_emitter);
+ Particles *sub_emitter = particles_owner.get_or_null(p_particles->sub_emitter);
if (sub_emitter) {
if (sub_emitter->emission_buffer == nullptr) { //no emission buffer, allocate emission buffer
_particles_allocate_emission_buffer(sub_emitter);
@@ -4594,11 +4593,11 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
uint32_t collision_3d_textures_used = 0;
for (const Set<RID>::Element *E = p_particles->collisions.front(); E; E = E->next()) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.getornull(E->get());
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(E->get());
if (!pci || !pci->active) {
continue;
}
- ParticlesCollision *pc = particles_collision_owner.getornull(pci->collision);
+ ParticlesCollision *pc = particles_collision_owner.get_or_null(pci->collision);
ERR_CONTINUE(!pc);
Transform3D to_collider = pci->transform;
@@ -4746,7 +4745,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
for (uint32_t i = 0; i < ParticlesFrameParams::MAX_3D_TEXTURES; i++) {
RID rd_tex;
if (i < collision_3d_textures_used) {
- Texture *t = texture_owner.getornull(collision_3d_textures[i]);
+ Texture *t = texture_owner.get_or_null(collision_3d_textures[i]);
if (t && t->type == Texture::TYPE_3D) {
rd_tex = t->rd_texture;
}
@@ -4791,7 +4790,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
p_particles->force_sub_emit = false; //reset
- Particles *sub_emitter = particles_owner.getornull(p_particles->sub_emitter);
+ Particles *sub_emitter = particles_owner.get_or_null(p_particles->sub_emitter);
if (sub_emitter && sub_emitter->emission_storage_buffer.is_valid()) {
// print_line("updating subemitter buffer");
@@ -4871,7 +4870,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, double p_delt
}
void RendererStorageRD::particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND(!particles);
if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) {
@@ -5229,7 +5228,7 @@ void RendererStorageRD::update_particles() {
bool RendererStorageRD::particles_is_inactive(RID p_particles) const {
ERR_FAIL_COND_V_MSG(RSG::threaded, false, "This function should never be used with threaded rendering, as it stalls the renderer.");
- const Particles *particles = particles_owner.getornull(p_particles);
+ const Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, false);
return !particles->emitting && particles->inactive;
}
@@ -5407,7 +5406,7 @@ void RendererStorageRD::particles_collision_initialize(RID p_rid) {
}
RID RendererStorageRD::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, RID());
ERR_FAIL_COND_V(particles_collision->type != RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE, RID());
@@ -5442,7 +5441,7 @@ RID RendererStorageRD::particles_collision_get_heightfield_framebuffer(RID p_par
}
void RendererStorageRD::particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
if (p_type == particles_collision->type) {
@@ -5458,13 +5457,13 @@ void RendererStorageRD::particles_collision_set_collision_type(RID p_particles_c
}
void RendererStorageRD::particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->cull_mask = p_cull_mask;
}
void RendererStorageRD::particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->radius = p_radius;
@@ -5472,7 +5471,7 @@ void RendererStorageRD::particles_collision_set_sphere_radius(RID p_particles_co
}
void RendererStorageRD::particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->extents = p_extents;
@@ -5480,41 +5479,41 @@ void RendererStorageRD::particles_collision_set_box_extents(RID p_particles_coll
}
void RendererStorageRD::particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->attractor_strength = p_strength;
}
void RendererStorageRD::particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->attractor_directionality = p_directionality;
}
void RendererStorageRD::particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->attractor_attenuation = p_curve;
}
void RendererStorageRD::particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->field_texture = p_texture;
}
void RendererStorageRD::particles_collision_height_field_update(RID p_particles_collision) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
particles_collision->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND(!particles_collision);
ERR_FAIL_INDEX(p_resolution, RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX);
@@ -5531,7 +5530,7 @@ void RendererStorageRD::particles_collision_set_height_field_resolution(RID p_pa
}
AABB RendererStorageRD::particles_collision_get_aabb(RID p_particles_collision) const {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, AABB());
switch (particles_collision->type) {
@@ -5554,13 +5553,13 @@ AABB RendererStorageRD::particles_collision_get_aabb(RID p_particles_collision)
}
Vector3 RendererStorageRD::particles_collision_get_extents(RID p_particles_collision) const {
- const ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, Vector3());
return particles_collision->extents;
}
bool RendererStorageRD::particles_collision_is_heightfield(RID p_particles_collision) const {
- const ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_particles_collision);
+ const ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_particles_collision);
ERR_FAIL_COND_V(!particles_collision, false);
return particles_collision->type == RS::PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE;
}
@@ -5571,12 +5570,12 @@ RID RendererStorageRD::particles_collision_instance_create(RID p_collision) {
return particles_collision_instance_owner.make_rid(pci);
}
void RendererStorageRD::particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.getornull(p_collision_instance);
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(p_collision_instance);
ERR_FAIL_COND(!pci);
pci->transform = p_transform;
}
void RendererStorageRD::particles_collision_instance_set_active(RID p_collision_instance, bool p_active) {
- ParticlesCollisionInstance *pci = particles_collision_instance_owner.getornull(p_collision_instance);
+ ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(p_collision_instance);
ERR_FAIL_COND(!pci);
pci->active = p_active;
}
@@ -5590,25 +5589,25 @@ void RendererStorageRD::visibility_notifier_initialize(RID p_notifier) {
visibility_notifier_owner.initialize_rid(p_notifier, VisibilityNotifier());
}
void RendererStorageRD::visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND(!vn);
vn->aabb = p_aabb;
vn->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND(!vn);
vn->enter_callback = p_enter_callbable;
vn->exit_callback = p_exit_callable;
}
AABB RendererStorageRD::visibility_notifier_get_aabb(RID p_notifier) const {
- const VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ const VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND_V(!vn, AABB());
return vn->aabb;
}
void RendererStorageRD::visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_notifier);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_notifier);
ERR_FAIL_COND(!vn);
if (p_enter) {
@@ -5652,7 +5651,7 @@ void RendererStorageRD::_skeleton_make_dirty(Skeleton *skeleton) {
}
void RendererStorageRD::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_COND(p_bones < 0);
@@ -5695,14 +5694,14 @@ void RendererStorageRD::skeleton_allocate_data(RID p_skeleton, int p_bones, bool
}
int RendererStorageRD::skeleton_get_bone_count(RID p_skeleton) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, 0);
return skeleton->size;
}
void RendererStorageRD::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_INDEX(p_bone, skeleton->size);
@@ -5727,7 +5726,7 @@ void RendererStorageRD::skeleton_bone_set_transform(RID p_skeleton, int p_bone,
}
Transform3D RendererStorageRD::skeleton_bone_get_transform(RID p_skeleton, int p_bone) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, Transform3D());
ERR_FAIL_INDEX_V(p_bone, skeleton->size, Transform3D());
@@ -5754,7 +5753,7 @@ Transform3D RendererStorageRD::skeleton_bone_get_transform(RID p_skeleton, int p
}
void RendererStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_INDEX(p_bone, skeleton->size);
@@ -5775,7 +5774,7 @@ void RendererStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bon
}
Transform2D RendererStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, Transform2D());
ERR_FAIL_INDEX_V(p_bone, skeleton->size, Transform2D());
@@ -5795,7 +5794,7 @@ Transform2D RendererStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton, in
}
void RendererStorageRD::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton->use_2d);
@@ -5874,14 +5873,14 @@ void RendererStorageRD::spot_light_initialize(RID p_light) {
}
void RendererStorageRD::light_set_color(RID p_light, const Color &p_color) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->color = p_color;
}
void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
@@ -5916,7 +5915,7 @@ void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, flo
}
void RendererStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->shadow = p_enabled;
@@ -5925,13 +5924,13 @@ void RendererStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
}
void RendererStorageRD::light_set_shadow_color(RID p_light, const Color &p_color) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->shadow_color = p_color;
}
void RendererStorageRD::light_set_projector(RID p_light, RID p_texture) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
if (light->projector == p_texture) {
@@ -5953,14 +5952,14 @@ void RendererStorageRD::light_set_projector(RID p_light, RID p_texture) {
}
void RendererStorageRD::light_set_negative(RID p_light, bool p_enable) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->negative = p_enable;
}
void RendererStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->cull_mask = p_mask;
@@ -5970,7 +5969,7 @@ void RendererStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
}
void RendererStorageRD::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->reverse_cull = p_enabled;
@@ -5980,7 +5979,7 @@ void RendererStorageRD::light_set_reverse_cull_face_mode(RID p_light, bool p_ena
}
void RendererStorageRD::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->bake_mode = p_bake_mode;
@@ -5990,7 +5989,7 @@ void RendererStorageRD::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bak
}
void RendererStorageRD::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->max_sdfgi_cascade = p_cascade;
@@ -6000,7 +5999,7 @@ void RendererStorageRD::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_casc
}
void RendererStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->omni_shadow_mode = p_mode;
@@ -6010,14 +6009,14 @@ void RendererStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniSha
}
RS::LightOmniShadowMode RendererStorageRD::light_omni_get_shadow_mode(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
return light->omni_shadow_mode;
}
void RendererStorageRD::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->directional_shadow_mode = p_mode;
@@ -6026,7 +6025,7 @@ void RendererStorageRD::light_directional_set_shadow_mode(RID p_light, RS::Light
}
void RendererStorageRD::light_directional_set_blend_splits(RID p_light, bool p_enable) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->directional_blend_splits = p_enable;
@@ -6035,56 +6034,56 @@ void RendererStorageRD::light_directional_set_blend_splits(RID p_light, bool p_e
}
bool RendererStorageRD::light_directional_get_blend_splits(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, false);
return light->directional_blend_splits;
}
void RendererStorageRD::light_directional_set_sky_only(RID p_light, bool p_sky_only) {
- Light *light = light_owner.getornull(p_light);
+ Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND(!light);
light->directional_sky_only = p_sky_only;
}
bool RendererStorageRD::light_directional_is_sky_only(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, false);
return light->directional_sky_only;
}
RS::LightDirectionalShadowMode RendererStorageRD::light_directional_get_shadow_mode(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
return light->directional_shadow_mode;
}
uint32_t RendererStorageRD::light_get_max_sdfgi_cascade(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->max_sdfgi_cascade;
}
RS::LightBakeMode RendererStorageRD::light_get_bake_mode(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_BAKE_DISABLED);
return light->bake_mode;
}
uint64_t RendererStorageRD::light_get_version(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->version;
}
AABB RendererStorageRD::light_get_aabb(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, AABB());
switch (light->type) {
@@ -6115,7 +6114,7 @@ void RendererStorageRD::reflection_probe_initialize(RID p_reflection_probe) {
}
void RendererStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->update_mode = p_mode;
@@ -6123,35 +6122,35 @@ void RendererStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::Reflec
}
void RendererStorageRD::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->intensity = p_intensity;
}
void RendererStorageRD::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->ambient_mode = p_mode;
}
void RendererStorageRD::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->ambient_color = p_color;
}
void RendererStorageRD::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->ambient_color_energy = p_energy;
}
void RendererStorageRD::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->max_distance = p_distance;
@@ -6160,7 +6159,7 @@ void RendererStorageRD::reflection_probe_set_max_distance(RID p_probe, float p_d
}
void RendererStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
if (reflection_probe->extents == p_extents) {
@@ -6171,7 +6170,7 @@ void RendererStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3
}
void RendererStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->origin_offset = p_offset;
@@ -6179,7 +6178,7 @@ void RendererStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Ve
}
void RendererStorageRD::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->interior = p_enable;
@@ -6187,14 +6186,14 @@ void RendererStorageRD::reflection_probe_set_as_interior(RID p_probe, bool p_ena
}
void RendererStorageRD::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->box_projection = p_enable;
}
void RendererStorageRD::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->enable_shadows = p_enable;
@@ -6202,7 +6201,7 @@ void RendererStorageRD::reflection_probe_set_enable_shadows(RID p_probe, bool p_
}
void RendererStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->cull_mask = p_layers;
@@ -6210,7 +6209,7 @@ void RendererStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_l
}
void RendererStorageRD::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
ERR_FAIL_COND(p_resolution < 32);
@@ -6218,7 +6217,7 @@ void RendererStorageRD::reflection_probe_set_resolution(RID p_probe, int p_resol
}
void RendererStorageRD::reflection_probe_set_lod_threshold(RID p_probe, float p_ratio) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->lod_threshold = p_ratio;
@@ -6227,7 +6226,7 @@ void RendererStorageRD::reflection_probe_set_lod_threshold(RID p_probe, float p_
}
AABB RendererStorageRD::reflection_probe_get_aabb(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, AABB());
AABB aabb;
@@ -6238,96 +6237,96 @@ AABB RendererStorageRD::reflection_probe_get_aabb(RID p_probe) const {
}
RS::ReflectionProbeUpdateMode RendererStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
return reflection_probe->update_mode;
}
uint32_t RendererStorageRD::reflection_probe_get_cull_mask(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->cull_mask;
}
Vector3 RendererStorageRD::reflection_probe_get_extents(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->extents;
}
Vector3 RendererStorageRD::reflection_probe_get_origin_offset(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->origin_offset;
}
bool RendererStorageRD::reflection_probe_renders_shadows(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->enable_shadows;
}
float RendererStorageRD::reflection_probe_get_origin_max_distance(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->max_distance;
}
float RendererStorageRD::reflection_probe_get_lod_threshold(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->lod_threshold;
}
int RendererStorageRD::reflection_probe_get_resolution(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->resolution;
}
float RendererStorageRD::reflection_probe_get_intensity(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->intensity;
}
bool RendererStorageRD::reflection_probe_is_interior(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->interior;
}
bool RendererStorageRD::reflection_probe_is_box_projection(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->box_projection;
}
RS::ReflectionProbeAmbientMode RendererStorageRD::reflection_probe_get_ambient_mode(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_AMBIENT_DISABLED);
return reflection_probe->ambient_mode;
}
Color RendererStorageRD::reflection_probe_get_ambient_color(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Color());
return reflection_probe->ambient_color;
}
float RendererStorageRD::reflection_probe_get_ambient_color_energy(RID p_probe) const {
- const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
+ const ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->ambient_color_energy;
@@ -6341,14 +6340,14 @@ void RendererStorageRD::decal_initialize(RID p_decal) {
}
void RendererStorageRD::decal_set_extents(RID p_decal, const Vector3 &p_extents) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->extents = p_extents;
decal->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
ERR_FAIL_INDEX(p_type, RS::DECAL_TEXTURE_MAX);
@@ -6372,32 +6371,32 @@ void RendererStorageRD::decal_set_texture(RID p_decal, RS::DecalTexture p_type,
}
void RendererStorageRD::decal_set_emission_energy(RID p_decal, float p_energy) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->emission_energy = p_energy;
}
void RendererStorageRD::decal_set_albedo_mix(RID p_decal, float p_mix) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->albedo_mix = p_mix;
}
void RendererStorageRD::decal_set_modulate(RID p_decal, const Color &p_modulate) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->modulate = p_modulate;
}
void RendererStorageRD::decal_set_cull_mask(RID p_decal, uint32_t p_layers) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->cull_mask = p_layers;
decal->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
void RendererStorageRD::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->distance_fade = p_enabled;
decal->distance_fade_begin = p_begin;
@@ -6405,20 +6404,20 @@ void RendererStorageRD::decal_set_distance_fade(RID p_decal, bool p_enabled, flo
}
void RendererStorageRD::decal_set_fade(RID p_decal, float p_above, float p_below) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->upper_fade = p_above;
decal->lower_fade = p_below;
}
void RendererStorageRD::decal_set_normal_fade(RID p_decal, float p_fade) {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND(!decal);
decal->normal_fade = p_fade;
}
AABB RendererStorageRD::decal_get_aabb(RID p_decal) const {
- Decal *decal = decal_owner.getornull(p_decal);
+ Decal *decal = decal_owner.get_or_null(p_decal);
ERR_FAIL_COND_V(!decal, AABB());
return AABB(-decal->extents, decal->extents * 2.0);
@@ -6432,7 +6431,7 @@ void RendererStorageRD::voxel_gi_initialize(RID p_voxel_gi) {
}
void RendererStorageRD::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &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) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
if (voxel_gi->octree_buffer.is_valid()) {
@@ -6557,20 +6556,20 @@ void RendererStorageRD::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D
}
AABB RendererStorageRD::voxel_gi_get_bounds(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, AABB());
return voxel_gi->bounds;
}
Vector3i RendererStorageRD::voxel_gi_get_octree_size(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector3i());
return voxel_gi->octree_size;
}
Vector<uint8_t> RendererStorageRD::voxel_gi_get_octree_cells(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (voxel_gi->octree_buffer.is_valid()) {
@@ -6580,7 +6579,7 @@ Vector<uint8_t> RendererStorageRD::voxel_gi_get_octree_cells(RID p_voxel_gi) con
}
Vector<uint8_t> RendererStorageRD::voxel_gi_get_data_cells(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (voxel_gi->data_buffer.is_valid()) {
@@ -6590,7 +6589,7 @@ Vector<uint8_t> RendererStorageRD::voxel_gi_get_data_cells(RID p_voxel_gi) const
}
Vector<uint8_t> RendererStorageRD::voxel_gi_get_distance_field(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<uint8_t>());
if (voxel_gi->data_buffer.is_valid()) {
@@ -6600,21 +6599,21 @@ Vector<uint8_t> RendererStorageRD::voxel_gi_get_distance_field(RID p_voxel_gi) c
}
Vector<int> RendererStorageRD::voxel_gi_get_level_counts(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Vector<int>());
return voxel_gi->level_counts;
}
Transform3D RendererStorageRD::voxel_gi_get_to_cell_xform(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, Transform3D());
return voxel_gi->to_cell_xform;
}
void RendererStorageRD::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->dynamic_range = p_range;
@@ -6622,14 +6621,14 @@ void RendererStorageRD::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range
}
float RendererStorageRD::voxel_gi_get_dynamic_range(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->dynamic_range;
}
void RendererStorageRD::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->propagation = p_range;
@@ -6637,72 +6636,72 @@ void RendererStorageRD::voxel_gi_set_propagation(RID p_voxel_gi, float p_range)
}
float RendererStorageRD::voxel_gi_get_propagation(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->propagation;
}
void RendererStorageRD::voxel_gi_set_energy(RID p_voxel_gi, float p_energy) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->energy = p_energy;
}
float RendererStorageRD::voxel_gi_get_energy(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->energy;
}
void RendererStorageRD::voxel_gi_set_bias(RID p_voxel_gi, float p_bias) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->bias = p_bias;
}
float RendererStorageRD::voxel_gi_get_bias(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->bias;
}
void RendererStorageRD::voxel_gi_set_normal_bias(RID p_voxel_gi, float p_normal_bias) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->normal_bias = p_normal_bias;
}
float RendererStorageRD::voxel_gi_get_normal_bias(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->normal_bias;
}
void RendererStorageRD::voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->anisotropy_strength = p_strength;
}
float RendererStorageRD::voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->anisotropy_strength;
}
void RendererStorageRD::voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->interior = p_enable;
}
void RendererStorageRD::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND(!voxel_gi);
voxel_gi->use_two_bounces = p_enable;
@@ -6710,43 +6709,43 @@ void RendererStorageRD::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enab
}
bool RendererStorageRD::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, false);
return voxel_gi->use_two_bounces;
}
bool RendererStorageRD::voxel_gi_is_interior(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->interior;
}
uint32_t RendererStorageRD::voxel_gi_get_version(RID p_voxel_gi) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->version;
}
uint32_t RendererStorageRD::voxel_gi_get_data_version(RID p_voxel_gi) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, 0);
return voxel_gi->data_version;
}
RID RendererStorageRD::voxel_gi_get_octree_buffer(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, RID());
return voxel_gi->octree_buffer;
}
RID RendererStorageRD::voxel_gi_get_data_buffer(RID p_voxel_gi) const {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, RID());
return voxel_gi->data_buffer;
}
RID RendererStorageRD::voxel_gi_get_sdf_texture(RID p_voxel_gi) {
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_voxel_gi);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi);
ERR_FAIL_COND_V(!voxel_gi, RID());
return voxel_gi->sdf_texture;
@@ -6763,20 +6762,20 @@ void RendererStorageRD::lightmap_initialize(RID p_lightmap) {
}
void RendererStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
lightmap_array_version++;
//erase lightmap users
if (lm->light_texture.is_valid()) {
- Texture *t = texture_owner.getornull(lm->light_texture);
+ Texture *t = texture_owner.get_or_null(lm->light_texture);
if (t) {
t->lightmap_users.erase(p_lightmap);
}
}
- Texture *t = texture_owner.getornull(p_light);
+ Texture *t = texture_owner.get_or_null(p_light);
lm->light_texture = p_light;
lm->uses_spherical_harmonics = p_uses_spherical_haromics;
@@ -6811,19 +6810,19 @@ void RendererStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool
}
void RendererStorageRD::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
lm->bounds = p_bounds;
}
void RendererStorageRD::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
lm->interior = p_interior;
}
void RendererStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
if (p_points.size()) {
@@ -6839,26 +6838,26 @@ void RendererStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const Pa
}
PackedVector3Array RendererStorageRD::lightmap_get_probe_capture_points(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedVector3Array());
return lm->points;
}
PackedColorArray RendererStorageRD::lightmap_get_probe_capture_sh(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedColorArray());
return lm->point_sh;
}
PackedInt32Array RendererStorageRD::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedInt32Array());
return lm->tetrahedra;
}
PackedInt32Array RendererStorageRD::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedInt32Array());
return lm->bsp_tree;
}
@@ -6868,7 +6867,7 @@ void RendererStorageRD::lightmap_set_probe_capture_update_speed(float p_speed) {
}
void RendererStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) {
- Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND(!lm);
for (int i = 0; i < 9; i++) {
@@ -6918,13 +6917,13 @@ void RendererStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_p
}
bool RendererStorageRD::lightmap_is_interior(RID p_lightmap) const {
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, false);
return lm->interior;
}
AABB RendererStorageRD::lightmap_get_aabb(RID p_lightmap) const {
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, AABB());
return lm->bounds;
}
@@ -6964,7 +6963,7 @@ void RendererStorageRD::_update_render_target(RenderTarget *rt) {
//create a placeholder until updated
rt->texture = texture_allocate();
texture_2d_placeholder_initialize(rt->texture);
- Texture *tex = texture_owner.getornull(rt->texture);
+ Texture *tex = texture_owner.get_or_null(rt->texture);
tex->is_render_target = true;
}
@@ -7011,7 +7010,7 @@ void RendererStorageRD::_update_render_target(RenderTarget *rt) {
{ //update texture
- Texture *tex = texture_owner.getornull(rt->texture);
+ Texture *tex = texture_owner.get_or_null(rt->texture);
//free existing textures
if (RD::get_singleton()->texture_is_valid(tex->rd_texture)) {
@@ -7118,7 +7117,7 @@ void RendererStorageRD::render_target_set_position(RID p_render_target, int p_x,
}
void RendererStorageRD::render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (rt->size.x != p_width || rt->size.y != p_height || rt->view_count != p_view_count) {
rt->size.x = p_width;
@@ -7129,7 +7128,7 @@ void RendererStorageRD::render_target_set_size(RID p_render_target, int p_width,
}
RID RendererStorageRD::render_target_get_texture(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->texture;
@@ -7139,53 +7138,53 @@ void RendererStorageRD::render_target_set_external_texture(RID p_render_target,
}
void RendererStorageRD::render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->flags[p_flag] = p_value;
_update_render_target(rt);
}
bool RendererStorageRD::render_target_was_used(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->was_used;
}
void RendererStorageRD::render_target_set_as_unused(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->was_used = false;
}
Size2 RendererStorageRD::render_target_get_size(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, Size2());
return rt->size;
}
RID RendererStorageRD::render_target_get_rd_framebuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->framebuffer;
}
RID RendererStorageRD::render_target_get_rd_texture(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->color;
}
RID RendererStorageRD::render_target_get_rd_backbuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->backbuffer;
}
RID RendererStorageRD::render_target_get_rd_backbuffer_framebuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
if (!rt->backbuffer.is_valid()) {
@@ -7196,32 +7195,32 @@ RID RendererStorageRD::render_target_get_rd_backbuffer_framebuffer(RID p_render_
}
void RendererStorageRD::render_target_request_clear(RID p_render_target, const Color &p_clear_color) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->clear_requested = true;
rt->clear_color = p_clear_color;
}
bool RendererStorageRD::render_target_is_clear_requested(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->clear_requested;
}
Color RendererStorageRD::render_target_get_clear_request_color(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, Color());
return rt->clear_color;
}
void RendererStorageRD::render_target_disable_clear_request(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->clear_requested = false;
}
void RendererStorageRD::render_target_do_clear_request(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->clear_requested) {
return;
@@ -7234,7 +7233,7 @@ void RendererStorageRD::render_target_do_clear_request(RID p_render_target) {
}
void RendererStorageRD::render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (rt->sdf_oversize == p_size && rt->sdf_scale == p_scale) {
return;
@@ -7276,28 +7275,28 @@ Rect2i RendererStorageRD::_render_target_get_sdf_rect(const RenderTarget *rt) co
}
Rect2i RendererStorageRD::render_target_get_sdf_rect(RID p_render_target) const {
- const RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ const RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, Rect2i());
return _render_target_get_sdf_rect(rt);
}
void RendererStorageRD::render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->sdf_enabled = p_enabled;
}
bool RendererStorageRD::render_target_is_sdf_enabled(RID p_render_target) const {
- const RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ const RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->sdf_enabled;
}
RID RendererStorageRD::render_target_get_sdf_texture(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
if (rt->sdf_buffer_read.is_null()) {
// no texture, create a dummy one for the 2D uniform set
@@ -7432,7 +7431,7 @@ void RendererStorageRD::_render_target_clear_sdf(RenderTarget *rt) {
}
RID RendererStorageRD::render_target_get_sdf_framebuffer(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
if (rt->sdf_buffer_write_fb.is_null()) {
@@ -7442,7 +7441,7 @@ RID RendererStorageRD::render_target_get_sdf_framebuffer(RID p_render_target) {
return rt->sdf_buffer_write_fb;
}
void RendererStorageRD::render_target_sdf_process(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
ERR_FAIL_COND(rt->sdf_buffer_write_fb.is_null());
@@ -7517,7 +7516,7 @@ void RendererStorageRD::render_target_sdf_process(RID p_render_target) {
}
void RendererStorageRD::render_target_copy_to_back_buffer(RID p_render_target, const Rect2i &p_region, bool p_gen_mipmaps) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->backbuffer.is_valid()) {
_create_render_target_backbuffer(rt);
@@ -7557,7 +7556,7 @@ void RendererStorageRD::render_target_copy_to_back_buffer(RID p_render_target, c
}
void RendererStorageRD::render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->backbuffer.is_valid()) {
_create_render_target_backbuffer(rt);
@@ -7578,7 +7577,7 @@ void RendererStorageRD::render_target_clear_back_buffer(RID p_render_target, con
}
void RendererStorageRD::render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->backbuffer.is_valid()) {
_create_render_target_backbuffer(rt);
@@ -7610,66 +7609,66 @@ void RendererStorageRD::render_target_gen_back_buffer_mipmaps(RID p_render_targe
}
RID RendererStorageRD::render_target_get_framebuffer_uniform_set(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->framebuffer_uniform_set;
}
RID RendererStorageRD::render_target_get_backbuffer_uniform_set(RID p_render_target) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->backbuffer_uniform_set;
}
void RendererStorageRD::render_target_set_framebuffer_uniform_set(RID p_render_target, RID p_uniform_set) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->framebuffer_uniform_set = p_uniform_set;
}
void RendererStorageRD::render_target_set_backbuffer_uniform_set(RID p_render_target, RID p_uniform_set) {
- RenderTarget *rt = render_target_owner.getornull(p_render_target);
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND(!rt);
rt->backbuffer_uniform_set = p_uniform_set;
}
void RendererStorageRD::base_update_dependency(RID p_base, DependencyTracker *p_instance) {
if (mesh_owner.owns(p_base)) {
- Mesh *mesh = mesh_owner.getornull(p_base);
+ Mesh *mesh = mesh_owner.get_or_null(p_base);
p_instance->update_dependency(&mesh->dependency);
} else if (multimesh_owner.owns(p_base)) {
- MultiMesh *multimesh = multimesh_owner.getornull(p_base);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_base);
p_instance->update_dependency(&multimesh->dependency);
if (multimesh->mesh.is_valid()) {
base_update_dependency(multimesh->mesh, p_instance);
}
} else if (reflection_probe_owner.owns(p_base)) {
- ReflectionProbe *rp = reflection_probe_owner.getornull(p_base);
+ ReflectionProbe *rp = reflection_probe_owner.get_or_null(p_base);
p_instance->update_dependency(&rp->dependency);
} else if (decal_owner.owns(p_base)) {
- Decal *decal = decal_owner.getornull(p_base);
+ Decal *decal = decal_owner.get_or_null(p_base);
p_instance->update_dependency(&decal->dependency);
} else if (voxel_gi_owner.owns(p_base)) {
- VoxelGI *gip = voxel_gi_owner.getornull(p_base);
+ VoxelGI *gip = voxel_gi_owner.get_or_null(p_base);
p_instance->update_dependency(&gip->dependency);
} else if (lightmap_owner.owns(p_base)) {
- Lightmap *lm = lightmap_owner.getornull(p_base);
+ Lightmap *lm = lightmap_owner.get_or_null(p_base);
p_instance->update_dependency(&lm->dependency);
} else if (light_owner.owns(p_base)) {
- Light *l = light_owner.getornull(p_base);
+ Light *l = light_owner.get_or_null(p_base);
p_instance->update_dependency(&l->dependency);
} else if (particles_owner.owns(p_base)) {
- Particles *p = particles_owner.getornull(p_base);
+ Particles *p = particles_owner.get_or_null(p_base);
p_instance->update_dependency(&p->dependency);
} else if (particles_collision_owner.owns(p_base)) {
- ParticlesCollision *pc = particles_collision_owner.getornull(p_base);
+ ParticlesCollision *pc = particles_collision_owner.get_or_null(p_base);
p_instance->update_dependency(&pc->dependency);
} else if (visibility_notifier_owner.owns(p_base)) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_base);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_base);
p_instance->update_dependency(&vn->dependency);
}
}
void RendererStorageRD::skeleton_update_dependency(RID p_skeleton, DependencyTracker *p_instance) {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND(!skeleton);
p_instance->update_dependency(&skeleton->dependency);
@@ -7775,7 +7774,7 @@ void RendererStorageRD::_update_decal_atlas() {
while ((K = decal_atlas.textures.next(K))) {
DecalAtlas::SortItem &si = itemsv.write[idx];
- Texture *src_tex = texture_owner.getornull(*K);
+ Texture *src_tex = texture_owner.get_or_null(*K);
si.size.width = (src_tex->width / border) + 1;
si.size.height = (src_tex->height / border) + 1;
@@ -7924,7 +7923,7 @@ void RendererStorageRD::_update_decal_atlas() {
const RID *K = nullptr;
while ((K = decal_atlas.textures.next(K))) {
DecalAtlas::Texture *t = decal_atlas.textures.getptr(*K);
- Texture *src_tex = texture_owner.getornull(*K);
+ Texture *src_tex = texture_owner.get_or_null(*K);
effects->copy_to_atlas_fb(src_tex->rd_texture, mm.fb, t->uv_rect, draw_list, false, t->panorama_to_dp_users > 0);
}
@@ -8340,7 +8339,7 @@ void RendererStorageRD::global_variable_set(const StringName &p_name, const Vari
} else {
//texture
for (Set<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_owner.getornull(E->get());
+ Material *material = material_owner.get_or_null(E->get());
ERR_CONTINUE(!material);
_material_queue_update(material, false, true);
}
@@ -8371,7 +8370,7 @@ void RendererStorageRD::global_variable_set_override(const StringName &p_name, c
} else {
//texture
for (Set<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) {
- Material *material = material_owner.getornull(E->get());
+ Material *material = material_owner.get_or_null(E->get());
ERR_CONTINUE(!material);
_material_queue_update(material, false, true);
}
@@ -8582,7 +8581,7 @@ void RendererStorageRD::_update_global_variables() {
// only happens in the case of a buffer variable added or removed,
// so not often.
for (const RID &E : global_variables.materials_using_buffer) {
- Material *material = material_owner.getornull(E);
+ Material *material = material_owner.get_or_null(E);
ERR_CONTINUE(!material); //wtf
_material_queue_update(material, true, false);
@@ -8595,7 +8594,7 @@ void RendererStorageRD::_update_global_variables() {
// only happens in the case of a buffer variable added or removed,
// so not often.
for (const RID &E : global_variables.materials_using_texture) {
- Material *material = material_owner.getornull(E);
+ Material *material = material_owner.get_or_null(E);
ERR_CONTINUE(!material); //wtf
_material_queue_update(material, false, true);
@@ -8640,7 +8639,7 @@ bool RendererStorageRD::has_os_feature(const String &p_feature) const {
bool RendererStorageRD::free(RID p_rid) {
if (texture_owner.owns(p_rid)) {
- Texture *t = texture_owner.getornull(p_rid);
+ Texture *t = texture_owner.get_or_null(p_rid);
ERR_FAIL_COND_V(!t, false);
ERR_FAIL_COND_V(t->is_render_target, false);
@@ -8654,7 +8653,7 @@ bool RendererStorageRD::free(RID p_rid) {
}
if (t->is_proxy && t->proxy_to.is_valid()) {
- Texture *proxy_to = texture_owner.getornull(t->proxy_to);
+ Texture *proxy_to = texture_owner.get_or_null(t->proxy_to);
if (proxy_to) {
proxy_to->proxies.erase(p_rid);
}
@@ -8666,7 +8665,7 @@ bool RendererStorageRD::free(RID p_rid) {
}
for (int i = 0; i < t->proxies.size(); i++) {
- Texture *p = texture_owner.getornull(t->proxies[i]);
+ Texture *p = texture_owner.get_or_null(t->proxies[i]);
ERR_CONTINUE(!p);
p->proxy_to = RID();
p->rd_texture = RID();
@@ -8681,7 +8680,7 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (canvas_texture_owner.owns(p_rid)) {
canvas_texture_owner.free(p_rid);
} else if (shader_owner.owns(p_rid)) {
- Shader *shader = shader_owner.getornull(p_rid);
+ Shader *shader = shader_owner.get_or_null(p_rid);
//make material unreference this
while (shader->owners.size()) {
material_set_shader(shader->owners.front()->get()->self, RID());
@@ -8693,7 +8692,7 @@ bool RendererStorageRD::free(RID p_rid) {
shader_owner.free(p_rid);
} else if (material_owner.owns(p_rid)) {
- Material *material = material_owner.getornull(p_rid);
+ Material *material = material_owner.get_or_null(p_rid);
material_set_shader(p_rid, RID()); //clean up shader
material->dependency.deleted_notify(p_rid);
@@ -8701,7 +8700,7 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (mesh_owner.owns(p_rid)) {
mesh_clear(p_rid);
mesh_set_shadow_mesh(p_rid, RID());
- Mesh *mesh = mesh_owner.getornull(p_rid);
+ Mesh *mesh = mesh_owner.get_or_null(p_rid);
mesh->dependency.deleted_notify(p_rid);
if (mesh->instances.size()) {
ERR_PRINT("deleting mesh with active instances");
@@ -8715,7 +8714,7 @@ bool RendererStorageRD::free(RID p_rid) {
}
mesh_owner.free(p_rid);
} else if (mesh_instance_owner.owns(p_rid)) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_rid);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_rid);
_mesh_instance_clear(mi);
mi->mesh->instances.erase(mi->I);
mi->I = nullptr;
@@ -8725,21 +8724,21 @@ bool RendererStorageRD::free(RID p_rid) {
} else if (multimesh_owner.owns(p_rid)) {
_update_dirty_multimeshes();
multimesh_allocate_data(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D);
- MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_rid);
multimesh->dependency.deleted_notify(p_rid);
multimesh_owner.free(p_rid);
} else if (skeleton_owner.owns(p_rid)) {
_update_dirty_skeletons();
skeleton_allocate_data(p_rid, 0);
- Skeleton *skeleton = skeleton_owner.getornull(p_rid);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_rid);
skeleton->dependency.deleted_notify(p_rid);
skeleton_owner.free(p_rid);
} else if (reflection_probe_owner.owns(p_rid)) {
- ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
+ ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_rid);
reflection_probe->dependency.deleted_notify(p_rid);
reflection_probe_owner.free(p_rid);
} else if (decal_owner.owns(p_rid)) {
- Decal *decal = decal_owner.getornull(p_rid);
+ Decal *decal = decal_owner.get_or_null(p_rid);
for (int i = 0; i < RS::DECAL_TEXTURE_MAX; i++) {
if (decal->textures[i].is_valid() && texture_owner.owns(decal->textures[i])) {
texture_remove_from_decal_atlas(decal->textures[i]);
@@ -8749,30 +8748,30 @@ bool RendererStorageRD::free(RID p_rid) {
decal_owner.free(p_rid);
} else if (voxel_gi_owner.owns(p_rid)) {
voxel_gi_allocate_data(p_rid, Transform3D(), AABB(), Vector3i(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<uint8_t>(), Vector<int>()); //deallocate
- VoxelGI *voxel_gi = voxel_gi_owner.getornull(p_rid);
+ VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_rid);
voxel_gi->dependency.deleted_notify(p_rid);
voxel_gi_owner.free(p_rid);
} else if (lightmap_owner.owns(p_rid)) {
lightmap_set_textures(p_rid, RID(), false);
- Lightmap *lightmap = lightmap_owner.getornull(p_rid);
+ Lightmap *lightmap = lightmap_owner.get_or_null(p_rid);
lightmap->dependency.deleted_notify(p_rid);
lightmap_owner.free(p_rid);
} else if (light_owner.owns(p_rid)) {
light_set_projector(p_rid, RID()); //clear projector
// delete the texture
- Light *light = light_owner.getornull(p_rid);
+ Light *light = light_owner.get_or_null(p_rid);
light->dependency.deleted_notify(p_rid);
light_owner.free(p_rid);
} else if (particles_owner.owns(p_rid)) {
update_particles();
- Particles *particles = particles_owner.getornull(p_rid);
+ Particles *particles = particles_owner.get_or_null(p_rid);
particles->dependency.deleted_notify(p_rid);
_particles_free_data(particles);
particles_owner.free(p_rid);
} else if (particles_collision_owner.owns(p_rid)) {
- ParticlesCollision *particles_collision = particles_collision_owner.getornull(p_rid);
+ ParticlesCollision *particles_collision = particles_collision_owner.get_or_null(p_rid);
if (particles_collision->heightfield_texture.is_valid()) {
RD::get_singleton()->free(particles_collision->heightfield_texture);
@@ -8780,18 +8779,18 @@ bool RendererStorageRD::free(RID p_rid) {
particles_collision->dependency.deleted_notify(p_rid);
particles_collision_owner.free(p_rid);
} else if (visibility_notifier_owner.owns(p_rid)) {
- VisibilityNotifier *vn = visibility_notifier_owner.getornull(p_rid);
+ VisibilityNotifier *vn = visibility_notifier_owner.get_or_null(p_rid);
vn->dependency.deleted_notify(p_rid);
visibility_notifier_owner.free(p_rid);
} else if (particles_collision_instance_owner.owns(p_rid)) {
particles_collision_instance_owner.free(p_rid);
} else if (render_target_owner.owns(p_rid)) {
- RenderTarget *rt = render_target_owner.getornull(p_rid);
+ RenderTarget *rt = render_target_owner.get_or_null(p_rid);
_clear_render_target(rt);
if (rt->texture.is_valid()) {
- Texture *tex = texture_owner.getornull(rt->texture);
+ Texture *tex = texture_owner.get_or_null(rt->texture);
tex->is_render_target = false;
free(rt->texture);
}
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h
index 02395a884f..d56afcc448 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.h
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.h
@@ -621,7 +621,6 @@ private:
float color[4];
float custom[3];
float lifetime;
- uint32_t pad[3];
};
struct ParticlesFrameParams {
@@ -1351,7 +1350,7 @@ public:
if (p_texture.is_null()) {
return RID();
}
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
if (!tex) {
return RID();
@@ -1363,7 +1362,7 @@ public:
if (p_texture.is_null()) {
return Size2i();
}
- Texture *tex = texture_owner.getornull(p_texture);
+ Texture *tex = texture_owner.get_or_null(p_texture);
if (!tex) {
return Size2i();
@@ -1431,12 +1430,12 @@ public:
void material_set_data_request_function(ShaderType p_shader_type, MaterialDataRequestFunction p_function);
_FORCE_INLINE_ uint32_t material_get_shader_id(RID p_material) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
return material->shader_id;
}
_FORCE_INLINE_ MaterialData *material_get_data(RID p_material, ShaderType p_shader_type) {
- Material *material = material_owner.getornull(p_material);
+ Material *material = material_owner.get_or_null(p_material);
if (!material || material->shader_type != p_shader_type) {
return nullptr;
} else {
@@ -1489,7 +1488,7 @@ public:
virtual void update_mesh_instances();
_FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, nullptr);
r_surface_count = mesh->surface_count;
if (r_surface_count == 0) {
@@ -1506,7 +1505,7 @@ public:
}
_FORCE_INLINE_ void *mesh_get_surface(RID p_mesh, uint32_t p_surface_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, nullptr);
ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, nullptr);
@@ -1514,7 +1513,7 @@ public:
}
_FORCE_INLINE_ RID mesh_get_shadow_mesh(RID p_mesh) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
ERR_FAIL_COND_V(!mesh, RID());
return mesh->shadow_mesh;
@@ -1600,7 +1599,7 @@ public:
}
_FORCE_INLINE_ void mesh_instance_surface_get_vertex_arrays_and_format(RID p_mesh_instance, uint32_t p_surface_index, uint32_t p_input_mask, RID &r_vertex_array_rd, RD::VertexFormatID &r_vertex_format) {
- MeshInstance *mi = mesh_instance_owner.getornull(p_mesh_instance);
+ MeshInstance *mi = mesh_instance_owner.get_or_null(p_mesh_instance);
ERR_FAIL_COND(!mi);
Mesh *mesh = mi->mesh;
ERR_FAIL_UNSIGNED_INDEX(p_surface_index, mesh->surface_count);
@@ -1641,7 +1640,7 @@ public:
}
_FORCE_INLINE_ uint32_t mesh_surface_get_render_pass_index(RID p_mesh, uint32_t p_surface_index, uint64_t p_render_pass, uint32_t *r_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
Mesh::Surface *s = mesh->surfaces[p_surface_index];
if (s->render_pass != p_render_pass) {
@@ -1654,7 +1653,7 @@ public:
}
_FORCE_INLINE_ uint32_t mesh_surface_get_multimesh_render_pass_index(RID p_mesh, uint32_t p_surface_index, uint64_t p_render_pass, uint32_t *r_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
Mesh::Surface *s = mesh->surfaces[p_surface_index];
if (s->multimesh_render_pass != p_render_pass) {
@@ -1667,7 +1666,7 @@ public:
}
_FORCE_INLINE_ uint32_t mesh_surface_get_particles_render_pass_index(RID p_mesh, uint32_t p_surface_index, uint64_t p_render_pass, uint32_t *r_index) {
- Mesh *mesh = mesh_owner.getornull(p_mesh);
+ Mesh *mesh = mesh_owner.get_or_null(p_mesh);
Mesh::Surface *s = mesh->surfaces[p_surface_index];
if (s->particles_render_pass != p_render_pass) {
@@ -1709,22 +1708,22 @@ public:
AABB multimesh_get_aabb(RID p_multimesh) const;
_FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
return multimesh->xform_format;
}
_FORCE_INLINE_ bool multimesh_uses_colors(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
return multimesh->uses_colors;
}
_FORCE_INLINE_ bool multimesh_uses_custom_data(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
return multimesh->uses_custom_data;
}
_FORCE_INLINE_ uint32_t multimesh_get_instances_to_draw(RID p_multimesh) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
if (multimesh->visible_instances >= 0) {
return multimesh->visible_instances;
}
@@ -1732,7 +1731,7 @@ public:
}
_FORCE_INLINE_ RID multimesh_get_3d_uniform_set(RID p_multimesh, RID p_shader, uint32_t p_set) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
if (!multimesh->uniform_set_3d.is_valid()) {
Vector<RD::Uniform> uniforms;
RD::Uniform u;
@@ -1747,7 +1746,7 @@ public:
}
_FORCE_INLINE_ RID multimesh_get_2d_uniform_set(RID p_multimesh, RID p_shader, uint32_t p_set) const {
- MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
if (!multimesh->uniform_set_2d.is_valid()) {
Vector<RD::Uniform> uniforms;
RD::Uniform u;
@@ -1776,11 +1775,11 @@ public:
Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const;
_FORCE_INLINE_ bool skeleton_is_valid(RID p_skeleton) {
- return skeleton_owner.getornull(p_skeleton) != nullptr;
+ return skeleton_owner.get_or_null(p_skeleton) != nullptr;
}
_FORCE_INLINE_ RID skeleton_get_3d_uniform_set(RID p_skeleton, RID p_shader, uint32_t p_set) const {
- Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
+ Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_COND_V(!skeleton, RID());
ERR_FAIL_COND_V(skeleton->size == 0, RID());
if (skeleton->use_2d) {
@@ -1834,7 +1833,7 @@ public:
RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
_FORCE_INLINE_ RS::LightType light_get_type(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->type;
@@ -1842,70 +1841,70 @@ public:
AABB light_get_aabb(RID p_light) const;
_FORCE_INLINE_ float light_get_param(RID p_light, RS::LightParam p_param) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->param[p_param];
}
_FORCE_INLINE_ RID light_get_projector(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RID());
return light->projector;
}
_FORCE_INLINE_ Color light_get_color(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, Color());
return light->color;
}
_FORCE_INLINE_ Color light_get_shadow_color(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, Color());
return light->shadow_color;
}
_FORCE_INLINE_ uint32_t light_get_cull_mask(RID p_light) {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0);
return light->cull_mask;
}
_FORCE_INLINE_ bool light_has_shadow(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->shadow;
}
_FORCE_INLINE_ bool light_has_projector(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return texture_owner.owns(light->projector);
}
_FORCE_INLINE_ bool light_is_negative(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
return light->negative;
}
_FORCE_INLINE_ float light_get_transmittance_bias(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0.0);
return light->param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS];
}
_FORCE_INLINE_ float light_get_shadow_volumetric_fog_fade(RID p_light) const {
- const Light *light = light_owner.getornull(p_light);
+ const Light *light = light_owner.get_or_null(p_light);
ERR_FAIL_COND_V(!light, 0.0);
return light->param[RS::LIGHT_PARAM_SHADOW_VOLUMETRIC_FOG_FADE];
@@ -1972,62 +1971,62 @@ public:
virtual void decal_set_normal_fade(RID p_decal, float p_fade);
_FORCE_INLINE_ Vector3 decal_get_extents(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->extents;
}
_FORCE_INLINE_ RID decal_get_texture(RID p_decal, RS::DecalTexture p_texture) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->textures[p_texture];
}
_FORCE_INLINE_ Color decal_get_modulate(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->modulate;
}
_FORCE_INLINE_ float decal_get_emission_energy(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->emission_energy;
}
_FORCE_INLINE_ float decal_get_albedo_mix(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->albedo_mix;
}
_FORCE_INLINE_ uint32_t decal_get_cull_mask(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->cull_mask;
}
_FORCE_INLINE_ float decal_get_upper_fade(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->upper_fade;
}
_FORCE_INLINE_ float decal_get_lower_fade(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->lower_fade;
}
_FORCE_INLINE_ float decal_get_normal_fade(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->normal_fade;
}
_FORCE_INLINE_ bool decal_is_distance_fade_enabled(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->distance_fade;
}
_FORCE_INLINE_ float decal_get_distance_fade_begin(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->distance_fade_begin;
}
_FORCE_INLINE_ float decal_get_distance_fade_length(RID p_decal) {
- const Decal *decal = decal_owner.getornull(p_decal);
+ const Decal *decal = decal_owner.get_or_null(p_decal);
return decal->distance_fade_length;
}
@@ -2102,18 +2101,18 @@ public:
return lightmap_probe_capture_update_speed;
}
_FORCE_INLINE_ RID lightmap_get_texture(RID p_lightmap) const {
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
ERR_FAIL_COND_V(!lm, RID());
return lm->light_texture;
}
_FORCE_INLINE_ int32_t lightmap_get_array_index(RID p_lightmap) const {
ERR_FAIL_COND_V(!using_lightmap_array, -1); //only for arrays
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
return lm->array_index;
}
_FORCE_INLINE_ bool lightmap_uses_spherical_harmonics(RID p_lightmap) const {
ERR_FAIL_COND_V(!using_lightmap_array, false); //only for arrays
- const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
+ const Lightmap *lm = lightmap_owner.get_or_null(p_lightmap);
return lm->uses_spherical_harmonics;
}
_FORCE_INLINE_ uint64_t lightmap_array_get_version() const {
@@ -2182,13 +2181,13 @@ public:
virtual bool particles_is_inactive(RID p_particles) const;
_FORCE_INLINE_ RS::ParticlesMode particles_get_mode(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, RS::PARTICLES_MODE_2D);
return particles->mode;
}
_FORCE_INLINE_ uint32_t particles_get_amount(RID p_particles, uint32_t &r_trail_divisor) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, 0);
if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) {
@@ -2201,21 +2200,21 @@ public:
}
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, 0);
return particles->has_collision_cache;
}
_FORCE_INLINE_ uint32_t particles_is_using_local_coords(RID p_particles) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, false);
return particles->use_local_coords;
}
_FORCE_INLINE_ RID particles_get_instance_buffer_uniform_set(RID p_particles, RID p_shader, uint32_t p_set) {
- Particles *particles = particles_owner.getornull(p_particles);
+ Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_COND_V(!particles, RID());
if (particles->particles_transforms_buffer_uniform_set.is_null()) {
_particles_update_buffers(particles);
diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp
index 82efa1318c..ffaf65ec35 100644
--- a/servers/rendering/renderer_rd/shader_rd.cpp
+++ b/servers/rendering/renderer_rd/shader_rd.cpp
@@ -292,7 +292,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
}
RS::ShaderNativeSourceCode ShaderRD::version_get_native_source_code(RID p_version) {
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
RS::ShaderNativeSourceCode source_code;
ERR_FAIL_COND_V(!version, source_code);
@@ -524,7 +524,7 @@ void ShaderRD::_compile_version(Version *p_version) {
void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines) {
ERR_FAIL_COND(is_compute);
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND(!version);
version->vertex_globals = p_vertex_globals.utf8();
version->fragment_globals = p_fragment_globals.utf8();
@@ -549,7 +549,7 @@ void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code
void ShaderRD::version_set_compute_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_compute_globals, const Vector<String> &p_custom_defines) {
ERR_FAIL_COND(!is_compute);
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND(!version);
version->compute_globals = p_compute_globals.utf8();
@@ -573,7 +573,7 @@ void ShaderRD::version_set_compute_code(RID p_version, const Map<String, String>
}
bool ShaderRD::version_is_valid(RID p_version) {
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND_V(!version, false);
if (version->dirty) {
@@ -585,7 +585,7 @@ bool ShaderRD::version_is_valid(RID p_version) {
bool ShaderRD::version_free(RID p_version) {
if (version_owner.owns(p_version)) {
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
_clear_version(version);
version_owner.free(p_version);
} else {
diff --git a/servers/rendering/renderer_rd/shader_rd.h b/servers/rendering/renderer_rd/shader_rd.h
index 529328f0ed..984b168659 100644
--- a/servers/rendering/renderer_rd/shader_rd.h
+++ b/servers/rendering/renderer_rd/shader_rd.h
@@ -141,7 +141,7 @@ public:
ERR_FAIL_INDEX_V(p_variant, variant_defines.size(), RID());
ERR_FAIL_COND_V(!variants_enabled[p_variant], RID());
- Version *version = version_owner.getornull(p_version);
+ Version *version = version_owner.get_or_null(p_version);
ERR_FAIL_COND_V(!version, RID());
if (version->dirty) {
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
index 8cb56fbc83..f0fb31a457 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
@@ -524,7 +524,7 @@ vec4 fog_process(vec3 vertex) {
}
}
- float fog_amount = 1.0 - exp(min(0.0, vertex.z * scene_data.fog_density));
+ float fog_amount = 1.0 - exp(min(0.0, -length(vertex) * scene_data.fog_density));
if (abs(scene_data.fog_height_density) > 0.001) {
float y = (scene_data.camera_matrix * vec4(vertex, 1.0)).y;
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
index c3c4139450..750ec5f00a 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
@@ -550,7 +550,7 @@ vec4 fog_process(vec3 vertex) {
}
}
- float fog_amount = 1.0 - exp(min(0.0, vertex.z * scene_data.fog_density));
+ float fog_amount = 1.0 - exp(min(0.0, -length(vertex) * scene_data.fog_density));
if (abs(scene_data.fog_height_density) > 0.001) {
float y = (scene_data.camera_matrix * vec4(vertex, 1.0)).y;
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index a4e4715292..705e72c13d 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -47,7 +47,7 @@ void RendererSceneCull::camera_initialize(RID p_rid) {
}
void RendererSceneCull::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);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::PERSPECTIVE;
camera->fov = p_fovy_degrees;
@@ -56,7 +56,7 @@ void RendererSceneCull::camera_set_perspective(RID p_camera, float p_fovy_degree
}
void RendererSceneCull::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::ORTHOGONAL;
camera->size = p_size;
@@ -65,7 +65,7 @@ void RendererSceneCull::camera_set_orthogonal(RID p_camera, float p_size, float
}
void RendererSceneCull::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);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::FRUSTUM;
camera->size = p_size;
@@ -75,32 +75,32 @@ void RendererSceneCull::camera_set_frustum(RID p_camera, float p_size, Vector2 p
}
void RendererSceneCull::camera_set_transform(RID p_camera, const Transform3D &p_transform) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->transform = p_transform.orthonormalized();
}
void RendererSceneCull::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->visible_layers = p_layers;
}
void RendererSceneCull::camera_set_environment(RID p_camera, RID p_env) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->env = p_env;
}
void RendererSceneCull::camera_set_camera_effects(RID p_camera, RID p_fx) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->effects = p_fx;
}
void RendererSceneCull::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
camera->vaspect = p_enable;
}
@@ -354,7 +354,7 @@ RID RendererSceneCull::scenario_allocate() {
void RendererSceneCull::scenario_initialize(RID p_rid) {
scenario_owner.initialize_rid(p_rid);
- Scenario *scenario = scenario_owner.getornull(p_rid);
+ Scenario *scenario = scenario_owner.get_or_null(p_rid);
scenario->self = p_rid;
scenario->reflection_probe_shadow_atlas = scene_render->shadow_atlas_create();
@@ -373,25 +373,25 @@ void RendererSceneCull::scenario_initialize(RID p_rid) {
}
void RendererSceneCull::scenario_set_environment(RID p_scenario, RID p_environment) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->environment = p_environment;
}
void RendererSceneCull::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->camera_effects = p_camera_effects;
}
void RendererSceneCull::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->fallback_environment = p_environment;
}
void RendererSceneCull::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
}
@@ -401,13 +401,13 @@ bool RendererSceneCull::is_scenario(RID p_scenario) const {
}
RID RendererSceneCull::scenario_get_environment(RID p_scenario) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, RID());
return scenario->environment;
}
void RendererSceneCull::scenario_remove_viewport_visibility_mask(RID p_scenario, RID p_viewport) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
if (!scenario->viewport_visibility_masks.has(p_viewport)) {
return;
@@ -419,7 +419,7 @@ void RendererSceneCull::scenario_remove_viewport_visibility_mask(RID p_scenario,
}
void RendererSceneCull::scenario_add_viewport_visibility_mask(RID p_scenario, RID p_viewport) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
ERR_FAIL_COND(scenario->viewport_visibility_masks.has(p_viewport));
@@ -459,7 +459,7 @@ RID RendererSceneCull::instance_allocate() {
}
void RendererSceneCull::instance_initialize(RID p_rid) {
instance_owner.initialize_rid(p_rid);
- Instance *instance = instance_owner.getornull(p_rid);
+ Instance *instance = instance_owner.get_or_null(p_rid);
instance->self = p_rid;
}
@@ -493,7 +493,7 @@ void RendererSceneCull::_instance_update_mesh_instance(Instance *p_instance) {
}
void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
Scenario *scenario = instance->scenario;
@@ -710,7 +710,7 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) {
}
void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->scenario) {
@@ -772,7 +772,7 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
}
if (p_scenario.is_valid()) {
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND(!scenario);
instance->scenario = scenario;
@@ -805,7 +805,7 @@ void RendererSceneCull::instance_set_scenario(RID p_instance, RID p_scenario) {
}
void RendererSceneCull::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->layer_mask = p_mask;
@@ -820,7 +820,7 @@ void RendererSceneCull::instance_set_layer_mask(RID p_instance, uint32_t p_mask)
}
void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D &p_transform) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->transform == p_transform) {
@@ -845,14 +845,14 @@ void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D
}
void RendererSceneCull::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->object_id = p_id;
}
void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->update_item.in_list()) {
@@ -865,7 +865,7 @@ void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_sh
}
void RendererSceneCull::instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->base_type == RS::INSTANCE_MESH) {
@@ -881,7 +881,7 @@ void RendererSceneCull::instance_set_surface_override_material(RID p_instance, i
}
void RendererSceneCull::instance_set_visible(RID p_instance, bool p_visible) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->visible == p_visible) {
@@ -926,7 +926,7 @@ inline bool is_geometry_instance(RenderingServer::InstanceType p_type) {
}
void RendererSceneCull::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
@@ -951,7 +951,7 @@ void RendererSceneCull::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
}
void RendererSceneCull::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->skeleton == p_skeleton) {
@@ -976,7 +976,7 @@ void RendererSceneCull::instance_attach_skeleton(RID p_instance, RID p_skeleton)
}
void RendererSceneCull::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->extra_margin = p_margin;
@@ -985,7 +985,7 @@ void RendererSceneCull::instance_set_extra_visibility_margin(RID p_instance, rea
Vector<ObjectID> RendererSceneCull::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -1009,7 +1009,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_aabb(const AABB &p_aabb, RID
Vector<ObjectID> RendererSceneCull::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);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -1032,7 +1032,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_ray(const Vector3 &p_from, co
Vector<ObjectID> RendererSceneCull::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
Vector<ObjectID> instances;
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
const_cast<RendererSceneCull *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -1056,7 +1056,7 @@ Vector<ObjectID> RendererSceneCull::instances_cull_convex(const Vector<Plane> &p
}
void RendererSceneCull::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
//ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK));
@@ -1131,7 +1131,7 @@ void RendererSceneCull::instance_geometry_set_flag(RID p_instance, RS::InstanceF
}
void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->cast_shadows = p_shadow_casting_setting;
@@ -1161,7 +1161,7 @@ void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instanc
}
void RendererSceneCull::instance_geometry_set_material_override(RID p_instance, RID p_material) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->material_override = p_material;
@@ -1174,7 +1174,7 @@ void RendererSceneCull::instance_geometry_set_material_override(RID p_instance,
}
void RendererSceneCull::instance_geometry_set_visibility_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->visibility_range_begin = p_min;
@@ -1194,7 +1194,7 @@ void RendererSceneCull::instance_geometry_set_visibility_range(RID p_instance, f
}
void RendererSceneCull::instance_set_visibility_parent(RID p_instance, RID p_parent_instance) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
Instance *old_parent = instance->visibility_parent;
@@ -1207,7 +1207,7 @@ void RendererSceneCull::instance_set_visibility_parent(RID p_instance, RID p_par
instance->visibility_parent = nullptr;
}
- Instance *parent = instance_owner.getornull(p_parent_instance);
+ Instance *parent = instance_owner.get_or_null(p_parent_instance);
ERR_FAIL_COND(p_parent_instance.is_valid() && !parent);
if (parent) {
@@ -1312,7 +1312,7 @@ void RendererSceneCull::_update_instance_visibility_dependencies(Instance *p_ins
}
void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
if (instance->lightmap) {
@@ -1321,7 +1321,7 @@ void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lig
instance->lightmap = nullptr;
}
- Instance *lightmap_instance = instance_owner.getornull(p_lightmap);
+ Instance *lightmap_instance = instance_owner.get_or_null(p_lightmap);
instance->lightmap = lightmap_instance;
instance->lightmap_uv_scale = p_lightmap_uv_scale;
@@ -1342,7 +1342,7 @@ void RendererSceneCull::instance_geometry_set_lightmap(RID p_instance, RID p_lig
}
void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
instance->lod_bias = p_lod_bias;
@@ -1354,7 +1354,7 @@ void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_l
}
void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) {
- Instance *instance = instance_owner.getornull(p_instance);
+ Instance *instance = instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
ERR_FAIL_COND(p_value.get_type() == Variant::OBJECT);
@@ -1377,7 +1377,7 @@ void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, c
}
Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const {
- const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.getornull(p_instance);
+ const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
if (instance->instance_shader_parameters.has(p_parameter)) {
@@ -1387,7 +1387,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance
}
Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const {
- const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.getornull(p_instance);
+ const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
if (instance->instance_shader_parameters.has(p_parameter)) {
@@ -1397,7 +1397,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(
}
void RendererSceneCull::instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const {
- const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.getornull(p_instance);
+ const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
ERR_FAIL_COND(!instance);
const_cast<RendererSceneCull *>(this)->update_dirty_instances();
@@ -2354,7 +2354,7 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons
void RendererSceneCull::render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, RID p_viewport, Size2 p_viewport_size, float p_screen_lod_threshold, RID p_shadow_atlas, Ref<XRInterface> &p_xr_interface, RenderInfo *r_render_info) {
#ifndef _3D_DISABLED
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
ERR_FAIL_COND(!camera);
RendererSceneRender::CameraData camera_data;
@@ -2747,9 +2747,9 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
}
void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_camera_data, RID p_render_buffers, RID p_environment, RID p_force_camera_effects, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, bool p_using_shadows, RendererScene::RenderInfo *r_render_info) {
- Instance *render_reflection_probe = instance_owner.getornull(p_reflection_probe); //if null, not rendering to it
+ Instance *render_reflection_probe = instance_owner.get_or_null(p_reflection_probe); //if null, not rendering to it
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
render_pass++;
@@ -3103,12 +3103,12 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c
}
RID RendererSceneCull::_render_get_environment(RID p_camera, RID p_scenario) {
- Camera *camera = camera_owner.getornull(p_camera);
+ Camera *camera = camera_owner.get_or_null(p_camera);
if (camera && scene_render->is_environment(camera->env)) {
return camera->env;
}
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
if (!scenario) {
return RID();
}
@@ -3125,7 +3125,7 @@ RID RendererSceneCull::_render_get_environment(RID p_camera, RID p_scenario) {
void RendererSceneCull::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) {
#ifndef _3D_DISABLED
- Scenario *scenario = scenario_owner.getornull(p_scenario);
+ Scenario *scenario = scenario_owner.get_or_null(p_scenario);
RID environment;
if (scenario->environment.is_valid()) {
@@ -3750,7 +3750,7 @@ bool RendererSceneCull::free(RID p_rid) {
camera_owner.free(p_rid);
} else if (scenario_owner.owns(p_rid)) {
- Scenario *scenario = scenario_owner.getornull(p_rid);
+ Scenario *scenario = scenario_owner.get_or_null(p_rid);
while (scenario->instances.first()) {
instance_set_scenario(scenario->instances.first()->self()->self, RID());
@@ -3771,7 +3771,7 @@ bool RendererSceneCull::free(RID p_rid) {
update_dirty_instances();
- Instance *instance = instance_owner.getornull(p_rid);
+ Instance *instance = instance_owner.get_or_null(p_rid);
instance_geometry_set_lightmap(p_rid, RID(), Rect2(), 0);
instance_set_scenario(p_rid, RID());
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index 8af2049ab3..2c07929357 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -554,7 +554,7 @@ void RendererViewport::draw_viewports() {
}
if (vp->update_mode == RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE) {
- Viewport *parent = viewport_owner.getornull(vp->parent);
+ Viewport *parent = viewport_owner.get_or_null(vp->parent);
if (parent && parent->last_pass == draw_viewports_pass) {
visible = true;
}
@@ -671,7 +671,7 @@ RID RendererViewport::viewport_allocate() {
void RendererViewport::viewport_initialize(RID p_rid) {
viewport_owner.initialize_rid(p_rid);
- Viewport *viewport = viewport_owner.getornull(p_rid);
+ Viewport *viewport = viewport_owner.get_or_null(p_rid);
viewport->self = p_rid;
viewport->render_target = RSG::storage->render_target_create();
viewport->shadow_atlas = RSG::scene->shadow_atlas_create();
@@ -679,7 +679,7 @@ void RendererViewport::viewport_initialize(RID p_rid) {
}
void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->use_xr == p_use_xr) {
@@ -691,7 +691,7 @@ void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
}
void RendererViewport::viewport_set_scale_3d(RID p_viewport, RenderingServer::ViewportScale3D p_scale_3d) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->scale_3d == p_scale_3d) {
@@ -720,7 +720,7 @@ uint32_t RendererViewport::Viewport::get_view_count() {
void RendererViewport::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);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->size = Size2(p_width, p_height);
@@ -732,7 +732,7 @@ void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_heig
}
void RendererViewport::viewport_set_active(RID p_viewport, bool p_active) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_active) {
@@ -745,21 +745,21 @@ void RendererViewport::viewport_set_active(RID p_viewport, bool p_active) {
}
void RendererViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->parent = p_parent_viewport;
}
void RendererViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->clear_mode = p_clear_mode;
}
void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_screen != DisplayServer::INVALID_WINDOW_ID) {
@@ -785,7 +785,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_
}
void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (p_enable == viewport->viewport_render_direct_to_screen) {
@@ -809,21 +809,21 @@ void RendererViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool
}
void RendererViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->update_mode = p_mode;
}
RID RendererViewport::viewport_get_texture(RID p_viewport) const {
- const Viewport *viewport = viewport_owner.getornull(p_viewport);
+ const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
return RSG::storage->render_target_get_texture(viewport->render_target);
}
RID RendererViewport::viewport_get_occluder_debug_texture(RID p_viewport) const {
- const Viewport *viewport = viewport_owner.getornull(p_viewport);
+ const Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
if (viewport->use_occlusion_culling && viewport->debug_draw == RenderingServer::VIEWPORT_DEBUG_DRAW_OCCLUDERS) {
@@ -833,35 +833,35 @@ RID RendererViewport::viewport_get_occluder_debug_texture(RID p_viewport) const
}
void RendererViewport::viewport_set_disable_2d(RID p_viewport, bool p_disable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->disable_2d = p_disable;
}
void RendererViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->disable_environment = p_disable;
}
void RendererViewport::viewport_set_disable_3d(RID p_viewport, bool p_disable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->disable_3d = p_disable;
}
void RendererViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->camera = p_camera;
}
void RendererViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->scenario.is_valid()) {
@@ -875,11 +875,11 @@ void RendererViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
}
void RendererViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(viewport->canvas_map.has(p_canvas));
- RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas);
+ RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->viewports.insert(p_viewport);
@@ -890,10 +890,10 @@ void RendererViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
}
void RendererViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
- RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas);
+ RendererCanvasCull::Canvas *canvas = RSG::canvas->canvas_owner.get_or_null(p_canvas);
ERR_FAIL_COND(!canvas);
viewport->canvas_map.erase(p_canvas);
@@ -901,7 +901,7 @@ void RendererViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
}
void RendererViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
@@ -909,7 +909,7 @@ void RendererViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canva
}
void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
RSG::storage->render_target_set_flag(viewport->render_target, RendererStorage::RENDER_TARGET_TRANSPARENT, p_enabled);
@@ -917,14 +917,14 @@ void RendererViewport::viewport_set_transparent_background(RID p_viewport, bool
}
void RendererViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->global_transform = p_transform;
}
void RendererViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
@@ -933,7 +933,7 @@ void RendererViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas
}
void RendererViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size, bool p_16_bits) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->shadow_atlas_size = p_size;
@@ -943,14 +943,14 @@ void RendererViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size
}
void RendererViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
RSG::scene->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
}
void RendererViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->msaa == p_msaa) {
@@ -961,7 +961,7 @@ void RendererViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa
}
void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::ViewportScreenSpaceAA p_mode) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->screen_space_aa == p_mode) {
@@ -972,7 +972,7 @@ void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::Viewport
}
void RendererViewport::viewport_set_use_debanding(RID p_viewport, bool p_use_debanding) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->use_debanding == p_use_debanding) {
@@ -983,7 +983,7 @@ void RendererViewport::viewport_set_use_debanding(RID p_viewport, bool p_use_deb
}
void RendererViewport::viewport_set_use_occlusion_culling(RID p_viewport, bool p_use_occlusion_culling) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
if (viewport->use_occlusion_culling == p_use_occlusion_culling) {
@@ -1018,7 +1018,7 @@ void RendererViewport::viewport_set_occlusion_culling_build_quality(RS::Viewport
}
void RendererViewport::viewport_set_lod_threshold(RID p_viewport, float p_pixels) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->lod_threshold = p_pixels;
@@ -1027,7 +1027,7 @@ void RendererViewport::viewport_set_lod_threshold(RID p_viewport, float p_pixels
int RendererViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfoType p_type, RS::ViewportRenderInfo p_info) {
ERR_FAIL_INDEX_V(p_info, RS::VIEWPORT_RENDER_INFO_MAX, -1);
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
if (!viewport) {
return 0; //there should be a lock here..
}
@@ -1036,62 +1036,62 @@ int RendererViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRende
}
void RendererViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->debug_draw = p_draw;
}
void RendererViewport::viewport_set_measure_render_time(RID p_viewport, bool p_enable) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->measure_render_time = p_enable;
}
float RendererViewport::viewport_get_measured_render_time_cpu(RID p_viewport) const {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, 0);
return double(viewport->time_cpu_end - viewport->time_cpu_begin) / 1000.0;
}
float RendererViewport::viewport_get_measured_render_time_gpu(RID p_viewport) const {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND_V(!viewport, 0);
return double((viewport->time_gpu_end - viewport->time_gpu_begin) / 1000) / 1000.0;
}
void RendererViewport::viewport_set_snap_2d_transforms_to_pixel(RID p_viewport, bool p_enabled) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->snap_2d_transforms_to_pixel = p_enabled;
}
void RendererViewport::viewport_set_snap_2d_vertices_to_pixel(RID p_viewport, bool p_enabled) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->snap_2d_vertices_to_pixel = p_enabled;
}
void RendererViewport::viewport_set_default_canvas_item_texture_filter(RID p_viewport, RS::CanvasItemTextureFilter p_filter) {
ERR_FAIL_COND_MSG(p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, "Viewport does not accept DEFAULT as texture filter (it's the topmost choice already).)");
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->texture_filter = p_filter;
}
void RendererViewport::viewport_set_default_canvas_item_texture_repeat(RID p_viewport, RS::CanvasItemTextureRepeat p_repeat) {
ERR_FAIL_COND_MSG(p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, "Viewport does not accept DEFAULT as texture repeat (it's the topmost choice already).)");
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->texture_repeat = p_repeat;
}
void RendererViewport::viewport_set_sdf_oversize_and_scale(RID p_viewport, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) {
- Viewport *viewport = viewport_owner.getornull(p_viewport);
+ Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);
RSG::storage->render_target_set_sdf_size_and_scale(viewport->render_target, p_size, p_scale);
@@ -1099,7 +1099,7 @@ void RendererViewport::viewport_set_sdf_oversize_and_scale(RID p_viewport, RS::V
bool RendererViewport::free(RID p_rid) {
if (viewport_owner.owns(p_rid)) {
- Viewport *viewport = viewport_owner.getornull(p_rid);
+ Viewport *viewport = viewport_owner.get_or_null(p_rid);
RSG::storage->free(viewport->render_target);
RSG::scene->free(viewport->shadow_atlas);
@@ -1132,7 +1132,7 @@ void RendererViewport::handle_timestamp(String p_timestamp, uint64_t p_cpu_time,
return;
}
- Viewport *viewport = viewport_owner.getornull(*vp);
+ Viewport *viewport = viewport_owner.get_or_null(*vp);
if (!viewport) {
return;
}
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 1b04a6e5e2..579f8abbe6 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -295,7 +295,7 @@ public:
AABB aabb;
struct LOD {
- float edge_length;
+ float edge_length = 0.0f;
Vector<uint8_t> index_data;
};
Vector<LOD> lods;
diff --git a/servers/xr/xr_interface_extension.cpp b/servers/xr/xr_interface_extension.cpp
index 315442fc57..7fdf90770d 100644
--- a/servers/xr/xr_interface_extension.cpp
+++ b/servers/xr/xr_interface_extension.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "xr_interface_extension.h"
+#include "servers/rendering/renderer_rd/renderer_storage_rd.h"
#include "servers/rendering/renderer_storage.h"
#include "servers/rendering/rendering_server_globals.h"
@@ -246,17 +247,21 @@ void XRInterfaceExtension::notification(int p_what) {
}
RID XRInterfaceExtension::get_render_target_texture(RID p_render_target) {
- RendererStorage *storage = RSG::storage;
- ERR_FAIL_NULL_V_MSG(storage, RID(), "Renderer storage not setup");
+ // In due time this will need to be enhance to return the correct INTERNAL RID for the chosen rendering engine.
+ // So once a GLES driver is implemented we'll return that and the implemented plugin needs to handle this correctly too.
+ RendererStorageRD *rd_storage = RendererStorageRD::base_singleton;
+ ERR_FAIL_NULL_V_MSG(rd_storage, RID(), "Renderer storage not setup");
- return storage->render_target_get_texture(p_render_target);
+ return rd_storage->render_target_get_rd_texture(p_render_target);
}
/*
RID XRInterfaceExtension::get_render_target_depth(RID p_render_target) {
- RendererStorage *storage = RSG::storage;
- ERR_FAIL_NULL_V_MSG(storage, RID(), "Renderer storage not setup");
+ // TODO implement this, the problem is that our depth texture isn't part of our render target as it is used for 3D rendering only
+ // but we don't have access to our render buffers from here....
+ RendererSceneRenderRD * rd_scene = ?????;
+ ERR_FAIL_NULL_V_MSG(rd_scene, RID(), "Renderer scene render not setup");
- return storage->render_target_get_depth(p_render_target);
+ return rd_scene->render_buffers_get_depth_texture(????????????);
}
*/
diff --git a/tests/test_physics_2d.cpp b/tests/test_physics_2d.cpp
index f63b866c3e..f6619db8fd 100644
--- a/tests/test_physics_2d.cpp
+++ b/tests/test_physics_2d.cpp
@@ -199,7 +199,7 @@ protected:
if (mb.is_valid()) {
if (mb->is_pressed()) {
- Point2 p(mb->get_position().x, mb->get_position().y);
+ Point2 p = mb->get_position();
if (mb->get_button_index() == 1) {
ray_to = p;
diff --git a/tests/test_physics_3d.cpp b/tests/test_physics_3d.cpp
index 3d1dad6545..d839ae26b7 100644
--- a/tests/test_physics_3d.cpp
+++ b/tests/test_physics_3d.cpp
@@ -361,7 +361,7 @@ public:
RID mesh_instance = vs->instance_create2(capsule_mesh, scenario);
character = ps->body_create();
- ps->body_set_mode(character, PhysicsServer3D::BODY_MODE_DYNAMIC_LOCKED);
+ ps->body_set_mode(character, PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR);
ps->body_set_space(character, space);
//todo add space
ps->body_add_shape(character, capsule_shape);
diff --git a/tests/test_translation.h b/tests/test_translation.h
index 52ff49bf9b..93c53bbbc9 100644
--- a/tests/test_translation.h
+++ b/tests/test_translation.h
@@ -35,6 +35,10 @@
#include "core/string/translation.h"
#include "core/string/translation_po.h"
+#ifdef TOOLS_ENABLED
+#include "editor/import/resource_importer_csv_translation.h"
+#endif
+
#include "thirdparty/doctest/doctest.h"
namespace TestTranslation {
@@ -145,6 +149,33 @@ TEST_CASE("[OptimizedTranslation] Generate from Translation and read messages")
CHECK(messages.size() == 0);
}
+#ifdef TOOLS_ENABLED
+TEST_CASE("[Translation] CSV import") {
+ Ref<ResourceImporterCSVTranslation> import_csv_translation = memnew(ResourceImporterCSVTranslation);
+
+ Map<StringName, Variant> options;
+ options["compress"] = false;
+ options["delimiter"] = 0;
+
+ List<String> gen_files;
+
+ Error result = import_csv_translation->import(TestUtils::get_data_path("translations.csv"),
+ "", options, nullptr, &gen_files);
+ CHECK(result == OK);
+ CHECK(gen_files.size() == 2);
+
+ for (const String &file : gen_files) {
+ Ref<Translation> translation = ResourceLoader::load(file);
+ CHECK(translation.is_valid());
+ TranslationServer::get_singleton()->add_translation(translation);
+ }
+
+ TranslationServer::get_singleton()->set_locale("de");
+
+ CHECK(Object().tr("GOOD_MORNING", "") == "Guten Morgen");
+}
+#endif // TOOLS_ENABLED
+
} // namespace TestTranslation
#endif // TEST_TRANSLATION_H
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 990bd30320..3d32609088 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -20,13 +20,15 @@ Files extracted from upstream source:
## bullet
- Upstream: https://github.com/bulletphysics/bullet3
-- Version: 3.08 (df09fd9ed37e365ceae884ca7f620b61607dae2e, 2020)
+- Version: 3.17 (ebe1916b90acae8b13cd8c6b637d8327cdc64e94, 2021)
- License: zlib
Files extracted from upstream source:
-- src/* apart from CMakeLists.txt and premake4.lua files
-- LICENSE.txt
+- `src/*` apart from CMakeLists.txt and premake4.lua files
+- `LICENSE.txt`, and `VERSION` as `VERSION.txt`
+
+Includes a warning fix which should be upstreamed soon (see patch in `patches`).
## certs
@@ -371,7 +373,9 @@ Files extracted from upstream repository:
- `LICENSE.md`.
An [experimental upstream feature](https://github.com/zeux/meshoptimizer/tree/simplify-attr),
-has been backported, see patch in `patches` directory.
+has been backported. On top of that, it was modified to report only distance error metrics
+instead of a combination of distance and attribute errors. Patches for both changes can be
+found in the `patches` directory.
## miniupnpc
@@ -422,10 +426,6 @@ Collection of single-file libraries used in Godot components.
* Upstream: https://research.activision.com/publications/archives/fast-filtering-of-reflection-probes
File coeffs_const_8.txt (retrieved April 2020)
* License: MIT
-- `easing_equations.cpp`
- * Upstream: http://robertpenner.com/easing/ via https://github.com/jesusgollonet/ofpennereasing (modified to fit Godot types)
- * Version: git (af72c147c3a74e7e872aa28c7e2abfcced04fdce, 2008) + Godot types and style changes
- * License: BSD-3-Clause
- `fastlz.{c,h}`
* Upstream: https://github.com/ariya/FastLZ
* Version: 0.5.0 (4f20f54d46f5a6dd4fae4def134933369b7602d2, 2020)
diff --git a/thirdparty/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp b/thirdparty/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp
index c79623bd57..6873a95d90 100644
--- a/thirdparty/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp
+++ b/thirdparty/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp
@@ -80,6 +80,7 @@ struct ClipVertex
btVector3 v;
int id;
//b2ContactID id;
+ //b2ContactID id;
};
#define b2Dot(a, b) (a).dot(b)
diff --git a/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h b/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
index e085c40892..dbe82fd61f 100644
--- a/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
+++ b/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
@@ -24,6 +24,7 @@ subject to the following restrictions:
#define WANTS_DEACTIVATION 3
#define DISABLE_DEACTIVATION 4
#define DISABLE_SIMULATION 5
+#define FIXED_BASE_MULTI_BODY 6
struct btBroadphaseProxy;
class btCollisionShape;
@@ -304,7 +305,7 @@ public:
SIMD_FORCE_INLINE bool isActive() const
{
- return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
+ return ((getActivationState() != FIXED_BASE_MULTI_BODY) && (getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
}
void setRestitution(btScalar rest)
diff --git a/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
index 71184f36ac..f74dcabc54 100644
--- a/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
+++ b/thirdparty/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
@@ -1037,7 +1037,7 @@ struct btSingleSweepCallback : public btBroadphaseRayCallback
m_castShape(castShape)
{
btVector3 unnormalizedRayDir = (m_convexToTrans.getOrigin() - m_convexFromTrans.getOrigin());
- btVector3 rayDir = unnormalizedRayDir.normalized();
+ btVector3 rayDir = unnormalizedRayDir.fuzzyZero() ? btVector3(btScalar(0.0), btScalar(0.0), btScalar(0.0)) : unnormalizedRayDir.normalized();
///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT
m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0];
m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1];
@@ -1294,9 +1294,7 @@ public:
btVector3 normalColor(1, 1, 0);
m_debugDrawer->drawLine(center, center + normal, normalColor);
}
- m_debugDrawer->drawLine(wv0, wv1, m_color);
- m_debugDrawer->drawLine(wv1, wv2, m_color);
- m_debugDrawer->drawLine(wv2, wv0, m_color);
+ m_debugDrawer->drawTriangle(wv0, wv1, wv2, m_color, 1.0);
}
};
diff --git a/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
index cab6980b65..01bf7f67f5 100644
--- a/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
+++ b/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
@@ -18,12 +18,57 @@ subject to the following restrictions:
#include "LinearMath/btTransformUtil.h"
btHeightfieldTerrainShape::btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength,
+ const float* heightfieldData, btScalar minHeight, btScalar maxHeight,
+ int upAxis, bool flipQuadEdges)
+ : m_userValue3(0), m_triangleInfoMap(0)
+{
+ initialize(heightStickWidth, heightStickLength, heightfieldData,
+ /*heightScale=*/1, minHeight, maxHeight, upAxis, PHY_FLOAT,
+ flipQuadEdges);
+}
+
+btHeightfieldTerrainShape::btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength, const double* heightfieldData,
+ btScalar minHeight, btScalar maxHeight, int upAxis, bool flipQuadEdges)
+ : m_userValue3(0), m_triangleInfoMap(0)
+{
+ initialize(heightStickWidth, heightStickLength, heightfieldData,
+ /*heightScale=*/1, minHeight, maxHeight, upAxis, PHY_DOUBLE,
+ flipQuadEdges);
+}
+
+btHeightfieldTerrainShape::btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength, const short* heightfieldData, btScalar heightScale,
+ btScalar minHeight, btScalar maxHeight, int upAxis, bool flipQuadEdges)
+ : m_userValue3(0), m_triangleInfoMap(0)
+{
+ initialize(heightStickWidth, heightStickLength, heightfieldData,
+ heightScale, minHeight, maxHeight, upAxis, PHY_SHORT,
+ flipQuadEdges);
+}
+
+btHeightfieldTerrainShape::btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength, const unsigned char* heightfieldData, btScalar heightScale,
+ btScalar minHeight, btScalar maxHeight, int upAxis, bool flipQuadEdges)
+ : m_userValue3(0), m_triangleInfoMap(0)
+{
+ initialize(heightStickWidth, heightStickLength, heightfieldData,
+ heightScale, minHeight, maxHeight, upAxis, PHY_UCHAR,
+ flipQuadEdges);
+}
+
+btHeightfieldTerrainShape::btHeightfieldTerrainShape(
int heightStickWidth, int heightStickLength, const void* heightfieldData,
btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis,
PHY_ScalarType hdt, bool flipQuadEdges)
:m_userValue3(0),
m_triangleInfoMap(0)
{
+ // legacy constructor: Assumes PHY_FLOAT means btScalar.
+#ifdef BT_USE_DOUBLE_PRECISION
+ if (hdt == PHY_FLOAT) hdt = PHY_DOUBLE;
+#endif
initialize(heightStickWidth, heightStickLength, heightfieldData,
heightScale, minHeight, maxHeight, upAxis, hdt,
flipQuadEdges);
@@ -33,9 +78,12 @@ btHeightfieldTerrainShape::btHeightfieldTerrainShape(int heightStickWidth, int h
: m_userValue3(0),
m_triangleInfoMap(0)
{
- // legacy constructor: support only float or unsigned char,
- // and min height is zero
+ // legacy constructor: support only btScalar or unsigned char data,
+ // and min height is zero.
PHY_ScalarType hdt = (useFloatData) ? PHY_FLOAT : PHY_UCHAR;
+#ifdef BT_USE_DOUBLE_PRECISION
+ if (hdt == PHY_FLOAT) hdt = PHY_DOUBLE;
+#endif
btScalar minHeight = 0.0f;
// previously, height = uchar * maxHeight / 65535.
@@ -59,7 +107,7 @@ void btHeightfieldTerrainShape::initialize(
// btAssert(heightScale) -- do we care? Trust caller here
btAssert(minHeight <= maxHeight); // && "bad min/max height");
btAssert(upAxis >= 0 && upAxis < 3); // && "bad upAxis--should be in range [0,2]");
- btAssert(hdt != PHY_UCHAR || hdt != PHY_FLOAT || hdt != PHY_SHORT); // && "Bad height data type enum");
+ btAssert(hdt != PHY_UCHAR || hdt != PHY_FLOAT || hdt != PHY_DOUBLE || hdt != PHY_SHORT); // && "Bad height data type enum");
// initialize member variables
m_shapeType = TERRAIN_SHAPE_PROXYTYPE;
@@ -152,6 +200,12 @@ btHeightfieldTerrainShape::getRawHeightFieldValue(int x, int y) const
break;
}
+ case PHY_DOUBLE:
+ {
+ val = m_heightfieldDataDouble[(y * m_heightStickWidth) + x];
+ break;
+ }
+
case PHY_UCHAR:
{
unsigned char heightFieldValue = m_heightfieldDataUnsignedChar[(y * m_heightStickWidth) + x];
@@ -232,6 +286,30 @@ getQuantized(
return (int)(x + 0.5);
}
+// Equivalent to std::minmax({a, b, c}).
+// Performs at most 3 comparisons.
+static btHeightfieldTerrainShape::Range minmaxRange(btScalar a, btScalar b, btScalar c)
+{
+ if (a > b)
+ {
+ if (b > c)
+ return btHeightfieldTerrainShape::Range(c, a);
+ else if (a > c)
+ return btHeightfieldTerrainShape::Range(b, a);
+ else
+ return btHeightfieldTerrainShape::Range(b, c);
+ }
+ else
+ {
+ if (a > c)
+ return btHeightfieldTerrainShape::Range(c, b);
+ else if (b > c)
+ return btHeightfieldTerrainShape::Range(a, b);
+ else
+ return btHeightfieldTerrainShape::Range(a, c);
+ }
+}
+
/// given input vector, return quantized version
/**
This routine is basically determining the gridpoint indices for a given
@@ -334,7 +412,8 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
}
// TODO If m_vboundsGrid is available, use it to determine if we really need to process this area
-
+
+ const Range aabbUpRange(aabbMin[m_upAxis], aabbMax[m_upAxis]);
for (int j = startJ; j < endJ; j++)
{
for (int x = startX; x < endX; x++)
@@ -349,29 +428,51 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
if (m_flipQuadEdges || (m_useDiamondSubdivision && !((j + x) & 1)) || (m_useZigzagSubdivision && !(j & 1)))
{
- //first triangle
getVertex(x, j, vertices[indices[0]]);
getVertex(x, j + 1, vertices[indices[1]]);
getVertex(x + 1, j + 1, vertices[indices[2]]);
- callback->processTriangle(vertices, 2 * x, j);
- //second triangle
- // getVertex(x,j,vertices[0]);//already got this vertex before, thanks to Danny Chapman
- getVertex(x + 1, j + 1, vertices[indices[1]]);
+
+ // Skip triangle processing if the triangle is out-of-AABB.
+ Range upRange = minmaxRange(vertices[0][m_upAxis], vertices[1][m_upAxis], vertices[2][m_upAxis]);
+
+ if (upRange.overlaps(aabbUpRange))
+ callback->processTriangle(vertices, 2 * x, j);
+
+ // already set: getVertex(x, j, vertices[indices[0]])
+
+ // equivalent to: getVertex(x + 1, j + 1, vertices[indices[1]]);
+ vertices[indices[1]] = vertices[indices[2]];
+
getVertex(x + 1, j, vertices[indices[2]]);
- callback->processTriangle(vertices, 2 * x+1, j);
+ upRange.min = btMin(upRange.min, vertices[indices[2]][m_upAxis]);
+ upRange.max = btMax(upRange.max, vertices[indices[2]][m_upAxis]);
+
+ if (upRange.overlaps(aabbUpRange))
+ callback->processTriangle(vertices, 2 * x + 1, j);
}
else
{
- //first triangle
getVertex(x, j, vertices[indices[0]]);
getVertex(x, j + 1, vertices[indices[1]]);
getVertex(x + 1, j, vertices[indices[2]]);
- callback->processTriangle(vertices, 2 * x, j);
- //second triangle
- getVertex(x + 1, j, vertices[indices[0]]);
- //getVertex(x,j+1,vertices[1]);
+
+ // Skip triangle processing if the triangle is out-of-AABB.
+ Range upRange = minmaxRange(vertices[0][m_upAxis], vertices[1][m_upAxis], vertices[2][m_upAxis]);
+
+ if (upRange.overlaps(aabbUpRange))
+ callback->processTriangle(vertices, 2 * x, j);
+
+ // already set: getVertex(x, j + 1, vertices[indices[1]]);
+
+ // equivalent to: getVertex(x + 1, j, vertices[indices[0]]);
+ vertices[indices[0]] = vertices[indices[2]];
+
getVertex(x + 1, j + 1, vertices[indices[2]]);
- callback->processTriangle(vertices, 2 * x+1, j);
+ upRange.min = btMin(upRange.min, vertices[indices[2]][m_upAxis]);
+ upRange.max = btMax(upRange.max, vertices[indices[2]][m_upAxis]);
+
+ if (upRange.overlaps(aabbUpRange))
+ callback->processTriangle(vertices, 2 * x + 1, j);
}
}
}
@@ -846,4 +947,4 @@ void btHeightfieldTerrainShape::buildAccelerator(int chunkSize)
void btHeightfieldTerrainShape::clearAccelerator()
{
m_vboundsGrid.clear();
-} \ No newline at end of file
+}
diff --git a/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h b/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
index 2cf3c00721..7e251fa71e 100644
--- a/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
+++ b/thirdparty/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
@@ -50,17 +50,15 @@ subject to the following restrictions:
The heightfield heights are determined from the data type used for the
heightfieldData array.
- - PHY_UCHAR: height at a point is the uchar value at the
+ - unsigned char: height at a point is the uchar value at the
grid point, multipled by heightScale. uchar isn't recommended
because of its inability to deal with negative values, and
low resolution (8-bit).
- - PHY_SHORT: height at a point is the short int value at that grid
+ - short: height at a point is the short int value at that grid
point, multipled by heightScale.
- - PHY_FLOAT: height at a point is the float value at that grid
- point. heightScale is ignored when using the float heightfield
- data type.
+ - float or dobule: height at a point is the value at that grid point.
Whatever the caller specifies as minHeight and maxHeight will be honored.
The class will not inspect the heightfield to discover the actual minimum
@@ -75,6 +73,14 @@ btHeightfieldTerrainShape : public btConcaveShape
public:
struct Range
{
+ Range() {}
+ Range(btScalar min, btScalar max) : min(min), max(max) {}
+
+ bool overlaps(const Range& other) const
+ {
+ return !(min > other.max || max < other.min);
+ }
+
btScalar min;
btScalar max;
};
@@ -95,7 +101,8 @@ protected:
union {
const unsigned char* m_heightfieldDataUnsignedChar;
const short* m_heightfieldDataShort;
- const btScalar* m_heightfieldDataFloat;
+ const float* m_heightfieldDataFloat;
+ const double* m_heightfieldDataDouble;
const void* m_heightfieldDataUnknown;
};
@@ -135,11 +142,33 @@ protected:
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
- /// preferred constructor
+ /// preferred constructors
+ btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength,
+ const float* heightfieldData, btScalar minHeight, btScalar maxHeight,
+ int upAxis, bool flipQuadEdges);
+ btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength,
+ const double* heightfieldData, btScalar minHeight, btScalar maxHeight,
+ int upAxis, bool flipQuadEdges);
+ btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength,
+ const short* heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight,
+ int upAxis, bool flipQuadEdges);
+ btHeightfieldTerrainShape(
+ int heightStickWidth, int heightStickLength,
+ const unsigned char* heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight,
+ int upAxis, bool flipQuadEdges);
+
+ /// legacy constructor
/**
This constructor supports a range of heightfield
data types, and allows for a non-zero minimum height value.
heightScale is needed for any integer-based heightfield data types.
+
+ This legacy constructor considers `PHY_FLOAT` to mean `btScalar`.
+ With `BT_USE_DOUBLE_PRECISION`, it will expect `heightfieldData`
+ to be double-precision.
*/
btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength,
const void* heightfieldData, btScalar heightScale,
@@ -150,7 +179,7 @@ public:
/// legacy constructor
/**
The legacy constructor assumes the heightfield has a minimum height
- of zero. Only unsigned char or floats are supported. For legacy
+ of zero. Only unsigned char or btScalar data are supported. For legacy
compatibility reasons, heightScale is calculated as maxHeight / 65535
(and is only used when useFloatData = false).
*/
@@ -218,4 +247,4 @@ public:
}
};
-#endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H \ No newline at end of file
+#endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp
index 7cb92fa3b4..d7588aedc8 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp
@@ -33,8 +33,8 @@
namespace
{
-const btScalar SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2)
-const btScalar SLEEP_TIMEOUT = btScalar(2); // in seconds
+const btScalar INITIAL_SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2)
+const btScalar INITIAL_SLEEP_TIMEOUT = btScalar(2); // in seconds
} // namespace
void btMultiBody::spatialTransform(const btMatrix3x3 &rotation_matrix, // rotates vectors in 'from' frame to vectors in 'to' frame
@@ -110,6 +110,9 @@ btMultiBody::btMultiBody(int n_links,
m_canSleep(canSleep),
m_canWakeup(true),
m_sleepTimer(0),
+ m_sleepEpsilon(INITIAL_SLEEP_EPSILON),
+ m_sleepTimeout(INITIAL_SLEEP_TIMEOUT),
+
m_userObjectPointer(0),
m_userIndex2(-1),
m_userIndex(-1),
@@ -1411,7 +1414,7 @@ void btMultiBody::solveImatrix(const btSpatialForceVector &rhs, btSpatialMotionV
}
}
-void btMultiBody::mulMatrix(btScalar *pA, btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const
+void btMultiBody::mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const
{
for (int row = 0; row < rowsA; row++)
{
@@ -2104,10 +2107,10 @@ void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep)
motion += m_realBuf[i] * m_realBuf[i];
}
- if (motion < SLEEP_EPSILON)
+ if (motion < m_sleepEpsilon)
{
m_sleepTimer += timestep;
- if (m_sleepTimer > SLEEP_TIMEOUT)
+ if (m_sleepTimer > m_sleepTimeout)
{
goToSleep();
}
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h
index 5a3efc9414..345970d261 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h
@@ -545,7 +545,10 @@ public:
{
m_canWakeup = canWakeup;
}
- bool isAwake() const { return m_awake; }
+ bool isAwake() const
+ {
+ return m_awake;
+ }
void wakeUp();
void goToSleep();
void checkMotionAndSleepIfRequired(btScalar timestep);
@@ -726,6 +729,17 @@ public:
bool isLinkAndAllAncestorsKinematic(const int i) const;
+ void setSleepThreshold(btScalar sleepThreshold)
+ {
+ m_sleepEpsilon = sleepThreshold;
+ }
+
+ void setSleepTimeout(btScalar sleepTimeout)
+ {
+ this->m_sleepTimeout = sleepTimeout;
+ }
+
+
private:
btMultiBody(const btMultiBody &); // not implemented
void operator=(const btMultiBody &); // not implemented
@@ -745,7 +759,7 @@ private:
}
}
- void mulMatrix(btScalar * pA, btScalar * pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const;
+ void mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const;
private:
btMultiBodyLinkCollider *m_baseCollider; //can be NULL
@@ -801,6 +815,8 @@ private:
bool m_canSleep;
bool m_canWakeup;
btScalar m_sleepTimer;
+ btScalar m_sleepEpsilon;
+ btScalar m_sleepTimeout;
void *m_userObjectPointer;
int m_userIndex2;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
index 1ba5861145..00d5fd5609 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
@@ -61,7 +61,8 @@ btScalar btMultiBodyConstraint::fillMultiBodyConstraint(btMultiBodySolverConstra
btScalar lowerLimit, btScalar upperLimit,
bool angConstraint,
btScalar relaxation,
- bool isFriction, btScalar desiredVelocity, btScalar cfmSlip)
+ bool isFriction, btScalar desiredVelocity, btScalar cfmSlip,
+ btScalar damping)
{
solverConstraint.m_multiBodyA = m_bodyA;
solverConstraint.m_multiBodyB = m_bodyB;
@@ -348,7 +349,7 @@ btScalar btMultiBodyConstraint::fillMultiBodyConstraint(btMultiBodySolverConstra
{
btScalar positionalError = 0.f;
- btScalar velocityError = desiredVelocity - rel_vel; // * damping;
+ btScalar velocityError = (desiredVelocity - rel_vel) * damping;
btScalar erp = infoGlobal.m_erp2;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h
index 4a6007ee3e..1aaa07b69e 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h
@@ -94,7 +94,7 @@ protected:
bool angConstraint = false,
btScalar relaxation = 1.f,
- bool isFriction = false, btScalar desiredVelocity = 0, btScalar cfmSlip = 0);
+ bool isFriction = false, btScalar desiredVelocity = 0, btScalar cfmSlip = 0, btScalar damping = 1.0);
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
index fef95f0c4e..e7af332eb3 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
@@ -137,7 +137,14 @@ void btMultiBodyDynamicsWorld::updateActivationState(btScalar timeStep)
btMultiBodyLinkCollider* col = body->getBaseCollider();
if (col && col->getActivationState() == ACTIVE_TAG)
{
- col->setActivationState(WANTS_DEACTIVATION);
+ if (body->hasFixedBase())
+ {
+ col->setActivationState(FIXED_BASE_MULTI_BODY);
+ } else
+ {
+ col->setActivationState(WANTS_DEACTIVATION);
+ }
+
col->setDeactivationTime(0.f);
}
for (int b = 0; b < body->getNumLinks(); b++)
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
index 4372489fa1..fec9b03213 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
@@ -43,6 +43,7 @@ void btMultiBodyJointMotor::finalizeMultiDof()
unsigned int offset = 6 + (m_bodyA->getLink(m_linkA).m_dofOffset + linkDoF);
// row 0: the lower bound
+ // row 0: the lower bound
jacobianA(0)[offset] = 1;
m_numDofsFinalized = m_jacSizeBoth;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp
index 5c20d2a0d4..00a7ef3579 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp
@@ -26,10 +26,13 @@ btMultiBodySphericalJointMotor::btMultiBodySphericalJointMotor(btMultiBody* body
: btMultiBodyConstraint(body, body, link, body->getLink(link).m_parent, 3, true, MULTIBODY_CONSTRAINT_SPHERICAL_MOTOR),
m_desiredVelocity(0, 0, 0),
m_desiredPosition(0,0,0,1),
- m_kd(1.),
- m_kp(0.2),
+ m_use_multi_dof_params(false),
+ m_kd(1., 1., 1.),
+ m_kp(0.2, 0.2, 0.2),
m_erp(1),
- m_rhsClamp(SIMD_INFINITY)
+ m_rhsClamp(SIMD_INFINITY),
+ m_maxAppliedImpulseMultiDof(maxMotorImpulse, maxMotorImpulse, maxMotorImpulse),
+ m_damping(1.0, 1.0, 1.0)
{
m_maxAppliedImpulse = maxMotorImpulse;
@@ -45,6 +48,7 @@ void btMultiBodySphericalJointMotor::finalizeMultiDof()
unsigned int offset = 6 + (m_bodyA->getLink(m_linkA).m_dofOffset + linkDoF);
// row 0: the lower bound
+ // row 0: the lower bound
jacobianA(0)[offset] = 1;
m_numDofsFinalized = m_jacSizeBoth;
@@ -138,7 +142,8 @@ btQuaternion relRot = currentQuat.inverse() * desiredQuat;
btScalar currentVelocity = m_bodyA->getJointVelMultiDof(m_linkA)[dof];
btScalar desiredVelocity = this->m_desiredVelocity[row];
- btScalar velocityError = desiredVelocity - currentVelocity;
+ double kd = m_use_multi_dof_params ? m_kd[row % 3] : m_kd[0];
+ btScalar velocityError = (desiredVelocity - currentVelocity) * kd;
btMatrix3x3 frameAworld;
frameAworld.setIdentity();
@@ -151,12 +156,16 @@ btQuaternion relRot = currentQuat.inverse() * desiredQuat;
case btMultibodyLink::eSpherical:
{
btVector3 constraintNormalAng = frameAworld.getColumn(row % 3);
- posError = m_kp*angleDiff[row % 3];
+ double kp = m_use_multi_dof_params ? m_kp[row % 3] : m_kp[0];
+ posError = kp*angleDiff[row % 3];
+ double max_applied_impulse = m_use_multi_dof_params ? m_maxAppliedImpulseMultiDof[row % 3] : m_maxAppliedImpulse;
fillMultiBodyConstraint(constraintRow, data, 0, 0, constraintNormalAng,
btVector3(0,0,0), dummy, dummy,
posError,
infoGlobal,
- -m_maxAppliedImpulse, m_maxAppliedImpulse, true);
+ -max_applied_impulse, max_applied_impulse, true,
+ 1.0, false, 0, 0,
+ m_damping[row % 3]);
constraintRow.m_orgConstraint = this;
constraintRow.m_orgDofIndex = row;
break;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h
index 621beab5a4..bdeccc2e24 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h
@@ -26,10 +26,13 @@ class btMultiBodySphericalJointMotor : public btMultiBodyConstraint
protected:
btVector3 m_desiredVelocity;
btQuaternion m_desiredPosition;
- btScalar m_kd;
- btScalar m_kp;
+ bool m_use_multi_dof_params;
+ btVector3 m_kd;
+ btVector3 m_kp;
btScalar m_erp;
btScalar m_rhsClamp; //maximum error
+ btVector3 m_maxAppliedImpulseMultiDof;
+ btVector3 m_damping;
public:
btMultiBodySphericalJointMotor(btMultiBody* body, int link, btScalar maxMotorImpulse);
@@ -44,16 +47,32 @@ public:
btMultiBodyJacobianData& data,
const btContactSolverInfo& infoGlobal);
- virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.f)
+ virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.0)
+ {
+ m_desiredVelocity = velTarget;
+ m_kd = btVector3(kd, kd, kd);
+ m_use_multi_dof_params = false;
+ }
+
+ virtual void setVelocityTargetMultiDof(const btVector3& velTarget, const btVector3& kd = btVector3(1.0, 1.0, 1.0))
{
m_desiredVelocity = velTarget;
m_kd = kd;
+ m_use_multi_dof_params = true;
}
- virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp = 1.f)
+ virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp =1.f)
+ {
+ m_desiredPosition = posTarget;
+ m_kp = btVector3(kp, kp, kp);
+ m_use_multi_dof_params = false;
+ }
+
+ virtual void setPositionTargetMultiDof(const btQuaternion& posTarget, const btVector3& kp = btVector3(1.f, 1.f, 1.f))
{
m_desiredPosition = posTarget;
m_kp = kp;
+ m_use_multi_dof_params = true;
}
virtual void setErp(btScalar erp)
@@ -68,6 +87,28 @@ public:
{
m_rhsClamp = rhsClamp;
}
+
+ btScalar getMaxAppliedImpulseMultiDof(int i) const
+ {
+ return m_maxAppliedImpulseMultiDof[i];
+ }
+
+ void setMaxAppliedImpulseMultiDof(const btVector3& maxImp)
+ {
+ m_maxAppliedImpulseMultiDof = maxImp;
+ m_use_multi_dof_params = true;
+ }
+
+ btScalar getDamping(int i) const
+ {
+ return m_damping[i];
+ }
+
+ void setDamping(const btVector3& damping)
+ {
+ m_damping = damping;
+ }
+
virtual void debugDraw(class btIDebugDraw* drawer)
{
//todo(erwincoumans)
diff --git a/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp b/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
index 5d864f2757..ed4e0b686d 100644
--- a/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
+++ b/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
@@ -532,7 +532,7 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
J_transpose = J.transpose();
btMatrixXu& tmp = m_scratchTmp;
-
+ //Minv.printMatrix("Minv=");
{
{
BT_PROFILE("J*Minv");
@@ -543,7 +543,7 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
m_A = tmp * J_transpose;
}
}
-
+ //J.printMatrix("J");
if (1)
{
// add cfm to the diagonal of m_A
diff --git a/thirdparty/bullet/BulletSoftBody/btDeformableBodySolver.cpp b/thirdparty/bullet/BulletSoftBody/btDeformableBodySolver.cpp
index 4b11fccecb..e81680f019 100644
--- a/thirdparty/bullet/BulletSoftBody/btDeformableBodySolver.cpp
+++ b/thirdparty/bullet/BulletSoftBody/btDeformableBodySolver.cpp
@@ -405,6 +405,10 @@ void btDeformableBodySolver::predictMotion(btScalar solverdt)
for (int i = 0; i < m_softBodies.size(); ++i)
{
btSoftBody* psb = m_softBodies[i];
+ /* Clear contacts */
+ psb->m_nodeRigidContacts.resize(0);
+ psb->m_faceRigidContacts.resize(0);
+ psb->m_faceNodeContacts.resize(0);
if (psb->isActive())
{
@@ -472,10 +476,6 @@ void btDeformableBodySolver::predictDeformableMotion(btSoftBody* psb, btScalar d
{
psb->updateFaceTree(true, true);
}
- /* Clear contacts */
- psb->m_nodeRigidContacts.resize(0);
- psb->m_faceRigidContacts.resize(0);
- psb->m_faceNodeContacts.resize(0);
/* Optimize dbvt's */
// psb->m_ndbvt.optimizeIncremental(1);
// psb->m_fdbvt.optimizeIncremental(1);
diff --git a/thirdparty/bullet/BulletSoftBody/btDeformableMousePickingForce.h b/thirdparty/bullet/BulletSoftBody/btDeformableMousePickingForce.h
index d218d96214..697408355c 100644
--- a/thirdparty/bullet/BulletSoftBody/btDeformableMousePickingForce.h
+++ b/thirdparty/bullet/BulletSoftBody/btDeformableMousePickingForce.h
@@ -29,7 +29,7 @@ class btDeformableMousePickingForce : public btDeformableLagrangianForce
public:
typedef btAlignedObjectArray<btVector3> TVStack;
- btDeformableMousePickingForce(btScalar k, btScalar d, const btSoftBody::Face& face, btVector3 mouse_pos, btScalar maxForce = 0.3) : m_elasticStiffness(k), m_dampingStiffness(d), m_face(face), m_mouse_pos(mouse_pos), m_maxForce(maxForce)
+ btDeformableMousePickingForce(btScalar k, btScalar d, const btSoftBody::Face& face, const btVector3& mouse_pos, btScalar maxForce = 0.3) : m_elasticStiffness(k), m_dampingStiffness(d), m_face(face), m_mouse_pos(mouse_pos), m_maxForce(maxForce)
{
}
diff --git a/thirdparty/bullet/BulletSoftBody/btSoftBody.h b/thirdparty/bullet/BulletSoftBody/btSoftBody.h
index f578487b8c..dfde8fd1e4 100644
--- a/thirdparty/bullet/BulletSoftBody/btSoftBody.h
+++ b/thirdparty/bullet/BulletSoftBody/btSoftBody.h
@@ -1317,8 +1317,8 @@ public:
}
for (int k = 0; k < m_faceNodeContacts.size(); ++k)
{
- int i = indices[k];
- btSoftBody::DeformableFaceNodeContact& c = m_faceNodeContacts[i];
+ int idx = indices[k];
+ btSoftBody::DeformableFaceNodeContact& c = m_faceNodeContacts[idx];
btSoftBody::Node* node = c.m_node;
btSoftBody::Face* face = c.m_face;
const btVector3& w = c.m_bary;
diff --git a/thirdparty/bullet/LinearMath/btIDebugDraw.h b/thirdparty/bullet/LinearMath/btIDebugDraw.h
index 82ec19a69b..df4db2ff5a 100644
--- a/thirdparty/bullet/LinearMath/btIDebugDraw.h
+++ b/thirdparty/bullet/LinearMath/btIDebugDraw.h
@@ -4,8 +4,8 @@ Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it freely,
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -21,7 +21,7 @@ subject to the following restrictions:
///The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
///Typical use case: create a debug drawer object, and assign it to a btCollisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld.
-///A class that implements the btIDebugDraw interface has to implement the drawLine method at a minimum.
+///A class that implements the btIDebugDraw interface will need to provide non-empty implementations of the the drawLine and getDebugMode methods at a minimum.
///For color arguments the X,Y,Z components refer to Red, Green and Blue each in the range [0..1]
class btIDebugDraw
{
diff --git a/thirdparty/bullet/LinearMath/btScalar.h b/thirdparty/bullet/LinearMath/btScalar.h
index 0402146af1..b239217bb6 100644
--- a/thirdparty/bullet/LinearMath/btScalar.h
+++ b/thirdparty/bullet/LinearMath/btScalar.h
@@ -25,7 +25,7 @@ subject to the following restrictions:
#include <float.h>
/* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/
-#define BT_BULLET_VERSION 308
+#define BT_BULLET_VERSION 317
inline int btGetVersion()
{
diff --git a/thirdparty/bullet/LinearMath/btSerializer.h b/thirdparty/bullet/LinearMath/btSerializer.h
index 4d1c760e24..f18442f23d 100644
--- a/thirdparty/bullet/LinearMath/btSerializer.h
+++ b/thirdparty/bullet/LinearMath/btSerializer.h
@@ -480,8 +480,8 @@ public:
}
buffer[9] = '3';
- buffer[10] = '0';
- buffer[11] = '8';
+ buffer[10] = '1';
+ buffer[11] = '7';
}
virtual void startSerialization()
@@ -499,7 +499,6 @@ public:
writeDNA();
//if we didn't pre-allocate a buffer, we need to create a contiguous buffer now
- int mysize = 0;
if (!m_totalSize)
{
if (m_buffer)
@@ -511,14 +510,12 @@ public:
unsigned char* currentPtr = m_buffer;
writeHeader(m_buffer);
currentPtr += BT_HEADER_LENGTH;
- mysize += BT_HEADER_LENGTH;
for (int i = 0; i < m_chunkPtrs.size(); i++)
{
int curLength = sizeof(btChunk) + m_chunkPtrs[i]->m_length;
memcpy(currentPtr, m_chunkPtrs[i], curLength);
btAlignedFree(m_chunkPtrs[i]);
currentPtr += curLength;
- mysize += curLength;
}
}
diff --git a/thirdparty/bullet/VERSION.txt b/thirdparty/bullet/VERSION.txt
new file mode 100644
index 0000000000..78c8a7428a
--- /dev/null
+++ b/thirdparty/bullet/VERSION.txt
@@ -0,0 +1 @@
+3.17
diff --git a/thirdparty/bullet/patches/bullet-fix-warnings.patch b/thirdparty/bullet/patches/bullet-fix-warnings.patch
new file mode 100644
index 0000000000..69cde1b16e
--- /dev/null
+++ b/thirdparty/bullet/patches/bullet-fix-warnings.patch
@@ -0,0 +1,42 @@
+diff --git a/thirdparty/bullet/BulletSoftBody/btSoftBody.h b/thirdparty/bullet/BulletSoftBody/btSoftBody.h
+index f578487b8c..dfde8fd1e4 100644
+--- a/thirdparty/bullet/BulletSoftBody/btSoftBody.h
++++ b/thirdparty/bullet/BulletSoftBody/btSoftBody.h
+@@ -1317,8 +1317,8 @@ public:
+ }
+ for (int k = 0; k < m_faceNodeContacts.size(); ++k)
+ {
+- int i = indices[k];
+- btSoftBody::DeformableFaceNodeContact& c = m_faceNodeContacts[i];
++ int idx = indices[k];
++ btSoftBody::DeformableFaceNodeContact& c = m_faceNodeContacts[idx];
+ btSoftBody::Node* node = c.m_node;
+ btSoftBody::Face* face = c.m_face;
+ const btVector3& w = c.m_bary;
+diff --git a/thirdparty/bullet/LinearMath/btSerializer.h b/thirdparty/bullet/LinearMath/btSerializer.h
+index ce4fc34e20..11592d2ccd 100644
+--- a/thirdparty/bullet/LinearMath/btSerializer.h
++++ b/thirdparty/bullet/LinearMath/btSerializer.h
+@@ -499,7 +499,6 @@ public:
+ writeDNA();
+
+ //if we didn't pre-allocate a buffer, we need to create a contiguous buffer now
+- int mysize = 0;
+ if (!m_totalSize)
+ {
+ if (m_buffer)
+@@ -511,14 +510,12 @@ public:
+ unsigned char* currentPtr = m_buffer;
+ writeHeader(m_buffer);
+ currentPtr += BT_HEADER_LENGTH;
+- mysize += BT_HEADER_LENGTH;
+ for (int i = 0; i < m_chunkPtrs.size(); i++)
+ {
+ int curLength = sizeof(btChunk) + m_chunkPtrs[i]->m_length;
+ memcpy(currentPtr, m_chunkPtrs[i], curLength);
+ btAlignedFree(m_chunkPtrs[i]);
+ currentPtr += curLength;
+- mysize += curLength;
+ }
+ }
+
diff --git a/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch b/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch
new file mode 100644
index 0000000000..54132a6c86
--- /dev/null
+++ b/thirdparty/meshoptimizer/patches/attribute-aware-simplify-distance-only-metric.patch
@@ -0,0 +1,176 @@
+diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp
+index 0f10ebef4b..cf5db4e119 100644
+--- a/thirdparty/meshoptimizer/simplifier.cpp
++++ b/thirdparty/meshoptimizer/simplifier.cpp
+@@ -20,7 +20,7 @@
+ #define TRACESTATS(i) (void)0
+ #endif
+
+-#define ATTRIBUTES 8
++#define ATTRIBUTES 3
+
+ // This work is based on:
+ // Michael Garland and Paul S. Heckbert. Surface simplification using quadric error metrics. 1997
+@@ -445,6 +445,7 @@ struct Collapse
+ float error;
+ unsigned int errorui;
+ };
++ float distance_error;
+ };
+
+ static float normalize(Vector3& v)
+@@ -525,6 +526,34 @@ static float quadricError(const Quadric& Q, const Vector3& v)
+ return fabsf(r) * s;
+ }
+
++static float quadricErrorNoAttributes(const Quadric& Q, const Vector3& v)
++{
++ float rx = Q.b0;
++ float ry = Q.b1;
++ float rz = Q.b2;
++
++ rx += Q.a10 * v.y;
++ ry += Q.a21 * v.z;
++ rz += Q.a20 * v.x;
++
++ rx *= 2;
++ ry *= 2;
++ rz *= 2;
++
++ rx += Q.a00 * v.x;
++ ry += Q.a11 * v.y;
++ rz += Q.a22 * v.z;
++
++ float r = Q.c;
++ r += rx * v.x;
++ r += ry * v.y;
++ r += rz * v.z;
++
++ float s = Q.w == 0.f ? 0.f : 1.f / Q.w;
++
++ return fabsf(r) * s;
++}
++
+ static void quadricFromPlane(Quadric& Q, float a, float b, float c, float d, float w)
+ {
+ float aw = a * w;
+@@ -680,7 +709,7 @@ static void quadricUpdateAttributes(Quadric& Q, const Vector3& p0, const Vector3
+ }
+ #endif
+
+-static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap)
++static void fillFaceQuadrics(Quadric* vertex_quadrics, Quadric* vertex_no_attrib_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap)
+ {
+ for (size_t i = 0; i < index_count; i += 3)
+ {
+@@ -690,6 +719,9 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+
+ Quadric Q;
+ quadricFromTriangle(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], 1.f);
++ quadricAdd(vertex_no_attrib_quadrics[remap[i0]], Q);
++ quadricAdd(vertex_no_attrib_quadrics[remap[i1]], Q);
++ quadricAdd(vertex_no_attrib_quadrics[remap[i2]], Q);
+
+ #if ATTRIBUTES
+ quadricUpdateAttributes(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], Q.w);
+@@ -700,7 +732,7 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+ }
+ }
+
+-static void fillEdgeQuadrics(Quadric* vertex_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap, const unsigned char* vertex_kind, const unsigned int* loop, const unsigned int* loopback)
++static void fillEdgeQuadrics(Quadric* vertex_quadrics, Quadric* vertex_no_attrib_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap, const unsigned char* vertex_kind, const unsigned int* loop, const unsigned int* loopback)
+ {
+ for (size_t i = 0; i < index_count; i += 3)
+ {
+@@ -744,6 +776,9 @@ static void fillEdgeQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
+
+ quadricAdd(vertex_quadrics[remap[i0]], Q);
+ quadricAdd(vertex_quadrics[remap[i1]], Q);
++
++ quadricAdd(vertex_no_attrib_quadrics[remap[i0]], Q);
++ quadricAdd(vertex_no_attrib_quadrics[remap[i1]], Q);
+ }
+ }
+ }
+@@ -848,7 +883,7 @@ static size_t pickEdgeCollapses(Collapse* collapses, const unsigned int* indices
+ return collapse_count;
+ }
+
+-static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const Vector3* vertex_positions, const Quadric* vertex_quadrics, const unsigned int* remap)
++static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const Vector3* vertex_positions, const Quadric* vertex_quadrics, const Quadric* vertex_no_attrib_quadrics, const unsigned int* remap)
+ {
+ for (size_t i = 0; i < collapse_count; ++i)
+ {
+@@ -868,10 +903,14 @@ static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const
+ float ei = quadricError(qi, vertex_positions[i1]);
+ float ej = quadricError(qj, vertex_positions[j1]);
+
++ const Quadric& naqi = vertex_no_attrib_quadrics[remap[i0]];
++ const Quadric& naqj = vertex_no_attrib_quadrics[remap[j0]];
++
+ // pick edge direction with minimal error
+ c.v0 = ei <= ej ? i0 : j0;
+ c.v1 = ei <= ej ? i1 : j1;
+ c.error = ei <= ej ? ei : ej;
++ c.distance_error = ei <= ej ? quadricErrorNoAttributes(naqi, vertex_positions[i1]) : quadricErrorNoAttributes(naqj, vertex_positions[j1]);
+ }
+ }
+
+@@ -968,7 +1007,7 @@ static void sortEdgeCollapses(unsigned int* sort_order, const Collapse* collapse
+ }
+ }
+
+-static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char* collapse_locked, Quadric* vertex_quadrics, const Collapse* collapses, size_t collapse_count, const unsigned int* collapse_order, const unsigned int* remap, const unsigned int* wedge, const unsigned char* vertex_kind, const Vector3* vertex_positions, const EdgeAdjacency& adjacency, size_t triangle_collapse_goal, float error_limit, float& result_error)
++static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char* collapse_locked, Quadric* vertex_quadrics, Quadric* vertex_no_attrib_quadrics, const Collapse* collapses, size_t collapse_count, const unsigned int* collapse_order, const unsigned int* remap, const unsigned int* wedge, const unsigned char* vertex_kind, const Vector3* vertex_positions, const EdgeAdjacency& adjacency, size_t triangle_collapse_goal, float error_limit, float& result_error)
+ {
+ size_t edge_collapses = 0;
+ size_t triangle_collapses = 0;
+@@ -1030,6 +1069,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
+ assert(collapse_remap[r1] == r1);
+
+ quadricAdd(vertex_quadrics[r1], vertex_quadrics[r0]);
++ quadricAdd(vertex_no_attrib_quadrics[r1], vertex_no_attrib_quadrics[r0]);
+
+ if (vertex_kind[i0] == Kind_Complex)
+ {
+@@ -1067,7 +1107,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
+ triangle_collapses += (vertex_kind[i0] == Kind_Border) ? 1 : 2;
+ edge_collapses++;
+
+- result_error = result_error < c.error ? c.error : result_error;
++ result_error = result_error < c.distance_error ? c.distance_error : result_error;
+ }
+
+ #if TRACE
+@@ -1455,9 +1495,11 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
+
+ Quadric* vertex_quadrics = allocator.allocate<Quadric>(vertex_count);
+ memset(vertex_quadrics, 0, vertex_count * sizeof(Quadric));
++ Quadric* vertex_no_attrib_quadrics = allocator.allocate<Quadric>(vertex_count);
++ memset(vertex_no_attrib_quadrics, 0, vertex_count * sizeof(Quadric));
+
+- fillFaceQuadrics(vertex_quadrics, indices, index_count, vertex_positions, remap);
+- fillEdgeQuadrics(vertex_quadrics, indices, index_count, vertex_positions, remap, vertex_kind, loop, loopback);
++ fillFaceQuadrics(vertex_quadrics, vertex_no_attrib_quadrics, indices, index_count, vertex_positions, remap);
++ fillEdgeQuadrics(vertex_quadrics, vertex_no_attrib_quadrics, indices, index_count, vertex_positions, remap, vertex_kind, loop, loopback);
+
+ if (result != indices)
+ memcpy(result, indices, index_count * sizeof(unsigned int));
+@@ -1488,7 +1530,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
+ if (edge_collapse_count == 0)
+ break;
+
+- rankEdgeCollapses(edge_collapses, edge_collapse_count, vertex_positions, vertex_quadrics, remap);
++ rankEdgeCollapses(edge_collapses, edge_collapse_count, vertex_positions, vertex_quadrics, vertex_no_attrib_quadrics, remap);
+
+ #if TRACE > 1
+ dumpEdgeCollapses(edge_collapses, edge_collapse_count, vertex_kind);
+@@ -1507,7 +1549,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
+ printf("pass %d: ", int(pass_count++));
+ #endif
+
+- size_t collapses = performEdgeCollapses(collapse_remap, collapse_locked, vertex_quadrics, edge_collapses, edge_collapse_count, collapse_order, remap, wedge, vertex_kind, vertex_positions, adjacency, triangle_collapse_goal, error_limit, result_error);
++ size_t collapses = performEdgeCollapses(collapse_remap, collapse_locked, vertex_quadrics, vertex_no_attrib_quadrics, edge_collapses, edge_collapse_count, collapse_order, remap, wedge, vertex_kind, vertex_positions, adjacency, triangle_collapse_goal, error_limit, result_error);
+
+ // no edges can be collapsed any more due to hitting the error limit or triangle collapse limit
+ if (collapses == 0)
diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp
index 0f10ebef4b..cf5db4e119 100644
--- a/thirdparty/meshoptimizer/simplifier.cpp
+++ b/thirdparty/meshoptimizer/simplifier.cpp
@@ -20,7 +20,7 @@
#define TRACESTATS(i) (void)0
#endif
-#define ATTRIBUTES 8
+#define ATTRIBUTES 3
// This work is based on:
// Michael Garland and Paul S. Heckbert. Surface simplification using quadric error metrics. 1997
@@ -445,6 +445,7 @@ struct Collapse
float error;
unsigned int errorui;
};
+ float distance_error;
};
static float normalize(Vector3& v)
@@ -525,6 +526,34 @@ static float quadricError(const Quadric& Q, const Vector3& v)
return fabsf(r) * s;
}
+static float quadricErrorNoAttributes(const Quadric& Q, const Vector3& v)
+{
+ float rx = Q.b0;
+ float ry = Q.b1;
+ float rz = Q.b2;
+
+ rx += Q.a10 * v.y;
+ ry += Q.a21 * v.z;
+ rz += Q.a20 * v.x;
+
+ rx *= 2;
+ ry *= 2;
+ rz *= 2;
+
+ rx += Q.a00 * v.x;
+ ry += Q.a11 * v.y;
+ rz += Q.a22 * v.z;
+
+ float r = Q.c;
+ r += rx * v.x;
+ r += ry * v.y;
+ r += rz * v.z;
+
+ float s = Q.w == 0.f ? 0.f : 1.f / Q.w;
+
+ return fabsf(r) * s;
+}
+
static void quadricFromPlane(Quadric& Q, float a, float b, float c, float d, float w)
{
float aw = a * w;
@@ -680,7 +709,7 @@ static void quadricUpdateAttributes(Quadric& Q, const Vector3& p0, const Vector3
}
#endif
-static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap)
+static void fillFaceQuadrics(Quadric* vertex_quadrics, Quadric* vertex_no_attrib_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap)
{
for (size_t i = 0; i < index_count; i += 3)
{
@@ -690,6 +719,9 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
Quadric Q;
quadricFromTriangle(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], 1.f);
+ quadricAdd(vertex_no_attrib_quadrics[remap[i0]], Q);
+ quadricAdd(vertex_no_attrib_quadrics[remap[i1]], Q);
+ quadricAdd(vertex_no_attrib_quadrics[remap[i2]], Q);
#if ATTRIBUTES
quadricUpdateAttributes(Q, vertex_positions[i0], vertex_positions[i1], vertex_positions[i2], Q.w);
@@ -700,7 +732,7 @@ static void fillFaceQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
}
}
-static void fillEdgeQuadrics(Quadric* vertex_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap, const unsigned char* vertex_kind, const unsigned int* loop, const unsigned int* loopback)
+static void fillEdgeQuadrics(Quadric* vertex_quadrics, Quadric* vertex_no_attrib_quadrics, const unsigned int* indices, size_t index_count, const Vector3* vertex_positions, const unsigned int* remap, const unsigned char* vertex_kind, const unsigned int* loop, const unsigned int* loopback)
{
for (size_t i = 0; i < index_count; i += 3)
{
@@ -744,6 +776,9 @@ static void fillEdgeQuadrics(Quadric* vertex_quadrics, const unsigned int* indic
quadricAdd(vertex_quadrics[remap[i0]], Q);
quadricAdd(vertex_quadrics[remap[i1]], Q);
+
+ quadricAdd(vertex_no_attrib_quadrics[remap[i0]], Q);
+ quadricAdd(vertex_no_attrib_quadrics[remap[i1]], Q);
}
}
}
@@ -848,7 +883,7 @@ static size_t pickEdgeCollapses(Collapse* collapses, const unsigned int* indices
return collapse_count;
}
-static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const Vector3* vertex_positions, const Quadric* vertex_quadrics, const unsigned int* remap)
+static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const Vector3* vertex_positions, const Quadric* vertex_quadrics, const Quadric* vertex_no_attrib_quadrics, const unsigned int* remap)
{
for (size_t i = 0; i < collapse_count; ++i)
{
@@ -868,10 +903,14 @@ static void rankEdgeCollapses(Collapse* collapses, size_t collapse_count, const
float ei = quadricError(qi, vertex_positions[i1]);
float ej = quadricError(qj, vertex_positions[j1]);
+ const Quadric& naqi = vertex_no_attrib_quadrics[remap[i0]];
+ const Quadric& naqj = vertex_no_attrib_quadrics[remap[j0]];
+
// pick edge direction with minimal error
c.v0 = ei <= ej ? i0 : j0;
c.v1 = ei <= ej ? i1 : j1;
c.error = ei <= ej ? ei : ej;
+ c.distance_error = ei <= ej ? quadricErrorNoAttributes(naqi, vertex_positions[i1]) : quadricErrorNoAttributes(naqj, vertex_positions[j1]);
}
}
@@ -968,7 +1007,7 @@ static void sortEdgeCollapses(unsigned int* sort_order, const Collapse* collapse
}
}
-static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char* collapse_locked, Quadric* vertex_quadrics, const Collapse* collapses, size_t collapse_count, const unsigned int* collapse_order, const unsigned int* remap, const unsigned int* wedge, const unsigned char* vertex_kind, const Vector3* vertex_positions, const EdgeAdjacency& adjacency, size_t triangle_collapse_goal, float error_limit, float& result_error)
+static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char* collapse_locked, Quadric* vertex_quadrics, Quadric* vertex_no_attrib_quadrics, const Collapse* collapses, size_t collapse_count, const unsigned int* collapse_order, const unsigned int* remap, const unsigned int* wedge, const unsigned char* vertex_kind, const Vector3* vertex_positions, const EdgeAdjacency& adjacency, size_t triangle_collapse_goal, float error_limit, float& result_error)
{
size_t edge_collapses = 0;
size_t triangle_collapses = 0;
@@ -1030,6 +1069,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
assert(collapse_remap[r1] == r1);
quadricAdd(vertex_quadrics[r1], vertex_quadrics[r0]);
+ quadricAdd(vertex_no_attrib_quadrics[r1], vertex_no_attrib_quadrics[r0]);
if (vertex_kind[i0] == Kind_Complex)
{
@@ -1067,7 +1107,7 @@ static size_t performEdgeCollapses(unsigned int* collapse_remap, unsigned char*
triangle_collapses += (vertex_kind[i0] == Kind_Border) ? 1 : 2;
edge_collapses++;
- result_error = result_error < c.error ? c.error : result_error;
+ result_error = result_error < c.distance_error ? c.distance_error : result_error;
}
#if TRACE
@@ -1455,9 +1495,11 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
Quadric* vertex_quadrics = allocator.allocate<Quadric>(vertex_count);
memset(vertex_quadrics, 0, vertex_count * sizeof(Quadric));
+ Quadric* vertex_no_attrib_quadrics = allocator.allocate<Quadric>(vertex_count);
+ memset(vertex_no_attrib_quadrics, 0, vertex_count * sizeof(Quadric));
- fillFaceQuadrics(vertex_quadrics, indices, index_count, vertex_positions, remap);
- fillEdgeQuadrics(vertex_quadrics, indices, index_count, vertex_positions, remap, vertex_kind, loop, loopback);
+ fillFaceQuadrics(vertex_quadrics, vertex_no_attrib_quadrics, indices, index_count, vertex_positions, remap);
+ fillEdgeQuadrics(vertex_quadrics, vertex_no_attrib_quadrics, indices, index_count, vertex_positions, remap, vertex_kind, loop, loopback);
if (result != indices)
memcpy(result, indices, index_count * sizeof(unsigned int));
@@ -1488,7 +1530,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
if (edge_collapse_count == 0)
break;
- rankEdgeCollapses(edge_collapses, edge_collapse_count, vertex_positions, vertex_quadrics, remap);
+ rankEdgeCollapses(edge_collapses, edge_collapse_count, vertex_positions, vertex_quadrics, vertex_no_attrib_quadrics, remap);
#if TRACE > 1
dumpEdgeCollapses(edge_collapses, edge_collapse_count, vertex_kind);
@@ -1507,7 +1549,7 @@ size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned
printf("pass %d: ", int(pass_count++));
#endif
- size_t collapses = performEdgeCollapses(collapse_remap, collapse_locked, vertex_quadrics, edge_collapses, edge_collapse_count, collapse_order, remap, wedge, vertex_kind, vertex_positions, adjacency, triangle_collapse_goal, error_limit, result_error);
+ size_t collapses = performEdgeCollapses(collapse_remap, collapse_locked, vertex_quadrics, vertex_no_attrib_quadrics, edge_collapses, edge_collapse_count, collapse_order, remap, wedge, vertex_kind, vertex_positions, adjacency, triangle_collapse_goal, error_limit, result_error);
// no edges can be collapsed any more due to hitting the error limit or triangle collapse limit
if (collapses == 0)
diff --git a/thirdparty/misc/easing_equations.cpp b/thirdparty/misc/easing_equations.cpp
deleted file mode 100644
index ce32c1a362..0000000000
--- a/thirdparty/misc/easing_equations.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/**
- * Adapted from Penner Easing equations' C++ port.
- * Source: https://github.com/jesusgollonet/ofpennereasing
- * License: BSD-3-clause
- */
-
-#include "scene/animation/tween.h"
-
-const real_t pi = 3.1415926535898;
-
-///////////////////////////////////////////////////////////////////////////
-// linear
-///////////////////////////////////////////////////////////////////////////
-namespace linear {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- return c * t / d + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- return c * t / d + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- return c * t / d + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return c * t / d + b;
-}
-}; // namespace linear
-///////////////////////////////////////////////////////////////////////////
-// sine
-///////////////////////////////////////////////////////////////////////////
-namespace sine {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- return -c * cos(t / d * (pi / 2)) + c + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- return c * sin(t / d * (pi / 2)) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- return -c / 2 * (cos(pi * t / d) - 1) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace sine
-///////////////////////////////////////////////////////////////////////////
-// quint
-///////////////////////////////////////////////////////////////////////////
-namespace quint {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- return c * pow(t / d, 5) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- return c * (pow(t / d - 1, 5) + 1) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(t, 5) + b;
- return c / 2 * (pow(t - 2, 5) + 2) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace quint
-///////////////////////////////////////////////////////////////////////////
-// quart
-///////////////////////////////////////////////////////////////////////////
-namespace quart {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- return c * pow(t / d, 4) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- return -c * (pow(t / d - 1, 4) - 1) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(t, 4) + b;
- return -c / 2 * (pow(t - 2, 4) - 2) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace quart
-///////////////////////////////////////////////////////////////////////////
-// quad
-///////////////////////////////////////////////////////////////////////////
-namespace quad {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- return c * pow(t / d, 2) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- t = t / d;
- return -c * t * (t - 2) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(t, 2) + b;
- return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace quad
-///////////////////////////////////////////////////////////////////////////
-// expo
-///////////////////////////////////////////////////////////////////////////
-namespace expo {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- if (t == 0) return b;
- return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- if (t == d) return b + c;
- return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- if (t == 0) return b;
- if (t == d) return b + c;
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005;
- return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace expo
-///////////////////////////////////////////////////////////////////////////
-// elastic
-///////////////////////////////////////////////////////////////////////////
-namespace elastic {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- if (t == 0) return b;
- if ((t /= d) == 1) return b + c;
- float p = d * 0.3f;
- float a = c;
- float s = p / 4;
- float postFix = a * pow(2, 10 * (t -= 1)); // this is a fix, again, with post-increment operators
- return -(postFix * sin((t * d - s) * (2 * pi) / p)) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- if (t == 0) return b;
- if ((t /= d) == 1) return b + c;
- float p = d * 0.3f;
- float a = c;
- float s = p / 4;
- return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b);
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- if (t == 0) return b;
- if ((t /= d / 2) == 2) return b + c;
- float p = d * (0.3f * 1.5f);
- float a = c;
- float s = p / 4;
-
- if (t < 1) {
- float postFix = a * pow(2, 10 * (t -= 1)); // postIncrement is evil
- return -0.5f * (postFix * sin((t * d - s) * (2 * pi) / p)) + b;
- }
- float postFix = a * pow(2, -10 * (t -= 1)); // postIncrement is evil
- return postFix * sin((t * d - s) * (2 * pi) / p) * 0.5f + c + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace elastic
-///////////////////////////////////////////////////////////////////////////
-// cubic
-///////////////////////////////////////////////////////////////////////////
-namespace cubic {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- t /= d;
- return c * t * t * t + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- t = t / d - 1;
- return c * (t * t * t + 1) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- t /= d / 2;
- if (t < 1) return c / 2 * t * t * t + b;
- t -= 2;
- return c / 2 * (t * t * t + 2) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace cubic
-///////////////////////////////////////////////////////////////////////////
-// circ
-///////////////////////////////////////////////////////////////////////////
-namespace circ {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- t /= d;
- return -c * (sqrt(1 - t * t) - 1) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- t = t / d - 1;
- return c * sqrt(1 - t * t) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- t /= d / 2;
- if (t < 1) {
- return -c / 2 * (sqrt(1 - t * t) - 1) + b;
- }
- t -= 2;
- return c / 2 * (sqrt(1 - t * t) + 1) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace circ
-///////////////////////////////////////////////////////////////////////////
-// bounce
-///////////////////////////////////////////////////////////////////////////
-namespace bounce {
-static real_t out(real_t t, real_t b, real_t c, real_t d);
-
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- return c - out(d - t, 0, c, d) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- if ((t /= d) < (1 / 2.75f)) {
- return c * (7.5625f * t * t) + b;
- } else if (t < (2 / 2.75f)) {
- float postFix = t -= (1.5f / 2.75f);
- return c * (7.5625f * (postFix)*t + .75f) + b;
- } else if (t < (2.5 / 2.75)) {
- float postFix = t -= (2.25f / 2.75f);
- return c * (7.5625f * (postFix)*t + .9375f) + b;
- } else {
- float postFix = t -= (2.625f / 2.75f);
- return c * (7.5625f * (postFix)*t + .984375f) + b;
- }
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? in(t * 2, b, c / 2, d) : out((t * 2) - d, b + c / 2, c / 2, d);
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace bounce
-///////////////////////////////////////////////////////////////////////////
-// back
-///////////////////////////////////////////////////////////////////////////
-namespace back {
-static real_t in(real_t t, real_t b, real_t c, real_t d) {
- float s = 1.70158f;
- float postFix = t /= d;
- return c * (postFix)*t * ((s + 1) * t - s) + b;
-}
-
-static real_t out(real_t t, real_t b, real_t c, real_t d) {
- float s = 1.70158f;
- t = t / d - 1;
- return c * (t * t * ((s + 1) * t + s) + 1) + b;
-}
-
-static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
- float s = 1.70158f * 1.525f;
- t /= d / 2;
- if (t < 1) return c / 2 * (t * t * ((s + 1) * t - s)) + b;
- t -= 2;
- return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b;
-}
-
-static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
- return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
-}
-}; // namespace back
-
-Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = {
- { &linear::in, &linear::out, &linear::in_out, &linear::out_in },
- { &sine::in, &sine::out, &sine::in_out, &sine::out_in },
- { &quint::in, &quint::out, &quint::in_out, &quint::out_in },
- { &quart::in, &quart::out, &quart::in_out, &quart::out_in },
- { &quad::in, &quad::out, &quad::in_out, &quad::out_in },
- { &expo::in, &expo::out, &expo::in_out, &expo::out_in },
- { &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in },
- { &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in },
- { &circ::in, &circ::out, &circ::in_out, &circ::out_in },
- { &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in },
- { &back::in, &back::out, &back::in_out, &back::out_in },
-};
-
-real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) {
-
- interpolater cb = interpolaters[p_trans_type][p_ease_type];
- ERR_FAIL_COND_V(cb == NULL, b);
- return cb(t, b, c, d);
-}